Files
@ f43d1a4680a9
Branch filter:
Location: hot67beta/components/com_media/assets/popup-imagemanager.js
f43d1a4680a9
5.9 KiB
text/javascript
menubar 0 to 10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | /**
* @version $Id: popup-imagemanager.js 8656 2007-08-30 22:40:39Z louis $
* @package Joomla
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
/**
* JImageManager behavior for media component
*
* @package Joomla.Extensions
* @subpackage Media
* @since 1.5
*/
var ImageManager = {
initialize: function()
{
o = this._getUriObject(window.self.location.href);
//console.log(o);
q = $H(this._getQueryObject(o.query));
this.editor = decodeURIComponent(q.get('e_name'));
// Setup image manager fields object
this.fields = new Object();
this.fields.url = $("f_url");
this.fields.alt = $("f_alt");
this.fields.align = $("f_align");
this.fields.title = $("f_title");
this.fields.caption = $("f_caption");
// Setup image listing objects
this.folderlist = $('folderlist');
this.frame = window.frames['imageframe'];
this.frameurl = this.frame.location.href;
// Setup imave listing frame
this.imageframe = $('imageframe');
this.imageframe.manager = this;
this.imageframe.addEvent('load', function(){ ImageManager.onloadimageview(); });
// Setup folder up button
this.upbutton = $('upbutton');
this.upbutton.removeEvents('click');
this.upbutton.addEvent('click', function(){ ImageManager.upFolder(); });
},
onloadimageview: function()
{
// Update the frame url
this.frameurl = this.frame.location.href;
var folder = this.getImageFolder();
for(var i = 0; i < this.folderlist.length; i++)
{
if(folder == this.folderlist.options[i].value) {
this.folderlist.selectedIndex = i;
break;
}
}
a = this._getUriObject($('uploadForm').getProperty('action'));
//console.log(a);
q = $H(this._getQueryObject(a.query));
q.set('folder', folder);
var query = [];
q.each(function(v, k){
if ($chk(v)) {
this.push(k+'='+v);
}
}, query);
a.query = query.join('&');
$('uploadForm').setProperty('action', a.scheme+'://'+a.domain+a.path+'?'+a.query);
},
getImageFolder: function()
{
var url = this.frame.location.search.substring(1);
var args = this.parseQuery(url);
return args['folder'];
},
onok: function()
{
extra = '';
// Get the image tag field information
var url = this.fields.url.getValue();
var alt = this.fields.alt.getValue();
var align = this.fields.align.getValue();
var title = this.fields.title.getValue();
var caption = this.fields.caption.getValue();
if (url != '') {
// Set alt attribute
if (alt != '') {
extra = extra + 'alt="'+alt+'" ';
} else {
extra = extra + 'alt="" ';
}
// Set align attribute
if (align != '') {
extra = extra + 'align="'+align+'" ';
}
// Set align attribute
if (title != '') {
extra = extra + 'title="'+title+'" ';
}
// Set align attribute
if (caption != '') {
extra = extra + 'class="caption" ';
}
var tag = "<img src=\""+url+"\" "+extra+"/>";
}
window.parent.jInsertEditorText(tag, this.editor);
return false;
},
setFolder: function(folder)
{
//this.showMessage('Loading');
for(var i = 0; i < this.folderlist.length; i++)
{
if(folder == this.folderlist.options[i].value) {
this.folderlist.selectedIndex = i;
break;
}
}
this.frame.location.href='index.php?option=com_media&view=imagesList&tmpl=component&folder=' + folder;
},
getFolder: function() {
return this.folderlist.getValue();
},
upFolder: function()
{
var currentFolder = this.getFolder();
if(currentFolder.length < 2) {
return false;
}
var folders = currentFolder.split('/');
var search = '';
for(var i = 0; i < folders.length - 1; i++) {
search += folders[i];
search += '/';
}
// remove the trailing slash
search = search.substring(0, search.length - 1);
for(var i = 0; i < this.folderlist.length; i++)
{
var thisFolder = this.folderlist.options[i].value;
if(thisFolder == search)
{
this.folderlist.selectedIndex = i;
var newFolder = this.folderlist.options[i].value;
this.setFolder(newFolder);
break;
}
}
},
populateFields: function(file)
{
$("f_url").value = image_base_path+file;
},
showMessage: function(text)
{
var message = $('message');
var messages = $('messages');
if(message.firstChild)
message.removeChild(message.firstChild);
message.appendChild(document.createTextNode(text));
messages.style.display = "block";
},
parseQuery: function(query)
{
var params = new Object();
if (!query) {
return params;
}
var pairs = query.split(/[;&]/);
for ( var i = 0; i < pairs.length; i++ )
{
var KeyVal = pairs[i].split('=');
if ( ! KeyVal || KeyVal.length != 2 ) {
continue;
}
var key = unescape( KeyVal[0] );
var val = unescape( KeyVal[1] ).replace(/\+ /g, ' ');
params[key] = val;
}
return params;
},
refreshFrame: function()
{
this._setFrameUrl();
},
_setFrameUrl: function(url)
{
if ($chk(url)) {
this.frameurl = url;
}
this.frame.location.href = this.frameurl;
},
_getQueryObject: function(q) {
var vars = q.split(/[&;]/);
var rs = {};
if (vars.length) vars.each(function(val) {
var keys = val.split('=');
if (keys.length && keys.length == 2) rs[encodeURIComponent(keys[0])] = encodeURIComponent(keys[1]);
});
return rs;
},
_getUriObject: function(u){
var bits = u.match(/^(?:([^:\/?#.]+):)?(?:\/\/)?(([^:\/?#]*)(?::(\d*))?)((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[\?#]|$)))*\/?)?([^?#\/]*))?(?:\?([^#]*))?(?:#(.*))?/);
return (bits)
? bits.associate(['uri', 'scheme', 'authority', 'domain', 'port', 'path', 'directory', 'file', 'query', 'fragment'])
: null;
}
};
window.addEvent('domready', function(){
ImageManager.initialize();
});
|