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

Side by Side Diff: chrome/browser/resources/md_downloads/crisper.js

Issue 2450663003: MD History: hide tooltip promo when drawer is swiped open (Closed)
Patch Set: on-lonely="fixUpCode_" Created 4 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/resources/md_history/app.html » ('j') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 function assert(condition,opt_message){if(!condition){var message="Assertion fai led";if(opt_message)message=message+": "+opt_message;var error=new Error(message );var global=function(){return this}();if(global.traceAssertionsForTesting)conso le.warn(error.stack);throw error}return condition}function assertNotReached(opt_ message){assert(false,opt_message||"Unreachable code hit")}function assertInstan ceof(value,type,opt_message){if(!(value instanceof type)){assertNotReached(opt_m essage||"Value "+value+" is not a[n] "+(type.name||typeof type))}return value} 4 function assert(condition,opt_message){if(!condition){var message="Assertion fai led";if(opt_message)message=message+": "+opt_message;var error=new Error(message );var global=function(){return this}();if(global.traceAssertionsForTesting)conso le.warn(error.stack);throw error}return condition}function assertNotReached(opt_ message){assert(false,opt_message||"Unreachable code hit")}function assertInstan ceof(value,type,opt_message){if(!(value instanceof type)){assertNotReached(opt_m essage||"Value "+value+" is not a[n] "+(type.name||typeof type))}return value}
5 // Copyright 2016 The Chromium Authors. All rights reserved. 5 // Copyright 2016 The Chromium Authors. All rights reserved.
6 // Use of this source code is governed by a BSD-style license that can be 6 // Use of this source code is governed by a BSD-style license that can be
7 // found in the LICENSE file. 7 // found in the LICENSE file.
8 function PromiseResolver(){this.resolve_;this.reject_;this.promise_=new Promise( function(resolve,reject){this.resolve_=resolve;this.reject_=reject}.bind(this))} PromiseResolver.prototype={get promise(){return this.promise_},set promise(p){as sertNotReached()},get resolve(){return this.resolve_},set resolve(r){assertNotRe ached()},get reject(){return this.reject_},set reject(s){assertNotReached()}}; 8 function PromiseResolver(){this.resolve_;this.reject_;this.promise_=new Promise( function(resolve,reject){this.resolve_=resolve;this.reject_=reject}.bind(this))} PromiseResolver.prototype={get promise(){return this.promise_},set promise(p){as sertNotReached()},get resolve(){return this.resolve_},set resolve(r){assertNotRe ached()},get reject(){return this.reject_},set reject(s){assertNotReached()}};
9 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 9 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
10 // Use of this source code is governed by a BSD-style license that can be 10 // Use of this source code is governed by a BSD-style license that can be
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // Use of this source code is governed by a BSD-style license that can be 50 // Use of this source code is governed by a BSD-style license that can be
51 // found in the LICENSE file. 51 // found in the LICENSE file.
52 var CrSearchFieldBehavior={properties:{label:{type:String,value:""},clearLabel:{ type:String,value:""},showingSearch:{type:Boolean,value:false,notify:true,observ er:"showingSearchChanged_",reflectToAttribute:true},lastValue_:{type:String,valu e:""}},getSearchInput:function(){},getValue:function(){return this.getSearchInpu t().value},setValue:function(value){this.getSearchInput().bindValue=value;this.o nValueChanged_(value)},showAndFocus:function(){this.showingSearch=true;this.focu s_()},focus_:function(){this.getSearchInput().focus()},onSearchTermSearch:functi on(){this.onValueChanged_(this.getValue())},onValueChanged_:function(newValue){i f(newValue==this.lastValue_)return;this.lastValue_=newValue;this.fire("search-ch anged",newValue)},onSearchTermKeydown:function(e){if(e.key=="Escape")this.showin gSearch=false},showingSearchChanged_:function(){if(this.showingSearch){this.focu s_();return}this.setValue("");this.getSearchInput().blur()}}; 52 var CrSearchFieldBehavior={properties:{label:{type:String,value:""},clearLabel:{ type:String,value:""},showingSearch:{type:Boolean,value:false,notify:true,observ er:"showingSearchChanged_",reflectToAttribute:true},lastValue_:{type:String,valu e:""}},getSearchInput:function(){},getValue:function(){return this.getSearchInpu t().value},setValue:function(value){this.getSearchInput().bindValue=value;this.o nValueChanged_(value)},showAndFocus:function(){this.showingSearch=true;this.focu s_()},focus_:function(){this.getSearchInput().focus()},onSearchTermSearch:functi on(){this.onValueChanged_(this.getValue())},onValueChanged_:function(newValue){i f(newValue==this.lastValue_)return;this.lastValue_=newValue;this.fire("search-ch anged",newValue)},onSearchTermKeydown:function(e){if(e.key=="Escape")this.showin gSearch=false},showingSearchChanged_:function(){if(this.showingSearch){this.focu s_();return}this.setValue("");this.getSearchInput().blur()}};
53 // Copyright 2016 The Chromium Authors. All rights reserved. 53 // Copyright 2016 The Chromium Authors. All rights reserved.
54 // Use of this source code is governed by a BSD-style license that can be 54 // Use of this source code is governed by a BSD-style license that can be
55 // found in the LICENSE file. 55 // found in the LICENSE file.
56 Polymer({is:"cr-toolbar-search-field",behaviors:[CrSearchFieldBehavior],properti es:{narrow:{type:Boolean,reflectToAttribute:true},label:String,clearLabel:String ,spinnerActive:{type:Boolean,reflectToAttribute:true},hasSearchText_:Boolean,isS pinnerShown_:{type:Boolean,computed:"computeIsSpinnerShown_(spinnerActive, showi ngSearch)"}},listeners:{tap:"showSearch_","searchInput.bind-value-changed":"onBi ndValueChanged_"},getSearchInput:function(){return this.$.searchInput},isSearchF ocused:function(){return this.$.searchTerm.focused},computeIconTabIndex_:functio n(narrow){return narrow?0:-1},computeIsSpinnerShown_:function(){return this.spin nerActive&&this.showingSearch},onInputBlur_:function(){if(!this.hasSearchText_)t his.showingSearch=false},onBindValueChanged_:function(){var newValue=this.$.sear chInput.bindValue;this.hasSearchText_=newValue!="";if(newValue!="")this.showingS earch=true},showSearch_:function(e){if(e.target!=this.$.clearSearch)this.showing Search=true},clearSearch_:function(e){this.setValue("");this.getSearchInput().fo cus()}}); 56 Polymer({is:"cr-toolbar-search-field",behaviors:[CrSearchFieldBehavior],properti es:{narrow:{type:Boolean,reflectToAttribute:true},label:String,clearLabel:String ,spinnerActive:{type:Boolean,reflectToAttribute:true},hasSearchText_:Boolean,isS pinnerShown_:{type:Boolean,computed:"computeIsSpinnerShown_(spinnerActive, showi ngSearch)"}},listeners:{tap:"showSearch_","searchInput.bind-value-changed":"onBi ndValueChanged_"},getSearchInput:function(){return this.$.searchInput},isSearchF ocused:function(){return this.$.searchTerm.focused},computeIconTabIndex_:functio n(narrow){return narrow?0:-1},computeIsSpinnerShown_:function(){return this.spin nerActive&&this.showingSearch},onInputBlur_:function(){if(!this.hasSearchText_)t his.showingSearch=false},onBindValueChanged_:function(){var newValue=this.$.sear chInput.bindValue;this.hasSearchText_=newValue!="";if(newValue!="")this.showingS earch=true},showSearch_:function(e){if(e.target!=this.$.clearSearch)this.showing Search=true},clearSearch_:function(e){this.setValue("");this.getSearchInput().fo cus()}});
57 // Copyright 2016 The Chromium Authors. All rights reserved. 57 // Copyright 2016 The Chromium Authors. All rights reserved.
58 // Use of this source code is governed by a BSD-style license that can be 58 // Use of this source code is governed by a BSD-style license that can be
59 // found in the LICENSE file. 59 // found in the LICENSE file.
60 Polymer({is:"cr-toolbar",properties:{pageName:String,searchPrompt:String,clearLa bel:String,menuLabel:String,menuPromo:String,spinnerActive:Boolean,showMenu:{typ e:Boolean,value:false},showMenuPromo:{type:Boolean,value:false},closeMenuPromo:S tring,narrow_:{type:Boolean,reflectToAttribute:true},showingSearch_:{type:Boolea n,reflectToAttribute:true}},observers:["possiblyShowMenuPromo_(showMenu, showMen uPromo, showingSearch_)"],getSearchField:function(){return this.$.search},onClos ePromoTap_:function(){this.showMenuPromo=false},onMenuTap_:function(){this.fire( "cr-menu-tap");this.onClosePromoTap_()},possiblyShowMenuPromo_:function(){Polyme r.RenderStatus.afterNextRender(this,function(){if(this.showMenu&&this.showMenuPr omo&&!this.showingSearch_){this.$$("#menuPromo").animate({opacity:[0,.9]},{durat ion:500,fill:"forwards"});this.fire("cr-menu-promo-shown")}}.bind(this))},titleI fNotShowMenuPromo_:function(title,showMenuPromo){return showMenuPromo?"":title}} ); 60 Polymer({is:"cr-toolbar",properties:{pageName:String,searchPrompt:String,clearLa bel:String,menuLabel:String,menuPromo:String,spinnerActive:Boolean,showMenu:{typ e:Boolean,value:false},showMenuPromo:{type:Boolean,value:false},closeMenuPromo:S tring,narrow_:{type:Boolean,reflectToAttribute:true},showingSearch_:{type:Boolea n,reflectToAttribute:true}},observers:["possiblyShowMenuPromo_(showMenu, showMen uPromo, showingSearch_)"],getSearchField:function(){return this.$.search},onClos ePromoTap_:function(){this.fire("cr-toolbar-menu-promo-close")},onMenuTap_:funct ion(){this.fire("cr-toolbar-menu-tap")},possiblyShowMenuPromo_:function(){Polyme r.RenderStatus.afterNextRender(this,function(){if(this.showMenu&&this.showMenuPr omo&&!this.showingSearch_){this.$$("#menuPromo").animate({opacity:[0,.9]},{durat ion:500,fill:"forwards"});this.fire("cr-toolbar-menu-promo-shown")}}.bind(this)) },titleIfNotShowMenuPromo_:function(title,showMenuPromo){return showMenuPromo?"" :title}});
61 // Copyright 2015 The Chromium Authors. All rights reserved. 61 // Copyright 2015 The Chromium Authors. All rights reserved.
62 // Use of this source code is governed by a BSD-style license that can be 62 // Use of this source code is governed by a BSD-style license that can be
63 // found in the LICENSE file. 63 // found in the LICENSE file.
64 cr.define("downloads",function(){var Toolbar=Polymer({is:"downloads-toolbar",pro perties:{downloadsShowing:{reflectToAttribute:true,type:Boolean,value:false,obse rver:"downloadsShowingChanged_"},spinnerActive:{type:Boolean,notify:true}},liste ners:{"paper-dropdown-close":"onPaperDropdownClose_","paper-dropdown-open":"onPa perDropdownOpen_"},canUndo:function(){return!this.$.toolbar.getSearchField().isS earchFocused()},canClearAll:function(){return!this.$.toolbar.getSearchField().ge tValue()&&this.downloadsShowing},onFindCommand:function(){this.$.toolbar.getSear chField().showAndFocus()},closeMoreActions_:function(){this.$.more.close()},down loadsShowingChanged_:function(){this.updateClearAll_()},onClearAllTap_:function( ){assert(this.canClearAll());downloads.ActionService.getInstance().clearAll()},o nPaperDropdownClose_:function(){window.removeEventListener("resize",assert(this. boundClose_))},onItemBlur_:function(e){var menu=this.$$("paper-menu");if(menu.it ems.indexOf(e.relatedTarget)>=0)return;this.$.more.restoreFocusOnClose=false;thi s.closeMoreActions_();this.$.more.restoreFocusOnClose=true},onPaperDropdownOpen_ :function(){this.boundClose_=this.boundClose_||this.closeMoreActions_.bind(this) ;window.addEventListener("resize",this.boundClose_)},onSearchChanged_:function(e vent){var actionService=downloads.ActionService.getInstance();if(actionService.s earch(event.detail))this.spinnerActive=actionService.isSearching();this.updateCl earAll_()},onOpenDownloadsFolderTap_:function(){downloads.ActionService.getInsta nce().openDownloadsFolder()},updateClearAll_:function(){this.$$("paper-menu .cle ar-all").hidden=!this.canClearAll()}});return{Toolbar:Toolbar}}); 64 cr.define("downloads",function(){var Toolbar=Polymer({is:"downloads-toolbar",pro perties:{downloadsShowing:{reflectToAttribute:true,type:Boolean,value:false,obse rver:"downloadsShowingChanged_"},spinnerActive:{type:Boolean,notify:true}},liste ners:{"paper-dropdown-close":"onPaperDropdownClose_","paper-dropdown-open":"onPa perDropdownOpen_"},canUndo:function(){return!this.$.toolbar.getSearchField().isS earchFocused()},canClearAll:function(){return!this.$.toolbar.getSearchField().ge tValue()&&this.downloadsShowing},onFindCommand:function(){this.$.toolbar.getSear chField().showAndFocus()},closeMoreActions_:function(){this.$.more.close()},down loadsShowingChanged_:function(){this.updateClearAll_()},onClearAllTap_:function( ){assert(this.canClearAll());downloads.ActionService.getInstance().clearAll()},o nPaperDropdownClose_:function(){window.removeEventListener("resize",assert(this. boundClose_))},onItemBlur_:function(e){var menu=this.$$("paper-menu");if(menu.it ems.indexOf(e.relatedTarget)>=0)return;this.$.more.restoreFocusOnClose=false;thi s.closeMoreActions_();this.$.more.restoreFocusOnClose=true},onPaperDropdownOpen_ :function(){this.boundClose_=this.boundClose_||this.closeMoreActions_.bind(this) ;window.addEventListener("resize",this.boundClose_)},onSearchChanged_:function(e vent){var actionService=downloads.ActionService.getInstance();if(actionService.s earch(event.detail))this.spinnerActive=actionService.isSearching();this.updateCl earAll_()},onOpenDownloadsFolderTap_:function(){downloads.ActionService.getInsta nce().openDownloadsFolder()},updateClearAll_:function(){this.$$("paper-menu .cle ar-all").hidden=!this.canClearAll()}});return{Toolbar:Toolbar}});
65 // Copyright 2015 The Chromium Authors. All rights reserved. 65 // Copyright 2015 The Chromium Authors. All rights reserved.
66 // Use of this source code is governed by a BSD-style license that can be 66 // Use of this source code is governed by a BSD-style license that can be
67 // found in the LICENSE file. 67 // found in the LICENSE file.
68 cr.define("downloads",function(){var Manager=Polymer({is:"downloads-manager",pro perties:{hasDownloads_:{observer:"hasDownloadsChanged_",type:Boolean},hasShadow_ :{type:Boolean,value:false,reflectToAttribute:true},items_:{type:Array,value:fun ction(){return[]}},spinnerActive_:{type:Boolean,notify:true}},hostAttributes:{lo ading:true},listeners:{"downloads-list.scroll":"onListScroll_"},observers:["item sChanged_(items_.*)"],clearAll_:function(){this.set("items_",[])},hasDownloadsCh anged_:function(){if(loadTimeData.getBoolean("allowDeletingHistory"))this.$.tool bar.downloadsShowing=this.hasDownloads_;if(this.hasDownloads_){this.$["downloads -list"].fire("iron-resize")}else{var isSearching=downloads.ActionService.getInst ance().isSearching();var messageToShow=isSearching?"noSearchResults":"noDownload s";this.$["no-downloads"].querySelector("span").textContent=loadTimeData.getStri ng(messageToShow)}},insertItems_:function(index,list){this.splice.apply(this,["i tems_",index,0].concat(list));this.updateHideDates_(index,index+list.length);thi s.removeAttribute("loading");this.spinnerActive_=false},itemsChanged_:function() {this.hasDownloads_=this.items_.length>0},onCanExecute_:function(e){e=e;switch(e .command.id){case"undo-command":e.canExecute=this.$.toolbar.canUndo();break;case "clear-all-command":e.canExecute=this.$.toolbar.canClearAll();break;case"find-co mmand":e.canExecute=true;break}},onCommand_:function(e){if(e.command.id=="clear- all-command")downloads.ActionService.getInstance().clearAll();else if(e.command. id=="undo-command")downloads.ActionService.getInstance().undo();else if(e.comman d.id=="find-command")this.$.toolbar.onFindCommand()},onListScroll_:function(){va r list=this.$["downloads-list"];if(list.scrollHeight-list.scrollTop-list.offsetH eight<=100){downloads.ActionService.getInstance().loadMore()}this.hasShadow_=lis t.scrollTop>0},onLoad_:function(){cr.ui.decorate("command",cr.ui.Command);docume nt.addEventListener("canExecute",this.onCanExecute_.bind(this));document.addEven tListener("command",this.onCommand_.bind(this));downloads.ActionService.getInsta nce().loadMore()},removeItem_:function(index){this.splice("items_",index,1);this .updateHideDates_(index,index);this.onListScroll_()},updateHideDates_:function(s tart,end){for(var i=start;i<=end;++i){var current=this.items_[i];if(!current)con tinue;var prev=this.items_[i-1];var hideDate=!!prev&&prev.date_string==current.d ate_string;this.set("items_."+i+".hideDate",hideDate)}},updateItem_:function(ind ex,data){this.set("items_."+index,data);this.updateHideDates_(index,index);var l ist=this.$["downloads-list"];list.updateSizeForItem(index)}});Manager.clearAll=f unction(){Manager.get().clearAll_()};Manager.get=function(){return queryRequired Element("downloads-manager")};Manager.insertItems=function(index,list){Manager.g et().insertItems_(index,list)};Manager.onLoad=function(){Manager.get().onLoad_() };Manager.removeItem=function(index){Manager.get().removeItem_(index)};Manager.u pdateItem=function(index,data){Manager.get().updateItem_(index,data)};return{Man ager:Manager}}); 68 cr.define("downloads",function(){var Manager=Polymer({is:"downloads-manager",pro perties:{hasDownloads_:{observer:"hasDownloadsChanged_",type:Boolean},hasShadow_ :{type:Boolean,value:false,reflectToAttribute:true},items_:{type:Array,value:fun ction(){return[]}},spinnerActive_:{type:Boolean,notify:true}},hostAttributes:{lo ading:true},listeners:{"downloads-list.scroll":"onListScroll_"},observers:["item sChanged_(items_.*)"],clearAll_:function(){this.set("items_",[])},hasDownloadsCh anged_:function(){if(loadTimeData.getBoolean("allowDeletingHistory"))this.$.tool bar.downloadsShowing=this.hasDownloads_;if(this.hasDownloads_){this.$["downloads -list"].fire("iron-resize")}else{var isSearching=downloads.ActionService.getInst ance().isSearching();var messageToShow=isSearching?"noSearchResults":"noDownload s";this.$["no-downloads"].querySelector("span").textContent=loadTimeData.getStri ng(messageToShow)}},insertItems_:function(index,list){this.splice.apply(this,["i tems_",index,0].concat(list));this.updateHideDates_(index,index+list.length);thi s.removeAttribute("loading");this.spinnerActive_=false},itemsChanged_:function() {this.hasDownloads_=this.items_.length>0},onCanExecute_:function(e){e=e;switch(e .command.id){case"undo-command":e.canExecute=this.$.toolbar.canUndo();break;case "clear-all-command":e.canExecute=this.$.toolbar.canClearAll();break;case"find-co mmand":e.canExecute=true;break}},onCommand_:function(e){if(e.command.id=="clear- all-command")downloads.ActionService.getInstance().clearAll();else if(e.command. id=="undo-command")downloads.ActionService.getInstance().undo();else if(e.comman d.id=="find-command")this.$.toolbar.onFindCommand()},onListScroll_:function(){va r list=this.$["downloads-list"];if(list.scrollHeight-list.scrollTop-list.offsetH eight<=100){downloads.ActionService.getInstance().loadMore()}this.hasShadow_=lis t.scrollTop>0},onLoad_:function(){cr.ui.decorate("command",cr.ui.Command);docume nt.addEventListener("canExecute",this.onCanExecute_.bind(this));document.addEven tListener("command",this.onCommand_.bind(this));downloads.ActionService.getInsta nce().loadMore()},removeItem_:function(index){this.splice("items_",index,1);this .updateHideDates_(index,index);this.onListScroll_()},updateHideDates_:function(s tart,end){for(var i=start;i<=end;++i){var current=this.items_[i];if(!current)con tinue;var prev=this.items_[i-1];var hideDate=!!prev&&prev.date_string==current.d ate_string;this.set("items_."+i+".hideDate",hideDate)}},updateItem_:function(ind ex,data){this.set("items_."+index,data);this.updateHideDates_(index,index);var l ist=this.$["downloads-list"];list.updateSizeForItem(index)}});Manager.clearAll=f unction(){Manager.get().clearAll_()};Manager.get=function(){return queryRequired Element("downloads-manager")};Manager.insertItems=function(index,list){Manager.g et().insertItems_(index,list)};Manager.onLoad=function(){Manager.get().onLoad_() };Manager.removeItem=function(index){Manager.get().removeItem_(index)};Manager.u pdateItem=function(index,data){Manager.get().updateItem_(index,data)};return{Man ager:Manager}});
69 // Copyright 2015 The Chromium Authors. All rights reserved. 69 // Copyright 2015 The Chromium Authors. All rights reserved.
70 // Use of this source code is governed by a BSD-style license that can be 70 // Use of this source code is governed by a BSD-style license that can be
71 // found in the LICENSE file. 71 // found in the LICENSE file.
72 window.addEventListener("load",function(){downloads.Manager.onLoad();document.fo nts.load("bold 12px Roboto")}); 72 window.addEventListener("load",function(){downloads.Manager.onLoad();document.fo nts.load("bold 12px Roboto")});
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/md_history/app.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698