Issue 2041: The module search component updated to support multiple instances in a single page.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.3.1@10933 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
nagoon97 2012-07-24 07:38:21 +00:00
parent 3516f0a9ce
commit 8a1f88ddf8
6 changed files with 55 additions and 43 deletions

View file

@ -580,7 +580,7 @@ $('.modulefinder').xeModuleFinder();
jQuery(function($){
$.fn.xeModuleSearch = function(){
var $moduleSearchWindow = $("#moduleSearchWindow");
var $moduleSearchWindow = $(this).find(".moduleSearchWindow");
var $siteListDiv = $moduleSearchWindow.find('.siteList');
var $moduleTypeListDiv = $moduleSearchWindow.find('.moduleTypeList');
@ -596,11 +596,7 @@ $.fn.xeModuleSearch = function(){
var MAX_LIST_HEIGHT = 280;
var t = this;
this.onModuleSelect = function(sModuleType, sModuleInstanceName, sModuleInstanceSrl){
$('#_target_module').val(sModuleInstanceName);
$('#index_module_srl').val(sModuleInstanceSrl);
};
var $t = $(this);
function setListSize($UL, nHeight){
var nWidth, $div;
@ -757,8 +753,15 @@ $.fn.xeModuleSearch = function(){
t.sSelectedModuleInstanceName = $this.text();
t.sSelectedModuleSrl = $this.data('module_srl');
t.onModuleSelect(t.sSelectedModuleType, t.sSelectedModuleInstanceName, t.sSelectedModuleSrl);
/*
var onModuleSelect = t.onModuleSelect;
if(typeof $t.data('onModuleSelect') === 'function'){
onModuleSelect = $t.data('onModuleSelect');
}
onModuleSelect(t.sSelectedModuleType, t.sSelectedModuleInstanceName, t.sSelectedModuleSrl);
*/
t.trigger('moduleSelect', [t.sSelectedModuleType, t.sSelectedModuleInstanceName, t.sSelectedModuleSrl]);
$('.tgAnchor.moduleSearch').trigger('close.tc');
oEvent.preventDefault();
@ -767,7 +770,7 @@ $.fn.xeModuleSearch = function(){
return this;
};
xe.ModuleSearch = $('.modulefinder').xeModuleSearch();
xe.ModuleSearch = $('.moduleSearch').xeModuleSearch();
});

View file

@ -18,11 +18,11 @@ j;f++)e=a("<li />").appendTo(b),a('<button type="button" />').text(g[f].domain).
a("<option />").attr("value",g).text(d[g].title).appendTo(e);e.prop("selectedIndex",0).change().focus();e.is(":visible")||e.slideDown(100,function(){b.find(".moduleIdList:not(:visible)").slideDown(100).trigger("show")}).trigger("show")}})}).end().find(".moduleList,.moduleIdList").hide().end().find(".moduleList").change(function(){var d,b,e;d=a(this);b=d.val();e=d.data("module_list");if(e[b]){e=e[b].list;d=d.closest(".modulefinder").find(".moduleIdList").removeAttr("disabled").empty();for(var k in e)e.hasOwnProperty(k)&&
a("<option />").attr("value",e[k].module_srl).text(e[k].browser_title).appendTo(d);d.prop("selectedIndex",0).change()}});return this};a(".modulefinder").xeModuleFinder()});
jQuery(function(a){a.fn.xeModuleSearch=function(){function d(a,b){var e;a.find("li div").width("");a.css("height","");a.css("overflow-y","");a.height()>b&&(e=a.find("li div"),e.width(e.width()-20+"px"),a.css("height",b+"px"),a.css("overflow-y","auto"))}function b(b){var e,f=RegExp(b,"ig"),h=m;j.empty();i=0;for(c=h.length;i<c;i++){e=h[i].domain;if(b){if(!e.match(f))continue;e=e.replace(f,function(a){return'<span class="highlight">'+a+"</span>"})}$li=a("<li />").appendTo(j);a('<a href="#" >').html("<div>"+
e+'</div><span class="icon-circle-arrow-right" style="display:inline-block;float:right;width:16px;height:16px;"></span>').data("site_srl",h[i].site_srl).appendTo($li)}d(j,n-l.parent("DIV").height())}var e=a("#moduleSearchWindow"),k=e.find(".siteList"),g=e.find(".moduleTypeList"),f=e.find(".moduleInstanceList"),j=k.find("UL"),o=g.find("UL"),h=f.find("UL"),l=e.find("INPUT.siteListSearchInput"),m,n=280,p=this;this.onModuleSelect=function(b,e,d){a("#_target_module").val(e);a("#index_module_srl").val(d)};
l.keyup(function(){b(l.val())});"undefined"==typeof console&&(console={log:function(){}});this.not(".xe-module-search").addClass("xe-module-search").find("a.tgAnchor.moduleSearch").bind("before-open.tc",function(){var e;e=a(this);j.empty();h.empty();g.hide();f.hide();a.exec_json("admin.getSiteAllList",{domain:""},function(d){var h=d.site_list;d.error||!a.isArray(h)?e.trigger("close.tc"):(m=h,b(l.val()),l.focus())})}).end().find(".tgContent .siteListUL").delegate("a","click",function(b){var h;h=a(this);
h.closest(".modulefinder");o.empty();f.hide();a.exec_json("module.procModuleAdminGetList",{site_srl:h.data("site_srl")},function(b){var f=b.module_list,l;if(!b.error&&f){for(l in f)f.hasOwnProperty(l)&&($li=a("<li />").appendTo(o),a('<a href="#" >').html("<div>"+f[l].title+'</div><span class="icon-circle-arrow-right" style="display:inline-block;float:right;width:16px;height:16px;"></span>').data("moduleInstanceList",f[l].list).appendTo($li));e.find(".moduleTypeList").show();d(o,n);j.find("li").removeClass("on");
h.parent("li").addClass("on")}});b.preventDefault()}).end().find(".moduleTypeListUL").delegate("a","click",function(b){var e,l;e=a(this);if(l=e.data("moduleInstanceList")){p.sSelectedModuleType=e.text();h.empty();for(var g in l)l.hasOwnProperty(g)&&($li=a("<li />").appendTo(h),a('<a href="#" >').html("<div>"+l[g].browser_title+"</div>").data("module_srl",l[g].module_srl).appendTo($li));f.show();d(h,n);o.find("li").removeClass("on");e.parent("li").addClass("on");b.preventDefault()}}).end().find(".moduleInstanceListUL").delegate("a",
"click",function(b){$this=a(this);p.sSelectedModuleInstanceName=$this.text();p.sSelectedModuleSrl=$this.data("module_srl");p.onModuleSelect(p.sSelectedModuleType,p.sSelectedModuleInstanceName,p.sSelectedModuleSrl);a(".tgAnchor.moduleSearch").trigger("close.tc");b.preventDefault()});return this};xe.ModuleSearch=a(".modulefinder").xeModuleSearch()});
e+'</div><span class="icon-circle-arrow-right" style="display:inline-block;float:right;width:16px;height:16px;"></span>').data("site_srl",h[i].site_srl).appendTo($li)}d(j,n-l.parent("DIV").height())}var e=a(this).find(".moduleSearchWindow"),k=e.find(".siteList"),g=e.find(".moduleTypeList"),f=e.find(".moduleInstanceList"),j=k.find("UL"),o=g.find("UL"),h=f.find("UL"),l=e.find("INPUT.siteListSearchInput"),m,n=280,p=this;a(this);l.keyup(function(){b(l.val())});"undefined"==typeof console&&(console={log:function(){}});
this.not(".xe-module-search").addClass("xe-module-search").find("a.tgAnchor.moduleSearch").bind("before-open.tc",function(){var e;e=a(this);j.empty();h.empty();g.hide();f.hide();a.exec_json("admin.getSiteAllList",{domain:""},function(d){var h=d.site_list;d.error||!a.isArray(h)?e.trigger("close.tc"):(m=h,b(l.val()),l.focus())})}).end().find(".tgContent .siteListUL").delegate("a","click",function(b){var h;h=a(this);h.closest(".modulefinder");o.empty();f.hide();a.exec_json("module.procModuleAdminGetList",
{site_srl:h.data("site_srl")},function(b){var f=b.module_list,l;if(!b.error&&f){for(l in f)f.hasOwnProperty(l)&&($li=a("<li />").appendTo(o),a('<a href="#" >').html("<div>"+f[l].title+'</div><span class="icon-circle-arrow-right" style="display:inline-block;float:right;width:16px;height:16px;"></span>').data("moduleInstanceList",f[l].list).appendTo($li));e.find(".moduleTypeList").show();d(o,n);j.find("li").removeClass("on");h.parent("li").addClass("on")}});b.preventDefault()}).end().find(".moduleTypeListUL").delegate("a",
"click",function(b){var e,l;e=a(this);if(l=e.data("moduleInstanceList")){p.sSelectedModuleType=e.text();h.empty();for(var g in l)l.hasOwnProperty(g)&&($li=a("<li />").appendTo(h),a('<a href="#" >').html("<div>"+l[g].browser_title+"</div>").data("module_srl",l[g].module_srl).appendTo($li));f.show();d(h,n);o.find("li").removeClass("on");e.parent("li").addClass("on");b.preventDefault()}}).end().find(".moduleInstanceListUL").delegate("a","click",function(b){$this=a(this);p.sSelectedModuleInstanceName=
$this.text();p.sSelectedModuleSrl=$this.data("module_srl");p.trigger("moduleSelect",[p.sSelectedModuleType,p.sSelectedModuleInstanceName,p.sSelectedModuleSrl]);a(".tgAnchor.moduleSearch").trigger("close.tc");b.preventDefault()});return this};xe.ModuleSearch=a(".moduleSearch").xeModuleSearch()});
jQuery(function(a){function d(a,b){for(var d=0,f=0;a&&a!=b;)d+=a.offsetTop,f+=a.offsetLeft,a=a.offsetParent;return{top:d,left:f}}var b=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 k,g,f,j,o,h,l,m,n,p;if(1==e.which){g=a(this);f=g.closest("tr");j=g.closest("table");p=j.get(0).offsetParent;g=f.height();o=f.width();before_event=a.Event("before-drag.st");
j.trigger(before_event);if(before_event.isDefaultPrevented())return!1;k=e.pageY;h=d(f.get(0),p);$clone=f.attr("target",!0).clone(!0).appendTo(j);n=(e=j.find("thead th")).length;e.filter("[colspan]").attr("colspan",function(a,b){n+=b-1});b.find("td").attr("colspan",n);l=[];j.find("tbody>tr:not([target],.sticky,:hidden)").each(function(){var b=a(this),e;e=d(this,p);l.push({top:e.top,bottom:e.top+b.height(),$item:b})});$clone.addClass("draggable").css({position:"absolute",opacity:0.6,width:o,height:g,
left:h.left,top:h.top,zIndex:100});b.css({position:"absolute",opacity:0.6,width:o,height:"10px",left:h.left,top:h.top,backgroundColor:"#bbb",overflow:"hidden",zIndex:99}).appendTo(j);f.css("opacity",0.6);a(document).unbind("mousedown.st mouseup.st").bind("mousemove.st",function(a){var e,d,f;m=null;a=h.top-(k-a.pageY);e=0;for(d=l.length;e<d;e++)f=l[e],e&&f.top>a||e<d-1&&f.bottom<a||(m={element:f.$item},f.top>a-12?(m.state="before",b.css("top",f.top-5)):(m.state="after",b.css("top",f.bottom-5)));$clone.css({top:a})}).bind("mouseup.st",