From 930f39730eea7ef848ac2129f55ce8ecef658eeb Mon Sep 17 00:00:00 2001 From: Leo Feyer Date: Wed, 24 Sep 2014 13:49:15 +0200 Subject: [PATCH] Allow to switch between the page and file picker in TinyMCE (see #6974) --- assets/contao/js/core-uncompressed.js | 35 ++++++++++--------- assets/contao/js/core.js | 2 +- system/docs/CHANGELOG.md | 3 ++ .../modules/core/controllers/BackendFile.php | 6 ++++ .../modules/core/controllers/BackendPage.php | 6 ++++ system/modules/core/languages/en/default.xlf | 6 ++++ .../core/templates/backend/be_picker.html5 | 9 +++-- system/modules/core/widgets/FileSelector.php | 17 +++++++++ system/themes/default/main.css | 2 +- system/themes/default/src/main.css | 6 ++-- system/themes/flexible/main.css | 2 +- system/themes/flexible/src/main.css | 6 ++-- 12 files changed, 73 insertions(+), 27 deletions(-) diff --git a/assets/contao/js/core-uncompressed.js b/assets/contao/js/core-uncompressed.js index 1959eef936..adf12b5560 100644 --- a/assets/contao/js/core-uncompressed.js +++ b/assets/contao/js/core-uncompressed.js @@ -856,8 +856,8 @@ var Backend = this.hide(); }); M.addButton(Contao.lang.apply, 'btn primary', function() { - var val = [], - frm = window.frames['simple-modal-iframe']; + var frm = window.frames['simple-modal-iframe'], + val = [], inp, i; if (frm === undefined) { alert('Could not find the SimpleModal frame'); return; @@ -866,8 +866,8 @@ var Backend = alert(Contao.lang.picker); return; // see #5704 } - var inp = frm.document.getElementById('tl_listing').getElementsByTagName('input'); - for (var i=0; i', + 'contents': '', 'model': 'modal' }); }, diff --git a/assets/contao/js/core.js b/assets/contao/js/core.js index 3b15d74a12..1c1604e159 100644 --- a/assets/contao/js/core.js +++ b/assets/contao/js/core.js @@ -1,2 +1,2 @@ /* Contao Open Source CMS, (c) 2005-2014 Leo Feyer, LGPL license */ -var AjaxRequest={toggleNavigation:function(e,t){e.blur();var n=$(t),a=$(e).getFirst("img");return n?("none"==n.getStyle("display")?(n.setStyle("display","inline"),a.src=a.src.replace("modPlus.gif","modMinus.gif"),$(e).store("tip:title",Contao.lang.collapse),(new Request.Contao).post({action:"toggleNavigation",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(n.setStyle("display","none"),a.src=a.src.replace("modMinus.gif","modPlus.gif"),$(e).store("tip:title",Contao.lang.expand),(new Request.Contao).post({action:"toggleNavigation",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):(new Request.Contao({evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n){var o=new Element("li",{id:t,"class":"tl_parent",html:n,styles:{display:"inline"}}).inject($(e).getParent("li"),"after");o.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),a.src=a.src.replace("modPlus.gif","modMinus.gif"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadNavigation",id:t,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},toggleStructure:function(e,t,n,a){e.blur();var o=$(t),l=$(e).getFirst("img");return o?("none"==o.getStyle("display")?(o.setStyle("display","inline"),l.src=l.src.replace("folPlus.gif","folMinus.gif"),$(e).store("tip:title",Contao.lang.collapse),new Request.Contao({field:e}).post({action:"toggleStructure",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(o.setStyle("display","none"),l.src=l.src.replace("folMinus.gif","folPlus.gif"),$(e).store("tip:title",Contao.lang.expand),new Request.Contao({field:e}).post({action:"toggleStructure",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):(new Request.Contao({field:e,evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(o){{var i=new Element("li",{id:t,"class":"parent",styles:{display:"inline"}});new Element("ul",{"class":"level_"+n,html:o}).inject(i,"bottom")}if(5==a)i.inject($(e).getParent("li"),"after");else{for(var r,s=!1,c=$(e).getParent("li");"element"==typeOf(c)&&(r=c.getNext("li"));)if(c=r,c.hasClass("tl_folder")){s=!0;break}s?i.inject(c,"before"):i.inject(c,"after")}i.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),l.src=l.src.replace("folPlus.gif","folMinus.gif"),window.fireEvent("structure"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadStructure",id:t,level:n,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},toggleFileManager:function(e,t,n,a){e.blur();var o=$(t),l=$(e).getFirst("img"),i=$(e).getNext("img");return o?("none"==o.getStyle("display")?(o.setStyle("display","inline"),l.src=l.src.replace("folPlus.gif","folMinus.gif"),i.src=i.src.replace("folderC","folderO"),$(e).store("tip:title",Contao.lang.collapse),new Request.Contao({field:e}).post({action:"toggleFileManager",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(o.setStyle("display","none"),l.src=l.src.replace("folMinus.gif","folPlus.gif"),i.src=i.src.replace("folderO","folderC"),$(e).store("tip:title",Contao.lang.expand),new Request.Contao({field:e}).post({action:"toggleFileManager",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):(new Request.Contao({field:e,evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n){{var o=new Element("li",{id:t,"class":"parent",styles:{display:"inline"}});new Element("ul",{"class":"level_"+a,html:n}).inject(o,"bottom")}o.inject($(e).getParent("li"),"after"),o.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),l.src=l.src.replace("folPlus.gif","folMinus.gif"),i.src=i.src.replace("folderC.gif","folderO.gif"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadFileManager",id:t,level:a,folder:n,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},togglePagetree:function(e,t,n,a,o){e.blur(),Backend.getScrollOffset();var l=$(t),i=$(e).getFirst("img");return l?("none"==l.getStyle("display")?(l.setStyle("display","inline"),i.src=i.src.replace("folPlus.gif","folMinus.gif"),$(e).store("tip:title",Contao.lang.collapse),new Request.Contao({field:e}).post({action:"togglePagetree",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(l.setStyle("display","none"),i.src=i.src.replace("folMinus.gif","folPlus.gif"),$(e).store("tip:title",Contao.lang.expand),new Request.Contao({field:e}).post({action:"togglePagetree",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):(new Request.Contao({field:e,evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n){{var a=new Element("li",{id:t,"class":"parent",styles:{display:"inline"}});new Element("ul",{"class":"level_"+o,html:n}).inject(a,"bottom")}a.inject($(e).getParent("li"),"after"),a.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),i.src=i.src.replace("folPlus.gif","folMinus.gif"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadPagetree",id:t,level:o,field:n,name:a,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},toggleFiletree:function(e,t,n,a,o,l){e.blur(),Backend.getScrollOffset();var i=$(t),r=$(e).getFirst("img");return i?("none"==i.getStyle("display")?(i.setStyle("display","inline"),r.src=r.src.replace("folPlus.gif","folMinus.gif"),$(e).store("tip:title",Contao.lang.collapse),new Request.Contao({field:e}).post({action:"toggleFiletree",id:t,state:1,REQUEST_TOKEN:Contao.request_token})):(i.setStyle("display","none"),r.src=r.src.replace("folMinus.gif","folPlus.gif"),$(e).store("tip:title",Contao.lang.expand),new Request.Contao({field:e}).post({action:"toggleFiletree",id:t,state:0,REQUEST_TOKEN:Contao.request_token})),!1):(new Request.Contao({field:e,evalScripts:!0,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n){{var a=new Element("li",{id:t,"class":"parent",styles:{display:"inline"}});new Element("ul",{"class":"level_"+l,html:n}).inject(a,"bottom")}a.inject($(e).getParent("li"),"after"),a.getElements("a").each(function(e){e.href=e.href.replace(/&ref=[a-f0-9]+/,"&ref="+Contao.referer_id)}),$(e).store("tip:title",Contao.lang.collapse),r.src=r.src.replace("folPlus.gif","folMinus.gif"),AjaxRequest.hideBox(),window.fireEvent("ajax_change")}}).post({action:"loadFiletree",id:t,folder:n,level:l,field:a,name:o,state:1,REQUEST_TOKEN:Contao.request_token}),!1)},toggleSubpalette:function(e,t,n){e.blur();var a=$(t);return a?void(e.value?(e.value="",e.checked="",a.setStyle("display","none"),new Request.Contao({field:e}).post({action:"toggleSubpalette",id:t,field:n,state:0,REQUEST_TOKEN:Contao.request_token})):(e.value=1,e.checked="checked",a.setStyle("display","block"),new Request.Contao({field:e}).post({action:"toggleSubpalette",id:t,field:n,state:1,REQUEST_TOKEN:Contao.request_token}))):void new Request.Contao({field:e,evalScripts:!1,onRequest:AjaxRequest.displayBox(Contao.lang.loading+" …"),onSuccess:function(n,a){var o=new Element("div",{id:t,html:n,styles:{display:"block"}}).inject($(e).getParent("div").getParent("div"),"after");a.javascript&&(document.write=function(e){var t="";e.replace(/