forked from berkmancenter/tagteam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Patrick Lewis
committed
Feb 14, 2018
1 parent
40731e7
commit da8a744
Showing
6 changed files
with
582 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* globals $ */ | ||
this.observeTagFilterControls = function () { | ||
$('#reset-filter').click(function (e) { | ||
$('#tag-cloud li').show() | ||
$('#filter-by').val('') | ||
}) | ||
|
||
var filterStuff = function (e) { | ||
if (e !== '') { | ||
e.preventDefault() | ||
} | ||
|
||
$('#tag-cloud li').show() | ||
|
||
var filterVal = $('#filter-by').val() | ||
var filterregex = new RegExp(filterVal, 'i') | ||
|
||
$('#tag-cloud li').each(function () { | ||
if (!$(this).find('.tag').html().match(filterregex)) { | ||
$(this).hide() | ||
} | ||
}) | ||
} | ||
|
||
$('#filter-button').click(filterStuff) | ||
$('#filter-by').observe_field(1, filterStuff) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* globals $ */ | ||
this.observeTagSortControls = function () { | ||
var sortTagsOnChange = function (e) { | ||
var sortBy = $('#sort-tags-by').val() | ||
var sort = $('#sort-tags-direction').val() | ||
|
||
var mappingFunction = function (elem) { | ||
var attributes = {} | ||
|
||
attributes.frequency = $(elem).find('.tag').data('tag-frequency') | ||
attributes.name = $(elem).find('.tag').data('tag-name').toString() | ||
|
||
return attributes | ||
} | ||
|
||
var compareFunction = function (a, b) { | ||
if (sortBy === 'frequency' && sort === 'desc') { | ||
return (b.value.frequency - a.value.frequency) || (b.value.frequency === a.value.frequency && a.value.name.localeCompare(b.value.name)) | ||
} else if (sortBy === 'frequency' && sort === 'asc') { | ||
return (a.value.frequency - b.value.frequency) || (b.value.frequency === a.value.frequency && a.value.name.localeCompare(b.value.name)) | ||
} else if (sortBy === 'alpha' && sort === 'asc') { | ||
return a.value.name.localeCompare(b.value.name) | ||
} else if (sortBy === 'alpha' && sort === 'desc') { | ||
return b.value.name.localeCompare(a.value.name) | ||
} else { | ||
return null | ||
} | ||
} | ||
|
||
$('#tag-cloud').detach(function () { | ||
$(this).sortChildren(mappingFunction, compareFunction) | ||
}) | ||
} | ||
|
||
$('#sort-tags-by').change(sortTagsOnChange) | ||
$('#sort-tags-direction').change(sortTagsOnChange) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.