From 41a5b5734488cc4e01ab5cdc953d59c4c06b657a Mon Sep 17 00:00:00 2001 From: dragan-dan Date: Thu, 8 Dec 2011 15:10:22 +0000 Subject: [PATCH] Enhanced filebox to add multiple attributes per image and also improved the filebox controlled used for widgets to add multiple images at the same time if you set the parameter allow_multiple=Y git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9929 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- common/js/plugins/filebox/filebox.js | 63 ++++++++++++ modules/admin/tpl/js/admin.js | 16 +++- modules/admin/tpl/js/admin.min.js | 54 +++++------ modules/module/lang/lang.xml | 12 +++ modules/module/module.controller.php | 8 +- modules/module/module.model.php | 33 ++++++- modules/module/tpl/adminFileBox.html | 25 ++++- modules/module/tpl/filebox_list_html.html | 10 +- modules/widget/tpl/js/generate_code.js | 45 ++++++++- .../tpl/widget_generate_code.filebox.html | 96 ++++++++++++++++--- modules/widget/widget.model.php | 2 + 11 files changed, 305 insertions(+), 59 deletions(-) diff --git a/common/js/plugins/filebox/filebox.js b/common/js/plugins/filebox/filebox.js index 92137822a..82d9f55f1 100644 --- a/common/js/plugins/filebox/filebox.js +++ b/common/js/plugins/filebox/filebox.js @@ -80,3 +80,66 @@ $.extend(window.XE, {'filebox' : filebox}); }) (jQuery); + +function addRow(tableID){ + + var table = document.getElementById(tableID); + var rowCount = table.rows.length; + var initial = table.rows(0); + var text1 = initial.cells(0).children(0).innerHTML; + var text2 = initial.cells(1).children(0).innerHTML; + var addrow = table.rows(rowCount-2).cells(2).children(0); + var deleteLink = table.rows(rowCount-2).cells(3).children(0).cloneNode(true); + var row = table.insertRow(rowCount-1); + + //cell for attribute name + var cell0= row.insertCell(0) + var element0 = document.createElement("label"); + element0.innerHTML = text1; + element0.htmlFor = "attribute_name"+rowCount; + cell0.appendChild(element0); + var element1 = document.createElement("input"); + element1.type = "text"; + element1.name="attribute_name"+rowCount; + element1.id="attribute_name"+rowCount; + cell0.appendChild(element1); + + //cell for attribute value + var cell1 = row.insertCell(1); + var element2 = document.createElement("label"); + element2.innerHTML = text2; + element2.htmlFor = "attribute_value"+rowCount; + cell1.appendChild(element2); + var element3 = document.createElement("input"); + element3.type = "text"; + element3.id="attribute_value"+rowCount; + element3.name="attribute_value"+rowCount; + cell1.appendChild(element3); + + //cell for addrow link + var cell2 = row.insertCell(2); + cell2.appendChild(addrow); + + //cell for delete link + var cell3 = row.insertCell(3); + deleteLink.href = "javascript:clearRow('attributes',"+rowCount+")"; + cell3.appendChild(deleteLink); +} + +function clearRow(tableID,rowNumber){ + var table = document.getElementById(tableID); + var text = "attribute_name"+rowNumber; + var rowCount = table.rows.length; + var sw = 0; + for(i=0;iinput:text,>input:password,>textarea").filter('input[value!=""],textarea:not(:empty)').prev("label").css("visibility","hidden").end().end().prev("label").addClass("overlap").css({top:"15px",left:"5px"}).next().focus(function(){var b=a(this).prev().stop().animate({opacity:0,left:"25px"},"fast",function(){b.css("visibility","hidden")})}).blur(function(){var b=a(this);a.trim(b.val())==""&&b.prev().stop().css("visibility","visible").animate({opacity:1,left:"5px"}, +jQuery(function(a){a(".form li").find(">input:text,>input:password,>textarea").filter('input[value!=""],textarea:not(:empty)').prev("label").css("visibility","hidden").end().end().prev("label").addClass("overlap").css({top:"15px",left:"5px"}).next().focus(function(){var b=a(this).prev().stop().animate({opacity:0,left:"25px"},"fast",function(){b.css("visibility","hidden")})}).blur(function(){var b=a(this);""==a.trim(b.val())&&b.prev().stop().css("visibility","visible").animate({opacity:1,left:"5px"}, "fast")}).end().parent().css("position","relative");var c=a("input:radio+label,input:checkbox+label").prev("input");c.change(function(){var b=a(this).attr("name");c.filter(function(){return this.name==b}).next("label").css("font-weight","normal").end().filter(":checked").next("label").css("font-weight","bold").end()}).change();a(".form th>input: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.fn.xePagination=function(){this.not(".xe-pagination").addClass("xe-pagination").find("span.tgContent").css("whiteSpace","nowrap").end().find("a.tgAnchor").each(function(){var b=a(this);b.after(a(b.attr("href")))}).end();return this};a(".pagination").xePagination();a(".portlet .action").css({display:"none",position:"absolute"}).parent().mouseleave(function(){a(this).find(">.action").fadeOut(100)}).mouseenter(function(){a(this).find(">.action").fadeIn(100)}).focusin(function(){a(this).mouseenter()}).focusout(function(){var b= -a(this),d;clearTimeout(b.data("timer"));d=setTimeout(function(){b.find(":focus").length||b.mouseleave()},10);b.data("timer",d)});a(window).resize(function(){a(document).width()<1300?(a(".dashboard>.section>br").remove(),a(".dashboard>.section>.portlet:odd").after('
')):(a(".dashboard>.section>br").remove(),a(".dashboard>.section>.portlet:eq(2),.dashboard>.section>.portlet:eq(5)").after('
'))});a(window).resize();a(".header>.siteTool>a.i").bind("before-open.tc", +a(this),d;clearTimeout(b.data("timer"));d=setTimeout(function(){b.find(":focus").length||b.mouseleave()},10);b.data("timer",d)});a(window).resize(function(){1300>a(document).width()?(a(".dashboard>.section>br").remove(),a(".dashboard>.section>.portlet:odd").after('
')):(a(".dashboard>.section>br").remove(),a(".dashboard>.section>.portlet:eq(2),.dashboard>.section>.portlet:eq(5)").after('
'))});a(window).resize();a(".header>.siteTool>a.i").bind("before-open.tc", function(){a(this).addClass("active").next("div.tgContent").find(">.section:gt(0)").hide().end().find(">.btnArea>button").show()}).bind("after-close.tc",function(){a(this).removeClass("active")}).next("#siteMapList").find(">.section:last").after('

').find("+p>button").click(function(){a(this).hide().parent().prevAll(".section").show()});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(/(@.+)$/,'...$1')).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()}); jQuery(function(a){a.fn.xeMenu=function(){this.removeClass("jx").attr("role","navigation").find("li").attr("role","menuitem").find(">ul").hide().end().filter(":has(>ul)").attr("aria-haspopup","true").end().end().delegate("li",{mouseover:function(){a(this).addClass("active").find(">ul").show().end().parentsUntil(".gnb").filter("li").addClass("active").end().end()},mouseleave:function(){a(this).removeClass("active").find(">ul").hide()},focusout:function(){var c=a(this);setTimeout(function(){c.find(":focus").length|| c.removeClass("active").find(">ul").hide()},1)}}).delegate("a",{focus:function(){a(this).parent("li").mouseover()}})};a("div.gnb").xeMenu()}); -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 c=a(this),b,d;b=a(c.attr("href"));b.parent("body").length||(d=a(''),d.click(function(){b.data("anchor").trigger("close.mw")}),b.prepend('').append('<\!--[if IE 6]>').find(">.fg").prepend(d).append(d.clone(true)).end().appendTo("body")); -b.data("anchor",c);b.data("state")=="showing"?c.trigger("close.mw"):c.trigger("open.mw");return false}).bind("open.mw",function(){var c=a(this),b,d;b=a.Event("before-open.mw");c.trigger(b);if(b.isDefaultPrevented())return false;b=a(c.attr("href"));d=c.data("duration")||"fast";b.data("state","showing");a("html,body").addClass("modalContainer");a(document).bind("keydown.mw",function(a){if(a.which==27)return c.trigger("close.mw"),false});b.fadeIn(d,function(){c.trigger("after-open.mw")}).find(">.bg").height(a(document).height()).end().find("button.modalClose:first").focus()}).bind("close.mw", -function(){var c=a(this),b,d;b=a.Event("before-close.mw");c.trigger(b);if(b.isDefaultPrevented())return false;b=a(c.attr("href"));d=c.data("duration")||"fast";b.data("state","hiding");a("html,body").removeClass("modalContainer");b.fadeOut(d,function(){c.trigger("after-close.mw")});c.focus()})};a("a.modalAnchor").xeModalWindow();a("div.modal").addClass("x").hide()}); -jQuery(function(a){var c=false;a.fn.xeContentToggler=function(){this.not(".xe-content-toggler").addClass("xe-content-toggler").each(function(){var b=a(this);$layer=a(b.attr("href"));$layer.hide().not(".xe-toggling-content").addClass("xe-toggling-content").mousedown(function(){c=true}).focusout(function(){setTimeout(function(){!c&&!$layer.find(":focus").length&&$layer.data("state")=="showing"&&b.trigger("close.tc");c=false},1)})}).click(function(){var b=a(this),d;d=a(b.attr("href"));d.data("anchor", -b);d.data("state")=="showing"?b.trigger("close.tc"):b.trigger("open.tc");return false}).bind("open.tc",function(){function b(){d.trigger("after-open.tc")}var d=a(this),g,f,e;g=a(d.attr("href"));f=d.data("effect");e=d.data("duration")||"fast";g.data("state","showing");d.trigger("before-open.tc");c=false;a(document).unbind("mousedown.tc keydown.tc").bind("mousedown.tc keydown.tc",function(b){if(b){if(b.type=="keydown"&&b.which!=27)return true;if(b.type=="mousedown"&&(b=a(b.target),b.is("html,.tgAnchor,.tgContent")|| -g.has(b).length))return true}d.trigger("close.tc");return false});switch(f){case "slide":g.slideDown(e,b);break;case "slide-h":f=g.css({"overflow-x":"",width:""}).width();g.show().css({"overflow-x":"hidden",width:"0px"}).animate({width:f},e,function(){g.css({"overflow-x":"",width:""});b()});break;case "fade":g.fadeIn(e,b);break;default:g.show(),d.trigger("after-open.tc")}}).bind("close.tc",function(){function b(){d.trigger("after-close.tc")}var d=a(this),c,f,e;a(document).unbind("mousedown.tc keydown.tc"); -c=a(d.attr("href"));f=d.data("effect");e=d.data("duration")||"fast";c.data("state","hiding");d.trigger("before-close.tc");switch(f){case "slide":c.slideUp(e,b);break;case "slide-h":c.animate({width:0},e,function(){c.hide();b()});break;case "fade":c.fadeOut(e,b);break;default:c.hide(),d.trigger("after-close.tc")}});return this};a("a.tgAnchor").xeContentToggler()}); +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 c=a(this),b,d;b=a(c.attr("href"));b.parent("body").length||(d=a(''),d.click(function(){b.data("anchor").trigger("close.mw")}),b.prepend('').append('<\!--[if IE 6]>').find(">.fg").prepend(d).append(d.clone(!0)).end().appendTo("body")); +b.data("anchor",c);"showing"==b.data("state")?c.trigger("close.mw"):c.trigger("open.mw");return!1}).bind("open.mw",function(){var c=a(this),b,d;b=a.Event("before-open.mw");c.trigger(b);if(b.isDefaultPrevented())return!1;b=a(c.attr("href"));d=c.data("duration")||"fast";b.data("state","showing");a("html,body").addClass("modalContainer");a(document).bind("keydown.mw",function(a){if(27==a.which)return c.trigger("close.mw"),!1});b.fadeIn(d,function(){c.trigger("after-open.mw")}).find(">.bg").height(a(document).height()).end().find("button.modalClose:first").focus()}).bind("close.mw", +function(){var c=a(this),b,d;b=a.Event("before-close.mw");c.trigger(b);if(b.isDefaultPrevented())return!1;b=a(c.attr("href"));d=c.data("duration")||"fast";b.data("state","hiding");a("html,body").removeClass("modalContainer");b.fadeOut(d,function(){c.trigger("after-close.mw")});c.focus()})};a("a.modalAnchor").xeModalWindow();a("div.modal").addClass("x").hide()}); +jQuery(function(a){var c=!1;a.fn.xeContentToggler=function(){this.not(".xe-content-toggler").addClass("xe-content-toggler").each(function(){var b=a(this);$layer=a(b.attr("href"));$layer.hide().not(".xe-toggling-content").addClass("xe-toggling-content").mousedown(function(){c=!0}).focusout(function(){setTimeout(function(){!c&&!$layer.find(":focus").length&&"showing"==$layer.data("state")&&b.trigger("close.tc");c=!1},1)})}).click(function(){var b=a(this),d;d=a(b.attr("href"));d.data("anchor",b);"showing"== +d.data("state")?b.trigger("close.tc"):b.trigger("open.tc");return!1}).bind("open.tc",function(){function b(){d.trigger("after-open.tc")}var d=a(this),g,f,e;g=a(d.attr("href"));f=d.data("effect");e=d.data("duration")||"fast";g.data("state","showing");d.trigger("before-open.tc");c=!1;a(document).unbind("mousedown.tc keydown.tc").bind("mousedown.tc keydown.tc",function(b){if(b){if("keydown"==b.type&&27!=b.which)return!0;if("mousedown"==b.type&&(b=a(b.target),b.is("html,.tgAnchor,.tgContent")||g.has(b).length))return!0}d.trigger("close.tc"); +return!1});switch(f){case "slide":g.slideDown(e,b);break;case "slide-h":f=g.css({"overflow-x":"",width:""}).width();g.show().css({"overflow-x":"hidden",width:"0px"}).animate({width:f},e,function(){g.css({"overflow-x":"",width:""});b()});break;case "fade":g.fadeIn(e,b);break;default:g.show(),d.trigger("after-open.tc")}}).bind("close.tc",function(){function b(){d.trigger("after-close.tc")}var d=a(this),c,f,e;a(document).unbind("mousedown.tc keydown.tc");c=a(d.attr("href"));f=d.data("effect");e=d.data("duration")|| +"fast";c.data("state","hiding");d.trigger("before-close.tc");switch(f){case "slide":c.slideUp(e,b);break;case "slide-h":c.animate({width:0},e,function(){c.hide();b()});break;case "fade":c.fadeOut(e,b);break;default:c.hide(),d.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 c,b,d;c=a(this);b=a(c.attr("href")).find(">ul");d=c.prev("input:text").val();a.exec_json("admin.getSiteAllList",{domain:d},function(d){var f=d.site_list,e,i;b.empty();c.closest(".modulefinder").find(".moduleList,.moduleIdList").attr("disabled","disabled");if(d.error||!a.isArray(f))c.trigger("close.tc");else for(e=0,i=f.length;e< i;e++)d=a("
  • ").appendTo(b),a(''; + if(i==0) $(this).siblings('input').val(src[i].id); + else { + var aux = $(this).siblings('input').val(); + $(this).siblings('input').val(aux+","+src[i].id); + } + } + else { + if(src[i]){ + htmlCode += ''; + if(i==0) $(this).siblings('input').val(src[i]); + else { + var aux = $(this).siblings('input').val(); + $(this).siblings('input').val(aux+","+src[i]); + } + } + } + } + } else { + htmlCode = ' '; + $(this).siblings('input').val(src); + } + $(this).before(htmlCode); - $(this).before(' '); - - $(this).siblings('input').val(src); + $('.filebox_del').bind('click', function(){ - $(this).siblings('input').val(''); + var filename = $(this).prev('img').attr("src"); + var files = $(this).siblings('input').val().split(","); + var newInput = ""; + for(var i=0;i - - @@ -16,20 +12,92 @@ -
      -
    • -

      -

      -
    • -
    • -

      -

      -
    • -
    + + + + + + + + + + +
    + + + + {$lang->add}{$lang->delete}
    + +
    + \ No newline at end of file diff --git a/modules/widget/widget.model.php b/modules/widget/widget.model.php index 08a476407..46966ef6b 100644 --- a/modules/widget/widget.model.php +++ b/modules/widget/widget.model.php @@ -228,6 +228,7 @@ $name = $var->name->body?$var->name->body:$var->title->body; $type = $var->attrs->type?$var->attrs->type:$var->type->body; if($type =='filebox') $buff .= sprintf('$widget_info->extra_var->%s->filter = "%s";', $id, $var->type->attrs->filter); + if($type =='filebox') $buff .= sprintf('$widget_info->extra_var->%s->allow_multiple = "%s";', $id, $var->type->attrs->allow_multiple); $buff .= sprintf('$widget_info->extra_var->%s->group = "%s";', $id, $group->title->body); $buff .= sprintf('$widget_info->extra_var->%s->name = "%s";', $id, $name); @@ -374,6 +375,7 @@ $buff .= sprintf('$widgetStyle_info->extra_var->%s->name = "%s";', $id, $name); $buff .= sprintf('$widgetStyle_info->extra_var->%s->type = "%s";', $id, $type); if($type =='filebox') $buff .= sprintf('$widgetStyle_info->extra_var->%s->filter = "%s";', $id, $var->attrs->filter); + if($type =='filebox') $buff .= sprintf('$widgetStyle_info->extra_var->%s->allow_multiple = "%s";', $id, $var->attrs->allow_multiple); $buff .= sprintf('$widgetStyle_info->extra_var->%s->value = $vars->%s;', $id, $id); $buff .= sprintf('$widgetStyle_info->extra_var->%s->description = "%s";', $id, str_replace('"','\"',$var->description->body));