Skip to content

Commit

Permalink
[#3028] Removed sanitiseParams as all needed items are returned from …
Browse files Browse the repository at this point in the history
…the API call
  • Loading branch information
johnmartin committed Dec 19, 2012
1 parent 8a8542c commit 593682a
Showing 1 changed file with 7 additions and 41 deletions.
48 changes: 7 additions & 41 deletions ckan/public/base/javascript/modules/popover-context.js
@@ -1,7 +1,7 @@
/* Popover context
* These appear when someone hovers over a context item in a activity stream to
* give the user more context into that particular item. It also allows for people to
* follow and unfollow quickly from within the popover
* give the user more context into that particular item. It also allows for
* people to follow and unfollow quickly from within the popover
*
* id - The user_id of user
* context - The type of this popover: currently supports user & package
Expand Down Expand Up @@ -100,7 +100,8 @@ this.ckan.module('popover-context', function($, _) {
}
},

/* Handles the showing of the popover on hover (also hides other active popovers)
/* Handles the showing of the popover on hover (also hides other active
* popovers)
*
* Returns nothing.
*/
Expand Down Expand Up @@ -154,48 +155,13 @@ this.ckan.module('popover-context', function($, _) {

// has this been rendered before?
if (typeof window.popover_context.render[type][id] == 'undefined') {
var params = this.sanitiseParams(json.result);
client.getTemplate('popover-context-' + type + '.html', params, this._onRenderPopover);
client.getTemplate('popover-context-' + type + '.html', json.result, this._onRenderPopover);
} else {
this._onRenderPopover(window.popover_context.render[type][id]);
}
}
},

/* Used to break down a raw object into something a little more passable into a GET request
*
* Returns object.
*/
sanitiseParams: function(raw) {
var type = this.options.type;
var params = {};
if (type == 'user') {
params.id = raw.id;
params.name = raw.name;
params.about = raw.about;
params.display_name = raw.display_name;
params.num_followers = raw.num_followers;
params.number_administered_packages = raw.number_administered_packages;
params.number_of_edits = raw.number_of_edits;
params.is_me = ( raw.id == this.options.authed );
} else if (type == 'dataset') {
params.id = raw.id;
params.title = raw.title;
params.name = raw.name;
params.notes = raw.notes;
params.num_resources = raw.resources.length;
params.num_tags = raw.tags.length;
} else if (type == 'group') {
params.id = raw.id;
params.title = raw.title;
params.name = raw.name;
params.description = raw.description;
params.num_datasets = raw.packages.length;
params.num_followers = raw.num_followers;
}
return params;
},

/* Renders the contents of the popover
*
* Returns nothing.
Expand Down Expand Up @@ -244,8 +210,8 @@ this.ckan.module('popover-context', function($, _) {
return false;
},

/* Callback from when you follow/unfollow a specified item... this is used to ensure
* all popovers associated to that user get re-populated
/* Callback from when you follow/unfollow a specified item... this is
* used to ensure all popovers associated to that user get re-populated
*
* Returns nothing.
*/
Expand Down

0 comments on commit 593682a

Please sign in to comment.