| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | |
| 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
| 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
| 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 var ui = ui || {}; | |
| 27 ui.actions = ui.actions || {}; | |
| 28 | |
| 29 (function() { | |
| 30 | |
| 31 var Action = base.extends('button', { | |
| 32 init: function() { | |
| 33 this._eventName = null; | |
| 34 $(this).addClass('action'); | |
| 35 this.addEventListener('click', function(event) { | |
| 36 if (this._eventName) { | |
| 37 $(this).trigger(this._eventName); | |
| 38 event.stopPropagation(); | |
| 39 } | |
| 40 }.bind(this)); | |
| 41 }, | |
| 42 makeDefault: function() { | |
| 43 $(this).addClass('default'); | |
| 44 return this; | |
| 45 } | |
| 46 }); | |
| 47 | |
| 48 ui.actions.Blame = base.extends(Action, { | |
| 49 init: function() { | |
| 50 this.textContent = 'Blame'; | |
| 51 this._eventName = 'blame'; | |
| 52 this.title = 'Blames this failure on this revision.' | |
| 53 } | |
| 54 }); | |
| 55 | |
| 56 ui.actions.Close = base.extends(Action, { | |
| 57 init: function() { | |
| 58 this.textContent = 'Close'; | |
| 59 this._eventName = 'close'; | |
| 60 } | |
| 61 }); | |
| 62 | |
| 63 ui.actions.Rollout = base.extends(Action, { | |
| 64 init: function() { | |
| 65 this.textContent = 'Roll out'; | |
| 66 this._eventName = 'rollout'; | |
| 67 this.title = 'Rolls out this revision.' | |
| 68 } | |
| 69 }); | |
| 70 | |
| 71 ui.actions.Examine = base.extends(Action, { | |
| 72 init: function() { | |
| 73 this.textContent = 'Examine'; | |
| 74 this._eventName = 'examine'; | |
| 75 this.title = 'Examine these failures in detail.' | |
| 76 } | |
| 77 }); | |
| 78 | |
| 79 ui.actions.Rebaseline = base.extends(Action, { | |
| 80 init: function() { | |
| 81 this.textContent = 'Rebaseline'; | |
| 82 this._eventName = 'rebaseline'; | |
| 83 } | |
| 84 }); | |
| 85 | |
| 86 ui.actions.ExpectFailure = base.extends(Action, { | |
| 87 init: function() { | |
| 88 this.textContent = 'Expect Failure'; | |
| 89 this._eventName = 'expectfailure'; | |
| 90 } | |
| 91 }); | |
| 92 | |
| 93 ui.actions.Next = base.extends(Action, { | |
| 94 init: function() { | |
| 95 this.innerHTML = '▶'; | |
| 96 this._eventName = 'next'; | |
| 97 $(this).addClass('next'); | |
| 98 } | |
| 99 }); | |
| 100 | |
| 101 ui.actions.Previous = base.extends(Action, { | |
| 102 init: function() { | |
| 103 this.innerHTML = '◀'; | |
| 104 this._eventName = 'previous'; | |
| 105 $(this).addClass('previous'); | |
| 106 } | |
| 107 }); | |
| 108 | |
| 109 ui.actions.List = base.extends('ul', { | |
| 110 init: function(actions) { | |
| 111 this.className = 'actions'; | |
| 112 if (!actions) | |
| 113 return; | |
| 114 actions.forEach(this.add.bind(this)); | |
| 115 }, | |
| 116 add: function(action) | |
| 117 { | |
| 118 var item = document.createElement('li'); | |
| 119 item.appendChild(action); | |
| 120 $(this).append(item); | |
| 121 } | |
| 122 }); | |
| 123 | |
| 124 })(); | |
| OLD | NEW |