| <!DOCTYPE html> |
| <!-- |
| Copyright 2015 The Chromium Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style license that can be |
| found in the LICENSE file. |
| --> |
| |
| <link rel="import" href="/extras/tquery/filter.html"> |
| |
| <polymer-element name='tv-e-tquery-filter-has-duration' |
| extends='tv-e-tquery-filter'> |
| <script> |
| 'use strict'; |
| |
| Polymer({ |
| ready: function() { |
| this.expected = undefined; |
| this.minValue = undefined; |
| this.maxValue = undefined; |
| }, |
| |
| get scriptName() { |
| return 'hasDuration'; |
| }, |
| |
| get scriptValue() { |
| return function(minValueOrExpected, maxValue) { |
| var filter = document.createElement(this.element.name); |
| if (minValueOrExpected !== undefined && maxValue !== undefined) { |
| filter.minValue = minValueOrExpected; |
| filter.maxValue = maxValue; |
| } else { |
| filter.expected = minValueOrExpected; |
| } |
| return filter; |
| }.bind(this); |
| }, |
| |
| evaluate: function(context) { |
| if (context.event.duration === undefined) |
| return false; |
| if (this.minValue !== undefined && this.maxValue !== undefined) { |
| return context.event.duration >= this.minValue && |
| context.event.duration <= this.maxValue; |
| } |
| return this.matchValue_(context.event.duration, this.expected); |
| } |
| }); |
| </script> |
| </polymer-element> |
| |