OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 PromiseResolver() { | 4 function PromiseResolver() { |
5 this.resolve_; | 5 this.resolve_; |
6 this.reject_; | 6 this.reject_; |
7 this.promise_ = new Promise(function(resolve, reject) { | 7 this.promise_ = new Promise(function(resolve, reject) { |
8 this.resolve_ = resolve; | 8 this.resolve_ = resolve; |
9 this.reject_ = reject; | 9 this.reject_ = reject; |
10 }.bind(this)); | 10 }.bind(this)); |
(...skipping 6518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6529 for (var prop in rect) { | 6529 for (var prop in rect) { |
6530 if (rect[prop] !== 0) return true; | 6530 if (rect[prop] !== 0) return true; |
6531 } | 6531 } |
6532 return false; | 6532 return false; |
6533 }, | 6533 }, |
6534 _calcSize: function() { | 6534 _calcSize: function() { |
6535 return this.getBoundingClientRect()[this.dimension] + 'px'; | 6535 return this.getBoundingClientRect()[this.dimension] + 'px'; |
6536 } | 6536 } |
6537 }); | 6537 }); |
6538 | 6538 |
6539 Polymer.IronFormElementBehavior = { | |
6540 properties: { | |
6541 name: { | |
6542 type: String | |
6543 }, | |
6544 value: { | |
6545 notify: true, | |
6546 type: String | |
6547 }, | |
6548 required: { | |
6549 type: Boolean, | |
6550 value: false | |
6551 }, | |
6552 _parentForm: { | |
6553 type: Object | |
6554 } | |
6555 }, | |
6556 attached: function() { | |
6557 this.fire('iron-form-element-register'); | |
6558 }, | |
6559 detached: function() { | |
6560 if (this._parentForm) { | |
6561 this._parentForm.fire('iron-form-element-unregister', { | |
6562 target: this | |
6563 }); | |
6564 } | |
6565 } | |
6566 }; | |
6567 | |
6568 Polymer.IronCheckedElementBehaviorImpl = { | |
6569 properties: { | |
6570 checked: { | |
6571 type: Boolean, | |
6572 value: false, | |
6573 reflectToAttribute: true, | |
6574 notify: true, | |
6575 observer: '_checkedChanged' | |
6576 }, | |
6577 toggles: { | |
6578 type: Boolean, | |
6579 value: true, | |
6580 reflectToAttribute: true | |
6581 }, | |
6582 value: { | |
6583 type: String, | |
6584 value: 'on', | |
6585 observer: '_valueChanged' | |
6586 } | |
6587 }, | |
6588 observers: [ '_requiredChanged(required)' ], | |
6589 created: function() { | |
6590 this._hasIronCheckedElementBehavior = true; | |
6591 }, | |
6592 _getValidity: function(_value) { | |
6593 return this.disabled || !this.required || this.checked; | |
6594 }, | |
6595 _requiredChanged: function() { | |
6596 if (this.required) { | |
6597 this.setAttribute('aria-required', 'true'); | |
6598 } else { | |
6599 this.removeAttribute('aria-required'); | |
6600 } | |
6601 }, | |
6602 _checkedChanged: function() { | |
6603 this.active = this.checked; | |
6604 this.fire('iron-change'); | |
6605 }, | |
6606 _valueChanged: function() { | |
6607 if (this.value === undefined || this.value === null) { | |
6608 this.value = 'on'; | |
6609 } | |
6610 } | |
6611 }; | |
6612 | |
6613 Polymer.IronCheckedElementBehavior = [ Polymer.IronFormElementBehavior, Polymer.
IronValidatableBehavior, Polymer.IronCheckedElementBehaviorImpl ]; | |
6614 | |
6615 Polymer.PaperCheckedElementBehaviorImpl = { | |
6616 _checkedChanged: function() { | |
6617 Polymer.IronCheckedElementBehaviorImpl._checkedChanged.call(this); | |
6618 if (this.hasRipple()) { | |
6619 if (this.checked) { | |
6620 this._ripple.setAttribute('checked', ''); | |
6621 } else { | |
6622 this._ripple.removeAttribute('checked'); | |
6623 } | |
6624 } | |
6625 }, | |
6626 _buttonStateChanged: function() { | |
6627 Polymer.PaperRippleBehavior._buttonStateChanged.call(this); | |
6628 if (this.disabled) { | |
6629 return; | |
6630 } | |
6631 if (this.isAttached) { | |
6632 this.checked = this.active; | |
6633 } | |
6634 } | |
6635 }; | |
6636 | |
6637 Polymer.PaperCheckedElementBehavior = [ Polymer.PaperInkyFocusBehavior, Polymer.
IronCheckedElementBehavior, Polymer.PaperCheckedElementBehaviorImpl ]; | |
6638 | |
6639 Polymer({ | |
6640 is: 'paper-checkbox', | |
6641 behaviors: [ Polymer.PaperCheckedElementBehavior ], | |
6642 hostAttributes: { | |
6643 role: 'checkbox', | |
6644 'aria-checked': false, | |
6645 tabindex: 0 | |
6646 }, | |
6647 properties: { | |
6648 ariaActiveAttribute: { | |
6649 type: String, | |
6650 value: 'aria-checked' | |
6651 } | |
6652 }, | |
6653 attached: function() { | |
6654 var inkSize = this.getComputedStyleValue('--calculated-paper-checkbox-ink-si
ze'); | |
6655 if (inkSize === '-1px') { | |
6656 var checkboxSize = parseFloat(this.getComputedStyleValue('--calculated-pap
er-checkbox-size')); | |
6657 var defaultInkSize = Math.floor(8 / 3 * checkboxSize); | |
6658 if (defaultInkSize % 2 !== checkboxSize % 2) { | |
6659 defaultInkSize++; | |
6660 } | |
6661 this.customStyle['--paper-checkbox-ink-size'] = defaultInkSize + 'px'; | |
6662 this.updateStyles(); | |
6663 } | |
6664 }, | |
6665 _computeCheckboxClass: function(checked, invalid) { | |
6666 var className = ''; | |
6667 if (checked) { | |
6668 className += 'checked '; | |
6669 } | |
6670 if (invalid) { | |
6671 className += 'invalid'; | |
6672 } | |
6673 return className; | |
6674 }, | |
6675 _computeCheckmarkClass: function(checked) { | |
6676 return checked ? '' : 'hidden'; | |
6677 }, | |
6678 _createRipple: function() { | |
6679 this._rippleContainer = this.$.checkboxContainer; | |
6680 return Polymer.PaperInkyFocusBehaviorImpl._createRipple.call(this); | |
6681 } | |
6682 }); | |
6683 | |
6684 Polymer({ | 6539 Polymer({ |
6685 is: 'paper-icon-button-light', | 6540 is: 'paper-icon-button-light', |
6686 "extends": 'button', | 6541 "extends": 'button', |
6687 behaviors: [ Polymer.PaperRippleBehavior ], | 6542 behaviors: [ Polymer.PaperRippleBehavior ], |
6688 listeners: { | 6543 listeners: { |
6689 down: '_rippleDown', | 6544 down: '_rippleDown', |
6690 up: '_rippleUp', | 6545 up: '_rippleUp', |
6691 focus: '_rippleDown', | 6546 focus: '_rippleDown', |
6692 blur: '_rippleUp' | 6547 blur: '_rippleUp' |
6693 }, | 6548 }, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6793 properties: { | 6648 properties: { |
6794 item: { | 6649 item: { |
6795 type: Object, | 6650 type: Object, |
6796 observer: 'showIcon_' | 6651 observer: 'showIcon_' |
6797 }, | 6652 }, |
6798 searchTerm: { | 6653 searchTerm: { |
6799 type: String | 6654 type: String |
6800 }, | 6655 }, |
6801 selected: { | 6656 selected: { |
6802 type: Boolean, | 6657 type: Boolean, |
6803 notify: true | 6658 reflectToAttribute: true |
6804 }, | 6659 }, |
6805 isFirstItem: { | 6660 isFirstItem: { |
6806 type: Boolean, | 6661 type: Boolean, |
6807 reflectToAttribute: true | 6662 reflectToAttribute: true |
6808 }, | 6663 }, |
6809 isCardStart: { | 6664 isCardStart: { |
6810 type: Boolean, | 6665 type: Boolean, |
6811 reflectToAttribute: true | 6666 reflectToAttribute: true |
6812 }, | 6667 }, |
6813 isCardEnd: { | 6668 isCardEnd: { |
(...skipping 20 matching lines...) Expand all Loading... |
6834 }); | 6689 }); |
6835 e.preventDefault(); | 6690 e.preventDefault(); |
6836 }, | 6691 }, |
6837 onCheckboxMousedown_: function(e) { | 6692 onCheckboxMousedown_: function(e) { |
6838 if (e.shiftKey) e.preventDefault(); | 6693 if (e.shiftKey) e.preventDefault(); |
6839 }, | 6694 }, |
6840 getEntrySummary_: function() { | 6695 getEntrySummary_: function() { |
6841 var item = this.item; | 6696 var item = this.item; |
6842 return loadTimeData.getStringF('entrySummary', item.dateTimeOfDay, item.st
arred ? loadTimeData.getString('bookmarked') : '', item.title, item.domain); | 6697 return loadTimeData.getStringF('entrySummary', item.dateTimeOfDay, item.st
arred ? loadTimeData.getString('bookmarked') : '', item.title, item.domain); |
6843 }, | 6698 }, |
| 6699 getAriaChecked_: function(selected) { |
| 6700 return selected ? 'true' : 'false'; |
| 6701 }, |
6844 onRemoveBookmarkTap_: function() { | 6702 onRemoveBookmarkTap_: function() { |
6845 if (!this.item.starred) return; | 6703 if (!this.item.starred) return; |
6846 if (this.$$('#bookmark-star') == this.root.activeElement) this.$['menu-but
ton'].focus(); | 6704 if (this.$$('#bookmark-star') == this.root.activeElement) this.$['menu-but
ton'].focus(); |
6847 var browserService = md_history.BrowserService.getInstance(); | 6705 var browserService = md_history.BrowserService.getInstance(); |
6848 browserService.removeBookmark(this.item.url); | 6706 browserService.removeBookmark(this.item.url); |
6849 browserService.recordAction('BookmarkStarClicked'); | 6707 browserService.recordAction('BookmarkStarClicked'); |
6850 this.fire('remove-bookmark-stars', this.item.url); | 6708 this.fire('remove-bookmark-stars', this.item.url); |
6851 }, | 6709 }, |
6852 onMenuButtonTap_: function(e) { | 6710 onMenuButtonTap_: function(e) { |
6853 this.fire('toggle-menu', { | 6711 this.fire('toggle-menu', { |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6999 var itemArrayPath = itemPathComponents.join('.'); | 6857 var itemArrayPath = itemPathComponents.join('.'); |
7000 var lastItemPathComponents = this.lastSelectedPath.split('.'); | 6858 var lastItemPathComponents = this.lastSelectedPath.split('.'); |
7001 var lastItemIndex = Number(lastItemPathComponents.pop()); | 6859 var lastItemIndex = Number(lastItemPathComponents.pop()); |
7002 if (itemArrayPath == lastItemPathComponents.join('.')) { | 6860 if (itemArrayPath == lastItemPathComponents.join('.')) { |
7003 for (var i = Math.min(itemIndex, lastItemIndex); i <= Math.max(itemIndex
, lastItemIndex); i++) { | 6861 for (var i = Math.min(itemIndex, lastItemIndex); i <= Math.max(itemIndex
, lastItemIndex); i++) { |
7004 paths.push(itemArrayPath + '.' + i); | 6862 paths.push(itemArrayPath + '.' + i); |
7005 } | 6863 } |
7006 } | 6864 } |
7007 } | 6865 } |
7008 if (paths.length == 0) paths.push(item.path); | 6866 if (paths.length == 0) paths.push(item.path); |
| 6867 var selected = !this.selectedPaths.has(item.path); |
7009 paths.forEach(function(path) { | 6868 paths.forEach(function(path) { |
7010 this.set(path + '.selected', item.selected); | 6869 this.set(path + '.selected', selected); |
7011 if (item.selected) { | 6870 if (selected) { |
7012 this.selectedPaths.add(path); | 6871 this.selectedPaths.add(path); |
7013 return; | 6872 return; |
7014 } | 6873 } |
7015 this.selectedPaths.delete(path); | 6874 this.selectedPaths.delete(path); |
7016 }.bind(this)); | 6875 }.bind(this)); |
7017 this.lastSelectedPath = itemPath; | 6876 this.lastSelectedPath = itemPath; |
7018 } | 6877 } |
7019 }; | 6878 }; |
7020 | 6879 |
7021 // Copyright 2016 The Chromium Authors. All rights reserved. | 6880 // Copyright 2016 The Chromium Authors. All rights reserved. |
(...skipping 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8827 | 8686 |
8828 case HistoryRange.MONTH: | 8687 case HistoryRange.MONTH: |
8829 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; | 8688 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; |
8830 break; | 8689 break; |
8831 } | 8690 } |
8832 break; | 8691 break; |
8833 } | 8692 } |
8834 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage
View', histogramValue, HistoryPageViewHistogram.END); | 8693 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage
View', histogramValue, HistoryPageViewHistogram.END); |
8835 } | 8694 } |
8836 }); | 8695 }); |
OLD | NEW |