| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * Helper utility functions for manipulating the DOM. | |
| 7 */ | |
| 8 var DomUtil = {}; | |
| 9 | |
| 10 /** | |
| 11 * Toggles the visibility on a node. | |
| 12 * | |
| 13 * @param {DOMNode} n The node to show/hide. | |
| 14 * @param {boolean} display False to hide the node. | |
| 15 */ | |
| 16 DomUtil.DisplayNode = function(n, display) { | |
| 17 n.style.display = display ? "" : "none"; | |
| 18 }; | |
| 19 | |
| 20 /** | |
| 21 * Appends a new node with tag |type| to |parent|. | |
| 22 * | |
| 23 * @param {DOMNode} parent | |
| 24 * @param {string} type | |
| 25 * @return {DOMNode} The node that was just created. | |
| 26 */ | |
| 27 DomUtil.AddNode = function(parent, type) { | |
| 28 if (!type) { | |
| 29 throw ("type must be defined"); | |
| 30 } | |
| 31 var doc = parent.ownerDocument; | |
| 32 var n = doc.createElement(type); | |
| 33 parent.appendChild(n); | |
| 34 return n; | |
| 35 }; | |
| 36 | |
| 37 /** | |
| 38 * Adds text to node |parent|. | |
| 39 * | |
| 40 * @param {DOMNode} parent | |
| 41 * @param {string} text | |
| 42 */ | |
| 43 DomUtil.AddText = function(parent, text) { | |
| 44 var doc = parent.ownerDocument; | |
| 45 var n = doc.createTextNode(text); | |
| 46 parent.appendChild(n); | |
| 47 return n; | |
| 48 }; | |
| OLD | NEW |