From 8d4bd6be6b5e36178ba62809c6d90124094bc63c Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Sat, 28 Dec 2024 10:33:41 +0100 Subject: [PATCH] Add support for SVG icons for toggler --- src/Resources/public/js/generalDriver.js | 16 ++------------- src/Resources/public/js/generalDriver.js.map | 1 + src/Resources/public/js/generalDriver_src.js | 21 ++++++++++---------- 3 files changed, 14 insertions(+), 24 deletions(-) create mode 100644 src/Resources/public/js/generalDriver.js.map diff --git a/src/Resources/public/js/generalDriver.js b/src/Resources/public/js/generalDriver.js index 6624502fd..16cc5df54 100644 --- a/src/Resources/public/js/generalDriver.js +++ b/src/Resources/public/js/generalDriver.js @@ -1,14 +1,2 @@ -/** - * Class Backend - * - * Provide methods to handle back end tasks. - * Special functions for DC_General - * - * @copyright The MetaModels team. - * @author Christian Schiffler - * @author Stefan Heimes - * @author Tristan Lins - * @author Sven Baumann - */ - -var BackendGeneral={loadSubTree:function(el,data){el.blur();var id=data.toggler,level=data.level,mode=data.mode,item=$(id),image=$(el).getFirst("img");data.action="DcGeneralLoadSubTree";data.REQUEST_TOKEN=Contao.request_token;if(item){if(item.getStyle("display")=="none"){item.setStyle("display","inline");image.src=image.src.replace("folPlus.svg","folMinus.svg");$(el).store("tip:title",Contao.lang.collapse);new Request.Contao({url:data.url,field:el}).post(data);}else{item.setStyle("display","none");image.src=image.src.replace("folMinus.svg","folPlus.svg");$(el).store("tip:title",Contao.lang.expand);new Request.Contao({url:data.url,field:el}).post(data);}return false;}new Request.Contao({url:data.url,field:el,evalScripts:true,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(txt,json){var li=new Element("li",{id:id,"class":"parent",styles:{display:"inline"}});var ul=new Element("ul",{"class":"level_"+level,html:txt}).inject(li,"bottom");if(mode==5){li.inject($(el).getParent("li"),"after");}else{var parent=$(el).getParent("li");li.inject(parent,"after");}li.getElements("a").each(function(el){el.href=el.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id);});$(el).store("tip:title",Contao.lang.collapse);image.src=image.src.replace("folPlus.svg","folMinus.svg");window.fireEvent("structure");AjaxRequest.hideBox();window.fireEvent("ajax_change");}}).post(data);return false;},toggleVisibility:function(el,icon,icon_disabled){el.blur();if(!icon){icon="visible.svg";}if(!icon_disabled){icon_disabled="invisible.svg";}var img=null,image=$(el).getFirst("img"),publish=(image.src.indexOf(icon_disabled)!=-1),div=el.getParent("div"),next,listIcon;new Request.Contao({url:$(el).href,followRedirects:false,onSuccess:function(){if(div.hasClass("tl_right")){img=div.getPrevious("div").getElement("img");}else{if(div.hasClass("tl_listing_container")){img=el.getParent("td").getPrevious("td").getFirst("div.list_icon");if(img==null){img=el.getParent("td").getPrevious("td").getElement("div.cte_type");}if(img==null){img=el.getParent("tr").getFirst("td").getElement("div.list_icon_new");}}else{if((next=div.getNext("div"))&&next.hasClass("cte_type")){img=next;}}}if((img===null)&&(listIcon=el.getParent().getParent().getElements("div.list_icon").getFirst().getParent())){img=listIcon[0];}if(img!=null){if(img.nodeName.toLowerCase()=="img"){if(img.getParent("ul.tl_listing").hasClass("tl_tree_xtnd")){if(publish){img.src=img.src.replace(/_1\.(gif|png|jpe?g)/,".$1");}else{img.src=img.src.replace(/\.(gif|png|jpe?g)/,"_1.$1");}}else{if(img.src.match(/folPlus|folMinus/)){if(img.getParent("a").getNext("a")){img=img.getParent("a").getNext("a").getFirst("img");}else{img=new Element("img");}}var index;if(publish){index=img.src.replace(/.*_([0-9])\.(gif|png|jpe?g)/,"$1");img.src=img.src.replace(/_[0-9]\.(gif|png|jpe?g)/,((index.toInt()==1)?"":"_"+(index.toInt()-1))+".$1");}else{index=img.src.replace(/.*_([0-9])\.(gif|png|jpe?g)/,"$1");img.src=img.src.replace(/(_[0-9])?\.(gif|png|jpe?g)/,((index==img.src)?"_1":"_"+(index.toInt()+1))+".$2");}}}else{if(img.hasClass("cte_type")){if(publish){img.addClass("published");img.removeClass("unpublished");}else{img.addClass("unpublished");img.removeClass("published");}}else{if(publish){img.setStyle("background-image",img.getStyle("background-image").replace(/_\.(gif|png|jpe?g)/,".$1"));}else{img.setStyle("background-image",img.getStyle("background-image").replace(/\.(gif|png|jpe?g)/,"_.$1"));}}}}if(publish){image.src=image.src.replace(icon_disabled,icon);}else{image.src=image.src.replace(icon,icon_disabled);}}}).get({state:(publish?1:0)});return false;},setLegendState:function(el,legend,table){el.blur();var fs=$("pal_"+legend);if(fs.hasClass("collapsed")){fs.removeClass("collapsed");new Request.Contao().post({action:"setLegendState",legend:legend,table:table,state:1,REQUEST_TOKEN:Contao.request_token});}else{fs.addClass("collapsed");new Request.Contao().post({action:"setLegendState",legend:legend,table:table,state:0,REQUEST_TOKEN:Contao.request_token});}return false;}}; +var BackendGeneral={loadSubTree:function(e,t){e.blur();var l=t.toggler,n=t.level,s=t.mode,a=$(l),i=$(e).getFirst("img");return t.action="DcGeneralLoadSubTree",t.REQUEST_TOKEN=Contao.request_token,a?("none"==a.getStyle("display")?(a.setStyle("display","inline"),i.src=i.src.replace("folPlus.svg","folMinus.svg"),$(e).store("tip:title",Contao.lang.collapse),new Request.Contao({url:t.url,field:e}).post(t)):(a.setStyle("display","none"),i.src=i.src.replace("folMinus.svg","folPlus.svg"),$(e).store("tip:title",Contao.lang.expand),new Request.Contao({url:t.url,field:e}).post(t)),!1):(new Request.Contao({url:t.url,field:e,evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(t,a){var r=new Element("li",{id:l,class:"parent",styles:{display:"inline"}});new Element("ul",{class:"level_"+n,html:t}).inject(r,"bottom");if(5==s)r.inject($(e).getParent("li"),"after");else{var o=$(e).getParent("li");r.inject(o,"after")}r.getElements("a").each((function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)})),$(e).store("tip:title",Contao.lang.collapse),i.src=i.src.replace("folPlus.svg","folMinus.svg"),window.fireEvent("structure"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post(t),!1)},toggleVisibility:function(e,t,l){e.blur(),t||(t="visible.svg"),l||(l="invisible.svg");var n,s,a=null,i=$(e).getFirst("img"),r=-1!=i.src.indexOf(l),o=e.getParent("div");return new Request.Contao({url:$(e).href,followRedirects:!1,onSuccess:function(){var c;(o.hasClass("tl_right")?a=o.getPrevious("div").getElement("img"):o.hasClass("tl_listing_container")?(null==(a=e.getParent("td").getPrevious("td").getFirst("div.list_icon"))&&(a=e.getParent("td").getPrevious("td").getElement("div.cte_type")),null==a&&(a=e.getParent("tr").getFirst("td").getElement("div.list_icon_new"))):(n=o.getNext("div"))&&n.hasClass("cte_type")&&(a=n),null===a&&(s=e.getParent().getParent().getElements("div.list_icon").getFirst().getParent())&&(a=s[0]),null!=a)&&("img"==a.nodeName.toLowerCase()?a.getParent("ul.tl_listing").hasClass("tl_tree_xtnd")?a.src=r?a.src.replace(/_1\.(gif|png|jpe?g|svg)/,".$1"):a.src.replace(/\.(gif|png|jpe?g|svg)/,"_1.$1"):(a.src.match(/folPlus|folMinus/)&&(a=a.getParent("a").getNext("a")?a.getParent("a").getNext("a").getFirst("img"):new Element("img")),r?(c=a.src.replace(/.*_([0-9])\.(gif|png|jpe?g|svg)/,"$1"),a.src=a.src.replace(/_[0-9]\.(gif|png|jpe?g|svg)/,(1==c.toInt()?"":"_"+(c.toInt()-1))+".$1")):(c=a.src.replace(/.*_([0-9])\.(gif|png|jpe?g|svg)/,"$1"),a.src=a.src.replace(/(_[0-9])?\.(gif|png|jpe?g|svg)/,(c==a.src?"_1":"_"+(c.toInt()+1))+".$2"))):a.hasClass("cte_type")?r?(a.addClass("published"),a.removeClass("unpublished")):(a.addClass("unpublished"),a.removeClass("published")):r?a.setStyle("background-image",a.getStyle("background-image").replace(/_\.(gif|png|jpe?g|svg)/,".$1")):a.setStyle("background-image",a.getStyle("background-image").replace(/\.(gif|png|jpe?g|svg)/,"_.$1")));i.src=r?i.src.replace(l,t):i.src.replace(t,l)}}).get({state:r?1:0}),!1},setLegendState:function(e,t,l){e.blur();var n=$("pal_"+t);return n.hasClass("collapsed")?(n.removeClass("collapsed"),(new Request.Contao).post({action:"setLegendState",legend:t,table:l,state:1,REQUEST_TOKEN:Contao.request_token})):(n.addClass("collapsed"),(new Request.Contao).post({action:"setLegendState",legend:t,table:l,state:0,REQUEST_TOKEN:Contao.request_token})),!1},displayMessage:function(e,t,l){var n=$("general_messageBox"),s=$("general_messageOverlay"),a=window.getScroll();null===s&&(s=new Element("div",{id:"general_messageOverlay"}).inject($(document.body),"bottom")),s.set({styles:{display:"block",top:a.y+"px"}}),null===n&&(n=new Element("div",{id:"general_messageBox"}).inject($(document.body),"bottom")),n.set({html:e,styles:{display:"block",top:a.y+100+"px"}}),l&&n.addClass(l),t&&n.addClass("loading")},hideMessage:function(){var e=$("general_messageBox"),t=$("general_messageOverlay");t&&t.setStyle("display","none"),e&&e.setStyle("display","none"),t.remove(),e.remove()},confirmSelectOverrideEditAll:function(e,t,l){e.blur();var n=e.form.elements[t],s=!1;return $$(n).each((function(e){if(s||!e.checked)return!0;s=!0})),s?("delete"===e.name||(e.onclick="",e.click()),!0):(this.displayMessage(l,!1,"box-small"),!1)},confirmSelectDeleteAll:function(e,t,l,n,s,a){return e.blur(),!!this.confirmSelectOverrideEditAll(e,t,l)&&(this.confirmDelete(e,n,s,a),!0)},confirmDelete:function(e,t,l,n){var s=new Element("div"),a=(new Element("h2",{html:t,class:"tl_info"}).inject(s,"bottom"),new Element("p").inject(s,"bottom"),new Element("div",{class:"tl_submit_container"}).inject(s,"bottom")),i=new Element("input",{id:e.name+"Ok",name:e.name+"Ok",value:l,type:"submit",class:"tl_submit"}).inject(a,"bottom"),r=new Element("input",{id:e.name+"Abort",name:e.name+"Abort",value:n,type:"submit",class:"tl_submit"}).inject(a,"bottom");return this.displayMessage(s.get("html"),!1,"box-small"),$(i.id).addEvent("click",(function(){e.onclick="",e.click()})),$(r.id).addEvent("click",(function(){BackendGeneral.hideMessage()})),!0}}; +//# sourceMappingURL=generalDriver.js.map \ No newline at end of file diff --git a/src/Resources/public/js/generalDriver.js.map b/src/Resources/public/js/generalDriver.js.map new file mode 100644 index 000000000..9e3f9c5b1 --- /dev/null +++ b/src/Resources/public/js/generalDriver.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["generalDriver_src.js"],"names":[],"mappings":"AAwBC,GAAI,eACJ,CACC,YAAa,SAAS,EAAI,GAEzB,EAAG,OAEH,IAAI,EAAQ,EAAK,QAChB,EAAQ,EAAK,MACb,EAAQ,EAAK,KACb,EAAQ,EAAE,GACV,EAAQ,EAAE,GAAI,SAAS,OAKxB,OAHA,EAAK,OAAS,uBACd,EAAK,cAAgB,OAAO,cAExB,GAC6B,QAA5B,EAAK,SAAS,YACjB,EAAK,SAAS,UAAW,UACzB,EAAM,IAAM,EAAM,IAAI,QAAQ,cAAe,gBAC7C,EAAE,GAAI,MAAM,YAAa,OAAO,KAAK,UACrC,IAAI,QAAQ,OAAO,CAAC,IAAK,EAAK,IAAK,MAAM,IAAK,KAAK,KAEnD,EAAK,SAAS,UAAW,QACzB,EAAM,IAAM,EAAM,IAAI,QAAQ,eAAgB,eAC9C,EAAE,GAAI,MAAM,YAAa,OAAO,KAAK,QACrC,IAAI,QAAQ,OAAO,CAAC,IAAK,EAAK,IAAK,MAAM,IAAK,KAAK,KAE7C,IAGR,IAAI,QAAQ,OAAO,CAClB,IAAK,EAAK,IACV,MAAO,EACP,aAAa,EACb,UAAW,YAAY,WAAW,OAAO,KAAK,QAAU,MACxD,UAAW,SAAS,EAAK,GACxB,IAAI,EAAK,IAAI,QAAQ,KAAM,CAC1B,GAAM,EACN,MAAS,SACT,OAAU,CACT,QAAW,YAIJ,IAAI,QAAQ,KAAM,CAC1B,MAAS,SAAW,EACpB,KAAQ,IACN,OAAO,EAAI,UAEd,GAAY,GAAR,EACH,EAAG,OAAO,EAAE,GAAI,UAAU,MAAO,aAC3B,CACN,IAAI,EAAS,EAAE,GAAI,UAAU,MAC7B,EAAG,OAAO,EAAQ,QACnB,CAGA,EAAG,Y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AAO,QACpB,KAAQ,EAAO,KAAO,QACtB,MAAS,EACT,KAAQ,SACR,MAAS,cACV,OAAO,EAAiB,UAa3B,OAXA,KAAK,eAAe,EAAiB,IAAI,SAAS,EAAO,aAEzD,EAAE,EAAgB,IAAI,SAAS,SAAS,WACpC,EAAO,QAAU,GACjB,EAAO,OACX,IAEA,EAAE,EAAmB,IAAI,SAAS,SAAS,WACvC,eAAe,aACnB,KAEO,CACX,I"} \ No newline at end of file diff --git a/src/Resources/public/js/generalDriver_src.js b/src/Resources/public/js/generalDriver_src.js index ea3efed2b..cf39cddd9 100644 --- a/src/Resources/public/js/generalDriver_src.js +++ b/src/Resources/public/js/generalDriver_src.js @@ -1,7 +1,7 @@ /** * This file is part of contao-community-alliance/dc-general. * - * (c) 2013-2017 Contao Community Alliance. + * (c) 2013-2024 Contao Community Alliance. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -16,7 +16,8 @@ * @author Stefan Heimes * @author Tristan Lins * @author Sven Baumann - * @copyright 2013-2017 Contao Community Alliance. + * @author Ingolf Steinhardt + * @copyright 2013-2024 Contao Community Alliance. * @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0 * @filesource */ @@ -152,9 +153,9 @@ var BackendGeneral = if (img.nodeName.toLowerCase() == 'img') { if (img.getParent('ul.tl_listing').hasClass('tl_tree_xtnd')) { if (publish) { - img.src = img.src.replace(/_1\.(gif|png|jpe?g)/, '.$1'); + img.src = img.src.replace(/_1\.(gif|png|jpe?g|svg)/, '.$1'); } else { - img.src = img.src.replace(/\.(gif|png|jpe?g)/, '_1.$1'); + img.src = img.src.replace(/\.(gif|png|jpe?g|svg)/, '_1.$1'); } } else { if (img.src.match(/folPlus|folMinus/)) { @@ -166,11 +167,11 @@ var BackendGeneral = } var index; if (publish) { - index = img.src.replace(/.*_([0-9])\.(gif|png|jpe?g)/, '$1'); - img.src = img.src.replace(/_[0-9]\.(gif|png|jpe?g)/, ((index.toInt() == 1) ? '' : '_' + (index.toInt() - 1)) + '.$1'); + index = img.src.replace(/.*_([0-9])\.(gif|png|jpe?g|svg)/, '$1'); + img.src = img.src.replace(/_[0-9]\.(gif|png|jpe?g|svg)/, ((index.toInt() == 1) ? '' : '_' + (index.toInt() - 1)) + '.$1'); } else { - index = img.src.replace(/.*_([0-9])\.(gif|png|jpe?g)/, '$1'); - img.src = img.src.replace(/(_[0-9])?\.(gif|png|jpe?g)/, ((index == img.src) ? '_1' : '_' + (index.toInt() + 1)) + '.$2'); + index = img.src.replace(/.*_([0-9])\.(gif|png|jpe?g|svg)/, '$1'); + img.src = img.src.replace(/(_[0-9])?\.(gif|png|jpe?g|svg)/, ((index == img.src) ? '_1' : '_' + (index.toInt() + 1)) + '.$2'); } } } @@ -187,9 +188,9 @@ var BackendGeneral = // List view else { if (publish) { - img.setStyle('background-image', img.getStyle('background-image').replace(/_\.(gif|png|jpe?g)/, '.$1')); + img.setStyle('background-image', img.getStyle('background-image').replace(/_\.(gif|png|jpe?g|svg)/, '.$1')); } else { - img.setStyle('background-image', img.getStyle('background-image').replace(/\.(gif|png|jpe?g)/, '_.$1')); + img.setStyle('background-image', img.getStyle('background-image').replace(/\.(gif|png|jpe?g|svg)/, '_.$1')); } } }