Skip to content

Commit

Permalink
multiple repositories display problem in browser -- fix alohaeditor#460
Browse files Browse the repository at this point in the history
  • Loading branch information
nka11 committed Mar 1, 2012
1 parent 4958a6d commit 696a7ce
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 31 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ All changes are categorized into one of the following keywords:
- **ENHANCEMENT**: core: #448 Aloha Editor possibility to be loaded as requireJS module
- **FEATURE**: added hotkey functionality
- **FEATURE**: added Aloha.settings.plugins.load to load plugins also via config
- **BUG**: fixes #424 -- SmartContentChanged is nott triggered when hitting
- **BUG**: fixes alohaeditor/Aloha-Editor#415 -- Repositorie entries appears twice in explorer
- **BUG**: fixes alohaeditor/Aloha-Editor##424 -- SmartContentChanged is not triggered when hitting
- **BUG**: browser: fixes alohaeditor/Aloha-Editor#415 -- Repositorie entries appears twice in explorer
- **FEATURE**: images browser plugin
- **ENHANCEMENT**: browser: commenting some methods and coding guidelines
- **BUG**: browser: fixes alohaeditor/Aloha-Editor#460 -- Error when multiple repositories are configured

## 0.20.6 - 2012/

Expand Down
3 changes: 3 additions & 0 deletions doc/guides/source/repository.textile
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ There are 2 BaseTypes: document and folder. All other objectTypes may extend eit
h4. Document

* id MUST
* repositoryId MUST
* name MUST
* baseType MUST (document|folder)
* type MUST
Expand All @@ -228,6 +229,7 @@ h4. Document
h4. Folder

* id MUST
* repositoryId MUST
* name MUST
* baseType MUST (document|folder)
* type MUST
Expand Down Expand Up @@ -285,6 +287,7 @@ The JSON response could look like:
<shell>
{
id: 'gailenejane/5008283282’,
repositoryId: 'flickr',
name: 'Quiet moment’,
type: ‘image/jpeg’,
url: 'http://www.flickr.com/photos/gailenejane/5008283282/‘,
Expand Down
65 changes: 36 additions & 29 deletions src/plugins/extra/browser/lib/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,21 +373,21 @@ var Browser = Class.extend({
},

getRepoChildren: function (params, callback) {
var that = this;
var browser = this;

if (this.repositoryManager) {
this.repositoryManager.getChildren(params, function (items) {
that.processRepoResponse(items, callback);
if (browser.repositoryManager) {
browser.repositoryManager.getChildren(params, function (items) {
browser.processRepoResponse(items, callback);
});
}
},

queryRepository: function (params, callback) {
var that = this;
var browser = this;

if (this.repositoryManager) {
this.repositoryManager.query(params, function (response) {
that.processRepoResponse(
if (browser.repositoryManager) {
browser.repositoryManager.query(params, function (response) {
browser.processRepoResponse(
(response.results > 0) ? response.items : [],
{ numItems: response.numItems, hasMoreItems: response.hasMoreItems},
callback
Expand All @@ -397,7 +397,7 @@ var Browser = Class.extend({
},

processRepoResponse: function (items, metainfo, callback) {
var that = this;
var browser = this;
var data = [];
// if the second parameter is a function, it is the callback
if (typeof metainfo === 'function') {
Expand All @@ -406,7 +406,7 @@ var Browser = Class.extend({
}

jQuery.each(items, function () {
data.push(that.harvestRepoObject(this));
data.push(browser.harvestRepoObject(this));
});

if (typeof callback === 'function') {
Expand All @@ -422,7 +422,7 @@ var Browser = Class.extend({
* and all other attributes are optional.
*/
harvestRepoObject: function (obj) {
var md5uid = md5lib.hex_md5(obj.id),
var md5uid = md5lib.hex_md5(obj.repositoryId + "://" + obj.id),
repo_obj = false;

if ( typeof this._objs[md5uid] === "undefined" ) {
Expand Down Expand Up @@ -517,7 +517,7 @@ var Browser = Class.extend({
* Fetch an object's children if we haven't already done so
*/
fetchChildren: function (obj, callback) {
var that = this;
var browser = this;

if (obj.hasMoreItems === true || obj.baseType === 'folder') {
if (obj.loaded === false) {
Expand All @@ -527,8 +527,8 @@ var Browser = Class.extend({
repositoryId : obj.repositoryId
},
function (data) {
if (that._objs[obj.uid].loaded === false) {// should not be called twice
that._objs[obj.uid].loaded = true;
if (obj.loaded === false) {// should not be called twice
obj.loaded = true;

if (typeof callback === 'function') {
callback(data);
Expand Down Expand Up @@ -568,7 +568,7 @@ var Browser = Class.extend({
* Creates the tree using jstree
*/
createTree: function (container) {
var plugin = this;
var browser = this;
var tree = jQuery(renderTemplate('<div class="{tree}">'));
var header = jQuery(renderTemplate(
'<div class="{tree-header} {grab-handle}">\
Expand All @@ -578,10 +578,16 @@ var Browser = Class.extend({

container.append(header, tree);

tree.height(this.grid.height() - header.outerHeight(true))
tree.height(browser.grid.height() - header.outerHeight(true))
.bind('loaded.jstree', function (event, data) {
jQuery('>ul>li', this).first().css('padding-top', 5);
tree.jstree("open_node", "li[rel='repository']");
var roots = jQuery('>ul>li', this), rootindex = 0;
roots.first().css('padding-top', 5);
roots.each(function() {
var rootid = md5lib.hex_md5("Repository" + rootindex);
rootindex++;
$(this).attr('id', rootid);
tree.jstree("open_node", "#" + rootid);
});
})
.bind('select_node.jstree', function (event, data) {
// Suppresses a bug in jsTree
Expand All @@ -590,33 +596,34 @@ var Browser = Class.extend({
}

var node = data.rslt.obj;
var folder = plugin.getObjectFromCache(node);
var folder = browser.getObjectFromCache(node);

if (typeof folder === 'object') {
plugin._pagingOffset = 0;
plugin._searchQuery = null;
plugin._currentFolder = folder;
plugin.fetchItems(folder, plugin.processItems);
browser._pagingOffset = 0;
browser._searchQuery = null;
browser._currentFolder = folder;
browser.fetchItems(folder, browser.processItems);
}
})
.jstree({
types: plugin.types,
rootFolderId: this.rootFolderId,
types: browser.types,
rootFolderId: browser.rootFolderId,
plugins: ['themes', 'json_data', 'ui', 'types'],
core: {
animation: 250
},
themes: {
theme : 'browser',
url : plugin.rootPath + 'css/jstree.css',
url : browser.rootPath + 'css/jstree.css',
dots : true,
icons : true
},
json_data: {
data: function (node, callback) {
if (plugin.repositoryManager) {
plugin.jstree_callback = callback;
plugin.fetchSubnodes.call(plugin, node, callback);
if (browser.repositoryManager) {
browser.jstree_callback = callback;
browser.fetchSubnodes.call(browser, node, callback);

} else {
callback();
}
Expand Down
9 changes: 9 additions & 0 deletions src/plugins/extra/imagebrowser/lib/imagebrowser-plugin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*!
* Aloha Editor
* Browser for images
* Author & Copyright (c) 2011 Gentics Software GmbH
* aloha-sales@gentics.com
* Licensed under the terms of http://www.aloha-editor.com/license.html
*
* Author : Nicolas Karageuzian - http://nka.me
*/
define( [

// js
Expand Down

0 comments on commit 696a7ce

Please sign in to comment.