Skip to content

Commit

Permalink
show only themes in extension registry, fix #66
Browse files Browse the repository at this point in the history
  • Loading branch information
dnbard committed Aug 3, 2014
1 parent 8a78f9e commit 206c982
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
5 changes: 4 additions & 1 deletion extension/achievements/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ define(function(require, exports, module){
_ = require('../vendor/lodash.min'),
locale = require('../services/locale'),
ExtensionsService = require('../services/extensions'),
image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAADaklEQVR42p2Sf2iUdRzHvwT5RyrlaoglqBSBDksi+rVsOXU07I47KsEE3eBicxWBehTVZJttjVs3k7vKTdncdmNuu82bzgmSO5dw262TgacVPNtipdW53d1ueN1zz/P9ft49zwO7cVr/9IUX38/n/cCL7/fzfNmRI6ysuppNf3d6E4UXTtEk+g3Gk3V0/OdlVNqzmlZYi4jtNBk8aLZRjq2FHj9wkjbZ3fN5h92dGw+517GGr3Onui4Up88HSvDLQg9+w2WMztdgOPIpPu634ED7OyisrMHL9sYMxfV9KPyiC3l2N56pbFG2dgQd7ERbHl2dqkKCZkAkQBDgpIALBWlVR4ViwJfgXMs5ukevY8tRD4rOTybZ2O9f0o1YBwRxBINBtLa2ZhEOhzExMXFfHgqFoHIB27lreD00BybBq53le0PU1NQEk8mUhdfrhcfjuS/XZbqo9qco8m9xsLDSTKPzR42rLIpsNhtqa2sNAoEARkZGMn1paWlGxIWK8dsu9N6pB/vx73oa+vNdqELOiJxOJ2ZnZzE3N4dkMmmg13qmyxZFJNJAwgLMPw/WNLmazvyanyVyuVzg2kCJKAs9czgcSyKuABP7gLGdYFXBZdQmbc4Sud1uCCFw79KzhoaGbNGVMuCiGWzN/gKyOPYgraT/n2jcDsw4wB7YtZc2l30EWVkadmNjI+LxOBKJBGRZRiqVMmo9y5qRcbXPtTm1gz1SfpJe/OyUJlIzIrPZDKvVauDz+dDd3Z3p9W9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LGdYFXBZdQmbc4Sud1uCCFw79KzhoaGbNGVMuCiGWzN/gKyOPYgraT/n2jcDsw4wB7YtZc2l30EWVkadmNjI+LxOBKJBGRZRiqVMmo9y5qRcbXPtTm1gz1SfpJe/OyUJlIzIrPZDKvVauDz+dDd3Z3p9W9Lw1aBm98AbWVga+uuUoFrDLL67++ot7f3P98RCQ5M+YDKN8Fe6rpBr3muYzqewl+RCCRJyiIajRq//t589k4EFJkGOg9CqdkFVjwoUeHQDEp++APH4jK+TalIys1QUyegJrzgC2fBE2e1egCqfBuqEjfgMU3SUg44LRgrfwWs4lJfbPetGN7WTnQldQzTih08+QlI526VhhMkh7T9JuiC1vcchNBYaH4Pl9/YiL7tT2Pf+py7rH9w++lBf0G6PVCBawMmSAPbIPkskC7ugRSuhBTUOH4IUvWHkGxbIZW8gA5zHuq2PYX3N6zCW2tWKsW5y+uZv++JtcO+dTXDnU9Gh6ufE/5FvioQ/qHDwn/mA+G3Piv8+RsyVKzPEUW5K8SOx5bHdjz6UN2rD7NV/wATxK/x0owARwAAAABJRU5ErkJggg==",
extensionsAffected = {};

function ThemeAchievement(){
this.calculate = function(extensions){
Expand All @@ -13,6 +14,7 @@ define(function(require, exports, module){
_.each(extensions, _.bind(function(extension){
var bracketsExtension = ExtensionsService.get(extension._id);
if (bracketsExtension && bracketsExtension.metadata && bracketsExtension.metadata.theme){
extensionsAffected[extension._id] = true;
this.writeBadge(null, extension);
console.log(extension._id);
}
Expand All @@ -27,6 +29,7 @@ define(function(require, exports, module){
}
}

ThemeAchievement.extensions = extensionsAffected;
ThemeAchievement.prototype = Achievement;
module.exports = ThemeAchievement;
});
1 change: 1 addition & 0 deletions extension/locale/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define(function (require, exports, module){
daily: 'downloads yesterday', //0.3.0
stars: 'Stars', //0.4.0
forks: 'Forks', //0.4.0
themes: 'Themes', //0.5.0

/*BADGES - 0.3.2*/
badgeAdobe: 'Adobe',
Expand Down
27 changes: 25 additions & 2 deletions extension/services/mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ define(function (require, exports, module){
dialogId = '.extension-manager-dialog.modal',
extensionService = require('./extensions'),
downloadsTemplate = require('text!../templates/downloads.html'),
ThemeAchievement = require('../achievements/theme'),
selectTemplate = _.template(require('text!../templates/sortButton.html'),{
sortby: locale.get('sortby'),
author: locale.get('author'),
Expand All @@ -15,7 +16,8 @@ define(function (require, exports, module){
trending: locale.get('trending'),
name: locale.get('name'),
stars: locale.get('stars'),
forks: locale.get('forks')
forks: locale.get('forks'),
themes: locale.get('themes')
});

function init(){
Expand Down Expand Up @@ -151,6 +153,10 @@ define(function (require, exports, module){
$t.attr('data-extension-yesterday', dailyDownloads? dailyDownloads : 0);
$t.attr('data-extension-stars', stars);
$t.attr('data-extension-forks', forks);

if (ThemeAchievement.extensions[id]){
$t.attr('data-extension-theme', true);
}
});
}

Expand Down Expand Up @@ -281,13 +287,30 @@ define(function (require, exports, module){
return -parseInt($(el).attr('data-extension-forks'));
});
}
}
};

var workaroundHandlers = {
'default': function(elements){
$(elements).show();
},
'themes': function(elements){
_.each(elements, function(element){
var $e = $(element);
if ($e.attr('data-extension-theme') != 'true'){
$e.hide();
}
});
}
};

function sort(criteria){
var handler = sortHandlers[criteria],
workaroundHandler = workaroundHandlers[criteria] || workaroundHandlers.default;
holder = $(dialogId).find('.extension-list.active tbody'),
elements = holder.find('tr');

workaroundHandler(elements);

if (typeof handler !== 'function'){ return; }

holder.empty();
Expand Down
6 changes: 3 additions & 3 deletions extension/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ span.ext-daily{

.ext-badges > .ext-badge-theme{
margin-left: 0px;
padding-left: 0px;
padding: 0px;
}

.fa{
Expand All @@ -72,7 +72,7 @@ span.ext-daily{

.fa-code-fork {
position: relative;
top: 2px;
top: 2px;
}

.ext-stars, .ext-forks{
Expand All @@ -87,7 +87,7 @@ span.ext-daily{
}

.ext-name {
margin-bottom: 3px !important;
margin-bottom: 3px !important;
}

.ext-info {
Expand Down
1 change: 1 addition & 0 deletions extension/templates/sortButton.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<option value="downloads">${downloads}</option>
<option value="forks">${forks}</option>
<option value="name">${name}</option>
<option value="themes">${themes}</option>
<option value="trending">${trending}</option>
<option value="stars">${stars}</option>
<option value="update">${update}</option>
Expand Down

0 comments on commit 206c982

Please sign in to comment.