OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). | 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). |
5 * Copyright (C) 2009 Joseph Pecoraro | 5 * Copyright (C) 2009 Joseph Pecoraro |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * | 10 * |
(...skipping 1998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2009 return new Promise(fulfill => { | 2009 return new Promise(fulfill => { |
2010 var image = new Image(); | 2010 var image = new Image(); |
2011 image.addEventListener('load', () => fulfill(image)); | 2011 image.addEventListener('load', () => fulfill(image)); |
2012 image.addEventListener('error', () => fulfill(null)); | 2012 image.addEventListener('error', () => fulfill(null)); |
2013 image.src = url; | 2013 image.src = url; |
2014 }); | 2014 }); |
2015 }; | 2015 }; |
2016 | 2016 |
2017 /** @type {!UI.ThemeSupport} */ | 2017 /** @type {!UI.ThemeSupport} */ |
2018 UI.themeSupport; | 2018 UI.themeSupport; |
| 2019 |
| 2020 /** |
| 2021 * @param {function(!File)} callback |
| 2022 * @return {!Node} |
| 2023 */ |
| 2024 UI.createFileSelectorElement = function(callback) { |
| 2025 var fileSelectorElement = createElement('input'); |
| 2026 fileSelectorElement.type = 'file'; |
| 2027 fileSelectorElement.style.display = 'none'; |
| 2028 fileSelectorElement.setAttribute('tabindex', -1); |
| 2029 fileSelectorElement.onchange = onChange; |
| 2030 function onChange(event) { |
| 2031 callback(fileSelectorElement.files[0]); |
| 2032 } |
| 2033 return fileSelectorElement; |
| 2034 }; |
OLD | NEW |