| OLD | NEW |
| 1 Polymer.nar = []; | 1 Polymer.nar = []; |
| 2 Polymer.Annotations = { | 2 Polymer.Annotations = { |
| 3 parseAnnotations: function (template) { | 3 parseAnnotations: function (template) { |
| 4 var list = []; | 4 var list = []; |
| 5 var content = template._content || template.content; | 5 var content = template._content || template.content; |
| 6 this._parseNodeAnnotations(content, list); | 6 this._parseNodeAnnotations(content, list); |
| 7 return list; | 7 return list; |
| 8 }, | 8 }, |
| 9 _parseNodeAnnotations: function (node, list) { | 9 _parseNodeAnnotations: function (node, list) { |
| 10 return node.nodeType === Node.TEXT_NODE ? this._parseTextNodeAnnotation(node, li
st) : this._parseElementAnnotations(node, list); | 10 return node.nodeType === Node.TEXT_NODE ? this._parseTextNodeAnnotation(node, li
st) : this._parseElementAnnotations(node, list); |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 var TAP_DISTANCE = 25; | 399 var TAP_DISTANCE = 25; |
| 400 var TRACK_DISTANCE = 5; | 400 var TRACK_DISTANCE = 5; |
| 401 var TRACK_LENGTH = 2; | 401 var TRACK_LENGTH = 2; |
| 402 var MOUSE_TIMEOUT = 2500; | 402 var MOUSE_TIMEOUT = 2500; |
| 403 var MOUSE_EVENTS = [ | 403 var MOUSE_EVENTS = [ |
| 404 'mousedown', | 404 'mousedown', |
| 405 'mousemove', | 405 'mousemove', |
| 406 'mouseup', | 406 'mouseup', |
| 407 'click' | 407 'click' |
| 408 ]; | 408 ]; |
| 409 var MOUSE_WHICH_TO_BUTTONS = [ |
| 410 0, |
| 411 1, |
| 412 4, |
| 413 2 |
| 414 ]; |
| 415 var MOUSE_HAS_BUTTONS = function () { |
| 416 try { |
| 417 return new MouseEvent('test', { buttons: 1 }).buttons === 1; |
| 418 } catch (e) { |
| 419 return false; |
| 420 } |
| 421 }(); |
| 409 var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/); | 422 var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/); |
| 410 var mouseCanceller = function (mouseEvent) { | 423 var mouseCanceller = function (mouseEvent) { |
| 411 mouseEvent[HANDLED_OBJ] = { skip: true }; | 424 mouseEvent[HANDLED_OBJ] = { skip: true }; |
| 412 if (mouseEvent.type === 'click') { | 425 if (mouseEvent.type === 'click') { |
| 413 var path = Polymer.dom(mouseEvent).path; | 426 var path = Polymer.dom(mouseEvent).path; |
| 414 for (var i = 0; i < path.length; i++) { | 427 for (var i = 0; i < path.length; i++) { |
| 415 if (path[i] === POINTERSTATE.mouse.target) { | 428 if (path[i] === POINTERSTATE.mouse.target) { |
| 416 return; | 429 return; |
| 417 } | 430 } |
| 418 } | 431 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 437 if (!POINTERSTATE.mouse.mouseIgnoreJob) { | 450 if (!POINTERSTATE.mouse.mouseIgnoreJob) { |
| 438 setupTeardownMouseCanceller(true); | 451 setupTeardownMouseCanceller(true); |
| 439 } | 452 } |
| 440 var unset = function () { | 453 var unset = function () { |
| 441 setupTeardownMouseCanceller(); | 454 setupTeardownMouseCanceller(); |
| 442 POINTERSTATE.mouse.target = null; | 455 POINTERSTATE.mouse.target = null; |
| 443 POINTERSTATE.mouse.mouseIgnoreJob = null; | 456 POINTERSTATE.mouse.mouseIgnoreJob = null; |
| 444 }; | 457 }; |
| 445 POINTERSTATE.mouse.mouseIgnoreJob = Polymer.Debounce(POINTERSTATE.mouse.mouseIgn
oreJob, unset, MOUSE_TIMEOUT); | 458 POINTERSTATE.mouse.mouseIgnoreJob = Polymer.Debounce(POINTERSTATE.mouse.mouseIgn
oreJob, unset, MOUSE_TIMEOUT); |
| 446 } | 459 } |
| 460 function hasLeftMouseButton(ev) { |
| 461 var type = ev.type; |
| 462 if (MOUSE_EVENTS.indexOf(type) === -1) { |
| 463 return false; |
| 464 } |
| 465 if (type === 'mousemove') { |
| 466 var buttons = ev.buttons === undefined ? 1 : ev.buttons; |
| 467 if (ev instanceof window.MouseEvent && !MOUSE_HAS_BUTTONS) { |
| 468 buttons = MOUSE_WHICH_TO_BUTTONS[ev.which] || 0; |
| 469 } |
| 470 return Boolean(buttons & 1); |
| 471 } else { |
| 472 var button = ev.button === undefined ? 0 : ev.button; |
| 473 return button === 0; |
| 474 } |
| 475 } |
| 476 function isSyntheticClick(ev) { |
| 477 if (ev.type === 'click') { |
| 478 if (ev.detail === 0) { |
| 479 return true; |
| 480 } |
| 481 var t = Gestures.findOriginalTarget(ev); |
| 482 var bcr = t.getBoundingClientRect(); |
| 483 var x = ev.pageX, y = ev.pageY; |
| 484 return !(x >= bcr.left && x <= bcr.right && (y >= bcr.top && y <= bcr.bottom)); |
| 485 } |
| 486 return false; |
| 487 } |
| 447 var POINTERSTATE = { | 488 var POINTERSTATE = { |
| 448 mouse: { | 489 mouse: { |
| 449 target: null, | 490 target: null, |
| 450 mouseIgnoreJob: null | 491 mouseIgnoreJob: null |
| 451 }, | 492 }, |
| 452 touch: { | 493 touch: { |
| 453 x: 0, | 494 x: 0, |
| 454 y: 0, | 495 y: 0, |
| 455 id: -1, | 496 id: -1, |
| 456 scrollDecided: false | 497 scrollDecided: false |
| 457 } | 498 } |
| 458 }; | 499 }; |
| 459 function firstTouchAction(ev) { | 500 function firstTouchAction(ev) { |
| 460 var path = Polymer.dom(ev).path; | 501 var path = Polymer.dom(ev).path; |
| 461 var ta = 'auto'; | 502 var ta = 'auto'; |
| 462 for (var i = 0, n; i < path.length; i++) { | 503 for (var i = 0, n; i < path.length; i++) { |
| 463 n = path[i]; | 504 n = path[i]; |
| 464 if (n[TOUCH_ACTION]) { | 505 if (n[TOUCH_ACTION]) { |
| 465 ta = n[TOUCH_ACTION]; | 506 ta = n[TOUCH_ACTION]; |
| 466 break; | 507 break; |
| 467 } | 508 } |
| 468 } | 509 } |
| 469 return ta; | 510 return ta; |
| 470 } | 511 } |
| 512 function trackDocument(stateObj, movefn, upfn) { |
| 513 stateObj.movefn = movefn; |
| 514 stateObj.upfn = upfn; |
| 515 document.addEventListener('mousemove', movefn); |
| 516 document.addEventListener('mouseup', upfn); |
| 517 } |
| 518 function untrackDocument(stateObj) { |
| 519 document.removeEventListener('mousemove', stateObj.movefn); |
| 520 document.removeEventListener('mouseup', stateObj.upfn); |
| 521 } |
| 471 var Gestures = { | 522 var Gestures = { |
| 472 gestures: {}, | 523 gestures: {}, |
| 473 recognizers: [], | 524 recognizers: [], |
| 474 deepTargetFind: function (x, y) { | 525 deepTargetFind: function (x, y) { |
| 475 var node = document.elementFromPoint(x, y); | 526 var node = document.elementFromPoint(x, y); |
| 476 var next = node; | 527 var next = node; |
| 477 while (next && next.shadowRoot) { | 528 while (next && next.shadowRoot) { |
| 478 next = next.shadowRoot.elementFromPoint(x, y); | 529 next = next.shadowRoot.elementFromPoint(x, y); |
| 479 if (next) { | 530 if (next) { |
| 480 node = next; | 531 node = next; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 } | 717 } |
| 667 } | 718 } |
| 668 }; | 719 }; |
| 669 Gestures.register({ | 720 Gestures.register({ |
| 670 name: 'downup', | 721 name: 'downup', |
| 671 deps: [ | 722 deps: [ |
| 672 'mousedown', | 723 'mousedown', |
| 673 'touchstart', | 724 'touchstart', |
| 674 'touchend' | 725 'touchend' |
| 675 ], | 726 ], |
| 727 flow: { |
| 728 start: [ |
| 729 'mousedown', |
| 730 'touchstart' |
| 731 ], |
| 732 end: [ |
| 733 'mouseup', |
| 734 'touchend' |
| 735 ] |
| 736 }, |
| 676 emits: [ | 737 emits: [ |
| 677 'down', | 738 'down', |
| 678 'up' | 739 'up' |
| 679 ], | 740 ], |
| 741 info: { |
| 742 movefn: function () { |
| 743 }, |
| 744 upfn: function () { |
| 745 } |
| 746 }, |
| 747 reset: function () { |
| 748 untrackDocument(this.info); |
| 749 }, |
| 680 mousedown: function (e) { | 750 mousedown: function (e) { |
| 751 if (!hasLeftMouseButton(e)) { |
| 752 return; |
| 753 } |
| 681 var t = Gestures.findOriginalTarget(e); | 754 var t = Gestures.findOriginalTarget(e); |
| 682 var self = this; | 755 var self = this; |
| 756 var movefn = function movefn(e) { |
| 757 if (!hasLeftMouseButton(e)) { |
| 758 self.fire('up', t, e); |
| 759 untrackDocument(self.info); |
| 760 } |
| 761 }; |
| 683 var upfn = function upfn(e) { | 762 var upfn = function upfn(e) { |
| 763 if (hasLeftMouseButton(e)) { |
| 684 self.fire('up', t, e); | 764 self.fire('up', t, e); |
| 685 document.removeEventListener('mouseup', upfn); | 765 } |
| 766 untrackDocument(self.info); |
| 686 }; | 767 }; |
| 687 document.addEventListener('mouseup', upfn); | 768 trackDocument(this.info, movefn, upfn); |
| 688 this.fire('down', t, e); | 769 this.fire('down', t, e); |
| 689 }, | 770 }, |
| 690 touchstart: function (e) { | 771 touchstart: function (e) { |
| 691 this.fire('down', Gestures.findOriginalTarget(e), e.changedTouches[0]); | 772 this.fire('down', Gestures.findOriginalTarget(e), e.changedTouches[0]); |
| 692 }, | 773 }, |
| 693 touchend: function (e) { | 774 touchend: function (e) { |
| 694 this.fire('up', Gestures.findOriginalTarget(e), e.changedTouches[0]); | 775 this.fire('up', Gestures.findOriginalTarget(e), e.changedTouches[0]); |
| 695 }, | 776 }, |
| 696 fire: function (type, target, event) { | 777 fire: function (type, target, event) { |
| 697 var self = this; | 778 var self = this; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 728 y: 0, | 809 y: 0, |
| 729 state: 'start', | 810 state: 'start', |
| 730 started: false, | 811 started: false, |
| 731 moves: [], | 812 moves: [], |
| 732 addMove: function (move) { | 813 addMove: function (move) { |
| 733 if (this.moves.length > TRACK_LENGTH) { | 814 if (this.moves.length > TRACK_LENGTH) { |
| 734 this.moves.shift(); | 815 this.moves.shift(); |
| 735 } | 816 } |
| 736 this.moves.push(move); | 817 this.moves.push(move); |
| 737 }, | 818 }, |
| 819 movefn: function () { |
| 820 }, |
| 821 upfn: function () { |
| 822 }, |
| 738 prevent: false | 823 prevent: false |
| 739 }, | 824 }, |
| 740 reset: function () { | 825 reset: function () { |
| 741 this.info.state = 'start'; | 826 this.info.state = 'start'; |
| 742 this.info.started = false; | 827 this.info.started = false; |
| 743 this.info.moves = []; | 828 this.info.moves = []; |
| 744 this.info.x = 0; | 829 this.info.x = 0; |
| 745 this.info.y = 0; | 830 this.info.y = 0; |
| 746 this.info.prevent = false; | 831 this.info.prevent = false; |
| 832 untrackDocument(this.info); |
| 747 }, | 833 }, |
| 748 hasMovedEnough: function (x, y) { | 834 hasMovedEnough: function (x, y) { |
| 749 if (this.info.prevent) { | 835 if (this.info.prevent) { |
| 750 return false; | 836 return false; |
| 751 } | 837 } |
| 752 if (this.info.started) { | 838 if (this.info.started) { |
| 753 return true; | 839 return true; |
| 754 } | 840 } |
| 755 var dx = Math.abs(this.info.x - x); | 841 var dx = Math.abs(this.info.x - x); |
| 756 var dy = Math.abs(this.info.y - y); | 842 var dy = Math.abs(this.info.y - y); |
| 757 return dx >= TRACK_DISTANCE || dy >= TRACK_DISTANCE; | 843 return dx >= TRACK_DISTANCE || dy >= TRACK_DISTANCE; |
| 758 }, | 844 }, |
| 759 mousedown: function (e) { | 845 mousedown: function (e) { |
| 846 if (!hasLeftMouseButton(e)) { |
| 847 return; |
| 848 } |
| 760 var t = Gestures.findOriginalTarget(e); | 849 var t = Gestures.findOriginalTarget(e); |
| 761 var self = this; | 850 var self = this; |
| 762 var movefn = function movefn(e) { | 851 var movefn = function movefn(e) { |
| 763 var x = e.clientX, y = e.clientY; | 852 var x = e.clientX, y = e.clientY; |
| 764 if (self.hasMovedEnough(x, y)) { | 853 if (self.hasMovedEnough(x, y)) { |
| 765 self.info.state = self.info.started ? e.type === 'mouseup' ? 'end' : 'track' : '
start'; | 854 self.info.state = self.info.started ? e.type === 'mouseup' ? 'end' : 'track' : '
start'; |
| 766 self.info.addMove({ | 855 self.info.addMove({ |
| 767 x: x, | 856 x: x, |
| 768 y: y | 857 y: y |
| 769 }); | 858 }); |
| 859 if (!hasLeftMouseButton(e)) { |
| 860 self.info.state = 'end'; |
| 861 untrackDocument(self.info); |
| 862 } |
| 770 self.fire(t, e); | 863 self.fire(t, e); |
| 771 self.info.started = true; | 864 self.info.started = true; |
| 772 } | 865 } |
| 773 }; | 866 }; |
| 774 var upfn = function upfn(e) { | 867 var upfn = function upfn(e) { |
| 775 if (self.info.started) { | 868 if (self.info.started) { |
| 776 Gestures.prevent('tap'); | 869 Gestures.prevent('tap'); |
| 777 movefn(e); | 870 movefn(e); |
| 778 } | 871 } |
| 779 document.removeEventListener('mousemove', movefn); | 872 untrackDocument(self.info); |
| 780 document.removeEventListener('mouseup', upfn); | |
| 781 }; | 873 }; |
| 782 document.addEventListener('mousemove', movefn); | 874 trackDocument(this.info, movefn, upfn); |
| 783 document.addEventListener('mouseup', upfn); | |
| 784 this.info.x = e.clientX; | 875 this.info.x = e.clientX; |
| 785 this.info.y = e.clientY; | 876 this.info.y = e.clientY; |
| 786 }, | 877 }, |
| 787 touchstart: function (e) { | 878 touchstart: function (e) { |
| 788 var ct = e.changedTouches[0]; | 879 var ct = e.changedTouches[0]; |
| 789 this.info.x = ct.clientX; | 880 this.info.x = ct.clientX; |
| 790 this.info.y = ct.clientY; | 881 this.info.y = ct.clientY; |
| 791 }, | 882 }, |
| 792 touchmove: function (e) { | 883 touchmove: function (e) { |
| 793 var t = Gestures.findOriginalTarget(e); | 884 var t = Gestures.findOriginalTarget(e); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 reset: function () { | 959 reset: function () { |
| 869 this.info.x = NaN; | 960 this.info.x = NaN; |
| 870 this.info.y = NaN; | 961 this.info.y = NaN; |
| 871 this.info.prevent = false; | 962 this.info.prevent = false; |
| 872 }, | 963 }, |
| 873 save: function (e) { | 964 save: function (e) { |
| 874 this.info.x = e.clientX; | 965 this.info.x = e.clientX; |
| 875 this.info.y = e.clientY; | 966 this.info.y = e.clientY; |
| 876 }, | 967 }, |
| 877 mousedown: function (e) { | 968 mousedown: function (e) { |
| 969 if (hasLeftMouseButton(e)) { |
| 878 this.save(e); | 970 this.save(e); |
| 971 } |
| 879 }, | 972 }, |
| 880 click: function (e) { | 973 click: function (e) { |
| 974 if (hasLeftMouseButton(e)) { |
| 881 this.forward(e); | 975 this.forward(e); |
| 976 } |
| 882 }, | 977 }, |
| 883 touchstart: function (e) { | 978 touchstart: function (e) { |
| 884 this.save(e.changedTouches[0]); | 979 this.save(e.changedTouches[0]); |
| 885 }, | 980 }, |
| 886 touchend: function (e) { | 981 touchend: function (e) { |
| 887 this.forward(e.changedTouches[0]); | 982 this.forward(e.changedTouches[0]); |
| 888 }, | 983 }, |
| 889 forward: function (e) { | 984 forward: function (e) { |
| 890 var dx = Math.abs(e.clientX - this.info.x); | 985 var dx = Math.abs(e.clientX - this.info.x); |
| 891 var dy = Math.abs(e.clientY - this.info.y); | 986 var dy = Math.abs(e.clientY - this.info.y); |
| 892 var t = Gestures.findOriginalTarget(e); | 987 var t = Gestures.findOriginalTarget(e); |
| 893 if (isNaN(dx) || isNaN(dy) || dx <= TAP_DISTANCE && dy <= TAP_DISTANCE) { | 988 if (isNaN(dx) || isNaN(dy) || dx <= TAP_DISTANCE && dy <= TAP_DISTANCE || isSynt
heticClick(e)) { |
| 894 if (!this.info.prevent) { | 989 if (!this.info.prevent) { |
| 895 Gestures.fire(t, 'tap', { | 990 Gestures.fire(t, 'tap', { |
| 896 x: e.clientX, | 991 x: e.clientX, |
| 897 y: e.clientY, | 992 y: e.clientY, |
| 898 sourceEvent: e | 993 sourceEvent: e |
| 899 }); | 994 }); |
| 900 } | 995 } |
| 901 } | 996 } |
| 902 } | 997 } |
| 903 }); | 998 }); |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 index: index, | 1599 index: index, |
| 1505 kind: note.kind, | 1600 kind: note.kind, |
| 1506 property: note.name, | 1601 property: note.name, |
| 1507 negate: note.negate, | 1602 negate: note.negate, |
| 1508 method: sig.method, | 1603 method: sig.method, |
| 1509 args: sig.args, | 1604 args: sig.args, |
| 1510 trigger: trigger | 1605 trigger: trigger |
| 1511 }); | 1606 }); |
| 1512 }, | 1607 }, |
| 1513 _parseMethod: function (expression) { | 1608 _parseMethod: function (expression) { |
| 1514 var m = expression.match(/(\w*)\((.*)\)/); | 1609 var m = expression.match(/([^\s]+)\((.*)\)/); |
| 1515 if (m) { | 1610 if (m) { |
| 1516 var sig = { | 1611 var sig = { |
| 1517 method: m[1], | 1612 method: m[1], |
| 1518 static: true | 1613 static: true |
| 1519 }; | 1614 }; |
| 1520 if (m[2].trim()) { | 1615 if (m[2].trim()) { |
| 1521 var args = m[2].replace(/\\,/g, ',').split(','); | 1616 var args = m[2].replace(/\\,/g, ',').split(','); |
| 1522 return this._parseArgs(args, sig); | 1617 return this._parseArgs(args, sig); |
| 1523 } else { | 1618 } else { |
| 1524 sig.args = Polymer.nar; | 1619 sig.args = Polymer.nar; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1599 for (var i in initialConfig) { | 1694 for (var i in initialConfig) { |
| 1600 if (initialConfig[i] !== undefined) { | 1695 if (initialConfig[i] !== undefined) { |
| 1601 this._config[i] = initialConfig[i]; | 1696 this._config[i] = initialConfig[i]; |
| 1602 } | 1697 } |
| 1603 } | 1698 } |
| 1604 this._handlers = []; | 1699 this._handlers = []; |
| 1605 }, | 1700 }, |
| 1606 _marshalAttributes: function () { | 1701 _marshalAttributes: function () { |
| 1607 this._takeAttributesToModel(this._config); | 1702 this._takeAttributesToModel(this._config); |
| 1608 }, | 1703 }, |
| 1704 _attributeChangedImpl: function (name) { |
| 1705 var model = this._clientsReadied ? this : this._config; |
| 1706 this._setAttributeToProperty(model, name); |
| 1707 }, |
| 1609 _configValue: function (name, value) { | 1708 _configValue: function (name, value) { |
| 1610 this._config[name] = value; | 1709 this._config[name] = value; |
| 1611 }, | 1710 }, |
| 1612 _beforeClientsReady: function () { | 1711 _beforeClientsReady: function () { |
| 1613 this._configure(); | 1712 this._configure(); |
| 1614 }, | 1713 }, |
| 1615 _configure: function () { | 1714 _configure: function () { |
| 1616 this._configureAnnotationReferences(); | 1715 this._configureAnnotationReferences(); |
| 1617 this._aboveConfig = this.mixin({}, this._config); | 1716 this._aboveConfig = this.mixin({}, this._config); |
| 1618 var config = {}; | 1717 var config = {}; |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 this.notifyPath(path + '.length', array.length); | 1977 this.notifyPath(path + '.length', array.length); |
| 1879 } | 1978 } |
| 1880 change.keySplices = null; | 1979 change.keySplices = null; |
| 1881 change.indexSplices = null; | 1980 change.indexSplices = null; |
| 1882 }, | 1981 }, |
| 1883 push: function (path) { | 1982 push: function (path) { |
| 1884 var array = this.get(path); | 1983 var array = this.get(path); |
| 1885 var args = Array.prototype.slice.call(arguments, 1); | 1984 var args = Array.prototype.slice.call(arguments, 1); |
| 1886 var len = array.length; | 1985 var len = array.length; |
| 1887 var ret = array.push.apply(array, args); | 1986 var ret = array.push.apply(array, args); |
| 1987 if (args.length) { |
| 1888 this._notifySplice(array, path, len, args.length, []); | 1988 this._notifySplice(array, path, len, args.length, []); |
| 1989 } |
| 1889 return ret; | 1990 return ret; |
| 1890 }, | 1991 }, |
| 1891 pop: function (path) { | 1992 pop: function (path) { |
| 1892 var array = this.get(path); | 1993 var array = this.get(path); |
| 1994 var hadLength = Boolean(array.length); |
| 1893 var args = Array.prototype.slice.call(arguments, 1); | 1995 var args = Array.prototype.slice.call(arguments, 1); |
| 1894 var rem = array.slice(-1); | |
| 1895 var ret = array.pop.apply(array, args); | 1996 var ret = array.pop.apply(array, args); |
| 1896 this._notifySplice(array, path, array.length, 0, rem); | 1997 if (hadLength) { |
| 1998 this._notifySplice(array, path, array.length, 0, [ret]); |
| 1999 } |
| 1897 return ret; | 2000 return ret; |
| 1898 }, | 2001 }, |
| 1899 splice: function (path, start, deleteCount) { | 2002 splice: function (path, start, deleteCount) { |
| 1900 var array = this.get(path); | 2003 var array = this.get(path); |
| 2004 if (start < 0) { |
| 2005 start = array.length - Math.floor(-start); |
| 2006 } else { |
| 2007 start = Math.floor(start); |
| 2008 } |
| 2009 if (!start) { |
| 2010 start = 0; |
| 2011 } |
| 1901 var args = Array.prototype.slice.call(arguments, 1); | 2012 var args = Array.prototype.slice.call(arguments, 1); |
| 1902 var ret = array.splice.apply(array, args); | 2013 var ret = array.splice.apply(array, args); |
| 1903 this._notifySplice(array, path, start, args.length - 2, ret); | 2014 var addedCount = Math.max(args.length - 2, 0); |
| 2015 if (addedCount || ret.length) { |
| 2016 this._notifySplice(array, path, start, addedCount, ret); |
| 2017 } |
| 1904 return ret; | 2018 return ret; |
| 1905 }, | 2019 }, |
| 1906 shift: function (path) { | 2020 shift: function (path) { |
| 1907 var array = this.get(path); | 2021 var array = this.get(path); |
| 2022 var hadLength = Boolean(array.length); |
| 1908 var args = Array.prototype.slice.call(arguments, 1); | 2023 var args = Array.prototype.slice.call(arguments, 1); |
| 1909 var ret = array.shift.apply(array, args); | 2024 var ret = array.shift.apply(array, args); |
| 2025 if (hadLength) { |
| 1910 this._notifySplice(array, path, 0, 0, [ret]); | 2026 this._notifySplice(array, path, 0, 0, [ret]); |
| 2027 } |
| 1911 return ret; | 2028 return ret; |
| 1912 }, | 2029 }, |
| 1913 unshift: function (path) { | 2030 unshift: function (path) { |
| 1914 var array = this.get(path); | 2031 var array = this.get(path); |
| 1915 var args = Array.prototype.slice.call(arguments, 1); | 2032 var args = Array.prototype.slice.call(arguments, 1); |
| 1916 var ret = array.unshift.apply(array, args); | 2033 var ret = array.unshift.apply(array, args); |
| 2034 if (args.length) { |
| 1917 this._notifySplice(array, path, 0, args.length, []); | 2035 this._notifySplice(array, path, 0, args.length, []); |
| 2036 } |
| 1918 return ret; | 2037 return ret; |
| 1919 } | 2038 } |
| 1920 }); | 2039 }); |
| 1921 }()); | 2040 }()); |
| 1922 Polymer.Base._addFeature({ | 2041 Polymer.Base._addFeature({ |
| 1923 resolveUrl: function (url) { | 2042 resolveUrl: function (url) { |
| 1924 var module = Polymer.DomModule.import(this.is); | 2043 var module = Polymer.DomModule.import(this.is); |
| 1925 var root = ''; | 2044 var root = ''; |
| 1926 if (module) { | 2045 if (module) { |
| 1927 var assetPath = module.getAttribute('assetpath') || ''; | 2046 var assetPath = module.getAttribute('assetpath') || ''; |
| 1928 root = Polymer.ResolveUrl.resolveUrl(assetPath, module.ownerDocument.baseURI); | 2047 root = Polymer.ResolveUrl.resolveUrl(assetPath, module.ownerDocument.baseURI); |
| 1929 } | 2048 } |
| 1930 return Polymer.ResolveUrl.resolveUrl(url, root); | 2049 return Polymer.ResolveUrl.resolveUrl(url, root); |
| 1931 } | 2050 } |
| 1932 }); | 2051 }); |
| 1933 Polymer.CssParse = function () { | 2052 Polymer.CssParse = function () { |
| 1934 var api = { | 2053 var api = { |
| 1935 parse: function (text) { | 2054 parse: function (text) { |
| 1936 text = this._clean(text); | 2055 text = this._clean(text); |
| 1937 return this._parseCss(this._lex(text), text); | 2056 return this._parseCss(this._lex(text), text); |
| 1938 }, | 2057 }, |
| 1939 _clean: function (cssText) { | 2058 _clean: function (cssText) { |
| 1940 return cssText.replace(rx.comments, '').replace(rx.port, ''); | 2059 return cssText.replace(this._rx.comments, '').replace(this._rx.port, ''); |
| 1941 }, | 2060 }, |
| 1942 _lex: function (text) { | 2061 _lex: function (text) { |
| 1943 var root = { | 2062 var root = { |
| 1944 start: 0, | 2063 start: 0, |
| 1945 end: text.length | 2064 end: text.length |
| 1946 }; | 2065 }; |
| 1947 var n = root; | 2066 var n = root; |
| 1948 for (var i = 0, s = 0, l = text.length; i < l; i++) { | 2067 for (var i = 0, s = 0, l = text.length; i < l; i++) { |
| 1949 switch (text[i]) { | 2068 switch (text[i]) { |
| 1950 case this.OPEN_BRACE: | 2069 case this.OPEN_BRACE: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1969 return root; | 2088 return root; |
| 1970 }, | 2089 }, |
| 1971 _parseCss: function (node, text) { | 2090 _parseCss: function (node, text) { |
| 1972 var t = text.substring(node.start, node.end - 1); | 2091 var t = text.substring(node.start, node.end - 1); |
| 1973 node.parsedCssText = node.cssText = t.trim(); | 2092 node.parsedCssText = node.cssText = t.trim(); |
| 1974 if (node.parent) { | 2093 if (node.parent) { |
| 1975 var ss = node.previous ? node.previous.end : node.parent.start; | 2094 var ss = node.previous ? node.previous.end : node.parent.start; |
| 1976 t = text.substring(ss, node.start - 1); | 2095 t = text.substring(ss, node.start - 1); |
| 1977 t = t.substring(t.lastIndexOf(';') + 1); | 2096 t = t.substring(t.lastIndexOf(';') + 1); |
| 1978 var s = node.parsedSelector = node.selector = t.trim(); | 2097 var s = node.parsedSelector = node.selector = t.trim(); |
| 1979 node.atRule = s.indexOf(AT_START) === 0; | 2098 node.atRule = s.indexOf(this.AT_START) === 0; |
| 1980 if (node.atRule) { | 2099 if (node.atRule) { |
| 1981 if (s.indexOf(MEDIA_START) === 0) { | 2100 if (s.indexOf(this.MEDIA_START) === 0) { |
| 1982 node.type = this.types.MEDIA_RULE; | 2101 node.type = this.types.MEDIA_RULE; |
| 1983 } else if (s.match(rx.keyframesRule)) { | 2102 } else if (s.match(this._rx.keyframesRule)) { |
| 1984 node.type = this.types.KEYFRAMES_RULE; | 2103 node.type = this.types.KEYFRAMES_RULE; |
| 1985 } | 2104 } |
| 1986 } else { | 2105 } else { |
| 1987 if (s.indexOf(VAR_START) === 0) { | 2106 if (s.indexOf(this.VAR_START) === 0) { |
| 1988 node.type = this.types.MIXIN_RULE; | 2107 node.type = this.types.MIXIN_RULE; |
| 1989 } else { | 2108 } else { |
| 1990 node.type = this.types.STYLE_RULE; | 2109 node.type = this.types.STYLE_RULE; |
| 1991 } | 2110 } |
| 1992 } | 2111 } |
| 1993 } | 2112 } |
| 1994 var r$ = node.rules; | 2113 var r$ = node.rules; |
| 1995 if (r$) { | 2114 if (r$) { |
| 1996 for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) { | 2115 for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) { |
| 1997 this._parseCss(r, text); | 2116 this._parseCss(r, text); |
| 1998 } | 2117 } |
| 1999 } | 2118 } |
| 2000 return node; | 2119 return node; |
| 2001 }, | 2120 }, |
| 2002 stringify: function (node, preserveProperties, text) { | 2121 stringify: function (node, preserveProperties, text) { |
| 2003 text = text || ''; | 2122 text = text || ''; |
| 2004 var cssText = ''; | 2123 var cssText = ''; |
| 2005 if (node.cssText || node.rules) { | 2124 if (node.cssText || node.rules) { |
| 2006 var r$ = node.rules; | 2125 var r$ = node.rules; |
| 2007 if (r$ && (preserveProperties || !hasMixinRules(r$))) { | 2126 if (r$ && (preserveProperties || !this._hasMixinRules(r$))) { |
| 2008 for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) { | 2127 for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) { |
| 2009 cssText = this.stringify(r, preserveProperties, cssText); | 2128 cssText = this.stringify(r, preserveProperties, cssText); |
| 2010 } | 2129 } |
| 2011 } else { | 2130 } else { |
| 2012 cssText = preserveProperties ? node.cssText : removeCustomProps(node.cssText); | 2131 cssText = preserveProperties ? node.cssText : this.removeCustomProps(node.cssTex
t); |
| 2013 cssText = cssText.trim(); | 2132 cssText = cssText.trim(); |
| 2014 if (cssText) { | 2133 if (cssText) { |
| 2015 cssText = ' ' + cssText + '\n'; | 2134 cssText = ' ' + cssText + '\n'; |
| 2016 } | 2135 } |
| 2017 } | 2136 } |
| 2018 } | 2137 } |
| 2019 if (cssText) { | 2138 if (cssText) { |
| 2020 if (node.selector) { | 2139 if (node.selector) { |
| 2021 text += node.selector + ' ' + this.OPEN_BRACE + '\n'; | 2140 text += node.selector + ' ' + this.OPEN_BRACE + '\n'; |
| 2022 } | 2141 } |
| 2023 text += cssText; | 2142 text += cssText; |
| 2024 if (node.selector) { | 2143 if (node.selector) { |
| 2025 text += this.CLOSE_BRACE + '\n\n'; | 2144 text += this.CLOSE_BRACE + '\n\n'; |
| 2026 } | 2145 } |
| 2027 } | 2146 } |
| 2028 return text; | 2147 return text; |
| 2029 }, | 2148 }, |
| 2149 _hasMixinRules: function (rules) { |
| 2150 return rules[0].selector.indexOf(this.VAR_START) >= 0; |
| 2151 }, |
| 2152 removeCustomProps: function (cssText) { |
| 2153 cssText = this.removeCustomPropAssignment(cssText); |
| 2154 return this.removeCustomPropApply(cssText); |
| 2155 }, |
| 2156 removeCustomPropAssignment: function (cssText) { |
| 2157 return cssText.replace(this._rx.customProp, '').replace(this._rx.mixinProp, ''); |
| 2158 }, |
| 2159 removeCustomPropApply: function (cssText) { |
| 2160 return cssText.replace(this._rx.mixinApply, '').replace(this._rx.varApply, ''); |
| 2161 }, |
| 2030 types: { | 2162 types: { |
| 2031 STYLE_RULE: 1, | 2163 STYLE_RULE: 1, |
| 2032 KEYFRAMES_RULE: 7, | 2164 KEYFRAMES_RULE: 7, |
| 2033 MEDIA_RULE: 4, | 2165 MEDIA_RULE: 4, |
| 2034 MIXIN_RULE: 1000 | 2166 MIXIN_RULE: 1000 |
| 2035 }, | 2167 }, |
| 2036 OPEN_BRACE: '{', | 2168 OPEN_BRACE: '{', |
| 2037 CLOSE_BRACE: '}' | 2169 CLOSE_BRACE: '}', |
| 2038 }; | 2170 _rx: { |
| 2039 function hasMixinRules(rules) { | |
| 2040 return rules[0].selector.indexOf(VAR_START) >= 0; | |
| 2041 } | |
| 2042 function removeCustomProps(cssText) { | |
| 2043 return cssText.replace(rx.customProp, '').replace(rx.mixinProp, '').replace(rx.m
ixinApply, '').replace(rx.varApply, ''); | |
| 2044 } | |
| 2045 var VAR_START = '--'; | |
| 2046 var MEDIA_START = '@media'; | |
| 2047 var AT_START = '@'; | |
| 2048 var rx = { | |
| 2049 comments: /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim, | 2171 comments: /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim, |
| 2050 port: /@import[^;]*;/gim, | 2172 port: /@import[^;]*;/gim, |
| 2051 customProp: /(?:^|[\s;])--[^;{]*?:[^{};]*?(?:[;\n]|$)/gim, | 2173 customProp: /(?:^|[\s;])--[^;{]*?:[^{};]*?(?:[;\n]|$)/gim, |
| 2052 mixinProp: /(?:^|[\s;])--[^;{]*?:[^{;]*?{[^}]*?}(?:[;\n]|$)?/gim, | 2174 mixinProp: /(?:^|[\s;])--[^;{]*?:[^{;]*?{[^}]*?}(?:[;\n]|$)?/gim, |
| 2053 mixinApply: /@apply[\s]*\([^)]*?\)[\s]*(?:[;\n]|$)?/gim, | 2175 mixinApply: /@apply[\s]*\([^)]*?\)[\s]*(?:[;\n]|$)?/gim, |
| 2054 varApply: /[^;:]*?:[^;]*var[^;]*(?:[;\n]|$)?/gim, | 2176 varApply: /[^;:]*?:[^;]*var[^;]*(?:[;\n]|$)?/gim, |
| 2055 keyframesRule: /^@[^\s]*keyframes/ | 2177 keyframesRule: /^@[^\s]*keyframes/ |
| 2178 }, |
| 2179 VAR_START: '--', |
| 2180 MEDIA_START: '@media', |
| 2181 AT_START: '@' |
| 2056 }; | 2182 }; |
| 2057 return api; | 2183 return api; |
| 2058 }(); | 2184 }(); |
| 2059 Polymer.StyleUtil = function () { | 2185 Polymer.StyleUtil = function () { |
| 2060 return { | 2186 return { |
| 2061 MODULE_STYLES_SELECTOR: 'style, link[rel=import][type~=css]', | 2187 MODULE_STYLES_SELECTOR: 'style, link[rel=import][type~=css]', |
| 2062 toCssText: function (rules, callback, preserveProperties) { | 2188 toCssText: function (rules, callback, preserveProperties) { |
| 2063 if (typeof rules === 'string') { | 2189 if (typeof rules === 'string') { |
| 2064 rules = this.parser.parse(rules); | 2190 rules = this.parser.parse(rules); |
| 2065 } | 2191 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2078 rulesForStyle: function (style) { | 2204 rulesForStyle: function (style) { |
| 2079 if (!style.__cssRules && style.textContent) { | 2205 if (!style.__cssRules && style.textContent) { |
| 2080 style.__cssRules = this.parser.parse(style.textContent); | 2206 style.__cssRules = this.parser.parse(style.textContent); |
| 2081 } | 2207 } |
| 2082 return style.__cssRules; | 2208 return style.__cssRules; |
| 2083 }, | 2209 }, |
| 2084 clearStyleRules: function (style) { | 2210 clearStyleRules: function (style) { |
| 2085 style.__cssRules = null; | 2211 style.__cssRules = null; |
| 2086 }, | 2212 }, |
| 2087 forEachStyleRule: function (node, callback) { | 2213 forEachStyleRule: function (node, callback) { |
| 2088 var s = node.selector; | 2214 var s = node.parsedSelector; |
| 2089 var skipRules = false; | 2215 var skipRules = false; |
| 2090 if (node.type === this.ruleTypes.STYLE_RULE) { | 2216 if (node.type === this.ruleTypes.STYLE_RULE) { |
| 2091 callback(node); | 2217 callback(node); |
| 2092 } else if (node.type === this.ruleTypes.KEYFRAMES_RULE || node.type === this.rul
eTypes.MIXIN_RULE) { | 2218 } else if (node.type === this.ruleTypes.KEYFRAMES_RULE || node.type === this.rul
eTypes.MIXIN_RULE) { |
| 2093 skipRules = true; | 2219 skipRules = true; |
| 2094 } | 2220 } |
| 2095 var r$ = node.rules; | 2221 var r$ = node.rules; |
| 2096 if (r$ && !skipRules) { | 2222 if (r$ && !skipRules) { |
| 2097 for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) { | 2223 for (var i = 0, l = r$.length, r; i < l && (r = r$[i]); i++) { |
| 2098 this.forEachStyleRule(r, callback); | 2224 this.forEachStyleRule(r, callback); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2218 return ext ? '[is=' + scope + ']' : scope; | 2344 return ext ? '[is=' + scope + ']' : scope; |
| 2219 }, | 2345 }, |
| 2220 rule: function (rule, scope, hostScope) { | 2346 rule: function (rule, scope, hostScope) { |
| 2221 this._transformRule(rule, this._transformComplexSelector, scope, hostScope); | 2347 this._transformRule(rule, this._transformComplexSelector, scope, hostScope); |
| 2222 }, | 2348 }, |
| 2223 _transformRule: function (rule, transformer, scope, hostScope) { | 2349 _transformRule: function (rule, transformer, scope, hostScope) { |
| 2224 var p$ = rule.selector.split(COMPLEX_SELECTOR_SEP); | 2350 var p$ = rule.selector.split(COMPLEX_SELECTOR_SEP); |
| 2225 for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) { | 2351 for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) { |
| 2226 p$[i] = transformer.call(this, p, scope, hostScope); | 2352 p$[i] = transformer.call(this, p, scope, hostScope); |
| 2227 } | 2353 } |
| 2228 rule.selector = p$.join(COMPLEX_SELECTOR_SEP); | 2354 rule.selector = rule.transformedSelector = p$.join(COMPLEX_SELECTOR_SEP); |
| 2229 }, | 2355 }, |
| 2230 _transformComplexSelector: function (selector, scope, hostScope) { | 2356 _transformComplexSelector: function (selector, scope, hostScope) { |
| 2231 var stop = false; | 2357 var stop = false; |
| 2232 var hostContext = false; | 2358 var hostContext = false; |
| 2233 var self = this; | 2359 var self = this; |
| 2234 selector = selector.replace(SIMPLE_SELECTOR_SEP, function (m, c, s) { | 2360 selector = selector.replace(SIMPLE_SELECTOR_SEP, function (m, c, s) { |
| 2235 if (!stop) { | 2361 if (!stop) { |
| 2236 var info = self._transformCompoundSelector(s, c, scope, hostScope); | 2362 var info = self._transformCompoundSelector(s, c, scope, hostScope); |
| 2237 stop = stop || info.stop; | 2363 stop = stop || info.stop; |
| 2238 hostContext = hostContext || info.hostContext; | 2364 hostContext = hostContext || info.hostContext; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2573 var propertyValue = self.valueForProperty(props[value], props) || (props[fallbac
k] ? self.valueForProperty(props[fallback], props) : fallback); | 2699 var propertyValue = self.valueForProperty(props[value], props) || (props[fallbac
k] ? self.valueForProperty(props[fallback], props) : fallback); |
| 2574 return prefix + (propertyValue || ''); | 2700 return prefix + (propertyValue || ''); |
| 2575 }; | 2701 }; |
| 2576 property = property.replace(this.rx.VAR_MATCH, fn); | 2702 property = property.replace(this.rx.VAR_MATCH, fn); |
| 2577 } | 2703 } |
| 2578 } | 2704 } |
| 2579 return property && property.trim() || ''; | 2705 return property && property.trim() || ''; |
| 2580 }, | 2706 }, |
| 2581 valueForProperties: function (property, props) { | 2707 valueForProperties: function (property, props) { |
| 2582 var parts = property.split(';'); | 2708 var parts = property.split(';'); |
| 2583 for (var i = 0, p, m; i < parts.length && (p = parts[i]); i++) { | 2709 for (var i = 0, p, m; i < parts.length; i++) { |
| 2710 if (p = parts[i]) { |
| 2584 m = p.match(this.rx.MIXIN_MATCH); | 2711 m = p.match(this.rx.MIXIN_MATCH); |
| 2585 if (m) { | 2712 if (m) { |
| 2586 p = this.valueForProperty(props[m[1]], props); | 2713 p = this.valueForProperty(props[m[1]], props); |
| 2587 } else { | 2714 } else { |
| 2588 var pp = p.split(':'); | 2715 var pp = p.split(':'); |
| 2589 if (pp[1]) { | 2716 if (pp[1]) { |
| 2590 pp[1] = pp[1].trim(); | 2717 pp[1] = pp[1].trim(); |
| 2591 pp[1] = this.valueForProperty(pp[1], props) || pp[1]; | 2718 pp[1] = this.valueForProperty(pp[1], props) || pp[1]; |
| 2592 } | 2719 } |
| 2593 p = pp.join(':'); | 2720 p = pp.join(':'); |
| 2594 } | 2721 } |
| 2595 parts[i] = p && p.lastIndexOf(';') === p.length - 1 ? p.slice(0, -1) : p || ''; | 2722 parts[i] = p && p.lastIndexOf(';') === p.length - 1 ? p.slice(0, -1) : p || ''; |
| 2596 } | 2723 } |
| 2724 } |
| 2597 return parts.join(';'); | 2725 return parts.join(';'); |
| 2598 }, | 2726 }, |
| 2599 applyProperties: function (rule, props) { | 2727 applyProperties: function (rule, props) { |
| 2600 var output = ''; | 2728 var output = ''; |
| 2601 if (!rule.propertyInfo) { | 2729 if (!rule.propertyInfo) { |
| 2602 this.decorateRule(rule); | 2730 this.decorateRule(rule); |
| 2603 } | 2731 } |
| 2604 if (rule.propertyInfo.cssText) { | 2732 if (rule.propertyInfo.cssText) { |
| 2605 output = this.valueForProperties(rule.propertyInfo.cssText, props); | 2733 output = this.valueForProperties(rule.propertyInfo.cssText, props); |
| 2606 } | 2734 } |
| 2607 rule.cssText = output; | 2735 rule.cssText = output; |
| 2608 }, | 2736 }, |
| 2609 propertyDataFromStyles: function (styles, element) { | 2737 propertyDataFromStyles: function (styles, element) { |
| 2610 var props = {}, self = this; | 2738 var props = {}, self = this; |
| 2611 var o = [], i = 0; | 2739 var o = [], i = 0; |
| 2612 styleUtil.forRulesInStyles(styles, function (rule) { | 2740 styleUtil.forRulesInStyles(styles, function (rule) { |
| 2613 if (!rule.propertyInfo) { | 2741 if (!rule.propertyInfo) { |
| 2614 self.decorateRule(rule); | 2742 self.decorateRule(rule); |
| 2615 } | 2743 } |
| 2616 if (element && rule.propertyInfo.properties && matchesSelector.call(element, rul
e.selector)) { | 2744 if (element && rule.propertyInfo.properties && matchesSelector.call(element, rul
e.transformedSelector || rule.parsedSelector)) { |
| 2617 self.collectProperties(rule, props); | 2745 self.collectProperties(rule, props); |
| 2618 addToBitMask(i, o); | 2746 addToBitMask(i, o); |
| 2619 } | 2747 } |
| 2620 i++; | 2748 i++; |
| 2621 }); | 2749 }); |
| 2622 return { | 2750 return { |
| 2623 properties: props, | 2751 properties: props, |
| 2624 key: o | 2752 key: o |
| 2625 }; | 2753 }; |
| 2626 }, | 2754 }, |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3004 this._addHostAttributes(b.hostAttributes); | 3132 this._addHostAttributes(b.hostAttributes); |
| 3005 }, | 3133 }, |
| 3006 _initFeatures: function () { | 3134 _initFeatures: function () { |
| 3007 this._poolContent(); | 3135 this._poolContent(); |
| 3008 this._setupConfigure(); | 3136 this._setupConfigure(); |
| 3009 this._setupStyleProperties(); | 3137 this._setupStyleProperties(); |
| 3010 this._pushHost(); | 3138 this._pushHost(); |
| 3011 this._stampTemplate(); | 3139 this._stampTemplate(); |
| 3012 this._popHost(); | 3140 this._popHost(); |
| 3013 this._marshalAnnotationReferences(); | 3141 this._marshalAnnotationReferences(); |
| 3014 this._marshalHostAttributes(); | |
| 3015 this._setupDebouncers(); | 3142 this._setupDebouncers(); |
| 3016 this._marshalInstanceEffects(); | 3143 this._marshalInstanceEffects(); |
| 3144 this._marshalHostAttributes(); |
| 3017 this._marshalBehaviors(); | 3145 this._marshalBehaviors(); |
| 3018 this._marshalAttributes(); | 3146 this._marshalAttributes(); |
| 3019 this._tryReady(); | 3147 this._tryReady(); |
| 3020 }, | 3148 }, |
| 3021 _marshalBehavior: function (b) { | 3149 _marshalBehavior: function (b) { |
| 3022 this._listenListeners(b.listeners); | 3150 this._listenListeners(b.listeners); |
| 3023 } | 3151 } |
| 3024 }); | 3152 }); |
| 3025 (function () { | 3153 (function () { |
| 3026 var nativeShadow = Polymer.Settings.useNativeShadow; | 3154 var nativeShadow = Polymer.Settings.useNativeShadow; |
| 3027 var propertyUtils = Polymer.StyleProperties; | 3155 var propertyUtils = Polymer.StyleProperties; |
| 3028 var styleUtil = Polymer.StyleUtil; | 3156 var styleUtil = Polymer.StyleUtil; |
| 3157 var cssParse = Polymer.CssParse; |
| 3029 var styleDefaults = Polymer.StyleDefaults; | 3158 var styleDefaults = Polymer.StyleDefaults; |
| 3030 var styleTransformer = Polymer.StyleTransformer; | 3159 var styleTransformer = Polymer.StyleTransformer; |
| 3031 Polymer({ | 3160 Polymer({ |
| 3032 is: 'custom-style', | 3161 is: 'custom-style', |
| 3033 extends: 'style', | 3162 extends: 'style', |
| 3034 created: function () { | 3163 created: function () { |
| 3035 this._tryApply(); | 3164 this._tryApply(); |
| 3036 }, | 3165 }, |
| 3037 attached: function () { | 3166 attached: function () { |
| 3038 this._tryApply(); | 3167 this._tryApply(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3056 } | 3185 } |
| 3057 }, | 3186 }, |
| 3058 _apply: function () { | 3187 _apply: function () { |
| 3059 var e = this.__appliedElement || this; | 3188 var e = this.__appliedElement || this; |
| 3060 this._computeStyleProperties(); | 3189 this._computeStyleProperties(); |
| 3061 var props = this._styleProperties; | 3190 var props = this._styleProperties; |
| 3062 var self = this; | 3191 var self = this; |
| 3063 e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e), function (rule)
{ | 3192 e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e), function (rule)
{ |
| 3064 var css = rule.cssText = rule.parsedCssText; | 3193 var css = rule.cssText = rule.parsedCssText; |
| 3065 if (rule.propertyInfo && rule.propertyInfo.cssText) { | 3194 if (rule.propertyInfo && rule.propertyInfo.cssText) { |
| 3066 css = css.replace(propertyUtils.rx.VAR_ASSIGN, ''); | 3195 css = cssParse.removeCustomPropAssignment(css); |
| 3067 rule.cssText = propertyUtils.valueForProperties(css, props); | 3196 rule.cssText = propertyUtils.valueForProperties(css, props); |
| 3068 } | 3197 } |
| 3069 styleTransformer.documentRule(rule); | 3198 styleTransformer.documentRule(rule); |
| 3070 }); | 3199 }); |
| 3071 } | 3200 } |
| 3072 }); | 3201 }); |
| 3073 }()); | 3202 }()); |
| 3074 Polymer.Templatizer = { | 3203 Polymer.Templatizer = { |
| 3075 properties: { __hideTemplateChildren__: { observer: '_showHideChildren' } }, | 3204 properties: { __hideTemplateChildren__: { observer: '_showHideChildren' } }, |
| 3076 _instanceProps: Polymer.nob, | 3205 _instanceProps: Polymer.nob, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 3104 template._content._ctor = ctor; | 3233 template._content._ctor = ctor; |
| 3105 this.ctor = ctor; | 3234 this.ctor = ctor; |
| 3106 }, | 3235 }, |
| 3107 _getRootDataHost: function () { | 3236 _getRootDataHost: function () { |
| 3108 return this.dataHost && this.dataHost._rootDataHost || this.dataHost; | 3237 return this.dataHost && this.dataHost._rootDataHost || this.dataHost; |
| 3109 }, | 3238 }, |
| 3110 _showHideChildrenImpl: function (hide) { | 3239 _showHideChildrenImpl: function (hide) { |
| 3111 var c = this._children; | 3240 var c = this._children; |
| 3112 for (var i = 0; i < c.length; i++) { | 3241 for (var i = 0; i < c.length; i++) { |
| 3113 var n = c[i]; | 3242 var n = c[i]; |
| 3114 if (n.style) { | 3243 if (Boolean(hide) != Boolean(n.__hideTemplateChildren__)) { |
| 3115 n.style.display = hide ? 'none' : ''; | 3244 if (n.nodeType === Node.TEXT_NODE) { |
| 3245 if (hide) { |
| 3246 n.__polymerTextContent__ = n.textContent; |
| 3247 n.textContent = ''; |
| 3248 } else { |
| 3249 n.textContent = n.__polymerTextContent__; |
| 3250 } |
| 3251 } else if (n.style) { |
| 3252 if (hide) { |
| 3253 n.__polymerDisplay__ = n.style.display; |
| 3254 n.style.display = 'none'; |
| 3255 } else { |
| 3256 n.style.display = n.__polymerDisplay__; |
| 3257 } |
| 3258 } |
| 3259 } |
| 3116 n.__hideTemplateChildren__ = hide; | 3260 n.__hideTemplateChildren__ = hide; |
| 3117 } | 3261 } |
| 3118 } | |
| 3119 }, | 3262 }, |
| 3120 _debounceTemplate: function (fn) { | 3263 _debounceTemplate: function (fn) { |
| 3121 Polymer.dom.addDebouncer(this.debounce('_debounceTemplate', fn)); | 3264 Polymer.dom.addDebouncer(this.debounce('_debounceTemplate', fn)); |
| 3122 }, | 3265 }, |
| 3123 _flushTemplates: function (debouncerExpired) { | 3266 _flushTemplates: function (debouncerExpired) { |
| 3124 Polymer.dom.flush(); | 3267 Polymer.dom.flush(); |
| 3125 }, | 3268 }, |
| 3126 _customPrepEffects: function (archetype) { | 3269 _customPrepEffects: function (archetype) { |
| 3127 var parentProps = archetype._parentProps; | 3270 var parentProps = archetype._parentProps; |
| 3128 for (var prop in parentProps) { | 3271 for (var prop in parentProps) { |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3790 indexForElement: function (el) { | 3933 indexForElement: function (el) { |
| 3791 var instance = this.modelForElement(el); | 3934 var instance = this.modelForElement(el); |
| 3792 return instance && instance[this.indexAs]; | 3935 return instance && instance[this.indexAs]; |
| 3793 } | 3936 } |
| 3794 }); | 3937 }); |
| 3795 Polymer({ | 3938 Polymer({ |
| 3796 is: 'array-selector', | 3939 is: 'array-selector', |
| 3797 properties: { | 3940 properties: { |
| 3798 items: { | 3941 items: { |
| 3799 type: Array, | 3942 type: Array, |
| 3800 observer: '_itemsChanged' | 3943 observer: '_resetSelection' |
| 3944 }, |
| 3945 multi: { |
| 3946 type: Boolean, |
| 3947 value: false, |
| 3948 observer: '_resetSelection' |
| 3801 }, | 3949 }, |
| 3802 selected: { | 3950 selected: { |
| 3803 type: Object, | 3951 type: Object, |
| 3804 notify: true | 3952 notify: true |
| 3805 }, | 3953 }, |
| 3806 toggle: Boolean, | 3954 toggle: { |
| 3807 multi: Boolean | 3955 type: Boolean, |
| 3956 value: false |
| 3957 } |
| 3808 }, | 3958 }, |
| 3809 _itemsChanged: function () { | 3959 _resetSelection: function () { |
| 3810 if (Array.isArray(this.selected)) { | 3960 if (Array.isArray(this.selected)) { |
| 3811 for (var i = 0; i < this.selected.length; i++) { | 3961 for (var i = 0; i < this.selected.length; i++) { |
| 3812 this.unlinkPaths('selected.' + i); | 3962 this.unlinkPaths('selected.' + i); |
| 3813 } | 3963 } |
| 3814 } else { | 3964 } else { |
| 3815 this.unlinkPaths('selected'); | 3965 this.unlinkPaths('selected'); |
| 3816 } | 3966 } |
| 3817 if (this.multi) { | 3967 if (this.multi) { |
| 3968 if (!this.selected || this.selected.length) { |
| 3818 this.selected = []; | 3969 this.selected = []; |
| 3970 this._selectedColl = Polymer.Collection.get(this.selected); |
| 3971 } |
| 3819 } else { | 3972 } else { |
| 3820 this.selected = null; | 3973 this.selected = null; |
| 3974 this._selectedColl = null; |
| 3975 } |
| 3976 }, |
| 3977 isSelected: function (item) { |
| 3978 if (this.multi) { |
| 3979 return this._selectedColl.getKey(item) !== undefined; |
| 3980 } else { |
| 3981 return this.selected == item; |
| 3821 } | 3982 } |
| 3822 }, | 3983 }, |
| 3823 deselect: function (item) { | 3984 deselect: function (item) { |
| 3824 if (this.multi) { | 3985 if (this.multi) { |
| 3825 var scol = Polymer.Collection.get(this.selected); | 3986 if (this.isSelected(item)) { |
| 3826 var sidx = this.selected.indexOf(item); | 3987 var skey = this._selectedColl.getKey(item); |
| 3827 if (sidx >= 0) { | 3988 this.arrayDelete('selected', item); |
| 3828 var skey = scol.getKey(item); | |
| 3829 this.splice('selected', sidx, 1); | |
| 3830 this.unlinkPaths('selected.' + skey); | 3989 this.unlinkPaths('selected.' + skey); |
| 3831 return true; | |
| 3832 } | 3990 } |
| 3833 } else { | 3991 } else { |
| 3834 this.selected = null; | 3992 this.selected = null; |
| 3835 this.unlinkPaths('selected'); | 3993 this.unlinkPaths('selected'); |
| 3836 } | 3994 } |
| 3837 }, | 3995 }, |
| 3838 select: function (item) { | 3996 select: function (item) { |
| 3839 var icol = Polymer.Collection.get(this.items); | 3997 var icol = Polymer.Collection.get(this.items); |
| 3840 var key = icol.getKey(item); | 3998 var key = icol.getKey(item); |
| 3841 if (this.multi) { | 3999 if (this.multi) { |
| 3842 var scol = Polymer.Collection.get(this.selected); | 4000 if (this.isSelected(item)) { |
| 3843 var skey = scol.getKey(item); | |
| 3844 if (skey >= 0) { | |
| 3845 if (this.toggle) { | 4001 if (this.toggle) { |
| 3846 this.deselect(item); | 4002 this.deselect(item); |
| 3847 } | 4003 } |
| 3848 } else { | 4004 } else { |
| 3849 this.push('selected', item); | 4005 this.push('selected', item); |
| 3850 this.async(function () { | 4006 skey = this._selectedColl.getKey(item); |
| 3851 skey = scol.getKey(item); | |
| 3852 this.linkPaths('selected.' + skey, 'items.' + key); | 4007 this.linkPaths('selected.' + skey, 'items.' + key); |
| 3853 }); | |
| 3854 } | 4008 } |
| 3855 } else { | 4009 } else { |
| 3856 if (this.toggle && item == this.selected) { | 4010 if (this.toggle && item == this.selected) { |
| 3857 this.deselect(); | 4011 this.deselect(); |
| 3858 } else { | 4012 } else { |
| 3859 this.linkPaths('selected', 'items.' + key); | 4013 this.linkPaths('selected', 'items.' + key); |
| 3860 this.selected = item; | 4014 this.selected = item; |
| 3861 } | 4015 } |
| 3862 } | 4016 } |
| 3863 } | 4017 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3888 if (this.if && this.ctor) { | 4042 if (this.if && this.ctor) { |
| 3889 this.async(this._ensureInstance); | 4043 this.async(this._ensureInstance); |
| 3890 } | 4044 } |
| 3891 }, | 4045 }, |
| 3892 render: function () { | 4046 render: function () { |
| 3893 this._flushTemplates(); | 4047 this._flushTemplates(); |
| 3894 }, | 4048 }, |
| 3895 _render: function () { | 4049 _render: function () { |
| 3896 if (this.if) { | 4050 if (this.if) { |
| 3897 if (!this.ctor) { | 4051 if (!this.ctor) { |
| 3898 this._wrapTextNodes(this._content || this.content); | |
| 3899 this.templatize(this); | 4052 this.templatize(this); |
| 3900 } | 4053 } |
| 3901 this._ensureInstance(); | 4054 this._ensureInstance(); |
| 3902 this._showHideChildren(); | 4055 this._showHideChildren(); |
| 3903 } else if (this.restamp) { | 4056 } else if (this.restamp) { |
| 3904 this._teardownInstance(); | 4057 this._teardownInstance(); |
| 3905 } | 4058 } |
| 3906 if (!this.restamp && this._instance) { | 4059 if (!this.restamp && this._instance) { |
| 3907 this._showHideChildren(); | 4060 this._showHideChildren(); |
| 3908 } | 4061 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3924 var c = this._instance._children; | 4077 var c = this._instance._children; |
| 3925 if (c) { | 4078 if (c) { |
| 3926 var parent = Polymer.dom(Polymer.dom(c[0]).parentNode); | 4079 var parent = Polymer.dom(Polymer.dom(c[0]).parentNode); |
| 3927 c.forEach(function (n) { | 4080 c.forEach(function (n) { |
| 3928 parent.removeChild(n); | 4081 parent.removeChild(n); |
| 3929 }); | 4082 }); |
| 3930 } | 4083 } |
| 3931 this._instance = null; | 4084 this._instance = null; |
| 3932 } | 4085 } |
| 3933 }, | 4086 }, |
| 3934 _wrapTextNodes: function (root) { | |
| 3935 for (var n = root.firstChild; n; n = n.nextSibling) { | |
| 3936 if (n.nodeType === Node.TEXT_NODE && n.textContent.trim()) { | |
| 3937 var s = document.createElement('span'); | |
| 3938 root.insertBefore(s, n); | |
| 3939 s.appendChild(n); | |
| 3940 n = s; | |
| 3941 } | |
| 3942 } | |
| 3943 }, | |
| 3944 _showHideChildren: function () { | 4087 _showHideChildren: function () { |
| 3945 var hidden = this.__hideTemplateChildren__ || !this.if; | 4088 var hidden = this.__hideTemplateChildren__ || !this.if; |
| 3946 if (this._instance) { | 4089 if (this._instance) { |
| 3947 this._instance._showHideChildren(hidden); | 4090 this._instance._showHideChildren(hidden); |
| 3948 } | 4091 } |
| 3949 }, | 4092 }, |
| 3950 _forwardParentProp: function (prop, value) { | 4093 _forwardParentProp: function (prop, value) { |
| 3951 if (this._instance) { | 4094 if (this._instance) { |
| 3952 this._instance[prop] = value; | 4095 this._instance[prop] = value; |
| 3953 } | 4096 } |
| 3954 }, | 4097 }, |
| 3955 _forwardParentPath: function (path, value) { | 4098 _forwardParentPath: function (path, value) { |
| 3956 if (this._instance) { | 4099 if (this._instance) { |
| 3957 this._instance.notifyPath(path, value, true); | 4100 this._instance.notifyPath(path, value, true); |
| 3958 } | 4101 } |
| 3959 } | 4102 } |
| 3960 }); | 4103 }); |
| 3961 Polymer.ImportStatus = { | |
| 3962 _ready: false, | |
| 3963 _callbacks: [], | |
| 3964 whenLoaded: function (cb) { | |
| 3965 if (this._ready) { | |
| 3966 cb(); | |
| 3967 } else { | |
| 3968 this._callbacks.push(cb); | |
| 3969 } | |
| 3970 }, | |
| 3971 _importsLoaded: function () { | |
| 3972 this._ready = true; | |
| 3973 this._callbacks.forEach(function (cb) { | |
| 3974 cb(); | |
| 3975 }); | |
| 3976 this._callbacks = []; | |
| 3977 } | |
| 3978 }; | |
| 3979 window.addEventListener('load', function () { | |
| 3980 Polymer.ImportStatus._importsLoaded(); | |
| 3981 }); | |
| 3982 if (window.HTMLImports) { | |
| 3983 HTMLImports.whenReady(function () { | |
| 3984 Polymer.ImportStatus._importsLoaded(); | |
| 3985 }); | |
| 3986 } | |
| 3987 Polymer({ | 4104 Polymer({ |
| 3988 is: 'dom-bind', | 4105 is: 'dom-bind', |
| 3989 extends: 'template', | 4106 extends: 'template', |
| 3990 created: function () { | 4107 created: function () { |
| 3991 Polymer.ImportStatus.whenLoaded(this._markImportsReady.bind(this)); | 4108 Polymer.RenderStatus.whenReady(this._markImportsReady.bind(this)); |
| 3992 }, | 4109 }, |
| 3993 _ensureReady: function () { | 4110 _ensureReady: function () { |
| 3994 if (!this._readied) { | 4111 if (!this._readied) { |
| 3995 this._readySelf(); | 4112 this._readySelf(); |
| 3996 } | 4113 } |
| 3997 }, | 4114 }, |
| 3998 _markImportsReady: function () { | 4115 _markImportsReady: function () { |
| 3999 this._importsReady = true; | 4116 this._importsReady = true; |
| 4000 this._ensureReady(); | 4117 this._ensureReady(); |
| 4001 }, | 4118 }, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4046 this._prepBehaviors(); | 4163 this._prepBehaviors(); |
| 4047 this._prepConfigure(); | 4164 this._prepConfigure(); |
| 4048 this._prepBindings(); | 4165 this._prepBindings(); |
| 4049 Polymer.Base._initFeatures.call(this); | 4166 Polymer.Base._initFeatures.call(this); |
| 4050 this._children = Array.prototype.slice.call(this.root.childNodes); | 4167 this._children = Array.prototype.slice.call(this.root.childNodes); |
| 4051 } | 4168 } |
| 4052 this._insertChildren(); | 4169 this._insertChildren(); |
| 4053 this.fire('dom-change'); | 4170 this.fire('dom-change'); |
| 4054 } | 4171 } |
| 4055 }); | 4172 }); |
| OLD | NEW |