Skip to content

Commit

Permalink
[ui:places] fix Studio-42#1206 allow modify places on load
Browse files Browse the repository at this point in the history
** example for preset places **
```javascript
elfinderInstance.bind('placesload', function(e, fm) {
	//if (fm.storage(e.data.storageKey) === null) { // for first
	//time only
	if (!fm.storage(e.data.storageKey)) {           // for empty
places
		e.data.dirs[targetHash] = fallbackName;     // preset
folder
	}
}
```
  • Loading branch information
nao-pon committed Feb 1, 2016
1 parent 9ad86d1 commit e259f46
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion js/ui/places.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,20 @@ $.fn.elfinderplaces = function(fm, opts) {
dat = $.map((fm.storage(key) || '').split(','), function(hash) { return hash || null;});
$.each(dat, function(i, d) {
var dir = d.split('#')
dirs[dir[0]] = dir[1]? dir[1] : { hash: dir[0], name: dir[0] };
dirs[dir[0]] = dir[1]? dir[1] : dir[0];
});
// allow modify `dirs`
/**
* example for preset places
*
* elfinderInstance.bind('placesload', function(e, fm) {
* //if (fm.storage(e.data.storageKey) === null) { // for first time only
* if (!fm.storage(e.data.storageKey)) { // for empty places
* e.data.dirs[targetHash] = fallbackName; // preset folder
* }
* }
**/
fm.trigger('placesload', {dirs: dirs, storageKey: key}, true);

hashes = Object.keys(dirs);
if (hashes.length) {
Expand Down

0 comments on commit e259f46

Please sign in to comment.