rhymix/modules/admin/tpl/js/admin.min.js
2012-11-22 06:59:53 +00:00

61 lines
28 KiB
JavaScript

function showWaitingFogLayer(){var a=jQuery('<span class="bg"></span>');a.height(jQuery(window).height());jQuery(".wfsr").wrap('<div class="wfsr_fog" />').before(a)}function hideWaitingFogLayer(){jQuery(".wfsr").prev("span").remove();jQuery(".wfsr").unwrap()}function doInstallModule(a){var f=[];f.module_name=a;exec_xml("install","procInstallAdminInstall",f,completeInstallModule);showWaitingFogLayer()}
function doUpdateModule(a){var f=[];f.module_name=a;exec_xml("install","procInstallAdminUpdate",f,completeInstallModule);showWaitingFogLayer()}function completeInstallModule(a){alert(a.message);location.reload()}
jQuery(function(a){function f(){var b=a(".x>.xin>.body"),d=b.find(">.gnb"),e=b.children("#content.content");e.width("99.99%");setTimeout(function(){e.removeAttr("style");d.height()>e.height()&&e.height(d.height())},100)}window.scrollTo(0,0);a(".x .skipNav>a").click(function(){a(a(this).attr("href")).attr("tabindex","0").css("outline","0").focus()});a(document.body).on("click",".x [data-toggle]",function(){var b=a(this);if(b.is("a")&&b.attr("href")!=b.attr("data-toggle")){var d=b.attr("href");b.attr("data-toggle",
d)}d=a(b.attr("data-toggle"));d.toggle();d.is(":visible")&&!d.find("a,input,button,textarea,select").length?d.not(":disabled").attr("tabindex","0").css("outline","0").focus():d.is(":visible")&&d.find("a,input,button,textarea,select").length?d.not(":disabled").find("a,input,button,textarea,select").eq(0).focus():b.focus();return!1});a(document.body).on("click",".x [data-show]",function(){var b=a(this);if(b.is("a")&&b.attr("href")!=b.attr("data-show")){var d=b.attr("href");b.attr("data-show",d)}a(b.attr("data-show")).show().attr("tabindex",
"0").focus();return!1});a(document.body).on("click",".x [data-hide]",function(){var b=a(this);if(b.is("a")&&b.attr("href")!=b.attr("data-hide")){var d=b.attr("href");b.attr("data-hide",d)}a(b.attr("data-hide")).hide();b.focus();return!1});a.fn.xeTabbable=function(){a(this).each(function(){var b=a(this);b.find(">.x_nav-tabs>li>a").each(function(b){a(this).attr("data-index",b+1)});b.find(">.x_tab-content>.x_tab-pane").each(function(b){a(this).attr("data-index",b+1)})});a('.x .x_tab-content>.x_tab-pane:not(".x_active")').hide()};
a(".x .x_tabbable").xeTabbable();a(document.body).on("click",'.x .x_nav-tabs>li>a[href*="#"]',function(){var b=a(this);if(b.parent("li").hasClass("x_disabled"))return!1;b.parent("li").addClass("x_active").siblings().removeClass("x_active");b.closest(".x_nav-tabs").next(".x_tab-content").find(">.x_tab-pane").eq(b.attr("data-index")-1).addClass("x_active").show().siblings(".x_tab-pane").removeClass("x_active").hide();a(this).parents(".x_tabbable").trigger("tab_change",[parseInt(a(this).attr("data-index"))-
1,a(this)]);return!1});a.fn.gnb=function(){var b=a(".x>.xin>.body"),d=b.find(">.gnb"),e=d.find(">ul>li"),g=new Date;g.setTime(g.getTime()+30758400);e.find(">a").prepend("<i />");e.each(function(b){a(this).attr("data-index",b+1)});var j=e.find(">ul>li.active_").closest("li.active").attr("data-index");e.find(">ul>li.active_").clone().addClass("active").attr("data-index",j).prependTo("#gnbNav").find(">a").prepend("<i />");e.find(">a").click(function(){function d(){b.removeClass("wide");f()}var e=a(this).parent("li"),
g=e.hasClass("open"),k=e.hasClass("active"),j=1<=e.find(">ul").length,q=b.hasClass("wide");if(!g&&!k&&j)return e.addClass("open").find(">ul").slideDown(100),d(),!1;if(g&&!k&&j&&!q)return e.removeClass("open").find(">ul").slideUp(100),d(),!1;if(q&&!j||k||q&&g)return d(),!1});d.find('>a[href="#gnbNav"]').click(function(){a(this).parent(".gnb").toggleClass("open");b.toggleClass("wide");980>=a(window).width()&&!d.hasClass("open")&&a("#gnbNav").removeClass("ex");f();a(this).parent(".gnb").hasClass("open")?
setCookie("__xe_admin_gnb_status","open",g):setCookie("__xe_admin_gnb_status","close",g);return!1});d.prepend('<button type="button" class="close before" />').append('<button type="button" class="close after" />');d.find(">.close").focus(function(){b.addClass("wide");f()});d.find(".exMenu>button").click(function(){a("#gnbNav").toggleClass("ex");f();a("#gnbNav").hasClass("ex")?setCookie("__xe_admin_gnb_ex_status","open",g):setCookie("__xe_admin_gnb_ex_status","close",g)});(e=getCookie("__xe_admin_gnb_status"))&&
setCookie("__xe_admin_gnb_status",e,g);(e=getCookie("__xe_admin_gnb_ex_status"))&&setCookie("__xe_admin_gnb_xe_status",e,g)};a(".gnb").gnb();a(".x #lang").mouseleave(function(){a(this).hide()}).focusout(function(){var b=a(this);setTimeout(function(){b.find("a:focus").length||b.mouseleave()},500)});a('.x th>input[type="checkbox"]').change(function(){var b=a(this),d=b.data("name");b.closest("table").find("input:checkbox").filter(function(){var b=a(this);return!b.prop("disabled")&&(b.attr("name")==d||
b.data("name")==d)}).prop("checked",b.prop("checked")).end().end().trigger("update.checkbox",[d,this.checked])});a(document.body).on("click",".x .x_pagination .x_disabled, .x .x_pagination .x_active",function(){return!1});if(1<a(".section").length){var e=a(".x .section").find(">h1:first");e.append('<button type="button" class="snToggle x_icon-chevron-up">Toggle this section</button>');a(".x .section.collapse>h1>.snToggle").removeClass("x_icon-chevron-up").addClass("x_icon-chevron-down");e.find(">.snToggle").click(function(){var b=
a(this),d=b.closest(".section");d.hasClass("collapse")?(d.removeClass("collapse"),b.removeClass("x_icon-chevron-down").addClass("x_icon-chevron-up")):(d.addClass("collapse"),b.removeClass("x_icon-chevron-up").addClass("x_icon-chevron-down"));f()})}e=a(".x .x_alert");e.prepend('<button type="button" class="x_close">&times;</button>');e.children(".x_close").click(function(){a(this).parent(".x_alert").hide()});a(".x .x_btn").click(function(){if(a(this).hasClass("x_disabled"))return!1});a.fn.vr=function(){this.each(function(){var b=
a(this);"|"==b.text()&&b.addClass("vr").filter(":first-child, :last-child").remove()})};a(".x i").vr();a.fn.labelMaker=function(){this.each(function(b){var b=b+1,d=a(this),b="i"+b;d.next("input, textarea, select").filter("[id]").not(":radio, :checkbox").length?d.attr("for",d.next().attr("id")):d.next("input, textarea, select").not("[id]").not(":radio, :checkbox").length?d.attr("for",b).next().attr("id",b):d.prev(":radio, :checkbox").filter("[id]").length?d.attr("for",d.prev().attr("id")):d.prev(":radio, :checkbox").not("[id]").length?
d.attr("for",b).prev().attr("id",b):d.children("input, textarea, select").filter("[id]").length?d.attr("for",d.children("input, textarea, select").filter("[id]").eq(0).attr("id")):d.children("input, textarea, select").not("[id]").length&&d.attr("for",b).children("input, textarea, select").not("[id]").eq(0).attr("id",b)})};a("label:not([for])").labelMaker();a.fn.checkToggle=function(){function b(){setTimeout(function(){a(":checked").parent("label").addClass("checked");a(':not(":checked")').parent("label").removeClass("checked")},
0)}this.change(b);b()};a(":radio, :checkbox").checkToggle();a.fn.fileTypeOverlap=function(){this.each(function(){var b=a(this);b.wrap('<span class="fileBtn x_btn" />').before(b.attr("title"))})};a('input[type="file"].overlap').fileTypeOverlap();a.fn.xeMask=function(){this.each(function(){var b=a(this),d=b.text();/^([\w\-\.]+?)@(([\w-]+\.)+[a-z]{2,})$/ig.test(d)&&b.html(d.replace(/(@.+)$/,'<span class="ellipsis">...</span><span class="cover">$1</span>')).find(">.ellipsis").css({position:"absolute",
zIndex:1}).hover(function(){a(this).next(".cover").mouseover()},function(){a(this).next(".cover").mouseout()}).end().find(">.cover").css({zIndex:2,opacity:0}).hover(function(){a(this).css("opacity",1).prev("span").css("visibility","hidden")},function(){a(this).css("opacity",0).prev("span").css("visibility","visible")}).end()})};a(".masked").xeMask();a.fn.tableSpan=function(){this.each(function(){var b=a(this),d=b.find(">thead>tr:eq(0)>th").length,b=b.find(">tbody>tr:eq(0)>td:only-child");d!=b.attr("colspan")&&
b.attr("colspan",d).css("text-align","center")})};a("table").tableSpan()});
jQuery(function(a){a.fn.xeModalWindow=function(){this.not(".xe-modal-window").addClass("xe-modal-window").each(function(){a(a(this).attr("href")).addClass("x").hide()}).click(function(){var f=a(this);"showing"==a(f.attr("href")).data("state")?f.trigger("close.mw"):f.trigger("open.mw");return!1}).bind("open.mw",function(){var f=a(this),e,b;e=a(f.attr("href"));e.parent("body").length||(b=a('<button type="button" class="x_close">&times;</button>'),b.click(function(){e.data("anchor").trigger("close.mw")}),
e.find("[data-hide]").click(function(){e.data("anchor").trigger("close.mw")}),a("body").append('<div class="x_modal-backdrop"></div>').append(e),e.prepend(b));e.data("anchor",f);b=a.Event("before-open.mw");f.trigger(b);if(b.isDefaultPrevented())return!1;e=a(f.attr("href"));b=f.data("duration")||"fast";e.data("state","showing");a(document).bind("keydown.mw",function(a){if(27==a.which)return f.trigger("close.mw"),!1});e.fadeIn(b,function(){f.trigger("after-open.mw")}).find("button.x_close:first").focus().end().prev(".x_modal-backdrop").show();
a("body").css("overflow","hidden")}).bind("close.mw",function(){var f=a(this),e,b;e=a.Event("before-close.mw");f.trigger(e);if(e.isDefaultPrevented())return!1;e=a(f.attr("href"));b=f.data("duration")||"fast";e.data("state","hiding");e.fadeOut(b,function(){f.trigger("after-close.mw")}).prev(".x_modal-backdrop").hide();a("body").css("overflow","auto");f.focus()});a("div.x_modal").addClass("x").hide()};a("a.modalAnchor").xeModalWindow()});
jQuery(function(a){var f=!1;a.fn.xeContentToggler=function(){this.not(".xe-content-toggler").addClass("xe-content-toggler").each(function(){var e=a(this);$layer=a(e.attr("href"));$layer.hide().not(".xe-toggling-content").addClass("xe-toggling-content").mousedown(function(){f=!0}).focusout(function(){setTimeout(function(){!f&&(!$layer.find(":focus").length&&"showing"==$layer.data("state"))&&e.trigger("close.tc");f=!1},1)})}).click(function(){var e=a(this),b;b=a(e.attr("href"));b.data("anchor",e);"showing"==
b.data("state")?e.trigger("close.tc"):e.trigger("open.tc");return!1}).bind("open.tc",function(){function e(){b.trigger("after-open.tc")}var b=a(this),d,k,g;d=a(b.attr("href"));k=b.data("effect");g=b.data("duration")||"fast";d.data("state","showing");b.trigger("before-open.tc");f=!1;a(document).unbind("mousedown.tc keydown.tc").bind("mousedown.tc keydown.tc",function(e){if(e&&("keydown"==e.type&&27!=e.which||"mousedown"==e.type&&(e=a(e.target),e.is("html,.tgAnchor,.tgContent")||d.has(e).length)))return!0;
b.trigger("close.tc");return!1});switch(k){case "slide":d.slideDown(g,e);break;case "slide-h":k=d.css({"overflow-x":"",width:""}).width();d.show().css({"overflow-x":"hidden",width:"0px"}).animate({width:k},g,function(){d.css({"overflow-x":"",width:""});e()});break;case "fade":d.fadeIn(g,e);break;default:d.show(),b.trigger("after-open.tc")}}).bind("close.tc",function(){function e(){b.trigger("after-close.tc")}var b=a(this),d,f,g;a(document).unbind("mousedown.tc keydown.tc");d=a(b.attr("href"));f=b.data("effect");
g=b.data("duration")||"fast";d.data("state","hiding");b.trigger("before-close.tc");switch(f){case "slide":d.slideUp(g,e);break;case "slide-h":d.animate({width:0},g,function(){d.hide();e()});break;case "fade":d.fadeOut(g,e);break;default:d.hide(),b.trigger("after-close.tc")}});return this};a("a.tgAnchor").xeContentToggler()});
jQuery(function(a){a.fn.xeModuleFinder=function(){this.not(".xe-module-finder").addClass("xe-module-finder").find("a.tgAnchor.findsite").bind("before-open.tc",function(){var f,e,b;f=a(this);e=a(f.attr("href")).find(">ul");b=f.prev("input:text").val();a.exec_json("admin.getSiteAllList",{domain:b},function(b){var k=b.site_list,g,j;e.empty();f.closest(".modulefinder").find(".moduleList,.moduleIdList").attr("disabled","disabled");if(b.error||!a.isArray(k))f.trigger("close.tc");else{g=0;for(j=k.length;g<
j;g++)b=a("<li />").appendTo(e),a('<button type="button" />').text(k[g].domain).data("site_srl",k[g].site_srl).appendTo(b)}})}).end().find(".tgContent.suggestion").delegate("button","click",function(){var f,e;f=a(this);e=f.closest(".modulefinder");e.find("a.tgAnchor.findsite").trigger("close.tc");a.exec_json("module.procModuleAdminGetList",{site_srl:f.data("site_srl")},function(b){var d=b.module_list,f;if(!b.error&&d){b=e.find(".moduleList").data("module_list",d).removeAttr("disabled").empty();for(f in d)d.hasOwnProperty(f)&&
a("<option />").attr("value",f).text(d[f].title).appendTo(b);b.prop("selectedIndex",0).change().focus();b.is(":visible")||b.slideDown(100,function(){e.find(".moduleIdList:not(:visible)").slideDown(100).trigger("show")}).trigger("show")}})}).end().find(".moduleList,.moduleIdList").hide().end().find(".moduleList").change(function(){var f,e,b;f=a(this);e=f.val();b=f.data("module_list");if(b[e]){b=b[e].list;f=f.closest(".modulefinder").find(".moduleIdList").removeAttr("disabled").empty();for(var d in b)b.hasOwnProperty(d)&&
a("<option />").attr("value",b[d].module_srl).text(b[d].browser_title).appendTo(f);f.prop("selectedIndex",0).change()}});return this};a(".modulefinder").xeModuleFinder()});
jQuery(function(a){var f=0;_xeModuleSearch=function(){var e=this,b=a(this),d=b.data("multiple");d||(d="");var k="__module_searcher_"+f;f++;a.exec_json("module.getModuleAdminModuleSearcherHtml",{id:k,is_multiple:d},function(d){function f(a,b){var d;a.find("li div").width("");a.css("height","auto");a.css("overflow-y","");a.height()>b&&(d=a.find("li div"),d.width(d.width()-20+"px"),a.css("height",b+"px"),a.css("overflow-y","auto"))}function h(b){var d,e=RegExp(b,"ig"),g=u;m.empty();i=0;for(c=g.length;i<
c;i++){d=g[i].domain;if(b){if(!d.match(e))continue;d=d.replace(e,function(a){return'<span class="highlight">'+a+"</span>"})}$li=a("<li />").appendTo(m);a("<a>").attr("href","#").html(d).data("site_srl",g[i].site_srl).appendTo($li)}f(m,t-r.parent("div").height());1==g.length&&m.find("a").trigger("click")}if(d&&d.html){b.after(d.html).addClass("tgAnchor").attr("href","#"+k).xeContentToggler();var l=b.next(".moduleWindow"),d=l.find(".siteList"),n=l.find(".moduleList"),p=l.find(".instanceList"),m=d.find(">ul"),
q=n.find(">ul"),s=p.find(">select"),r=l.find("input.siteFinder"),u,t=280;r.keyup(function(){h(r.val())});"undefined"==typeof console&&(console={log:function(){}});b.not(".xe-module-search").addClass("xe-module-search").parent().find(".moduleTrigger").bind("before-open.tc",function(){var b;b=a(this);m.empty();s.empty();n.hide();p.hide();a.exec_json("admin.getSiteAllList",{domain:""},function(d){var e=d.site_list;d.error||!a.isArray(e)?b.trigger("close.tc"):(u=e,h(r.val()),r.focus())})});l.find(".siteList>ul").delegate("a",
"click",function(b){var d;d=a(this);d.closest(".moduleSearch");q.empty();p.hide();a.exec_json("module.procModuleAdminGetList",{site_srl:d.data("site_srl")},function(b){var e=b.module_list,g;if(!b.error&&e){for(g in e)e.hasOwnProperty(g)&&($li=a("<li />").appendTo(q),a("<a>").attr("href","#").html(e[g].title).data("moduleInstanceList",e[g].list).appendTo($li));l.find(".moduleList").show();f(q,t);m.find("li").removeClass("x_active");d.parent("li").addClass("x_active")}});b.preventDefault()}).end().find(".moduleList>ul").delegate("a",
"click",function(b){var d,g;d=a(this);if(g=d.data("moduleInstanceList")){e.sSelectedModuleType=d.text();s.empty();for(var h in g)g.hasOwnProperty(h)&&($li=a("<option />").html(g[h].browser_title+" ("+g[h].mid+")").appendTo(s).val(g[h].module_srl).data("mid",g[h].mid).data("module_srl",g[h].module_srl).data("layout_srl",g[h].layout_srl).data("browser_title",g[h].browser_title));p.show();f(s,t);q.find("li").removeClass("x_active");d.parent("li").addClass("x_active");b.preventDefault()}}).end().find(".moduleSearch_ok").click(function(d){var f=
[];s.find("option:selected").each(function(){f.push({type:e.sSelectedModuleType,module_srl:a(this).data("module_srl"),layout_srl:a(this).data("layout_srl"),browser_title:a(this).data("browser_title"),mid:a(this).data("mid")})});b.trigger("moduleSelect",[f]);a(".moduleTrigger").trigger("close.tc");d.preventDefault()})}});return this};a.fn.xeModuleSearch=function(){a(this).each(_xeModuleSearch)};a(".moduleTrigger").xeModuleSearch();a.fn.xeModuleSearchHtml=function(){var e=0;a(this).each(function(){var b=
a(this),d=b.attr("id");d||(d="__module_search_"+e);e++;var d=a('<a class="x_btn moduleTrigger">'+xe.cmd_find+"</a>"),f=a('<input type="text" readonly>');b.after(d).after("&nbsp;").after(f).hide();d.xeModuleSearch();d.bind("moduleSelect",function(a,d){f.val(d[0].browser_title+" ("+d[0].mid+")");b.val(d[0].module_srl)});b.val()&&a.exec_json("module.getModuleAdminModuleInfo",{module_srl:b.val()},function(a){a&&a.module_info&&f.val(a.module_info.browser_title+" ("+a.module_info.mid+")")})});return this};
a(".module_search").xeModuleSearchHtml()});
jQuery(function(a){var f=a('<tr class="placeholder"><td>&nbsp;</td></tr>');a.fn.xeSortableTable=function(){this.not(".xe-sortable-table").addClass("xe-sortable-table").delegate("button.dragBtn","mousedown.st",function(e){var b,d,k,g,j,h,l,n,p,m;if(1==e.which){d=a(this);k=d.closest("tr");g=d.closest("table");m=g.get(0).offsetParent;d=k.height();j=k.width();before_event=a.Event("before-drag.st");g.trigger(before_event);if(before_event.isDefaultPrevented())return!1;b=e.pageY;h=getOffset(k.get(0),m);
$clone=k.attr("target",!0).clone(!0).appendTo(g);p=(e=g.find("thead th")).length;e.filter("[colspan]").attr("colspan",function(a,b){p+=b-1});f.find("td").attr("colspan",p);l=[];g.find("tbody>tr:not([target],.sticky,:hidden)").each(function(){var b=a(this),d;d=getOffset(this,m);l.push({top:d.top,bottom:d.top+b.height(),$item:b})});$clone.addClass("draggable").css({position:"absolute",opacity:0.6,width:j,height:d,left:h.left,top:h.top,zIndex:100});f.css({position:"absolute",opacity:0.6,width:j,height:"10px",
left:h.left,top:h.top,backgroundColor:"#bbb",overflow:"hidden",zIndex:99}).appendTo(g);k.css("opacity",0.6);a(document).unbind("mousedown.st mouseup.st").bind("mousemove.st",function(a){var d,e,g;n=null;a=h.top-(b-a.pageY);d=0;for(e=l.length;d<e;d++)g=l[d],d&&g.top>a||d<e-1&&g.bottom<a||(n={element:g.$item},g.top>a-12?(n.state="before",f.css("top",g.top-5)):(n.state="after",f.css("top",g.bottom-5)));$clone.css({top:a})}).bind("mouseup.st",function(){var b;a(document).unbind("mousemove.st mouseup.st");
k.removeAttr("target").css("opacity","");$clone.remove();f.remove();n&&(b=a(n.element),b[n.state](k),g.trigger("after-drag.st"))})}});return this};a("table.sortable").xeSortableTable()});
jQuery(function(a){a(".filebox").bind("before-open.mw",function(){function b(h){f.html(h.html);f.find(".select").bind("click",function(){var b=a("input.select_checkbox:checked");0==b.length?(b=a(this).closest("tr").find("img.filebox_item").attr("src"))?(e.trigger("filebox.selected",[b]),e.trigger("close.mw")):alert("None selected!"):(e.trigger("filebox.selected",[b]),e.trigger("close.mw"));return!1});f.find(".x_pagination").find("a").filter(function(){return a(this).data("toggle")||a(this).parent().hasClass("x_disabled")||
a(this).parent().hasClass("x_active")?!1:!0}).bind("click",function(){var e=a(this).attr("page");a.exec_json("module.getFileBoxListHtml",{page:e},b);return!1});a("#goToFileBox").find("button").bind("click",function(){var e=a(this).prev("input").val();a.exec_json("module.getFileBoxListHtml",{page:e},b);return!1});f.closest(".x_modal-body").scrollTop(0)}var e,f,j;e=a(this);j=e.attr("href");f=a(j).find(".filebox_list");a.exec_json("module.getFileBoxListHtml",{page:"1"},b)});var f=a(".x .dsTg .__simple"),
e=a(".x .dsTg .__detail");a(".x .dsTg td.title").each(function(){var b=a(this);0==b.find("p.x_alert").length&&b.addClass("tg").find(">*:not(:first-child)").hide()});var b=a(".x .dsTg td.tg>*:not(:first-child)");f.click(function(){b.slideUp(200);e.removeClass("x_active");f.addClass("x_active")});e.click(function(){b.slideDown(200);e.addClass("x_active");f.removeClass("x_active")})});
jQuery(function(a){a.fn.xeMultilingualWindow=function(f){function e(){if(h.is(":visible")&&h.find(".editMode").length){var a=h.find(".editMode");confirm(xe.msg_confirm_save_and_use_multilingual)?a.find(".save").trigger("click"):a.find(".cancel").trigger("click")}return!0}function b(){h.find(".item > fieldset").hide().prev("a").children("i").removeClass("x_icon-chevrom-up").addClass("x_icon-chevron-down");g.find('[href="#lang_create"]').trigger("click");j.find(".editMode").children("textarea").val("");
l=!1;return!0}function d(a,b){var d=g.data("lang-target");l=!1;d&&d.trigger("selected.g11n",[a,b])}function k(b,g,m,j,l){"undefined"==typeof b&&(b=1);"undefined"==typeof g&&(g=xe.current_lang);"undefined"==typeof m&&(m="");"undefined"==typeof j&&(j="");"undefined"==typeof l&&(l=!0);a.exec_json("module.getModuleAdminLangListHtml",{page:b,lang_code:g,search_keyword:m,name:j,list_count:f.list_count},function(b){b&&b.html&&(h.html(b.html),h.find(".x_pagination a").click(function(){var b=a(this).data("page"),
d=a(this).data("search_keyword"),e=a(this).data("current_lang");if(b)return k(b,e,d),!1}),h.find(".x_pagination").submit(function(){var b=a(this).find('[name="page"]').val(),d=a(this).data("search_keyword"),e=a(this).data("current_lang");if(!b)return!1;k(b,e,d);return!1}),h.find(".search").submit(function(){var b=a(this).find('[name="search_keyword"]').val(),d=a(this).find('[name="lang_code"]').val();k(1,d,b);return!1}),h.find("#search_cancel").click(function(){k(1,xe.current_lang,"")}),h.find(".set").append('<i class="x_icon-chevron-down"></i>').click(function(){function b(e){d.next("fieldset").find("textarea").each(function(){var b=
a(this),d=e.langs[b.data("lang")];/^\$user_lang->/.test(d)?b.val("").data("value",""):b.val(d).data("value",d)});d.data("is_loaded",!0)}var d=a(this),f=d.data("lang_code");e();d.next("fieldset").is(":visible")?d.children("i").removeClass("x_icon-chevron-up").addClass("x_icon-chevron-down"):(d.parent(".item").siblings(".item").find("a > i").removeClass("x_icon-chevron-up").addClass("x_icon-chevron-down").end().children("fieldset").hide(),d.children("i").removeClass("x_icon-chevron-down").addClass("x_icon-chevron-up"));
"undefined"==typeof d.data("is_loaded")&&a.exec_json("module.getModuleAdminLangCode",{name:f},b)}),f.view_use||h.find(".useit").hide(),f.view_modify||h.find(".modify").hide(),f.view_delete||h.find(".delete").hide(),"save"==f.modify_type&&h.find(".save").text(xe.cmd_save),h.find(".modify").click(function(){a(this).closest("fieldset").addClass("editMode").find("textarea").removeAttr("disabled");a(this).siblings(".cancel").prependTo(a(this).parent());a(this).siblings(".delete").attr("disabled","disabled")}),
h.find(".cancel").click(function(){a(this).closest("fieldset").removeClass("editMode").find("textarea").attr("disabled","disabled").each(function(){var b=a(this);b.val(b.data("value"))});a(this).siblings(".modify").prependTo(a(this).parent());a(this).siblings(".delete").removeAttr("disabled");return!1}),h.find(".delete").click(function(){confirm(xe.confirm_delete)&&(lang_name=a(this).closest(".item").find('[href^="#lang-"]').data("lang_code"),a.exec_json("module.procModuleAdminDeleteLang",{name:lang_name},
function(a){if(a)if(a.error)alert(a.message);else{var b=h.find(".x_pagination"),a=b.data("page"),d=b.data("search_keyword"),b=b.data("lang_code");a||($page=1);k(a,b,d)}}))}),h.find(".item").submit(function(){var b=a(this),d=b.find(".editMode").children("textarea"),e=b.find('[href^="#lang-"]'),f={},g=null;d.each(function(){var b=a(this);f[b.attr("class")]=b.val();b.data("tmp_value",b.val());xe.current_lang==b.attr("class")&&(g=b.val())});f.lang_name=e.data("lang_code");a.exec_json("module.procModuleAdminInsertLang",
f,function(f){f&&(!f.error&&f.name)&&(d.each(function(){var b=a(this);b.data("value",b.data("tmp_value"))}),e.children("span").html(g),h.find(".cancel").trigger("click"),b.find(".useit").trigger("click"))});return!1}),h.find(".useit").click(function(){var b=a(this).closest(".item").find('[href^="#lang-"]'),e=b.data("lang_code"),b=b.children("span").text();d(e,b)}),l&&(document.location.href="#lang_search"),j&&a("#lang_search").find('[href^="#lang-"]').trigger("click"))})}var g=a(this),j=g.find("#lang_create"),
h=g.find("#lang_search"),l=!1,f=a.extend({create_type:"save_and_use",modify_type:"save_and_use",view_use:!0,view_modify:!0,view_delete:!1,list_count:5},f||{});"save_and_use"!=f.create_type&&j.find(".save-useit").text(xe.cmd_save);g.find(".x_tabbable").xeTabbable();j.find(".editMode textarea").change(function(){l=!0});j.submit(function(){var e={},g=null;a(this).find(".editMode").children("textarea").each(function(){var b=a(this);e[b.attr("class")]=b.val();xe.current_lang==b.attr("class")&&(g=b.val())});
if(!g)return alert(xe.msg_empty_multilingual),!1;a.exec_json("module.procModuleAdminInsertLang",e,function(a){a&&(!a.error&&a.name)&&("save_and_use"==f.create_type?d(a.name,g):(alert(a.message),b()))});return!1});g.find('[href="#lang_search"]').click(function(){k()});g.bind("reset.g11n",function(){b()});g.bind("before-open.g11n",function(a,b){b?(k(1,xe.current_lang,"",b,!1),g.find('[href="#lang_search"]').trigger("click")):k(1,xe.current_lang,"","",!1)});g.bind("before-close.g11n",function(){var a;
j.is(":visible")&&l&&confirm(xe.msg_confirm_save_and_use_multilingual)&&j.find(".save-useit").trigger("click");a=!e()||!b()?!1:void 0;return a});return this}});var is_loaded_multilingual_window_html=!1;jQuery(function(a){a.fn.xeLoadMultilingualWindowHtml=function(){a.exec_json("module.getModuleAdminMultilingualHtml",{},function(f){var e=a(".x #content");a(f.html).appendTo(e).xeMultilingualWindow();a(".lang_code").trigger("loaded-multilingualWindow")});return this}});var multilingual_id_count=0;
jQuery(function(a){a.fn.xeApplyMultilingualUI=function(){a(this).each(function(){function f(){function f(){h.val(n.val()).width(h.data("width")).removeAttr("disabled");h.parent(".g11n").removeClass("active");/^\$user_lang->/.test(h.val())&&a.exec_json("module.getModuleAdminLangCode",{name:h.val().replace("$user_lang->","")},function(a){if(a&&a.langs){var b=h.width();h.closest(".g11n").addClass("active");h.val(a.langs[xe.current_lang]).attr("disabled","disabled").width(b-44).data("active",!0)}})}var g=
a("#g11n"),j=e.width(),h="TEXTAREA"==b.tagName||"textarea"==e.data("type")?a('<textarea id="lang_'+d+'" class="displayInput" style="width:'+j+'px" data-width="'+j+'">').data("lang-id",d):a('<input type="text" id="lang_'+d+'" class="displayInput" style="width:'+(j-28)+'px" data-width="'+(j-28)+'">').data("lang-id",d);h.attr("placeholder",e.attr("placeholder"));var j=a('<button type="button" class="x_add-on remover" title="'+xe.cmd_remove_multilingual_text+'"><i class="x_icon-remove"></i>'+xe.cmd_remove_multilingual_text+
"</button>").data("lang-target",d),l=a('<a href="#g11n" class="x_add-on modalAnchor" title="'+xe.cmd_set_multilingual_text+'"><i class="x_icon-globe"></i>'+xe.cmd_set_multilingual_text+"</a>").data("lang-target",d);e.parent().addClass("g11n").addClass("x_input-append");e.after(h,j,l);e.hide();l.attr("href","#g11n").xeModalWindow();h.bind("selected.g11n",function(a,b,d){a=h.width();h.data("active")||(a-=44);h.width(a).attr("disabled","disabled").val(d).data("active",!0).parent(".g11n").addClass("active");
h.siblings("#"+h.data("lang-id")).val("$user_lang->"+b);l.trigger("close.mw")});l.bind("open.mw",function(){var b=a(this).siblings(".displayInput");b.data("active")?g.trigger("before-open.g11n",b.prev(".lang_code").val().replace("$user_lang->","")):g.trigger("before-open.g11n");g.data("lang-target",b)});l.bind("before-close.mw",function(){return g.trigger("before-close.g11n")});j.click(function(){var b=a(this);if(b.siblings(".displayInput").data("active")){var d=a("#lang_"+b.data("lang-target")),
e=d.width();d.val("").removeAttr("disabled").width(e+44).data("active",!1).parent(".g11n").removeClass("active");b.siblings(".lang_code").val("")}});var n=e;h.bind("change keyup",function(){e=a(this);e.data("active")||n.val(e.val())});e.bind("reload-multilingual",f);f()}is_loaded_multilingual_window_html||(a().xeLoadMultilingualWindowHtml(),is_loaded_multilingual_window_html=!0);var e=a(this),b=this;e.parent().hasClass("g11n")?e.siblings().remove():e.wrap("<span></span>");var d=e.attr("id");d||(d=
"__lang_code_"+multilingual_id_count,multilingual_id_count++,e.attr("id",d));a("#g11n").length?f():e.bind("loaded-multilingualWindow",f)});return this};a('.vLang[type="hidden"]').each(function(){var f=a(this);f.next("textarea.vLang").length&&f.data("type","textarea");f.removeClass("vLang").addClass("lang_code");f.parent().find(".editUserLang").remove().end().find(".vLang").remove()});a(".lang_code").xeApplyMultilingualUI()});
function getOffset(a,f){for(var e=0,b=0;a&&a!=f;)e+=a.offsetTop,b+=a.offsetLeft,a=a.offsetParent;return{top:e,left:b}};