Hi Everyone!
After a lot of work and figuring out, I present to the OC community, the properly '
behaving' Image Manager for OC.(this need be packaged in every OC release IMHO)
- Remembers the last opened tree and selected folder.
Tested: OC 1.5.1.3
Browsers: FF 7.0, Chrome 12, Opera 11.51
File attached (ZIPPED) : Extract filemanager.tpl from ZIP and copy to your OC installation admin\view\template\common\ folder. MAKE A BACKUP OF YOUR ORIGINAL in case you want to revert, which I highly doubt
Code below (modified only/partial): for full code view please download and view the source of the filemanager.tpl file.
Code: Select all
...
$(document).ready(function () {
$('#column_left').tree({
plugins : {
cookie : {}
},
data: {
type: 'json',
async: true,
opts: {
method: 'POST',
url: 'index.php?route=common/filemanager/directory&token=<?php echo $token; ?>'
}
},
selected: 'top',
ui: {
theme_name: 'classic',
animation: 400
},
types: {
'default': {
clickable: true,
creatable: false,
renameable: false,
deletable: false,
draggable: false,
max_children: -1,
max_depth: -1,
valid_children: 'all'
}
},
callback: {
beforedata: function(NODE, TREE_OBJ) {
if (NODE == false) {
TREE_OBJ.settings.data.opts.static = [
{
data: 'image',
attributes: {
'id': 'top',
'directory': ''
},
state: 'closed'
}
];
return { 'directory': '' }
} else {
TREE_OBJ.settings.data.opts.static = false;
return { 'directory': $(NODE).attr('directory') }
};
},
onselect: function (NODE, TREE_OBJ) {
$.ajax({
url: 'index.php?route=common/filemanager/files&token=<?php echo $token; ?>',
type: 'POST',
data: 'directory=' + encodeURIComponent($(NODE).attr('directory')),
dataType: 'json',
success: function(json) {
html = '<div>';
if (json) {
for (i = 0; i < json.length; i++) {
name = '';
filename = json[i]['filename'];
for (j = 0; j < filename.length; j = j + 15) {
name += filename.substr(j, 15) + '<br />';
}
name += json[i]['size'];
html += '<a file="' + json[i]['file'] + '"><img src="' + json[i]['thumb'] + '" title="' + json[i]['filename'] + '" /><br />' + name + '</a>';
}
}
html += '</div>';
$('#column_right').html(html);
}
});
},
onopen: function(TREE_OBJ) {
var tr = $('#column_left li#top li[directory]');
tr.each(function(index, domEle) {
dd = $(domEle).attr('directory');
dd = dd.replace(/\//g, "");
dd = dd.replace(" ", "");
$(domEle).attr('id', dd);
});
var myTree = $.tree.reference('#column_left');
var cc = $.cookie('selected');
var bb = '#' + cc;
myTree.select_branch(bb);
},
},
});
...
Happy Open Carting!
Please consider donating
or
Pass me some work.
++++
Here's an OC demo done by me : itwaarbazaar.com
My deviantArt page: kaylohn.deviantart.com
My YouTube Channel:
http://www.youtube.com/kaylohn
+++++++
EDIT
+++++++
Please download from the extensions page for latest version and updates
http://www.opencart.com/index.php?route ... on_id=3601