Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Unified Diff: native_client_sdk/src/examples/resources/index.js

Issue 23919004: [NaCl SDK] Create a resources/ directory and move files to it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move httpd.cmd too Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/examples/resources/index.js
diff --git a/native_client_sdk/src/examples/resources/index.js b/native_client_sdk/src/examples/resources/index.js
deleted file mode 100644
index ab4b4ff61849400411fcb262ea4272b2610d3e78..0000000000000000000000000000000000000000
--- a/native_client_sdk/src/examples/resources/index.js
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright (c) 2013 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.
-
-var iframeUpdateIntervalID;
-
-function selectExample(el) {
- setIframeSrc(el.dataset.href);
- deselectAllNavItems();
- selectNavItem(el);
-}
-
-function selectNavItem(el) {
- el.classList.add('selected');
-}
-
-function deselectAllNavItems() {
- var navItemEls = document.querySelectorAll('.nav-item');
- for (var i = 0; i < navItemEls.length; ++i) {
- navItemEls[i].classList.remove('selected');
- }
-}
-
-function setIframeSrc(src) {
- var iframeEl = document.querySelector('iframe');
-
- window.clearInterval(iframeUpdateIntervalID);
- iframeEl.style.height = '';
- iframeEl.src = src;
-}
-
-document.addEventListener('DOMContentLoaded', function () {
- var iframeEl = document.querySelector('iframe');
- var iframeWrapperEl = document.querySelector('.iframe-wrapper');
- var navItemEls = document.querySelectorAll('.nav-item');
-
- for (var i = 0; i < navItemEls.length; ++i) {
- navItemEls[i].addEventListener('click', function (e) {
- selectExample(this);
- });
- }
-
- iframeEl.addEventListener('load', function () {
- var iframeDocument = this.contentWindow.document;
- var iframeBodyEl = iframeDocument.body;
- iframeEl.style.height = iframeBodyEl.scrollHeight + 'px';
-
- // HACK: polling the body height to update the iframe. There's got to be a
- // better way to do this...
- var prevBodyHeight;
- var prevWrapperHeight;
- iframeUpdateIntervalID = window.setInterval(function () {
- var bodyHeight = iframeBodyEl.getBoundingClientRect().height;
- var wrapperHeight = iframeWrapperEl.clientHeight;
- if (bodyHeight != prevBodyHeight || wrapperHeight != prevWrapperHeight) {
- // HACK: magic 4... without it, the scrollbar is always visible. :(
- var newHeight = Math.max(wrapperHeight - 4, bodyHeight);
- iframeEl.style.height = newHeight + 'px';
- prevBodyHeight = bodyHeight;
- prevWrapperHeight = wrapperHeight;
- }
- }, 100); // .1s
- }, false);
-
- var closeButtonEl = document.querySelector('.close-button');
- closeButtonEl.addEventListener('click', function () {
- window.close();
- });
-
- // select the first example.
- selectExample(document.querySelector('.nav-item'));
-});
« no previous file with comments | « native_client_sdk/src/examples/resources/index.css ('k') | native_client_sdk/src/examples/resources/index.html.template » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698