mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-02 16:52:16 +09:00
widget module
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9031 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
249ba8c7f5
commit
2a8c16d4f9
13 changed files with 550 additions and 557 deletions
|
|
@ -1,4 +1,4 @@
|
|||
function doDisplaySkinColorset()
|
||||
function doDisplaySkinColorset(colorset)
|
||||
{
|
||||
var skin = jQuery('select[name=skin]').val();
|
||||
if(!skin) {
|
||||
|
|
@ -6,39 +6,39 @@ function doDisplaySkinColorset()
|
|||
return;
|
||||
}
|
||||
|
||||
function completeGetSkinColorset(ret_obj)
|
||||
{
|
||||
var sel = jQuery("select[name=colorset]").get(0);
|
||||
var length = sel.options.length;
|
||||
var selected_colorset = colorset;
|
||||
for(var i=0;i<length;i++) sel.remove(0);
|
||||
|
||||
if(!ret_obj["colorset_list"]) return;
|
||||
|
||||
var colorset_list = ret_obj["colorset_list"].split("\n");
|
||||
var selected_index = 0;
|
||||
for(var i=0;i<colorset_list.length;i++) {
|
||||
var tmp = colorset_list[i].split("|@|");
|
||||
if(selected_colorset && selected_colorset==tmp[0]) selected_index = i;
|
||||
var opt = new Option(tmp[1], tmp[0], false, false);
|
||||
sel.options.add(opt);
|
||||
}
|
||||
|
||||
sel.selectedIndex = selected_index;
|
||||
|
||||
doShowSkinColorset();
|
||||
}
|
||||
|
||||
var params = new Array();
|
||||
params["selected_widget"] = jQuery('input[name=selected_widget]').val();
|
||||
params["skin"] = skin;
|
||||
params["colorset"] = jQuery('select[name=colorset]').val();
|
||||
params["colorset"] = colorset;
|
||||
|
||||
var response_tags = new Array("error","message","colorset_list");
|
||||
|
||||
exec_xml("widget", "procWidgetGetColorsetList", params, completeGetSkinColorset, response_tags, params);
|
||||
}
|
||||
|
||||
function completeGetSkinColorset(ret_obj)
|
||||
{
|
||||
var sel = jQuery("select[name=colorset]").get(0);
|
||||
var length = sel.options.length;
|
||||
var selected_colorset = jQuery('select[name=colorset]').val();
|
||||
for(var i=0;i<length;i++) sel.remove(0);
|
||||
|
||||
if(!ret_obj["colorset_list"]) return;
|
||||
|
||||
var colorset_list = ret_obj["colorset_list"].split("\n");
|
||||
var selected_index = 0;
|
||||
for(var i=0;i<colorset_list.length;i++) {
|
||||
var tmp = colorset_list[i].split("|@|");
|
||||
if(selected_colorset && selected_colorset==tmp[0]) selected_index = i;
|
||||
var opt = new Option(tmp[1], tmp[0], false, false);
|
||||
sel.options.add(opt);
|
||||
}
|
||||
|
||||
sel.selectedIndex = selected_index;
|
||||
|
||||
doShowSkinColorset();
|
||||
}
|
||||
|
||||
function doHideSkinColorset()
|
||||
{
|
||||
jQuery('select[name=colorset]').parents('li').hide();
|
||||
|
|
@ -49,6 +49,141 @@ function doShowSkinColorset()
|
|||
jQuery('select[name=colorset]').parents('li').show();
|
||||
}
|
||||
|
||||
function completeGenerateCodeInPage(widget_code) {
|
||||
if(!opener || !widget_code) {
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
|
||||
opener.doAddWidgetCode(widget_code);
|
||||
window.close();
|
||||
}
|
||||
|
||||
var selected_node = null;
|
||||
|
||||
function getWidgetVars() {
|
||||
if(!opener || !opener.selectedWidget || !opener.selectedWidget.getAttribute("widget")) return;
|
||||
selected_node = opener.selectedWidget;
|
||||
|
||||
if(!xGetElementById('fo_widget').widgetstyle.value) {
|
||||
xGetElementById('fo_widget').widgetstyle.value = selected_node.getAttribute('widgetstyle');
|
||||
}
|
||||
|
||||
doFillWidgetVars();
|
||||
}
|
||||
|
||||
function doFillWidgetVars() {
|
||||
if(!opener || !opener.selectedWidget || !opener.selectedWidget.getAttribute("widget")) return;
|
||||
selected_node = opener.selectedWidget;
|
||||
|
||||
// 스킨과 컬러셋은 기본
|
||||
var skin = selected_node.getAttribute("skin");
|
||||
var colorset = selected_node.getAttribute("colorset");
|
||||
var widget_sequence = parseInt(selected_node.getAttribute("widget_sequence"),10);
|
||||
|
||||
var fo_widget = jQuery("#fo_widget");
|
||||
var fo_obj = xGetElementById("fo_widget");
|
||||
jQuery('#widget_skin').val(skin);
|
||||
|
||||
// 위젯 스타일 유지를 위한 hidden input 추가하고 값을 저장
|
||||
var attrs = selected_node.attributes;
|
||||
for (i=0; i< attrs.length ; i++){
|
||||
var name = attrs[i].name;
|
||||
var value = jQuery(selected_node).attr(name);
|
||||
if(value=='Array') continue;
|
||||
if(jQuery("[name="+name+"]",fo_widget).size()>0 || !value || name == 'style') continue;
|
||||
|
||||
var dummy = jQuery('<input type="hidden" name="'+name+'" >').val(value).appendTo("#fo_widget").get(0);
|
||||
}
|
||||
|
||||
// 위젯의 속성 설정
|
||||
var obj_list = new Array();
|
||||
jQuery('input,select,textarea','#fo_widget').each( function() {
|
||||
obj_list.push(this);
|
||||
});
|
||||
|
||||
for(var j=0;j<obj_list.length;j++) {
|
||||
var node = obj_list[j];
|
||||
if(node.name.indexOf('_')==0) continue;
|
||||
if(node.name == 'widgetstyle') continue;
|
||||
|
||||
var length = node.length;
|
||||
var type = node.type;
|
||||
if((typeof(type)=='undefined'||!type) && typeof(length)!='undefined' && typeof(node[0])!='undefined' && length>0) type = node[0].type;
|
||||
else length = 0;
|
||||
var name = node.name;
|
||||
|
||||
switch(type) {
|
||||
case "hidden" :
|
||||
case "text" :
|
||||
case "textarea" :
|
||||
var val = selected_node.getAttribute(name);
|
||||
if(!val) continue;
|
||||
var unescaped_val = unescape(val);
|
||||
if(!unescaped_val) node.value = val;
|
||||
else node.value = unescaped_val;
|
||||
break;
|
||||
case "checkbox" :
|
||||
if(selected_node.getAttribute(name)) {
|
||||
var val = selected_node.getAttribute(name).split(',');
|
||||
if(fo_obj[name].length) {
|
||||
for(var i=0;i<fo_obj[name].length;i++) {
|
||||
var v = fo_obj[name][i].value;
|
||||
for(var k=0;k<val.length;k++) {
|
||||
if(v == val[k]) {
|
||||
fo_obj[name][i].checked=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(fo_obj[name].value == val) fo_obj[name].checked =true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "select" :
|
||||
case "select-one" :
|
||||
var val = selected_node.getAttribute(name);
|
||||
var sel = fo_obj[name];
|
||||
if(!val) break;
|
||||
for(var i=0;i<sel.options.length;i++) {
|
||||
if(sel.options[i].value == val) sel.options[i].selected = true;
|
||||
else sel.options[i].selected = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var style = selected_node.getAttribute("style");
|
||||
if(typeof(style)=="object") style = style["cssText"];
|
||||
fo_obj.style.value = style;
|
||||
|
||||
fo_obj.widget_padding_left.value = selected_node.getAttribute("widget_padding_left");
|
||||
fo_obj.widget_padding_right.value = selected_node.getAttribute("widget_padding_right");
|
||||
fo_obj.widget_padding_bottom.value = selected_node.getAttribute("widget_padding_bottom");
|
||||
fo_obj.widget_padding_top.value = selected_node.getAttribute("widget_padding_top");
|
||||
|
||||
|
||||
// 컬러셋 설정
|
||||
if(skin && xGetElementById("widget_colorset") && xGetElementById("widget_colorset").options.length<1 && colorset) {
|
||||
doDisplaySkinColorset(colorset);
|
||||
}
|
||||
|
||||
// widget sequence 설정
|
||||
fo_obj.widget_sequence.value = widget_sequence;
|
||||
|
||||
xe.broadcast('MULTIORDER_SYNC');
|
||||
xe.broadcast('MODULELIST_SYNC');
|
||||
|
||||
jQuery('.filebox')
|
||||
.each(function(){
|
||||
var $this = jQuery(this);
|
||||
var src = $this.siblings('input').eq(0).val();
|
||||
if (src) $this.trigger('filebox.selected', [src]);
|
||||
})
|
||||
}
|
||||
|
||||
var $current_filebox;
|
||||
|
||||
jQuery(document).ready(function($){
|
||||
|
|
@ -69,7 +204,7 @@ jQuery(document).ready(function($){
|
|||
})
|
||||
.remove();
|
||||
|
||||
$(this).before('<img src="'+src+'" alt="" style="border: 1px solid #ccc; padding: 5px; max-height: 200px;"> <button class="filebox_del text" type="button">'+xe.lang.cmd_delete+'</button>');
|
||||
$(this).before('<img src="'+src+'" alt="" style="border: 1px solid #ccc; padding: 5px; max-height: 200px; max-width: 200px;"> <button class="filebox_del text" type="button">'+xe.lang.cmd_delete+'</button>');
|
||||
|
||||
$(this).siblings('input').val(src);
|
||||
|
||||
|
|
@ -133,4 +268,29 @@ jQuery(document).ready(function($){
|
|||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#fo_widget').bind('submit', function(){
|
||||
function on_complete(data){
|
||||
if (data.error){
|
||||
alert(data.message);
|
||||
return;
|
||||
}
|
||||
|
||||
completeGenerateCodeInPage(data.widget_code);
|
||||
}
|
||||
|
||||
var datas = $(this).serializeArray();
|
||||
var params = new Object();
|
||||
for(var i in datas){
|
||||
var data = datas[i];
|
||||
|
||||
if(/\[\]$/.test(data.name)) data.name = data.name.replace(/\[\]$/, '');
|
||||
if(params[data.name]) params[data.name] += '|@|' + data.value;
|
||||
else params[data.name] = data.value;
|
||||
}
|
||||
|
||||
$.exec_json('widget.procWidgetGenerateCodeInPage', params, on_complete);
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue