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

Side by Side Diff: pkg/polymer/lib/boot.js

Issue 24149003: Port of github.com/polymer/polymer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This script dynamically prepares a set of files to run polymer.dart. It uses 5 // This script dynamically prepares a set of files to run polymer.dart. It uses
6 // the html_import polyfill to search for all imported files, then 6 // the html_import polyfill to search for all imported files, then
7 // it inlines all <polymer-element> definitions on the top-level page (needed by 7 // it inlines all <polymer-element> definitions on the top-level page (needed by
8 // registerPolymerElement), and it removes script tags that appear inside 8 // registerPolymerElement), and it removes script tags that appear inside
9 // those tags. It finally rewrites the main entrypoint to call an initialization 9 // those tags. It finally rewrites the main entrypoint to call an initialization
10 // function on each of the declared <polymer-elements>. 10 // function on each of the declared <polymer-elements>.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 (function() { 50 (function() {
51 // Only run in Dartium. 51 // Only run in Dartium.
52 if (!navigator.webkitStartDart) { 52 if (!navigator.webkitStartDart) {
53 // TODO(sigmund): rephrase when we split build.dart in two: analysis vs 53 // TODO(sigmund): rephrase when we split build.dart in two: analysis vs
54 // deploy pieces. 54 // deploy pieces.
55 console.warn('boot.js only works in Dartium. Run the build.dart' + 55 console.warn('boot.js only works in Dartium. Run the build.dart' +
56 ' tool to compile a depolyable JavaScript version') 56 ' tool to compile a depolyable JavaScript version')
57 return; 57 return;
58 } 58 }
59 document.write( 59
60 '<script src="packages/html_import/html_import.min.js"></script>'); 60
61 // Load HTML Imports:
62 var htmlImportsSrc = 'src="packages/html_import/html_import.min.js"';
63 document.write('<script ' + htmlImportsSrc + '></script>');
64 var importScript = document.querySelector('script[' + htmlImportsSrc + ']');
65 importScript.addEventListener('load', function() {
66 // NOTE: this is from polymer/src/lib/dom.js
67 window.HTMLImports.importer.preloadSelectors +=
68 ', polymer-element link[rel=stylesheet]';
69 });
70
71 // TODO(jmesserly): we need this in deploy tool too.
72 // NOTE: this is from polymer/src/boot.js:
73 // FOUC prevention tactic
74 var style = document.createElement('style');
75 style.textContent = 'body {opacity: 0;}';
76 var head = document.querySelector('head');
77 head.insertBefore(style, head.firstChild);
78
79 window.addEventListener('WebComponentsReady', function() {
80 document.body.style.webkitTransition = 'opacity 0.3s';
81 document.body.style.opacity = 1;
82 });
61 83
62 // Extract a Dart import URL from a script tag, which is the 'src' attribute 84 // Extract a Dart import URL from a script tag, which is the 'src' attribute
63 // of the script tag, or a data-url with the script contents for inlined code. 85 // of the script tag, or a data-url with the script contents for inlined code.
64 function getScriptUrl(script) { 86 function getScriptUrl(script) {
65 var url = script.src; 87 var url = script.src;
66 if (url) { 88 if (url) {
67 // Normalize package: urls 89 // Normalize package: urls
68 var index = url.indexOf('packages/'); 90 var index = url.indexOf('packages/');
69 if (index == 0 || (index > 0 && url[index - 1] == '/')) { 91 if (index == 0 || (index > 0 && url[index - 1] == '/')) {
70 url = "package:" + url.slice(index + 9); 92 url = "package:" + url.slice(index + 9);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 alreadyRan = true; 175 alreadyRan = true;
154 var ref = document.body.children[0]; 176 var ref = document.body.children[0];
155 inlinePolymerElements(document, ref); 177 inlinePolymerElements(document, ref);
156 mergeScripts(); 178 mergeScripts();
157 if (!navigator.webkitStartDart()) { 179 if (!navigator.webkitStartDart()) {
158 document.body.innerHTML = 'This build has expired. Please download a ' + 180 document.body.innerHTML = 'This build has expired. Please download a ' +
159 'new Dartium at http://www.dartlang.org/dartium/index.html'; 181 'new Dartium at http://www.dartlang.org/dartium/index.html';
160 } 182 }
161 }); 183 });
162 })(); 184 })();
OLDNEW
« no previous file with comments | « pkg/polymer/example/component/news/web/news-component.html ('k') | pkg/polymer/lib/component_build.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698