Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: chrome/browser/resources/history/history.js

Issue 12039045: History: Fix RTL layout in grouped history and some other minor fixes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/history/history.css ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 <include src="../uber/uber_utils.js"> 5 <include src="../uber/uber_utils.js">
6 6
7 /////////////////////////////////////////////////////////////////////////////// 7 ///////////////////////////////////////////////////////////////////////////////
8 // Globals: 8 // Globals:
9 /** @const */ var RESULTS_PER_PAGE = 150; 9 /** @const */ var RESULTS_PER_PAGE = 150;
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // Whether this is the continuation of a previous day. 65 // Whether this is the continuation of a previous day.
66 this.continued = continued; 66 this.continued = continued;
67 } 67 }
68 68
69 // Visit, public: ------------------------------------------------------------- 69 // Visit, public: -------------------------------------------------------------
70 70
71 /** 71 /**
72 * Returns a dom structure for a browse page result or a search page result. 72 * Returns a dom structure for a browse page result or a search page result.
73 * @param {Object} propertyBag A bag of configuration properties, false by 73 * @param {Object} propertyBag A bag of configuration properties, false by
74 * default: 74 * default:
75 * <ul> 75 * - isSearchResult: Whether or not the result is a search result.
76 * <li>isSearchResult: Whether or not the result is a search result.</li> 76 * - addTitleFavicon: Whether or not the favicon should be added.
77 * <li>addTitleFavicon: Whether or not the favicon should be added.</li>
78 * </ul>
79 * @return {Node} A DOM node to represent the history entry or search result. 77 * @return {Node} A DOM node to represent the history entry or search result.
80 */ 78 */
81 Visit.prototype.getResultDOM = function(propertyBag) { 79 Visit.prototype.getResultDOM = function(propertyBag) {
82 var isSearchResult = propertyBag.isSearchResult || false; 80 var isSearchResult = propertyBag.isSearchResult || false;
83 var addTitleFavicon = propertyBag.addTitleFavicon || false; 81 var addTitleFavicon = propertyBag.addTitleFavicon || false;
84 var node = createElementWithClassName('li', 'entry'); 82 var node = createElementWithClassName('li', 'entry');
85 var time = createElementWithClassName('div', 'time'); 83 var time = createElementWithClassName('div', 'time');
86 var entryBox = createElementWithClassName('label', 'entry-box'); 84 var entryBox = createElementWithClassName('label', 'entry-box');
87 var domain = createElementWithClassName('div', 'domain'); 85 var domain = createElementWithClassName('div', 'domain');
88 86
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 * Receiver for history query. 370 * Receiver for history query.
373 * @param {Object} info An object containing information about the query. 371 * @param {Object} info An object containing information about the query.
374 * @param {Array} results A list of results. 372 * @param {Array} results A list of results.
375 */ 373 */
376 HistoryModel.prototype.addResults = function(info, results) { 374 HistoryModel.prototype.addResults = function(info, results) {
377 $('loading-spinner').hidden = true; 375 $('loading-spinner').hidden = true;
378 this.inFlight_ = false; 376 this.inFlight_ = false;
379 this.isQueryFinished_ = info.finished; 377 this.isQueryFinished_ = info.finished;
380 this.queryCursor_ = info.cursor; 378 this.queryCursor_ = info.cursor;
381 379
382 // If the results are not for the current search term there's nothing more 380 // If the results are not for the current search term then there is nothing
Patrick Dubroy 2013/01/25 15:29:59 Didn't want to do what James suggested? ;-)
Sergiu 2013/01/28 17:24:52 I realized that I didn't like the sentence with or
383 // to do. 381 // more to do.
384 if (info.term != this.searchText_) 382 if (info.term != this.searchText_)
385 return; 383 return;
386 384
387 // If necessary, sort the results from newest to oldest. 385 // If necessary, sort the results from newest to oldest.
388 if (!results.sorted) 386 if (!results.sorted)
389 results.sort(function(a, b) { return b.time - a.time; }); 387 results.sort(function(a, b) { return b.time - a.time; });
390 388
391 var lastVisit = this.visits_.slice(-1)[0]; 389 var lastVisit = this.visits_.slice(-1)[0];
392 var lastDay = lastVisit ? lastVisit.dateRelativeDay : null; 390 var lastDay = lastVisit ? lastVisit.dateRelativeDay : null;
393 391
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 * Record that the given visit has been rendered. 689 * Record that the given visit has been rendered.
692 * @param {Visit} visit The visit that was rendered. 690 * @param {Visit} visit The visit that was rendered.
693 * @private 691 * @private
694 */ 692 */
695 HistoryView.prototype.setVisitRendered_ = function(visit) { 693 HistoryView.prototype.setVisitRendered_ = function(visit) {
696 visit.isRendered = true; 694 visit.isRendered = true;
697 this.currentVisits_.push(visit); 695 this.currentVisits_.push(visit);
698 }; 696 };
699 697
700 /** 698 /**
701 * This function generates and adds the grouped visits DOM for a certain 699 * Generates and adds the grouped visits DOM for a certain domain. This
702 * domain. This includes the clickable arrow and domain name and the visit 700 * includes the clickable arrow and domain name and the visit entries for
703 * entries for that domain. 701 * that domain.
704 * @param {Element} results DOM object to which to add the elements. 702 * @param {Element} results DOM object to which to add the elements.
705 * @param {string} domain Current domain name. 703 * @param {string} domain Current domain name.
706 * @param {Array} domainVisits Array of visits for this domain. 704 * @param {Array} domainVisits Array of visits for this domain.
707 * @private 705 * @private
708 */ 706 */
709 HistoryView.prototype.getGroupedVisitsDOM_ = function( 707 HistoryView.prototype.getGroupedVisitsDOM_ = function(
710 results, domain, domainVisits) { 708 results, domain, domainVisits) {
711 // Add a new domain entry. 709 // Add a new domain entry.
712 var siteResults = results.appendChild( 710 var siteResults = results.appendChild(
713 createElementWithClassName('li', 'site-entry')); 711 createElementWithClassName('li', 'site-entry'));
714 // Make a wrapper that will contain the arrow, the favicon and the domain. 712 // Make a wrapper that will contain the arrow, the favicon and the domain.
715 var siteDomainWrapper = siteResults.appendChild( 713 var siteDomainWrapper = siteResults.appendChild(
716 createElementWithClassName('div', 'site-domain-wrapper')); 714 createElementWithClassName('div', 'site-domain-wrapper'));
717 var siteArrow = siteDomainWrapper.appendChild( 715 var siteArrow = siteDomainWrapper.appendChild(
718 createElementWithClassName('div', 'site-domain-arrow collapse')); 716 createElementWithClassName('div', 'site-domain-arrow collapse'));
719 siteArrow.textContent = '►'; 717 siteArrow.textContent = '►';
720 var siteDomain = siteDomainWrapper.appendChild( 718 var siteDomain = siteDomainWrapper.appendChild(
721 createElementWithClassName('div', 'site-domain')); 719 createElementWithClassName('div', 'site-domain'));
722 var numberOfVisits = createElementWithClassName('span', 'number-visits'); 720 var numberOfVisits = createElementWithClassName('span', 'number-visits');
723 numberOfVisits.textContent = loadTimeData.getStringF('numbervisits', 721 numberOfVisits.textContent = loadTimeData.getStringF('numbervisits',
724 domainVisits.length); 722 domainVisits.length);
725 siteDomain.textContent = domain; 723 siteDomain.textContent = ' ' + domain + ' ';
Patrick Dubroy 2013/01/25 15:29:59 Why are you adding space to both sides of the doma
Sergiu 2013/01/28 17:24:52 Put in a -webkit-margin-end but it may still not w
726 siteDomain.appendChild(numberOfVisits); 724 siteDomain.appendChild(numberOfVisits);
727 siteResults.appendChild(siteDomainWrapper); 725 siteResults.appendChild(siteDomainWrapper);
728 var resultsList = siteResults.appendChild( 726 var resultsList = siteResults.appendChild(
729 createElementWithClassName('ol', 'site-results')); 727 createElementWithClassName('ol', 'site-results'));
730 728
731 domainVisits[0].addFaviconToElement_(siteDomain); 729 domainVisits[0].addFaviconToElement_(siteDomain);
732 730
733 siteDomainWrapper.addEventListener('click', toggleHandler); 731 siteDomainWrapper.addEventListener('click', toggleHandler);
734 // Collapse until it gets toggled. 732 // Collapse until it gets toggled.
735 resultsList.style.height = 0; 733 resultsList.style.height = 0;
(...skipping 22 matching lines...) Expand all
758 visitsByDomain[domain] = []; 756 visitsByDomain[domain] = [];
759 domains.push(domain); 757 domains.push(domain);
760 } 758 }
761 visitsByDomain[domain].push(visit); 759 visitsByDomain[domain].push(visit);
762 } 760 }
763 var sortByVisits = function(a, b) { 761 var sortByVisits = function(a, b) {
764 return visitsByDomain[b].length - visitsByDomain[a].length; 762 return visitsByDomain[b].length - visitsByDomain[a].length;
765 }; 763 };
766 domains.sort(sortByVisits); 764 domains.sort(sortByVisits);
767 765
768 for (var i = 0, domain; domain = domains[i]; i++) { 766 for (var i = 0, domain; domain = domains[i]; i++)
769 this.getGroupedVisitsDOM_(results, domain, visitsByDomain[domain]); 767 this.getGroupedVisitsDOM_(results, domain, visitsByDomain[domain]);
770 }
771 }; 768 };
772 769
773 /** 770 /**
774 * Adds the results grouped by days, grouping them if needed. 771 * Adds the results grouped by days, grouping them if needed.
775 * @param {Array} visits Visits returned by the query. 772 * @param {Array} visits Visits returned by the query.
776 * @param {Element} parentElement Element to which to add the results to. 773 * @param {Element} parentElement Element to which to add the results to.
777 * @private 774 * @private
778 */ 775 */
779 HistoryView.prototype.addDayResults_ = function(visits, parentElement) { 776 HistoryView.prototype.addDayResults_ = function(visits, parentElement) {
780 if (visits.length == 0) 777 if (visits.length == 0)
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 * Set the hash to a specified state, this will create an entry in the 959 * Set the hash to a specified state, this will create an entry in the
963 * session history so the back button cycles through hash states, which 960 * session history so the back button cycles through hash states, which
964 * are then picked up by our listener. 961 * are then picked up by our listener.
965 * @param {string} term The current search string. 962 * @param {string} term The current search string.
966 * @param {number} page The page currently being viewed. 963 * @param {number} page The page currently being viewed.
967 * @param {boolean} grouped Whether the results are grouped or not. 964 * @param {boolean} grouped Whether the results are grouped or not.
968 */ 965 */
969 PageState.prototype.setUIState = function(term, page, grouped) { 966 PageState.prototype.setUIState = function(term, page, grouped) {
970 // Make sure the form looks pretty. 967 // Make sure the form looks pretty.
971 $('search-field').value = term; 968 $('search-field').value = term;
972 if (grouped) { 969 if (grouped)
973 $('display-filter-sites').checked = true; 970 $('display-filter-sites').checked = true;
974 } else { 971 else
975 $('display-filter-sites').checked = false; 972 $('display-filter-sites').checked = false;
976 }
977 var hash = this.getHashData(); 973 var hash = this.getHashData();
978 if (hash.q != term || hash.p != page || hash.g != grouped) { 974 if (hash.q != term || hash.p != page || hash.g != grouped) {
979 window.location.hash = PageState.getHashString( 975 window.location.hash = PageState.getHashString(
980 term, page, grouped); 976 term, page, grouped);
981 } 977 }
982 }; 978 };
983 979
984 /** 980 /**
985 * Static method to get the hash string for a specified state 981 * Static method to get the hash string for a specified state
986 * @param {string} term The current search string. 982 * @param {string} term The current search string.
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 historyView.reload(); 1302 historyView.reload();
1307 } 1303 }
1308 1304
1309 // Add handlers to HTML elements. 1305 // Add handlers to HTML elements.
1310 document.addEventListener('DOMContentLoaded', load); 1306 document.addEventListener('DOMContentLoaded', load);
1311 1307
1312 // This event lets us enable and disable menu items before the menu is shown. 1308 // This event lets us enable and disable menu items before the menu is shown.
1313 document.addEventListener('canExecute', function(e) { 1309 document.addEventListener('canExecute', function(e) {
1314 e.canExecute = true; 1310 e.canExecute = true;
1315 }); 1311 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/history/history.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698