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 * @fileoverview Implements some utilities for the legacy 'inline' and 'overlay' | |
7 * UI modes. | |
8 **/ | |
9 | |
10 goog.provide('google.cf.installer.frame'); | |
11 | |
12 /** | |
13 * Plucks properties from the passed arguments and sets them on the passed | |
14 * DOM node | |
15 * @param {Node} node The node to set properties on | |
16 * @param {Object} args A map of user-specified properties to set | |
17 */ | |
18 google.cf.installer.frame.setProperties = function(node, args) { | |
19 var cssText = args['cssText'] || ''; | |
20 node.style.cssText = ' ' + cssText; | |
21 | |
22 var classText = args['className'] || ''; | |
23 node.className = classText; | |
24 | |
25 var srcNode = args['node']; | |
26 if (typeof srcNode == 'string') | |
27 srcNode = document.getElementById(srcNode); | |
28 return args['id'] || (srcNode ? srcNode['id'] || '' : ''); | |
29 }; | |
30 | |
31 /** | |
32 * Determines the parent node to create the IFrame in, based on the provided | |
33 * arguments. Note that this should only be called once. | |
34 * @param {Object} args A map of user-specified properties. | |
35 */ | |
36 google.cf.installer.frame.getParentNode = function(args) { | |
37 var srcNode = args['node']; | |
38 if (typeof srcNode == 'string') | |
39 srcNode = document.getElementById(srcNode); | |
40 if (srcNode) { | |
41 var parentNode = srcNode.parentNode; | |
42 parentNode.removeChild(srcNode); | |
43 return parentNode; | |
44 } | |
45 return document.body; | |
46 }; | |
OLD | NEW |