Created
December 16, 2014 15:05
-
-
Save anonymous/749f37045f85454b680e to your computer and use it in GitHub Desktop.
A quick Backbone.View to handle a sort caret icon; depends on FontAwesome.
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
class App.Views.SortCaret extends Backbone.View | |
tagName: 'span' | |
classname: 'sort-caret-container' | |
downCaret: 'fa-caret-down' | |
upCaret: 'fa-caret-up' | |
constructor: (options = {}) -> | |
this.downCaret = options.downCaret if options.downCaret | |
this.upCaret = options.upCaret if options.upCaret | |
super(options) | |
render: () -> | |
this._insertIcon() | |
this.setDownCaret() | |
return this | |
setDownCaret: () -> this._setCaret this.downCaret, this.upCaret | |
setUpCaret: () -> this._setCaret this.upCaret, this.downCaret | |
_insertIcon: () -> | |
@icon = $('<i class="sort-caret fa" />') | |
this.$el.html @icon | |
return | |
_setCaret: (addCaret, removeCaret) -> | |
@icon.removeClass removeCaret | |
@icon.addClass addCaret | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment