Issue 2041: Starting module search UI modified for easier use

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.3.1@10921 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
nagoon97 2012-07-20 10:25:08 +00:00
parent 38d57999c6
commit 804f42a8e1
11 changed files with 395 additions and 24 deletions

View file

@ -576,6 +576,196 @@ $('.modulefinder').xeModuleFinder();
});
// Module Search : A New Version Of Module Finder
jQuery(function($){
$.fn.xeModuleSearch = function(){
var $moduleSearchWindow = $("#moduleSearchWindow");
var $siteListDiv = $moduleSearchWindow.find('.siteList');
var $moduleTypeListDiv = $moduleSearchWindow.find('.moduleTypeList');
var $moduleInstanceListDiv = $moduleSearchWindow.find('.moduleInstanceList');
var $siteList = $siteListDiv.find('UL');
var $moduleTypeList = $moduleTypeListDiv.find('UL');
var $moduleInstanceList = $moduleInstanceListDiv.find('UL');
var $siteListSearchInput = $moduleSearchWindow.find('INPUT.siteListSearchInput');
var aSiteListData;
var MAX_LIST_HEIGHT = 280;
function setListSize($UL, nHeight){
var nWidth, $div;
$UL.find('li div').width('');
$UL.css('height', '');
$UL.css('overflow-y', '');
if($UL.height() > nHeight){
$div = $UL.find('li div');
$div.width($div.width()-20+'px');
$UL.css('height', nHeight+'px');
$UL.css('overflow-y', 'auto');
}
}
function setSiteList(sFilter){
var sDomain;
var rxFilter = new RegExp(sFilter, "ig");
var list = aSiteListData;
$siteList.empty();
for(i=0,c=list.length; i < c; i++) {
sDomain = list[i].domain;
if(sFilter){
if(!sDomain.match(rxFilter)) continue;
sDomain = sDomain.replace(rxFilter, function(sKeyword){
return '<span class="highlight">'+sKeyword+'</span>';
});
}
$li = $('<li />').appendTo($siteList);
$('<a href="#" >').html(
'<div>' + sDomain + '</div>' +
'<span class="icon-circle-arrow-right" style="display:inline-block;float:right;width:16px;height:16px;"></span>'
).data('site_srl', list[i].site_srl).appendTo($li);
}
setListSize($siteList, MAX_LIST_HEIGHT - $siteListSearchInput.parent("DIV").height());
}
$siteListSearchInput.keyup(function(){
setSiteList($siteListSearchInput.val());
});
if(typeof console == 'undefined'){
console={log:function(){}};
}
this
.not('.xe-module-search')
.addClass('xe-module-search')
.find('a.tgAnchor.moduleSearch')
.bind('before-open.tc', function(){
var $this;
$this = $(this);
function on_complete(data) {
var $li, list = data.site_list, i, c;
if(data.error || !$.isArray(list)) {
$this.trigger('close.tc');
return;
}
aSiteListData = list;
setSiteList($siteListSearchInput.val());
console.log(data);
$siteListSearchInput.focus();
};
$siteList.empty();
$moduleInstanceList.empty();
$moduleTypeListDiv.hide();
$moduleInstanceListDiv.hide();
$.exec_json('admin.getSiteAllList', {domain:""}, on_complete);
})
.end()
.find('.tgContent .siteListUL')
.delegate('a','click',function(oEvent){
var $this, $finder;
$this = $(this);
$finder = $this.closest('.modulefinder');
function on_complete(data) {
console.log(data);
var list = data.module_list, x;
if(data.error || !list) return;
for(x in list) {
if(!list.hasOwnProperty(x)) continue;
$li = $('<li />').appendTo($moduleTypeList);
$('<a href="#" >').html(
'<div>'+list[x].title+'</div>' +
'<span class="icon-circle-arrow-right" style="display:inline-block;float:right;width:16px;height:16px;"></span>'
).data('moduleInstanceList', list[x].list).appendTo($li);
//$('<option />').attr('value', x).text(list[x].title).appendTo($mod_select);
}
$moduleSearchWindow.find('.moduleTypeList').show();
setListSize($moduleTypeList, MAX_LIST_HEIGHT);
$siteList.find('li').removeClass('on');
$this.parent('li').addClass('on');
};
//$finder.find('a.tgAnchor.findsite').trigger('close.tc');
$moduleTypeList.empty();
$moduleInstanceListDiv.hide();
$.exec_json('module.procModuleAdminGetList', {site_srl:$this.data('site_srl')}, on_complete);
oEvent.preventDefault();
})
.end()
//.find('.moduleList,.moduleIdList').hide().end()
.find('.moduleTypeListUL')
.delegate('a', 'click', function(oEvent){
var $this, $mid_select, val, list;
$this = $(this);
list = $this.data('moduleInstanceList');
if(!list) return;
$moduleInstanceList.empty();
for(var x in list) {
if(!list.hasOwnProperty(x)) continue;
$li = $('<li />').appendTo($moduleInstanceList);
$('<a href="#" >').html(
'<div>'+list[x].browser_title+'</div>'
).data('module_srl', list[x].module_srl).appendTo($li);
}
$moduleInstanceListDiv.show();
setListSize($moduleInstanceList, MAX_LIST_HEIGHT);
$moduleTypeList.find('li').removeClass('on');
$this.parent('li').addClass('on');
oEvent.preventDefault();
})
.end()
.find('.moduleInstanceListUL')
.delegate('a','click',function(oEvent){
$this = $(this);
var target_module = $this.text();
var index_module_srl = $this.data('module_srl');
$('#_target_module').val(target_module);
$('#index_module_srl').val(index_module_srl);
$('.tgAnchor.moduleSearch').trigger('close.tc');
oEvent.preventDefault();
});
return this;
};
$('.modulefinder').xeModuleSearch();
});
// Sortable table
jQuery(function($){
@ -1250,4 +1440,4 @@ jQuery(function($){
}
});
});
});
});

File diff suppressed because one or more lines are too long

View file

@ -2,7 +2,7 @@ jQuery(function(b){function k(a){if(moduleList=a.menuList){var c=b("#menuNameLis
b(this).parent().prevAll("._parent_key").val();a.find("input[name=menu_item_srl]").val(i);a.submit()});b("a._child_delete").click(function(){var i=b(this).parents("li").find("._item_key").val();a.find("input[name=menu_item_srl]").val(i);a.submit()})});
jQuery(function(b){function k(a,b){for(var c=0,e=0;a&&a!=b;)c+=a.offsetTop,e+=a.offsetLeft,a=a.offsetParent;return{top:c,left:e}}b("form.siteMap").delegate("li:not(.placeholder)","dropped.st",function(){var a=b(this),d;d=a.find(">input._parent_key");a.parent("ul").parent("li").length?d.val(a.parent("ul").parent("li").find(">input._item_key").val()):d.val("0")});var d=!1,h=b('<li class="placeholder">');b("div.adminMenu").delegate("li:not(.placeholder,.parent)",{"mousedown.st":function(a){var i,c,e,
f,m,n,j,l,g;if(!(b(a.target).is("a,input,label,textarea")||1!=a.which)){d=!0;c=b(this);n=c.height();m=c.width();e=c.parentsUntil(".siteMap").filter("ul");f=e.eq(-1);f.css("position","relative");i=a.pageY;j=k(this,f.get(0));$clone=c.clone(!0).attr("target",!0);for(a=e.length-1;a;a--)$clone=$clone.wrap("<li><ul /></li>").parent().parent();l=[];f.find("li").each(function(){if(c[0]===this||c.has(this).length)return!0;var a=k(this,f.get(0));l.push({top:a.top,bottom:a.top+32,$item:b(this)})});$clone.find(".side,input").remove().end().addClass("draggable").css({position:"absolute",
opacity:0.6,width:m,height:n,left:j.left,top:j.top,zIndex:100}).appendTo(f.eq(0));h.css({position:"absolute",opacity:0.6,width:m,height:"10px",left:j.left,top:j.top,zIndex:99}).appendTo(f.eq(0));c.css("opacity",0.6);b(document).unbind("mousemove.st mouseup.st").bind("mousemove.st",function(a){var b,c,d;g=null;a=j.top-(i-a.pageY);for(b=0,c=l.length;b<c;b++)d=l[b],d.top>a||d.bottom<a||(g={element:d.$item},d.$item.hasClass("parent")?(g.state="prepend",h.css("top",d.bottom-5)):d.top>a-12?(g.state="before",
opacity:0.6,width:m,height:n,left:j.left,top:j.top,zIndex:100}).appendTo(f.eq(0));h.css({position:"absolute",opacity:0.6,width:m,height:"10px",left:j.left,top:j.top,zIndex:99}).appendTo(f.eq(0));c.css("opacity",0.6);b(document).unbind("mousemove.st mouseup.st").bind("mousemove.st",function(a){var b,c,d;g=null;a=j.top-(i-a.pageY);b=0;for(c=l.length;b<c;b++)d=l[b],d.top>a||d.bottom<a||(g={element:d.$item},d.$item.hasClass("parent")?(g.state="prepend",h.css("top",d.bottom-5)):d.top>a-12?(g.state="before",
h.css("top",d.top-5)):(g.state="after",h.css("top",d.bottom-5)));$clone.css({top:a})}).bind("mouseup.st",function(){var a,e;d=!1;b(document).unbind("mousemove.st mouseup.st");c.css("opacity","");$clone.remove();h.remove();e=b("<li />").height(c.height());if(g){a=b(g.element);c.before(e);if("prepend"==g.state)a.find(">ul").length||a.find(">.side").after("<ul>"),a.find(">ul").prepend(c.hide());else a[g.state](c.hide());c.slideDown(100,function(){c.removeClass("active")});e.slideUp(100,function(){var a=
e.parent();e.remove();a.children("li").length||a.remove()});c.trigger("dropped.st")}});return!1}},"mouseover.st":function(){d||b(this).addClass("active");return!1},"mouseout.st":function(){d||b(this).removeClass("active");return!1}}).find("li").prepend('<button type="button" class="moveTo">Move to</button>').filter(".parent").find(">button.moveTo").css({visibility:"hidden","margin-left":"-12px"}).end().end().end();b('<div id="dropzone-marker" />').css({display:"none",position:"absolute",backgroundColor:"#000",
opacity:0.7}).appendTo("body")});

View file

@ -1,6 +1,6 @@
jQuery(function(c){function o(a,c){for(var b=0,g=0;a&&a!=c;)b+=a.offsetTop,g+=a.offsetLeft,a=a.offsetParent;return{top:b,left:g}}var l=!1,k=c('<li class="placeholder">');c("form.siteMap").delegate("li:not(.placeholder)",{"mousedown.st":function(a){var d,b,g,h,n,p,i,m,j;if(!(c(a.target).is("a,input,label,textarea")||1!=a.which)){l=!0;b=c(this);p=b.height();n=b.width();g=b.parentsUntil(".siteMap").filter("ul");h=g.eq(-1);h.css("position","relative");d=a.pageY;i=o(this,h.get(0));$clone=b.clone(!0).attr("target",
!0);for(a=g.length-1;a;a--)$clone=$clone.wrap("<li><ul /></li>").parent().parent();m=[];h.find("li").each(function(){if(b[0]===this||b.has(this).length)return!0;var a=o(this,h.get(0));m.push({top:a.top,bottom:a.top+32,item:this})});$clone.find(".side,input").remove().end().addClass("draggable").css({position:"absolute",opacity:0.6,width:n,height:p,left:i.left,top:i.top,zIndex:100}).appendTo(h.eq(0));k.css({position:"absolute",opacity:0.6,width:n,height:"5px",left:i.left,top:i.top,zIndex:99}).appendTo(h.eq(0));
b.css("opacity",0.6);c(document).unbind("mousemove.st mouseup.st").bind("mousemove.st",function(a){var b,c,e,f;j=null;a=i.top-(d-a.pageY);for(b=0,c=m.length;b<c;b++)if(f=a,e=m[b],0==b&&f<e.top&&(f=e.top),b==c-1&&f>e.bottom&&(f=e.bottom),e.top<=f&&e.bottom>=f){b=e.item;3>=Math.abs(e.top-f)?(k.css({top:e.top-3,height:"5px"}),f="before"):3>=Math.abs(e.bottom-f)?(k.css({top:e.bottom-3,height:"5px"}),f="after"):(k.css({top:e.top+3,height:"27px"}),f="prepend");j={element:b,state:f};break}$clone.css({top:a})}).bind("mouseup.st",
b.css("opacity",0.6);c(document).unbind("mousemove.st mouseup.st").bind("mousemove.st",function(a){var b,c,e,f;j=null;a=i.top-(d-a.pageY);b=0;for(c=m.length;b<c;b++)if(f=a,e=m[b],0==b&&f<e.top&&(f=e.top),b==c-1&&f>e.bottom&&(f=e.bottom),e.top<=f&&e.bottom>=f){b=e.item;3>=Math.abs(e.top-f)?(k.css({top:e.top-3,height:"5px"}),f="before"):3>=Math.abs(e.bottom-f)?(k.css({top:e.bottom-3,height:"5px"}),f="after"):(k.css({top:e.top+3,height:"27px"}),f="prepend");j={element:b,state:f};break}$clone.css({top:a})}).bind("mouseup.st",
function(){var a,d;l=!1;c(document).unbind("mousemove.st mouseup.st");b.css("opacity","");$clone.remove();k.remove();d=c("<li />").height(b.height());if(j){a=c(j.element);b.before(d);if("prepend"==j.state)a.find(">ul").length||a.find(">.side").after("<ul>"),a.find(">ul").prepend(b.hide());else a[j.state](b.hide());b.slideDown(100,function(){b.removeClass("active")});d.slideUp(100,function(){var a=d.parent();d.remove();a.children("li").length||a.remove()});b.trigger("dropped.st")}});return!1}},"mouseover.st":function(){l||
c(this).addClass("active");return!1},"mouseout.st":function(){l||c(this).removeClass("active");return!1}}).find("li").prepend('<button type="button" class="moveTo">Move to</button>').append('<span class="vr"></span><span class="hr"></span>').find("input:text").focus(function(){var a=c(this),d=a.prev("label"),b=a.parent();a.width(b.width()-(parseInt(b.css("text-indent"))||0)-a.next(".side").width()-60).css("opacity","");d.hide()}).blur(function(){var a=c(this),d=a.prev("label"),b=a.val();a.width(0).css("opacity",
0);d.removeClass("no-text").empty().text(b).show();b||d.addClass("no-text").text("---")}).each(function(a){var d=c(this),a="sitemap-id-"+a;d.attr("id",a).css({width:0,opacity:0,overflow:"hidden"}).before("<label />").prev("label").attr("for",a).text(d.val())}).end().end()});