This file contains hidden or 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
function countCSSRules() { | |
var results = '', | |
log = ''; | |
if (!document.styleSheets) { | |
return; | |
} | |
for (var i = 0; i < document.styleSheets.length; i++) { | |
countSheet(document.styleSheets[i]); | |
} | |
function countSheet(sheet) { |
This file contains hidden or 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
var compileTemplates = function() { | |
_.each(App.Views, function(View) { | |
if (View.prototype.templateId) { | |
// The templateId references the id of a DOM element containing | |
// the content of the template | |
var html = jQuery('#' + View.prototype.templateId).html() || ''; | |
View.prototype.template = _.template(html); | |
} | |
}); | |
} |
This file contains hidden or 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
// main.js | |
App = { | |
// Namespaces | |
Collections: {}, | |
Models: {}, | |
Views: {}, | |
Mixins: {}, | |
initialize: function() { | |
this.comments = new App.Collections.Comments({ model: App.Models.Comment }); |
This file contains hidden or 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
// main.js | |
App = _.extend({}, Backbone.Events, { | |
... | |
}); |
This file contains hidden or 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
defaults: { | |
ajaxTimeout: 15000, | |
autoUpdateAlertTimeShown: 6500, | |
editTimeWindow: 90, | |
maxIndentationDepth: 30, | |
showAutoUpdateAlert: true, | |
showAvatars: true, | |
showSignatures: true, | |
showImages: true, | |
sortMethod: 'ancestry' |
This file contains hidden or 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
App.Mixins.Ajax = { | |
... | |
}; | |
App.Models.Comment = Backbone.extend(_.extend({}, | |
// Mixins | |
App.Mixins.Ajax, { | |
// Methods | |
initialize: function() { |
This file contains hidden or 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
App.Mixins.Ajax = { | |
// Override urls in the target object to contain a map of | |
// actionName => /url/path/with/:bound/:segments | |
urls: {}, | |
// Any options specified here are merged with those you pass to | |
// this.ajax({...}) before being passed to jQuery.ajax | |
ajaxOptions: {}, | |
// Return the matching url from the 'urls' object, with /:path/:segments |
This file contains hidden or 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
App.Views.CommentList = Backbone.View.extend({ | |
childrenById: {}, | |
childSelector: 'div', | |
childView: function() { | |
return App.Views.Comment; | |
}, | |
// Bind child event handlers once, instead of once per child view | |
delegateEvents: function() { | |
// Call super |
This file contains hidden or 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
App.Models.Comment = Backbone.Model.extend(_.extend({}, App.Mixins.Ajax, { | |
urls: { | |
flag: '/comments/flag_comment/:id' | |
}, | |
flag: function(formData) { | |
this.set('is_flagged', true); | |
return this.ajax('flag', { | |
data: formData, | |
error: function() { |
This file contains hidden or 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
function goTo(page) { | |
var callback = function(e, adMarkup) { | |
if (page < bb.current) { | |
// Insert AFTER the requested page, if moving backwards | |
page += 1; | |
} | |
insertAdBeforePage(adMarkup, page); | |
}; | |
$(document).on('renderTentpoleFeatureAd', callback); | |
$(document).trigger('tentpoleFeaturePageFlip', pagesSeen, bb.current, page); |
OlderNewer