mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 11:44:10 +09:00
1 line
No EOL
6.8 KiB
JavaScript
1 line
No EOL
6.8 KiB
JavaScript
function doDisplaySkinColorset(a){function b(b){for(var c=jQuery("select[name=colorset]").get(0),d=c.options.length,e=a,f=0;d>f;f++)c.remove(0);if(b.colorset_list){for(var g=b.colorset_list.split("\n"),h=0,f=0;f<g.length;f++){var i=g[f].split("|@|");e&&e==i[0]&&(h=f);var j=new Option(i[1],i[0],!1,!1);c.options.add(j)}c.selectedIndex=h,doShowSkinColorset()}}var c=jQuery("select[name=skin]").val();if(!c)return void doHideSkinColorset();var d=[];d.selected_widget=jQuery("input[name=selected_widget]").val(),d.skin=c,d.colorset=a;var e=["error","message","colorset_list"];exec_xml("widget","procWidgetGetColorsetList",d,b,e,d)}function doHideSkinColorset(){jQuery("select[name=colorset]").closest(".x_control-group").hide()}function doShowSkinColorset(){jQuery("select[name=colorset]").closest(".x_control-group").show()}function completeGenerateCodeInPage(a){return opener&&a?(opener.doAddWidgetCode(a),void window.close()):void window.close()}function getWidgetVars(){opener&&opener.selectedWidget&&opener.selectedWidget.getAttribute("widget")&&(selected_node=opener.selectedWidget,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")){selected_node=opener.selectedWidget;var a=selected_node.getAttribute("skin"),b=selected_node.getAttribute("colorset"),c=parseInt(selected_node.getAttribute("widget_sequence"),10),d=jQuery("#fo_widget"),e=xGetElementById("fo_widget");jQuery("#widget_skin").val(a);var f=selected_node.attributes,g=["style","sizset","draggable","class"];for(q=0;q<f.length;q++){var h=f[q].name,i=jQuery(selected_node).attr(h);if("Array"!=i&&!(jQuery("[name="+h+"]",d).size()>0||!i||0===h.indexOf("sizcache")||jQuery.inArray(h,g)>-1)){jQuery('<input type="hidden" name="'+h+'" />').val(i).appendTo("#fo_widget").get(0)}}var j=[];jQuery("input,select,textarea","#fo_widget").each(function(){j.push(this)});for(var k=0;k<j.length;k++){var l=j[k];if(0!==l.name.indexOf("_")&&"widgetstyle"!=l.name&&"button"!=l.type&&""!==l.name){var m=l.length,n=l.type;("undefined"==typeof n||!n)&&"undefined"!=typeof m&&"undefined"!=typeof l[0]&&m>0?n=l[0].type:m=0;var h=l.name;switch(n){case"hidden":case"number":case"text":case"textarea":var o=selected_node.getAttribute(h);if(!o)continue;var p=unescape(o);l.value=p?p:o,jQuery("#"+h).val(l.value);break;case"radio":case"checkbox":if(selected_node.getAttribute(h)){var o=selected_node.getAttribute(h).split(",");if(e[h].length){for(var q=0;q<e[h].length;q++)for(var r=e[h][q].value,s=0;s<o.length;s++)if(r==o[s]){e[h][q].checked=!0;break}}else e[h].value==o&&(e[h].checked=!0)}break;case"select":case"select-one":var o=selected_node.getAttribute(h),t=e[h];if(!o)break;for(var q=0;q<t.options.length;q++)t.options[q].selected=t.options[q].value==o?!0:!1}}}var u=selected_node.getAttribute("style");"object"==typeof u&&(u=u.cssText),e.style.value=u,e.widget_padding_left.value=selected_node.getAttribute("widget_padding_left"),e.widget_padding_right.value=selected_node.getAttribute("widget_padding_right"),e.widget_padding_bottom.value=selected_node.getAttribute("widget_padding_bottom"),e.widget_padding_top.value=selected_node.getAttribute("widget_padding_top"),a&&xGetElementById("widget_colorset")&&xGetElementById("widget_colorset").options.length<1&&b&&doDisplaySkinColorset(b),e.widget_sequence.value=c,xe.broadcast("MULTIORDER_SYNC"),xe.broadcast("MODULELIST_SYNC"),xe.broadcast("MID_SYNC"),xe.broadcast("MULTILANG_SYNC"),jQuery(".filebox").each(function(){var a=jQuery(this),b=a.siblings("input").eq(0).val().split(",");b&&a.trigger("filebox.selected",[b])})}}var selected_node=null,$current_filebox;jQuery(document).ready(function($){$("select[name=skin]").next("input").bind("click",function(){doDisplaySkinColorset()}),doHideSkinColorset(),$(".filebox").bind("before-open.mw",function(){$("#filebox_upload").find("input[name=comment], input[name=addfile]").val("")}),$(".filebox").bind("filebox.selected",function(a,b){$(this).siblings().filter(function(){return"input"!=this.nodeName.toLowerCase()}).remove();var c="";if(b instanceof Object){for(var d=0;d<b.length;d++)if(b[d].id)if(c+='<img src="'+b[d].id+'" alt="" style="border:1px solid #ccc;padding:5px;max-height:200px;max-width:200px"> <button type="button" class="filebox_del x_icon-remove">'+xe.lang.cmd_delete+"</button> ",0===d)$(this).siblings("input").val(b[d].id);else{var e=$(this).siblings("input").val();$(this).siblings("input").val(e+","+b[d].id)}else if(b[d])if(c+='<img src="'+b[d]+'" alt="" style="border:1px solid #ccc;padding:5px;max-height:200px;max-width:200px"> <button type="button" class="filebox_del x_icon-remove">'+xe.lang.cmd_delete+"</button> ",0===d)$(this).siblings("input").val(b[d]);else{var e=$(this).siblings("input").val();$(this).siblings("input").val(e+","+b[d])}}else c='<img src="'+b+'" alt="" style="border: 1px solid #ccc; padding: 5px; max-height: 200px; max-width: 200px;"> <button class="filebox_del x_btn x_btn-danger" type="button">'+xe.lang.cmd_delete+"</button> ",$(this).siblings("input").val(b);$(this).before(c),$(".filebox_del").bind("click",function(){for(var a=$(this).prev("img").attr("src"),b=$(this).siblings("input").val().split(","),c="",d=0;d<b.length;d++)b[d]!=a&&(c.length?c+=","+b[d]:c=b[d]);$(this).siblings("input").val(c),$(this).prev("img").remove(),$(this).remove()})}),$(".filebox").click(function(){$current_filebox=$(this)}),$("#filebox_upload").find("input[type=submit]").click(function(){if($("iframe[name=iframeTarget]").length<1){var $iframe=$(document.createElement("iframe"));$iframe.css("display","none"),$iframe.attr("src","#"),$iframe.attr("name","iframeTarget"),$iframe.load(function(){var data=eval("("+$(window.iframeTarget.document.getElementsByTagName("body")[0]).html()+")");return data.error?void alert(data.message):($current_filebox.trigger("filebox.selected",[data.save_filename]),void $current_filebox.trigger("close.mw"))}),$("body").append($iframe.get(0)),$(this).parents("form").attr("target","iframeTarget")}}),$("#widget_code_form").bind("submit",function(){function a(a){return a.error?void alert(a.message):void $("#widget_code").val(a.widget_code)}var b=$(this).serializeArray(),c={};for(var d in b){var e=b[d];/\[\]$/.test(e.name)&&(e.name=e.name.replace(/\[\]$/,"")),c[e.name]?c[e.name]+="|@|"+e.value:c[e.name]=e.value}return $.exec_json("widget.procWidgetGenerateCode",c,a),!1}),$("#fo_widget").bind("submit",function(){function a(a){return"0"!=a.error?void alert(a.message):void completeGenerateCodeInPage(a.widget_code)}var b=$(this).serializeArray(),c={};for(var d in b){var e=b[d];/\[\]$/.test(e.name)&&(e.name=e.name.replace(/\[\]$/,"")),c[e.name]?c[e.name]+="|@|"+e.value:c[e.name]=e.value}return exec_xml("widget","procWidgetGenerateCodeInPage",c,a,["error","message","widget_code"]),!1})}); |