From: <fg...@us...> - 2010-09-11 18:39:34
|
Revision: 3070 http://openutils.svn.sourceforge.net/openutils/?rev=3070&view=rev Author: fgiust Date: 2010-09-11 18:39:27 +0000 (Sat, 11 Sep 2010) Log Message: ----------- MEDIA-176 maintain the active page after editing a media Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/js/mootools-1.2.4.4-more.js trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.html Modified: trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/js/mootools-1.2.4.4-more.js =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/js/mootools-1.2.4.4-more.js 2010-09-11 18:14:46 UTC (rev 3069) +++ trunk/openutils-mgnlmedia/src/main/resources/mgnl-resources/media/js/mootools-1.2.4.4-more.js 2010-09-11 18:39:27 UTC (rev 3070) @@ -2238,4 +2238,218 @@ }); -})(); \ No newline at end of file +})(); + + +/* +--- + +script: String.QueryString.js + +description: Methods for dealing with URI query strings. + +license: MIT-style license + +authors: +- Sebastian MarkbÃ¥ge, Aaron Newton, Lennart Pilon, Valerio Proietti + +requires: +- core:1.2.4/Array +- core:1.2.4/String +- /MooTools.More + +provides: [String.QueryString] + +... +*/ + +String.implement({ + + parseQueryString: function(){ + var vars = this.split(/[&;]/), res = {}; + if (vars.length) vars.each(function(val){ + var index = val.indexOf('='), + keys = index < 0 ? [''] : val.substr(0, index).match(/[^\]\[]+/g), + value = decodeURIComponent(val.substr(index + 1)), + obj = res; + keys.each(function(key, i){ + var current = obj[key]; + if(i < keys.length - 1) + obj = obj[key] = current || {}; + else if($type(current) == 'array') + current.push(value); + else + obj[key] = $defined(current) ? [current, value] : value; + }); + }); + return res; + }, + + cleanQueryString: function(method){ + return this.split('&').filter(function(val){ + var index = val.indexOf('='), + key = index < 0 ? '' : val.substr(0, index), + value = val.substr(index + 1); + return method ? method.run([key, value]) : $chk(value); + }).join('&'); + } + +}); + +/* +--- + +script: URI.js + +description: Provides methods useful in managing the window location and uris. + +license: MIT-style license + +authors: +- Sebastian Markbåge +- Aaron Newton + +requires: +- core:1.2.4/Selectors +- /String.QueryString + +provides: URI + +... +*/ + +var URI = new Class({ + + Implements: Options, + + options: { + /*base: false*/ + }, + + regex: /^(?:(\w+):)?(?:\/\/(?:(?:([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)?(\.\.?$|(?:[^?#\/]*\/)*)([^?#]*)(?:\?([^#]*))?(?:#(.*))?/, + parts: ['scheme', 'user', 'password', 'host', 'port', 'directory', 'file', 'query', 'fragment'], + schemes: {http: 80, https: 443, ftp: 21, rtsp: 554, mms: 1755, file: 0}, + + initialize: function(uri, options){ + this.setOptions(options); + var base = this.options.base || URI.base; + if(!uri) uri = base; + + if (uri && uri.parsed) this.parsed = $unlink(uri.parsed); + else this.set('value', uri.href || uri.toString(), base ? new URI(base) : false); + }, + + parse: function(value, base){ + var bits = value.match(this.regex); + if (!bits) return false; + bits.shift(); + return this.merge(bits.associate(this.parts), base); + }, + + merge: function(bits, base){ + if ((!bits || !bits.scheme) && (!base || !base.scheme)) return false; + if (base){ + this.parts.every(function(part){ + if (bits[part]) return false; + bits[part] = base[part] || ''; + return true; + }); + } + bits.port = bits.port || this.schemes[bits.scheme.toLowerCase()]; + bits.directory = bits.directory ? this.parseDirectory(bits.directory, base ? base.directory : '') : '/'; + return bits; + }, + + parseDirectory: function(directory, baseDirectory) { + directory = (directory.substr(0, 1) == '/' ? '' : (baseDirectory || '/')) + directory; + if (!directory.test(URI.regs.directoryDot)) return directory; + var result = []; + directory.replace(URI.regs.endSlash, '').split('/').each(function(dir){ + if (dir == '..' && result.length > 0) result.pop(); + else if (dir != '.') result.push(dir); + }); + return result.join('/') + '/'; + }, + + combine: function(bits){ + return bits.value || bits.scheme + '://' + + (bits.user ? bits.user + (bits.password ? ':' + bits.password : '') + '@' : '') + + (bits.host || '') + (bits.port && bits.port != this.schemes[bits.scheme] ? ':' + bits.port : '') + + (bits.directory || '/') + (bits.file || '') + + (bits.query ? '?' + bits.query : '') + + (bits.fragment ? '#' + bits.fragment : ''); + }, + + set: function(part, value, base){ + if (part == 'value'){ + var scheme = value.match(URI.regs.scheme); + if (scheme) scheme = scheme[1]; + if (scheme && !$defined(this.schemes[scheme.toLowerCase()])) this.parsed = { scheme: scheme, value: value }; + else this.parsed = this.parse(value, (base || this).parsed) || (scheme ? { scheme: scheme, value: value } : { value: value }); + } else if (part == 'data') { + this.setData(value); + } else { + this.parsed[part] = value; + } + return this; + }, + + get: function(part, base){ + switch(part){ + case 'value': return this.combine(this.parsed, base ? base.parsed : false); + case 'data' : return this.getData(); + } + return this.parsed[part] || ''; + }, + + go: function(){ + document.location.href = this.toString(); + }, + + toURI: function(){ + return this; + }, + + getData: function(key, part){ + var qs = this.get(part || 'query'); + if (!$chk(qs)) return key ? null : {}; + var obj = qs.parseQueryString(); + return key ? obj[key] : obj; + }, + + setData: function(values, merge, part){ + if (typeof values == 'string'){ + data = this.getData(); + data[arguments[0]] = arguments[1]; + values = data; + } else if (merge) { + values = $merge(this.getData(), values); + } + return this.set(part || 'query', Hash.toQueryString(values)); + }, + + clearData: function(part){ + return this.set(part || 'query', ''); + } + +}); + +URI.prototype.toString = URI.prototype.valueOf = function(){ + return this.get('value'); +}; + +URI.regs = { + endSlash: /\/$/, + scheme: /^(\w+):/, + directoryDot: /\.\/|\.$/ +}; + +URI.base = new URI(document.getElements('base[href]', true).getLast(), {base: document.location}); + +String.implement({ + + toURI: function(options){ + return new URI(this, options); + } + +}); \ No newline at end of file Modified: trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.html =================================================================== --- trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.html 2010-09-11 18:14:46 UTC (rev 3069) +++ trunk/openutils-mgnlmedia/src/main/resources/net/sourceforge/openutils/mgnlmedia/media/pages/MediaBrowserPage.html 2010-09-11 18:39:27 UTC (rev 3070) @@ -8,6 +8,8 @@ <!--[if lte IE 7]> <link rel="stylesheet" type="text/css" href="${this.request.contextPath}/.resources/media/css/ie-fix.css" /> <![endif]--> + <script type="text/javascript" src="${this.request.contextPath}/.resources/media/js/mootools-1.2.4-core.js"></script> + <script type="text/javascript" src="${this.request.contextPath}/.resources/media/js/mootools-1.2.4.4-more.js"></script> <script type="text/javascript" src="${this.request.contextPath}/.resources/ext/ext-base.js"></script> <script type="text/javascript" src="${this.request.contextPath}/.resources/ext/ext-all.js"></script> <script type="text/javascript" src="${this.request.contextPath}/.resources/media/js/miframe.js"></script> @@ -242,6 +244,14 @@ { url += "&mediaType=" + mediaType; } + + var olduri = frames['mediaFolderView'].location.href.parseQueryString(); + + if (olduri['page'] != undefined) + { + url += "&page=" + olduri['page']; + } + frames['mediaFolderView'].location.href = url; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |