Index: content/browser/resources/media/new/collapse.js |
diff --git a/content/browser/resources/media/new/collapse.js b/content/browser/resources/media/new/collapse.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c24aa80dbb404fb5cd540610d43a9bfe349bf929 |
--- /dev/null |
+++ b/content/browser/resources/media/new/collapse.js |
@@ -0,0 +1,27 @@ |
+// Copyright (c) 2012 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. |
+ |
+ |
+/** |
+ * @fileoverview Sets up the event handlers for the collapsing containers |
+ */ |
+ |
+(function () { |
+ "use strict"; |
+ var allCollapseDivs = document.querySelectorAll('.collapse'); |
+ (Array.prototype.slice.call(allCollapseDivs)).forEach(function (elem) { |
+ // find the header for the div, because we only want to trigger on that |
+ var header = elem.querySelector("h2"); |
+ header.onclick = function () { |
+ var wasOpen = elem.className.indexOf("open") !== -1; |
+ |
+ if (wasOpen) { |
+ elem.className = "collapse closed"; |
+ } else { |
+ elem.className = "collapse open"; |
+ } |
+ }; |
+ }); |
+ |
+}()); |