diff --git a/index.html b/index.html index ed15d24e..8a0a6871 100644 --- a/index.html +++ b/index.html @@ -1,24 +1,25 @@ - + + Enhanced History - - - - - + + + + + - - + + +
- @@ -26,8 +27,6 @@ - - @@ -63,9 +62,10 @@ - + - + + diff --git a/manifest.json b/manifest.json index ac7a0972..f3b28ee3 100644 --- a/manifest.json +++ b/manifest.json @@ -1,13 +1,10 @@ { "background": { "scripts": [ - "bower_components/honeybadger.js/honeybadger.js", "bower_components/chrome-sync/chrome_sync.js", "bower_components/underscore/underscore-min.js", "scripts/namespace.js", "scripts/config.js", - "scripts/lib/error_tracker.js", - "scripts/lib/analytics_tracker.js", "scripts/chrome/page_context_menu.js", "scripts/chrome/selection_context_menu.js", "scripts/chrome/omnibox.js", @@ -57,5 +54,5 @@ "webRequest", "webRequestBlocking" ], - "version": "3.9.10.5" + "version": "3.9.11.0" } diff --git a/scripts/chrome/browser_actions.js b/scripts/chrome/browser_actions.js index 8c958216..46fa3bdc 100644 --- a/scripts/chrome/browser_actions.js +++ b/scripts/chrome/browser_actions.js @@ -1,29 +1,22 @@ (function() { - var BrowserActions = function(options) { - if(!options.chrome) { - throw("Chrome API not set"); - } - if(!options.tracker) { - throw("Tracker not set"); - } +var BrowserActions = function(options) { + if (!options.chrome) { + throw ("Chrome API not set"); + } - this.chromeAPI = options.chrome; - this.tracker = options.tracker; - }; + this.chromeAPI = options.chrome; +}; - BrowserActions.prototype.listen = function() { - var _this = this; - if(this.chromeAPI.browserAction) { - this.chromeAPI.browserAction.onClicked.addListener(function() { - _this.openHistory(); - }); - } - }; +BrowserActions.prototype.listen = function() { + var _this = this; + if (this.chromeAPI.browserAction) { + this.chromeAPI.browserAction.onClicked.addListener( + function() { _this.openHistory(); }); + } +}; - BrowserActions.prototype.openHistory = function() { - this.tracker.browserActionClick(); - this.chromeAPI.tabs.create({url: 'chrome://history'}); - }; +BrowserActions.prototype.openHistory = + function() { this.chromeAPI.tabs.create({url : 'chrome://history'}); }; - BH.Chrome.BrowserActions = BrowserActions; +BH.Chrome.BrowserActions = BrowserActions; })(); diff --git a/scripts/chrome/omnibox.js b/scripts/chrome/omnibox.js index 160f822d..677c8309 100644 --- a/scripts/chrome/omnibox.js +++ b/scripts/chrome/omnibox.js @@ -1,51 +1,39 @@ (function() { - var Omnibox = function(options) { - if(!options.chrome) { - throw("Chrome API not set"); - } - if(!options.tracker) { - throw("Tracker not set"); - } +var Omnibox = function(options) { + if (!options.chrome) { + throw ("Chrome API not set"); + } - this.chromeAPI = options.chrome; - this.tracker = options.tracker; - }; + this.chromeAPI = options.chrome; +}; - Omnibox.prototype.listen = function() { - if(this.chromeAPI.omnibox) { - var _this = this; - this.chromeAPI.omnibox.onInputChanged.addListener(function(text, suggest) { - _this.setDefaultSuggestion(text); - }); +Omnibox.prototype.listen = function() { + if (this.chromeAPI.omnibox) { + var _this = this; + this.chromeAPI.omnibox.onInputChanged.addListener(function( + text, suggest) { _this.setDefaultSuggestion(text); }); - this.chromeAPI.omnibox.onInputEntered.addListener(function(text) { - _this.tracker.omniboxSearch(); - _this.getActiveTab(function(tabId) { - _this.updateTabURL(tabId, text); - }); - }); - } - }; + this.chromeAPI.omnibox.onInputEntered.addListener(function(text) { + _this.getActiveTab(function(tabId) { _this.updateTabURL(tabId, text); }); + }); + } +}; - Omnibox.prototype.setDefaultSuggestion = function(text) { - if(this.chromeAPI.omnibox) { - this.chromeAPI.omnibox.setDefaultSuggestion({ - description: "Search " + text + " in history" - }); - } - }; +Omnibox.prototype.setDefaultSuggestion = function(text) { + if (this.chromeAPI.omnibox) { + this.chromeAPI.omnibox.setDefaultSuggestion( + {description : "Search " + text + " in history"}); + } +}; - Omnibox.prototype.getActiveTab = function(callback) { - this.chromeAPI.tabs.query({active: true, currentWindow: true}, function(tabs) { - callback(tabs[0].id); - }); - }; +Omnibox.prototype.getActiveTab = function(callback) { + this.chromeAPI.tabs.query({active : true, currentWindow : true}, + function(tabs) { callback(tabs[0].id); }); +}; - Omnibox.prototype.updateTabURL = function(tabId, text) { - this.chromeAPI.tabs.update(tabId, { - url: "chrome://history/#search/" + text - }); - }; +Omnibox.prototype.updateTabURL = function(tabId, text) { + this.chromeAPI.tabs.update(tabId, {url : "chrome://history/#search/" + text}); +}; - BH.Chrome.Omnibox = Omnibox; +BH.Chrome.Omnibox = Omnibox; })(); diff --git a/scripts/chrome/page_context_menu.js b/scripts/chrome/page_context_menu.js index aca8b0eb..6b78f6cf 100644 --- a/scripts/chrome/page_context_menu.js +++ b/scripts/chrome/page_context_menu.js @@ -1,104 +1,97 @@ (function() { - var getDomain = function(url) { - var match = url.match(/\w+:\/\/(.*?)\//); - if(match) { - return match[1].replace('www.', ''); +var getDomain = function(url) { + var match = url.match(/\w+:\/\/(.*?)\//); + if (match) { + return match[1].replace('www.', ''); + } + return false; +}; + +var PageContextMenu = function(options) { + if (!options.chrome) { + throw ("Chrome API not set"); + } + + this.chromeAPI = options.chrome; + + this.id = 'better_history_page_context_menu'; +}; + +PageContextMenu.prototype.create = function() { + this.menu = this.chromeAPI.contextMenus.create({ + title : this.chromeAPI.i18n.getMessage('visits_to_domain', [ 'domain' ]), + contexts : [ 'page' ], + id : this.id + }); + + var _this = this; + this.chromeAPI.contextMenus.onClicked.addListener(function( + data) { _this.onClick(data); }); +}; + +PageContextMenu.prototype.onClick = function(data) { + if (data.menuItemId === this.id) { + var domain = getDomain(data.pageUrl); + + url = "chrome://history/#search"; + if (domain) { + url += '/' + domain; } - return false; - }; - - var PageContextMenu = function(options) { - if(!options.chrome) { - throw("Chrome API not set"); - } - if(!options.tracker) { - throw("Tracker not set"); - } - - this.chromeAPI = options.chrome; - this.tracker = options.tracker; - - this.id = 'better_history_page_context_menu'; - }; - - PageContextMenu.prototype.create = function() { - this.menu = this.chromeAPI.contextMenus.create({ - title: this.chromeAPI.i18n.getMessage('visits_to_domain', ['domain']), - contexts: ['page'], - id: this.id - }); - var _this = this; - this.chromeAPI.contextMenus.onClicked.addListener(function(data) { - _this.onClick(data); - }); - }; - - PageContextMenu.prototype.onClick = function(data) { - if(data.menuItemId === this.id) { - var domain = getDomain(data.pageUrl); - - url = "chrome://history/#search"; - if(domain) { - url += '/' + domain; - } - - this.tracker.contextMenuClick(); - - this.chromeAPI.tabs.create({url: url}); + this.chromeAPI.tabs.create({url : url}); + } +}; + +PageContextMenu.prototype.updateTitleDomain = function(tab) { + if (tab) { + var domain = getDomain(tab.url); + if (domain) { + this.chromeAPI.contextMenus.update(this.menu, { + title : this.chromeAPI.i18n.getMessage('visits_to_domain', [ domain ]) + }); } - }; - - PageContextMenu.prototype.updateTitleDomain = function(tab) { - if(tab) { - var domain = getDomain(tab.url); - if(domain) { - this.chromeAPI.contextMenus.update(this.menu, { - title: this.chromeAPI.i18n.getMessage('visits_to_domain', [domain]) - }); - } - } - }; - - PageContextMenu.prototype.listenToTabs = function() { - if(this.chromeAPI.tabs) { - var _this = this; - - if(this.chromeAPI.tabs.onActivated) { - this.chromeAPI.tabs.onActivated.addListener(function(tabInfo) { - if(_this.menu) { - _this.onTabSelectionChanged(tabInfo.tabId); - } - }); - } - - if(this.chromeAPI.tabs.onUpdated) { - this.chromeAPI.tabs.onUpdated.addListener(function(tabId, changedInfo, tab) { - if(_this.menu) { - _this.onTabUpdated(tab); - } - }); - } - } - }; + } +}; - PageContextMenu.prototype.onTabSelectionChanged = function(tabId) { +PageContextMenu.prototype.listenToTabs = function() { + if (this.chromeAPI.tabs) { var _this = this; - this.chromeAPI.tabs.get(tabId, function(tab) { - _this.updateTitleDomain(tab); - }); - }; - - PageContextMenu.prototype.onTabUpdated = function(tab) { - if(tab && tab.selected) { - this.updateTitleDomain(tab); - } - }; - PageContextMenu.prototype.remove = function() { - this.chromeAPI.contextMenus.remove(this.menu); - delete(this.menu); - }; + if (this.chromeAPI.tabs.onActivated) { + this.chromeAPI.tabs.onActivated.addListener(function(tabInfo) { + if (_this.menu) { + _this.onTabSelectionChanged(tabInfo.tabId); + } + }); + } - BH.Chrome.PageContextMenu = PageContextMenu; + if (this.chromeAPI.tabs.onUpdated) { + this.chromeAPI.tabs.onUpdated.addListener(function(tabId, changedInfo, + tab) { + if (_this.menu) { + _this.onTabUpdated(tab); + } + }); + } + } +}; + +PageContextMenu.prototype.onTabSelectionChanged = function(tabId) { + var _this = this; + this.chromeAPI.tabs.get(tabId, + function(tab) { _this.updateTitleDomain(tab); }); +}; + +PageContextMenu.prototype.onTabUpdated = function(tab) { + if (tab && tab.selected) { + this.updateTitleDomain(tab); + } +}; + +PageContextMenu.prototype.remove = function() { + this.chromeAPI.contextMenus.remove(this.menu); + delete (this.menu); +}; + +BH.Chrome.PageContextMenu = PageContextMenu; })(); diff --git a/scripts/chrome/selection_context_menu.js b/scripts/chrome/selection_context_menu.js index 0b8de5b8..c445b9e6 100644 --- a/scripts/chrome/selection_context_menu.js +++ b/scripts/chrome/selection_context_menu.js @@ -1,46 +1,39 @@ (function() { - var SelectionContextMenu = function(options) { - if(!options.chrome) { - throw("Chrome API not set"); - } - if(!options.tracker) { - throw("Tracker not set"); - } +var SelectionContextMenu = function(options) { + if (!options.chrome) { + throw ("Chrome API not set"); + } - this.chromeAPI = options.chrome; - this.tracker = options.tracker; + this.chromeAPI = options.chrome; - this.id = 'better_history_selection_context_menu'; - }; + this.id = 'better_history_selection_context_menu'; +}; - SelectionContextMenu.prototype.create = function() { - if(this.chromeAPI.contextMenus && this.chromeAPI.contextMenus.create) { - this.menu = this.chromeAPI.contextMenus.create({ - title: this.chromeAPI.i18n.getMessage('search_in_history'), - contexts: ['selection'], - id: this.id - }); +SelectionContextMenu.prototype.create = function() { + if (this.chromeAPI.contextMenus && this.chromeAPI.contextMenus.create) { + this.menu = this.chromeAPI.contextMenus.create({ + title : this.chromeAPI.i18n.getMessage('search_in_history'), + contexts : [ 'selection' ], + id : this.id + }); - var _this = this; - this.chromeAPI.contextMenus.onClicked.addListener(function(data) { - _this.onClick(data); - }); - } - }; + var _this = this; + this.chromeAPI.contextMenus.onClicked.addListener(function( + data) { _this.onClick(data); }); + } +}; - SelectionContextMenu.prototype.onClick = function(data) { - if(data.menuItemId === this.id) { - this.tracker.selectionContextMenuClick(); - this.chromeAPI.tabs.create({ - url: "chrome://history/#search/" + data.selectionText - }); - } - }; +SelectionContextMenu.prototype.onClick = function(data) { + if (data.menuItemId === this.id) { + this.chromeAPI.tabs.create( + {url : "chrome://history/#search/" + data.selectionText}); + } +}; - SelectionContextMenu.prototype.remove = function() { - this.chromeAPI.contextMenus.remove(this.menu); - delete(this.menu); - }; +SelectionContextMenu.prototype.remove = function() { + this.chromeAPI.contextMenus.remove(this.menu); + delete (this.menu); +}; - BH.Chrome.SelectionContextMenu = SelectionContextMenu; +BH.Chrome.SelectionContextMenu = SelectionContextMenu; })(); diff --git a/scripts/initialize_background.js b/scripts/initialize_background.js index ad1e5447..4c6d27ed 100644 --- a/scripts/initialize_background.js +++ b/scripts/initialize_background.js @@ -1,53 +1,44 @@ (function() { - var errorTracker = new BH.Lib.ErrorTracker(Honeybadger), - analyticsTracker = new BH.Lib.AnalyticsTracker(); - - load = function() { - var browserActions = new BH.Chrome.BrowserActions({ - chrome: chrome, - tracker: analyticsTracker - }); - browserActions.listen(); - - var omnibox = new BH.Chrome.Omnibox({ - chrome: chrome, - tracker: analyticsTracker - }); - omnibox.listen(); - - window.selectionContextMenu = new BH.Chrome.SelectionContextMenu({ - chrome: chrome, - tracker: analyticsTracker - }); - - window.pageContextMenu = new BH.Chrome.PageContextMenu({ - chrome: chrome, - tracker: analyticsTracker - }); - pageContextMenu.listenToTabs(); - - new ChromeSync().get('settings', function(data) { - var settings = data.settings || {}; - - if(settings.searchBySelection !== false) { - selectionContextMenu.create(); - } - - if(settings.searchByDomain !== false) { - pageContextMenu.create(); - } - }); - }; - - if(BH.config.env === 'prod') { - try { - load(); +load = function() { + var browserActions = new BH.Chrome.BrowserActions({ + chrome : chrome, + }); + browserActions.listen(); + + var omnibox = new BH.Chrome.Omnibox({ + chrome : chrome, + }); + omnibox.listen(); + + window.selectionContextMenu = new BH.Chrome.SelectionContextMenu({ + chrome : chrome, + }); + + window.pageContextMenu = new BH.Chrome.PageContextMenu({ + chrome : chrome, + }); + pageContextMenu.listenToTabs(); + + new ChromeSync().get('settings', function(data) { + var settings = data.settings || {}; + + if (settings.searchBySelection !== false) { + selectionContextMenu.create(); } - catch(e) { - errorTracker.report(e); + + if (settings.searchByDomain !== false) { + pageContextMenu.create(); } - } else { + }); +}; + +if (BH.config.env === 'prod') { + try { load(); + } catch (e) { + console.log.error(e); } +} else { + load(); +} })(); - diff --git a/scripts/initialize_extension.js b/scripts/initialize_extension.js index ffe883c6..026e4948 100644 --- a/scripts/initialize_extension.js +++ b/scripts/initialize_extension.js @@ -1,53 +1,41 @@ (function() { - if(BH.config.env === 'prod') { - window.errorTracker = new BH.Lib.ErrorTracker(Honeybadger); - } - - window.analyticsTracker = new BH.Lib.AnalyticsTracker(); +var load = function() { + Historian.setWorkerPath('bower_components/chrome-historian/src/workers/'); - var load = function() { - Historian.setWorkerPath('bower_components/chrome-historian/src/workers/'); + if (chrome && chrome.i18n && chrome.i18n.getUILanguage) { + BH.lang = chrome.i18n.getUILanguage(); + } - if(chrome && chrome.i18n && chrome.i18n.getUILanguage) { - BH.lang = chrome.i18n.getUILanguage(); + Settings = Backbone.Model.extend({ + defaults : { + searchBySelection : true, + searchByDomain : true, + use24HourClock : false } + }); - analyticsTracker.historyOpen(); - - Settings = Backbone.Model.extend({ - defaults: { - searchBySelection: true, - searchByDomain: true, - use24HourClock: false - } - }); + var settings = new Settings(); + new ChromeSync().get('settings', + function(props) { settings.set(props.settings); }); - var settings = new Settings(); - new ChromeSync().get('settings', function(props) { - settings.set(props.settings); - }); + window.router = new BH.Router({ + settings : settings, + }); - window.router = new BH.Router({ - settings: settings, - tracker: analyticsTracker - }); + Backbone.history.start(); - Backbone.history.start(); + // BH.Modals.MailingListModal.prompt(function() { + // new BH.Modals.MailingListModal().open(); + // }); +}; - // BH.Modals.MailingListModal.prompt(function() { - // new BH.Modals.MailingListModal().open(); - // analyticsTracker.mailingListPrompt(); - // }); - }; - - if(BH.config.env === 'prod') { - try { - load(); - } - catch(e) { - errorTracker.report(e); - } - } else { +if (BH.config.env === 'prod') { + try { load(); + } catch (e) { + console.log.error(e); } +} else { + load(); +} })(); diff --git a/scripts/lib/analytics_tracker.js b/scripts/lib/analytics_tracker.js deleted file mode 100644 index 1d8ceb04..00000000 --- a/scripts/lib/analytics_tracker.js +++ /dev/null @@ -1,131 +0,0 @@ -(function() { - var trackEvent = function(params) { - params.unshift('_trackEvent'); - track(params); - }; - - var track = function(params) { - //_gaq.push(params); - }; - - AnalyticsTracker = function() { - //if(!_gaq) { - // throw("Analytics not set"); - //} - - //_gaq.push(['_setAccount', BH.config.analyticsKey]); - - - return { - pageView: function(url) { - // Don't track what people search for - if(url.match(/search/)) { - url = 'search'; - } - track(['_trackPageview', '/' + url]); - }, - - historyOpen: function() { - trackEvent(['History', 'Open']); - }, - - dayActivityVisitCount: function(amount) { - trackEvent(['Activity', 'Day View', 'Visit Count', amount]); - }, - - dayActivityDownloadCount: function(amount) { - trackEvent(['Activity', 'Day View', 'Download Count', amount]); - }, - - todayView: function() { - trackEvent(['Today', 'Click']); - }, - - featureNotSupported: function(feature) { - trackEvent(['Feature', 'Not Supported', feature]); - }, - - searchVisitDomain: function() { - trackEvent(['Visit', 'Search domain']); - }, - - visitDeletion: function() { - trackEvent(['Visit', 'Delete']); - }, - - downloadDeletion: function() { - trackEvent(['Download', 'Delete']); - }, - - hourDeletion: function() { - trackEvent(['Day Hour', 'Delete']); - }, - - searchResultDeletion: function() { - trackEvent(['Searched Visit', 'Delete']); - }, - - searchResultsDeletion: function() { - trackEvent(['Search results', 'Delete']); - }, - - searchDeeper: function() { - trackEvent(['Search results', 'Search deeper']); - }, - - expireCache: function() { - trackEvent(['Search results', 'Expire cache']); - }, - - paginationClick: function() { - trackEvent(['Pagination', 'Click']); - }, - - deviceClick: function() { - trackEvent(['Device', 'Click']); - }, - - omniboxSearch: function() { - trackEvent(['Omnibox', 'Search']); - }, - - browserActionClick: function() { - trackEvent(['Browser action', 'Click']); - }, - - contextMenuClick: function() { - trackEvent(['Context menu', 'Click']); - }, - - selectionContextMenuClick: function() { - trackEvent(['Selection context menu', 'Click']); - }, - - syncStorageError: function(operation, msg) { - trackEvent(['Storage Error', operation, 'Sync', msg]); - }, - - syncStorageAccess: function(operation) { - trackEvent(['Storage Access', operation, 'Sync']); - }, - - localStorageError: function(operation, msg) { - trackEvent(['Storage Error', operation, 'Local', msg]); - }, - - mailingListPrompt: function() { - trackEvent(['Mailing List Prompt', 'Seen']); - }, - - searchTipsModalOpened: function() { - trackEvent(['Search Tips Modal', 'Open']); - }, - - hourClick: function(hour) { - trackEvent(['Visits', 'Hour Click', hour]); - } - }; - }; - - BH.Lib.AnalyticsTracker = AnalyticsTracker; -})(); diff --git a/scripts/lib/error_tracker.js b/scripts/lib/error_tracker.js deleted file mode 100644 index ca043fe5..00000000 --- a/scripts/lib/error_tracker.js +++ /dev/null @@ -1,17 +0,0 @@ -(function() { - var ErrorTracker = function(tracker) { - // this.tracker = tracker; - // this.tracker.setContext({version: BH.version}); - // this.tracker.configure({ - // api_key: BH.config.errorKey, - // environment: BH.config.env, - // onerror: true - // }); - }; - - ErrorTracker.prototype.report = function(e, data) { - // this.tracker.notify(e, {context: data}); - }; - - BH.Lib.ErrorTracker = ErrorTracker; -})(); diff --git a/scripts/modals/search_tips_modal.js b/scripts/modals/search_tips_modal.js index 45d0b718..bdc067c3 100644 --- a/scripts/modals/search_tips_modal.js +++ b/scripts/modals/search_tips_modal.js @@ -1,40 +1,32 @@ (function() { - var SearchTipsModal = BH.Modals.Base.extend({ - className: 'search_tips_view modal', - template: 'search_tips.html', +var SearchTipsModal = BH.Modals.Base.extend({ + className : 'search_tips_view modal', + template : 'search_tips.html', - events: { - 'click .close': 'closeClicked', - 'click .content-area a': 'linkClicked' - }, + events : { + 'click .close' : 'closeClicked', + 'click .content-area a' : 'linkClicked' + }, - initialize: function() { - this.attachGeneralEvents(); - }, + initialize : function() { this.attachGeneralEvents(); }, - render: function() { - this.$el.html(this.renderTemplate(this.getI18nValues())); - analyticsTracker.searchTipsModalOpened(); - return this; - }, + render : function() { + this.$el.html(this.renderTemplate(this.getI18nValues())); + return this; + }, - closeClicked: function(ev) { - ev.preventDefault(); - this.close(); - }, + closeClicked : function(ev) { + ev.preventDefault(); + this.close(); + }, - linkClicked: function(ev) { - this.close(); - }, + linkClicked : function(ev) { this.close(); }, - getI18nValues: function() { - return BH.Chrome.I18n.t([ - 'close_button', - 'search_tips_title', - 'search_suggestion_link' - ]); - } - }); + getI18nValues : function() { + return BH.Chrome.I18n.t( + [ 'close_button', 'search_tips_title', 'search_suggestion_link' ]); + } +}); - BH.Modals.SearchTipsModal = SearchTipsModal; +BH.Modals.SearchTipsModal = SearchTipsModal; })(); diff --git a/scripts/namespace.js b/scripts/namespace.js index aa94dd90..b5d4f6ac 100644 --- a/scripts/namespace.js +++ b/scripts/namespace.js @@ -1,16 +1,15 @@ this.BH = { - Views: {}, - Modals: {}, - Lib: {}, - Trackers: {}, - Presenters: {}, - Templates: {}, - Init: {}, - Chrome: {}, - lang: 'en', - version: null + Views : {}, + Modals : {}, + Lib : {}, + Presenters : {}, + Templates : {}, + Init : {}, + Chrome : {}, + lang : 'en', + version : null }; -if(chrome && chrome.runtime && chrome.runtime.getManifest) { +if (chrome && chrome.runtime && chrome.runtime.getManifest) { this.BH.version = chrome.runtime.getManifest().version; } diff --git a/scripts/router.js b/scripts/router.js index 4543dc7b..aebb5288 100644 --- a/scripts/router.js +++ b/scripts/router.js @@ -1,164 +1,156 @@ (function() { - var Router = Backbone.Router.extend({ - routes: { - '': 'visits', - 'devices': 'devices', - 'statistic': 'statistic', - 'settings': 'settings', - 'search(/*query)': 'search', - 'visits(/:date)': 'visits' - }, - - initialize: function(options) { - settings = options.settings; - tracker = options.tracker; - - this.cache = new BH.Views.Cache({ - settings: settings - }); +var Router = Backbone.Router.extend({ + routes : { + '' : 'visits', + 'devices' : 'devices', + 'statistic' : 'statistic', + 'settings' : 'settings', + 'search(/*query)' : 'search', + 'visits(/:date)' : 'visits' + }, - this.app = new BH.Views.AppView({ - el: $('.app') - }); - this.app.render(); + initialize : function(options) { + settings = options.settings; - this.on('route', function() { - var url = Backbone.history.getFragment(); - window.analyticsTracker.pageView(url); - }); - }, + this.cache = new BH.Views.Cache({settings : settings}); - devices: function() { - this.app.selectNav('.devices'); + this.app = new BH.Views.AppView({el : $('.app')}); + this.app.render(); - var cacheView = this.cache.view('devices'); - var view = cacheView.view; + this.on('route', function() { var url = Backbone.history.getFragment(); }); + }, - delay(cacheView.transitioning, function() { - new Historian.Devices().fetch(function(devices) { - if(devices) { - view.collection.reset(devices); - } else { - view.feature.set({supported: false}); - } - }); + devices : function() { + this.app.selectNav('.devices'); + + var cacheView = this.cache.view('devices'); + var view = cacheView.view; + + delay(cacheView.transitioning, function() { + new Historian.Devices().fetch(function(devices) { + if (devices) { + view.collection.reset(devices); + } else { + view.feature.set({supported : false}); + } }); - }, + }); + }, - visits: function(date) { - this.app.selectNav('.visits'); + visits : function(date) { + this.app.selectNav('.visits'); - if(!date) { - date = 'today'; - } + if (!date) { + date = 'today'; + } - // special cases - switch(date) { - case 'today': - date = moment(); - break; - case 'yesterday': - date = moment().subtract(1, 'days'); - break; - default: - date = moment(new Date(date)); - } + // special cases + switch (date) { + case 'today': + date = moment(); + break; + case 'yesterday': + date = moment().subtract(1, 'days'); + break; + default: + date = moment(new Date(date)); + } - date = date.startOf('day').toDate(); + date = date.startOf('day').toDate(); - var cacheView = this.cache.view('visits', [date.getTime()]); - var view = cacheView.view; + var cacheView = this.cache.view('visits', [ date.getTime() ]); + var view = cacheView.view; - view.$('.search').focus(); + view.$('.search').focus(); - delay(cacheView.transitioning, function() { - new Historian.Day(date).fetch(function(history) { - if(history) { - if(history.length !== view.collection.length) { - view.collection.reset(history); - } - } else { - view.feature.set({supported: false}); - } - }); - }); - }, - - settings: function() { - this.app.selectNav('.settings'); - this.cache.view('settings'); - }, - - search: function(query) { - this.app.selectNav('.search'); - var view = this.cache.view('search').view; - - var _this = this; - delay(true, function() { - if(query) { - view.model.set({query: decodeURIComponent(query)}); - view.historian = new Historian.Search(query); - view.historian.fetch({}, function(history, cacheDatetime) { + delay(cacheView.transitioning, function() { + new Historian.Day(date).fetch(function(history) { + if (history) { + if (history.length !== view.collection.length) { view.collection.reset(history); - if(cacheDatetime) { - view.model.set({cacheDatetime: cacheDatetime}); - } else { - view.model.unset('cacheDatetime'); - } - }); + } } else { - view.historian = new Historian.Search(); - view.historian.fetchCache(function(cache) { - if(cache && cache.query) { - _this.navigate("search/" + cache.query, {trigger: false}); - - // Only trigger data reset if cache times differ. This is to prevent data - // reload flicker between navigating to and from /#search - var cachedDatetime = view.model.get('cacheDatetime'); - if(cachedDatetime) { - if(cachedDatetime.getTime() != cache.datetime.getTime()) { - view.model.set({ - query: cache.query, - cacheDatetime: new Date(cache.datetime) - }); - view.collection.reset(cache.results); - } - } - } - }); + view.feature.set({supported : false}); } }); - }, - - statistic: function() { - this.app.selectNav('.statistic'); - - var cacheView = this.cache.view('statistic'); - var view = cacheView.view; -/* - delay(cacheView.transitioning, function() { - new Historian.Devices().fetch(function(devices) { - if(statistic) { - view.collection.reset(devices); + }); + }, + + settings : function() { + this.app.selectNav('.settings'); + this.cache.view('settings'); + }, + + search : function(query) { + this.app.selectNav('.search'); + var view = this.cache.view('search').view; + + var _this = this; + delay(true, function() { + if (query) { + view.model.set({query : decodeURIComponent(query)}); + view.historian = new Historian.Search(query); + view.historian.fetch({}, function(history, cacheDatetime) { + view.collection.reset(history); + if (cacheDatetime) { + view.model.set({cacheDatetime : cacheDatetime}); } else { - view.feature.set({supported: false}); + view.model.unset('cacheDatetime'); } }); - }); -*/ - }, - - }); - - // if we need to transition to another view, delay the query until the - // transition fires. There can be a noticeable lag if the delay is skipped - var delay = function(shouldDelay, callback) { - if(shouldDelay) { - setTimeout(function() { callback(); }, 250); - } else { - callback(); - } - }; - - BH.Router = Router; + } else { + view.historian = new Historian.Search(); + view.historian.fetchCache(function(cache) { + if (cache && cache.query) { + _this.navigate("search/" + cache.query, {trigger : false}); + + // Only trigger data reset if cache times differ. This is to prevent + // data reload flicker between navigating to and from /#search + var cachedDatetime = view.model.get('cacheDatetime'); + if (cachedDatetime) { + if (cachedDatetime.getTime() != cache.datetime.getTime()) { + view.model.set({ + query : cache.query, + cacheDatetime : new Date(cache.datetime) + }); + view.collection.reset(cache.results); + } + } + } + }); + } + }); + }, + + statistic : function() { + this.app.selectNav('.statistic'); + + var cacheView = this.cache.view('statistic'); + var view = cacheView.view; + /* + delay(cacheView.transitioning, function() { + new Historian.Devices().fetch(function(devices) { + if(statistic) { + view.collection.reset(devices); + } else { + view.feature.set({supported: false}); + } + }); + }); + */ + }, + +}); + +// if we need to transition to another view, delay the query until the +// transition fires. There can be a noticeable lag if the delay is skipped +var delay = function(shouldDelay, callback) { + if (shouldDelay) { + setTimeout(function() { callback(); }, 250); + } else { + callback(); + } +}; + +BH.Router = Router; })(); diff --git a/scripts/views/devices_list_view.js b/scripts/views/devices_list_view.js index 12bf3bd9..6661e451 100644 --- a/scripts/views/devices_list_view.js +++ b/scripts/views/devices_list_view.js @@ -1,33 +1,30 @@ (function() { - var DevicesListView = Backbone.View.extend({ - className: 'devices_list_view', +var DevicesListView = Backbone.View.extend({ + className : 'devices_list_view', - template: 'devices_list.html', + template : 'devices_list.html', - events: { - 'click a': 'deviceClicked' - }, + events : {'click a' : 'deviceClicked'}, - render: function() { - presenter = new BH.Presenters.DevicesPresenter(); - var template = BH.Lib.Template.fetch(this.template); - var html = Mustache.to_html(template, presenter.deviceList(this.collection.toJSON())); - this.$el.append(html); - return this; - }, + render : function() { + presenter = new BH.Presenters.DevicesPresenter(); + var template = BH.Lib.Template.fetch(this.template); + var html = Mustache.to_html(template, + presenter.deviceList(this.collection.toJSON())); + this.$el.append(html); + return this; + }, - deviceClicked: function(ev) { - ev.preventDefault(); - var $el = $(ev.currentTarget); + deviceClicked : function(ev) { + ev.preventDefault(); + var $el = $(ev.currentTarget); - window.analyticsTracker.deviceClick(); + this.$('.selected').removeClass('selected'); + $el.addClass('selected'); - this.$('.selected').removeClass('selected'); - $el.addClass('selected'); + this.model.set({name : $el.data('name')}); + } +}); - this.model.set({name: $el.data('name')}); - } - }); - - BH.Views.DevicesListView = DevicesListView; +BH.Views.DevicesListView = DevicesListView; })(); diff --git a/scripts/views/devices_view.js b/scripts/views/devices_view.js index c7a3be1a..7981579c 100644 --- a/scripts/views/devices_view.js +++ b/scripts/views/devices_view.js @@ -1,67 +1,56 @@ (function() { - var DevicesView = BH.Views.MainView.extend({ - className: 'devices_view with_controls', +var DevicesView = BH.Views.MainView.extend({ + className : 'devices_view with_controls', - template: 'devices.html', + template : 'devices.html', - events: { - 'keyup .search': 'onSearchTyped', - 'blur .search': 'onSearchBlurred' - }, + events : + {'keyup .search' : 'onSearchTyped', 'blur .search' : 'onSearchBlurred'}, - initialize: function() { - this.tracker = analyticsTracker; - this.collection.on('reset', this.onCollectionReset, this); + initialize : function() { + this.collection.on('reset', this.onCollectionReset, this); - this.model = new Backbone.Model(); + this.model = new Backbone.Model(); - this.feature = new Backbone.Model({supported: true}); - this.feature.on('change:supported', this.onFeatureSupportedChange, this); - }, + this.feature = new Backbone.Model({supported : true}); + this.feature.on('change:supported', this.onFeatureSupportedChange, this); + }, - pageTitle: function() { - return BH.Chrome.I18n.t('devices_title'); - }, + pageTitle : function() { return BH.Chrome.I18n.t('devices_title'); }, - render: function() { - var properties = _.extend(this.getI18nValues(), {devices: this.collection.toJSON()}); - var template = BH.Lib.Template.fetch(this.template); - var html = Mustache.to_html(template, properties); - this.$el.append(html); + render : function() { + var properties = + _.extend(this.getI18nValues(), {devices : this.collection.toJSON()}); + var template = BH.Lib.Template.fetch(this.template); + var html = Mustache.to_html(template, properties); + this.$el.append(html); - var devicesResultsView = new BH.Views.DevicesResultsView({ - model: this.model, - collection: new Backbone.Collection(), - el: this.$('.content') - }); + var devicesResultsView = new BH.Views.DevicesResultsView({ + model : this.model, + collection : new Backbone.Collection(), + el : this.$('.content') + }); - return this; - }, + return this; + }, - onCollectionReset: function() { - this.$('.devices_list_view').remove(); + onCollectionReset : function() { + this.$('.devices_list_view').remove(); - var devicesListView = new BH.Views.DevicesListView({ - collection: this.collection, - model: this.model - }); - this.$('header').append(devicesListView.render().el); + var devicesListView = new BH.Views.DevicesListView( + {collection : this.collection, model : this.model}); + this.$('header').append(devicesListView.render().el); - devicesListView.$('a').eq(0)[0].click(); - }, + devicesListView.$('a').eq(0)[0].click(); + }, - onFeatureSupportedChange: function() { - this.tracker.featureNotSupported('devices'); - this.browserFeatureNotSupported(); - }, + onFeatureSupportedChange : function() { this.browserFeatureNotSupported(); }, - getI18nValues: function() { - return BH.Chrome.I18n.t([ - 'devices_title', - 'search_input_placeholder_text' - ]); - } - }); + getI18nValues : function() { + return BH.Chrome.I18n.t( + [ 'devices_title', 'search_input_placeholder_text' ]); + } +}); - BH.Views.DevicesView = DevicesView; +BH.Views.DevicesView = DevicesView; })(); diff --git a/scripts/views/search_controls_view.js b/scripts/views/search_controls_view.js index 63bc4f11..d6b5b5e2 100644 --- a/scripts/views/search_controls_view.js +++ b/scripts/views/search_controls_view.js @@ -1,76 +1,76 @@ (function() { - var SearchControlsView = Backbone.View.extend({ - className: 'search_controls_view', - template: 'search_controls.html', +var SearchControlsView = Backbone.View.extend({ + className : 'search_controls_view', + template : 'search_controls.html', - events: { - 'click .delete_all': 'clickedDeleteAll', - 'click #search_tips': 'clickedSearchTips' - }, + events : { + 'click .delete_all' : 'clickedDeleteAll', + 'click #search_tips' : 'clickedSearchTips' + }, - initialize: function() { - this.collection.on('reset', this.onHistoryChanged, this); - this.page = new Backbone.Model({page: 1}); - }, + initialize : function() { + this.collection.on('reset', this.onHistoryChanged, this); + this.page = new Backbone.Model({page : 1}); + }, - render: function() { - var properties = _.extend(this.getI18nValues(), this.model.toJSON()); - var template = BH.Lib.Template.fetch(this.template); - var html = Mustache.to_html(template, properties); - this.$el.html(html); - return this; - }, - - onHistoryChanged: function() { - var deleteButton = this.$('.delete_all'); - if(this.collection.length === 0 || !this.model.get('query')) { - deleteButton.attr('disabled', 'disabled'); - } else { - deleteButton.removeAttr('disabled'); - } - - new BH.Views.SearchPaginationView({ - collection: this.collection, - query: this.model.get('query'), - el: $('.pagination'), - model: this.page - }).render(); - }, + render : function() { + var properties = _.extend(this.getI18nValues(), this.model.toJSON()); + var template = BH.Lib.Template.fetch(this.template); + var html = Mustache.to_html(template, properties); + this.$el.html(html); + return this; + }, + onHistoryChanged : function() { + var deleteButton = this.$('.delete_all'); + if (this.collection.length === 0 || !this.model.get('query')) { + deleteButton.attr('disabled', 'disabled'); + } else { + deleteButton.removeAttr('disabled'); + } - clickedDeleteAll: function(ev) { - ev.preventDefault(); - if($(ev.target).parent().attr('disabled') !== 'disabled') { - this.promptView = BH.Modals.CreatePrompt(BH.Chrome.I18n.t('confirm_delete_all_search_results')); - this.promptView.open(); - this.promptView.model.on('change', this.deleteAction, this); - } - }, + new BH.Views + .SearchPaginationView({ + collection : this.collection, + query : this.model.get('query'), + el : $('.pagination'), + model : this.page + }) + .render(); + }, - deleteAction: function(prompt) { - if(prompt.get('action')) { - analyticsTracker.searchResultsDeletion(); + clickedDeleteAll : function(ev) { + ev.preventDefault(); + if ($(ev.target).parent().attr('disabled') !== 'disabled') { + this.promptView = BH.Modals.CreatePrompt( + BH.Chrome.I18n.t('confirm_delete_all_search_results')); + this.promptView.open(); + this.promptView.model.on('change', this.deleteAction, this); + } + }, - var _this = this; - new Historian.Search(this.model.get('query')).destroy({}, function() { - _this.collection.reset([]); - _this.model.unset('cacheDatetime'); - _this.promptView.close(); - }); - } else { - this.promptView.close(); - } - }, + deleteAction : function(prompt) { + if (prompt.get('action')) { + var _this = this; + new Historian.Search(this.model.get('query')).destroy({}, function() { + _this.collection.reset([]); + _this.model.unset('cacheDatetime'); + _this.promptView.close(); + }); + } else { + this.promptView.close(); + } + }, - clickedSearchTips: function(ev) { - ev.preventDefault(); - new BH.Modals.SearchTipsModal().open(); - }, + clickedSearchTips : function(ev) { + ev.preventDefault(); + new BH.Modals.SearchTipsModal().open(); + }, - getI18nValues: function() { - return BH.Chrome.I18n.t(['delete_all_visits_for_search_button']); - } - }); + getI18nValues : function() { + return BH.Chrome.I18n.t([ 'delete_all_visits_for_search_button' ]); + } +}); - BH.Views.SearchControlsView = SearchControlsView; +BH.Views.SearchControlsView = SearchControlsView; })(); diff --git a/scripts/views/search_pagination_view.js b/scripts/views/search_pagination_view.js index f096881a..60c0ecb7 100644 --- a/scripts/views/search_pagination_view.js +++ b/scripts/views/search_pagination_view.js @@ -1,78 +1,74 @@ (function() { - var SearchPaginationView = BH.Views.MainView.extend({ - className: 'search_pagination_view', - template: 'search_pagination.html', +var SearchPaginationView = BH.Views.MainView.extend({ + className : 'search_pagination_view', + template : 'search_pagination.html', - initialize: function(options) { - this.query = options.query; - this.pages = BH.Lib.Pagination.calculatePages(this.collection.length); + initialize : function(options) { + this.query = options.query; + this.pages = BH.Lib.Pagination.calculatePages(this.collection.length); - this.collection.on('remove', this.onVisitRemove, this); - this.collection.on('add', this.onVisitsAdd, this); + this.collection.on('remove', this.onVisitRemove, this); + this.collection.on('add', this.onVisitsAdd, this); - if(this.model.get('page') > this.pages) { - this.model.set({page: 1}); - } - }, + if (this.model.get('page') > this.pages) { + this.model.set({page : 1}); + } + }, - events: { - 'click .pagination a': 'onPageClicked' - }, + events : {'click .pagination a' : 'onPageClicked'}, - render: function() { - this.pages = BH.Lib.Pagination.calculatePages(this.collection.length); - this.model.set({totalPages: this.pages}); + render : function() { + this.pages = BH.Lib.Pagination.calculatePages(this.collection.length); + this.model.set({totalPages : this.pages}); - var properties = { - // Hide pagination if there is only one page of results - paginationClass: (this.pages === 1 ? 'hidden' : ''), - pages: [] - }; + var properties = { + // Hide pagination if there is only one page of results + paginationClass : (this.pages === 1 ? 'hidden' : ''), + pages : [] + }; - var _this = this; - _.range(1, this.pages + 1).forEach(function(i) { - properties.pages.push({ - url: "#search/" + _this.query + "/p" + i, - className: (i === _this.model.get('page') ? 'selected' : ''), - number: i - }); + var _this = this; + _.range(1, this.pages + 1).forEach(function(i) { + properties.pages.push({ + url : "#search/" + _this.query + "/p" + i, + className : (i === _this.model.get('page') ? 'selected' : ''), + number : i }); + }); - var template = BH.Lib.Template.fetch(this.template); - var html = Mustache.to_html(template, _.extend(this.getI18nValues(), properties)); - this.$el.html(html); - }, - - onVisitRemove: function() { - if(this.collection.length % 100 === 0) { - this.render(); - } else { - var copy = BH.Chrome.I18n.t('number_of_visits', [this.collection.length]); - this.$('.number_of_visits').text(copy); - } - }, + var template = BH.Lib.Template.fetch(this.template); + var html = + Mustache.to_html(template, _.extend(this.getI18nValues(), properties)); + this.$el.html(html); + }, - onVisitsAdd: function() { + onVisitRemove : function() { + if (this.collection.length % 100 === 0) { this.render(); - }, + } else { + var copy = + BH.Chrome.I18n.t('number_of_visits', [ this.collection.length ]); + this.$('.number_of_visits').text(copy); + } + }, - onPageClicked: function(ev) { - ev.preventDefault(); - var $el = $(ev.currentTarget); - this.$('a').removeClass('selected'); - $el.addClass('selected'); - this.model.set({page: parseInt($el.data('page'), 10)}); - analyticsTracker.paginationClick(); - }, + onVisitsAdd : function() { this.render(); }, - getI18nValues: function() { - var properties = []; - properties['i18n_number_of_visits'] = BH.Chrome.I18n.t('number_of_visits', [ - this.collection.length - ]); - return properties; - } - }); + onPageClicked : function(ev) { + ev.preventDefault(); + var $el = $(ev.currentTarget); + this.$('a').removeClass('selected'); + $el.addClass('selected'); + this.model.set({page : parseInt($el.data('page'), 10)}); + }, + + getI18nValues : function() { + var properties = []; + properties['i18n_number_of_visits'] = + BH.Chrome.I18n.t('number_of_visits', [ this.collection.length ]); + return properties; + } +}); - BH.Views.SearchPaginationView = SearchPaginationView; +BH.Views.SearchPaginationView = SearchPaginationView; })(); diff --git a/scripts/views/search_results_view.js b/scripts/views/search_results_view.js index a342cbee..e6b3ba18 100644 --- a/scripts/views/search_results_view.js +++ b/scripts/views/search_results_view.js @@ -1,135 +1,128 @@ (function() { - var SearchResultsView = Backbone.View.extend({ - template: 'search_results.html', - - events: { - 'click .delete_visit': 'deleteClicked', - 'click .delete_download': 'deleteDownloadClicked' - }, - - initialize: function(options) { - this.page = options.page; - this.query = options.query; - this.deepSearched = options.deepSearched; - this.collection.on('add', this.onVisitAdded, this); - this.page.on('change:page', this.onPageChange, this); - }, - - render: function() { - var result = BH.Lib.Pagination.calculateBounds(this.page.get('page') - 1); - var start = result[0]; - var end = result[1]; - - var presenter = new BH.Presenters.SearchHistoryPresenter(this.collection.toJSON(), this.query); - - var properties = _.extend(this.getI18nValues(), { - visits: presenter.history(start, end), - extendSearch: this.page.get('totalPages') === this.page.get('page') && !this.deepSearched - }); - - var template = BH.Lib.Template.fetch(this.template); - var html = Mustache.to_html(template, properties); - this.$el.html(html); - - this.show(); - this.inflateDates(); - this.inflateDownloadIcons(); - - document.body.scrollTop = 0; - - return this; - }, - - resetRender: function() { - this.hide(); - var _this = this; - setTimeout(function() { - _this.$('.visits_content').html(''); - }, 250); - }, - - show: function() { - this.$el.removeClass('disappear'); - }, - - hide: function() { - this.$el.addClass('disappear'); - }, - - inflateDates: function() { - var result = BH.Lib.Pagination.calculateBounds(this.page.get('page') - 1); - var start = result[0]; - var end = result[1]; - var presenter = new BH.Presenters.SearchHistoryPresenter(this.collection.toJSON(), this.query); - var history = presenter.history(start, end); - - var _this = this; - $('.visit .datetime').each(function(i, el) { - _this.inflateDate($(el), history[i].lastVisitTime || history[i].startTime); - }); - }, - - inflateDate: function($el, timestamp) { - $el.text(new Date(timestamp).toLocaleString(BH.lang)); - }, - - inflateDownloadIcons: function() { - var callback = function(el, uri) { - $(el).find('.description').css({backgroundImage: "url(" + uri + ")"}); - }; - - $('.download').each(function(i, el) { - var downloadId = parseInt($(el).data('download-id'), 10); - chrome.downloads.getFileIcon(downloadId, {}, function(uri) { - callback(el, uri); - }); - }); - }, - - deleteClicked: function(ev) { - ev.preventDefault(); - var $el = $(ev.currentTarget); - var url = $el.data('url'); - - var _this = this; - Historian.deleteUrl(url, function() { - $el.parents('.visit').remove(); - _this.collection.remove(_this.collection.where({url: url})); - new Historian.Search().expireCache(); - window.analyticsTracker.searchResultDeletion(); - }); - }, - - deleteDownloadClicked: function(ev) { - ev.preventDefault(); - var $el = $(ev.currentTarget); - var url = $el.data('url'); - - var _this = this; - Historian.deleteDownload(url, function() { - $el.parents('.visit').remove(); - _this.collection.remove(_this.collection.where({url: url})); - new Historian.Search().expireCache(); - window.analyticsTracker.searchResultDeletion(); - }); - }, - - onVisitAdded: function(model) { - if($('.visits li').length < 100) { - var visitView = new BH.Views.VisitView({model: model}); - this.$('.visits').append(visitView.render().el); - - this.inflateDate(visitView.$('.datetime'), model.get('lastVisitTime')); - } - }, - - onPageChange: function() { - this.render(); - }, - - getI18nValues: function() { - return BH.Chrome.I18n.t(['no_visits_found', 'prompt_delete_button']); +var SearchResultsView = Backbone.View.extend({ + template : 'search_results.html', + + events : { + 'click .delete_visit' : 'deleteClicked', + 'click .delete_download' : 'deleteDownloadClicked' + }, + + initialize : function(options) { + this.page = options.page; + this.query = options.query; + this.deepSearched = options.deepSearched; + this.collection.on('add', this.onVisitAdded, this); + this.page.on('change:page', this.onPageChange, this); + }, + + render : function() { + var result = BH.Lib.Pagination.calculateBounds(this.page.get('page') - 1); + var start = result[0]; + var end = result[1]; + + var presenter = new BH.Presenters.SearchHistoryPresenter( + this.collection.toJSON(), this.query); + + var properties = _.extend(this.getI18nValues(), { + visits : presenter.history(start, end), + extendSearch : this.page.get('totalPages') === this.page.get('page') && + !this.deepSearched + }); + + var template = BH.Lib.Template.fetch(this.template); + var html = Mustache.to_html(template, properties); + this.$el.html(html); + + this.show(); + this.inflateDates(); + this.inflateDownloadIcons(); + + document.body.scrollTop = 0; + + return this; + }, + + resetRender : function() { + this.hide(); + var _this = this; + setTimeout(function() { _this.$('.visits_content').html(''); }, 250); + }, + + show : function() { this.$el.removeClass('disappear'); }, + + hide : function() { this.$el.addClass('disappear'); }, + + inflateDates : function() { + var result = BH.Lib.Pagination.calculateBounds(this.page.get('page') - 1); + var start = result[0]; + var end = result[1]; + var presenter = new BH.Presenters.SearchHistoryPresenter( + this.collection.toJSON(), this.query); + var history = presenter.history(start, end); + + var _this = this; + $('.visit .datetime').each(function(i, el) { + _this.inflateDate($(el), + history[i].lastVisitTime || history[i].startTime); + }); + }, + + inflateDate : function( + $el, + timestamp) { $el.text(new Date(timestamp).toLocaleString(BH.lang)); }, + + inflateDownloadIcons : function() { + var callback = function(el, uri) { + $(el).find('.description').css({backgroundImage : "url(" + uri + ")"}); + }; + + $('.download').each(function(i, el) { + var downloadId = parseInt($(el).data('download-id'), 10); + chrome.downloads.getFileIcon(downloadId, {}, + function(uri) { callback(el, uri); }); + }); + }, + + deleteClicked : function(ev) { + ev.preventDefault(); + var $el = $(ev.currentTarget); + var url = $el.data('url'); + + var _this = this; + Historian.deleteUrl(url, function() { + $el.parents('.visit').remove(); + _this.collection.remove(_this.collection.where({url : url})); + new Historian.Search().expireCache(); + }); + }, + + deleteDownloadClicked : function(ev) { + ev.preventDefault(); + var $el = $(ev.currentTarget); + var url = $el.data('url'); + + var _this = this; + Historian.deleteDownload(url, function() { + $el.parents('.visit').remove(); + _this.collection.remove(_this.collection.where({url : url})); + new Historian.Search().expireCache(); + }); + }, + + onVisitAdded : function(model) { + if ($('.visits li').length < 100) { + var visitView = new BH.Views.VisitView({model : model}); + this.$('.visits').append(visitView.render().el); + + this.inflateDate(visitView.$('.datetime'), model.get('lastVisitTime')); } - }); - BH.Views.SearchResultsView = SearchResultsView; + }, + + onPageChange : function() { this.render(); }, + + getI18nValues : function() { + return BH.Chrome.I18n.t([ 'no_visits_found', 'prompt_delete_button' ]); + } +}); +BH.Views.SearchResultsView = SearchResultsView; })(); diff --git a/scripts/views/search_view.js b/scripts/views/search_view.js index b9da6886..a60a7ce2 100644 --- a/scripts/views/search_view.js +++ b/scripts/views/search_view.js @@ -1,149 +1,141 @@ (function() { - var SearchView = BH.Views.MainView.extend({ - className: 'search_view with_controls', - template: 'search.html', - - events: { - 'click .fresh_search': 'clickedFreshSearch', - 'click .search_deeper': 'clickedSearchDeeper', - 'keyup .search': 'onSearchTyped', - 'blur .search': 'onSearchBlurred' - }, - - initialize: function() { - this.collection.on('reset', this.onHistoryChanged, this); - this.model.on('change:query', this.onQueryChanged, this); - this.model.on('change:cacheDatetime', this.onCacheChanged, this); - }, - - render: function() { - var presenter = new BH.Presenters.SearchPresenter(this.model.toJSON()); - var properties = _.extend(this.getI18nValues(), presenter.searchInfo()); - var template = BH.Lib.Template.fetch(this.template); - var html = Mustache.to_html(template, properties); - this.$el.append(html); - - this.searchControlsView = new BH.Views.SearchControlsView({ - model: this.model, - collection: this.collection, - el: this.$('.search_controls') - }); - this.searchControlsView.render(); - - return this; - }, - - pageTitle: function() { - return BH.Chrome.I18n.t('searching_title'); - }, - - onHistoryChanged: function() { - this.$el.removeClass('loading'); - this.renderVisits(); - this.assignTabIndices('.visit a.item'); - }, - - onCacheChanged: function() { - if(this.model.get('cacheDatetime')) { - var datetime = moment(this.model.get('cacheDatetime')); - var date = datetime.format(BH.Chrome.I18n.t('extended_formal_date')); - var time = datetime.format(BH.Chrome.I18n.t('local_time')); - this.$('.cached .datetime').text(time + " " + date); - this.$('.cached').show(); - } else { - this.$('.cached').hide(); - } - }, - - onQueryChanged: function() { - this.searchControlsView.render(); - if(this.model.get('query')) { - this.$('.cached').hide(); - this.$el.addClass('loading'); - - var presenter = new BH.Presenters.SearchPresenter(this.model.toJSON()); - var properties = presenter.searchInfo(); - this.$('.title').text(properties.title); - this.$('.visits_content').html(''); - } - }, - - clickedFreshSearch: function(ev) { - ev.preventDefault(); - new Historian.Search().expireCache(); - window.analyticsTracker.expireCache(); - this.$('.visits_content').html(''); +var SearchView = BH.Views.MainView.extend({ + className : 'search_view with_controls', + template : 'search.html', + + events : { + 'click .fresh_search' : 'clickedFreshSearch', + 'click .search_deeper' : 'clickedSearchDeeper', + 'keyup .search' : 'onSearchTyped', + 'blur .search' : 'onSearchBlurred' + }, + + initialize : function() { + this.collection.on('reset', this.onHistoryChanged, this); + this.model.on('change:query', this.onQueryChanged, this); + this.model.on('change:cacheDatetime', this.onCacheChanged, this); + }, + + render : function() { + var presenter = new BH.Presenters.SearchPresenter(this.model.toJSON()); + var properties = _.extend(this.getI18nValues(), presenter.searchInfo()); + var template = BH.Lib.Template.fetch(this.template); + var html = Mustache.to_html(template, properties); + this.$el.append(html); + + this.searchControlsView = new BH.Views.SearchControlsView({ + model : this.model, + collection : this.collection, + el : this.$('.search_controls') + }); + this.searchControlsView.render(); + + return this; + }, + + pageTitle : function() { return BH.Chrome.I18n.t('searching_title'); }, + + onHistoryChanged : function() { + this.$el.removeClass('loading'); + this.renderVisits(); + this.assignTabIndices('.visit a.item'); + }, + + onCacheChanged : function() { + if (this.model.get('cacheDatetime')) { + var datetime = moment(this.model.get('cacheDatetime')); + var date = datetime.format(BH.Chrome.I18n.t('extended_formal_date')); + var time = datetime.format(BH.Chrome.I18n.t('local_time')); + this.$('.cached .datetime').text(time + " " + date); + this.$('.cached').show(); + } else { this.$('.cached').hide(); - this.$('.pagination').html(''); - this.$el.addClass('loading'); - - this.searchControlsView.page.set({page: 1}); - Backbone.history.loadUrl(Backbone.history.fragment); - }, - - clickedSearchDeeper: function(ev) { - ev.preventDefault(); - window.analyticsTracker.searchDeeper(); + } + }, - this.$('.number_of_visits').html(''); - this.$('.search_deeper').addClass('searching'); - this.$('.pagination').html(''); + onQueryChanged : function() { + this.searchControlsView.render(); + if (this.model.get('query')) { + this.$('.cached').hide(); this.$el.addClass('loading'); - this.searchDeeper(); - }, - - searchDeeper: function() { - // This is a shitty solution - this.deepSearched = true; - - var options = { - startAtResult: 5001, - maxResults: 0 - }; + var presenter = new BH.Presenters.SearchPresenter(this.model.toJSON()); + var properties = presenter.searchInfo(); + this.$('.title').text(properties.title); + this.$('.visits_content').html(''); + } + }, + + clickedFreshSearch : function(ev) { + ev.preventDefault(); + new Historian.Search().expireCache(); + this.$('.visits_content').html(''); + this.$('.cached').hide(); + this.$('.pagination').html(''); + this.$el.addClass('loading'); + + this.searchControlsView.page.set({page : 1}); + Backbone.history.loadUrl(Backbone.history.fragment); + }, + + clickedSearchDeeper : function(ev) { + ev.preventDefault(); + + this.$('.number_of_visits').html(''); + this.$('.search_deeper').addClass('searching'); + this.$('.pagination').html(''); + this.$el.addClass('loading'); + + this.searchDeeper(); + }, + + searchDeeper : function() { + // This is a shitty solution + this.deepSearched = true; + + var options = {startAtResult : 5001, maxResults : 0}; + + var _this = this; + new Historian.Search(this.model.get('query')) + .fetch(options, function(history) { + _this.$('.search_deeper').hide(); + _this.collection.add(history); + _this.$el.removeClass('loading'); + }); + }, + + renderVisits : function() { + this.$el.removeClass('loading'); + this.$('.search').focus(); + + this.$('.visits_content').addClass('disappear'); + var _this = this; + setTimeout(function() { + _this.$('.visits_content').html(''); + if (_this.searchResultsView) { + _this.searchResultsView.undelegateEvents(); + } - var _this = this; - new Historian.Search(this.model.get('query')).fetch(options, function(history) { - _this.$('.search_deeper').hide(); - _this.collection.add(history); - _this.$el.removeClass('loading'); + _this.searchResultsView = new BH.Views.SearchResultsView({ + query : _this.model.get('query'), + collection : _this.collection, + el : _this.$('.visits_content'), + page : _this.searchControlsView.page, + deepSearched : _this.deepSearched }); - }, - - renderVisits: function() { - this.$el.removeClass('loading'); - this.$('.search').focus(); - - this.$('.visits_content').addClass('disappear'); - var _this = this; - setTimeout(function() { - _this.$('.visits_content').html(''); - if(_this.searchResultsView) { - _this.searchResultsView.undelegateEvents(); - } - - _this.searchResultsView = new BH.Views.SearchResultsView({ - query: _this.model.get('query'), - collection: _this.collection, - el: _this.$('.visits_content'), - page: _this.searchControlsView.page, - deepSearched: _this.deepSearched - }); - _this.$('.visits_content').removeClass('disappear'); + _this.$('.visits_content').removeClass('disappear'); - _this.searchResultsView.render(); + _this.searchResultsView.render(); - _this.delay = 50; - }, this.delay || 0); - }, + _this.delay = 50; + }, this.delay || 0); + }, - getI18nValues: function() { - return BH.Chrome.I18n.t([ - 'search_input_placeholder_text', - 'no_visits_found' - ]); - } - }); + getI18nValues : function() { + return BH.Chrome.I18n.t( + [ 'search_input_placeholder_text', 'no_visits_found' ]); + } +}); - BH.Views.SearchView = SearchView; +BH.Views.SearchView = SearchView; })(); diff --git a/scripts/views/visits_results_view.js b/scripts/views/visits_results_view.js index 52954105..3aaf5b90 100644 --- a/scripts/views/visits_results_view.js +++ b/scripts/views/visits_results_view.js @@ -1,248 +1,227 @@ (function() { - var VisitsResultsView = Backbone.View.extend({ - template: 'visits_results.html', - - events: { - 'click .download': 'downloadClicked', - 'click .delete_hour': 'deleteHourClicked', - 'click .delete_visit': 'deleteVisitClicked', - 'click .delete_download': 'deleteDownloadClicked', - 'click .visit > a': 'visitClicked', - 'click .hours a': 'hourClicked' - }, - - initialize: function() { - this.hourModel = new Backbone.Model(); - this.hourModel.on('change:hour', this.onHourChanged, this); - }, - - render: function() { - var properties = this.getI18nValues(); - var presenter = new BH.Presenters.VisitsPresenter(); - var visitsByHour = presenter.visitsByHour(this.collection.toJSON()); - var hours = presenter.hoursDistribution(this.collection.toJSON()); - - if(this.collection.length > 0) { - var date = new Date(this.model.get('date')); - properties.history = { - visitsByHour: visitsByHour.reverse(), - date: date.toLocaleDateString('en'), - day: moment(date).format('dddd'), - hours: hours - }; - } - - var template = BH.Lib.Template.fetch(this.template); - var html = Mustache.to_html(template, properties); - - this.$el.html(html); - - document.body.scrollTop = 0; - - this.show(); - this.inflateDates(); - this.inflateDownloadIcons(); - - // Mark first available hour as selected - this.$('.controls.hours a:not(.disabled)').eq(0).addClass('selected'); - - window.analyticsTracker.dayActivityDownloadCount(this.$('.visits a.download').length); - window.analyticsTracker.dayActivityVisitCount(this.$('.visits a.site').length); +var VisitsResultsView = Backbone.View.extend({ + template : 'visits_results.html', + + events : { + 'click .download' : 'downloadClicked', + 'click .delete_hour' : 'deleteHourClicked', + 'click .delete_visit' : 'deleteVisitClicked', + 'click .delete_download' : 'deleteDownloadClicked', + 'click .visit > a' : 'visitClicked', + 'click .hours a' : 'hourClicked' + }, + + initialize : function() { + this.hourModel = new Backbone.Model(); + this.hourModel.on('change:hour', this.onHourChanged, this); + }, + + render : function() { + var properties = this.getI18nValues(); + var presenter = new BH.Presenters.VisitsPresenter(); + var visitsByHour = presenter.visitsByHour(this.collection.toJSON()); + var hours = presenter.hoursDistribution(this.collection.toJSON()); + + if (this.collection.length > 0) { + var date = new Date(this.model.get('date')); + properties.history = { + visitsByHour : visitsByHour.reverse(), + date : date.toLocaleDateString('en'), + day : moment(date).format('dddd'), + hours : hours + }; + } + var template = BH.Lib.Template.fetch(this.template); + var html = Mustache.to_html(template, properties); - var _this = this; - hourScrollSpy(function(hour) { - _this.hourModel.set({hour: hour}); - }); + this.$el.html(html); - return this; - }, + document.body.scrollTop = 0; - resetRender: function() { - this.hide(); - this.$('.visits_content').html(''); - }, + this.show(); + this.inflateDates(); + this.inflateDownloadIcons(); - show: function() { - this.$el.removeClass('disappear'); - }, + // Mark first available hour as selected + this.$('.controls.hours a:not(.disabled)').eq(0).addClass('selected'); - hide: function() { - this.$el.addClass('disappear'); - }, + var _this = this; + hourScrollSpy(function(hour) { _this.hourModel.set({hour : hour}); }); - inflateDates: function() { - var _this = this; - $('.time').each(function(i, el) { - var model = _this.collection.at(i); - timestamp = model.get('lastVisitTime') || model.get('startTime'); - $(el).text(new Date(timestamp).toLocaleTimeString(BH.lang)); - }); - }, + return this; + }, - inflateDownloadIcons: function() { - var callback = function(el, uri) { - $(el).find('.description').css({backgroundImage: "url(" + uri + ")"}); - }; + resetRender : function() { + this.hide(); + this.$('.visits_content').html(''); + }, - $('.download').each(function(i, el) { - downloadId = parseInt($(el).data('download-id'), 10); - chrome.downloads.getFileIcon(downloadId, {}, function(uri) { - callback(el, uri); - }); - }); - }, + show : function() { this.$el.removeClass('disappear'); }, - visitClicked: function(ev) { - if($(ev.target).hasClass('search_domain')) { - ev.preventDefault(); - window.analyticsTracker.searchVisitDomain(); - router.navigate($(ev.target).attr('href'), {trigger: true}); - } - }, + hide : function() { this.$el.addClass('disappear'); }, - hourClicked: function(ev) { - ev.preventDefault(); - var hour = $(ev.currentTarget).data('hour'); - scrollToHour(hour); - window.analyticsTracker.hourClick(hour.toString()); - }, - - onHourChanged: function() { - var hour = this.hourModel.get('hour'); - this.$('.hours a').removeClass("selected"); - this.$(".hours a[data-hour='" + hour + "']").addClass("selected"); - }, - - downloadClicked: function(ev) { - ev.preventDefault(); - var $el = $(ev.currentTarget); - var downloadId = parseInt($el.data('download-id'), 10); - chrome.downloads.show(downloadId); - }, + inflateDates : function() { + var _this = this; + $('.time').each(function(i, el) { + var model = _this.collection.at(i); + timestamp = model.get('lastVisitTime') || model.get('startTime'); + $(el).text(new Date(timestamp).toLocaleTimeString(BH.lang)); + }); + }, - deleteHourClicked: function(ev) { - ev.preventDefault(); - var hour = $(ev.currentTarget).data('hour'); - this.promptToDeleteHour(hour); - }, + inflateDownloadIcons : function() { + var callback = function(el, uri) { + $(el).find('.description').css({backgroundImage : "url(" + uri + ")"}); + }; - deleteVisitClicked: function(ev) { - ev.preventDefault(); - var $el = $(ev.currentTarget); - analyticsTracker.visitDeletion(); - Historian.deleteUrl($el.data('url'), function() { - $el.parent('.visit').remove(); - }); - }, + $('.download').each(function(i, el) { + downloadId = parseInt($(el).data('download-id'), 10); + chrome.downloads.getFileIcon(downloadId, {}, + function(uri) { callback(el, uri); }); + }); + }, - deleteDownloadClicked: function(ev) { + visitClicked : function(ev) { + if ($(ev.target).hasClass('search_domain')) { ev.preventDefault(); - var $el = $(ev.currentTarget); - analyticsTracker.downloadDeletion(); - Historian.deleteDownload($el.data('url'), function() { - $el.parent('.visit').remove(); - }); - }, - - promptToDeleteHour: function(hour) { + router.navigate($(ev.target).attr('href'), {trigger : true}); + } + }, + + hourClicked : function(ev) { + ev.preventDefault(); + var hour = $(ev.currentTarget).data('hour'); + scrollToHour(hour); + }, + + onHourChanged : function() { + var hour = this.hourModel.get('hour'); + this.$('.hours a').removeClass("selected"); + this.$(".hours a[data-hour='" + hour + "']").addClass("selected"); + }, + + downloadClicked : function(ev) { + ev.preventDefault(); + var $el = $(ev.currentTarget); + var downloadId = parseInt($el.data('download-id'), 10); + chrome.downloads.show(downloadId); + }, + + deleteHourClicked : function(ev) { + ev.preventDefault(); + var hour = $(ev.currentTarget).data('hour'); + this.promptToDeleteHour(hour); + }, + + deleteVisitClicked : function(ev) { + ev.preventDefault(); + var $el = $(ev.currentTarget); + Historian.deleteUrl($el.data('url'), + function() { $el.parent('.visit').remove(); }); + }, + + deleteDownloadClicked : function(ev) { + ev.preventDefault(); + var $el = $(ev.currentTarget); + Historian.deleteDownload($el.data('url'), + function() { $el.parent('.visit').remove(); }); + }, + + promptToDeleteHour : function(hour) { + var date = new Date(this.model.get('date')); + date.setHours(hour); + date.setSeconds(0); + date.setMinutes(0); + var timestamp = date.toLocaleString(BH.lang); + var promptMessage = + BH.Chrome.I18n.t('confirm_delete_all_visits', [ timestamp ]); + this.promptView = BH.Modals.CreatePrompt(promptMessage); + this.promptView.open(); + + var _this = this; + this.promptView.model.on( + 'change', function(prompt) { _this.promptAction(prompt, hour); }, this); + }, + + promptAction : function(prompt, hour) { + if (prompt.get('action')) { var date = new Date(this.model.get('date')); - date.setHours(hour); - date.setSeconds(0); - date.setMinutes(0); - var timestamp = date.toLocaleString(BH.lang); - var promptMessage = BH.Chrome.I18n.t('confirm_delete_all_visits', [timestamp]); - this.promptView = BH.Modals.CreatePrompt(promptMessage); - this.promptView.open(); + var dayHistorian = new Historian.Day(date); var _this = this; - this.promptView.model.on('change', function(prompt) { - _this.promptAction(prompt, hour); - }, this); - }, - - promptAction: function(prompt, hour) { - if(prompt.get('action')) { - window.analyticsTracker.hourDeletion(); - var date = new Date(this.model.get('date')); - var dayHistorian = new Historian.Day(date); - - var _this = this; - dayHistorian.destroyHour(hour, function() { - - // Remove the hour container from the DOM and unselect - // the active hour in the menu. - $('.hour_visits[data-hour=' + hour + ']').remove(); - $('a[data-hour=' + hour + ']').addClass('disabled'); - - // After an hour is removed, the active hour in the menu - // must be updated. Manually trigger a scroll event. - $(window).trigger('scroll'); - - _this.promptView.close(); - }); - } else { - this.promptView.close(); - } - }, - - getI18nValues: function() { - return BH.Chrome.I18n.t([ - 'prompt_delete_button', - 'delete_time_interval_button', - 'no_visits_found', - 'expand_button', - 'collapse_button', - 'search_by_domain', - 'delete_all_visits_for_filter_button' - ]); - } - }); + dayHistorian.destroyHour(hour, function() { + // Remove the hour container from the DOM and unselect + // the active hour in the menu. + $('.hour_visits[data-hour=' + hour + ']').remove(); + $('a[data-hour=' + hour + ']').addClass('disabled'); - var hourScrollSpy = function(cb) { - var lastId = null; - var topMenu = $('.hours'); - var topMenuHeight = topMenu.outerHeight(); - var menuItems = topMenu.find("a"); - var scrollItems = menuItems.map(function() { - var item = $($(this).attr("href")); - if (item.length) { return item; } - }); - - $(window).scroll(function() { - // Get container scroll position - var fromTop = $(this).scrollTop() + topMenuHeight; + // After an hour is removed, the active hour in the menu + // must be updated. Manually trigger a scroll event. + $(window).trigger('scroll'); - // Get id of current scroll item - var cur = scrollItems.map(function() { - if(($(this).offset().top - 205) < fromTop) { - return this; - } + _this.promptView.close(); }); + } else { + this.promptView.close(); + } + }, + + getI18nValues : function() { + return BH.Chrome.I18n.t([ + 'prompt_delete_button', 'delete_time_interval_button', 'no_visits_found', + 'expand_button', 'collapse_button', 'search_by_domain', + 'delete_all_visits_for_filter_button' + ]); + } +}); + +var hourScrollSpy = function(cb) { + var lastId = null; + var topMenu = $('.hours'); + var topMenuHeight = topMenu.outerHeight(); + var menuItems = topMenu.find("a"); + var scrollItems = menuItems.map(function() { + var item = $($(this).attr("href")); + if (item.length) { + return item; + } + }); - // Get the id of the current element - cur = cur[cur.length - 1]; - var id = cur && cur.length ? cur[0].id : ""; - - if(lastId !== id) { - lastId = id; + $(window).scroll(function() { + // Get container scroll position + var fromTop = $(this).scrollTop() + topMenuHeight; - var $el = menuItems.filter("[href='#" + id + "']"); - cb($el.data('hour')); + // Get id of current scroll item + var cur = scrollItems.map(function() { + if (($(this).offset().top - 205) < fromTop) { + return this; } }); - }; - var scrollToHour = function(hour) { - var topMenuHeight = $('.hours').outerHeight(), - $el = $('.hour_visits[data-hour=' + hour + ']'); + // Get the id of the current element + cur = cur[cur.length - 1]; + var id = cur && cur.length ? cur[0].id : ""; - if($el.length > 0) { - var offsetTop = $el.offset().top - topMenuHeight + 1; + if (lastId !== id) { + lastId = id; - $('html, body').stop().animate({scrollTop: offsetTop - 120}, 300); + var $el = menuItems.filter("[href='#" + id + "']"); + cb($el.data('hour')); } - }; + }); +}; + +var scrollToHour = function(hour) { + var topMenuHeight = $('.hours').outerHeight(), + $el = $('.hour_visits[data-hour=' + hour + ']'); + + if ($el.length > 0) { + var offsetTop = $el.offset().top - topMenuHeight + 1; + + $('html, body').stop().animate({scrollTop : offsetTop - 120}, 300); + } +}; - BH.Views.VisitsResultsView = VisitsResultsView; +BH.Views.VisitsResultsView = VisitsResultsView; })(); diff --git a/scripts/views/visits_view.js b/scripts/views/visits_view.js index 79ac1888..5cfc097c 100644 --- a/scripts/views/visits_view.js +++ b/scripts/views/visits_view.js @@ -1,66 +1,56 @@ (function() { - var VisitsView = BH.Views.MainView.extend({ - className: 'visits_view', +var VisitsView = BH.Views.MainView.extend({ + className : 'visits_view', - template: 'visits.html', + template : 'visits.html', - events: { - 'keyup .search': 'onSearchTyped', - 'blur .search': 'onSearchBlurred' - }, + events : + {'keyup .search' : 'onSearchTyped', 'blur .search' : 'onSearchBlurred'}, - initialize: function() { - this.tracker = analyticsTracker; - this.collection.on('reset', this.onCollectionReset, this); - this.model.on('change:date', this.onDateChange, this); + initialize : function() { + this.collection.on('reset', this.onCollectionReset, this); + this.model.on('change:date', this.onDateChange, this); - this.feature = new Backbone.Model({supported: true}); - this.feature.on('change:supported', this.onFeatureSupportedChange, this); - }, + this.feature = new Backbone.Model({supported : true}); + this.feature.on('change:supported', this.onFeatureSupportedChange, this); + }, - pageTitle: function() { - return 'Activity'; - }, + pageTitle : function() { return 'Activity'; }, - render: function() { - var template = BH.Lib.Template.fetch(this.template); - var html = Mustache.to_html(template, this.getI18nValues()); - this.$el.append(html); + render : function() { + var template = BH.Lib.Template.fetch(this.template); + var html = Mustache.to_html(template, this.getI18nValues()); + this.$el.append(html); - this.timelineView = new BH.Views.TimelineView({ - model: this.model, - el: this.$('.timeline_view') - }); - this.timelineView.render(); + this.timelineView = new BH.Views.TimelineView( + {model : this.model, el : this.$('.timeline_view')}); + this.timelineView.render(); - this.visitsResultsView = new BH.Views.VisitsResultsView({ - collection: this.collection, - model: this.model, - el: this.$('.visits_content') - }); + this.visitsResultsView = new BH.Views.VisitsResultsView({ + collection : this.collection, + model : this.model, + el : this.$('.visits_content') + }); - return this; - }, + return this; + }, - onDateChange: function(ev) { - this.timelineView.render(); - this.visitsResultsView.resetRender(); - }, + onDateChange : function(ev) { + this.timelineView.render(); + this.visitsResultsView.resetRender(); + }, - onCollectionReset: function() { - this.visitsResultsView.render(); - this.assignTabIndices('.visits > .visit > a.item'); - }, + onCollectionReset : function() { + this.visitsResultsView.render(); + this.assignTabIndices('.visits > .visit > a.item'); + }, - onFeatureSupportedChange: function() { - this.tracker.featureNotSupported('Query (by day)'); - this.browserFeatureNotSupported(); - }, + onFeatureSupportedChange : function() { this.browserFeatureNotSupported(); }, - getI18nValues: function() { - return BH.Chrome.I18n.t(['search_input_placeholder_text']); - } - }); + getI18nValues : function() { + return BH.Chrome.I18n.t([ 'search_input_placeholder_text' ]); + } +}); - BH.Views.VisitsView = VisitsView; +BH.Views.VisitsView = VisitsView; })();