Index: chrome/common/extensions/docs/templates/articles/app_codelab9_multipleviews.html |
diff --git a/chrome/common/extensions/docs/templates/articles/app_codelab9_multipleviews.html b/chrome/common/extensions/docs/templates/articles/app_codelab9_multipleviews.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b0945a047070dea5cc1743f8783c31b0de935b1a |
--- /dev/null |
+++ b/chrome/common/extensions/docs/templates/articles/app_codelab9_multipleviews.html |
@@ -0,0 +1,57 @@ |
+<h1 id="lab_9_multiple_views">Lab 9 - Multiple Views</h1> |
+ |
+<p>Unlike standard web apps, a Chrome app has complete control of its windows. It can create any number of windows at arbitrary screen locations, control the window's look and feel, minimize, maximize and much more.</p> |
+ |
+<p>In this lab, we will move the Drop area of our current application to another window. Here you can see how windows talk to each other and to the event page directly, synchronously, because they are all in the same thread.</p> |
+ |
+<ol> |
+<li><p>Let's adapt our code then. Start by removing the droptext <code><div></code> from <a href="https://github.com/GoogleChrome/chrome-app-codelab/blob/master/lab9_multipleviews/angularjs/index.html">index.html</a>.</p></li> |
+<li><p>Create a new HTML with the drop area: <a href="https://github.com/GoogleChrome/chrome-app-codelab/blob/master/lab9_multipleviews/angularjs/droparea.html">droparea.html</a> |
+<pre> |
+<html ng-app ng-csp> |
+ <head> |
+ <script src="angular.min.js"></script> |
+ <script src="droparea.js"></script> |
+ <link rel="stylesheet" href="todo.css"> |
+ <title>File Drop</title> |
+ </head> |
+ <body ng-controller="DropCtrl" ng-class="dropClass"> |
+ <h2>Drop Area</h2> |
+ <div>{{dropText}}</div> |
+ </body> |
+</html> |
+</pre></p></li> |
+<li><p>Move all drop-related functionality from <a href="https://github.com/GoogleChrome/chrome-app-codelab/blob/master/lab9_multipleviews/angularjs/controller.js">controller.js</a> to a new file, <a href="https://github.com/GoogleChrome/chrome-app-codelab/blob/master/lab9_multipleviews/angularjs/droparea.js">droparea.js</a>: |
+<pre> |
+function DropCtrl($scope) { |
+ // move here the variable initializations for defaultDropText and $scope.dropText |
+ // move here the methods dragOver, dragLeave and drop |
+} |
+</pre></p></li> |
+<li><p>In the existing <code>controller.js</code>, add the call to create a new window: |
+<pre> |
+chrome.app.window.create('droparea.html', |
+ {id: 'dropArea', width: 200, height: 200 }, |
+ function(dropWin) { |
+ dropWin.contentWindow.$parentScope = $scope; |
+ }); |
+</pre></p></li> |
+</ol> |
+ |
+<p>And that's all. Thanks to the hierarchical scope support on Angular, the <code>DropCtrl</code> controller is a child of the <code>TodoCtrl</code> and inherits all the context of its parent.</p> |
+ |
+<p>To test, open the app, right-click, and select Reload App. Move the top view to the right, and you can see the additional view.</p> |
+ |
+<p class="note"><b>Note:</b> If you get stuck and want to see the app in action, go to <code>chrome://extensions</code>, load the unpacked <a href="app_codelab9_multipleviews.html">lab9_multipleviews</a>, and launch the app from a new tab.</p> |
+ |
+<h1 id="takeaway_">Takeaway:</h1> |
+ |
+<ul> |
+<li>Web developers usually have a mindset of one-window-per-webapp. |
+The Chrome app platform opens more possibilities for your creativity. |
+A document editor, for example, can have one window per opened document, a more natural metaphor for native-like apps.</li> |
+</ul> |
+ |
+<h1 id="what_39_s_next_">What's next?</h1> |
+ |
+<p>In <a href="app_codelab_10_publishing.html">lab_10_publishing</a>, we finish off with instructions on how to publish your app in the Chrome Web Store.</p> |