CVE-2024-28190: Insufficient Information (NVD-CWE-noinfo)
value: Contao is an open source content management system. Starting in version 4.0.0 and prior to version 4.13.40 and 5.3.4, users can inject malicious code in filenames when uploading files (back end and front end), which is then executed in tooltips and popups in the back end. Contao versions 4.13.40 and 5.3.4 have a patch for this issue. As a workaround, remove upload fields from frontend forms and disable uploads for untrusted back end users.
CWE description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
Published: 2024-04-09T14:15Z
Repository: https://github.com/contao/contao
Language: JavaScript
Files changed: core-bundle/src/Resources/contao/drivers/DC_Folder.php, core-bundle/src/Resources/public/core.js, core-bundle/src/Resources/public/core.min.js, core-bundle/src/Resources/public/mootao.js, core-bundle/src/Resources/public/mootao.min.js
Commit date: 2024-04-09 07:19:32 +0200
Commit message: Merge pull request from GHSA-v24p-7p4j-qvvf

* Encode file names in tooltips and titles

* Remove ampersands in sanitizeFileName()

* Revert "Remove ampersands in sanitizeFileName()"

This reverts commit 81d06fe1ba46a969f5eacfa1420a8519379e0262.

---------

Co-authored-by: Leo Feyer <1192057+leofeyer@users.noreply.github.com>
Diff: diff --git a/core-bundle/src/Resources/contao/drivers/DC_Folder.php b/core-bundle/src/Resources/contao/drivers/DC_Folder.php
index 09a3a8ec9ca..9895e9aac1d 100644
--- a/core-bundle/src/Resources/contao/drivers/DC_Folder.php
+++ b/core-bundle/src/Resources/contao/drivers/DC_Folder.php
@@ -2718,11 +2718,11 @@ class DC_Folder extends DataContainer implements ListableDataContainerInterface,
 
 			$folderImg = $protected ? 'folderCP.svg' : 'folderC.svg';
 			$folderAlt = $protected ? $GLOBALS['TL_LANG']['MSC']['folderCP'] : $GLOBALS['TL_LANG']['MSC']['folderC'];
 
 			// Add the current folder
-			$strFolderNameEncoded = StringUtil::convertEncoding(StringUtil::specialchars(basename($currentFolder)), System::getContainer()->getParameter('kernel.charset'));
+			$strFolderNameEncoded = StringUtil::convertEncoding(StringUtil::specialchars(basename($currentFolder), false, true), System::getContainer()->getParameter('kernel.charset'));
 			$return .= Image::getHtml($folderImg, $folderAlt) . ' <a href="' . $this->addToUrl('fn=' . $currentEncoded) . '" title="' . StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['selectNode']) . '"><strong>' . $strFolderNameEncoded . '</strong></a></div> <div class="tl_right">';
 
 			// Paste buttons
 			if ($arrClipboard !== false && Input::get('act') != 'select')
 			{
@@ -2840,11 +2840,11 @@ class DC_Folder extends DataContainer implements ListableDataContainerInterface,
 						$thumbnail .= '<br><p class="preview-image broken-image">Broken image!</p>';
 					}
 				}
 			}
 
-			$strFileNameEncoded = StringUtil::convertEncoding(StringUtil::specialchars(basename($currentFile)), System::getContainer()->getParameter('kernel.charset'));
+			$strFileNameEncoded = StringUtil::convertEncoding(StringUtil::specialchars(basename($currentFile), false, true), System::getContainer()->getParameter('kernel.charset'));
 			$iconAlt = sprintf($GLOBALS['TL_LANG']['MSC']['typeOfFile'], strtoupper($objFile->extension));
 
 			// No popup links for protected files and templates (see #700)
 			if ($blnProtected || $this->strTable == 'tl_templates')
 			{
diff --git a/core-bundle/src/Resources/public/core.js b/core-bundle/src/Resources/public/core.js
index 2c2b10c4844..d6127096581 100644
--- a/core-bundle/src/Resources/public/core.js
+++ b/core-bundle/src/Resources/public/core.js
@@ -975,11 +975,11 @@ var Backend =
 			'overlayOpacity': .7,
 			'onShow': function() { document.body.setStyle('overflow', 'hidden'); },
 			'onHide': function() { document.body.setStyle('overflow', 'auto'); }
 		});
 		M.show({
-			'title': opt.title,
+			'title': opt.title && opt.title.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;'),
 			'contents': '<img src="' + opt.url + '" alt="">'
 		});
 	},
 
 	/**
@@ -1000,11 +1000,11 @@ var Backend =
 			'overlayOpacity': .7,
 			'onShow': function() { document.body.setStyle('overflow', 'hidden'); },
 			'onHide': function() { document.body.setStyle('overflow', 'auto'); }
 		});
 		M.show({
-			'title': opt.title,
+			'title': opt.title && opt.title.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;'),
 			'contents': '<iframe src="' + opt.url + '" width="100%" height="' + opt.height + '" frameborder="0"></iframe>',
 			'model': 'modal'
 		});
 	},
 
@@ -1090,11 +1090,11 @@ var Backend =
 				}).post({'action':act, 'name':opt.id, 'value':field.value, 'REQUEST_TOKEN':Contao.request_token});
 			}
 			this.hide();
 		});
 		M.show({
-			'title': opt.title,
+			'title': opt.title && opt.title.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;'),
 			'contents': '<iframe src="' + opt.url + '" name="simple-modal-iframe" width="100%" height="' + opt.height + '" frameborder="0"></iframe>',
 			'model': 'modal'
 		});
 	},
 
diff --git a/core-bundle/src/Resources/public/core.min.js b/core-bundle/src/Resources/public/core.min.js
index 5ed931c65fc..dbcbb2e5fec 100644
--- a/core-bundle/src/Resources/public/core.min.js
+++ b/core-bundle/src/Resources/public/core.min.js
@@ -1 +1 @@
-var AjaxRequest={themePath:Contao.script_url+"system/themes/"+Contao.theme+"/",toggleNavigation:function(e,t,n){var a=$(t),o=$(e).getParent("li");return a&&(o.hasClass("collapsed")?(o.removeClass("collapsed"),$(e).setAttribute("aria-expanded","true"),$(e).store("tip:title",Contao.lang.collapse),new Request.Contao({url:n}).post({action:"toggleNavigation",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(o.addClass("collapsed"),$(e).setAttribute("aria-expanded","false"),$(e).store("tip:title",Contao.lang.expand),new Request.Contao({url:n}).post({action:"toggleNavigation",id:t,state:0,REQUEST_TOKEN:Contao.request_token}))),!1},toggleStructure:function(i,l,s,r){i.blur();var e=$(l),c=$(i).getFirst("img");return e?"none"==e.getStyle("display")?(e.setStyle("display",null),c.src=AjaxRequest.themePath+"icons/folMinus.svg",$(i).store("tip:title",Contao.lang.collapse),new Request.Contao({field:i}).post({action:"toggleStructure",id:l,state:1,REQUEST_TOKEN:Contao.request_token})):(e.setStyle("display","none"),c.src=AjaxRequest.themePath+"icons/folPlus.svg",$(i).store("tip:title",Contao.lang.expand),new Request.Contao({field:i}).post({action:"toggleStructure",id:l,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:i,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:l,class:"parent",styles:{display:"inline"}});if(new Element("ul",{class:"level_"+s,html:e}).inject(t,"bottom"),5==r)t.inject($(i).getParent("li"),"after");else{for(var n,a=!1,o=$(i).getParent("li");"element"==typeOf(o)&&(n=o.getNext("li"));)if((o=n).hasClass("tl_folder")){a=!0;break}a?t.inject(o,"before"):t.inject(o,"after")}t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(i).store("tip:title",Contao.lang.collapse),c.src=AjaxRequest.themePath+"icons/folMinus.svg",window.fireEvent("structure"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadStructure",id:l,level:s,state:1,REQUEST_TOKEN:Contao.request_token}),!1},toggleFileManager:function(n,a,e,o){n.blur();var t=$(a),i=$(n).getFirst("img");return t?"none"==t.getStyle("display")?(t.setStyle("display",null),i.src=AjaxRequest.themePath+"icons/folMinus.svg",$(n).store("tip:title",Contao.lang.collapse),new Request.Contao({field:n}).post({action:"toggleFileManager",id:a,state:1,REQUEST_TOKEN:Contao.request_token})):(t.setStyle("display","none"),i.src=AjaxRequest.themePath+"icons/folPlus.svg",$(n).store("tip:title",Contao.lang.expand),new Request.Contao({field:n}).post({action:"toggleFileManager",id:a,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:n,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:a,class:"parent",styles:{display:"inline"}});new Element("ul",{class:"level_"+o,html:e}).inject(t,"bottom"),t.inject($(n).getParent("li"),"after"),t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(n).store("tip:title",Contao.lang.collapse),i.src=AjaxRequest.themePath+"icons/folMinus.svg",AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadFileManager",id:a,level:o,folder:e,state:1,REQUEST_TOKEN:Contao.request_token}),!1},togglePagetree:function(n,a,e,t,o){n.blur(),Backend.getScrollOffset();var i=$(a),l=$(n).getFirst("img");return i?"none"==i.getStyle("display")?(i.setStyle("display",null),l.src=AjaxRequest.themePath+"icons/folMinus.svg",$(n).store("tip:title",Contao.lang.collapse),new Request.Contao({field:n}).post({action:"togglePagetree",id:a,state:1,REQUEST_TOKEN:Contao.request_token})):(i.setStyle("display","none"),l.src=AjaxRequest.themePath+"icons/folPlus.svg",$(n).store("tip:title",Contao.lang.expand),new Request.Contao({field:n}).post({action:"togglePagetree",id:a,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:n,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:a,class:"parent",styles:{display:"inline"}});new Element("ul",{class:"level_"+o,html:e}).inject(t,"bottom"),t.inject($(n).getParent("li"),"after"),t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(n).store("tip:title",Contao.lang.collapse),l.src=AjaxRequest.themePath+"icons/folMinus.svg",AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadPagetree",id:a,level:o,field:e,name:t,state:1,REQUEST_TOKEN:Contao.request_token}),!1},toggleFiletree:function(n,a,e,t,o,i){n.blur(),Backend.getScrollOffset();var l=$(a),s=$(n).getFirst("img");return l?"none"==l.getStyle("display")?(l.setStyle("display",null),s.src=AjaxRequest.themePath+"icons/folMinus.svg",$(n).store("tip:title",Contao.lang.collapse),new Request.Contao({field:n}).post({action:"toggleFiletree",id:a,state:1,REQUEST_TOKEN:Contao.request_token})):(l.setStyle("display","none"),s.src=AjaxRequest.themePath+"icons/folPlus.svg",$(n).store("tip:title",Contao.lang.expand),new Request.Contao({field:n}).post({action:"toggleFiletree",id:a,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:n,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:a,class:"parent",styles:{display:"inline"}});new Element("ul",{class:"level_"+i,html:e}).inject(t,"bottom"),t.inject($(n).getParent("li"),"after"),t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(n).store("tip:title",Contao.lang.collapse),s.src=AjaxRequest.themePath+"icons/folMinus.svg",AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadFiletree",id:a,folder:e,level:i,field:t,name:o,state:1,REQUEST_TOKEN:Contao.request_token}),!1},toggleSubpalette:function(a,o,e){a.blur();var t=$(o);function i(e){a.form.elements.VERSION_NUMBER&&(a.form.elements.VERSION_NUMBER.value=/<input\s+[^>]*?name="VERSION_NUMBER"\s+[^>]*?value="([^"]*)"/i.exec(e)[1])}t?a.value?(a.value="",a.checked="",t.setStyle("display","none"),t.getElements("[required]").each(function(e){e.set("required",null).set("data-required","")}),new Request.Contao({field:a,onSuccess:i}).post({action:"toggleSubpalette",id:o,field:e,state:0,REQUEST_TOKEN:Contao.request_token})):(a.value=1,a.checked="checked",t.setStyle("display",null),t.getElements("[data-required]").each(function(e){e.set("required","").set("data-required",null)}),new Request.Contao({field:a,onSuccess:i}).post({action:"toggleSubpalette",id:o,field:e,state:1,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:a,evalScripts:!1,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e,t){var n=new Element("div",{id:o,class:"subpal cf",html:e,styles:{display:"block"}}).inject($(a).getParent("div").getParent("div"),"after");t.javascript&&(document.write=function(e){var n="";e.replace(/<script src="([^"]+)"/i,function(e,t){n=t}),n&&Asset.javascript(n,{onLoad:function(){Browser.exec(t.javascript)}})},Browser.exec(t.javascript)),a.value=1,a.checked="checked",n.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),i(e),AjaxRequest.hideBox(),window.fireEvent("subpalette"),window.fireEvent("ajax_change")}}).post({action:"toggleSubpalette",id:o,field:e,load:1,state:1,REQUEST_TOKEN:Contao.request_token})},toggleField:function(e,t){e.blur();var n,a,o=null,i=$(e).getFirst("img"),l=1==i.get("data-state"),s=e.getParent("div");return t&&(s.hasClass("tl_right")?o=s.getPrevious("div").getElement("img"):s.hasClass("tl_listing_container")?(null===(o=e.getParent("td").getPrevious("td").getFirst("div.list_icon"))&&(o=e.getParent("td").getPrevious("td").getElement("div.cte_type")),null===o&&(o=e.getParent("tr").getFirst("td").getElement("div.list_icon_new"))):(n=s.getNext("div"))&&(n.hasClass("cte_type")&&(o=n),null===o&&(o=n.getFirst("div.list_icon"))),null!==o&&("img"==o.nodeName.toLowerCase()?(o.getParent("ul.tl_listing").hasClass("tl_tree_xtnd")||(a=o.getParent("a"))&&-1==a.href.indexOf("contao/preview")&&(o=(n=a.getNext("a"))?n.getFirst("img"):new Element("img")),o.src=l?o.get("data-icon-disabled"):o.get("data-icon")):o.hasClass("cte_type")?l?(o.addClass("unpublished"),o.removeClass("published")):(o.addClass("published"),o.removeClass("unpublished")):o.setStyle("background-image","url("+(l?o.get("data-icon-disabled"):o.get("data-icon"))+")"))),i.src=l?i.get("data-icon-disabled"):i.get("data-icon"),i.set("data-state",l?0:1),new Request.Contao({url:e.href,followRedirects:!1}).get(),!1},toggleVisibility:function(e,t,n){window.console&&console.warn("AjaxRequest.toggleVisibility() is deprecated. Please use the new toggle operation."),e.blur();var a,o,i,l,s,r,c=null,d=$(e).getFirst("img"),u=1==d.get("data-state"),g=e.getParent("div");return null===d.get("data-state")&&(u=-1==d.src.indexOf("invisible"),window.console&&console.warn('Using a visibility toggle without a "data-state" attribute is deprecated. Please adjust your Contao DCA file.')),g.hasClass("tl_right")?c=g.getPrevious("div").getElement("img"):g.hasClass("tl_listing_container")?(null===(c=e.getParent("td").getPrevious("td").getFirst("div.list_icon"))&&(c=e.getParent("td").getPrevious("td").getElement("div.cte_type")),null===c&&(c=e.getParent("tr").getFirst("td").getElement("div.list_icon_new"))):(o=g.getNext("div"))&&(o.hasClass("cte_type")&&(c=o),null===c&&(c=o.getFirst("div.list_icon"))),null!==c&&("img"==c.nodeName.toLowerCase()?(c.getParent("ul.tl_listing").hasClass("tl_tree_xtnd")?(i=c.get("data-icon"),l=c.get("data-icon-disabled"),null===i&&(i=c.src.replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)$/,"$1/$2.$3"),window.console&&console.warn('Using a row icon without a "data-icon" attribute is deprecated. Please adjust your Contao DCA file.')),null===l&&(l=c.src.replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)$/,"$1/$2_.$3"),window.console&&console.warn('Using a row icon without a "data-icon-disabled" attribute is deprecated. Please adjust your Contao DCA file.'))):((s=c.getParent("a"))&&-1==s.href.indexOf("contao/preview")&&(c=(o=s.getNext("a"))?o.getFirst("img"):new Element("img")),i=c.get("data-icon"),l=c.get("data-icon-disabled"),null===i&&(a=c.src.replace(/.*_([0-9])\.(gif|png|jpe?g|svg)/,"$1"),i=c.src.replace(/_[0-9]\.(gif|png|jpe?g|svg)/,(1==a.toInt()?"":"_"+(a.toInt()-1))+".$1").split(/[\\/]/).pop(),window.console&&console.warn('Using a row icon without a "data-icon" attribute is deprecated. Please adjust your Contao DCA file.')),null===l&&(a=c.src.replace(/.*_([0-9])\.(gif|png|jpe?g|svg)/,"$1"),l=c.src.replace(/(_[0-9])?\.(gif|png|jpe?g|svg)/,(a==c.src?"_1":"_"+(a.toInt()+1))+".$2").split(/[\\/]/).pop(),window.console&&console.warn('Using a row icon without a "data-icon-disabled" attribute is deprecated. Please adjust your Contao DCA file.'))),-1==i.indexOf("/")&&(i=AjaxRequest.themePath+(i.match(/\.svg$/)?"icons/":"images/")+i),-1==l.indexOf("/")&&(l=AjaxRequest.themePath+(l.match(/\.svg$/)?"icons/":"images/")+l),c.src=u?l:i):c.hasClass("cte_type")?u?(c.addClass("unpublished"),c.removeClass("published")):(c.addClass("published"),c.removeClass("unpublished")):(i=c.get("data-icon"),l=c.get("data-icon-disabled"),null===i&&(i=c.getStyle("background-image").replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)\);?$/,"$1/$2.$2"),window.console&&console.warn('Using a row icon without a "data-icon" attribute is deprecated. Please adjust your Contao DCA file.')),null===l&&(l=c.getStyle("background-image").replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)\);?$/,"$1/$2_.$3"),window.console&&console.warn('Using a row icon without a "data-icon-disabled" attribute is deprecated. Please adjust your Contao DCA file.')),-1==i.indexOf("/")&&(i=AjaxRequest.themePath+(i.match(/\.svg$/)?"icons/":"images/")+i),-1==l.indexOf("/")&&(l=AjaxRequest.themePath+(l.match(/\.svg$/)?"icons/":"images/")+l),c.setStyle("background-image","url("+(u?l:i)+")"))),"tl_style"==n&&g.getParent("div").getElement("pre").toggleClass("disabled"),i=d.get("data-icon")||AjaxRequest.themePath+"icons/visible.svg",l=d.get("data-icon-disabled")||AjaxRequest.themePath+"icons/invisible.svg",-1!==e.href.indexOf("act=toggle")?(d.src=u?l:i,d.set("data-state",u?0:1),new Request.Contao({url:e.href,followRedirects:!1}).get()):(d.src=u?l:i,d.set("data-state",u?0:1),(r={state:u?0:1,rt:Contao.request_token})[$(e).get("data-tid")||"tid"]=t,new Request.Contao({url:window.location.href,followRedirects:!1}).get(r)),!1},toggleFeatured:function(e,t){window.console&&console.warn("AjaxRequest.toggleFeatured() is deprecated. Please use the new toggle operation."),e.blur();var n=$(e).getFirst("img"),a=1==n.get("data-state");return null===n.get("data-state")&&(a=-1==n.src.indexOf("featured_"),window.console&&console.warn('Using a featured toggle without a "data-state" attribute is deprecated. Please adjust your Contao DCA file.')),a?(n.src=AjaxRequest.themePath+"icons/featured_.svg",n.set("data-state",0),(new Request.Contao).post({action:"toggleFeatured",id:t,state:0,REQUEST_TOKEN:Contao.request_token})):(n.src=AjaxRequest.themePath+"icons/featured.svg",n.set("data-state",1),(new Request.Contao).post({action:"toggleFeatured",id:t,state:1,REQUEST_TOKEN:Contao.request_token})),!1},toggleFieldset:function(e,t,n){e.blur(),Backend.getScrollOffset();var a=$("pal_"+t);if(a.hasClass("collapsed"))a.removeClass("collapsed"),(new Request.Contao).post({action:"toggleFieldset",id:t,table:n,state:1,REQUEST_TOKEN:Contao.request_token});else{for(var o=a.getParent("form"),i=a.getElements("[required]"),l=!0,s=0;s<i.length;s++)if(!i[s].get("value")){l=!1;break}l?(a.addClass("collapsed"),(new Request.Contao).post({action:"toggleFieldset",id:t,table:n,state:0,REQUEST_TOKEN:Contao.request_token})):"function"==typeof o.checkValidity&&o.getElement('button[type="submit"]').click()}return!1},toggleCheckboxGroup:function(e,t){e.blur();var n=$(t),a=$(e).getFirst("img");return!!n&&("none"==n.getStyle("display")?(n.setStyle("display",null),a.src=AjaxRequest.themePath+"icons/folMinus.svg",(new Request.Contao).post({action:"toggleCheckboxGroup",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(n.setStyle("display","none"),a.src=AjaxRequest.themePath+"icons/folPlus.svg",(new Request.Contao).post({action:"toggleCheckboxGroup",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!0)},displayBox:function(e){var t=$("tl_ajaxBox"),n=$("tl_ajaxOverlay"),a=window.getScroll();null===n&&(n=new Element("div",{id:"tl_ajaxOverlay"}).inject($(document.body),"bottom")),n.set({styles:{display:"block",top:a.y+"px"}}),null===t&&(t=new Element("div",{id:"tl_ajaxBox"}).inject($(document.body),"bottom")),t.set({html:e,styles:{display:"block",top:a.y+100+"px"}})},hideBox:function(){var e=$("tl_ajaxBox"),t=$("tl_ajaxOverlay");t&&t.setStyle("display","none"),e&&e.setStyle("display","none")}},Backend={currentId:null,xMousePosition:0,yMousePosition:0,popupWindow:null,themePath:Contao.script_url+"system/themes/"+Contao.theme+"/",getMousePosition:function(e){Backend.xMousePosition=e.client.x,Backend.yMousePosition=e.client.y},openWindow:function(e,t,n){e.blur(),t=Browser.ie?t+40:t+17,n=Browser.ie?n+30:n+17,Backend.popupWindow=window.open(e.href,"","width="+t+",height="+n+",modal=yes,left=100,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no")},openModalWindow:function(e,t,n){new SimpleModal({width:e,hideFooter:!0,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}}).show({title:t,contents:n})},openModalImage:function(e){var t=e||{},n=(window.getSize().x-20).toInt();(!t.width||t.width>n)&&(t.width=Math.min(n,900)),new SimpleModal({width:t.width,hideFooter:!0,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}}).show({title:t.title,contents:'<img src="'+t.url+'" alt="">'})},openModalIframe:function(e){var t=e||{},n=(window.getSize().x-20).toInt(),a=(window.getSize().y-137).toInt();(!t.width||t.width>n)&&(t.width=Math.min(n,900)),(!t.height||t.height>a)&&(t.height=a),new SimpleModal({width:t.width,hideFooter:!0,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}}).show({title:t.title,contents:'<iframe src="'+t.url+'" width="100%" height="'+t.height+'" frameborder="0"></iframe>',model:"modal"})},openModalSelector:function(e){var d=e||{},t=(window.getSize().x-20).toInt(),n=(window.getSize().y-192).toInt();d.id||(d.id="tl_select"),(!d.width||d.width>t)&&(d.width=Math.min(t,900)),(!d.height||d.height>n)&&(d.height=n);var a=new SimpleModal({width:d.width,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}});a.addButton(Contao.lang.cancel,"btn",function(){this.buttons[0].hasClass("btn-disabled")||this.hide()}),a.addButton(Contao.lang.apply,"btn primary",function(){if(!this.buttons[1].hasClass("btn-disabled")){var e,t,n,a,o,i,l,s,r=window.frames["simple-modal-iframe"],c=[];if(void 0!==r){for((l=(e=r.document.getElementById(d.id)).get("data-picker-value"))&&(c=JSON.parse(l)),t=e.getElementsByTagName("input"),i=0;i<t.length;i++)t[i].id.match(/^(check_all_|reset_)/)||(s=c.indexOf(t[i].get("value")),t[i].checked?-1==s&&c.push(t[i].get("value")):-1!=s&&c.splice(s,1));d.callback?d.callback(e.get("data-table"),c):d.tag&&(n=$(d.tag))?(window.console&&console.warn("Using the modal selector without a callback function is deprecated. Please adjust your Contao DCA file."),n.value=c.join(","),(o=e.get("data-inserttag"))&&(n.value="{{"+o+"::"+n.value+"}}"),d.self.set("href",d.self.get("href").replace(/&value=[^&]*/,"&value="+c.join(",")))):d.id&&(n=$("ctrl_"+d.id))&&(a=e.get("data-callback"))&&(window.console&&console.warn("Using the modal selector without a callback function is deprecated. Please adjust your Contao DCA file."),n.value=c.join("\t"),new Request.Contao({field:n,evalScripts:!1,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e,t){$("ctrl_"+d.id).getParent("div").set("html",t.content),t.javascript&&Browser.exec(t.javascript),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:a,name:d.id,value:n.value,REQUEST_TOKEN:Contao.request_token})),this.hide()}else alert("Could not find the SimpleModal frame")}}),a.show({title:d.title,contents:'<iframe src="'+d.url+'" name="simple-modal-iframe" width="100%" height="'+d.height+'" frameborder="0"></iframe>',model:"modal"})},openModalBrowser:function(n,e,t,a,o){Backend.openModalSelector({id:"tl_listing",title:a.document.getElement("div.mce-title").get("text"),url:Contao.routes.backend_picker+"?context="+("file"==t?"link":"file")+"&amp;extras[fieldType]=radio&amp;extras[filesOnly]=true&amp;extras[source]="+o+"&amp;value="+e+"&amp;popup=1",callback:function(e,t){a.document.getElementById(n).value=t.join(",")}})},getScrollOffset:function(){window.sessionStorage.setItem("contao_backend_offset",window.getScroll().y)},initScrollOffset:function(){Cookie.dispose("BE_PAGE_OFFSET"),$$('.tl_submit_container button[name][name!="save"]').each(function(e){e.addEvent("click",function(){window.sessionStorage.removeItem("contao_backend_offset")})});var e=window.sessionStorage.getItem("contao_backend_offset");if(window.sessionStorage.removeItem("contao_backend_offset"),e){var t=window.document.getElementById("header"),i=0;t&&t.addClass("down"),$$("[data-add-to-scroll-offset]").each(function(e){var t=e.get("data-add-to-scroll-offset"),n=e.getScrollSize().y,a=!1,o=!1;t?("-"===t.charAt(0)&&(a=!0,t=t.substring(1)),"%"===t.charAt(t.length-1)&&(o=!0,t=t.substring(0,t.length-1)),t=parseInt(t,10),o&&(t=Math.round(n*t/100)),a&&(t*=-1),i+=t):i+=n}),this.vScrollTo(parseInt(e,10)+i)}},autoSubmit:function(e){Backend.getScrollOffset();var t=new Element("input",{type:"hidden",name:"SUBMIT_TYPE",value:"auto"}),n=$(e)||e;t.inject(n,"bottom"),n.submit()},vScrollTo:function(e){window.addEvent("load",function(){window.scrollTo(null,parseInt(e))})},limitPreviewHeight:function(){var l=0;$$("div.limit_height").each(function(e){var t,n,a,o,i=e.getParent(".tl_content");i&&(i.hasClass("wrapper_start")||i.hasClass("wrapper_stop"))||(0===l&&(l=e.className.replace(/[^0-9]*/,"").toInt()),l&&(t=new Element("div",{class:"limit_toggler"}),n=new Element("button",{type:"button",html:"<span>...</span>",class:"unselectable","data-state":0}).inject(t),a=e.getCoordinates(),e.setStyle("height",l),a.height<=l||(n.addEvent("click",function(){o=t.getPrevious("div").getStyle("height").toInt(),t.getPrevious("div").setStyle("height",l<o?l:""),n.set("data-state",n.get("data-state")?0:1)}),t.inject(e,"after"))))})},toggleCheckboxes:function(e,t){for(var n=$$("input"),a=$(e).checked?"checked":"",o=0;o<n.length;o++)"checkbox"==n[o].type.toLowerCase()&&(void 0!==t&&t!=n[o].id.substr(0,t.length)||(n[o].checked=a))},toggleCheckboxGroup:function(e,t){var n=$(e).className,a=$(e).checked?"checked":"";"tl_checkbox"==n?($(t)?$$("#"+t+" .tl_checkbox"):$(e).getParent("fieldset").getElements(".tl_checkbox")).each(function(e){e.checked=a}):"tl_tree_checkbox"==n&&$$("#"+t+" .parent .tl_tree_checkbox").each(function(e){e.checked=a});Backend.getScrollOffset()},toggleCheckboxElements:function(e,t){var n=$(e).checked?"checked":"";$$("."+t).each(function(e){e.hasClass("tl_checkbox")&&(e.checked=n)}),Backend.getScrollOffset()},toggleWrap:function(e){var t=$(e),n="off"==t.getProperty("wrap")?"soft":"off";t.setProperty("wrap",n)},toggleUnchanged:function(){$$("#result-list .tl_confirm").each(function(e){e.toggleClass("hidden")})},blink:function(){},addColorPicker:function(){return!0},collapsePalettes:function(){$$("fieldset.hide").each(function(e){e.addClass("collapsed")}),$$("label.error, label.mandatory").each(function(e){var t=e.getParent("fieldset");t&&t.removeClass("collapsed")})},addInteractiveHelp:function(){new Tips.Contao("p.tl_tip",{offset:{x:9,y:23},text:function(e){return e.get("html")}}),new Tips.Contao($("home"),{offset:{x:15,y:42}}),new Tips.Contao($$("#tmenu a[title]").filter(function(e){return""!=e.title}),{offset:{x:9,y:42}}),new Tips.Contao($$('a[title][class^="group-"]').filter(function(e){return""!=e.title}),{offset:{x:3,y:27}}),new Tips.Contao($$("a[title].navigation").filter(function(e){return""!=e.title}),{offset:{x:34,y:32}}),$$("img[title]").filter(function(e){return""!=e.title}).each(function(e){new Tips.Contao(e,{offset:{x:0,y:"gimage"==e.get("class")?60:30}})}),["a[title]","input[title]","button[title]","time[title]","span[title]"].each(function(e){new Tips.Contao($$(e).filter(function(e){return""!=e.title}),{offset:{x:0,y:"time[title]"==e||"span[title]"==e?26:30}})})},retrieveInteractiveHelp:function(e){e&&e.each(function(e){var t=e.retrieve("tip:title");t&&e.set("title",t)})},hideInteractiveHelp:function(){function e(){document.querySelectorAll(".tip-wrap").forEach(function(e){e.setStyle("display","none")})}e(),setTimeout(e,(new Tips.Contao).options.showDelay)},makeParentViewSortable:function(e){var t=new Scroller(document.getElement("body"),{onChange:function(e,t){this.element.scrollTo(this.element.getScroll().x,t)}}),i=new Sortables(e,{constrain:!0,opacity:.6,onStart:function(){t.start()},onComplete:function(){t.stop()},onSort:function(e){var t,n,a=e.getParent("ul"),o=0;if(a&&(t=a.getChildren("li > div:first-child")))for(n=0;n<t.length;n++)t[n].hasClass("wrapper_stop")&&0<o&&o--,t[n].className=t[n].className.replace(/(^|\s)indent[^\s]*/g,""),0<o&&t[n].addClass("indent").addClass("indent_"+o),t[n].hasClass("wrapper_start")&&o++,t[n].removeClass("indent_first"),t[n].removeClass("indent_last"),t[n-1]&&t[n-1].hasClass("wrapper_start")&&t[n].addClass("indent_first"),t[n+1]&&t[n+1].hasClass("wrapper_stop")&&t[n].addClass("indent_last")},handle:".drag-handle"});i.active=!1,i.addEvent("start",function(){i.active=!0}),i.addEvent("complete",function(e){var t,n,a,o;i.active&&(e.getPrevious("li")?(t=e.get("id").replace(/li_/,""),n=e.getPrevious("li").get("id").replace(/li_/,""),a=window.location.search.replace(/id=[0-9]*/,"id="+t)+"&act=cut&mode=1&pid="+n,o=window.location.href.replace(/\?.*$/,""),new Request.Contao({url:o+a,followRedirects:!1}).get()):e.getParent("ul")&&(t=e.get("id").replace(/li_/,""),n=e.getParent("ul").get("id").replace(/ul_/,""),a=window.location.search.replace(/id=[0-9]*/,"id="+t)+"&act=cut&mode=2&pid="+n,o=window.location.href.replace(/\?.*$/,""),new Request.Contao({url:o+a,followRedirects:!1}).get()))})},makeMultiSrcSortable:function(a,o,i){var e=new Sortables($(a),{constrain:!0,opacity:.6}).addEvent("complete",function(){var e,t=[],n=$(a).getChildren("[data-id]");for(e=0;e<n.length;e++)t.push(n[e].get("data-id"));o===i&&$(i).value.split(",").forEach(function(e){-1===t.indexOf(e)&&t.push(e)}),$(o).value=t.join(",")});$(a).getElements(".gimage").each(function(n){n.hasClass("removable")?new Element("button",{type:"button",html:"&times;",class:"tl_red"}).addEvent("click",function(){var e=n.getParent("li"),t=e.get("data-id");$(i).value=$(i).value.split(",").filter(function(e){return e!=t}).join(","),$(o).value=$(o).value.split(",").filter(function(e){return e!=t}).join(","),e.dispose()}).inject(n,"after"):new Element("button",{type:"button",html:"&times",disabled:!0}).inject(n,"after")}),e.fireEvent("complete")},enableFileTreeDragAndDrop:function(c,d){var u=new Scroller(document.getElement("body"),{onChange:function(e,t){this.element.scrollTo(this.element.getScroll().x,t)}});function g(e){return e&&e.hasClass("parent")&&e.getPrevious(".tl_folder")?e.getPrevious(".tl_folder"):e}c.addEvent("mousedown",function(e){var t=e.target.hasClass("drag-handle")?e.target:e.target.getParent(".drag-handle"),o=e.target.getParent(".tl_file,.tl_folder");if(t&&o&&!e.rightClick){u.start(),c.addClass("tl_listing_dragging");var i,l,n=o.getElements(".tl_left")[0]||o,s=n.clone(!0).inject(c).addClass("tl_left_dragging");s.setPosition({x:e.page.x-n.getOffsetParent().getPosition().x-s.getSize().x,y:n.getPosition(n.getOffsetParent()).y}).setStyle("display","none");var a=new Drag.Move(s,{droppables:$$([c]).append(c.getElements(".tl_folder,li.parent,.tl_folder_top")),unDraggableTags:[],modifiers:{x:"left",y:"top"},onStart:function(){s.setStyle("display","")},onEnter:function(e,t){if((t=g(t)).addClass("tl_folder_dropping"),t.hasClass("tl_folder")&&i!==t){i=t,l=(new Date).getTime();var n=t.getElement('img[src$="/icons/folPlus.svg"]');(n=n&&n.getParent("a"))&&setTimeout(function(){if(i===t&&l+900<(new Date).getTime()){var e=document.createEvent("HTMLEvents");e.initEvent("click",!0,!0),n.dispatchEvent(e),l=i=void 0,window.addEvent("ajax_change",function e(){a&&a.droppables&&c&&c.getElements&&(a.droppables=$$([c]).append(c.getElements(".tl_folder,li.parent"))),window.removeEvent("ajax_change",e)})}},1e3)}},onCancel:function(){l=i=void 0,u.stop(),s.destroy(),window.removeEvent("keyup",r),c.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping"),c.removeClass("tl_listing_dragging")},onDrop:function(e,t){if(l=i=void 0,u.stop(),s.destroy(),window.removeEvent("keyup",r),c.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping"),c.removeClass("tl_listing_dragging"),t=g(t)){var n=o.get("data-id"),a=t.get("data-id")||decodeURIComponent(d.url.split(/[?&]pid=/)[1].split("&")[0]);n&&a&&(0===(a+"/").indexOf(n+"/")||a+"/"===n.replace(/[^/]+$/,""))||(Backend.getScrollOffset(),document.location.href=d.url+"&id="+encodeURIComponent(n)+"&pid="+encodeURIComponent(a))}},onLeave:function(e,t){(t=g(t)).removeClass("tl_folder_dropping"),l=i=void 0}});a.start(e),window.addEvent("keyup",r)}function r(e){"esc"===e.key&&a&&a.stop&&(a.droppables=$$([]),a.stop())}})},listWizard:function(e){var l=$(e),s=function(n){var e,a,o,i;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){Backend.getScrollOffset(),e=n.clone(!0).inject(n,"before"),(a=n.getFirst("input"))&&(e.getFirst("input").value=a.value),s(e)});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<l.getChildren().length&&n.destroy()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("li"))?n.inject(o,"before"):n.inject(l,"bottom"),t.focus()):40==e.event.keyCode&&(e.preventDefault(),(i=n.getNext("li"))?n.inject(i,"after"):n.inject(l.getFirst("li"),"before"),t.focus())})}})};new Sortables(l,{constrain:!0,opacity:.6,handle:".drag-handle"}),l.getChildren().each(function(e){s(e)})},tableWizard:function(e){var t=$(e),u=t.getElement("thead"),g=t.getElement("tbody"),f=function(e){var t,n,a,o,i=e.getChildren();for(a=0;a<i.length;a++)for(n=i[a].getChildren(),o=0;o<n.length;o++)(t=n[o].getFirst("textarea"))&&(t.name=t.name.replace(/\[[0-9]+][[0-9]+]/g,"["+a+"]["+o+"]"));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){f(e)}})},h=function(n){var a,o,i,l,s,r,c,d=u.getFirst("tr");n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"rcopy":t.addEvent("click",function(){for(Backend.getScrollOffset(),l=new Element("tr"),s=n.getChildren(),c=0;c<s.length;c++)Backend.retrieveInteractiveHelp(s[c].getElements("button,a")),i=s[c].clone(!0).inject(l,"bottom"),(a=s[c].getFirst("textarea"))&&(i.getFirst("textarea").value=a.value);l.inject(n,"after"),h(l),f(g),Backend.addInteractiveHelp()});break;case"rdelete":t.addEvent("click",function(){Backend.getScrollOffset(),1<g.getChildren().length&&n.destroy(),f(g),Backend.hideInteractiveHelp()});break;case"ccopy":t.addEvent("click",function(){for(Backend.getScrollOffset(),r=p(t),s=g.getChildren(),c=0;c<s.length;c++)o=s[c].getChildren()[r],Backend.retrieveInteractiveHelp(o.getElements("button,a")),i=o.clone(!0).inject(o,"after"),(a=o.getFirst("textarea"))&&(i.getFirst("textarea").value=a.value),h(i);var e=d.getFirst("td");Backend.retrieveInteractiveHelp(e.getElements("button,a")),i=e.clone(!0).inject(d.getLast("td"),"before"),h(i),f(g),Backend.addInteractiveHelp()});break;case"cmovel":t.addEvent("click",function(){if(Backend.getScrollOffset(),r=p(t),s=g.getChildren(),0<r)for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(o.getPrevious(),"before");else for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(s[c].getLast(),"before");f(g)});break;case"cmover":t.addEvent("click",function(){if(Backend.getScrollOffset(),r=p(t),s=g.getChildren(),r<n.getChildren().length-2)for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(o.getNext(),"after");else for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(s[c].getFirst(),"before");f(g)});break;case"cdelete":t.addEvent("click",function(){if(Backend.getScrollOffset(),r=p(t),s=g.getChildren(),2<n.getChildren().length){for(c=0;c<s.length;c++)s[c].getChildren()[r].destroy();d.getFirst("td").destroy()}f(g),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(l=n.getPrevious("tr"))?n.inject(l,"before"):n.inject(g,"bottom"),t.focus(),f(g)):40==e.event.keyCode&&(e.preventDefault(),(l=n.getNext("tr"))?n.inject(l,"after"):n.inject(g,"top"),t.focus(),f(g))})}})},p=function(e){var t,n=$(e).getParent("td"),a=n.getParent("tr").getChildren(),o=0;for(t=0;t<a.length&&a[t]!=n;t++)o++;return o};f(g),u.getChildren().each(function(e){h(e)}),g.getChildren().each(function(e){h(e)}),Backend.tableWizardResize()},tableWizardResize:function(t){var n=window.localStorage.getItem("contao_table_wizard_cell_size");if(void 0!==t)n="",$$(".tl_tablewizard textarea").each(function(e){e.setStyle("width",(e.getStyle("width").toInt()*t).round().limit(142,284)),e.setStyle("height",(e.getStyle("height").toInt()*t).round().limit(66,132)),""==n&&(n=e.getStyle("width")+"|"+e.getStyle("height"))}),window.localStorage.setItem("contao_table_wizard_cell_size",n);else if(null!==n){var a=n.split("|");$$(".tl_tablewizard textarea").each(function(e){e.setStyle("width",a[0]),e.setStyle("height",a[1])})}},tableWizardSetWidth:function(){var e=$("tl_tablewizard");e&&e.setStyle("width",Math.round(.96*e.getParent(".tl_formbody_edit").getComputedSize().width))},moduleWizard:function(e){var r=$(e).getElement("tbody"),c=function(e){var t,n,a,o,i,l=e.getChildren();for(n=0;n<l.length;n++)for(t=l[n].getChildren(),a=0;a<t.length;a++)(o=t[a].getElement("select"))&&(o.name=o.name.replace(/\[[0-9]+]/g,"["+n+"]")),(i=t[a].getElement('input[type="checkbox"]'))&&(i.set("tabindex",-1),i.name=i.name.replace(/\[[0-9]+]/g,"["+n+"]"));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){c(e)}})},d=function(n){var e,a,o,i,l,s;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),o=new Element("tr"),i=n.getChildren(),s=0;s<i.length;s++)Backend.retrieveInteractiveHelp(i[s].getElements("button,a")),a=i[s].clone(!0).inject(o,"bottom"),(e=i[s].getElement("select"))&&(a.getElement("select").value=e.value);o.inject(n,"after"),o.getElement(".chzn-container").destroy(),new Chosen(o.getElement("select.tl_select")),d(o),c(r),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<r.getChildren().length&&n.destroy(),c(r),Backend.hideInteractiveHelp()});break;case"enable":t.addEvent("click",function(){Backend.getScrollOffset(),(l=t.getNext('input[type="checkbox"]')).checked?(l.checked="",t.getElement("img").src=Backend.themePath+"icons/invisible.svg"):(l.checked="checked",t.getElement("img").src=Backend.themePath+"icons/visible.svg"),c(r)});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("tr"))?n.inject(o,"before"):n.inject(r,"bottom"),t.focus(),c(r)):40==e.event.keyCode&&(e.preventDefault(),(o=n.getNext("tr"))?n.inject(o,"after"):n.inject(r,"top"),t.focus(),c(r))})}})};c(r),r.getChildren().each(function(e){d(e)})},optionsWizard:function(e){var s=$(e).getElement("tbody"),r=function(e){var t,n,a,o,i=e.getChildren();for(n=0;n<i.length;n++)for(t=i[n].getChildren(),a=0;a<t.length;a++)(o=t[a].getFirst("input"))&&(o.name=o.name.replace(/\[[0-9]+]/g,"["+n+"]"),"checkbox"==o.type&&(o.id=o.name.replace(/\[[0-9]+]/g,"").replace(/\[/g,"_").replace(/]/g,"")+"_"+n,o.getNext("label").set("for",o.id)));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){r(e)}})},c=function(n){var e,a,o,i,l;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),o=new Element("tr"),i=n.getChildren(),l=0;l<i.length;l++)Backend.retrieveInteractiveHelp(i[l].getElements("button,a")),a=i[l].clone(!0).inject(o,"bottom"),(e=i[l].getFirst("input"))&&(a.getFirst("input").value=e.value,"checkbox"==e.type&&(a.getFirst("input").checked=e.checked?"checked":""));o.inject(n,"after"),c(o),r(s),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<s.getChildren().length&&n.destroy(),r(s),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("tr"))?n.inject(o,"before"):n.inject(s,"bottom"),t.focus(),r(s)):40==e.event.keyCode&&(e.preventDefault(),(o=n.getNext("tr"))?n.inject(o,"after"):n.inject(s,"top"),t.focus(),r(s))})}})};r(s),s.getChildren().each(function(e){c(e)})},keyValueWizard:function(e){var s=$(e).getElement("tbody"),r=function(e){var t,n,a,o,i=e.getChildren();for(n=0;n<i.length;n++)for(t=i[n].getChildren(),a=0;a<t.length;a++)(o=t[a].getFirst("input"))&&(o.name=o.name.replace(/\[[0-9]+]/g,"["+n+"]"));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){r(e)}})},c=function(n){var e,a,o,i,l;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),o=new Element("tr"),i=n.getChildren(),l=0;l<i.length;l++)Backend.retrieveInteractiveHelp(i[l].getElements("button,a")),a=i[l].clone(!0).inject(o,"bottom"),(e=i[l].getFirst("input"))&&(a.getFirst().value=e.value);o.inject(n,"after"),c(o),r(s),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<s.getChildren().length&&n.destroy(),r(s),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("tr"))?n.inject(o,"before"):n.inject(s,"bottom"),t.focus(),r(s)):40==e.event.keyCode&&(e.preventDefault(),(o=n.getNext("tr"))?n.inject(o,"after"):n.inject(s,"top"),t.focus(),r(s))})}})};r(s),s.getChildren().each(function(e){c(e)})},checkboxWizard:function(e){var o=$(e).getElement(".sortable");new Sortables(o,{constrain:!0,opacity:.6,handle:".drag-handle"}),o.getChildren().each(function(e){var n,a;(n=e).getElements("button").each(function(t){t.hasEvent("click")||t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(a=n.getPrevious("span"))?n.inject(a,"before"):n.inject(o,"bottom"),t.focus()):40==e.event.keyCode&&(e.preventDefault(),(a=n.getNext("span"))?n.inject(a,"after"):n.inject(o,"top"),t.focus())})})})},metaDelete:function(e){var t=e.getParent("li");null===t.getPrevious()&&null===t.getNext()?t.getElements("input, textarea").each(function(e){e.value=""}):t.destroy()},toggleAddLanguageButton:function(e){var t=e.getParent("div").getElement('input[type="button"]');""!=e.value?t.removeProperty("disabled"):t.setProperty("disabled",!0)},sectionWizard:function(e){var c=$(e).getElement("tbody"),d=function(e){var t,n,a,o=e.getChildren();for(n=0;n<o.length;n++)for(t=o[n].getChildren(),a=0;a<t.length;a++)t[a].getElements("input").each(function(e){e.name=e.name.replace(/\[[0-9]+]/g,"["+n+"]")}),t[a].getElements("select").each(function(e){e.name=e.name.replace(/\[[0-9]+]/g,"["+n+"]")});new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){d(e)}})},u=function(n){var e,a,o,i,l,s,r;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),a=new Element("tr"),o=n.getChildren(),s=0;s<o.length;s++)for(Backend.retrieveInteractiveHelp(o[s].getElements("button,a")),e=o[s].clone(!0).inject(a,"bottom"),i=o[s].getElements("select"),l=e.getElements("select"),r=0;r<i.length;r++)l[r].value=i[r].value;a.inject(n,"after"),u(a),d(c),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<c.getChildren().length&&n.destroy(),d(c),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(a=n.getPrevious("tr"))?n.inject(a,"before"):n.inject(c,"bottom"),t.focus(),d(c)):40==e.event.keyCode&&(e.preventDefault(),(a=n.getNext("tr"))?n.inject(a,"after"):n.inject(c,"top"),t.focus(),d(c))})}})};d(c),c.getChildren().each(function(e){u(e)})},updateModuleLink:function(e){var t=e.getParent("tr").getLast("td"),n=t.getElement("a.module_link");n.href=n.href.replace(/id=[0-9]+/,"id="+e.value),0<e.value?(t.getElement("a.module_link").setStyle("display",null),t.getElement("img.module_image").setStyle("display","none")):(t.getElement("a.module_link").setStyle("display","none"),t.getElement("img.module_image").setStyle("display",null))},enableImageSizeWidgets:function(){$$(".tl_image_size").each(function(e){function t(){if(""===n.get("value")||0===n.get("value").indexOf("_")||n.get("value").toInt().toString()===n.get("value")){a.readOnly=!0,o.readOnly=!0;var e=$(n.getSelected()[0]).get("text");e=1<e.split("(").length?e.split("(").getLast().split(")")[0].split("x"):["",""],a.set("value","").set("placeholder",+e[0]||""),o.set("value","").set("placeholder",+e[1]||"")}else a.set("placeholder",""),o.set("placeholder",""),a.readOnly=!1,o.readOnly=!1}var n=e.getElement("select"),a=e.getChildren("input")[0],o=e.getChildren("input")[1];t(),n.addEvent("change",t),n.addEvent("keyup",t)})},enableToggleSelect:function(){function a(e){for(t=r.indexOf(e),n=r.indexOf(o),l=Math.min(t,n),s=Math.max(t,n),i=!!r[n].checked;l<=s;l++)r[l].checked=i}var o,t,n,i,l,s,e=$("tl_listing"),r=[];e&&(r=e.getElements('input[type="checkbox"]')),$$(".toggle_select").each(function(e){var t=e.retrieve("boundEvent");t&&e.removeEvent("click",t),e.getElements('label,input[type="checkbox"],input[type="radio"]').each(function(e){e.addEvent("click",function(e){e.stopPropagation()})}),t=function(e){var t=this.getElement('input[type="checkbox"],input[type="radio"]'),n=$(e.target).getParent(".limit_toggler");t&&!t.get("disabled")&&null===n&&("radio"!=t.type?(e.shift&&o?a(t):(t.checked=t.checked?"":"checked","Backend.toggleCheckboxes(this)"==t.get("onclick")&&Backend.toggleCheckboxes(t)),o=t):t.checked||(t.checked="checked"))}.bind(e),e.addEvent("click",t),e.store("boundEvent",t)}),r.each(function(e){e.addEvent("click",function(e){e.shift&&o&&a(this),o=this})})},autoFocusFirstInputField:function(){var e=document.querySelector("#main .tl_formbody_edit");if(e){var t=$(e).getElements("input, textarea").filter(function(e){return!e.get("disabled")&&!e.get("readonly")&&e.isVisible()&&"checkbox"!==e.get("type")&&"radio"!==e.get("type")&&"submit"!==e.get("type")&&"image"!==e.get("type")&&(!e.get("autocomplete")||"off"===e.get("autocomplete")||!e.get("value"))});t[0]&&t[0].focus()}},editPreviewWizard:function(s){function r(){return{x:u.getComputedSize().width,y:u.getComputedSize().height}}function e(){var e=r(),t=u.getComputedSize();c.setStyles({top:t.computedTop+(g.y.get("value")*e.y).round()+"px",left:t.computedLeft+(g.x.get("value")*e.x).round()+"px",width:(g.width.get("value")*e.x).round()+"px",height:(g.height.get("value")*e.y).round()+"px"}),g.width.get("value").toFloat()&&g.height.get("value").toFloat()?c.setStyle("display",null):c.setStyle("display","none")}function t(e){e.preventDefault(),f||(f=!0,d={x:e.page.x-s.getPosition().x-u.getComputedSize().computedLeft,y:e.page.y-s.getPosition().y-u.getComputedSize().computedTop},a(e))}function n(e){a(e),f=!1}var c,d,u=(s=$(s)).getElement("img"),g={},f=!1,a=function(e){if(f){e.preventDefault();var t,n,a,o,i=u.getComputedSize(),l={x:[Math.max(0,Math.min(i.width,d.x)),Math.max(0,Math.min(i.width,e.page.x-s.getPosition().x-i.computedLeft))],y:[Math.max(0,Math.min(i.height,d.y)),Math.max(0,Math.min(i.height,e.page.y-s.getPosition().y-i.computedTop))]};c.setStyles({top:Math.min(l.y[0],l.y[1])+i.computedTop+"px",left:Math.min(l.x[0],l.x[1])+i.computedLeft+"px",width:Math.abs(l.x[0]-l.x[1])+"px",height:Math.abs(l.y[0]-l.y[1])+"px"}),t=r(),n=c.getStyles("top","left","width","height"),a=u.getComputedSize(),(o={x:Math.max(0,Math.min(1,(n.left.toFloat()-a.computedLeft)/t.x)),y:Math.max(0,Math.min(1,(n.top.toFloat()-a.computedTop)/t.y))}).width=Math.min(1-o.x,n.width.toFloat()/t.x),o.height=Math.min(1-o.y,n.height.toFloat()/t.y),o.width&&o.height?c.setStyle("display",null):(o.x=o.y=o.width=o.height="",c.setStyle("display","none")),Object.each(o,function(e,t){g[t].set("value",""===e?"":Number(e).toFixed(15))})}};window.addEvent("domready",function(){s.getParent(".tl_tbox,.tl_box").getElements('input[name^="importantPart"]').each(function(t){["x","y","width","height"].each(function(e){t.get("name").substr(13,e.length)===e.capitalize()&&(g[e]=t=$(t))})}),4===Object.getLength(g)&&(Object.each(g,function(e){e.getParent().setStyle("display","none")}),s.addClass("tl_edit_preview_enabled"),c=new Element("div",{class:"tl_edit_preview_important_part"}).inject(s),e(),u.addEvent("load",e),s.addEvents({mousedown:t,touchstart:t}),$(document.documentElement).addEvents({mousemove:a,touchmove:a,mouseup:n,touchend:n,touchcancel:n,resize:e}))})},enableFileTreeUpload:function(i,e){i=$(i);var l,s,r=e.url,t=new Element("div",{class:"dropzone dropzone-filetree",html:'<span class="dropzone-previews"></span>'}).inject(i,"top");e.previewsContainer=t.getElement(".dropzone-previews"),e.clickable=!1;var c=new Dropzone(i,e);c.on("queuecomplete",function(){window.location.reload()}),c.on("dragover",function(e){if(e.dataTransfer&&e.dataTransfer.types&&-1!==e.dataTransfer.types.indexOf("Files")){i.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping");var t=e.target&&$(e.target);if(t){var n=t.match(".tl_folder")?t:t.getParent(".tl_folder");if(n=n||(n=t.getParent(".parent"))&&n.getPrevious(".tl_folder")){var a=n.getElement('img[src$="/icons/new.svg"]');a=a&&a.getParent("a")}}if(a&&a.href){if(c.options.url=""+a.href,n.addClass("tl_folder_dropping"),l!==n){l=n,s=(new Date).getTime();var o=n.getElement('img[src$="/icons/folPlus.svg"]');(o=o&&o.getParent("a"))&&setTimeout(function(){if(l===n&&s+900<(new Date).getTime()){var e=document.createEvent("HTMLEvents");e.initEvent("click",!0,!0),o.dispatchEvent(e),s=l=void 0}},1e3)}}else c.options.url=r,s=l=void 0}}),c.on("drop",function(e){e.dataTransfer&&e.dataTransfer.types&&-1!==e.dataTransfer.types.indexOf("Files")&&(t.addClass("dropzone-filetree-enabled"),Backend.getScrollOffset())}),c.on("dragleave",function(){i.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping"),s=l=void 0})},crawl:function(){var a=2e3,e=$("tl_crawl"),c=e.getElement("div.progress-bar"),d=e.getElement("p.progress-count"),u=e.getElement("div.results");!function n(e){e=e||!1;new Request({url:window.location.href,headers:{"Only-Status-Update":e},onSuccess:function(e){var t=JSON.decode(e);!function(e){var t,n=e.total-e.pending,a=0<e.total?parseInt(n/e.total*100,10):100;if(c.setStyle("width",a+"%"),c.set("html",a+"%"),c.setAttribute("aria-valuenow",a),d.set("html",n+" / "+e.total),e.finished)for(t in c.removeClass("running").addClass("finished"),u.removeClass("running").addClass("finished"),e.results)if(e.results.hasOwnProperty(t)){var o=u.getElement('.result[data-subscriber="'+t+'"] p.summary'),i=u.getElement('.result[data-subscriber="'+t+'"] p.warning'),l=u.getElement('.result[data-subscriber="'+t+'"] p.subscriber-log'),s=e.results[t],r=s.summary;s.warning&&i.set("html",s.warning),s.hasLog&&l.setStyle("display","block"),o.addClass(s.wasSuccessful?"success":"failure"),o.set("html",r)}}(t),t.finished||setTimeout(n,a)}}).send()}(!0)}};document.addEvent("mousedown",function(e){Backend.getMousePosition(e)}),window.addEvent("domready",function(){$(document.body).addClass("js"),Browser.Features.Touch&&$(document.body).addClass("touch"),Backend.collapsePalettes(),Backend.addInteractiveHelp(),Backend.tableWizardSetWidth(),Backend.enableImageSizeWidgets(),Backend.enableToggleSelect(),Backend.autoFocusFirstInputField(),null!=Elements.chosen&&$$("select.tl_chosen").chosen(),$$("textarea.monospace").each(function(e){Backend.toggleWrap(e)})}),window.addEvent("resize",function(){Backend.tableWizardSetWidth()}),window.addEvent("load",function(){Backend.limitPreviewHeight()}),window.addEvent("ajax_change",function(){Backend.addInteractiveHelp(),Backend.enableImageSizeWidgets(),Backend.enableToggleSelect(),null!=Elements.chosen&&$$("select.tl_chosen").filter(function(e){return"none"!=e.getStyle("display")}).chosen()});
\ No newline at end of file
+var AjaxRequest={themePath:Contao.script_url+"system/themes/"+Contao.theme+"/",toggleNavigation:function(e,t,n){var a=$(t),o=$(e).getParent("li");return a&&(o.hasClass("collapsed")?(o.removeClass("collapsed"),$(e).setAttribute("aria-expanded","true"),$(e).store("tip:title",Contao.lang.collapse),new Request.Contao({url:n}).post({action:"toggleNavigation",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(o.addClass("collapsed"),$(e).setAttribute("aria-expanded","false"),$(e).store("tip:title",Contao.lang.expand),new Request.Contao({url:n}).post({action:"toggleNavigation",id:t,state:0,REQUEST_TOKEN:Contao.request_token}))),!1},toggleStructure:function(i,l,s,r){i.blur();var e=$(l),c=$(i).getFirst("img");return e?"none"==e.getStyle("display")?(e.setStyle("display",null),c.src=AjaxRequest.themePath+"icons/folMinus.svg",$(i).store("tip:title",Contao.lang.collapse),new Request.Contao({field:i}).post({action:"toggleStructure",id:l,state:1,REQUEST_TOKEN:Contao.request_token})):(e.setStyle("display","none"),c.src=AjaxRequest.themePath+"icons/folPlus.svg",$(i).store("tip:title",Contao.lang.expand),new Request.Contao({field:i}).post({action:"toggleStructure",id:l,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:i,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:l,class:"parent",styles:{display:"inline"}});if(new Element("ul",{class:"level_"+s,html:e}).inject(t,"bottom"),5==r)t.inject($(i).getParent("li"),"after");else{for(var n,a=!1,o=$(i).getParent("li");"element"==typeOf(o)&&(n=o.getNext("li"));)if((o=n).hasClass("tl_folder")){a=!0;break}a?t.inject(o,"before"):t.inject(o,"after")}t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(i).store("tip:title",Contao.lang.collapse),c.src=AjaxRequest.themePath+"icons/folMinus.svg",window.fireEvent("structure"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadStructure",id:l,level:s,state:1,REQUEST_TOKEN:Contao.request_token}),!1},toggleFileManager:function(n,a,e,o){n.blur();var t=$(a),i=$(n).getFirst("img");return t?"none"==t.getStyle("display")?(t.setStyle("display",null),i.src=AjaxRequest.themePath+"icons/folMinus.svg",$(n).store("tip:title",Contao.lang.collapse),new Request.Contao({field:n}).post({action:"toggleFileManager",id:a,state:1,REQUEST_TOKEN:Contao.request_token})):(t.setStyle("display","none"),i.src=AjaxRequest.themePath+"icons/folPlus.svg",$(n).store("tip:title",Contao.lang.expand),new Request.Contao({field:n}).post({action:"toggleFileManager",id:a,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:n,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:a,class:"parent",styles:{display:"inline"}});new Element("ul",{class:"level_"+o,html:e}).inject(t,"bottom"),t.inject($(n).getParent("li"),"after"),t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(n).store("tip:title",Contao.lang.collapse),i.src=AjaxRequest.themePath+"icons/folMinus.svg",AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadFileManager",id:a,level:o,folder:e,state:1,REQUEST_TOKEN:Contao.request_token}),!1},togglePagetree:function(n,a,e,t,o){n.blur(),Backend.getScrollOffset();var i=$(a),l=$(n).getFirst("img");return i?"none"==i.getStyle("display")?(i.setStyle("display",null),l.src=AjaxRequest.themePath+"icons/folMinus.svg",$(n).store("tip:title",Contao.lang.collapse),new Request.Contao({field:n}).post({action:"togglePagetree",id:a,state:1,REQUEST_TOKEN:Contao.request_token})):(i.setStyle("display","none"),l.src=AjaxRequest.themePath+"icons/folPlus.svg",$(n).store("tip:title",Contao.lang.expand),new Request.Contao({field:n}).post({action:"togglePagetree",id:a,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:n,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:a,class:"parent",styles:{display:"inline"}});new Element("ul",{class:"level_"+o,html:e}).inject(t,"bottom"),t.inject($(n).getParent("li"),"after"),t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(n).store("tip:title",Contao.lang.collapse),l.src=AjaxRequest.themePath+"icons/folMinus.svg",AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadPagetree",id:a,level:o,field:e,name:t,state:1,REQUEST_TOKEN:Contao.request_token}),!1},toggleFiletree:function(n,a,e,t,o,i){n.blur(),Backend.getScrollOffset();var l=$(a),s=$(n).getFirst("img");return l?"none"==l.getStyle("display")?(l.setStyle("display",null),s.src=AjaxRequest.themePath+"icons/folMinus.svg",$(n).store("tip:title",Contao.lang.collapse),new Request.Contao({field:n}).post({action:"toggleFiletree",id:a,state:1,REQUEST_TOKEN:Contao.request_token})):(l.setStyle("display","none"),s.src=AjaxRequest.themePath+"icons/folPlus.svg",$(n).store("tip:title",Contao.lang.expand),new Request.Contao({field:n}).post({action:"toggleFiletree",id:a,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:n,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:a,class:"parent",styles:{display:"inline"}});new Element("ul",{class:"level_"+i,html:e}).inject(t,"bottom"),t.inject($(n).getParent("li"),"after"),t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(n).store("tip:title",Contao.lang.collapse),s.src=AjaxRequest.themePath+"icons/folMinus.svg",AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadFiletree",id:a,folder:e,level:i,field:t,name:o,state:1,REQUEST_TOKEN:Contao.request_token}),!1},toggleSubpalette:function(a,o,e){a.blur();var t=$(o);function i(e){a.form.elements.VERSION_NUMBER&&(a.form.elements.VERSION_NUMBER.value=/<input\s+[^>]*?name="VERSION_NUMBER"\s+[^>]*?value="([^"]*)"/i.exec(e)[1])}t?a.value?(a.value="",a.checked="",t.setStyle("display","none"),t.getElements("[required]").each(function(e){e.set("required",null).set("data-required","")}),new Request.Contao({field:a,onSuccess:i}).post({action:"toggleSubpalette",id:o,field:e,state:0,REQUEST_TOKEN:Contao.request_token})):(a.value=1,a.checked="checked",t.setStyle("display",null),t.getElements("[data-required]").each(function(e){e.set("required","").set("data-required",null)}),new Request.Contao({field:a,onSuccess:i}).post({action:"toggleSubpalette",id:o,field:e,state:1,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:a,evalScripts:!1,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e,t){var n=new Element("div",{id:o,class:"subpal cf",html:e,styles:{display:"block"}}).inject($(a).getParent("div").getParent("div"),"after");t.javascript&&(document.write=function(e){var n="";e.replace(/<script src="([^"]+)"/i,function(e,t){n=t}),n&&Asset.javascript(n,{onLoad:function(){Browser.exec(t.javascript)}})},Browser.exec(t.javascript)),a.value=1,a.checked="checked",n.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),i(e),AjaxRequest.hideBox(),window.fireEvent("subpalette"),window.fireEvent("ajax_change")}}).post({action:"toggleSubpalette",id:o,field:e,load:1,state:1,REQUEST_TOKEN:Contao.request_token})},toggleField:function(e,t){e.blur();var n,a,o=null,i=$(e).getFirst("img"),l=1==i.get("data-state"),s=e.getParent("div");return t&&(s.hasClass("tl_right")?o=s.getPrevious("div").getElement("img"):s.hasClass("tl_listing_container")?(null===(o=e.getParent("td").getPrevious("td").getFirst("div.list_icon"))&&(o=e.getParent("td").getPrevious("td").getElement("div.cte_type")),null===o&&(o=e.getParent("tr").getFirst("td").getElement("div.list_icon_new"))):(n=s.getNext("div"))&&(n.hasClass("cte_type")&&(o=n),null===o&&(o=n.getFirst("div.list_icon"))),null!==o&&("img"==o.nodeName.toLowerCase()?(o.getParent("ul.tl_listing").hasClass("tl_tree_xtnd")||(a=o.getParent("a"))&&-1==a.href.indexOf("contao/preview")&&(o=(n=a.getNext("a"))?n.getFirst("img"):new Element("img")),o.src=l?o.get("data-icon-disabled"):o.get("data-icon")):o.hasClass("cte_type")?l?(o.addClass("unpublished"),o.removeClass("published")):(o.addClass("published"),o.removeClass("unpublished")):o.setStyle("background-image","url("+(l?o.get("data-icon-disabled"):o.get("data-icon"))+")"))),i.src=l?i.get("data-icon-disabled"):i.get("data-icon"),i.set("data-state",l?0:1),new Request.Contao({url:e.href,followRedirects:!1}).get(),!1},toggleVisibility:function(e,t,n){window.console&&console.warn("AjaxRequest.toggleVisibility() is deprecated. Please use the new toggle operation."),e.blur();var a,o,i,l,s,r,c=null,d=$(e).getFirst("img"),u=1==d.get("data-state"),g=e.getParent("div");return null===d.get("data-state")&&(u=-1==d.src.indexOf("invisible"),window.console&&console.warn('Using a visibility toggle without a "data-state" attribute is deprecated. Please adjust your Contao DCA file.')),g.hasClass("tl_right")?c=g.getPrevious("div").getElement("img"):g.hasClass("tl_listing_container")?(null===(c=e.getParent("td").getPrevious("td").getFirst("div.list_icon"))&&(c=e.getParent("td").getPrevious("td").getElement("div.cte_type")),null===c&&(c=e.getParent("tr").getFirst("td").getElement("div.list_icon_new"))):(o=g.getNext("div"))&&(o.hasClass("cte_type")&&(c=o),null===c&&(c=o.getFirst("div.list_icon"))),null!==c&&("img"==c.nodeName.toLowerCase()?(c.getParent("ul.tl_listing").hasClass("tl_tree_xtnd")?(i=c.get("data-icon"),l=c.get("data-icon-disabled"),null===i&&(i=c.src.replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)$/,"$1/$2.$3"),window.console&&console.warn('Using a row icon without a "data-icon" attribute is deprecated. Please adjust your Contao DCA file.')),null===l&&(l=c.src.replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)$/,"$1/$2_.$3"),window.console&&console.warn('Using a row icon without a "data-icon-disabled" attribute is deprecated. Please adjust your Contao DCA file.'))):((s=c.getParent("a"))&&-1==s.href.indexOf("contao/preview")&&(c=(o=s.getNext("a"))?o.getFirst("img"):new Element("img")),i=c.get("data-icon"),l=c.get("data-icon-disabled"),null===i&&(a=c.src.replace(/.*_([0-9])\.(gif|png|jpe?g|svg)/,"$1"),i=c.src.replace(/_[0-9]\.(gif|png|jpe?g|svg)/,(1==a.toInt()?"":"_"+(a.toInt()-1))+".$1").split(/[\\/]/).pop(),window.console&&console.warn('Using a row icon without a "data-icon" attribute is deprecated. Please adjust your Contao DCA file.')),null===l&&(a=c.src.replace(/.*_([0-9])\.(gif|png|jpe?g|svg)/,"$1"),l=c.src.replace(/(_[0-9])?\.(gif|png|jpe?g|svg)/,(a==c.src?"_1":"_"+(a.toInt()+1))+".$2").split(/[\\/]/).pop(),window.console&&console.warn('Using a row icon without a "data-icon-disabled" attribute is deprecated. Please adjust your Contao DCA file.'))),-1==i.indexOf("/")&&(i=AjaxRequest.themePath+(i.match(/\.svg$/)?"icons/":"images/")+i),-1==l.indexOf("/")&&(l=AjaxRequest.themePath+(l.match(/\.svg$/)?"icons/":"images/")+l),c.src=u?l:i):c.hasClass("cte_type")?u?(c.addClass("unpublished"),c.removeClass("published")):(c.addClass("published"),c.removeClass("unpublished")):(i=c.get("data-icon"),l=c.get("data-icon-disabled"),null===i&&(i=c.getStyle("background-image").replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)\);?$/,"$1/$2.$2"),window.console&&console.warn('Using a row icon without a "data-icon" attribute is deprecated. Please adjust your Contao DCA file.')),null===l&&(l=c.getStyle("background-image").replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)\);?$/,"$1/$2_.$3"),window.console&&console.warn('Using a row icon without a "data-icon-disabled" attribute is deprecated. Please adjust your Contao DCA file.')),-1==i.indexOf("/")&&(i=AjaxRequest.themePath+(i.match(/\.svg$/)?"icons/":"images/")+i),-1==l.indexOf("/")&&(l=AjaxRequest.themePath+(l.match(/\.svg$/)?"icons/":"images/")+l),c.setStyle("background-image","url("+(u?l:i)+")"))),"tl_style"==n&&g.getParent("div").getElement("pre").toggleClass("disabled"),i=d.get("data-icon")||AjaxRequest.themePath+"icons/visible.svg",l=d.get("data-icon-disabled")||AjaxRequest.themePath+"icons/invisible.svg",-1!==e.href.indexOf("act=toggle")?(d.src=u?l:i,d.set("data-state",u?0:1),new Request.Contao({url:e.href,followRedirects:!1}).get()):(d.src=u?l:i,d.set("data-state",u?0:1),(r={state:u?0:1,rt:Contao.request_token})[$(e).get("data-tid")||"tid"]=t,new Request.Contao({url:window.location.href,followRedirects:!1}).get(r)),!1},toggleFeatured:function(e,t){window.console&&console.warn("AjaxRequest.toggleFeatured() is deprecated. Please use the new toggle operation."),e.blur();var n=$(e).getFirst("img"),a=1==n.get("data-state");return null===n.get("data-state")&&(a=-1==n.src.indexOf("featured_"),window.console&&console.warn('Using a featured toggle without a "data-state" attribute is deprecated. Please adjust your Contao DCA file.')),a?(n.src=AjaxRequest.themePath+"icons/featured_.svg",n.set("data-state",0),(new Request.Contao).post({action:"toggleFeatured",id:t,state:0,REQUEST_TOKEN:Contao.request_token})):(n.src=AjaxRequest.themePath+"icons/featured.svg",n.set("data-state",1),(new Request.Contao).post({action:"toggleFeatured",id:t,state:1,REQUEST_TOKEN:Contao.request_token})),!1},toggleFieldset:function(e,t,n){e.blur(),Backend.getScrollOffset();var a=$("pal_"+t);if(a.hasClass("collapsed"))a.removeClass("collapsed"),(new Request.Contao).post({action:"toggleFieldset",id:t,table:n,state:1,REQUEST_TOKEN:Contao.request_token});else{for(var o=a.getParent("form"),i=a.getElements("[required]"),l=!0,s=0;s<i.length;s++)if(!i[s].get("value")){l=!1;break}l?(a.addClass("collapsed"),(new Request.Contao).post({action:"toggleFieldset",id:t,table:n,state:0,REQUEST_TOKEN:Contao.request_token})):"function"==typeof o.checkValidity&&o.getElement('button[type="submit"]').click()}return!1},toggleCheckboxGroup:function(e,t){e.blur();var n=$(t),a=$(e).getFirst("img");return!!n&&("none"==n.getStyle("display")?(n.setStyle("display",null),a.src=AjaxRequest.themePath+"icons/folMinus.svg",(new Request.Contao).post({action:"toggleCheckboxGroup",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(n.setStyle("display","none"),a.src=AjaxRequest.themePath+"icons/folPlus.svg",(new Request.Contao).post({action:"toggleCheckboxGroup",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!0)},displayBox:function(e){var t=$("tl_ajaxBox"),n=$("tl_ajaxOverlay"),a=window.getScroll();null===n&&(n=new Element("div",{id:"tl_ajaxOverlay"}).inject($(document.body),"bottom")),n.set({styles:{display:"block",top:a.y+"px"}}),null===t&&(t=new Element("div",{id:"tl_ajaxBox"}).inject($(document.body),"bottom")),t.set({html:e,styles:{display:"block",top:a.y+100+"px"}})},hideBox:function(){var e=$("tl_ajaxBox"),t=$("tl_ajaxOverlay");t&&t.setStyle("display","none"),e&&e.setStyle("display","none")}},Backend={currentId:null,xMousePosition:0,yMousePosition:0,popupWindow:null,themePath:Contao.script_url+"system/themes/"+Contao.theme+"/",getMousePosition:function(e){Backend.xMousePosition=e.client.x,Backend.yMousePosition=e.client.y},openWindow:function(e,t,n){e.blur(),t=Browser.ie?t+40:t+17,n=Browser.ie?n+30:n+17,Backend.popupWindow=window.open(e.href,"","width="+t+",height="+n+",modal=yes,left=100,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no")},openModalWindow:function(e,t,n){new SimpleModal({width:e,hideFooter:!0,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}}).show({title:t,contents:n})},openModalImage:function(e){var t=e||{},n=(window.getSize().x-20).toInt();(!t.width||t.width>n)&&(t.width=Math.min(n,900)),new SimpleModal({width:t.width,hideFooter:!0,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}}).show({title:t.title&&t.title.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),contents:'<img src="'+t.url+'" alt="">'})},openModalIframe:function(e){var t=e||{},n=(window.getSize().x-20).toInt(),a=(window.getSize().y-137).toInt();(!t.width||t.width>n)&&(t.width=Math.min(n,900)),(!t.height||t.height>a)&&(t.height=a),new SimpleModal({width:t.width,hideFooter:!0,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}}).show({title:t.title&&t.title.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),contents:'<iframe src="'+t.url+'" width="100%" height="'+t.height+'" frameborder="0"></iframe>',model:"modal"})},openModalSelector:function(e){var d=e||{},t=(window.getSize().x-20).toInt(),n=(window.getSize().y-192).toInt();d.id||(d.id="tl_select"),(!d.width||d.width>t)&&(d.width=Math.min(t,900)),(!d.height||d.height>n)&&(d.height=n);var a=new SimpleModal({width:d.width,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}});a.addButton(Contao.lang.cancel,"btn",function(){this.buttons[0].hasClass("btn-disabled")||this.hide()}),a.addButton(Contao.lang.apply,"btn primary",function(){if(!this.buttons[1].hasClass("btn-disabled")){var e,t,n,a,o,i,l,s,r=window.frames["simple-modal-iframe"],c=[];if(void 0!==r){for((l=(e=r.document.getElementById(d.id)).get("data-picker-value"))&&(c=JSON.parse(l)),t=e.getElementsByTagName("input"),i=0;i<t.length;i++)t[i].id.match(/^(check_all_|reset_)/)||(s=c.indexOf(t[i].get("value")),t[i].checked?-1==s&&c.push(t[i].get("value")):-1!=s&&c.splice(s,1));d.callback?d.callback(e.get("data-table"),c):d.tag&&(n=$(d.tag))?(window.console&&console.warn("Using the modal selector without a callback function is deprecated. Please adjust your Contao DCA file."),n.value=c.join(","),(o=e.get("data-inserttag"))&&(n.value="{{"+o+"::"+n.value+"}}"),d.self.set("href",d.self.get("href").replace(/&value=[^&]*/,"&value="+c.join(",")))):d.id&&(n=$("ctrl_"+d.id))&&(a=e.get("data-callback"))&&(window.console&&console.warn("Using the modal selector without a callback function is deprecated. Please adjust your Contao DCA file."),n.value=c.join("\t"),new Request.Contao({field:n,evalScripts:!1,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e,t){$("ctrl_"+d.id).getParent("div").set("html",t.content),t.javascript&&Browser.exec(t.javascript),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:a,name:d.id,value:n.value,REQUEST_TOKEN:Contao.request_token})),this.hide()}else alert("Could not find the SimpleModal frame")}}),a.show({title:d.title&&d.title.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),contents:'<iframe src="'+d.url+'" name="simple-modal-iframe" width="100%" height="'+d.height+'" frameborder="0"></iframe>',model:"modal"})},openModalBrowser:function(n,e,t,a,o){Backend.openModalSelector({id:"tl_listing",title:a.document.getElement("div.mce-title").get("text"),url:Contao.routes.backend_picker+"?context="+("file"==t?"link":"file")+"&amp;extras[fieldType]=radio&amp;extras[filesOnly]=true&amp;extras[source]="+o+"&amp;value="+e+"&amp;popup=1",callback:function(e,t){a.document.getElementById(n).value=t.join(",")}})},getScrollOffset:function(){window.sessionStorage.setItem("contao_backend_offset",window.getScroll().y)},initScrollOffset:function(){Cookie.dispose("BE_PAGE_OFFSET"),$$('.tl_submit_container button[name][name!="save"]').each(function(e){e.addEvent("click",function(){window.sessionStorage.removeItem("contao_backend_offset")})});var e=window.sessionStorage.getItem("contao_backend_offset");if(window.sessionStorage.removeItem("contao_backend_offset"),e){var t=window.document.getElementById("header"),i=0;t&&t.addClass("down"),$$("[data-add-to-scroll-offset]").each(function(e){var t=e.get("data-add-to-scroll-offset"),n=e.getScrollSize().y,a=!1,o=!1;t?("-"===t.charAt(0)&&(a=!0,t=t.substring(1)),"%"===t.charAt(t.length-1)&&(o=!0,t=t.substring(0,t.length-1)),t=parseInt(t,10),o&&(t=Math.round(n*t/100)),a&&(t*=-1),i+=t):i+=n}),this.vScrollTo(parseInt(e,10)+i)}},autoSubmit:function(e){Backend.getScrollOffset();var t=new Element("input",{type:"hidden",name:"SUBMIT_TYPE",value:"auto"}),n=$(e)||e;t.inject(n,"bottom"),n.submit()},vScrollTo:function(e){window.addEvent("load",function(){window.scrollTo(null,parseInt(e))})},limitPreviewHeight:function(){var l=0;$$("div.limit_height").each(function(e){var t,n,a,o,i=e.getParent(".tl_content");i&&(i.hasClass("wrapper_start")||i.hasClass("wrapper_stop"))||(0===l&&(l=e.className.replace(/[^0-9]*/,"").toInt()),l&&(t=new Element("div",{class:"limit_toggler"}),n=new Element("button",{type:"button",html:"<span>...</span>",class:"unselectable","data-state":0}).inject(t),a=e.getCoordinates(),e.setStyle("height",l),a.height<=l||(n.addEvent("click",function(){o=t.getPrevious("div").getStyle("height").toInt(),t.getPrevious("div").setStyle("height",l<o?l:""),n.set("data-state",n.get("data-state")?0:1)}),t.inject(e,"after"))))})},toggleCheckboxes:function(e,t){for(var n=$$("input"),a=$(e).checked?"checked":"",o=0;o<n.length;o++)"checkbox"==n[o].type.toLowerCase()&&(void 0!==t&&t!=n[o].id.substr(0,t.length)||(n[o].checked=a))},toggleCheckboxGroup:function(e,t){var n=$(e).className,a=$(e).checked?"checked":"";"tl_checkbox"==n?($(t)?$$("#"+t+" .tl_checkbox"):$(e).getParent("fieldset").getElements(".tl_checkbox")).each(function(e){e.checked=a}):"tl_tree_checkbox"==n&&$$("#"+t+" .parent .tl_tree_checkbox").each(function(e){e.checked=a});Backend.getScrollOffset()},toggleCheckboxElements:function(e,t){var n=$(e).checked?"checked":"";$$("."+t).each(function(e){e.hasClass("tl_checkbox")&&(e.checked=n)}),Backend.getScrollOffset()},toggleWrap:function(e){var t=$(e),n="off"==t.getProperty("wrap")?"soft":"off";t.setProperty("wrap",n)},toggleUnchanged:function(){$$("#result-list .tl_confirm").each(function(e){e.toggleClass("hidden")})},blink:function(){},addColorPicker:function(){return!0},collapsePalettes:function(){$$("fieldset.hide").each(function(e){e.addClass("collapsed")}),$$("label.error, label.mandatory").each(function(e){var t=e.getParent("fieldset");t&&t.removeClass("collapsed")})},addInteractiveHelp:function(){new Tips.Contao("p.tl_tip",{offset:{x:9,y:23},text:function(e){return e.get("html")}}),new Tips.Contao($("home"),{offset:{x:15,y:42}}),new Tips.Contao($$("#tmenu a[title]").filter(function(e){return""!=e.title}),{offset:{x:9,y:42}}),new Tips.Contao($$('a[title][class^="group-"]').filter(function(e){return""!=e.title}),{offset:{x:3,y:27}}),new Tips.Contao($$("a[title].navigation").filter(function(e){return""!=e.title}),{offset:{x:34,y:32}}),$$("img[title]").filter(function(e){return""!=e.title}).each(function(e){new Tips.Contao(e,{offset:{x:0,y:"gimage"==e.get("class")?60:30}})}),["a[title]","input[title]","button[title]","time[title]","span[title]"].each(function(e){new Tips.Contao($$(e).filter(function(e){return""!=e.title}),{offset:{x:0,y:"time[title]"==e||"span[title]"==e?26:30}})})},retrieveInteractiveHelp:function(e){e&&e.each(function(e){var t=e.retrieve("tip:title");t&&e.set("title",t)})},hideInteractiveHelp:function(){function e(){document.querySelectorAll(".tip-wrap").forEach(function(e){e.setStyle("display","none")})}e(),setTimeout(e,(new Tips.Contao).options.showDelay)},makeParentViewSortable:function(e){var t=new Scroller(document.getElement("body"),{onChange:function(e,t){this.element.scrollTo(this.element.getScroll().x,t)}}),i=new Sortables(e,{constrain:!0,opacity:.6,onStart:function(){t.start()},onComplete:function(){t.stop()},onSort:function(e){var t,n,a=e.getParent("ul"),o=0;if(a&&(t=a.getChildren("li > div:first-child")))for(n=0;n<t.length;n++)t[n].hasClass("wrapper_stop")&&0<o&&o--,t[n].className=t[n].className.replace(/(^|\s)indent[^\s]*/g,""),0<o&&t[n].addClass("indent").addClass("indent_"+o),t[n].hasClass("wrapper_start")&&o++,t[n].removeClass("indent_first"),t[n].removeClass("indent_last"),t[n-1]&&t[n-1].hasClass("wrapper_start")&&t[n].addClass("indent_first"),t[n+1]&&t[n+1].hasClass("wrapper_stop")&&t[n].addClass("indent_last")},handle:".drag-handle"});i.active=!1,i.addEvent("start",function(){i.active=!0}),i.addEvent("complete",function(e){var t,n,a,o;i.active&&(e.getPrevious("li")?(t=e.get("id").replace(/li_/,""),n=e.getPrevious("li").get("id").replace(/li_/,""),a=window.location.search.replace(/id=[0-9]*/,"id="+t)+"&act=cut&mode=1&pid="+n,o=window.location.href.replace(/\?.*$/,""),new Request.Contao({url:o+a,followRedirects:!1}).get()):e.getParent("ul")&&(t=e.get("id").replace(/li_/,""),n=e.getParent("ul").get("id").replace(/ul_/,""),a=window.location.search.replace(/id=[0-9]*/,"id="+t)+"&act=cut&mode=2&pid="+n,o=window.location.href.replace(/\?.*$/,""),new Request.Contao({url:o+a,followRedirects:!1}).get()))})},makeMultiSrcSortable:function(a,o,i){var e=new Sortables($(a),{constrain:!0,opacity:.6}).addEvent("complete",function(){var e,t=[],n=$(a).getChildren("[data-id]");for(e=0;e<n.length;e++)t.push(n[e].get("data-id"));o===i&&$(i).value.split(",").forEach(function(e){-1===t.indexOf(e)&&t.push(e)}),$(o).value=t.join(",")});$(a).getElements(".gimage").each(function(n){n.hasClass("removable")?new Element("button",{type:"button",html:"&times;",class:"tl_red"}).addEvent("click",function(){var e=n.getParent("li"),t=e.get("data-id");$(i).value=$(i).value.split(",").filter(function(e){return e!=t}).join(","),$(o).value=$(o).value.split(",").filter(function(e){return e!=t}).join(","),e.dispose()}).inject(n,"after"):new Element("button",{type:"button",html:"&times",disabled:!0}).inject(n,"after")}),e.fireEvent("complete")},enableFileTreeDragAndDrop:function(c,d){var u=new Scroller(document.getElement("body"),{onChange:function(e,t){this.element.scrollTo(this.element.getScroll().x,t)}});function g(e){return e&&e.hasClass("parent")&&e.getPrevious(".tl_folder")?e.getPrevious(".tl_folder"):e}c.addEvent("mousedown",function(e){var t=e.target.hasClass("drag-handle")?e.target:e.target.getParent(".drag-handle"),o=e.target.getParent(".tl_file,.tl_folder");if(t&&o&&!e.rightClick){u.start(),c.addClass("tl_listing_dragging");var i,l,n=o.getElements(".tl_left")[0]||o,s=n.clone(!0).inject(c).addClass("tl_left_dragging");s.setPosition({x:e.page.x-n.getOffsetParent().getPosition().x-s.getSize().x,y:n.getPosition(n.getOffsetParent()).y}).setStyle("display","none");var a=new Drag.Move(s,{droppables:$$([c]).append(c.getElements(".tl_folder,li.parent,.tl_folder_top")),unDraggableTags:[],modifiers:{x:"left",y:"top"},onStart:function(){s.setStyle("display","")},onEnter:function(e,t){if((t=g(t)).addClass("tl_folder_dropping"),t.hasClass("tl_folder")&&i!==t){i=t,l=(new Date).getTime();var n=t.getElement('img[src$="/icons/folPlus.svg"]');(n=n&&n.getParent("a"))&&setTimeout(function(){if(i===t&&l+900<(new Date).getTime()){var e=document.createEvent("HTMLEvents");e.initEvent("click",!0,!0),n.dispatchEvent(e),l=i=void 0,window.addEvent("ajax_change",function e(){a&&a.droppables&&c&&c.getElements&&(a.droppables=$$([c]).append(c.getElements(".tl_folder,li.parent"))),window.removeEvent("ajax_change",e)})}},1e3)}},onCancel:function(){l=i=void 0,u.stop(),s.destroy(),window.removeEvent("keyup",r),c.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping"),c.removeClass("tl_listing_dragging")},onDrop:function(e,t){if(l=i=void 0,u.stop(),s.destroy(),window.removeEvent("keyup",r),c.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping"),c.removeClass("tl_listing_dragging"),t=g(t)){var n=o.get("data-id"),a=t.get("data-id")||decodeURIComponent(d.url.split(/[?&]pid=/)[1].split("&")[0]);n&&a&&(0===(a+"/").indexOf(n+"/")||a+"/"===n.replace(/[^/]+$/,""))||(Backend.getScrollOffset(),document.location.href=d.url+"&id="+encodeURIComponent(n)+"&pid="+encodeURIComponent(a))}},onLeave:function(e,t){(t=g(t)).removeClass("tl_folder_dropping"),l=i=void 0}});a.start(e),window.addEvent("keyup",r)}function r(e){"esc"===e.key&&a&&a.stop&&(a.droppables=$$([]),a.stop())}})},listWizard:function(e){var l=$(e),s=function(n){var e,a,o,i;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){Backend.getScrollOffset(),e=n.clone(!0).inject(n,"before"),(a=n.getFirst("input"))&&(e.getFirst("input").value=a.value),s(e)});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<l.getChildren().length&&n.destroy()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("li"))?n.inject(o,"before"):n.inject(l,"bottom"),t.focus()):40==e.event.keyCode&&(e.preventDefault(),(i=n.getNext("li"))?n.inject(i,"after"):n.inject(l.getFirst("li"),"before"),t.focus())})}})};new Sortables(l,{constrain:!0,opacity:.6,handle:".drag-handle"}),l.getChildren().each(function(e){s(e)})},tableWizard:function(e){var t=$(e),u=t.getElement("thead"),g=t.getElement("tbody"),f=function(e){var t,n,a,o,i=e.getChildren();for(a=0;a<i.length;a++)for(n=i[a].getChildren(),o=0;o<n.length;o++)(t=n[o].getFirst("textarea"))&&(t.name=t.name.replace(/\[[0-9]+][[0-9]+]/g,"["+a+"]["+o+"]"));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){f(e)}})},p=function(n){var a,o,i,l,s,r,c,d=u.getFirst("tr");n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"rcopy":t.addEvent("click",function(){for(Backend.getScrollOffset(),l=new Element("tr"),s=n.getChildren(),c=0;c<s.length;c++)Backend.retrieveInteractiveHelp(s[c].getElements("button,a")),i=s[c].clone(!0).inject(l,"bottom"),(a=s[c].getFirst("textarea"))&&(i.getFirst("textarea").value=a.value);l.inject(n,"after"),p(l),f(g),Backend.addInteractiveHelp()});break;case"rdelete":t.addEvent("click",function(){Backend.getScrollOffset(),1<g.getChildren().length&&n.destroy(),f(g),Backend.hideInteractiveHelp()});break;case"ccopy":t.addEvent("click",function(){for(Backend.getScrollOffset(),r=h(t),s=g.getChildren(),c=0;c<s.length;c++)o=s[c].getChildren()[r],Backend.retrieveInteractiveHelp(o.getElements("button,a")),i=o.clone(!0).inject(o,"after"),(a=o.getFirst("textarea"))&&(i.getFirst("textarea").value=a.value),p(i);var e=d.getFirst("td");Backend.retrieveInteractiveHelp(e.getElements("button,a")),i=e.clone(!0).inject(d.getLast("td"),"before"),p(i),f(g),Backend.addInteractiveHelp()});break;case"cmovel":t.addEvent("click",function(){if(Backend.getScrollOffset(),r=h(t),s=g.getChildren(),0<r)for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(o.getPrevious(),"before");else for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(s[c].getLast(),"before");f(g)});break;case"cmover":t.addEvent("click",function(){if(Backend.getScrollOffset(),r=h(t),s=g.getChildren(),r<n.getChildren().length-2)for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(o.getNext(),"after");else for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(s[c].getFirst(),"before");f(g)});break;case"cdelete":t.addEvent("click",function(){if(Backend.getScrollOffset(),r=h(t),s=g.getChildren(),2<n.getChildren().length){for(c=0;c<s.length;c++)s[c].getChildren()[r].destroy();d.getFirst("td").destroy()}f(g),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(l=n.getPrevious("tr"))?n.inject(l,"before"):n.inject(g,"bottom"),t.focus(),f(g)):40==e.event.keyCode&&(e.preventDefault(),(l=n.getNext("tr"))?n.inject(l,"after"):n.inject(g,"top"),t.focus(),f(g))})}})},h=function(e){var t,n=$(e).getParent("td"),a=n.getParent("tr").getChildren(),o=0;for(t=0;t<a.length&&a[t]!=n;t++)o++;return o};f(g),u.getChildren().each(function(e){p(e)}),g.getChildren().each(function(e){p(e)}),Backend.tableWizardResize()},tableWizardResize:function(t){var n=window.localStorage.getItem("contao_table_wizard_cell_size");if(void 0!==t)n="",$$(".tl_tablewizard textarea").each(function(e){e.setStyle("width",(e.getStyle("width").toInt()*t).round().limit(142,284)),e.setStyle("height",(e.getStyle("height").toInt()*t).round().limit(66,132)),""==n&&(n=e.getStyle("width")+"|"+e.getStyle("height"))}),window.localStorage.setItem("contao_table_wizard_cell_size",n);else if(null!==n){var a=n.split("|");$$(".tl_tablewizard textarea").each(function(e){e.setStyle("width",a[0]),e.setStyle("height",a[1])})}},tableWizardSetWidth:function(){var e=$("tl_tablewizard");e&&e.setStyle("width",Math.round(.96*e.getParent(".tl_formbody_edit").getComputedSize().width))},moduleWizard:function(e){var r=$(e).getElement("tbody"),c=function(e){var t,n,a,o,i,l=e.getChildren();for(n=0;n<l.length;n++)for(t=l[n].getChildren(),a=0;a<t.length;a++)(o=t[a].getElement("select"))&&(o.name=o.name.replace(/\[[0-9]+]/g,"["+n+"]")),(i=t[a].getElement('input[type="checkbox"]'))&&(i.set("tabindex",-1),i.name=i.name.replace(/\[[0-9]+]/g,"["+n+"]"));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){c(e)}})},d=function(n){var e,a,o,i,l,s;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),o=new Element("tr"),i=n.getChildren(),s=0;s<i.length;s++)Backend.retrieveInteractiveHelp(i[s].getElements("button,a")),a=i[s].clone(!0).inject(o,"bottom"),(e=i[s].getElement("select"))&&(a.getElement("select").value=e.value);o.inject(n,"after"),o.getElement(".chzn-container").destroy(),new Chosen(o.getElement("select.tl_select")),d(o),c(r),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<r.getChildren().length&&n.destroy(),c(r),Backend.hideInteractiveHelp()});break;case"enable":t.addEvent("click",function(){Backend.getScrollOffset(),(l=t.getNext('input[type="checkbox"]')).checked?(l.checked="",t.getElement("img").src=Backend.themePath+"icons/invisible.svg"):(l.checked="checked",t.getElement("img").src=Backend.themePath+"icons/visible.svg"),c(r)});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("tr"))?n.inject(o,"before"):n.inject(r,"bottom"),t.focus(),c(r)):40==e.event.keyCode&&(e.preventDefault(),(o=n.getNext("tr"))?n.inject(o,"after"):n.inject(r,"top"),t.focus(),c(r))})}})};c(r),r.getChildren().each(function(e){d(e)})},optionsWizard:function(e){var s=$(e).getElement("tbody"),r=function(e){var t,n,a,o,i=e.getChildren();for(n=0;n<i.length;n++)for(t=i[n].getChildren(),a=0;a<t.length;a++)(o=t[a].getFirst("input"))&&(o.name=o.name.replace(/\[[0-9]+]/g,"["+n+"]"),"checkbox"==o.type&&(o.id=o.name.replace(/\[[0-9]+]/g,"").replace(/\[/g,"_").replace(/]/g,"")+"_"+n,o.getNext("label").set("for",o.id)));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){r(e)}})},c=function(n){var e,a,o,i,l;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),o=new Element("tr"),i=n.getChildren(),l=0;l<i.length;l++)Backend.retrieveInteractiveHelp(i[l].getElements("button,a")),a=i[l].clone(!0).inject(o,"bottom"),(e=i[l].getFirst("input"))&&(a.getFirst("input").value=e.value,"checkbox"==e.type&&(a.getFirst("input").checked=e.checked?"checked":""));o.inject(n,"after"),c(o),r(s),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<s.getChildren().length&&n.destroy(),r(s),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("tr"))?n.inject(o,"before"):n.inject(s,"bottom"),t.focus(),r(s)):40==e.event.keyCode&&(e.preventDefault(),(o=n.getNext("tr"))?n.inject(o,"after"):n.inject(s,"top"),t.focus(),r(s))})}})};r(s),s.getChildren().each(function(e){c(e)})},keyValueWizard:function(e){var s=$(e).getElement("tbody"),r=function(e){var t,n,a,o,i=e.getChildren();for(n=0;n<i.length;n++)for(t=i[n].getChildren(),a=0;a<t.length;a++)(o=t[a].getFirst("input"))&&(o.name=o.name.replace(/\[[0-9]+]/g,"["+n+"]"));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){r(e)}})},c=function(n){var e,a,o,i,l;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),o=new Element("tr"),i=n.getChildren(),l=0;l<i.length;l++)Backend.retrieveInteractiveHelp(i[l].getElements("button,a")),a=i[l].clone(!0).inject(o,"bottom"),(e=i[l].getFirst("input"))&&(a.getFirst().value=e.value);o.inject(n,"after"),c(o),r(s),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<s.getChildren().length&&n.destroy(),r(s),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("tr"))?n.inject(o,"before"):n.inject(s,"bottom"),t.focus(),r(s)):40==e.event.keyCode&&(e.preventDefault(),(o=n.getNext("tr"))?n.inject(o,"after"):n.inject(s,"top"),t.focus(),r(s))})}})};r(s),s.getChildren().each(function(e){c(e)})},checkboxWizard:function(e){var o=$(e).getElement(".sortable");new Sortables(o,{constrain:!0,opacity:.6,handle:".drag-handle"}),o.getChildren().each(function(e){var n,a;(n=e).getElements("button").each(function(t){t.hasEvent("click")||t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(a=n.getPrevious("span"))?n.inject(a,"before"):n.inject(o,"bottom"),t.focus()):40==e.event.keyCode&&(e.preventDefault(),(a=n.getNext("span"))?n.inject(a,"after"):n.inject(o,"top"),t.focus())})})})},metaDelete:function(e){var t=e.getParent("li");null===t.getPrevious()&&null===t.getNext()?t.getElements("input, textarea").each(function(e){e.value=""}):t.destroy()},toggleAddLanguageButton:function(e){var t=e.getParent("div").getElement('input[type="button"]');""!=e.value?t.removeProperty("disabled"):t.setProperty("disabled",!0)},sectionWizard:function(e){var c=$(e).getElement("tbody"),d=function(e){var t,n,a,o=e.getChildren();for(n=0;n<o.length;n++)for(t=o[n].getChildren(),a=0;a<t.length;a++)t[a].getElements("input").each(function(e){e.name=e.name.replace(/\[[0-9]+]/g,"["+n+"]")}),t[a].getElements("select").each(function(e){e.name=e.name.replace(/\[[0-9]+]/g,"["+n+"]")});new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){d(e)}})},u=function(n){var e,a,o,i,l,s,r;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),a=new Element("tr"),o=n.getChildren(),s=0;s<o.length;s++)for(Backend.retrieveInteractiveHelp(o[s].getElements("button,a")),e=o[s].clone(!0).inject(a,"bottom"),i=o[s].getElements("select"),l=e.getElements("select"),r=0;r<i.length;r++)l[r].value=i[r].value;a.inject(n,"after"),u(a),d(c),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<c.getChildren().length&&n.destroy(),d(c),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(a=n.getPrevious("tr"))?n.inject(a,"before"):n.inject(c,"bottom"),t.focus(),d(c)):40==e.event.keyCode&&(e.preventDefault(),(a=n.getNext("tr"))?n.inject(a,"after"):n.inject(c,"top"),t.focus(),d(c))})}})};d(c),c.getChildren().each(function(e){u(e)})},updateModuleLink:function(e){var t=e.getParent("tr").getLast("td"),n=t.getElement("a.module_link");n.href=n.href.replace(/id=[0-9]+/,"id="+e.value),0<e.value?(t.getElement("a.module_link").setStyle("display",null),t.getElement("img.module_image").setStyle("display","none")):(t.getElement("a.module_link").setStyle("display","none"),t.getElement("img.module_image").setStyle("display",null))},enableImageSizeWidgets:function(){$$(".tl_image_size").each(function(e){function t(){if(""===n.get("value")||0===n.get("value").indexOf("_")||n.get("value").toInt().toString()===n.get("value")){a.readOnly=!0,o.readOnly=!0;var e=$(n.getSelected()[0]).get("text");e=1<e.split("(").length?e.split("(").getLast().split(")")[0].split("x"):["",""],a.set("value","").set("placeholder",+e[0]||""),o.set("value","").set("placeholder",+e[1]||"")}else a.set("placeholder",""),o.set("placeholder",""),a.readOnly=!1,o.readOnly=!1}var n=e.getElement("select"),a=e.getChildren("input")[0],o=e.getChildren("input")[1];t(),n.addEvent("change",t),n.addEvent("keyup",t)})},enableToggleSelect:function(){function a(e){for(t=r.indexOf(e),n=r.indexOf(o),l=Math.min(t,n),s=Math.max(t,n),i=!!r[n].checked;l<=s;l++)r[l].checked=i}var o,t,n,i,l,s,e=$("tl_listing"),r=[];e&&(r=e.getElements('input[type="checkbox"]')),$$(".toggle_select").each(function(e){var t=e.retrieve("boundEvent");t&&e.removeEvent("click",t),e.getElements('label,input[type="checkbox"],input[type="radio"]').each(function(e){e.addEvent("click",function(e){e.stopPropagation()})}),t=function(e){var t=this.getElement('input[type="checkbox"],input[type="radio"]'),n=$(e.target).getParent(".limit_toggler");t&&!t.get("disabled")&&null===n&&("radio"!=t.type?(e.shift&&o?a(t):(t.checked=t.checked?"":"checked","Backend.toggleCheckboxes(this)"==t.get("onclick")&&Backend.toggleCheckboxes(t)),o=t):t.checked||(t.checked="checked"))}.bind(e),e.addEvent("click",t),e.store("boundEvent",t)}),r.each(function(e){e.addEvent("click",function(e){e.shift&&o&&a(this),o=this})})},autoFocusFirstInputField:function(){var e=document.querySelector("#main .tl_formbody_edit");if(e){var t=$(e).getElements("input, textarea").filter(function(e){return!e.get("disabled")&&!e.get("readonly")&&e.isVisible()&&"checkbox"!==e.get("type")&&"radio"!==e.get("type")&&"submit"!==e.get("type")&&"image"!==e.get("type")&&(!e.get("autocomplete")||"off"===e.get("autocomplete")||!e.get("value"))});t[0]&&t[0].focus()}},editPreviewWizard:function(s){function r(){return{x:u.getComputedSize().width,y:u.getComputedSize().height}}function e(){var e=r(),t=u.getComputedSize();c.setStyles({top:t.computedTop+(g.y.get("value")*e.y).round()+"px",left:t.computedLeft+(g.x.get("value")*e.x).round()+"px",width:(g.width.get("value")*e.x).round()+"px",height:(g.height.get("value")*e.y).round()+"px"}),g.width.get("value").toFloat()&&g.height.get("value").toFloat()?c.setStyle("display",null):c.setStyle("display","none")}function t(e){e.preventDefault(),f||(f=!0,d={x:e.page.x-s.getPosition().x-u.getComputedSize().computedLeft,y:e.page.y-s.getPosition().y-u.getComputedSize().computedTop},a(e))}function n(e){a(e),f=!1}var c,d,u=(s=$(s)).getElement("img"),g={},f=!1,a=function(e){if(f){e.preventDefault();var t,n,a,o,i=u.getComputedSize(),l={x:[Math.max(0,Math.min(i.width,d.x)),Math.max(0,Math.min(i.width,e.page.x-s.getPosition().x-i.computedLeft))],y:[Math.max(0,Math.min(i.height,d.y)),Math.max(0,Math.min(i.height,e.page.y-s.getPosition().y-i.computedTop))]};c.setStyles({top:Math.min(l.y[0],l.y[1])+i.computedTop+"px",left:Math.min(l.x[0],l.x[1])+i.computedLeft+"px",width:Math.abs(l.x[0]-l.x[1])+"px",height:Math.abs(l.y[0]-l.y[1])+"px"}),t=r(),n=c.getStyles("top","left","width","height"),a=u.getComputedSize(),(o={x:Math.max(0,Math.min(1,(n.left.toFloat()-a.computedLeft)/t.x)),y:Math.max(0,Math.min(1,(n.top.toFloat()-a.computedTop)/t.y))}).width=Math.min(1-o.x,n.width.toFloat()/t.x),o.height=Math.min(1-o.y,n.height.toFloat()/t.y),o.width&&o.height?c.setStyle("display",null):(o.x=o.y=o.width=o.height="",c.setStyle("display","none")),Object.each(o,function(e,t){g[t].set("value",""===e?"":Number(e).toFixed(15))})}};window.addEvent("domready",function(){s.getParent(".tl_tbox,.tl_box").getElements('input[name^="importantPart"]').each(function(t){["x","y","width","height"].each(function(e){t.get("name").substr(13,e.length)===e.capitalize()&&(g[e]=t=$(t))})}),4===Object.getLength(g)&&(Object.each(g,function(e){e.getParent().setStyle("display","none")}),s.addClass("tl_edit_preview_enabled"),c=new Element("div",{class:"tl_edit_preview_important_part"}).inject(s),e(),u.addEvent("load",e),s.addEvents({mousedown:t,touchstart:t}),$(document.documentElement).addEvents({mousemove:a,touchmove:a,mouseup:n,touchend:n,touchcancel:n,resize:e}))})},enableFileTreeUpload:function(i,e){i=$(i);var l,s,r=e.url,t=new Element("div",{class:"dropzone dropzone-filetree",html:'<span class="dropzone-previews"></span>'}).inject(i,"top");e.previewsContainer=t.getElement(".dropzone-previews"),e.clickable=!1;var c=new Dropzone(i,e);c.on("queuecomplete",function(){window.location.reload()}),c.on("dragover",function(e){if(e.dataTransfer&&e.dataTransfer.types&&-1!==e.dataTransfer.types.indexOf("Files")){i.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping");var t=e.target&&$(e.target);if(t){var n=t.match(".tl_folder")?t:t.getParent(".tl_folder");if(n=n||(n=t.getParent(".parent"))&&n.getPrevious(".tl_folder")){var a=n.getElement('img[src$="/icons/new.svg"]');a=a&&a.getParent("a")}}if(a&&a.href){if(c.options.url=""+a.href,n.addClass("tl_folder_dropping"),l!==n){l=n,s=(new Date).getTime();var o=n.getElement('img[src$="/icons/folPlus.svg"]');(o=o&&o.getParent("a"))&&setTimeout(function(){if(l===n&&s+900<(new Date).getTime()){var e=document.createEvent("HTMLEvents");e.initEvent("click",!0,!0),o.dispatchEvent(e),s=l=void 0}},1e3)}}else c.options.url=r,s=l=void 0}}),c.on("drop",function(e){e.dataTransfer&&e.dataTransfer.types&&-1!==e.dataTransfer.types.indexOf("Files")&&(t.addClass("dropzone-filetree-enabled"),Backend.getScrollOffset())}),c.on("dragleave",function(){i.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping"),s=l=void 0})},crawl:function(){var a=2e3,e=$("tl_crawl"),c=e.getElement("div.progress-bar"),d=e.getElement("p.progress-count"),u=e.getElement("div.results");!function n(e){e=e||!1;new Request({url:window.location.href,headers:{"Only-Status-Update":e},onSuccess:function(e){var t=JSON.decode(e);!function(e){var t,n=e.total-e.pending,a=0<e.total?parseInt(n/e.total*100,10):100;if(c.setStyle("width",a+"%"),c.set("html",a+"%"),c.setAttribute("aria-valuenow",a),d.set("html",n+" / "+e.total),e.finished)for(t in c.removeClass("running").addClass("finished"),u.removeClass("running").addClass("finished"),e.results)if(e.results.hasOwnProperty(t)){var o=u.getElement('.result[data-subscriber="'+t+'"] p.summary'),i=u.getElement('.result[data-subscriber="'+t+'"] p.warning'),l=u.getElement('.result[data-subscriber="'+t+'"] p.subscriber-log'),s=e.results[t],r=s.summary;s.warning&&i.set("html",s.warning),s.hasLog&&l.setStyle("display","block"),o.addClass(s.wasSuccessful?"success":"failure"),o.set("html",r)}}(t),t.finished||setTimeout(n,a)}}).send()}(!0)}};document.addEvent("mousedown",function(e){Backend.getMousePosition(e)}),window.addEvent("domready",function(){$(document.body).addClass("js"),Browser.Features.Touch&&$(document.body).addClass("touch"),Backend.collapsePalettes(),Backend.addInteractiveHelp(),Backend.tableWizardSetWidth(),Backend.enableImageSizeWidgets(),Backend.enableToggleSelect(),Backend.autoFocusFirstInputField(),null!=Elements.chosen&&$$("select.tl_chosen").chosen(),$$("textarea.monospace").each(function(e){Backend.toggleWrap(e)})}),window.addEvent("resize",function(){Backend.tableWizardSetWidth()}),window.addEvent("load",function(){Backend.limitPreviewHeight()}),window.addEvent("ajax_change",function(){Backend.addInteractiveHelp(),Backend.enableImageSizeWidgets(),Backend.enableToggleSelect(),null!=Elements.chosen&&$$("select.tl_chosen").filter(function(e){return"none"!=e.getStyle("display")}).chosen()});
\ No newline at end of file
diff --git a/core-bundle/src/Resources/public/mootao.js b/core-bundle/src/Resources/public/mootao.js
index ab86763ab4f..9f75157ae28 100644
--- a/core-bundle/src/Resources/public/mootao.js
+++ b/core-bundle/src/Resources/public/mootao.js
@@ -177,10 +177,15 @@ Tips.Contao = new Class(
 
 		this.fireEvent('bound', bounds);
 		this.tip.setStyles(obj);
 	},
 
+	fill: function(element, contents){
+		if (typeof contents == 'string') element.set(element.hasClass('tip-text') ? 'html' : 'text', contents);
+		else element.adopt(contents);
+	},
+
 	hide: function(element) {
 		if (!this.tip) document.id(this);
 		this.fireEvent('hide', [this.tip, element]);
 	}
 });
diff --git a/core-bundle/src/Resources/public/mootao.min.js b/core-bundle/src/Resources/public/mootao.min.js
index f7bc164e674..77795e221a4 100644
--- a/core-bundle/src/Resources/public/mootao.min.js
+++ b/core-bundle/src/Resources/public/mootao.min.js
@@ -1 +1 @@
-Request.Contao=new Class({Extends:Request.JSON,options:{followRedirects:!0,url:window.location.href},initialize:function(t){t&&!t.url&&t.field&&t.field.form&&t.field.form.action&&(this.options.url=t.field.form.action),this.parent(t)},success:function(e){var i,t=this.getHeader("X-Ajax-Location");if(t&&this.options.followRedirects)location.replace(t);else{try{i=this.response.json=JSON.decode(e,this.options.secure)}catch(t){i={content:e}}null===i?i={content:""}:"object"!=typeof i&&(i={content:e}),""!=i.content&&(i.content=i.content.stripScripts(function(t){i.javascript=t.replace(/<!--|\/\/-->|<!\[CDATA\[\/\/>|<!]]>/g,"")}),i.javascript&&this.options.evalScripts&&Browser.exec(i.javascript)),this.onSuccess(i.content,i)}},failure:function(){var t=this.getHeader("X-Ajax-Location");t&&401===this.status||t&&this.options.followRedirects&&300<=this.status&&this.status<400?location.replace(t):this.onFailure()}}),Request.Mixed=Request.Contao,Tips.Contao=new Class({Extends:Tips,options:{id:"tip",onShow:function(){var t=this.tip.getElement("div.tip-title"),e=this.tip.getElement("div.tip-text");(t&&t.innerHTML||e&&e.innerHTML)&&this.tip.setStyle("display","block")},onHide:function(){this.tip.setStyle("display","none")},title:"title",text:"",showDelay:1e3,hideDelay:100,className:"tip-wrap",offset:{x:16,y:16},windowPadding:{x:0,y:0},fixed:!0,waiAria:!0},position:function(t){this.tip||document.id(this);var e=window.getSize(),i=window.getScroll(),s={x:this.tip.offsetWidth,y:this.tip.offsetHeight},n={x:"left",y:"top"},o={y:!1,x2:!1,y2:!1,x:!1},a={};for(var r in n)a[n[r]]=t.page[r]+this.options.offset[r],a[n[r]]<0&&(o[r]=!0),a[n[r]]+s[r]-i[r]>e[r]-this.options.windowPadding[r]&&("x"==r&&(a[n[r]]=t.page[r]-this.options.offset[r]-s[r]),o[r+"2"]=!0);var h=this.tip.getElement("div.tip-top");o.x2?(a.left+=24,h.setStyles({left:"auto",right:"9px"})):(a.left-=9,h.setStyles({left:"9px",right:"auto"})),this.fireEvent("bound",o),this.tip.setStyles(a)},hide:function(t){this.tip||document.id(this),this.fireEvent("hide",[this.tip,t])}}),Class.refactor(Drag,{attach:function(){return this.handles.addEvent("touchstart",this.bound.start),this.previous.apply(this,arguments)},detach:function(){return this.handles.removeEvent("touchstart",this.bound.start),this.previous.apply(this,arguments)},start:function(){document.addEvents({touchmove:this.bound.check,touchend:this.bound.cancel}),this.previous.apply(this,arguments)},check:function(t){this.options.preventDefault&&t.preventDefault(),Math.round(Math.sqrt(Math.pow(t.page.x-this.mouse.start.x,2)+Math.pow(t.page.y-this.mouse.start.y,2)))>this.options.snap&&(this.cancel(),this.document.addEvents({mousemove:this.bound.drag,mouseup:this.bound.stop}),document.addEvents({touchmove:this.bound.drag,touchend:this.bound.stop}),this.fireEvent("start",[this.element,t]).fireEvent("snap",this.element))},cancel:function(){return document.removeEvents({touchmove:this.bound.check,touchend:this.bound.cancel}),this.previous.apply(this,arguments)},stop:function(){return document.removeEvents({touchmove:this.bound.drag,touchend:this.bound.stop}),this.previous.apply(this,arguments)}}),Class.refactor(Sortables,{initialize:function(t,e){return e.dragOptions=Object.merge(e.dragOptions||{},{preventDefault:e.dragOptions&&e.dragOptions.preventDefault||Browser.Features.Touch}),void 0===e.dragOptions.unDraggableTags&&(e.dragOptions.unDraggableTags=this.options.unDraggableTags.filter(function(t){return"button"!=t})),this.previous.apply(this,arguments)},addItems:function(){return Array.flatten(arguments).each(function(e){this.elements.push(e);var t=e.retrieve("sortables:start",function(t){this.start.call(this,t,e)}.bind(this));(this.options.handle&&e.getElement(this.options.handle)||e).addEvents({mousedown:t,touchstart:t})},this),this},removeItems:function(){return $$(Array.flatten(arguments).map(function(t){this.elements.erase(t);var e=t.retrieve("sortables:start");return(this.options.handle&&t.getElement(this.options.handle)||t).removeEvents({mousedown:e,touchend:e}),t},this))},getClone:function(t,e){if(!this.options.clone)return new Element(e.tagName).inject(document.body);if("function"==typeOf(this.options.clone))return this.options.clone.call(this,t,e,this.list);var i=this.previous.apply(this,arguments);return i.addEvent("touchstart",function(t){e.fireEvent("touchstart",t)}),i}}),Class.refactor(Request.Queue,{onComplete:function(){this.fireEvent("complete",arguments)},onCancel:function(){this.options.autoAdvance&&!this.error&&this.resume(),this.fireEvent("cancel",arguments)},onSuccess:function(){this.options.autoAdvance&&!this.error&&this.resume(),this.fireEvent("success",arguments),this.queue.length||this.isRunning()||this.fireEvent("end")},onFailure:function(){this.error=!0,!this.options.stopOnFailure&&this.options.autoAdvance&&this.resume(),this.fireEvent("failure",arguments),this.queue.length||this.isRunning()||this.fireEvent("end")},onException:function(){this.error=!0,!this.options.stopOnFailure&&this.options.autoAdvance&&this.resume(),this.fireEvent("exception",arguments)}}),Contao.SerpPreview=new Class({options:{id:0,trail:null,titleField:null,titleFallbackField:null,aliasField:null,descriptionField:null,descriptionFallbackField:null,titleTag:null},shorten:function(t,e){return t.length<=e?t:t.substr(0,t.lastIndexOf(" ",e))+" …"},html2string:function(t){return(new DOMParser).parseFromString(t,"text/html").body.textContent},getTinymce:function(){if(window.tinyMCE&&this.options.descriptionFallbackField)return window.tinyMCE.get(this.options.descriptionFallbackField)},initialize:function(){this.options=Object.merge.apply(null,[{},this.options].append(arguments));var t=$("serp_title_"+this.options.id),e=$("serp_url_"+this.options.id),i=$("serp_description_"+this.options.id),s=$(this.options.titleField),n=$(this.options.titleFallbackField),o=$(this.options.aliasField),a=$(this.options.descriptionField),r=$(this.options.descriptionFallbackField),h=-1===this.options.trail.indexOf("›"),l=this.options.titleTag||"%s";s&&s.addEvent("input",function(){s.value?t.set("text",this.shorten(l.replace(/%s/,s.value).replace(/%%/g,"%"),64)):n&&n.value?t.set("text",this.shorten(this.html2string(l.replace(/%s/,n.value)).replace(/%%/g,"%"),64)):t.set("text","")}.bind(this)),n&&n.addEvent("input",function(){s&&s.value||t.set("text",this.shorten(this.html2string(l.replace(/%s/,n.value)).replace(/%%/g,"%"),64))}.bind(this)),o&&o.addEvent("input",function(){"index"==o.value&&h?e.set("text",this.options.trail):e.set("text",this.options.trail+" › "+(o.value||this.options.id).replace(/\//g," › "))}.bind(this)),a&&a.addEvent("input",function(){if(a.value)i.set("text",this.shorten(a.value,160));else{var t=this.getTinymce();t?i.set("text",this.shorten(this.html2string(t.getContent()),160)):r&&r.value?i.set("text",this.shorten(this.html2string(r.value),160)):i.set("text","")}}.bind(this)),r&&r.addEvent("input",function(){a&&a.value||i.set("text",this.shorten(this.html2string(r.value),160))}.bind(this)),setTimeout(function(){var t=this.getTinymce();t&&t.on("keyup",function(){a&&a.value||i.set("text",this.shorten(this.html2string(window.tinyMCE.activeEditor.getContent()),160))}.bind(this))}.bind(this),4)}});
\ No newline at end of file
+Request.Contao=new Class({Extends:Request.JSON,options:{followRedirects:!0,url:window.location.href},initialize:function(t){t&&!t.url&&t.field&&t.field.form&&t.field.form.action&&(this.options.url=t.field.form.action),this.parent(t)},success:function(e){var i,t=this.getHeader("X-Ajax-Location");if(t&&this.options.followRedirects)location.replace(t);else{try{i=this.response.json=JSON.decode(e,this.options.secure)}catch(t){i={content:e}}null===i?i={content:""}:"object"!=typeof i&&(i={content:e}),""!=i.content&&(i.content=i.content.stripScripts(function(t){i.javascript=t.replace(/<!--|\/\/-->|<!\[CDATA\[\/\/>|<!]]>/g,"")}),i.javascript&&this.options.evalScripts&&Browser.exec(i.javascript)),this.onSuccess(i.content,i)}},failure:function(){var t=this.getHeader("X-Ajax-Location");t&&401===this.status||t&&this.options.followRedirects&&300<=this.status&&this.status<400?location.replace(t):this.onFailure()}}),Request.Mixed=Request.Contao,Tips.Contao=new Class({Extends:Tips,options:{id:"tip",onShow:function(){var t=this.tip.getElement("div.tip-title"),e=this.tip.getElement("div.tip-text");(t&&t.innerHTML||e&&e.innerHTML)&&this.tip.setStyle("display","block")},onHide:function(){this.tip.setStyle("display","none")},title:"title",text:"",showDelay:1e3,hideDelay:100,className:"tip-wrap",offset:{x:16,y:16},windowPadding:{x:0,y:0},fixed:!0,waiAria:!0},position:function(t){this.tip||document.id(this);var e=window.getSize(),i=window.getScroll(),s={x:this.tip.offsetWidth,y:this.tip.offsetHeight},n={x:"left",y:"top"},o={y:!1,x2:!1,y2:!1,x:!1},a={};for(var r in n)a[n[r]]=t.page[r]+this.options.offset[r],a[n[r]]<0&&(o[r]=!0),a[n[r]]+s[r]-i[r]>e[r]-this.options.windowPadding[r]&&("x"==r&&(a[n[r]]=t.page[r]-this.options.offset[r]-s[r]),o[r+"2"]=!0);var h=this.tip.getElement("div.tip-top");o.x2?(a.left+=24,h.setStyles({left:"auto",right:"9px"})):(a.left-=9,h.setStyles({left:"9px",right:"auto"})),this.fireEvent("bound",o),this.tip.setStyles(a)},fill:function(t,e){"string"==typeof e?t.set(t.hasClass("tip-text")?"html":"text",e):t.adopt(e)},hide:function(t){this.tip||document.id(this),this.fireEvent("hide",[this.tip,t])}}),Class.refactor(Drag,{attach:function(){return this.handles.addEvent("touchstart",this.bound.start),this.previous.apply(this,arguments)},detach:function(){return this.handles.removeEvent("touchstart",this.bound.start),this.previous.apply(this,arguments)},start:function(){document.addEvents({touchmove:this.bound.check,touchend:this.bound.cancel}),this.previous.apply(this,arguments)},check:function(t){this.options.preventDefault&&t.preventDefault(),Math.round(Math.sqrt(Math.pow(t.page.x-this.mouse.start.x,2)+Math.pow(t.page.y-this.mouse.start.y,2)))>this.options.snap&&(this.cancel(),this.document.addEvents({mousemove:this.bound.drag,mouseup:this.bound.stop}),document.addEvents({touchmove:this.bound.drag,touchend:this.bound.stop}),this.fireEvent("start",[this.element,t]).fireEvent("snap",this.element))},cancel:function(){return document.removeEvents({touchmove:this.bound.check,touchend:this.bound.cancel}),this.previous.apply(this,arguments)},stop:function(){return document.removeEvents({touchmove:this.bound.drag,touchend:this.bound.stop}),this.previous.apply(this,arguments)}}),Class.refactor(Sortables,{initialize:function(t,e){return e.dragOptions=Object.merge(e.dragOptions||{},{preventDefault:e.dragOptions&&e.dragOptions.preventDefault||Browser.Features.Touch}),void 0===e.dragOptions.unDraggableTags&&(e.dragOptions.unDraggableTags=this.options.unDraggableTags.filter(function(t){return"button"!=t})),this.previous.apply(this,arguments)},addItems:function(){return Array.flatten(arguments).each(function(e){this.elements.push(e);var t=e.retrieve("sortables:start",function(t){this.start.call(this,t,e)}.bind(this));(this.options.handle&&e.getElement(this.options.handle)||e).addEvents({mousedown:t,touchstart:t})},this),this},removeItems:function(){return $$(Array.flatten(arguments).map(function(t){this.elements.erase(t);var e=t.retrieve("sortables:start");return(this.options.handle&&t.getElement(this.options.handle)||t).removeEvents({mousedown:e,touchend:e}),t},this))},getClone:function(t,e){if(!this.options.clone)return new Element(e.tagName).inject(document.body);if("function"==typeOf(this.options.clone))return this.options.clone.call(this,t,e,this.list);var i=this.previous.apply(this,arguments);return i.addEvent("touchstart",function(t){e.fireEvent("touchstart",t)}),i}}),Class.refactor(Request.Queue,{onComplete:function(){this.fireEvent("complete",arguments)},onCancel:function(){this.options.autoAdvance&&!this.error&&this.resume(),this.fireEvent("cancel",arguments)},onSuccess:function(){this.options.autoAdvance&&!this.error&&this.resume(),this.fireEvent("success",arguments),this.queue.length||this.isRunning()||this.fireEvent("end")},onFailure:function(){this.error=!0,!this.options.stopOnFailure&&this.options.autoAdvance&&this.resume(),this.fireEvent("failure",arguments),this.queue.length||this.isRunning()||this.fireEvent("end")},onException:function(){this.error=!0,!this.options.stopOnFailure&&this.options.autoAdvance&&this.resume(),this.fireEvent("exception",arguments)}}),Contao.SerpPreview=new Class({options:{id:0,trail:null,titleField:null,titleFallbackField:null,aliasField:null,descriptionField:null,descriptionFallbackField:null,titleTag:null},shorten:function(t,e){return t.length<=e?t:t.substr(0,t.lastIndexOf(" ",e))+" …"},html2string:function(t){return(new DOMParser).parseFromString(t,"text/html").body.textContent},getTinymce:function(){if(window.tinyMCE&&this.options.descriptionFallbackField)return window.tinyMCE.get(this.options.descriptionFallbackField)},initialize:function(){this.options=Object.merge.apply(null,[{},this.options].append(arguments));var t=$("serp_title_"+this.options.id),e=$("serp_url_"+this.options.id),i=$("serp_description_"+this.options.id),s=$(this.options.titleField),n=$(this.options.titleFallbackField),o=$(this.options.aliasField),a=$(this.options.descriptionField),r=$(this.options.descriptionFallbackField),h=-1===this.options.trail.indexOf("›"),l=this.options.titleTag||"%s";s&&s.addEvent("input",function(){s.value?t.set("text",this.shorten(l.replace(/%s/,s.value).replace(/%%/g,"%"),64)):n&&n.value?t.set("text",this.shorten(this.html2string(l.replace(/%s/,n.value)).replace(/%%/g,"%"),64)):t.set("text","")}.bind(this)),n&&n.addEvent("input",function(){s&&s.value||t.set("text",this.shorten(this.html2string(l.replace(/%s/,n.value)).replace(/%%/g,"%"),64))}.bind(this)),o&&o.addEvent("input",function(){"index"==o.value&&h?e.set("text",this.options.trail):e.set("text",this.options.trail+" › "+(o.value||this.options.id).replace(/\//g," › "))}.bind(this)),a&&a.addEvent("input",function(){if(a.value)i.set("text",this.shorten(a.value,160));else{var t=this.getTinymce();t?i.set("text",this.shorten(this.html2string(t.getContent()),160)):r&&r.value?i.set("text",this.shorten(this.html2string(r.value),160)):i.set("text","")}}.bind(this)),r&&r.addEvent("input",function(){a&&a.value||i.set("text",this.shorten(this.html2string(r.value),160))}.bind(this)),setTimeout(function(){var t=this.getTinymce();t&&t.on("keyup",function(){a&&a.value||i.set("text",this.shorten(this.html2string(window.tinyMCE.activeEditor.getContent()),160))}.bind(this))}.bind(this),4)}});
\ No newline at end of file

Vulnerable code: 			$strFolderNameEncoded = StringUtil::convertEncoding(StringUtil::specialchars(basename($currentFolder)), System::getContainer()->getParameter('kernel.charset'));
			$strFileNameEncoded = StringUtil::convertEncoding(StringUtil::specialchars(basename($currentFile)), System::getContainer()->getParameter('kernel.charset'));
			'title': opt.title,
			'title': opt.title,
			'title': opt.title,
var AjaxRequest={themePath:Contao.script_url+"system/themes/"+Contao.theme+"/",toggleNavigation:function(e,t,n){var a=$(t),o=$(e).getParent("li");return a&&(o.hasClass("collapsed")?(o.removeClass("collapsed"),$(e).setAttribute("aria-expanded","true"),$(e).store("tip:title",Contao.lang.collapse),new Request.Contao({url:n}).post({action:"toggleNavigation",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(o.addClass("collapsed"),$(e).setAttribute("aria-expanded","false"),$(e).store("tip:title",Contao.lang.expand),new Request.Contao({url:n}).post({action:"toggleNavigation",id:t,state:0,REQUEST_TOKEN:Contao.request_token}))),!1},toggleStructure:function(i,l,s,r){i.blur();var e=$(l),c=$(i).getFirst("img");return e?"none"==e.getStyle("display")?(e.setStyle("display",null),c.src=AjaxRequest.themePath+"icons/folMinus.svg",$(i).store("tip:title",Contao.lang.collapse),new Request.Contao({field:i}).post({action:"toggleStructure",id:l,state:1,REQUEST_TOKEN:Contao.request_token})):(e.setStyle("display","none"),c.src=AjaxRequest.themePath+"icons/folPlus.svg",$(i).store("tip:title",Contao.lang.expand),new Request.Contao({field:i}).post({action:"toggleStructure",id:l,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:i,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:l,class:"parent",styles:{display:"inline"}});if(new Element("ul",{class:"level_"+s,html:e}).inject(t,"bottom"),5==r)t.inject($(i).getParent("li"),"after");else{for(var n,a=!1,o=$(i).getParent("li");"element"==typeOf(o)&&(n=o.getNext("li"));)if((o=n).hasClass("tl_folder")){a=!0;break}a?t.inject(o,"before"):t.inject(o,"after")}t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(i).store("tip:title",Contao.lang.collapse),c.src=AjaxRequest.themePath+"icons/folMinus.svg",window.fireEvent("structure"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadStructure",id:l,level:s,state:1,REQUEST_TOKEN:Contao.request_token}),!1},toggleFileManager:function(n,a,e,o){n.blur();var t=$(a),i=$(n).getFirst("img");return t?"none"==t.getStyle("display")?(t.setStyle("display",null),i.src=AjaxRequest.themePath+"icons/folMinus.svg",$(n).store("tip:title",Contao.lang.collapse),new Request.Contao({field:n}).post({action:"toggleFileManager",id:a,state:1,REQUEST_TOKEN:Contao.request_token})):(t.setStyle("display","none"),i.src=AjaxRequest.themePath+"icons/folPlus.svg",$(n).store("tip:title",Contao.lang.expand),new Request.Contao({field:n}).post({action:"toggleFileManager",id:a,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:n,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:a,class:"parent",styles:{display:"inline"}});new Element("ul",{class:"level_"+o,html:e}).inject(t,"bottom"),t.inject($(n).getParent("li"),"after"),t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(n).store("tip:title",Contao.lang.collapse),i.src=AjaxRequest.themePath+"icons/folMinus.svg",AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadFileManager",id:a,level:o,folder:e,state:1,REQUEST_TOKEN:Contao.request_token}),!1},togglePagetree:function(n,a,e,t,o){n.blur(),Backend.getScrollOffset();var i=$(a),l=$(n).getFirst("img");return i?"none"==i.getStyle("display")?(i.setStyle("display",null),l.src=AjaxRequest.themePath+"icons/folMinus.svg",$(n).store("tip:title",Contao.lang.collapse),new Request.Contao({field:n}).post({action:"togglePagetree",id:a,state:1,REQUEST_TOKEN:Contao.request_token})):(i.setStyle("display","none"),l.src=AjaxRequest.themePath+"icons/folPlus.svg",$(n).store("tip:title",Contao.lang.expand),new Request.Contao({field:n}).post({action:"togglePagetree",id:a,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:n,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:a,class:"parent",styles:{display:"inline"}});new Element("ul",{class:"level_"+o,html:e}).inject(t,"bottom"),t.inject($(n).getParent("li"),"after"),t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(n).store("tip:title",Contao.lang.collapse),l.src=AjaxRequest.themePath+"icons/folMinus.svg",AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadPagetree",id:a,level:o,field:e,name:t,state:1,REQUEST_TOKEN:Contao.request_token}),!1},toggleFiletree:function(n,a,e,t,o,i){n.blur(),Backend.getScrollOffset();var l=$(a),s=$(n).getFirst("img");return l?"none"==l.getStyle("display")?(l.setStyle("display",null),s.src=AjaxRequest.themePath+"icons/folMinus.svg",$(n).store("tip:title",Contao.lang.collapse),new Request.Contao({field:n}).post({action:"toggleFiletree",id:a,state:1,REQUEST_TOKEN:Contao.request_token})):(l.setStyle("display","none"),s.src=AjaxRequest.themePath+"icons/folPlus.svg",$(n).store("tip:title",Contao.lang.expand),new Request.Contao({field:n}).post({action:"toggleFiletree",id:a,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:n,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:a,class:"parent",styles:{display:"inline"}});new Element("ul",{class:"level_"+i,html:e}).inject(t,"bottom"),t.inject($(n).getParent("li"),"after"),t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(n).store("tip:title",Contao.lang.collapse),s.src=AjaxRequest.themePath+"icons/folMinus.svg",AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadFiletree",id:a,folder:e,level:i,field:t,name:o,state:1,REQUEST_TOKEN:Contao.request_token}),!1},toggleSubpalette:function(a,o,e){a.blur();var t=$(o);function i(e){a.form.elements.VERSION_NUMBER&&(a.form.elements.VERSION_NUMBER.value=/<input\s+[^>]*?name="VERSION_NUMBER"\s+[^>]*?value="([^"]*)"/i.exec(e)[1])}t?a.value?(a.value="",a.checked="",t.setStyle("display","none"),t.getElements("[required]").each(function(e){e.set("required",null).set("data-required","")}),new Request.Contao({field:a,onSuccess:i}).post({action:"toggleSubpalette",id:o,field:e,state:0,REQUEST_TOKEN:Contao.request_token})):(a.value=1,a.checked="checked",t.setStyle("display",null),t.getElements("[data-required]").each(function(e){e.set("required","").set("data-required",null)}),new Request.Contao({field:a,onSuccess:i}).post({action:"toggleSubpalette",id:o,field:e,state:1,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:a,evalScripts:!1,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e,t){var n=new Element("div",{id:o,class:"subpal cf",html:e,styles:{display:"block"}}).inject($(a).getParent("div").getParent("div"),"after");t.javascript&&(document.write=function(e){var n="";e.replace(/<script src="([^"]+)"/i,function(e,t){n=t}),n&&Asset.javascript(n,{onLoad:function(){Browser.exec(t.javascript)}})},Browser.exec(t.javascript)),a.value=1,a.checked="checked",n.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),i(e),AjaxRequest.hideBox(),window.fireEvent("subpalette"),window.fireEvent("ajax_change")}}).post({action:"toggleSubpalette",id:o,field:e,load:1,state:1,REQUEST_TOKEN:Contao.request_token})},toggleField:function(e,t){e.blur();var n,a,o=null,i=$(e).getFirst("img"),l=1==i.get("data-state"),s=e.getParent("div");return t&&(s.hasClass("tl_right")?o=s.getPrevious("div").getElement("img"):s.hasClass("tl_listing_container")?(null===(o=e.getParent("td").getPrevious("td").getFirst("div.list_icon"))&&(o=e.getParent("td").getPrevious("td").getElement("div.cte_type")),null===o&&(o=e.getParent("tr").getFirst("td").getElement("div.list_icon_new"))):(n=s.getNext("div"))&&(n.hasClass("cte_type")&&(o=n),null===o&&(o=n.getFirst("div.list_icon"))),null!==o&&("img"==o.nodeName.toLowerCase()?(o.getParent("ul.tl_listing").hasClass("tl_tree_xtnd")||(a=o.getParent("a"))&&-1==a.href.indexOf("contao/preview")&&(o=(n=a.getNext("a"))?n.getFirst("img"):new Element("img")),o.src=l?o.get("data-icon-disabled"):o.get("data-icon")):o.hasClass("cte_type")?l?(o.addClass("unpublished"),o.removeClass("published")):(o.addClass("published"),o.removeClass("unpublished")):o.setStyle("background-image","url("+(l?o.get("data-icon-disabled"):o.get("data-icon"))+")"))),i.src=l?i.get("data-icon-disabled"):i.get("data-icon"),i.set("data-state",l?0:1),new Request.Contao({url:e.href,followRedirects:!1}).get(),!1},toggleVisibility:function(e,t,n){window.console&&console.warn("AjaxRequest.toggleVisibility() is deprecated. Please use the new toggle operation."),e.blur();var a,o,i,l,s,r,c=null,d=$(e).getFirst("img"),u=1==d.get("data-state"),g=e.getParent("div");return null===d.get("data-state")&&(u=-1==d.src.indexOf("invisible"),window.console&&console.warn('Using a visibility toggle without a "data-state" attribute is deprecated. Please adjust your Contao DCA file.')),g.hasClass("tl_right")?c=g.getPrevious("div").getElement("img"):g.hasClass("tl_listing_container")?(null===(c=e.getParent("td").getPrevious("td").getFirst("div.list_icon"))&&(c=e.getParent("td").getPrevious("td").getElement("div.cte_type")),null===c&&(c=e.getParent("tr").getFirst("td").getElement("div.list_icon_new"))):(o=g.getNext("div"))&&(o.hasClass("cte_type")&&(c=o),null===c&&(c=o.getFirst("div.list_icon"))),null!==c&&("img"==c.nodeName.toLowerCase()?(c.getParent("ul.tl_listing").hasClass("tl_tree_xtnd")?(i=c.get("data-icon"),l=c.get("data-icon-disabled"),null===i&&(i=c.src.replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)$/,"$1/$2.$3"),window.console&&console.warn('Using a row icon without a "data-icon" attribute is deprecated. Please adjust your Contao DCA file.')),null===l&&(l=c.src.replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)$/,"$1/$2_.$3"),window.console&&console.warn('Using a row icon without a "data-icon-disabled" attribute is deprecated. Please adjust your Contao DCA file.'))):((s=c.getParent("a"))&&-1==s.href.indexOf("contao/preview")&&(c=(o=s.getNext("a"))?o.getFirst("img"):new Element("img")),i=c.get("data-icon"),l=c.get("data-icon-disabled"),null===i&&(a=c.src.replace(/.*_([0-9])\.(gif|png|jpe?g|svg)/,"$1"),i=c.src.replace(/_[0-9]\.(gif|png|jpe?g|svg)/,(1==a.toInt()?"":"_"+(a.toInt()-1))+".$1").split(/[\\/]/).pop(),window.console&&console.warn('Using a row icon without a "data-icon" attribute is deprecated. Please adjust your Contao DCA file.')),null===l&&(a=c.src.replace(/.*_([0-9])\.(gif|png|jpe?g|svg)/,"$1"),l=c.src.replace(/(_[0-9])?\.(gif|png|jpe?g|svg)/,(a==c.src?"_1":"_"+(a.toInt()+1))+".$2").split(/[\\/]/).pop(),window.console&&console.warn('Using a row icon without a "data-icon-disabled" attribute is deprecated. Please adjust your Contao DCA file.'))),-1==i.indexOf("/")&&(i=AjaxRequest.themePath+(i.match(/\.svg$/)?"icons/":"images/")+i),-1==l.indexOf("/")&&(l=AjaxRequest.themePath+(l.match(/\.svg$/)?"icons/":"images/")+l),c.src=u?l:i):c.hasClass("cte_type")?u?(c.addClass("unpublished"),c.removeClass("published")):(c.addClass("published"),c.removeClass("unpublished")):(i=c.get("data-icon"),l=c.get("data-icon-disabled"),null===i&&(i=c.getStyle("background-image").replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)\);?$/,"$1/$2.$2"),window.console&&console.warn('Using a row icon without a "data-icon" attribute is deprecated. Please adjust your Contao DCA file.')),null===l&&(l=c.getStyle("background-image").replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)\);?$/,"$1/$2_.$3"),window.console&&console.warn('Using a row icon without a "data-icon-disabled" attribute is deprecated. Please adjust your Contao DCA file.')),-1==i.indexOf("/")&&(i=AjaxRequest.themePath+(i.match(/\.svg$/)?"icons/":"images/")+i),-1==l.indexOf("/")&&(l=AjaxRequest.themePath+(l.match(/\.svg$/)?"icons/":"images/")+l),c.setStyle("background-image","url("+(u?l:i)+")"))),"tl_style"==n&&g.getParent("div").getElement("pre").toggleClass("disabled"),i=d.get("data-icon")||AjaxRequest.themePath+"icons/visible.svg",l=d.get("data-icon-disabled")||AjaxRequest.themePath+"icons/invisible.svg",-1!==e.href.indexOf("act=toggle")?(d.src=u?l:i,d.set("data-state",u?0:1),new Request.Contao({url:e.href,followRedirects:!1}).get()):(d.src=u?l:i,d.set("data-state",u?0:1),(r={state:u?0:1,rt:Contao.request_token})[$(e).get("data-tid")||"tid"]=t,new Request.Contao({url:window.location.href,followRedirects:!1}).get(r)),!1},toggleFeatured:function(e,t){window.console&&console.warn("AjaxRequest.toggleFeatured() is deprecated. Please use the new toggle operation."),e.blur();var n=$(e).getFirst("img"),a=1==n.get("data-state");return null===n.get("data-state")&&(a=-1==n.src.indexOf("featured_"),window.console&&console.warn('Using a featured toggle without a "data-state" attribute is deprecated. Please adjust your Contao DCA file.')),a?(n.src=AjaxRequest.themePath+"icons/featured_.svg",n.set("data-state",0),(new Request.Contao).post({action:"toggleFeatured",id:t,state:0,REQUEST_TOKEN:Contao.request_token})):(n.src=AjaxRequest.themePath+"icons/featured.svg",n.set("data-state",1),(new Request.Contao).post({action:"toggleFeatured",id:t,state:1,REQUEST_TOKEN:Contao.request_token})),!1},toggleFieldset:function(e,t,n){e.blur(),Backend.getScrollOffset();var a=$("pal_"+t);if(a.hasClass("collapsed"))a.removeClass("collapsed"),(new Request.Contao).post({action:"toggleFieldset",id:t,table:n,state:1,REQUEST_TOKEN:Contao.request_token});else{for(var o=a.getParent("form"),i=a.getElements("[required]"),l=!0,s=0;s<i.length;s++)if(!i[s].get("value")){l=!1;break}l?(a.addClass("collapsed"),(new Request.Contao).post({action:"toggleFieldset",id:t,table:n,state:0,REQUEST_TOKEN:Contao.request_token})):"function"==typeof o.checkValidity&&o.getElement('button[type="submit"]').click()}return!1},toggleCheckboxGroup:function(e,t){e.blur();var n=$(t),a=$(e).getFirst("img");return!!n&&("none"==n.getStyle("display")?(n.setStyle("display",null),a.src=AjaxRequest.themePath+"icons/folMinus.svg",(new Request.Contao).post({action:"toggleCheckboxGroup",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(n.setStyle("display","none"),a.src=AjaxRequest.themePath+"icons/folPlus.svg",(new Request.Contao).post({action:"toggleCheckboxGroup",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!0)},displayBox:function(e){var t=$("tl_ajaxBox"),n=$("tl_ajaxOverlay"),a=window.getScroll();null===n&&(n=new Element("div",{id:"tl_ajaxOverlay"}).inject($(document.body),"bottom")),n.set({styles:{display:"block",top:a.y+"px"}}),null===t&&(t=new Element("div",{id:"tl_ajaxBox"}).inject($(document.body),"bottom")),t.set({html:e,styles:{display:"block",top:a.y+100+"px"}})},hideBox:function(){var e=$("tl_ajaxBox"),t=$("tl_ajaxOverlay");t&&t.setStyle("display","none"),e&&e.setStyle("display","none")}},Backend={currentId:null,xMousePosition:0,yMousePosition:0,popupWindow:null,themePath:Contao.script_url+"system/themes/"+Contao.theme+"/",getMousePosition:function(e){Backend.xMousePosition=e.client.x,Backend.yMousePosition=e.client.y},openWindow:function(e,t,n){e.blur(),t=Browser.ie?t+40:t+17,n=Browser.ie?n+30:n+17,Backend.popupWindow=window.open(e.href,"","width="+t+",height="+n+",modal=yes,left=100,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no")},openModalWindow:function(e,t,n){new SimpleModal({width:e,hideFooter:!0,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}}).show({title:t,contents:n})},openModalImage:function(e){var t=e||{},n=(window.getSize().x-20).toInt();(!t.width||t.width>n)&&(t.width=Math.min(n,900)),new SimpleModal({width:t.width,hideFooter:!0,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}}).show({title:t.title,contents:'<img src="'+t.url+'" alt="">'})},openModalIframe:function(e){var t=e||{},n=(window.getSize().x-20).toInt(),a=(window.getSize().y-137).toInt();(!t.width||t.width>n)&&(t.width=Math.min(n,900)),(!t.height||t.height>a)&&(t.height=a),new SimpleModal({width:t.width,hideFooter:!0,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}}).show({title:t.title,contents:'<iframe src="'+t.url+'" width="100%" height="'+t.height+'" frameborder="0"></iframe>',model:"modal"})},openModalSelector:function(e){var d=e||{},t=(window.getSize().x-20).toInt(),n=(window.getSize().y-192).toInt();d.id||(d.id="tl_select"),(!d.width||d.width>t)&&(d.width=Math.min(t,900)),(!d.height||d.height>n)&&(d.height=n);var a=new SimpleModal({width:d.width,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}});a.addButton(Contao.lang.cancel,"btn",function(){this.buttons[0].hasClass("btn-disabled")||this.hide()}),a.addButton(Contao.lang.apply,"btn primary",function(){if(!this.buttons[1].hasClass("btn-disabled")){var e,t,n,a,o,i,l,s,r=window.frames["simple-modal-iframe"],c=[];if(void 0!==r){for((l=(e=r.document.getElementById(d.id)).get("data-picker-value"))&&(c=JSON.parse(l)),t=e.getElementsByTagName("input"),i=0;i<t.length;i++)t[i].id.match(/^(check_all_|reset_)/)||(s=c.indexOf(t[i].get("value")),t[i].checked?-1==s&&c.push(t[i].get("value")):-1!=s&&c.splice(s,1));d.callback?d.callback(e.get("data-table"),c):d.tag&&(n=$(d.tag))?(window.console&&console.warn("Using the modal selector without a callback function is deprecated. Please adjust your Contao DCA file."),n.value=c.join(","),(o=e.get("data-inserttag"))&&(n.value="{{"+o+"::"+n.value+"}}"),d.self.set("href",d.self.get("href").replace(/&value=[^&]*/,"&value="+c.join(",")))):d.id&&(n=$("ctrl_"+d.id))&&(a=e.get("data-callback"))&&(window.console&&console.warn("Using the modal selector without a callback function is deprecated. Please adjust your Contao DCA file."),n.value=c.join("\t"),new Request.Contao({field:n,evalScripts:!1,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e,t){$("ctrl_"+d.id).getParent("div").set("html",t.content),t.javascript&&Browser.exec(t.javascript),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:a,name:d.id,value:n.value,REQUEST_TOKEN:Contao.request_token})),this.hide()}else alert("Could not find the SimpleModal frame")}}),a.show({title:d.title,contents:'<iframe src="'+d.url+'" name="simple-modal-iframe" width="100%" height="'+d.height+'" frameborder="0"></iframe>',model:"modal"})},openModalBrowser:function(n,e,t,a,o){Backend.openModalSelector({id:"tl_listing",title:a.document.getElement("div.mce-title").get("text"),url:Contao.routes.backend_picker+"?context="+("file"==t?"link":"file")+"&amp;extras[fieldType]=radio&amp;extras[filesOnly]=true&amp;extras[source]="+o+"&amp;value="+e+"&amp;popup=1",callback:function(e,t){a.document.getElementById(n).value=t.join(",")}})},getScrollOffset:function(){window.sessionStorage.setItem("contao_backend_offset",window.getScroll().y)},initScrollOffset:function(){Cookie.dispose("BE_PAGE_OFFSET"),$$('.tl_submit_container button[name][name!="save"]').each(function(e){e.addEvent("click",function(){window.sessionStorage.removeItem("contao_backend_offset")})});var e=window.sessionStorage.getItem("contao_backend_offset");if(window.sessionStorage.removeItem("contao_backend_offset"),e){var t=window.document.getElementById("header"),i=0;t&&t.addClass("down"),$$("[data-add-to-scroll-offset]").each(function(e){var t=e.get("data-add-to-scroll-offset"),n=e.getScrollSize().y,a=!1,o=!1;t?("-"===t.charAt(0)&&(a=!0,t=t.substring(1)),"%"===t.charAt(t.length-1)&&(o=!0,t=t.substring(0,t.length-1)),t=parseInt(t,10),o&&(t=Math.round(n*t/100)),a&&(t*=-1),i+=t):i+=n}),this.vScrollTo(parseInt(e,10)+i)}},autoSubmit:function(e){Backend.getScrollOffset();var t=new Element("input",{type:"hidden",name:"SUBMIT_TYPE",value:"auto"}),n=$(e)||e;t.inject(n,"bottom"),n.submit()},vScrollTo:function(e){window.addEvent("load",function(){window.scrollTo(null,parseInt(e))})},limitPreviewHeight:function(){var l=0;$$("div.limit_height").each(function(e){var t,n,a,o,i=e.getParent(".tl_content");i&&(i.hasClass("wrapper_start")||i.hasClass("wrapper_stop"))||(0===l&&(l=e.className.replace(/[^0-9]*/,"").toInt()),l&&(t=new Element("div",{class:"limit_toggler"}),n=new Element("button",{type:"button",html:"<span>...</span>",class:"unselectable","data-state":0}).inject(t),a=e.getCoordinates(),e.setStyle("height",l),a.height<=l||(n.addEvent("click",function(){o=t.getPrevious("div").getStyle("height").toInt(),t.getPrevious("div").setStyle("height",l<o?l:""),n.set("data-state",n.get("data-state")?0:1)}),t.inject(e,"after"))))})},toggleCheckboxes:function(e,t){for(var n=$$("input"),a=$(e).checked?"checked":"",o=0;o<n.length;o++)"checkbox"==n[o].type.toLowerCase()&&(void 0!==t&&t!=n[o].id.substr(0,t.length)||(n[o].checked=a))},toggleCheckboxGroup:function(e,t){var n=$(e).className,a=$(e).checked?"checked":"";"tl_checkbox"==n?($(t)?$$("#"+t+" .tl_checkbox"):$(e).getParent("fieldset").getElements(".tl_checkbox")).each(function(e){e.checked=a}):"tl_tree_checkbox"==n&&$$("#"+t+" .parent .tl_tree_checkbox").each(function(e){e.checked=a});Backend.getScrollOffset()},toggleCheckboxElements:function(e,t){var n=$(e).checked?"checked":"";$$("."+t).each(function(e){e.hasClass("tl_checkbox")&&(e.checked=n)}),Backend.getScrollOffset()},toggleWrap:function(e){var t=$(e),n="off"==t.getProperty("wrap")?"soft":"off";t.setProperty("wrap",n)},toggleUnchanged:function(){$$("#result-list .tl_confirm").each(function(e){e.toggleClass("hidden")})},blink:function(){},addColorPicker:function(){return!0},collapsePalettes:function(){$$("fieldset.hide").each(function(e){e.addClass("collapsed")}),$$("label.error, label.mandatory").each(function(e){var t=e.getParent("fieldset");t&&t.removeClass("collapsed")})},addInteractiveHelp:function(){new Tips.Contao("p.tl_tip",{offset:{x:9,y:23},text:function(e){return e.get("html")}}),new Tips.Contao($("home"),{offset:{x:15,y:42}}),new Tips.Contao($$("#tmenu a[title]").filter(function(e){return""!=e.title}),{offset:{x:9,y:42}}),new Tips.Contao($$('a[title][class^="group-"]').filter(function(e){return""!=e.title}),{offset:{x:3,y:27}}),new Tips.Contao($$("a[title].navigation").filter(function(e){return""!=e.title}),{offset:{x:34,y:32}}),$$("img[title]").filter(function(e){return""!=e.title}).each(function(e){new Tips.Contao(e,{offset:{x:0,y:"gimage"==e.get("class")?60:30}})}),["a[title]","input[title]","button[title]","time[title]","span[title]"].each(function(e){new Tips.Contao($$(e).filter(function(e){return""!=e.title}),{offset:{x:0,y:"time[title]"==e||"span[title]"==e?26:30}})})},retrieveInteractiveHelp:function(e){e&&e.each(function(e){var t=e.retrieve("tip:title");t&&e.set("title",t)})},hideInteractiveHelp:function(){function e(){document.querySelectorAll(".tip-wrap").forEach(function(e){e.setStyle("display","none")})}e(),setTimeout(e,(new Tips.Contao).options.showDelay)},makeParentViewSortable:function(e){var t=new Scroller(document.getElement("body"),{onChange:function(e,t){this.element.scrollTo(this.element.getScroll().x,t)}}),i=new Sortables(e,{constrain:!0,opacity:.6,onStart:function(){t.start()},onComplete:function(){t.stop()},onSort:function(e){var t,n,a=e.getParent("ul"),o=0;if(a&&(t=a.getChildren("li > div:first-child")))for(n=0;n<t.length;n++)t[n].hasClass("wrapper_stop")&&0<o&&o--,t[n].className=t[n].className.replace(/(^|\s)indent[^\s]*/g,""),0<o&&t[n].addClass("indent").addClass("indent_"+o),t[n].hasClass("wrapper_start")&&o++,t[n].removeClass("indent_first"),t[n].removeClass("indent_last"),t[n-1]&&t[n-1].hasClass("wrapper_start")&&t[n].addClass("indent_first"),t[n+1]&&t[n+1].hasClass("wrapper_stop")&&t[n].addClass("indent_last")},handle:".drag-handle"});i.active=!1,i.addEvent("start",function(){i.active=!0}),i.addEvent("complete",function(e){var t,n,a,o;i.active&&(e.getPrevious("li")?(t=e.get("id").replace(/li_/,""),n=e.getPrevious("li").get("id").replace(/li_/,""),a=window.location.search.replace(/id=[0-9]*/,"id="+t)+"&act=cut&mode=1&pid="+n,o=window.location.href.replace(/\?.*$/,""),new Request.Contao({url:o+a,followRedirects:!1}).get()):e.getParent("ul")&&(t=e.get("id").replace(/li_/,""),n=e.getParent("ul").get("id").replace(/ul_/,""),a=window.location.search.replace(/id=[0-9]*/,"id="+t)+"&act=cut&mode=2&pid="+n,o=window.location.href.replace(/\?.*$/,""),new Request.Contao({url:o+a,followRedirects:!1}).get()))})},makeMultiSrcSortable:function(a,o,i){var e=new Sortables($(a),{constrain:!0,opacity:.6}).addEvent("complete",function(){var e,t=[],n=$(a).getChildren("[data-id]");for(e=0;e<n.length;e++)t.push(n[e].get("data-id"));o===i&&$(i).value.split(",").forEach(function(e){-1===t.indexOf(e)&&t.push(e)}),$(o).value=t.join(",")});$(a).getElements(".gimage").each(function(n){n.hasClass("removable")?new Element("button",{type:"button",html:"&times;",class:"tl_red"}).addEvent("click",function(){var e=n.getParent("li"),t=e.get("data-id");$(i).value=$(i).value.split(",").filter(function(e){return e!=t}).join(","),$(o).value=$(o).value.split(",").filter(function(e){return e!=t}).join(","),e.dispose()}).inject(n,"after"):new Element("button",{type:"button",html:"&times",disabled:!0}).inject(n,"after")}),e.fireEvent("complete")},enableFileTreeDragAndDrop:function(c,d){var u=new Scroller(document.getElement("body"),{onChange:function(e,t){this.element.scrollTo(this.element.getScroll().x,t)}});function g(e){return e&&e.hasClass("parent")&&e.getPrevious(".tl_folder")?e.getPrevious(".tl_folder"):e}c.addEvent("mousedown",function(e){var t=e.target.hasClass("drag-handle")?e.target:e.target.getParent(".drag-handle"),o=e.target.getParent(".tl_file,.tl_folder");if(t&&o&&!e.rightClick){u.start(),c.addClass("tl_listing_dragging");var i,l,n=o.getElements(".tl_left")[0]||o,s=n.clone(!0).inject(c).addClass("tl_left_dragging");s.setPosition({x:e.page.x-n.getOffsetParent().getPosition().x-s.getSize().x,y:n.getPosition(n.getOffsetParent()).y}).setStyle("display","none");var a=new Drag.Move(s,{droppables:$$([c]).append(c.getElements(".tl_folder,li.parent,.tl_folder_top")),unDraggableTags:[],modifiers:{x:"left",y:"top"},onStart:function(){s.setStyle("display","")},onEnter:function(e,t){if((t=g(t)).addClass("tl_folder_dropping"),t.hasClass("tl_folder")&&i!==t){i=t,l=(new Date).getTime();var n=t.getElement('img[src$="/icons/folPlus.svg"]');(n=n&&n.getParent("a"))&&setTimeout(function(){if(i===t&&l+900<(new Date).getTime()){var e=document.createEvent("HTMLEvents");e.initEvent("click",!0,!0),n.dispatchEvent(e),l=i=void 0,window.addEvent("ajax_change",function e(){a&&a.droppables&&c&&c.getElements&&(a.droppables=$$([c]).append(c.getElements(".tl_folder,li.parent"))),window.removeEvent("ajax_change",e)})}},1e3)}},onCancel:function(){l=i=void 0,u.stop(),s.destroy(),window.removeEvent("keyup",r),c.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping"),c.removeClass("tl_listing_dragging")},onDrop:function(e,t){if(l=i=void 0,u.stop(),s.destroy(),window.removeEvent("keyup",r),c.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping"),c.removeClass("tl_listing_dragging"),t=g(t)){var n=o.get("data-id"),a=t.get("data-id")||decodeURIComponent(d.url.split(/[?&]pid=/)[1].split("&")[0]);n&&a&&(0===(a+"/").indexOf(n+"/")||a+"/"===n.replace(/[^/]+$/,""))||(Backend.getScrollOffset(),document.location.href=d.url+"&id="+encodeURIComponent(n)+"&pid="+encodeURIComponent(a))}},onLeave:function(e,t){(t=g(t)).removeClass("tl_folder_dropping"),l=i=void 0}});a.start(e),window.addEvent("keyup",r)}function r(e){"esc"===e.key&&a&&a.stop&&(a.droppables=$$([]),a.stop())}})},listWizard:function(e){var l=$(e),s=function(n){var e,a,o,i;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){Backend.getScrollOffset(),e=n.clone(!0).inject(n,"before"),(a=n.getFirst("input"))&&(e.getFirst("input").value=a.value),s(e)});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<l.getChildren().length&&n.destroy()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("li"))?n.inject(o,"before"):n.inject(l,"bottom"),t.focus()):40==e.event.keyCode&&(e.preventDefault(),(i=n.getNext("li"))?n.inject(i,"after"):n.inject(l.getFirst("li"),"before"),t.focus())})}})};new Sortables(l,{constrain:!0,opacity:.6,handle:".drag-handle"}),l.getChildren().each(function(e){s(e)})},tableWizard:function(e){var t=$(e),u=t.getElement("thead"),g=t.getElement("tbody"),f=function(e){var t,n,a,o,i=e.getChildren();for(a=0;a<i.length;a++)for(n=i[a].getChildren(),o=0;o<n.length;o++)(t=n[o].getFirst("textarea"))&&(t.name=t.name.replace(/\[[0-9]+][[0-9]+]/g,"["+a+"]["+o+"]"));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){f(e)}})},h=function(n){var a,o,i,l,s,r,c,d=u.getFirst("tr");n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"rcopy":t.addEvent("click",function(){for(Backend.getScrollOffset(),l=new Element("tr"),s=n.getChildren(),c=0;c<s.length;c++)Backend.retrieveInteractiveHelp(s[c].getElements("button,a")),i=s[c].clone(!0).inject(l,"bottom"),(a=s[c].getFirst("textarea"))&&(i.getFirst("textarea").value=a.value);l.inject(n,"after"),h(l),f(g),Backend.addInteractiveHelp()});break;case"rdelete":t.addEvent("click",function(){Backend.getScrollOffset(),1<g.getChildren().length&&n.destroy(),f(g),Backend.hideInteractiveHelp()});break;case"ccopy":t.addEvent("click",function(){for(Backend.getScrollOffset(),r=p(t),s=g.getChildren(),c=0;c<s.length;c++)o=s[c].getChildren()[r],Backend.retrieveInteractiveHelp(o.getElements("button,a")),i=o.clone(!0).inject(o,"after"),(a=o.getFirst("textarea"))&&(i.getFirst("textarea").value=a.value),h(i);var e=d.getFirst("td");Backend.retrieveInteractiveHelp(e.getElements("button,a")),i=e.clone(!0).inject(d.getLast("td"),"before"),h(i),f(g),Backend.addInteractiveHelp()});break;case"cmovel":t.addEvent("click",function(){if(Backend.getScrollOffset(),r=p(t),s=g.getChildren(),0<r)for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(o.getPrevious(),"before");else for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(s[c].getLast(),"before");f(g)});break;case"cmover":t.addEvent("click",function(){if(Backend.getScrollOffset(),r=p(t),s=g.getChildren(),r<n.getChildren().length-2)for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(o.getNext(),"after");else for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(s[c].getFirst(),"before");f(g)});break;case"cdelete":t.addEvent("click",function(){if(Backend.getScrollOffset(),r=p(t),s=g.getChildren(),2<n.getChildren().length){for(c=0;c<s.length;c++)s[c].getChildren()[r].destroy();d.getFirst("td").destroy()}f(g),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(l=n.getPrevious("tr"))?n.inject(l,"before"):n.inject(g,"bottom"),t.focus(),f(g)):40==e.event.keyCode&&(e.preventDefault(),(l=n.getNext("tr"))?n.inject(l,"after"):n.inject(g,"top"),t.focus(),f(g))})}})},p=function(e){var t,n=$(e).getParent("td"),a=n.getParent("tr").getChildren(),o=0;for(t=0;t<a.length&&a[t]!=n;t++)o++;return o};f(g),u.getChildren().each(function(e){h(e)}),g.getChildren().each(function(e){h(e)}),Backend.tableWizardResize()},tableWizardResize:function(t){var n=window.localStorage.getItem("contao_table_wizard_cell_size");if(void 0!==t)n="",$$(".tl_tablewizard textarea").each(function(e){e.setStyle("width",(e.getStyle("width").toInt()*t).round().limit(142,284)),e.setStyle("height",(e.getStyle("height").toInt()*t).round().limit(66,132)),""==n&&(n=e.getStyle("width")+"|"+e.getStyle("height"))}),window.localStorage.setItem("contao_table_wizard_cell_size",n);else if(null!==n){var a=n.split("|");$$(".tl_tablewizard textarea").each(function(e){e.setStyle("width",a[0]),e.setStyle("height",a[1])})}},tableWizardSetWidth:function(){var e=$("tl_tablewizard");e&&e.setStyle("width",Math.round(.96*e.getParent(".tl_formbody_edit").getComputedSize().width))},moduleWizard:function(e){var r=$(e).getElement("tbody"),c=function(e){var t,n,a,o,i,l=e.getChildren();for(n=0;n<l.length;n++)for(t=l[n].getChildren(),a=0;a<t.length;a++)(o=t[a].getElement("select"))&&(o.name=o.name.replace(/\[[0-9]+]/g,"["+n+"]")),(i=t[a].getElement('input[type="checkbox"]'))&&(i.set("tabindex",-1),i.name=i.name.replace(/\[[0-9]+]/g,"["+n+"]"));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){c(e)}})},d=function(n){var e,a,o,i,l,s;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),o=new Element("tr"),i=n.getChildren(),s=0;s<i.length;s++)Backend.retrieveInteractiveHelp(i[s].getElements("button,a")),a=i[s].clone(!0).inject(o,"bottom"),(e=i[s].getElement("select"))&&(a.getElement("select").value=e.value);o.inject(n,"after"),o.getElement(".chzn-container").destroy(),new Chosen(o.getElement("select.tl_select")),d(o),c(r),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<r.getChildren().length&&n.destroy(),c(r),Backend.hideInteractiveHelp()});break;case"enable":t.addEvent("click",function(){Backend.getScrollOffset(),(l=t.getNext('input[type="checkbox"]')).checked?(l.checked="",t.getElement("img").src=Backend.themePath+"icons/invisible.svg"):(l.checked="checked",t.getElement("img").src=Backend.themePath+"icons/visible.svg"),c(r)});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("tr"))?n.inject(o,"before"):n.inject(r,"bottom"),t.focus(),c(r)):40==e.event.keyCode&&(e.preventDefault(),(o=n.getNext("tr"))?n.inject(o,"after"):n.inject(r,"top"),t.focus(),c(r))})}})};c(r),r.getChildren().each(function(e){d(e)})},optionsWizard:function(e){var s=$(e).getElement("tbody"),r=function(e){var t,n,a,o,i=e.getChildren();for(n=0;n<i.length;n++)for(t=i[n].getChildren(),a=0;a<t.length;a++)(o=t[a].getFirst("input"))&&(o.name=o.name.replace(/\[[0-9]+]/g,"["+n+"]"),"checkbox"==o.type&&(o.id=o.name.replace(/\[[0-9]+]/g,"").replace(/\[/g,"_").replace(/]/g,"")+"_"+n,o.getNext("label").set("for",o.id)));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){r(e)}})},c=function(n){var e,a,o,i,l;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),o=new Element("tr"),i=n.getChildren(),l=0;l<i.length;l++)Backend.retrieveInteractiveHelp(i[l].getElements("button,a")),a=i[l].clone(!0).inject(o,"bottom"),(e=i[l].getFirst("input"))&&(a.getFirst("input").value=e.value,"checkbox"==e.type&&(a.getFirst("input").checked=e.checked?"checked":""));o.inject(n,"after"),c(o),r(s),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<s.getChildren().length&&n.destroy(),r(s),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("tr"))?n.inject(o,"before"):n.inject(s,"bottom"),t.focus(),r(s)):40==e.event.keyCode&&(e.preventDefault(),(o=n.getNext("tr"))?n.inject(o,"after"):n.inject(s,"top"),t.focus(),r(s))})}})};r(s),s.getChildren().each(function(e){c(e)})},keyValueWizard:function(e){var s=$(e).getElement("tbody"),r=function(e){var t,n,a,o,i=e.getChildren();for(n=0;n<i.length;n++)for(t=i[n].getChildren(),a=0;a<t.length;a++)(o=t[a].getFirst("input"))&&(o.name=o.name.replace(/\[[0-9]+]/g,"["+n+"]"));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){r(e)}})},c=function(n){var e,a,o,i,l;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),o=new Element("tr"),i=n.getChildren(),l=0;l<i.length;l++)Backend.retrieveInteractiveHelp(i[l].getElements("button,a")),a=i[l].clone(!0).inject(o,"bottom"),(e=i[l].getFirst("input"))&&(a.getFirst().value=e.value);o.inject(n,"after"),c(o),r(s),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<s.getChildren().length&&n.destroy(),r(s),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("tr"))?n.inject(o,"before"):n.inject(s,"bottom"),t.focus(),r(s)):40==e.event.keyCode&&(e.preventDefault(),(o=n.getNext("tr"))?n.inject(o,"after"):n.inject(s,"top"),t.focus(),r(s))})}})};r(s),s.getChildren().each(function(e){c(e)})},checkboxWizard:function(e){var o=$(e).getElement(".sortable");new Sortables(o,{constrain:!0,opacity:.6,handle:".drag-handle"}),o.getChildren().each(function(e){var n,a;(n=e).getElements("button").each(function(t){t.hasEvent("click")||t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(a=n.getPrevious("span"))?n.inject(a,"before"):n.inject(o,"bottom"),t.focus()):40==e.event.keyCode&&(e.preventDefault(),(a=n.getNext("span"))?n.inject(a,"after"):n.inject(o,"top"),t.focus())})})})},metaDelete:function(e){var t=e.getParent("li");null===t.getPrevious()&&null===t.getNext()?t.getElements("input, textarea").each(function(e){e.value=""}):t.destroy()},toggleAddLanguageButton:function(e){var t=e.getParent("div").getElement('input[type="button"]');""!=e.value?t.removeProperty("disabled"):t.setProperty("disabled",!0)},sectionWizard:function(e){var c=$(e).getElement("tbody"),d=function(e){var t,n,a,o=e.getChildren();for(n=0;n<o.length;n++)for(t=o[n].getChildren(),a=0;a<t.length;a++)t[a].getElements("input").each(function(e){e.name=e.name.replace(/\[[0-9]+]/g,"["+n+"]")}),t[a].getElements("select").each(function(e){e.name=e.name.replace(/\[[0-9]+]/g,"["+n+"]")});new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){d(e)}})},u=function(n){var e,a,o,i,l,s,r;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),a=new Element("tr"),o=n.getChildren(),s=0;s<o.length;s++)for(Backend.retrieveInteractiveHelp(o[s].getElements("button,a")),e=o[s].clone(!0).inject(a,"bottom"),i=o[s].getElements("select"),l=e.getElements("select"),r=0;r<i.length;r++)l[r].value=i[r].value;a.inject(n,"after"),u(a),d(c),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<c.getChildren().length&&n.destroy(),d(c),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(a=n.getPrevious("tr"))?n.inject(a,"before"):n.inject(c,"bottom"),t.focus(),d(c)):40==e.event.keyCode&&(e.preventDefault(),(a=n.getNext("tr"))?n.inject(a,"after"):n.inject(c,"top"),t.focus(),d(c))})}})};d(c),c.getChildren().each(function(e){u(e)})},updateModuleLink:function(e){var t=e.getParent("tr").getLast("td"),n=t.getElement("a.module_link");n.href=n.href.replace(/id=[0-9]+/,"id="+e.value),0<e.value?(t.getElement("a.module_link").setStyle("display",null),t.getElement("img.module_image").setStyle("display","none")):(t.getElement("a.module_link").setStyle("display","none"),t.getElement("img.module_image").setStyle("display",null))},enableImageSizeWidgets:function(){$$(".tl_image_size").each(function(e){function t(){if(""===n.get("value")||0===n.get("value").indexOf("_")||n.get("value").toInt().toString()===n.get("value")){a.readOnly=!0,o.readOnly=!0;var e=$(n.getSelected()[0]).get("text");e=1<e.split("(").length?e.split("(").getLast().split(")")[0].split("x"):["",""],a.set("value","").set("placeholder",+e[0]||""),o.set("value","").set("placeholder",+e[1]||"")}else a.set("placeholder",""),o.set("placeholder",""),a.readOnly=!1,o.readOnly=!1}var n=e.getElement("select"),a=e.getChildren("input")[0],o=e.getChildren("input")[1];t(),n.addEvent("change",t),n.addEvent("keyup",t)})},enableToggleSelect:function(){function a(e){for(t=r.indexOf(e),n=r.indexOf(o),l=Math.min(t,n),s=Math.max(t,n),i=!!r[n].checked;l<=s;l++)r[l].checked=i}var o,t,n,i,l,s,e=$("tl_listing"),r=[];e&&(r=e.getElements('input[type="checkbox"]')),$$(".toggle_select").each(function(e){var t=e.retrieve("boundEvent");t&&e.removeEvent("click",t),e.getElements('label,input[type="checkbox"],input[type="radio"]').each(function(e){e.addEvent("click",function(e){e.stopPropagation()})}),t=function(e){var t=this.getElement('input[type="checkbox"],input[type="radio"]'),n=$(e.target).getParent(".limit_toggler");t&&!t.get("disabled")&&null===n&&("radio"!=t.type?(e.shift&&o?a(t):(t.checked=t.checked?"":"checked","Backend.toggleCheckboxes(this)"==t.get("onclick")&&Backend.toggleCheckboxes(t)),o=t):t.checked||(t.checked="checked"))}.bind(e),e.addEvent("click",t),e.store("boundEvent",t)}),r.each(function(e){e.addEvent("click",function(e){e.shift&&o&&a(this),o=this})})},autoFocusFirstInputField:function(){var e=document.querySelector("#main .tl_formbody_edit");if(e){var t=$(e).getElements("input, textarea").filter(function(e){return!e.get("disabled")&&!e.get("readonly")&&e.isVisible()&&"checkbox"!==e.get("type")&&"radio"!==e.get("type")&&"submit"!==e.get("type")&&"image"!==e.get("type")&&(!e.get("autocomplete")||"off"===e.get("autocomplete")||!e.get("value"))});t[0]&&t[0].focus()}},editPreviewWizard:function(s){function r(){return{x:u.getComputedSize().width,y:u.getComputedSize().height}}function e(){var e=r(),t=u.getComputedSize();c.setStyles({top:t.computedTop+(g.y.get("value")*e.y).round()+"px",left:t.computedLeft+(g.x.get("value")*e.x).round()+"px",width:(g.width.get("value")*e.x).round()+"px",height:(g.height.get("value")*e.y).round()+"px"}),g.width.get("value").toFloat()&&g.height.get("value").toFloat()?c.setStyle("display",null):c.setStyle("display","none")}function t(e){e.preventDefault(),f||(f=!0,d={x:e.page.x-s.getPosition().x-u.getComputedSize().computedLeft,y:e.page.y-s.getPosition().y-u.getComputedSize().computedTop},a(e))}function n(e){a(e),f=!1}var c,d,u=(s=$(s)).getElement("img"),g={},f=!1,a=function(e){if(f){e.preventDefault();var t,n,a,o,i=u.getComputedSize(),l={x:[Math.max(0,Math.min(i.width,d.x)),Math.max(0,Math.min(i.width,e.page.x-s.getPosition().x-i.computedLeft))],y:[Math.max(0,Math.min(i.height,d.y)),Math.max(0,Math.min(i.height,e.page.y-s.getPosition().y-i.computedTop))]};c.setStyles({top:Math.min(l.y[0],l.y[1])+i.computedTop+"px",left:Math.min(l.x[0],l.x[1])+i.computedLeft+"px",width:Math.abs(l.x[0]-l.x[1])+"px",height:Math.abs(l.y[0]-l.y[1])+"px"}),t=r(),n=c.getStyles("top","left","width","height"),a=u.getComputedSize(),(o={x:Math.max(0,Math.min(1,(n.left.toFloat()-a.computedLeft)/t.x)),y:Math.max(0,Math.min(1,(n.top.toFloat()-a.computedTop)/t.y))}).width=Math.min(1-o.x,n.width.toFloat()/t.x),o.height=Math.min(1-o.y,n.height.toFloat()/t.y),o.width&&o.height?c.setStyle("display",null):(o.x=o.y=o.width=o.height="",c.setStyle("display","none")),Object.each(o,function(e,t){g[t].set("value",""===e?"":Number(e).toFixed(15))})}};window.addEvent("domready",function(){s.getParent(".tl_tbox,.tl_box").getElements('input[name^="importantPart"]').each(function(t){["x","y","width","height"].each(function(e){t.get("name").substr(13,e.length)===e.capitalize()&&(g[e]=t=$(t))})}),4===Object.getLength(g)&&(Object.each(g,function(e){e.getParent().setStyle("display","none")}),s.addClass("tl_edit_preview_enabled"),c=new Element("div",{class:"tl_edit_preview_important_part"}).inject(s),e(),u.addEvent("load",e),s.addEvents({mousedown:t,touchstart:t}),$(document.documentElement).addEvents({mousemove:a,touchmove:a,mouseup:n,touchend:n,touchcancel:n,resize:e}))})},enableFileTreeUpload:function(i,e){i=$(i);var l,s,r=e.url,t=new Element("div",{class:"dropzone dropzone-filetree",html:'<span class="dropzone-previews"></span>'}).inject(i,"top");e.previewsContainer=t.getElement(".dropzone-previews"),e.clickable=!1;var c=new Dropzone(i,e);c.on("queuecomplete",function(){window.location.reload()}),c.on("dragover",function(e){if(e.dataTransfer&&e.dataTransfer.types&&-1!==e.dataTransfer.types.indexOf("Files")){i.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping");var t=e.target&&$(e.target);if(t){var n=t.match(".tl_folder")?t:t.getParent(".tl_folder");if(n=n||(n=t.getParent(".parent"))&&n.getPrevious(".tl_folder")){var a=n.getElement('img[src$="/icons/new.svg"]');a=a&&a.getParent("a")}}if(a&&a.href){if(c.options.url=""+a.href,n.addClass("tl_folder_dropping"),l!==n){l=n,s=(new Date).getTime();var o=n.getElement('img[src$="/icons/folPlus.svg"]');(o=o&&o.getParent("a"))&&setTimeout(function(){if(l===n&&s+900<(new Date).getTime()){var e=document.createEvent("HTMLEvents");e.initEvent("click",!0,!0),o.dispatchEvent(e),s=l=void 0}},1e3)}}else c.options.url=r,s=l=void 0}}),c.on("drop",function(e){e.dataTransfer&&e.dataTransfer.types&&-1!==e.dataTransfer.types.indexOf("Files")&&(t.addClass("dropzone-filetree-enabled"),Backend.getScrollOffset())}),c.on("dragleave",function(){i.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping"),s=l=void 0})},crawl:function(){var a=2e3,e=$("tl_crawl"),c=e.getElement("div.progress-bar"),d=e.getElement("p.progress-count"),u=e.getElement("div.results");!function n(e){e=e||!1;new Request({url:window.location.href,headers:{"Only-Status-Update":e},onSuccess:function(e){var t=JSON.decode(e);!function(e){var t,n=e.total-e.pending,a=0<e.total?parseInt(n/e.total*100,10):100;if(c.setStyle("width",a+"%"),c.set("html",a+"%"),c.setAttribute("aria-valuenow",a),d.set("html",n+" / "+e.total),e.finished)for(t in c.removeClass("running").addClass("finished"),u.removeClass("running").addClass("finished"),e.results)if(e.results.hasOwnProperty(t)){var o=u.getElement('.result[data-subscriber="'+t+'"] p.summary'),i=u.getElement('.result[data-subscriber="'+t+'"] p.warning'),l=u.getElement('.result[data-subscriber="'+t+'"] p.subscriber-log'),s=e.results[t],r=s.summary;s.warning&&i.set("html",s.warning),s.hasLog&&l.setStyle("display","block"),o.addClass(s.wasSuccessful?"success":"failure"),o.set("html",r)}}(t),t.finished||setTimeout(n,a)}}).send()}(!0)}};document.addEvent("mousedown",function(e){Backend.getMousePosition(e)}),window.addEvent("domready",function(){$(document.body).addClass("js"),Browser.Features.Touch&&$(document.body).addClass("touch"),Backend.collapsePalettes(),Backend.addInteractiveHelp(),Backend.tableWizardSetWidth(),Backend.enableImageSizeWidgets(),Backend.enableToggleSelect(),Backend.autoFocusFirstInputField(),null!=Elements.chosen&&$$("select.tl_chosen").chosen(),$$("textarea.monospace").each(function(e){Backend.toggleWrap(e)})}),window.addEvent("resize",function(){Backend.tableWizardSetWidth()}),window.addEvent("load",function(){Backend.limitPreviewHeight()}),window.addEvent("ajax_change",function(){Backend.addInteractiveHelp(),Backend.enableImageSizeWidgets(),Backend.enableToggleSelect(),null!=Elements.chosen&&$$("select.tl_chosen").filter(function(e){return"none"!=e.getStyle("display")}).chosen()});
Request.Contao=new Class({Extends:Request.JSON,options:{followRedirects:!0,url:window.location.href},initialize:function(t){t&&!t.url&&t.field&&t.field.form&&t.field.form.action&&(this.options.url=t.field.form.action),this.parent(t)},success:function(e){var i,t=this.getHeader("X-Ajax-Location");if(t&&this.options.followRedirects)location.replace(t);else{try{i=this.response.json=JSON.decode(e,this.options.secure)}catch(t){i={content:e}}null===i?i={content:""}:"object"!=typeof i&&(i={content:e}),""!=i.content&&(i.content=i.content.stripScripts(function(t){i.javascript=t.replace(/<!--|\/\/-->|<!\[CDATA\[\/\/>|<!]]>/g,"")}),i.javascript&&this.options.evalScripts&&Browser.exec(i.javascript)),this.onSuccess(i.content,i)}},failure:function(){var t=this.getHeader("X-Ajax-Location");t&&401===this.status||t&&this.options.followRedirects&&300<=this.status&&this.status<400?location.replace(t):this.onFailure()}}),Request.Mixed=Request.Contao,Tips.Contao=new Class({Extends:Tips,options:{id:"tip",onShow:function(){var t=this.tip.getElement("div.tip-title"),e=this.tip.getElement("div.tip-text");(t&&t.innerHTML||e&&e.innerHTML)&&this.tip.setStyle("display","block")},onHide:function(){this.tip.setStyle("display","none")},title:"title",text:"",showDelay:1e3,hideDelay:100,className:"tip-wrap",offset:{x:16,y:16},windowPadding:{x:0,y:0},fixed:!0,waiAria:!0},position:function(t){this.tip||document.id(this);var e=window.getSize(),i=window.getScroll(),s={x:this.tip.offsetWidth,y:this.tip.offsetHeight},n={x:"left",y:"top"},o={y:!1,x2:!1,y2:!1,x:!1},a={};for(var r in n)a[n[r]]=t.page[r]+this.options.offset[r],a[n[r]]<0&&(o[r]=!0),a[n[r]]+s[r]-i[r]>e[r]-this.options.windowPadding[r]&&("x"==r&&(a[n[r]]=t.page[r]-this.options.offset[r]-s[r]),o[r+"2"]=!0);var h=this.tip.getElement("div.tip-top");o.x2?(a.left+=24,h.setStyles({left:"auto",right:"9px"})):(a.left-=9,h.setStyles({left:"9px",right:"auto"})),this.fireEvent("bound",o),this.tip.setStyles(a)},hide:function(t){this.tip||document.id(this),this.fireEvent("hide",[this.tip,t])}}),Class.refactor(Drag,{attach:function(){return this.handles.addEvent("touchstart",this.bound.start),this.previous.apply(this,arguments)},detach:function(){return this.handles.removeEvent("touchstart",this.bound.start),this.previous.apply(this,arguments)},start:function(){document.addEvents({touchmove:this.bound.check,touchend:this.bound.cancel}),this.previous.apply(this,arguments)},check:function(t){this.options.preventDefault&&t.preventDefault(),Math.round(Math.sqrt(Math.pow(t.page.x-this.mouse.start.x,2)+Math.pow(t.page.y-this.mouse.start.y,2)))>this.options.snap&&(this.cancel(),this.document.addEvents({mousemove:this.bound.drag,mouseup:this.bound.stop}),document.addEvents({touchmove:this.bound.drag,touchend:this.bound.stop}),this.fireEvent("start",[this.element,t]).fireEvent("snap",this.element))},cancel:function(){return document.removeEvents({touchmove:this.bound.check,touchend:this.bound.cancel}),this.previous.apply(this,arguments)},stop:function(){return document.removeEvents({touchmove:this.bound.drag,touchend:this.bound.stop}),this.previous.apply(this,arguments)}}),Class.refactor(Sortables,{initialize:function(t,e){return e.dragOptions=Object.merge(e.dragOptions||{},{preventDefault:e.dragOptions&&e.dragOptions.preventDefault||Browser.Features.Touch}),void 0===e.dragOptions.unDraggableTags&&(e.dragOptions.unDraggableTags=this.options.unDraggableTags.filter(function(t){return"button"!=t})),this.previous.apply(this,arguments)},addItems:function(){return Array.flatten(arguments).each(function(e){this.elements.push(e);var t=e.retrieve("sortables:start",function(t){this.start.call(this,t,e)}.bind(this));(this.options.handle&&e.getElement(this.options.handle)||e).addEvents({mousedown:t,touchstart:t})},this),this},removeItems:function(){return $$(Array.flatten(arguments).map(function(t){this.elements.erase(t);var e=t.retrieve("sortables:start");return(this.options.handle&&t.getElement(this.options.handle)||t).removeEvents({mousedown:e,touchend:e}),t},this))},getClone:function(t,e){if(!this.options.clone)return new Element(e.tagName).inject(document.body);if("function"==typeOf(this.options.clone))return this.options.clone.call(this,t,e,this.list);var i=this.previous.apply(this,arguments);return i.addEvent("touchstart",function(t){e.fireEvent("touchstart",t)}),i}}),Class.refactor(Request.Queue,{onComplete:function(){this.fireEvent("complete",arguments)},onCancel:function(){this.options.autoAdvance&&!this.error&&this.resume(),this.fireEvent("cancel",arguments)},onSuccess:function(){this.options.autoAdvance&&!this.error&&this.resume(),this.fireEvent("success",arguments),this.queue.length||this.isRunning()||this.fireEvent("end")},onFailure:function(){this.error=!0,!this.options.stopOnFailure&&this.options.autoAdvance&&this.resume(),this.fireEvent("failure",arguments),this.queue.length||this.isRunning()||this.fireEvent("end")},onException:function(){this.error=!0,!this.options.stopOnFailure&&this.options.autoAdvance&&this.resume(),this.fireEvent("exception",arguments)}}),Contao.SerpPreview=new Class({options:{id:0,trail:null,titleField:null,titleFallbackField:null,aliasField:null,descriptionField:null,descriptionFallbackField:null,titleTag:null},shorten:function(t,e){return t.length<=e?t:t.substr(0,t.lastIndexOf(" ",e))+" …"},html2string:function(t){return(new DOMParser).parseFromString(t,"text/html").body.textContent},getTinymce:function(){if(window.tinyMCE&&this.options.descriptionFallbackField)return window.tinyMCE.get(this.options.descriptionFallbackField)},initialize:function(){this.options=Object.merge.apply(null,[{},this.options].append(arguments));var t=$("serp_title_"+this.options.id),e=$("serp_url_"+this.options.id),i=$("serp_description_"+this.options.id),s=$(this.options.titleField),n=$(this.options.titleFallbackField),o=$(this.options.aliasField),a=$(this.options.descriptionField),r=$(this.options.descriptionFallbackField),h=-1===this.options.trail.indexOf("›"),l=this.options.titleTag||"%s";s&&s.addEvent("input",function(){s.value?t.set("text",this.shorten(l.replace(/%s/,s.value).replace(/%%/g,"%"),64)):n&&n.value?t.set("text",this.shorten(this.html2string(l.replace(/%s/,n.value)).replace(/%%/g,"%"),64)):t.set("text","")}.bind(this)),n&&n.addEvent("input",function(){s&&s.value||t.set("text",this.shorten(this.html2string(l.replace(/%s/,n.value)).replace(/%%/g,"%"),64))}.bind(this)),o&&o.addEvent("input",function(){"index"==o.value&&h?e.set("text",this.options.trail):e.set("text",this.options.trail+" › "+(o.value||this.options.id).replace(/\//g," › "))}.bind(this)),a&&a.addEvent("input",function(){if(a.value)i.set("text",this.shorten(a.value,160));else{var t=this.getTinymce();t?i.set("text",this.shorten(this.html2string(t.getContent()),160)):r&&r.value?i.set("text",this.shorten(this.html2string(r.value),160)):i.set("text","")}}.bind(this)),r&&r.addEvent("input",function(){a&&a.value||i.set("text",this.shorten(this.html2string(r.value),160))}.bind(this)),setTimeout(function(){var t=this.getTinymce();t&&t.on("keyup",function(){a&&a.value||i.set("text",this.shorten(this.html2string(window.tinyMCE.activeEditor.getContent()),160))}.bind(this))}.bind(this),4)}});
Fixed code: 			$strFolderNameEncoded = StringUtil::convertEncoding(StringUtil::specialchars(basename($currentFolder), false, true), System::getContainer()->getParameter('kernel.charset'));
			$strFileNameEncoded = StringUtil::convertEncoding(StringUtil::specialchars(basename($currentFile), false, true), System::getContainer()->getParameter('kernel.charset'));
			'title': opt.title && opt.title.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;'),
			'title': opt.title && opt.title.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;'),
			'title': opt.title && opt.title.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;'),
var AjaxRequest={themePath:Contao.script_url+"system/themes/"+Contao.theme+"/",toggleNavigation:function(e,t,n){var a=$(t),o=$(e).getParent("li");return a&&(o.hasClass("collapsed")?(o.removeClass("collapsed"),$(e).setAttribute("aria-expanded","true"),$(e).store("tip:title",Contao.lang.collapse),new Request.Contao({url:n}).post({action:"toggleNavigation",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(o.addClass("collapsed"),$(e).setAttribute("aria-expanded","false"),$(e).store("tip:title",Contao.lang.expand),new Request.Contao({url:n}).post({action:"toggleNavigation",id:t,state:0,REQUEST_TOKEN:Contao.request_token}))),!1},toggleStructure:function(i,l,s,r){i.blur();var e=$(l),c=$(i).getFirst("img");return e?"none"==e.getStyle("display")?(e.setStyle("display",null),c.src=AjaxRequest.themePath+"icons/folMinus.svg",$(i).store("tip:title",Contao.lang.collapse),new Request.Contao({field:i}).post({action:"toggleStructure",id:l,state:1,REQUEST_TOKEN:Contao.request_token})):(e.setStyle("display","none"),c.src=AjaxRequest.themePath+"icons/folPlus.svg",$(i).store("tip:title",Contao.lang.expand),new Request.Contao({field:i}).post({action:"toggleStructure",id:l,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:i,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:l,class:"parent",styles:{display:"inline"}});if(new Element("ul",{class:"level_"+s,html:e}).inject(t,"bottom"),5==r)t.inject($(i).getParent("li"),"after");else{for(var n,a=!1,o=$(i).getParent("li");"element"==typeOf(o)&&(n=o.getNext("li"));)if((o=n).hasClass("tl_folder")){a=!0;break}a?t.inject(o,"before"):t.inject(o,"after")}t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(i).store("tip:title",Contao.lang.collapse),c.src=AjaxRequest.themePath+"icons/folMinus.svg",window.fireEvent("structure"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadStructure",id:l,level:s,state:1,REQUEST_TOKEN:Contao.request_token}),!1},toggleFileManager:function(n,a,e,o){n.blur();var t=$(a),i=$(n).getFirst("img");return t?"none"==t.getStyle("display")?(t.setStyle("display",null),i.src=AjaxRequest.themePath+"icons/folMinus.svg",$(n).store("tip:title",Contao.lang.collapse),new Request.Contao({field:n}).post({action:"toggleFileManager",id:a,state:1,REQUEST_TOKEN:Contao.request_token})):(t.setStyle("display","none"),i.src=AjaxRequest.themePath+"icons/folPlus.svg",$(n).store("tip:title",Contao.lang.expand),new Request.Contao({field:n}).post({action:"toggleFileManager",id:a,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:n,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:a,class:"parent",styles:{display:"inline"}});new Element("ul",{class:"level_"+o,html:e}).inject(t,"bottom"),t.inject($(n).getParent("li"),"after"),t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(n).store("tip:title",Contao.lang.collapse),i.src=AjaxRequest.themePath+"icons/folMinus.svg",AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadFileManager",id:a,level:o,folder:e,state:1,REQUEST_TOKEN:Contao.request_token}),!1},togglePagetree:function(n,a,e,t,o){n.blur(),Backend.getScrollOffset();var i=$(a),l=$(n).getFirst("img");return i?"none"==i.getStyle("display")?(i.setStyle("display",null),l.src=AjaxRequest.themePath+"icons/folMinus.svg",$(n).store("tip:title",Contao.lang.collapse),new Request.Contao({field:n}).post({action:"togglePagetree",id:a,state:1,REQUEST_TOKEN:Contao.request_token})):(i.setStyle("display","none"),l.src=AjaxRequest.themePath+"icons/folPlus.svg",$(n).store("tip:title",Contao.lang.expand),new Request.Contao({field:n}).post({action:"togglePagetree",id:a,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:n,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:a,class:"parent",styles:{display:"inline"}});new Element("ul",{class:"level_"+o,html:e}).inject(t,"bottom"),t.inject($(n).getParent("li"),"after"),t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(n).store("tip:title",Contao.lang.collapse),l.src=AjaxRequest.themePath+"icons/folMinus.svg",AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadPagetree",id:a,level:o,field:e,name:t,state:1,REQUEST_TOKEN:Contao.request_token}),!1},toggleFiletree:function(n,a,e,t,o,i){n.blur(),Backend.getScrollOffset();var l=$(a),s=$(n).getFirst("img");return l?"none"==l.getStyle("display")?(l.setStyle("display",null),s.src=AjaxRequest.themePath+"icons/folMinus.svg",$(n).store("tip:title",Contao.lang.collapse),new Request.Contao({field:n}).post({action:"toggleFiletree",id:a,state:1,REQUEST_TOKEN:Contao.request_token})):(l.setStyle("display","none"),s.src=AjaxRequest.themePath+"icons/folPlus.svg",$(n).store("tip:title",Contao.lang.expand),new Request.Contao({field:n}).post({action:"toggleFiletree",id:a,state:0,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:n,evalScripts:!0,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e){var t=new Element("li",{id:a,class:"parent",styles:{display:"inline"}});new Element("ul",{class:"level_"+i,html:e}).inject(t,"bottom"),t.inject($(n).getParent("li"),"after"),t.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(n).store("tip:title",Contao.lang.collapse),s.src=AjaxRequest.themePath+"icons/folMinus.svg",AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadFiletree",id:a,folder:e,level:i,field:t,name:o,state:1,REQUEST_TOKEN:Contao.request_token}),!1},toggleSubpalette:function(a,o,e){a.blur();var t=$(o);function i(e){a.form.elements.VERSION_NUMBER&&(a.form.elements.VERSION_NUMBER.value=/<input\s+[^>]*?name="VERSION_NUMBER"\s+[^>]*?value="([^"]*)"/i.exec(e)[1])}t?a.value?(a.value="",a.checked="",t.setStyle("display","none"),t.getElements("[required]").each(function(e){e.set("required",null).set("data-required","")}),new Request.Contao({field:a,onSuccess:i}).post({action:"toggleSubpalette",id:o,field:e,state:0,REQUEST_TOKEN:Contao.request_token})):(a.value=1,a.checked="checked",t.setStyle("display",null),t.getElements("[data-required]").each(function(e){e.set("required","").set("data-required",null)}),new Request.Contao({field:a,onSuccess:i}).post({action:"toggleSubpalette",id:o,field:e,state:1,REQUEST_TOKEN:Contao.request_token})):new Request.Contao({field:a,evalScripts:!1,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e,t){var n=new Element("div",{id:o,class:"subpal cf",html:e,styles:{display:"block"}}).inject($(a).getParent("div").getParent("div"),"after");t.javascript&&(document.write=function(e){var n="";e.replace(/<script src="([^"]+)"/i,function(e,t){n=t}),n&&Asset.javascript(n,{onLoad:function(){Browser.exec(t.javascript)}})},Browser.exec(t.javascript)),a.value=1,a.checked="checked",n.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),i(e),AjaxRequest.hideBox(),window.fireEvent("subpalette"),window.fireEvent("ajax_change")}}).post({action:"toggleSubpalette",id:o,field:e,load:1,state:1,REQUEST_TOKEN:Contao.request_token})},toggleField:function(e,t){e.blur();var n,a,o=null,i=$(e).getFirst("img"),l=1==i.get("data-state"),s=e.getParent("div");return t&&(s.hasClass("tl_right")?o=s.getPrevious("div").getElement("img"):s.hasClass("tl_listing_container")?(null===(o=e.getParent("td").getPrevious("td").getFirst("div.list_icon"))&&(o=e.getParent("td").getPrevious("td").getElement("div.cte_type")),null===o&&(o=e.getParent("tr").getFirst("td").getElement("div.list_icon_new"))):(n=s.getNext("div"))&&(n.hasClass("cte_type")&&(o=n),null===o&&(o=n.getFirst("div.list_icon"))),null!==o&&("img"==o.nodeName.toLowerCase()?(o.getParent("ul.tl_listing").hasClass("tl_tree_xtnd")||(a=o.getParent("a"))&&-1==a.href.indexOf("contao/preview")&&(o=(n=a.getNext("a"))?n.getFirst("img"):new Element("img")),o.src=l?o.get("data-icon-disabled"):o.get("data-icon")):o.hasClass("cte_type")?l?(o.addClass("unpublished"),o.removeClass("published")):(o.addClass("published"),o.removeClass("unpublished")):o.setStyle("background-image","url("+(l?o.get("data-icon-disabled"):o.get("data-icon"))+")"))),i.src=l?i.get("data-icon-disabled"):i.get("data-icon"),i.set("data-state",l?0:1),new Request.Contao({url:e.href,followRedirects:!1}).get(),!1},toggleVisibility:function(e,t,n){window.console&&console.warn("AjaxRequest.toggleVisibility() is deprecated. Please use the new toggle operation."),e.blur();var a,o,i,l,s,r,c=null,d=$(e).getFirst("img"),u=1==d.get("data-state"),g=e.getParent("div");return null===d.get("data-state")&&(u=-1==d.src.indexOf("invisible"),window.console&&console.warn('Using a visibility toggle without a "data-state" attribute is deprecated. Please adjust your Contao DCA file.')),g.hasClass("tl_right")?c=g.getPrevious("div").getElement("img"):g.hasClass("tl_listing_container")?(null===(c=e.getParent("td").getPrevious("td").getFirst("div.list_icon"))&&(c=e.getParent("td").getPrevious("td").getElement("div.cte_type")),null===c&&(c=e.getParent("tr").getFirst("td").getElement("div.list_icon_new"))):(o=g.getNext("div"))&&(o.hasClass("cte_type")&&(c=o),null===c&&(c=o.getFirst("div.list_icon"))),null!==c&&("img"==c.nodeName.toLowerCase()?(c.getParent("ul.tl_listing").hasClass("tl_tree_xtnd")?(i=c.get("data-icon"),l=c.get("data-icon-disabled"),null===i&&(i=c.src.replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)$/,"$1/$2.$3"),window.console&&console.warn('Using a row icon without a "data-icon" attribute is deprecated. Please adjust your Contao DCA file.')),null===l&&(l=c.src.replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)$/,"$1/$2_.$3"),window.console&&console.warn('Using a row icon without a "data-icon-disabled" attribute is deprecated. Please adjust your Contao DCA file.'))):((s=c.getParent("a"))&&-1==s.href.indexOf("contao/preview")&&(c=(o=s.getNext("a"))?o.getFirst("img"):new Element("img")),i=c.get("data-icon"),l=c.get("data-icon-disabled"),null===i&&(a=c.src.replace(/.*_([0-9])\.(gif|png|jpe?g|svg)/,"$1"),i=c.src.replace(/_[0-9]\.(gif|png|jpe?g|svg)/,(1==a.toInt()?"":"_"+(a.toInt()-1))+".$1").split(/[\\/]/).pop(),window.console&&console.warn('Using a row icon without a "data-icon" attribute is deprecated. Please adjust your Contao DCA file.')),null===l&&(a=c.src.replace(/.*_([0-9])\.(gif|png|jpe?g|svg)/,"$1"),l=c.src.replace(/(_[0-9])?\.(gif|png|jpe?g|svg)/,(a==c.src?"_1":"_"+(a.toInt()+1))+".$2").split(/[\\/]/).pop(),window.console&&console.warn('Using a row icon without a "data-icon-disabled" attribute is deprecated. Please adjust your Contao DCA file.'))),-1==i.indexOf("/")&&(i=AjaxRequest.themePath+(i.match(/\.svg$/)?"icons/":"images/")+i),-1==l.indexOf("/")&&(l=AjaxRequest.themePath+(l.match(/\.svg$/)?"icons/":"images/")+l),c.src=u?l:i):c.hasClass("cte_type")?u?(c.addClass("unpublished"),c.removeClass("published")):(c.addClass("published"),c.removeClass("unpublished")):(i=c.get("data-icon"),l=c.get("data-icon-disabled"),null===i&&(i=c.getStyle("background-image").replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)\);?$/,"$1/$2.$2"),window.console&&console.warn('Using a row icon without a "data-icon" attribute is deprecated. Please adjust your Contao DCA file.')),null===l&&(l=c.getStyle("background-image").replace(/(.*)\/([a-z0-9]+)_?\.(gif|png|jpe?g|svg)\);?$/,"$1/$2_.$3"),window.console&&console.warn('Using a row icon without a "data-icon-disabled" attribute is deprecated. Please adjust your Contao DCA file.')),-1==i.indexOf("/")&&(i=AjaxRequest.themePath+(i.match(/\.svg$/)?"icons/":"images/")+i),-1==l.indexOf("/")&&(l=AjaxRequest.themePath+(l.match(/\.svg$/)?"icons/":"images/")+l),c.setStyle("background-image","url("+(u?l:i)+")"))),"tl_style"==n&&g.getParent("div").getElement("pre").toggleClass("disabled"),i=d.get("data-icon")||AjaxRequest.themePath+"icons/visible.svg",l=d.get("data-icon-disabled")||AjaxRequest.themePath+"icons/invisible.svg",-1!==e.href.indexOf("act=toggle")?(d.src=u?l:i,d.set("data-state",u?0:1),new Request.Contao({url:e.href,followRedirects:!1}).get()):(d.src=u?l:i,d.set("data-state",u?0:1),(r={state:u?0:1,rt:Contao.request_token})[$(e).get("data-tid")||"tid"]=t,new Request.Contao({url:window.location.href,followRedirects:!1}).get(r)),!1},toggleFeatured:function(e,t){window.console&&console.warn("AjaxRequest.toggleFeatured() is deprecated. Please use the new toggle operation."),e.blur();var n=$(e).getFirst("img"),a=1==n.get("data-state");return null===n.get("data-state")&&(a=-1==n.src.indexOf("featured_"),window.console&&console.warn('Using a featured toggle without a "data-state" attribute is deprecated. Please adjust your Contao DCA file.')),a?(n.src=AjaxRequest.themePath+"icons/featured_.svg",n.set("data-state",0),(new Request.Contao).post({action:"toggleFeatured",id:t,state:0,REQUEST_TOKEN:Contao.request_token})):(n.src=AjaxRequest.themePath+"icons/featured.svg",n.set("data-state",1),(new Request.Contao).post({action:"toggleFeatured",id:t,state:1,REQUEST_TOKEN:Contao.request_token})),!1},toggleFieldset:function(e,t,n){e.blur(),Backend.getScrollOffset();var a=$("pal_"+t);if(a.hasClass("collapsed"))a.removeClass("collapsed"),(new Request.Contao).post({action:"toggleFieldset",id:t,table:n,state:1,REQUEST_TOKEN:Contao.request_token});else{for(var o=a.getParent("form"),i=a.getElements("[required]"),l=!0,s=0;s<i.length;s++)if(!i[s].get("value")){l=!1;break}l?(a.addClass("collapsed"),(new Request.Contao).post({action:"toggleFieldset",id:t,table:n,state:0,REQUEST_TOKEN:Contao.request_token})):"function"==typeof o.checkValidity&&o.getElement('button[type="submit"]').click()}return!1},toggleCheckboxGroup:function(e,t){e.blur();var n=$(t),a=$(e).getFirst("img");return!!n&&("none"==n.getStyle("display")?(n.setStyle("display",null),a.src=AjaxRequest.themePath+"icons/folMinus.svg",(new Request.Contao).post({action:"toggleCheckboxGroup",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(n.setStyle("display","none"),a.src=AjaxRequest.themePath+"icons/folPlus.svg",(new Request.Contao).post({action:"toggleCheckboxGroup",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!0)},displayBox:function(e){var t=$("tl_ajaxBox"),n=$("tl_ajaxOverlay"),a=window.getScroll();null===n&&(n=new Element("div",{id:"tl_ajaxOverlay"}).inject($(document.body),"bottom")),n.set({styles:{display:"block",top:a.y+"px"}}),null===t&&(t=new Element("div",{id:"tl_ajaxBox"}).inject($(document.body),"bottom")),t.set({html:e,styles:{display:"block",top:a.y+100+"px"}})},hideBox:function(){var e=$("tl_ajaxBox"),t=$("tl_ajaxOverlay");t&&t.setStyle("display","none"),e&&e.setStyle("display","none")}},Backend={currentId:null,xMousePosition:0,yMousePosition:0,popupWindow:null,themePath:Contao.script_url+"system/themes/"+Contao.theme+"/",getMousePosition:function(e){Backend.xMousePosition=e.client.x,Backend.yMousePosition=e.client.y},openWindow:function(e,t,n){e.blur(),t=Browser.ie?t+40:t+17,n=Browser.ie?n+30:n+17,Backend.popupWindow=window.open(e.href,"","width="+t+",height="+n+",modal=yes,left=100,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no")},openModalWindow:function(e,t,n){new SimpleModal({width:e,hideFooter:!0,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}}).show({title:t,contents:n})},openModalImage:function(e){var t=e||{},n=(window.getSize().x-20).toInt();(!t.width||t.width>n)&&(t.width=Math.min(n,900)),new SimpleModal({width:t.width,hideFooter:!0,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}}).show({title:t.title&&t.title.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),contents:'<img src="'+t.url+'" alt="">'})},openModalIframe:function(e){var t=e||{},n=(window.getSize().x-20).toInt(),a=(window.getSize().y-137).toInt();(!t.width||t.width>n)&&(t.width=Math.min(n,900)),(!t.height||t.height>a)&&(t.height=a),new SimpleModal({width:t.width,hideFooter:!0,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}}).show({title:t.title&&t.title.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),contents:'<iframe src="'+t.url+'" width="100%" height="'+t.height+'" frameborder="0"></iframe>',model:"modal"})},openModalSelector:function(e){var d=e||{},t=(window.getSize().x-20).toInt(),n=(window.getSize().y-192).toInt();d.id||(d.id="tl_select"),(!d.width||d.width>t)&&(d.width=Math.min(t,900)),(!d.height||d.height>n)&&(d.height=n);var a=new SimpleModal({width:d.width,draggable:!1,overlayOpacity:.7,onShow:function(){document.body.setStyle("overflow","hidden")},onHide:function(){document.body.setStyle("overflow","auto")}});a.addButton(Contao.lang.cancel,"btn",function(){this.buttons[0].hasClass("btn-disabled")||this.hide()}),a.addButton(Contao.lang.apply,"btn primary",function(){if(!this.buttons[1].hasClass("btn-disabled")){var e,t,n,a,o,i,l,s,r=window.frames["simple-modal-iframe"],c=[];if(void 0!==r){for((l=(e=r.document.getElementById(d.id)).get("data-picker-value"))&&(c=JSON.parse(l)),t=e.getElementsByTagName("input"),i=0;i<t.length;i++)t[i].id.match(/^(check_all_|reset_)/)||(s=c.indexOf(t[i].get("value")),t[i].checked?-1==s&&c.push(t[i].get("value")):-1!=s&&c.splice(s,1));d.callback?d.callback(e.get("data-table"),c):d.tag&&(n=$(d.tag))?(window.console&&console.warn("Using the modal selector without a callback function is deprecated. Please adjust your Contao DCA file."),n.value=c.join(","),(o=e.get("data-inserttag"))&&(n.value="{{"+o+"::"+n.value+"}}"),d.self.set("href",d.self.get("href").replace(/&value=[^&]*/,"&value="+c.join(",")))):d.id&&(n=$("ctrl_"+d.id))&&(a=e.get("data-callback"))&&(window.console&&console.warn("Using the modal selector without a callback function is deprecated. Please adjust your Contao DCA file."),n.value=c.join("\t"),new Request.Contao({field:n,evalScripts:!1,onRequest:function(){AjaxRequest.displayBox(Contao.lang.loading+" …")},onSuccess:function(e,t){$("ctrl_"+d.id).getParent("div").set("html",t.content),t.javascript&&Browser.exec(t.javascript),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:a,name:d.id,value:n.value,REQUEST_TOKEN:Contao.request_token})),this.hide()}else alert("Could not find the SimpleModal frame")}}),a.show({title:d.title&&d.title.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),contents:'<iframe src="'+d.url+'" name="simple-modal-iframe" width="100%" height="'+d.height+'" frameborder="0"></iframe>',model:"modal"})},openModalBrowser:function(n,e,t,a,o){Backend.openModalSelector({id:"tl_listing",title:a.document.getElement("div.mce-title").get("text"),url:Contao.routes.backend_picker+"?context="+("file"==t?"link":"file")+"&amp;extras[fieldType]=radio&amp;extras[filesOnly]=true&amp;extras[source]="+o+"&amp;value="+e+"&amp;popup=1",callback:function(e,t){a.document.getElementById(n).value=t.join(",")}})},getScrollOffset:function(){window.sessionStorage.setItem("contao_backend_offset",window.getScroll().y)},initScrollOffset:function(){Cookie.dispose("BE_PAGE_OFFSET"),$$('.tl_submit_container button[name][name!="save"]').each(function(e){e.addEvent("click",function(){window.sessionStorage.removeItem("contao_backend_offset")})});var e=window.sessionStorage.getItem("contao_backend_offset");if(window.sessionStorage.removeItem("contao_backend_offset"),e){var t=window.document.getElementById("header"),i=0;t&&t.addClass("down"),$$("[data-add-to-scroll-offset]").each(function(e){var t=e.get("data-add-to-scroll-offset"),n=e.getScrollSize().y,a=!1,o=!1;t?("-"===t.charAt(0)&&(a=!0,t=t.substring(1)),"%"===t.charAt(t.length-1)&&(o=!0,t=t.substring(0,t.length-1)),t=parseInt(t,10),o&&(t=Math.round(n*t/100)),a&&(t*=-1),i+=t):i+=n}),this.vScrollTo(parseInt(e,10)+i)}},autoSubmit:function(e){Backend.getScrollOffset();var t=new Element("input",{type:"hidden",name:"SUBMIT_TYPE",value:"auto"}),n=$(e)||e;t.inject(n,"bottom"),n.submit()},vScrollTo:function(e){window.addEvent("load",function(){window.scrollTo(null,parseInt(e))})},limitPreviewHeight:function(){var l=0;$$("div.limit_height").each(function(e){var t,n,a,o,i=e.getParent(".tl_content");i&&(i.hasClass("wrapper_start")||i.hasClass("wrapper_stop"))||(0===l&&(l=e.className.replace(/[^0-9]*/,"").toInt()),l&&(t=new Element("div",{class:"limit_toggler"}),n=new Element("button",{type:"button",html:"<span>...</span>",class:"unselectable","data-state":0}).inject(t),a=e.getCoordinates(),e.setStyle("height",l),a.height<=l||(n.addEvent("click",function(){o=t.getPrevious("div").getStyle("height").toInt(),t.getPrevious("div").setStyle("height",l<o?l:""),n.set("data-state",n.get("data-state")?0:1)}),t.inject(e,"after"))))})},toggleCheckboxes:function(e,t){for(var n=$$("input"),a=$(e).checked?"checked":"",o=0;o<n.length;o++)"checkbox"==n[o].type.toLowerCase()&&(void 0!==t&&t!=n[o].id.substr(0,t.length)||(n[o].checked=a))},toggleCheckboxGroup:function(e,t){var n=$(e).className,a=$(e).checked?"checked":"";"tl_checkbox"==n?($(t)?$$("#"+t+" .tl_checkbox"):$(e).getParent("fieldset").getElements(".tl_checkbox")).each(function(e){e.checked=a}):"tl_tree_checkbox"==n&&$$("#"+t+" .parent .tl_tree_checkbox").each(function(e){e.checked=a});Backend.getScrollOffset()},toggleCheckboxElements:function(e,t){var n=$(e).checked?"checked":"";$$("."+t).each(function(e){e.hasClass("tl_checkbox")&&(e.checked=n)}),Backend.getScrollOffset()},toggleWrap:function(e){var t=$(e),n="off"==t.getProperty("wrap")?"soft":"off";t.setProperty("wrap",n)},toggleUnchanged:function(){$$("#result-list .tl_confirm").each(function(e){e.toggleClass("hidden")})},blink:function(){},addColorPicker:function(){return!0},collapsePalettes:function(){$$("fieldset.hide").each(function(e){e.addClass("collapsed")}),$$("label.error, label.mandatory").each(function(e){var t=e.getParent("fieldset");t&&t.removeClass("collapsed")})},addInteractiveHelp:function(){new Tips.Contao("p.tl_tip",{offset:{x:9,y:23},text:function(e){return e.get("html")}}),new Tips.Contao($("home"),{offset:{x:15,y:42}}),new Tips.Contao($$("#tmenu a[title]").filter(function(e){return""!=e.title}),{offset:{x:9,y:42}}),new Tips.Contao($$('a[title][class^="group-"]').filter(function(e){return""!=e.title}),{offset:{x:3,y:27}}),new Tips.Contao($$("a[title].navigation").filter(function(e){return""!=e.title}),{offset:{x:34,y:32}}),$$("img[title]").filter(function(e){return""!=e.title}).each(function(e){new Tips.Contao(e,{offset:{x:0,y:"gimage"==e.get("class")?60:30}})}),["a[title]","input[title]","button[title]","time[title]","span[title]"].each(function(e){new Tips.Contao($$(e).filter(function(e){return""!=e.title}),{offset:{x:0,y:"time[title]"==e||"span[title]"==e?26:30}})})},retrieveInteractiveHelp:function(e){e&&e.each(function(e){var t=e.retrieve("tip:title");t&&e.set("title",t)})},hideInteractiveHelp:function(){function e(){document.querySelectorAll(".tip-wrap").forEach(function(e){e.setStyle("display","none")})}e(),setTimeout(e,(new Tips.Contao).options.showDelay)},makeParentViewSortable:function(e){var t=new Scroller(document.getElement("body"),{onChange:function(e,t){this.element.scrollTo(this.element.getScroll().x,t)}}),i=new Sortables(e,{constrain:!0,opacity:.6,onStart:function(){t.start()},onComplete:function(){t.stop()},onSort:function(e){var t,n,a=e.getParent("ul"),o=0;if(a&&(t=a.getChildren("li > div:first-child")))for(n=0;n<t.length;n++)t[n].hasClass("wrapper_stop")&&0<o&&o--,t[n].className=t[n].className.replace(/(^|\s)indent[^\s]*/g,""),0<o&&t[n].addClass("indent").addClass("indent_"+o),t[n].hasClass("wrapper_start")&&o++,t[n].removeClass("indent_first"),t[n].removeClass("indent_last"),t[n-1]&&t[n-1].hasClass("wrapper_start")&&t[n].addClass("indent_first"),t[n+1]&&t[n+1].hasClass("wrapper_stop")&&t[n].addClass("indent_last")},handle:".drag-handle"});i.active=!1,i.addEvent("start",function(){i.active=!0}),i.addEvent("complete",function(e){var t,n,a,o;i.active&&(e.getPrevious("li")?(t=e.get("id").replace(/li_/,""),n=e.getPrevious("li").get("id").replace(/li_/,""),a=window.location.search.replace(/id=[0-9]*/,"id="+t)+"&act=cut&mode=1&pid="+n,o=window.location.href.replace(/\?.*$/,""),new Request.Contao({url:o+a,followRedirects:!1}).get()):e.getParent("ul")&&(t=e.get("id").replace(/li_/,""),n=e.getParent("ul").get("id").replace(/ul_/,""),a=window.location.search.replace(/id=[0-9]*/,"id="+t)+"&act=cut&mode=2&pid="+n,o=window.location.href.replace(/\?.*$/,""),new Request.Contao({url:o+a,followRedirects:!1}).get()))})},makeMultiSrcSortable:function(a,o,i){var e=new Sortables($(a),{constrain:!0,opacity:.6}).addEvent("complete",function(){var e,t=[],n=$(a).getChildren("[data-id]");for(e=0;e<n.length;e++)t.push(n[e].get("data-id"));o===i&&$(i).value.split(",").forEach(function(e){-1===t.indexOf(e)&&t.push(e)}),$(o).value=t.join(",")});$(a).getElements(".gimage").each(function(n){n.hasClass("removable")?new Element("button",{type:"button",html:"&times;",class:"tl_red"}).addEvent("click",function(){var e=n.getParent("li"),t=e.get("data-id");$(i).value=$(i).value.split(",").filter(function(e){return e!=t}).join(","),$(o).value=$(o).value.split(",").filter(function(e){return e!=t}).join(","),e.dispose()}).inject(n,"after"):new Element("button",{type:"button",html:"&times",disabled:!0}).inject(n,"after")}),e.fireEvent("complete")},enableFileTreeDragAndDrop:function(c,d){var u=new Scroller(document.getElement("body"),{onChange:function(e,t){this.element.scrollTo(this.element.getScroll().x,t)}});function g(e){return e&&e.hasClass("parent")&&e.getPrevious(".tl_folder")?e.getPrevious(".tl_folder"):e}c.addEvent("mousedown",function(e){var t=e.target.hasClass("drag-handle")?e.target:e.target.getParent(".drag-handle"),o=e.target.getParent(".tl_file,.tl_folder");if(t&&o&&!e.rightClick){u.start(),c.addClass("tl_listing_dragging");var i,l,n=o.getElements(".tl_left")[0]||o,s=n.clone(!0).inject(c).addClass("tl_left_dragging");s.setPosition({x:e.page.x-n.getOffsetParent().getPosition().x-s.getSize().x,y:n.getPosition(n.getOffsetParent()).y}).setStyle("display","none");var a=new Drag.Move(s,{droppables:$$([c]).append(c.getElements(".tl_folder,li.parent,.tl_folder_top")),unDraggableTags:[],modifiers:{x:"left",y:"top"},onStart:function(){s.setStyle("display","")},onEnter:function(e,t){if((t=g(t)).addClass("tl_folder_dropping"),t.hasClass("tl_folder")&&i!==t){i=t,l=(new Date).getTime();var n=t.getElement('img[src$="/icons/folPlus.svg"]');(n=n&&n.getParent("a"))&&setTimeout(function(){if(i===t&&l+900<(new Date).getTime()){var e=document.createEvent("HTMLEvents");e.initEvent("click",!0,!0),n.dispatchEvent(e),l=i=void 0,window.addEvent("ajax_change",function e(){a&&a.droppables&&c&&c.getElements&&(a.droppables=$$([c]).append(c.getElements(".tl_folder,li.parent"))),window.removeEvent("ajax_change",e)})}},1e3)}},onCancel:function(){l=i=void 0,u.stop(),s.destroy(),window.removeEvent("keyup",r),c.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping"),c.removeClass("tl_listing_dragging")},onDrop:function(e,t){if(l=i=void 0,u.stop(),s.destroy(),window.removeEvent("keyup",r),c.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping"),c.removeClass("tl_listing_dragging"),t=g(t)){var n=o.get("data-id"),a=t.get("data-id")||decodeURIComponent(d.url.split(/[?&]pid=/)[1].split("&")[0]);n&&a&&(0===(a+"/").indexOf(n+"/")||a+"/"===n.replace(/[^/]+$/,""))||(Backend.getScrollOffset(),document.location.href=d.url+"&id="+encodeURIComponent(n)+"&pid="+encodeURIComponent(a))}},onLeave:function(e,t){(t=g(t)).removeClass("tl_folder_dropping"),l=i=void 0}});a.start(e),window.addEvent("keyup",r)}function r(e){"esc"===e.key&&a&&a.stop&&(a.droppables=$$([]),a.stop())}})},listWizard:function(e){var l=$(e),s=function(n){var e,a,o,i;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){Backend.getScrollOffset(),e=n.clone(!0).inject(n,"before"),(a=n.getFirst("input"))&&(e.getFirst("input").value=a.value),s(e)});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<l.getChildren().length&&n.destroy()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("li"))?n.inject(o,"before"):n.inject(l,"bottom"),t.focus()):40==e.event.keyCode&&(e.preventDefault(),(i=n.getNext("li"))?n.inject(i,"after"):n.inject(l.getFirst("li"),"before"),t.focus())})}})};new Sortables(l,{constrain:!0,opacity:.6,handle:".drag-handle"}),l.getChildren().each(function(e){s(e)})},tableWizard:function(e){var t=$(e),u=t.getElement("thead"),g=t.getElement("tbody"),f=function(e){var t,n,a,o,i=e.getChildren();for(a=0;a<i.length;a++)for(n=i[a].getChildren(),o=0;o<n.length;o++)(t=n[o].getFirst("textarea"))&&(t.name=t.name.replace(/\[[0-9]+][[0-9]+]/g,"["+a+"]["+o+"]"));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){f(e)}})},p=function(n){var a,o,i,l,s,r,c,d=u.getFirst("tr");n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"rcopy":t.addEvent("click",function(){for(Backend.getScrollOffset(),l=new Element("tr"),s=n.getChildren(),c=0;c<s.length;c++)Backend.retrieveInteractiveHelp(s[c].getElements("button,a")),i=s[c].clone(!0).inject(l,"bottom"),(a=s[c].getFirst("textarea"))&&(i.getFirst("textarea").value=a.value);l.inject(n,"after"),p(l),f(g),Backend.addInteractiveHelp()});break;case"rdelete":t.addEvent("click",function(){Backend.getScrollOffset(),1<g.getChildren().length&&n.destroy(),f(g),Backend.hideInteractiveHelp()});break;case"ccopy":t.addEvent("click",function(){for(Backend.getScrollOffset(),r=h(t),s=g.getChildren(),c=0;c<s.length;c++)o=s[c].getChildren()[r],Backend.retrieveInteractiveHelp(o.getElements("button,a")),i=o.clone(!0).inject(o,"after"),(a=o.getFirst("textarea"))&&(i.getFirst("textarea").value=a.value),p(i);var e=d.getFirst("td");Backend.retrieveInteractiveHelp(e.getElements("button,a")),i=e.clone(!0).inject(d.getLast("td"),"before"),p(i),f(g),Backend.addInteractiveHelp()});break;case"cmovel":t.addEvent("click",function(){if(Backend.getScrollOffset(),r=h(t),s=g.getChildren(),0<r)for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(o.getPrevious(),"before");else for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(s[c].getLast(),"before");f(g)});break;case"cmover":t.addEvent("click",function(){if(Backend.getScrollOffset(),r=h(t),s=g.getChildren(),r<n.getChildren().length-2)for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(o.getNext(),"after");else for(c=0;c<s.length;c++)(o=s[c].getChildren()[r]).inject(s[c].getFirst(),"before");f(g)});break;case"cdelete":t.addEvent("click",function(){if(Backend.getScrollOffset(),r=h(t),s=g.getChildren(),2<n.getChildren().length){for(c=0;c<s.length;c++)s[c].getChildren()[r].destroy();d.getFirst("td").destroy()}f(g),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(l=n.getPrevious("tr"))?n.inject(l,"before"):n.inject(g,"bottom"),t.focus(),f(g)):40==e.event.keyCode&&(e.preventDefault(),(l=n.getNext("tr"))?n.inject(l,"after"):n.inject(g,"top"),t.focus(),f(g))})}})},h=function(e){var t,n=$(e).getParent("td"),a=n.getParent("tr").getChildren(),o=0;for(t=0;t<a.length&&a[t]!=n;t++)o++;return o};f(g),u.getChildren().each(function(e){p(e)}),g.getChildren().each(function(e){p(e)}),Backend.tableWizardResize()},tableWizardResize:function(t){var n=window.localStorage.getItem("contao_table_wizard_cell_size");if(void 0!==t)n="",$$(".tl_tablewizard textarea").each(function(e){e.setStyle("width",(e.getStyle("width").toInt()*t).round().limit(142,284)),e.setStyle("height",(e.getStyle("height").toInt()*t).round().limit(66,132)),""==n&&(n=e.getStyle("width")+"|"+e.getStyle("height"))}),window.localStorage.setItem("contao_table_wizard_cell_size",n);else if(null!==n){var a=n.split("|");$$(".tl_tablewizard textarea").each(function(e){e.setStyle("width",a[0]),e.setStyle("height",a[1])})}},tableWizardSetWidth:function(){var e=$("tl_tablewizard");e&&e.setStyle("width",Math.round(.96*e.getParent(".tl_formbody_edit").getComputedSize().width))},moduleWizard:function(e){var r=$(e).getElement("tbody"),c=function(e){var t,n,a,o,i,l=e.getChildren();for(n=0;n<l.length;n++)for(t=l[n].getChildren(),a=0;a<t.length;a++)(o=t[a].getElement("select"))&&(o.name=o.name.replace(/\[[0-9]+]/g,"["+n+"]")),(i=t[a].getElement('input[type="checkbox"]'))&&(i.set("tabindex",-1),i.name=i.name.replace(/\[[0-9]+]/g,"["+n+"]"));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){c(e)}})},d=function(n){var e,a,o,i,l,s;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),o=new Element("tr"),i=n.getChildren(),s=0;s<i.length;s++)Backend.retrieveInteractiveHelp(i[s].getElements("button,a")),a=i[s].clone(!0).inject(o,"bottom"),(e=i[s].getElement("select"))&&(a.getElement("select").value=e.value);o.inject(n,"after"),o.getElement(".chzn-container").destroy(),new Chosen(o.getElement("select.tl_select")),d(o),c(r),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<r.getChildren().length&&n.destroy(),c(r),Backend.hideInteractiveHelp()});break;case"enable":t.addEvent("click",function(){Backend.getScrollOffset(),(l=t.getNext('input[type="checkbox"]')).checked?(l.checked="",t.getElement("img").src=Backend.themePath+"icons/invisible.svg"):(l.checked="checked",t.getElement("img").src=Backend.themePath+"icons/visible.svg"),c(r)});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("tr"))?n.inject(o,"before"):n.inject(r,"bottom"),t.focus(),c(r)):40==e.event.keyCode&&(e.preventDefault(),(o=n.getNext("tr"))?n.inject(o,"after"):n.inject(r,"top"),t.focus(),c(r))})}})};c(r),r.getChildren().each(function(e){d(e)})},optionsWizard:function(e){var s=$(e).getElement("tbody"),r=function(e){var t,n,a,o,i=e.getChildren();for(n=0;n<i.length;n++)for(t=i[n].getChildren(),a=0;a<t.length;a++)(o=t[a].getFirst("input"))&&(o.name=o.name.replace(/\[[0-9]+]/g,"["+n+"]"),"checkbox"==o.type&&(o.id=o.name.replace(/\[[0-9]+]/g,"").replace(/\[/g,"_").replace(/]/g,"")+"_"+n,o.getNext("label").set("for",o.id)));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){r(e)}})},c=function(n){var e,a,o,i,l;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),o=new Element("tr"),i=n.getChildren(),l=0;l<i.length;l++)Backend.retrieveInteractiveHelp(i[l].getElements("button,a")),a=i[l].clone(!0).inject(o,"bottom"),(e=i[l].getFirst("input"))&&(a.getFirst("input").value=e.value,"checkbox"==e.type&&(a.getFirst("input").checked=e.checked?"checked":""));o.inject(n,"after"),c(o),r(s),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<s.getChildren().length&&n.destroy(),r(s),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("tr"))?n.inject(o,"before"):n.inject(s,"bottom"),t.focus(),r(s)):40==e.event.keyCode&&(e.preventDefault(),(o=n.getNext("tr"))?n.inject(o,"after"):n.inject(s,"top"),t.focus(),r(s))})}})};r(s),s.getChildren().each(function(e){c(e)})},keyValueWizard:function(e){var s=$(e).getElement("tbody"),r=function(e){var t,n,a,o,i=e.getChildren();for(n=0;n<i.length;n++)for(t=i[n].getChildren(),a=0;a<t.length;a++)(o=t[a].getFirst("input"))&&(o.name=o.name.replace(/\[[0-9]+]/g,"["+n+"]"));new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){r(e)}})},c=function(n){var e,a,o,i,l;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),o=new Element("tr"),i=n.getChildren(),l=0;l<i.length;l++)Backend.retrieveInteractiveHelp(i[l].getElements("button,a")),a=i[l].clone(!0).inject(o,"bottom"),(e=i[l].getFirst("input"))&&(a.getFirst().value=e.value);o.inject(n,"after"),c(o),r(s),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<s.getChildren().length&&n.destroy(),r(s),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(o=n.getPrevious("tr"))?n.inject(o,"before"):n.inject(s,"bottom"),t.focus(),r(s)):40==e.event.keyCode&&(e.preventDefault(),(o=n.getNext("tr"))?n.inject(o,"after"):n.inject(s,"top"),t.focus(),r(s))})}})};r(s),s.getChildren().each(function(e){c(e)})},checkboxWizard:function(e){var o=$(e).getElement(".sortable");new Sortables(o,{constrain:!0,opacity:.6,handle:".drag-handle"}),o.getChildren().each(function(e){var n,a;(n=e).getElements("button").each(function(t){t.hasEvent("click")||t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(a=n.getPrevious("span"))?n.inject(a,"before"):n.inject(o,"bottom"),t.focus()):40==e.event.keyCode&&(e.preventDefault(),(a=n.getNext("span"))?n.inject(a,"after"):n.inject(o,"top"),t.focus())})})})},metaDelete:function(e){var t=e.getParent("li");null===t.getPrevious()&&null===t.getNext()?t.getElements("input, textarea").each(function(e){e.value=""}):t.destroy()},toggleAddLanguageButton:function(e){var t=e.getParent("div").getElement('input[type="button"]');""!=e.value?t.removeProperty("disabled"):t.setProperty("disabled",!0)},sectionWizard:function(e){var c=$(e).getElement("tbody"),d=function(e){var t,n,a,o=e.getChildren();for(n=0;n<o.length;n++)for(t=o[n].getChildren(),a=0;a<t.length;a++)t[a].getElements("input").each(function(e){e.name=e.name.replace(/\[[0-9]+]/g,"["+n+"]")}),t[a].getElements("select").each(function(e){e.name=e.name.replace(/\[[0-9]+]/g,"["+n+"]")});new Sortables(e,{constrain:!0,opacity:.6,handle:".drag-handle",onComplete:function(){d(e)}})},u=function(n){var e,a,o,i,l,s,r;n.getElements("button").each(function(t){if(!t.hasEvent("click"))switch(t.getProperty("data-command")){case"copy":t.addEvent("click",function(){for(Backend.getScrollOffset(),a=new Element("tr"),o=n.getChildren(),s=0;s<o.length;s++)for(Backend.retrieveInteractiveHelp(o[s].getElements("button,a")),e=o[s].clone(!0).inject(a,"bottom"),i=o[s].getElements("select"),l=e.getElements("select"),r=0;r<i.length;r++)l[r].value=i[r].value;a.inject(n,"after"),u(a),d(c),Backend.addInteractiveHelp()});break;case"delete":t.addEvent("click",function(){Backend.getScrollOffset(),1<c.getChildren().length&&n.destroy(),d(c),Backend.hideInteractiveHelp()});break;case null:t.addEvent("keydown",function(e){38==e.event.keyCode?(e.preventDefault(),(a=n.getPrevious("tr"))?n.inject(a,"before"):n.inject(c,"bottom"),t.focus(),d(c)):40==e.event.keyCode&&(e.preventDefault(),(a=n.getNext("tr"))?n.inject(a,"after"):n.inject(c,"top"),t.focus(),d(c))})}})};d(c),c.getChildren().each(function(e){u(e)})},updateModuleLink:function(e){var t=e.getParent("tr").getLast("td"),n=t.getElement("a.module_link");n.href=n.href.replace(/id=[0-9]+/,"id="+e.value),0<e.value?(t.getElement("a.module_link").setStyle("display",null),t.getElement("img.module_image").setStyle("display","none")):(t.getElement("a.module_link").setStyle("display","none"),t.getElement("img.module_image").setStyle("display",null))},enableImageSizeWidgets:function(){$$(".tl_image_size").each(function(e){function t(){if(""===n.get("value")||0===n.get("value").indexOf("_")||n.get("value").toInt().toString()===n.get("value")){a.readOnly=!0,o.readOnly=!0;var e=$(n.getSelected()[0]).get("text");e=1<e.split("(").length?e.split("(").getLast().split(")")[0].split("x"):["",""],a.set("value","").set("placeholder",+e[0]||""),o.set("value","").set("placeholder",+e[1]||"")}else a.set("placeholder",""),o.set("placeholder",""),a.readOnly=!1,o.readOnly=!1}var n=e.getElement("select"),a=e.getChildren("input")[0],o=e.getChildren("input")[1];t(),n.addEvent("change",t),n.addEvent("keyup",t)})},enableToggleSelect:function(){function a(e){for(t=r.indexOf(e),n=r.indexOf(o),l=Math.min(t,n),s=Math.max(t,n),i=!!r[n].checked;l<=s;l++)r[l].checked=i}var o,t,n,i,l,s,e=$("tl_listing"),r=[];e&&(r=e.getElements('input[type="checkbox"]')),$$(".toggle_select").each(function(e){var t=e.retrieve("boundEvent");t&&e.removeEvent("click",t),e.getElements('label,input[type="checkbox"],input[type="radio"]').each(function(e){e.addEvent("click",function(e){e.stopPropagation()})}),t=function(e){var t=this.getElement('input[type="checkbox"],input[type="radio"]'),n=$(e.target).getParent(".limit_toggler");t&&!t.get("disabled")&&null===n&&("radio"!=t.type?(e.shift&&o?a(t):(t.checked=t.checked?"":"checked","Backend.toggleCheckboxes(this)"==t.get("onclick")&&Backend.toggleCheckboxes(t)),o=t):t.checked||(t.checked="checked"))}.bind(e),e.addEvent("click",t),e.store("boundEvent",t)}),r.each(function(e){e.addEvent("click",function(e){e.shift&&o&&a(this),o=this})})},autoFocusFirstInputField:function(){var e=document.querySelector("#main .tl_formbody_edit");if(e){var t=$(e).getElements("input, textarea").filter(function(e){return!e.get("disabled")&&!e.get("readonly")&&e.isVisible()&&"checkbox"!==e.get("type")&&"radio"!==e.get("type")&&"submit"!==e.get("type")&&"image"!==e.get("type")&&(!e.get("autocomplete")||"off"===e.get("autocomplete")||!e.get("value"))});t[0]&&t[0].focus()}},editPreviewWizard:function(s){function r(){return{x:u.getComputedSize().width,y:u.getComputedSize().height}}function e(){var e=r(),t=u.getComputedSize();c.setStyles({top:t.computedTop+(g.y.get("value")*e.y).round()+"px",left:t.computedLeft+(g.x.get("value")*e.x).round()+"px",width:(g.width.get("value")*e.x).round()+"px",height:(g.height.get("value")*e.y).round()+"px"}),g.width.get("value").toFloat()&&g.height.get("value").toFloat()?c.setStyle("display",null):c.setStyle("display","none")}function t(e){e.preventDefault(),f||(f=!0,d={x:e.page.x-s.getPosition().x-u.getComputedSize().computedLeft,y:e.page.y-s.getPosition().y-u.getComputedSize().computedTop},a(e))}function n(e){a(e),f=!1}var c,d,u=(s=$(s)).getElement("img"),g={},f=!1,a=function(e){if(f){e.preventDefault();var t,n,a,o,i=u.getComputedSize(),l={x:[Math.max(0,Math.min(i.width,d.x)),Math.max(0,Math.min(i.width,e.page.x-s.getPosition().x-i.computedLeft))],y:[Math.max(0,Math.min(i.height,d.y)),Math.max(0,Math.min(i.height,e.page.y-s.getPosition().y-i.computedTop))]};c.setStyles({top:Math.min(l.y[0],l.y[1])+i.computedTop+"px",left:Math.min(l.x[0],l.x[1])+i.computedLeft+"px",width:Math.abs(l.x[0]-l.x[1])+"px",height:Math.abs(l.y[0]-l.y[1])+"px"}),t=r(),n=c.getStyles("top","left","width","height"),a=u.getComputedSize(),(o={x:Math.max(0,Math.min(1,(n.left.toFloat()-a.computedLeft)/t.x)),y:Math.max(0,Math.min(1,(n.top.toFloat()-a.computedTop)/t.y))}).width=Math.min(1-o.x,n.width.toFloat()/t.x),o.height=Math.min(1-o.y,n.height.toFloat()/t.y),o.width&&o.height?c.setStyle("display",null):(o.x=o.y=o.width=o.height="",c.setStyle("display","none")),Object.each(o,function(e,t){g[t].set("value",""===e?"":Number(e).toFixed(15))})}};window.addEvent("domready",function(){s.getParent(".tl_tbox,.tl_box").getElements('input[name^="importantPart"]').each(function(t){["x","y","width","height"].each(function(e){t.get("name").substr(13,e.length)===e.capitalize()&&(g[e]=t=$(t))})}),4===Object.getLength(g)&&(Object.each(g,function(e){e.getParent().setStyle("display","none")}),s.addClass("tl_edit_preview_enabled"),c=new Element("div",{class:"tl_edit_preview_important_part"}).inject(s),e(),u.addEvent("load",e),s.addEvents({mousedown:t,touchstart:t}),$(document.documentElement).addEvents({mousemove:a,touchmove:a,mouseup:n,touchend:n,touchcancel:n,resize:e}))})},enableFileTreeUpload:function(i,e){i=$(i);var l,s,r=e.url,t=new Element("div",{class:"dropzone dropzone-filetree",html:'<span class="dropzone-previews"></span>'}).inject(i,"top");e.previewsContainer=t.getElement(".dropzone-previews"),e.clickable=!1;var c=new Dropzone(i,e);c.on("queuecomplete",function(){window.location.reload()}),c.on("dragover",function(e){if(e.dataTransfer&&e.dataTransfer.types&&-1!==e.dataTransfer.types.indexOf("Files")){i.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping");var t=e.target&&$(e.target);if(t){var n=t.match(".tl_folder")?t:t.getParent(".tl_folder");if(n=n||(n=t.getParent(".parent"))&&n.getPrevious(".tl_folder")){var a=n.getElement('img[src$="/icons/new.svg"]');a=a&&a.getParent("a")}}if(a&&a.href){if(c.options.url=""+a.href,n.addClass("tl_folder_dropping"),l!==n){l=n,s=(new Date).getTime();var o=n.getElement('img[src$="/icons/folPlus.svg"]');(o=o&&o.getParent("a"))&&setTimeout(function(){if(l===n&&s+900<(new Date).getTime()){var e=document.createEvent("HTMLEvents");e.initEvent("click",!0,!0),o.dispatchEvent(e),s=l=void 0}},1e3)}}else c.options.url=r,s=l=void 0}}),c.on("drop",function(e){e.dataTransfer&&e.dataTransfer.types&&-1!==e.dataTransfer.types.indexOf("Files")&&(t.addClass("dropzone-filetree-enabled"),Backend.getScrollOffset())}),c.on("dragleave",function(){i.getElements(".tl_folder_dropping").removeClass("tl_folder_dropping"),s=l=void 0})},crawl:function(){var a=2e3,e=$("tl_crawl"),c=e.getElement("div.progress-bar"),d=e.getElement("p.progress-count"),u=e.getElement("div.results");!function n(e){e=e||!1;new Request({url:window.location.href,headers:{"Only-Status-Update":e},onSuccess:function(e){var t=JSON.decode(e);!function(e){var t,n=e.total-e.pending,a=0<e.total?parseInt(n/e.total*100,10):100;if(c.setStyle("width",a+"%"),c.set("html",a+"%"),c.setAttribute("aria-valuenow",a),d.set("html",n+" / "+e.total),e.finished)for(t in c.removeClass("running").addClass("finished"),u.removeClass("running").addClass("finished"),e.results)if(e.results.hasOwnProperty(t)){var o=u.getElement('.result[data-subscriber="'+t+'"] p.summary'),i=u.getElement('.result[data-subscriber="'+t+'"] p.warning'),l=u.getElement('.result[data-subscriber="'+t+'"] p.subscriber-log'),s=e.results[t],r=s.summary;s.warning&&i.set("html",s.warning),s.hasLog&&l.setStyle("display","block"),o.addClass(s.wasSuccessful?"success":"failure"),o.set("html",r)}}(t),t.finished||setTimeout(n,a)}}).send()}(!0)}};document.addEvent("mousedown",function(e){Backend.getMousePosition(e)}),window.addEvent("domready",function(){$(document.body).addClass("js"),Browser.Features.Touch&&$(document.body).addClass("touch"),Backend.collapsePalettes(),Backend.addInteractiveHelp(),Backend.tableWizardSetWidth(),Backend.enableImageSizeWidgets(),Backend.enableToggleSelect(),Backend.autoFocusFirstInputField(),null!=Elements.chosen&&$$("select.tl_chosen").chosen(),$$("textarea.monospace").each(function(e){Backend.toggleWrap(e)})}),window.addEvent("resize",function(){Backend.tableWizardSetWidth()}),window.addEvent("load",function(){Backend.limitPreviewHeight()}),window.addEvent("ajax_change",function(){Backend.addInteractiveHelp(),Backend.enableImageSizeWidgets(),Backend.enableToggleSelect(),null!=Elements.chosen&&$$("select.tl_chosen").filter(function(e){return"none"!=e.getStyle("display")}).chosen()});
	fill: function(element, contents){
		if (typeof contents == 'string') element.set(element.hasClass('tip-text') ? 'html' : 'text', contents);
		else element.adopt(contents);
	},

Request.Contao=new Class({Extends:Request.JSON,options:{followRedirects:!0,url:window.location.href},initialize:function(t){t&&!t.url&&t.field&&t.field.form&&t.field.form.action&&(this.options.url=t.field.form.action),this.parent(t)},success:function(e){var i,t=this.getHeader("X-Ajax-Location");if(t&&this.options.followRedirects)location.replace(t);else{try{i=this.response.json=JSON.decode(e,this.options.secure)}catch(t){i={content:e}}null===i?i={content:""}:"object"!=typeof i&&(i={content:e}),""!=i.content&&(i.content=i.content.stripScripts(function(t){i.javascript=t.replace(/<!--|\/\/-->|<!\[CDATA\[\/\/>|<!]]>/g,"")}),i.javascript&&this.options.evalScripts&&Browser.exec(i.javascript)),this.onSuccess(i.content,i)}},failure:function(){var t=this.getHeader("X-Ajax-Location");t&&401===this.status||t&&this.options.followRedirects&&300<=this.status&&this.status<400?location.replace(t):this.onFailure()}}),Request.Mixed=Request.Contao,Tips.Contao=new Class({Extends:Tips,options:{id:"tip",onShow:function(){var t=this.tip.getElement("div.tip-title"),e=this.tip.getElement("div.tip-text");(t&&t.innerHTML||e&&e.innerHTML)&&this.tip.setStyle("display","block")},onHide:function(){this.tip.setStyle("display","none")},title:"title",text:"",showDelay:1e3,hideDelay:100,className:"tip-wrap",offset:{x:16,y:16},windowPadding:{x:0,y:0},fixed:!0,waiAria:!0},position:function(t){this.tip||document.id(this);var e=window.getSize(),i=window.getScroll(),s={x:this.tip.offsetWidth,y:this.tip.offsetHeight},n={x:"left",y:"top"},o={y:!1,x2:!1,y2:!1,x:!1},a={};for(var r in n)a[n[r]]=t.page[r]+this.options.offset[r],a[n[r]]<0&&(o[r]=!0),a[n[r]]+s[r]-i[r]>e[r]-this.options.windowPadding[r]&&("x"==r&&(a[n[r]]=t.page[r]-this.options.offset[r]-s[r]),o[r+"2"]=!0);var h=this.tip.getElement("div.tip-top");o.x2?(a.left+=24,h.setStyles({left:"auto",right:"9px"})):(a.left-=9,h.setStyles({left:"9px",right:"auto"})),this.fireEvent("bound",o),this.tip.setStyles(a)},fill:function(t,e){"string"==typeof e?t.set(t.hasClass("tip-text")?"html":"text",e):t.adopt(e)},hide:function(t){this.tip||document.id(this),this.fireEvent("hide",[this.tip,t])}}),Class.refactor(Drag,{attach:function(){return this.handles.addEvent("touchstart",this.bound.start),this.previous.apply(this,arguments)},detach:function(){return this.handles.removeEvent("touchstart",this.bound.start),this.previous.apply(this,arguments)},start:function(){document.addEvents({touchmove:this.bound.check,touchend:this.bound.cancel}),this.previous.apply(this,arguments)},check:function(t){this.options.preventDefault&&t.preventDefault(),Math.round(Math.sqrt(Math.pow(t.page.x-this.mouse.start.x,2)+Math.pow(t.page.y-this.mouse.start.y,2)))>this.options.snap&&(this.cancel(),this.document.addEvents({mousemove:this.bound.drag,mouseup:this.bound.stop}),document.addEvents({touchmove:this.bound.drag,touchend:this.bound.stop}),this.fireEvent("start",[this.element,t]).fireEvent("snap",this.element))},cancel:function(){return document.removeEvents({touchmove:this.bound.check,touchend:this.bound.cancel}),this.previous.apply(this,arguments)},stop:function(){return document.removeEvents({touchmove:this.bound.drag,touchend:this.bound.stop}),this.previous.apply(this,arguments)}}),Class.refactor(Sortables,{initialize:function(t,e){return e.dragOptions=Object.merge(e.dragOptions||{},{preventDefault:e.dragOptions&&e.dragOptions.preventDefault||Browser.Features.Touch}),void 0===e.dragOptions.unDraggableTags&&(e.dragOptions.unDraggableTags=this.options.unDraggableTags.filter(function(t){return"button"!=t})),this.previous.apply(this,arguments)},addItems:function(){return Array.flatten(arguments).each(function(e){this.elements.push(e);var t=e.retrieve("sortables:start",function(t){this.start.call(this,t,e)}.bind(this));(this.options.handle&&e.getElement(this.options.handle)||e).addEvents({mousedown:t,touchstart:t})},this),this},removeItems:function(){return $$(Array.flatten(arguments).map(function(t){this.elements.erase(t);var e=t.retrieve("sortables:start");return(this.options.handle&&t.getElement(this.options.handle)||t).removeEvents({mousedown:e,touchend:e}),t},this))},getClone:function(t,e){if(!this.options.clone)return new Element(e.tagName).inject(document.body);if("function"==typeOf(this.options.clone))return this.options.clone.call(this,t,e,this.list);var i=this.previous.apply(this,arguments);return i.addEvent("touchstart",function(t){e.fireEvent("touchstart",t)}),i}}),Class.refactor(Request.Queue,{onComplete:function(){this.fireEvent("complete",arguments)},onCancel:function(){this.options.autoAdvance&&!this.error&&this.resume(),this.fireEvent("cancel",arguments)},onSuccess:function(){this.options.autoAdvance&&!this.error&&this.resume(),this.fireEvent("success",arguments),this.queue.length||this.isRunning()||this.fireEvent("end")},onFailure:function(){this.error=!0,!this.options.stopOnFailure&&this.options.autoAdvance&&this.resume(),this.fireEvent("failure",arguments),this.queue.length||this.isRunning()||this.fireEvent("end")},onException:function(){this.error=!0,!this.options.stopOnFailure&&this.options.autoAdvance&&this.resume(),this.fireEvent("exception",arguments)}}),Contao.SerpPreview=new Class({options:{id:0,trail:null,titleField:null,titleFallbackField:null,aliasField:null,descriptionField:null,descriptionFallbackField:null,titleTag:null},shorten:function(t,e){return t.length<=e?t:t.substr(0,t.lastIndexOf(" ",e))+" …"},html2string:function(t){return(new DOMParser).parseFromString(t,"text/html").body.textContent},getTinymce:function(){if(window.tinyMCE&&this.options.descriptionFallbackField)return window.tinyMCE.get(this.options.descriptionFallbackField)},initialize:function(){this.options=Object.merge.apply(null,[{},this.options].append(arguments));var t=$("serp_title_"+this.options.id),e=$("serp_url_"+this.options.id),i=$("serp_description_"+this.options.id),s=$(this.options.titleField),n=$(this.options.titleFallbackField),o=$(this.options.aliasField),a=$(this.options.descriptionField),r=$(this.options.descriptionFallbackField),h=-1===this.options.trail.indexOf("›"),l=this.options.titleTag||"%s";s&&s.addEvent("input",function(){s.value?t.set("text",this.shorten(l.replace(/%s/,s.value).replace(/%%/g,"%"),64)):n&&n.value?t.set("text",this.shorten(this.html2string(l.replace(/%s/,n.value)).replace(/%%/g,"%"),64)):t.set("text","")}.bind(this)),n&&n.addEvent("input",function(){s&&s.value||t.set("text",this.shorten(this.html2string(l.replace(/%s/,n.value)).replace(/%%/g,"%"),64))}.bind(this)),o&&o.addEvent("input",function(){"index"==o.value&&h?e.set("text",this.options.trail):e.set("text",this.options.trail+" › "+(o.value||this.options.id).replace(/\//g," › "))}.bind(this)),a&&a.addEvent("input",function(){if(a.value)i.set("text",this.shorten(a.value,160));else{var t=this.getTinymce();t?i.set("text",this.shorten(this.html2string(t.getContent()),160)):r&&r.value?i.set("text",this.shorten(this.html2string(r.value),160)):i.set("text","")}}.bind(this)),r&&r.addEvent("input",function(){a&&a.value||i.set("text",this.shorten(this.html2string(r.value),160))}.bind(this)),setTimeout(function(){var t=this.getTinymce();t&&t.on("keyup",function(){a&&a.value||i.set("text",this.shorten(this.html2string(window.tinyMCE.activeEditor.getContent()),160))}.bind(this))}.bind(this),4)}});