diff --git a/media/media/js/mediamanager.js b/media/media/js/mediamanager.js index 110c8c8de907a..54ca8a9b09676 100644 --- a/media/media/js/mediamanager.js +++ b/media/media/js/mediamanager.js @@ -26,7 +26,12 @@ this.updatepaths = $( 'input.update-folder' ); this.frame = window.frames.folderframe; - this.frameurl = this.frame.location.href; + + var self = this; + + $(this.frame).one('load', function (e) { + self.frameurl = self.frame.location.href; + }); }, /** @@ -59,7 +64,7 @@ var folder = this.getFolder() || '', query = [], - a = getUriObject( $( '#uploadForm' ).attr( 'action' ) ), + a = getUriObject( $( '#uploadForm' ).prop( 'action' ) ), q = getQueryObject( a.query ), k, v; @@ -67,7 +72,7 @@ el.value = folder; } ); - this.folderpath.value = basepath + (folder ? '/' + folder : ''); + this.folderpath.value = scope.basepath + (folder ? '/' + folder : ''); q.folder = folder; @@ -75,14 +80,14 @@ if (!q.hasOwnProperty( k )) { continue; } v = q[ k ]; - query.push( k + (v === null ? '' : '=' + v) ); + query.push(encodeURIComponent(k) + (v === null ? '' : '=' + encodeURIComponent(v))); } a.query = query.join( '&' ); a.fragment = null; - $( '#uploadForm' ).attr( 'action', buildUri(a) ); - $( '#' + viewstyle ).addClass( 'active' ); + $( '#uploadForm' ).prop( 'action', buildUri(a) ); + $( '#' + scope.viewstyle ).addClass( 'active' ); }, /** @@ -92,10 +97,13 @@ */ setViewType: function( type ) { $( '#' + type ).addClass( 'active' ); - $( '#' + viewstyle ).removeClass( 'active' ); - viewstyle = type; + $( '#' + scope.viewstyle ).removeClass( 'active' ); + scope.viewstyle = type; var folder = this.getFolder(); + folder = encodeURIComponent(folder); + type = encodeURIComponent(type); + this.setFrameUrl( 'index.php?option=com_media&view=mediaList&tmpl=component&folder=' + folder + '&layout=' + type ); }, @@ -181,10 +189,12 @@ MediaManager.initialize(); document.updateUploader = function() { - MediaManager.onloadframe(); + $(MediaManager.frame).one('load', function() { + MediaManager.onloadframe(); + }); }; - MediaManager.onloadframe(); + document.updateUploader(); }); }( jQuery, window )); diff --git a/media/media/js/mediamanager.min.js b/media/media/js/mediamanager.min.js index a84602364281a..490461226beed 100644 --- a/media/media/js/mediamanager.min.js +++ b/media/media/js/mediamanager.min.js @@ -1 +1,2 @@ -!function(e,t){"use strict";function a(t){var a={};return t=t||"",e.each(t.split(/[&;]/),function(e,t){var r=t.split("=");a[decodeURIComponent(r[0])]=2==r.length?decodeURIComponent(r[1]):null}),a}function r(t){var a={},r=t.match(/^(?:([^:\/?#.]+):)?(?:\/\/)?(([^:\/?#]*)(?::(\d*))?)((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[\?#]|$)))*\/?)?([^?#\/]*))?(?:\?([^#]*))?(?:#(.*))?/);return e.each(["uri","scheme","authority","domain","port","path","directory","file","query","fragment"],function(e,t){a[t]=r&&r[e]?r[e]:""}),a}function n(e){return e.scheme+"://"+e.domain+(e.port?":"+e.port:"")+(e.path?e.path:"/")+(e.query?"?"+e.query:"")+(e.fragment?"#"+e.fragment:"")}var o=t.MediaManager={initialize:function(){this.folderpath=e("#folderpath"),this.updatepaths=e("input.update-folder"),this.frame=window.frames.folderframe,this.frameurl=this.frame.location.href},submit:function(t){var a=this.frame.document.getElementById("mediamanager-form");a.task.value=t,e("#username").length&&(a.username.value=e("#username").val(),a.password.value=e("#password").val()),a.submit()},onloadframe:function(){this.frameurl=this.frame.location.href;var t,o,i=this.getFolder()||"",l=[],u=r(e("#uploadForm").attr("action")),s=a(u.query);this.updatepaths.each(function(e,t){t.value=i}),this.folderpath.value=basepath+(i?"/"+i:""),s.folder=i;for(t in s)s.hasOwnProperty(t)&&(o=s[t],l.push(t+(null===o?"":"="+o)));u.query=l.join("&"),u.fragment=null,e("#uploadForm").attr("action",n(u)),e("#"+viewstyle).addClass("active")},setViewType:function(t){e("#"+t).addClass("active"),e("#"+viewstyle).removeClass("active"),viewstyle=t;var a=this.getFolder();this.setFrameUrl("index.php?option=com_media&view=mediaList&tmpl=component&folder="+a+"&layout="+t)},refreshFrame:function(){this.setFrameUrl()},getFolder:function(){var e=a(this.frame.location.search.substring(1));return e.folder=void 0===e.folder?"":e.folder,e.folder},setFrameUrl:function(e){null!==e&&(this.frameurl=e),this.frame.location.href=this.frameurl}};e(function(){o.initialize(),document.updateUploader=function(){o.onloadframe()},o.onloadframe()})}(jQuery,window); \ No newline at end of file +!(function(i,l){"use strict";var e=l.MediaManager={initialize:function(){this.folderpath=i("#folderpath"),this.updatepaths=i("input.update-folder"),this.frame=window.frames.folderframe;var t=this;i(this.frame).one("load",(function(e){t.frameurl=t.frame.location.href}))},submit:function(e){var t=this.frame.document.getElementById("mediamanager-form");t.task.value=e,i("#username").length&&(t.username.value=i("#username").val(),t.password.value=i("#password").val()),t.submit()},onloadframe:function(){this.frameurl=this.frame.location.href;var e,t,a=this.getFolder()||"",o=[],r=(function(e){var a={},o=e.match(/^(?:([^:\/?#.]+):)?(?:\/\/)?(([^:\/?#]*)(?::(\d*))?)((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[\?#]|$)))*\/?)?([^?#\/]*))?(?:\?([^#]*))?(?:#(.*))?/);return i.each(["uri","scheme","authority","domain","port","path","directory","file","query","fragment"],(function(e,t){a[t]=o&&o[e]?o[e]:""})),a})(i("#uploadForm").prop("action")),n=u(r.query);for(e in this.updatepaths.each((function(e,t){t.value=a})),this.folderpath.value=l.basepath+(a?"/"+a:""),n.folder=a,n)n.hasOwnProperty(e)&&(t=n[e],o.push(encodeURIComponent(e)+(null===t?"":"="+encodeURIComponent(t))));r.query=o.join("&"),r.fragment=null,i("#uploadForm").prop("action",(function(e){return e.scheme+"://"+e.domain+(e.port?":"+e.port:"")+(e.path?e.path:"/")+(e.query?"?"+e.query:"")+(e.fragment?"#"+e.fragment:"")})(r)),i("#"+l.viewstyle).addClass("active")},setViewType:function(e){i("#"+e).addClass("active"),i("#"+l.viewstyle).removeClass("active"),l.viewstyle=e;var t=this.getFolder();t=encodeURIComponent(t),e=encodeURIComponent(e),this.setFrameUrl("index.php?option=com_media&view=mediaList&tmpl=component&folder="+t+"&layout="+e)},refreshFrame:function(){this.setFrameUrl()},getFolder:function(){var e=u(this.frame.location.search.substring(1));return e.folder=void 0===e.folder?"":e.folder,e.folder},setFrameUrl:function(e){null!==e&&(this.frameurl=e),this.frame.location.href=this.frameurl}};function u(e){var o={};return e=e||"",i.each(e.split(/[&;]/),(function(e,t){var a=t.split("=");o[decodeURIComponent(a[0])]=2==a.length?decodeURIComponent(a[1]):null})),o}i((function(){e.initialize(),document.updateUploader=function(){i(e.frame).one("load",(function(){e.onloadframe()}))},document.updateUploader()}))})(jQuery,window); + diff --git a/media/media/js/popup-imagemanager.js b/media/media/js/popup-imagemanager.js index 610fb7327ddf3..e2731f3358b8f 100644 --- a/media/media/js/popup-imagemanager.js +++ b/media/media/js/popup-imagemanager.js @@ -32,7 +32,7 @@ this.author = options.author; this.base = options.base; this.asset = options.asset; - this.editor = decodeURIComponent(q.e_name); + this.editor = q.e_name; // Setup image manager fields object this.fields = { @@ -79,7 +79,7 @@ this.frameurl = this.frame.location.href; this.setFolder(folder); - a = this.getUriObject($form.attr('action')); + a = this.getUriObject($form.prop('action')); q = this.getQueryObject(a.query); q.folder = folder; a.query = $.param(q); @@ -89,7 +89,7 @@ portString = ':' + a.port; } - $form.attr('action', a.scheme + '://' + a.domain + portString + a.path + '?' + a.query); + $form.prop('action', a.scheme + '://' + a.domain + portString + a.path + '?' + a.query); }, /** @@ -99,7 +99,7 @@ */ getImageFolder: function () { - return this.getQueryObject(this.frame.location.search.substring(1)).folder.replace(/%2F/gi, "/"); + return this.getQueryObject(this.frame.location.search.substring(1)).folder; }, /** @@ -178,7 +178,6 @@ */ setFolder: function (folder, asset, author) { - folder = folder.replace(/%2F/gi, "/"); for (var i = 0, l = this.folderlist.length; i < l; i++) { if (folder == this.folderlist.options[i].value) @@ -277,11 +276,12 @@ view: 'imagesList', tmpl: 'component', asset: asset, - author: author + author: author, + folder: folder }; // Don't run folder through params because / will end up double encoded. - this.frameurl = 'index.php?' + $.param(qs) + '&folder=' + folder; + this.frameurl = 'index.php?' + $.param(qs); this.frame.location.href = this.frameurl; }, @@ -300,7 +300,7 @@ { var keys = val.split('='); - rs[keys[0]] = keys.length == 2 ? keys[1] : null; + rs[ decodeURIComponent(keys[0]) ] = keys.length == 2 ? decodeURIComponent(keys[1]) : null; }); return rs; diff --git a/media/media/js/popup-imagemanager.min.js b/media/media/js/popup-imagemanager.min.js index 464cacf0aa426..fe6500d365257 100644 --- a/media/media/js/popup-imagemanager.min.js +++ b/media/media/js/popup-imagemanager.min.js @@ -1 +1,2 @@ -(function($,doc){'use strict';window.ImageManager={initialize:function(){var o=this.getUriObject(window.self.location.href),q=this.getQueryObject(o.query);var options=Joomla.getOptions('mediamanager');this.author=options.author;this.base=options.base;this.asset=options.asset;this.editor=decodeURIComponent(q.e_name);this.fields={'url':doc.getElementById("f_url"),'alt':doc.getElementById("f_alt"),'align':doc.getElementById("f_align"),'title':doc.getElementById("f_title"),'caption':doc.getElementById("f_caption"),'c_class':doc.getElementById("f_caption_class")};this.folderlist=doc.getElementById('folderlist');this.frame=window.frames.imageframe;this.frameurl=this.frame.location.href;$('#imageframe').on('load',function(){ImageManager.onloadimageview()});$('#upbutton').off('click').on('click',function(){ImageManager.upFolder()})},onloadimageview:function(){var folder=this.getImageFolder(),$form=$('#uploadForm'),portString='',a,q;this.frameurl=this.frame.location.href;this.setFolder(folder);a=this.getUriObject($form.attr('action'));q=this.getQueryObject(a.query);q.folder=folder;a.query=$.param(q);if(typeof(a.port)!=='undefined'&&a.port!=80){portString=':'+a.port}$form.attr('action',a.scheme+'://'+a.domain+portString+a.path+'?'+a.query)},getImageFolder:function(){return this.getQueryObject(this.frame.location.search.substring(1)).folder.replace(/%2F/gi,"/")},onok:function(){var tag='',attr=[],figclass='',captionclass='',url=this.fields.url.value,alt=this.fields.alt.value,align=this.fields.align.value,title=this.fields.title.value,caption=this.fields.caption.value,c_class=this.fields.c_class.value;if(url){attr.push('alt="'+alt+'"');if(align&&!caption){attr.push('class="pull-'+align+'"')}if(title){attr.push('title="'+title+'"')}tag='';if(caption){if(align){figclass=' class="pull-'+align+'"'}if(c_class){captionclass=' class="'+c_class+'"'}tag=''+tag+''+caption+''}}if(window.Joomla&&Joomla.editors.instances.hasOwnProperty(this.editor)){Joomla.editors.instances[editor].replaceSelection(tag)}else{window.parent.jInsertEditorText(tag,this.editor)}return true},setFolder:function(folder,asset,author){folder=folder.replace(/%2F/gi,"/");for(var i=0,l=this.folderlist.length;i:first-child').remove();$message.append(text);$('#messages').css('display','block')},refreshFrame:function(){this.frame.location.href=this.frameurl},setFrameUrl:function(folder,asset,author){var qs={option:'com_media',view:'imagesList',tmpl:'component',asset:asset,author:author};this.frameurl='index.php?'+$.param(qs)+'&folder='+folder;this.frame.location.href=this.frameurl},getQueryObject:function(q){var rs={};$.each((q||'').split(/[&;]/),function(key,val){var keys=val.split('=');rs[keys[0]]=keys.length==2?keys[1]:null});return rs},getUriObject:function(u){var bitsAssociate={},bits=u.match(/^(?:([^:\/?#.]+):)?(?:\/\/)?(([^:\/?#]*)(?::(\d*))?)((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[\?#]|$)))*\/?)?([^?#\/]*))?(?:\?([^#]*))?(?:#(.*))?/);$.each(['uri','scheme','authority','domain','port','path','directory','file','query','fragment'],function(key,index){bitsAssociate[index]=(!!bits&&!!bits[key])?bits[key]:''});return bitsAssociate}};$(function(){window.ImageManager.initialize()})}(jQuery,document)); \ No newline at end of file +!(function(s,a){"use strict";window.ImageManager={initialize:function(){var e=this.getUriObject(window.self.location.href),t=this.getQueryObject(e.query),i=Joomla.getOptions("mediamanager");this.author=i.author,this.base=i.base,this.asset=i.asset,this.editor=t.e_name,this.fields={url:a.getElementById("f_url"),alt:a.getElementById("f_alt"),align:a.getElementById("f_align"),title:a.getElementById("f_title"),caption:a.getElementById("f_caption"),c_class:a.getElementById("f_caption_class")},this.folderlist=a.getElementById("folderlist"),this.frame=window.frames.imageframe,this.frameurl=this.frame.location.href,s("#imageframe").on("load",(function(){ImageManager.onloadimageview()})),s("#upbutton").off("click").on("click",(function(){ImageManager.upFolder()}))},onloadimageview:function(){var e,t,i=this.getImageFolder(),a=s("#uploadForm"),r="";this.frameurl=this.frame.location.href,this.setFolder(i),e=this.getUriObject(a.prop("action")),(t=this.getQueryObject(e.query)).folder=i,e.query=s.param(t),void 0!==e.port&&80!=e.port&&(r=":"+e.port),a.prop("action",e.scheme+"://"+e.domain+r+e.path+"?"+e.query)},getImageFolder:function(){return this.getQueryObject(this.frame.location.search.substring(1)).folder},onok:function(){var e="",t=[],i="",a="",r=this.fields.url.value,s=this.fields.alt.value,o=this.fields.align.value,n=this.fields.title.value,l=this.fields.caption.value,c=this.fields.c_class.value;return r&&(t.push('alt="'+s+'"'),o&&!l&&t.push('class="pull-'+o+'"'),n&&t.push('title="'+n+'"'),e='",l&&(o&&(i=' class="pull-'+o+'"'),c&&(a=' class="'+c+'"'),e=""+e+""+l+"")),window.Joomla&&Joomla.editors.instances.hasOwnProperty(this.editor)?Joomla.editors.instances[editor].replaceSelection(e):window.parent.jInsertEditorText(e,this.editor),!0},setFolder:function(e,t,i){for(var a=0,r=this.folderlist.length;a:first-child").remove(),t.append(e),s("#messages").css("display","block")},refreshFrame:function(){this.frame.location.href=this.frameurl},setFrameUrl:function(e,t,i){var a={option:"com_media",view:"imagesList",tmpl:"component",asset:t,author:i,folder:e};this.frameurl="index.php?"+s.param(a),this.frame.location.href=this.frameurl},getQueryObject:function(e){var a={};return s.each((e||"").split(/[&;]/),(function(e,t){var i=t.split("=");a[decodeURIComponent(i[0])]=2==i.length?decodeURIComponent(i[1]):null})),a},getUriObject:function(e){var i={},a=e.match(/^(?:([^:\/?#.]+):)?(?:\/\/)?(([^:\/?#]*)(?::(\d*))?)((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[\?#]|$)))*\/?)?([^?#\/]*))?(?:\?([^#]*))?(?:#(.*))?/);return s.each(["uri","scheme","authority","domain","port","path","directory","file","query","fragment"],(function(e,t){i[t]=a&&a[e]?a[e]:""})),i}},s((function(){window.ImageManager.initialize()}))})(jQuery,document); +