Permalink
Browse files

+ JS code now more customizable

  • Loading branch information...
1 parent a7f877c commit 1ae4aade9a73e36e5d7cd63dbec4ec175470ca4f @floere committed Jan 30, 2012

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.
@@ -103,8 +103,6 @@ function AllocationRenderer(allocationChosenCallback, config) {
var word = original_token[2];
if (formatting.filter) { word = formatting.filter(word); }
-
- console.log(word);
var explanation = explanations[category] || category;
if (single && !(formatting && formatting.ignoreSingle)) {
@@ -1,6 +1,6 @@
var PickyAllocationsCloud = function(view, config) {
- var allocations = $('#picky .allocations');
+ var allocations = $(config['allocationsSelector'] || '#picky .allocations');
var shownAllocations = allocations.find('.shown');
var showMoreAllocations = allocations.find('.more');
var hiddenAllocations = allocations.find('.hidden');
@@ -1,5 +1,6 @@
var PickyResultsRenderer = function(addination, config) {
+ var results = $(config['resultsSelector'] || '#picky div.results');
var allocationWrapper = config['wrapResults'] || '<ol class="results"></ol>';
// Adds asterisks to the last token.
@@ -98,9 +99,6 @@ var PickyResultsRenderer = function(addination, config) {
// Render results with the data.
//
this.render = function(data) {
- // TODO Extract, also from view.
- //
- var results = $('#picky div.results');
data.allocations.each(function(i, allocation) {
// Only render if there is something to render.
// TODO Move into methods.
@@ -5,14 +5,15 @@ var PickyView = function(picky_controller, config) {
var showResultsLimit = config.showResultsLimit || 10;
- var searchField = $('#picky input.query');
- var clearButton = $('#picky div.reset');
- var searchButton = $('#picky input.search_button');
- var resultCounter = $('#picky div.status');
- var dashboard = $('#picky .dashboard');
-
- var results = $('#picky .results'); // Push into results.
- var noResults = $('#picky .no_results');
+ var searchField = $(config['inputSelector'] || '#picky input.query');
+ var clearButton = $(config['resetSelector'] || '#picky div.reset');
+ var searchButton = $(config['buttonSelector'] || '#picky input.search_button');
+ var resultCounter = $(config['counterSelector'] || '#picky div.status');
+ var dashboard = $(config['dashboardSelector'] || '#picky .dashboard');
+
+ // Push into results.
+ var results = $(config['resultsSelector'] || '#picky div.results');
+ var noResults = $(config['noResultsSelector'] || '#picky .no_results');
var addination = new PickyAddination(this, results); // Push into results.
@@ -103,8 +103,6 @@ function AllocationRenderer(allocationChosenCallback, config) {
var word = original_token[2];
if (formatting.filter) { word = formatting.filter(word); }
-
- console.log(word);
var explanation = explanations[category] || category;
if (single && !(formatting && formatting.ignoreSingle)) {
@@ -1,6 +1,6 @@
var PickyAllocationsCloud = function(view, config) {
- var allocations = $('#picky .allocations');
+ var allocations = $(config['allocationsSelector'] || '#picky .allocations');
var shownAllocations = allocations.find('.shown');
var showMoreAllocations = allocations.find('.more');
var hiddenAllocations = allocations.find('.hidden');
@@ -38,7 +38,7 @@ function Allocations(allocations) {
this.length = this.allocations.length;
this.each = function(callback) {
- return $.each(this.allocations, callback);
+ return this.allocations.each(callback);
};
};
@@ -12,4 +12,15 @@ Array.prototype.include = function(val) {
Array.prototype.remove = function(index) {
this.splice(index, 1);
return this;
-};
+};
+
+Array.prototype.compare = function(other) {
+ return this.join('') == other.join('');
+};
+
+Array.prototype.each = function(callback) {
+ for(var i = 0, l = this.length; i < l; i++) {
+ callback(i, this[i]);
+ }
+ return this;
+}
@@ -1,5 +1,6 @@
var PickyResultsRenderer = function(addination, config) {
+ var results = $(config['resultsSelector'] || '#picky div.results');
var allocationWrapper = config['wrapResults'] || '<ol class="results"></ol>';
// Adds asterisks to the last token.
@@ -98,9 +99,6 @@ var PickyResultsRenderer = function(addination, config) {
// Render results with the data.
//
this.render = function(data) {
- // TODO Extract, also from view.
- //
- var results = $('#picky div.results');
data.allocations.each(function(i, allocation) {
// Only render if there is something to render.
// TODO Move into methods.
@@ -5,14 +5,15 @@ var PickyView = function(picky_controller, config) {
var showResultsLimit = config.showResultsLimit || 10;
- var searchField = $('#picky input.query');
- var clearButton = $('#picky div.reset');
- var searchButton = $('#picky input.search_button');
- var resultCounter = $('#picky div.status');
- var dashboard = $('#picky .dashboard');
-
- var results = $('#picky .results'); // Push into results.
- var noResults = $('#picky .no_results');
+ var searchField = $(config['inputSelector'] || '#picky input.query');
+ var clearButton = $(config['resetSelector'] || '#picky div.reset');
+ var searchButton = $(config['buttonSelector'] || '#picky input.search_button');
+ var resultCounter = $(config['counterSelector'] || '#picky div.status');
+ var dashboard = $(config['dashboardSelector'] || '#picky .dashboard');
+
+ // Push into results.
+ var results = $(config['resultsSelector'] || '#picky div.results');
+ var noResults = $(config['noResultsSelector'] || '#picky .no_results');
var addination = new PickyAddination(this, results); // Push into results.
Oops, something went wrong.

0 comments on commit 1ae4aad

Please sign in to comment.