~didrocks/+junk/face-detection-15.04

« back to all changes in this revision

Viewing changes to facedetection/www/bower_components/iron-component-page/iron-component-page.html

  • Committer: Didier Roche
  • Date: 2016-05-10 23:09:11 UTC
  • Revision ID: didier.roche@canonical.com-20160510230911-c7xr490zrj3yrzxd
New version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!--
 
2
@license
 
3
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
 
4
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
 
5
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
 
6
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
 
7
Code distributed by Google as part of the polymer project is also
 
8
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
 
9
-->
 
10
 
 
11
<link rel="import" href="../polymer/polymer.html">
 
12
<link rel="import" href="../hydrolysis/hydrolysis-analyzer.html">
 
13
<link rel="import" href="../iron-ajax/iron-ajax.html">
 
14
<link rel="import" href="../iron-doc-viewer/iron-doc-viewer.html">
 
15
<link rel="import" href="../iron-flex-layout/iron-flex-layout.html">
 
16
<link rel="import" href="../iron-icons/iron-icons.html">
 
17
<link rel="import" href="../iron-selector/iron-selector.html">
 
18
<link rel="import" href="../paper-header-panel/paper-header-panel.html">
 
19
<link rel="import" href="../paper-styles/color.html">
 
20
<link rel="import" href="../paper-styles/typography.html">
 
21
<link rel="import" href="../paper-toolbar/paper-toolbar.html">
 
22
 
 
23
<!--
 
24
Loads Polymer element and behavior documentation using
 
25
[Hydrolysis](https://github.com/PolymerLabs/hydrolysis) and renders a complete
 
26
documentation page including demos (if available).
 
27
-->
 
28
 
 
29
<dom-module id="iron-component-page">
 
30
  <template>
 
31
    <style>
 
32
      :host {
 
33
        font-family: 'Roboto', 'Noto', sans-serif;
 
34
        @apply(--layout-fit);
 
35
        @apply(--layout);
 
36
        @apply(--layout-vertical);
 
37
        overflow: hidden;
 
38
        background: var(--paper-grey-50);
 
39
      }
 
40
 
 
41
      p {
 
42
        max-width: 20em;
 
43
      }
 
44
 
 
45
      paper-header-panel {
 
46
        @apply(--layout-flex);
 
47
        background: var(--paper-grey-50);
 
48
      }
 
49
 
 
50
      paper-toolbar {
 
51
        --paper-toolbar-background: var(--paper-grey-50);
 
52
        --paper-toolbar-color: var(--paper-grey-800);
 
53
        flex-shrink: 0;
 
54
      }
 
55
 
 
56
      :host > paper-header-panel {
 
57
        opacity: 0;
 
58
        transition: opacity 0.5s;
 
59
      }
 
60
 
 
61
      :host(.loaded) > paper-header-panel {
 
62
        opacity: 1.0;
 
63
      }
 
64
 
 
65
      #content {
 
66
        display: block;
 
67
        background: var(--paper-grey-50);
 
68
      }
 
69
 
 
70
      paper-toolbar a {
 
71
        margin: 0 10px;
 
72
        cursor: pointer;
 
73
      }
 
74
 
 
75
      paper-toolbar a:last-child {
 
76
        margin-right: 0;
 
77
      }
 
78
 
 
79
      paper-toolbar a, paper-toolbar a iron-icon {
 
80
        font-weight: normal;
 
81
        color: var(--paper-grey-500);
 
82
      }
 
83
 
 
84
      paper-toolbar iron-icon {
 
85
        margin: -2px 5px 0 0;
 
86
      }
 
87
 
 
88
      paper-toolbar a.iron-selected, paper-toolbar a.iron-selected iron-icon {
 
89
        color: var(--paper-grey-800);
 
90
      }
 
91
 
 
92
      paper-toolbar a:hover, paper-toolbar a:hover iron-icon {
 
93
        color: var(--paper-pink-500);
 
94
      }
 
95
 
 
96
      select {
 
97
        cursor: pointer;
 
98
      }
 
99
 
 
100
      #demo iframe {
 
101
        @apply(--layout-fit);
 
102
      }
 
103
 
 
104
      #nodocs {
 
105
        background: var(--paper-grey-50);
 
106
        font-size: 24px;
 
107
        font-weight: 400;
 
108
        color: var(--paper-grey-400);
 
109
      }
 
110
 
 
111
      #demo iframe {
 
112
        border: 0;
 
113
        background: transparent;
 
114
        width: 100%;
 
115
        height: 100%;
 
116
        overflow-x: none;
 
117
        overflow-y: auto;
 
118
      }
 
119
 
 
120
      #view > * {
 
121
        display: none;
 
122
      }
 
123
 
 
124
      #view > .iron-selected {
 
125
        display: block;
 
126
      }
 
127
 
 
128
      #docs {
 
129
        max-width: var(--iron-component-page-max-width, 48em);
 
130
        @apply(--iron-component-page-container);
 
131
        padding: 20px;
 
132
        margin: 0 auto;
 
133
      }
 
134
 
 
135
      #active {
 
136
        font-size: 20px;
 
137
        font-family: Roboto, Noto;
 
138
        border: 0;
 
139
        background: transparent;
 
140
      }
 
141
 
 
142
      paper-toolbar a {
 
143
        font-size: 14px;
 
144
        text-transform: uppercase;
 
145
        cursor: pointer;
 
146
      }
 
147
 
 
148
      #cart-icon {
 
149
        margin-left: 10px;
 
150
        cursor: pointer;
 
151
      }
 
152
 
 
153
      #catalog-heading {
 
154
        margin: 4px 0 18px;
 
155
      }
 
156
 
 
157
      #catalog-heading h2 {
 
158
        color: var(--paper-grey-800);
 
159
        @apply(--paper-font-title);
 
160
        margin: 0;
 
161
      }
 
162
 
 
163
      #catalog-heading .version {
 
164
        color: var(--paper-grey-500);
 
165
        font-size: 18px;
 
166
        line-height: 24px;
 
167
        font-weight: 400;
 
168
      }
 
169
      #catalog-heading .version:before {
 
170
        content: "(";
 
171
      }
 
172
      #catalog-heading .version:after {
 
173
        content: ")";
 
174
      }
 
175
 
 
176
      [catalog-only] {
 
177
        display: none;
 
178
      }
 
179
 
 
180
      :host([catalog]) [catalog-only] {
 
181
        display: block;
 
182
      }
 
183
      :host([catalog]) [catalog-hidden] {
 
184
        display: none;
 
185
      }
 
186
 
 
187
      .no-docs {
 
188
        @apply(--layout-horizontal);
 
189
        @apply(--layout-center-center);
 
190
        @apply(--layout-fit);
 
191
      }
 
192
 
 
193
      .docs-header {
 
194
        @apply(--layout-flex);
 
195
      }
 
196
    </style>
 
197
 
 
198
    <hydrolysis-analyzer id="analyzer" src="[[_srcUrl]]" transitive="[[transitive]]" clean analyzer="{{_hydroDesc}}" loading="{{_hydroLoading}}"></hydrolysis-analyzer>
 
199
    <iron-ajax id="ajax" url="[[docSrc]]" handle-as="json" on-response="_handleAjaxResponse" on-error="_handleError"></iron-ajax>
 
200
 
 
201
    <paper-header-panel id="headerPanel" mode="[[scrollMode]]">
 
202
      <paper-toolbar catalog-hidden>
 
203
        <div class="docs-header">
 
204
          <!-- TODO: Replace with paper-dropdown-menu when available -->
 
205
          <select id="active" value="[[active]]" on-change="_handleMenuItemSelected">
 
206
            <template is="dom-repeat" items="[[docElements]]">
 
207
              <option value="[[item.is]]">[[item.is]]</option>
 
208
            </template>
 
209
            <template is="dom-repeat" items="[[docBehaviors]]">
 
210
              <option value="[[item.is]]">[[item.is]]</option>
 
211
            </template>
 
212
          </select>
 
213
        </div>
 
214
        <iron-selector attr-for-selected="view" selected="{{view}}" id="links" hidden$="[[!docDemos.length]]">
 
215
          <a view="docs"><iron-icon icon="description"></iron-icon> Docs</a>
 
216
          <a view="[[_demoView(docDemos.0.path)]]"><iron-icon icon="visibility"></iron-icon> <span>Demo</span></a>
 
217
        </iron-selector>
 
218
      </paper-toolbar>
 
219
      <div id="content">
 
220
        <iron-selector id="view" selected="[[_viewType(view)]]" attr-for-selected="id">
 
221
          <div id="docs">
 
222
            <div id="catalog-heading" catalog-only>
 
223
              <h2><span>[[active]]</span> <span class="version" hidden$="[[!version]]">[[version]]</span></h2>
 
224
            </div>
 
225
            <iron-doc-viewer prefix="[[_fragmentPrefix]]" id="viewer" descriptor="{{_activeDescriptor}}"
 
226
              on-iron-doc-viewer-component-selected="_handleComponentSelectedEvent"></iron-doc-viewer>
 
227
            <div id="nodocs" hidden$="[[_activeDescriptor]]" class="no-docs">
 
228
              No documentation found.
 
229
            </div>
 
230
          </div>
 
231
          <div id="demo"></div>
 
232
        </iron-selector>
 
233
      </div>
 
234
    </paper-header-panel>
 
235
  </template>
 
236
 
 
237
  <script>
 
238
    (function() {
 
239
      // var hydrolysis = require('hydrolysis');
 
240
 
 
241
      /**
 
242
       * @param {string} url
 
243
       * @return {string} `url` stripped of a file name, if one is present. This
 
244
       *     considers URLs like "example.com/foo" to already be a base (no `.` is)
 
245
       *     present in the final path part).
 
246
       */
 
247
      function _baseUrl(url) {
 
248
        return url.match(/^(.*?)\/?([^\/]+\.[^\/]+)?$/)[1] + '/';
 
249
      }
 
250
 
 
251
      Polymer({
 
252
        is: 'iron-component-page',
 
253
 
 
254
        properties: {
 
255
          /**
 
256
           * The URL to an import that declares (or transitively imports) the
 
257
           * elements that you wish to see documented.
 
258
           *
 
259
           * If the URL is relative, it will be resolved relative to the master
 
260
           * document.
 
261
           *
 
262
           * If a `src` URL is not specified, it will resolve the name of the
 
263
           * directory containing this element, followed by `dirname.html`. For
 
264
           * example:
 
265
           *
 
266
           * `awesome-sauce/index.html`:
 
267
           *
 
268
           *     <iron-doc-viewer></iron-doc-viewer>
 
269
           *
 
270
           * Would implicitly have `src="awesome-sauce.html"`.
 
271
           */
 
272
          src: {
 
273
            type:     String,
 
274
            observer: '_srcChanged',
 
275
          },
 
276
 
 
277
          /**
 
278
           * The URL to a precompiled JSON descriptor. If you have precompiled
 
279
           * and stored a documentation set using Hydrolysis, you can load the
 
280
           * analyzer directly via AJAX by specifying this attribute.
 
281
           *
 
282
           * If a `doc-src` is not specified, it is ignored and the default
 
283
           * rules according to the `src` attribute are used.
 
284
           */
 
285
          docSrc: {
 
286
            type: String,
 
287
            observer: '_srcChanged',
 
288
          },
 
289
 
 
290
          /**
 
291
           * The relative root for determining paths to demos and default source
 
292
           * detection.
 
293
           */
 
294
          base: {
 
295
            type: String,
 
296
            value: function() {
 
297
              // Don't include URL hash.
 
298
              return this.ownerDocument.baseURI.replace(/\#.*$/, '');
 
299
            }
 
300
          },
 
301
 
 
302
          /**
 
303
           * The element or behavior that will be displayed on the page. Defaults
 
304
           * to the element matching the name of the source file.
 
305
           */
 
306
          active: {
 
307
            type: String,
 
308
            notify: true,
 
309
            value: ''
 
310
          },
 
311
 
 
312
          /**
 
313
           * The current view. Can be `docs` or `demo`.
 
314
           */
 
315
          view: {
 
316
            type: String,
 
317
            value: 'docs',
 
318
            notify: true
 
319
          },
 
320
 
 
321
          /**
 
322
           * Whether _all_ dependencies should be loaded and documented.
 
323
           *
 
324
           * Turning this on will probably slow down the load process dramatically.
 
325
           */
 
326
          transitive: {
 
327
            type: Boolean,
 
328
            value: false
 
329
          },
 
330
 
 
331
          /** The Hydrolysis element descriptors that have been loaded. */
 
332
          docElements: {
 
333
            type:     Array,
 
334
            notify: true,
 
335
            readOnly: true,
 
336
            value: function() {
 
337
              return [];
 
338
            }
 
339
          },
 
340
 
 
341
          /** The Hydrolysis behavior descriptors that have been loaded. */
 
342
          docBehaviors: {
 
343
            type:     Array,
 
344
            notify: true,
 
345
            readOnly: true,
 
346
            value: function() {
 
347
              return [];
 
348
            }
 
349
          },
 
350
 
 
351
          /**
 
352
           * Demos for the currently selected element.
 
353
           */
 
354
          docDemos: {
 
355
            type: Array,
 
356
            notify: true,
 
357
            readOnly: true
 
358
          },
 
359
 
 
360
          /**
 
361
           * The scroll mode for the page. For details about the modes,
 
362
           * see the mode property in paper-header-panel.
 
363
           */
 
364
          scrollMode: {
 
365
            type: String,
 
366
            value: 'waterfall'
 
367
          },
 
368
 
 
369
          /**
 
370
           * The currently displayed element.
 
371
           *
 
372
           * @type {!hydrolysis.ElementDescriptor}
 
373
           */
 
374
          _activeDescriptor: Object,
 
375
 
 
376
          _fragmentPrefix: String,
 
377
 
 
378
          /**
 
379
           * Toggle flag to be used when this element is being displayed in the
 
380
           * Polymer Elements catalog.
 
381
           */
 
382
          catalog: {
 
383
            type: Boolean,
 
384
            value: false,
 
385
            reflectToAttribute: true
 
386
          },
 
387
 
 
388
          /**
 
389
           * An optional version string.
 
390
           */
 
391
          version: String,
 
392
 
 
393
          /**
 
394
           * The hydrolysis analyzer.
 
395
           *
 
396
           * @type {!hydrolysis.Analyzer}
 
397
           */
 
398
          _analyzer: {
 
399
            type: Object,
 
400
            observer: '_analyzerChanged',
 
401
          },
 
402
          _hydroDesc: {
 
403
            type: Object,
 
404
            observer: '_detectAnalyzer'
 
405
          },
 
406
          _ajaxDesc: {
 
407
            type: Object,
 
408
            observer: '_detectAnalyzer'
 
409
          },
 
410
 
 
411
          /** Whether the analyzer is loading source. */
 
412
          _loading: {
 
413
            type:     Boolean,
 
414
            observer: '_loadingChanged',
 
415
          },
 
416
          _hydroLoading: {
 
417
            type: Boolean,
 
418
            observer: '_detectLoading'
 
419
          },
 
420
          _ajaxLoading: {
 
421
            type: Boolean,
 
422
            observer: '_detectLoading'
 
423
          },
 
424
 
 
425
          /** The complete URL to this component's demo. */
 
426
          _demoUrl: {
 
427
            type: String,
 
428
            value: '',
 
429
          },
 
430
 
 
431
          /** The complete URL to this component's source. */
 
432
          _srcUrl: String,
 
433
        },
 
434
 
 
435
        observers: [
 
436
          '_updateFrameSrc(view, base)',
 
437
          '_activeChanged(active, _analyzer)'
 
438
        ],
 
439
 
 
440
        attached: function() {
 
441
          // In the catalog, let the catalog do all the routing
 
442
          if (!this.catalog) {
 
443
            this._setActiveFromHash();
 
444
            this.listen(window, 'hashchange', '_setActiveFromHash');
 
445
          }
 
446
        },
 
447
 
 
448
        detached: function() {
 
449
          if (!this.catalog) {
 
450
            this.unlisten(window, 'hashchange', '_setActiveFromHash');
 
451
          }
 
452
        },
 
453
 
 
454
        ready: function() {
 
455
          var elements = this._loadJson();
 
456
          if (elements) {
 
457
            this.docElements = elements;
 
458
            this._loading  = false;
 
459
          } else {
 
460
            // Make sure our change handlers trigger in all cases.
 
461
            if (!this.src && !this.catalog) {
 
462
              this._srcChanged();
 
463
            }
 
464
          }
 
465
        },
 
466
 
 
467
        /**
 
468
         * Loads an array of hydrolysis element descriptors (as JSON) from the text
 
469
         * content of this element, if present.
 
470
         *
 
471
         * @return {Array<hydrolysis.ElementDescriptor>} The descriptors, or `null`.
 
472
         */
 
473
        _loadJson: function() {
 
474
          var textContent = '';
 
475
          Array.prototype.forEach.call(Polymer.dom(this).childNodes, function(node) {
 
476
            textContent = textContent + node.textContent;
 
477
          });
 
478
          textContent = textContent.trim();
 
479
          if (textContent === '') return null;
 
480
 
 
481
          try {
 
482
            var json = JSON.parse(textContent);
 
483
            if (!Array.isArray(json)) return [];
 
484
            return json;
 
485
          } catch(error) {
 
486
            console.error('Failure when parsing JSON:', textContent, error);
 
487
            throw error;
 
488
          }
 
489
        },
 
490
 
 
491
        /**
 
492
         * Load the page identified in the fragment identifier.
 
493
         */
 
494
 
 
495
        _setActiveFromHash: function(hash) {
 
496
          // hash is either element-name or element-name:{properties|methods|events} or
 
497
          // element-name:{property|method|event}.member-name
 
498
          var hash = window.location.hash;
 
499
          if (hash) {
 
500
            var elementDelimiter = hash.indexOf(':');
 
501
            elementDelimiter = (elementDelimiter == -1) ? hash.length : elementDelimiter;
 
502
            var el = hash.slice(1, elementDelimiter);
 
503
            if (this.active != el) {
 
504
              this.active = el;
 
505
            }
 
506
            this.$.viewer.scrollToAnchor(hash);
 
507
          }
 
508
        },
 
509
 
 
510
        _srcChanged: function() {
 
511
          var srcUrl;
 
512
          if (this.docSrc) {
 
513
            if (!this.$.ajax.lastRequest || (this.docSrc !== this.$.ajax.lastRequest.url && this.docSrc !== this._lastDocSrc)) {
 
514
              this._ajaxLoading = true;
 
515
              this._ajaxDesc = null;
 
516
              this._activeDescriptor = null;
 
517
              this.$.ajax.generateRequest();
 
518
            }
 
519
            this._lastDocSrc = this.docSrc;
 
520
            return;
 
521
          } else if (this.src) {
 
522
            srcUrl = new URL(this.src, this.base).toString();
 
523
          } else {
 
524
            var base = _baseUrl(this.base);
 
525
            srcUrl = new URL(base.match(/([^\/]*)\/$/)[1] + ".html", base).toString();
 
526
          }
 
527
 
 
528
          // Rewrite gh-pages URLs to https://rawgit.com/
 
529
          var match = srcUrl.match(/([^\/\.]+)\.github\.io\/([^\/]+)\/?([^\/]*)$/);
 
530
          if (match) {
 
531
            srcUrl = "https://cdn.rawgit.com/" + match[1] + "/" + match[2] + "/master/" + match[3];
 
532
          }
 
533
 
 
534
          this._baseUrl = _baseUrl(srcUrl);
 
535
          this._srcUrl  = srcUrl;
 
536
          if (!this._hydroLoading) this.$.analyzer.analyze();
 
537
        },
 
538
 
 
539
        _updateFrameSrc: function(view) {
 
540
          if (!view || view.indexOf("demo:") !== 0) return "about:blank";
 
541
 
 
542
          var src = view.split(':')[1];
 
543
          var demoSrc = new URL(src, this.base).toString();
 
544
 
 
545
          // If you use history.pushState with iframe.src = url, you will create 2 history entries,
 
546
          // but creating a new iframe dynamically will prevent it.
 
547
 
 
548
          if (this._iframe) {
 
549
            Polymer.dom(this.$.demo).removeChild(this._iframe);
 
550
          }
 
551
 
 
552
          this._iframe = document.createElement('iframe');
 
553
          this._iframe.src = demoSrc;
 
554
          Polymer.dom(this.$.demo).appendChild(this._iframe);
 
555
        },
 
556
 
 
557
        _getDefaultActive: function() {
 
558
          var matchedPage;
 
559
          var url = this._srcUrl || this.base;
 
560
          var mainFile = url.replace(_baseUrl(this.base), '');
 
561
 
 
562
          function findMatch(list) {
 
563
            for (var item, i = 0; i < list.length; i++) {
 
564
              item = list[i];
 
565
              if (item && item.contentHref && item.contentHref.indexOf(mainFile) > 0) {
 
566
                return item;
 
567
              }
 
568
            }
 
569
            return null;
 
570
          }
 
571
 
 
572
          matchedPage = findMatch(this.docElements) || findMatch(this.docBehaviors);
 
573
 
 
574
          if (matchedPage) {
 
575
            return matchedPage.is;
 
576
          } else if (this.docElements.length > 0) {
 
577
            return this.docElements[0].is;
 
578
          } else if (this.docBehaviors.length > 0) {
 
579
            return this.docBehaviors[0].is;
 
580
          }
 
581
          return null;
 
582
        },
 
583
 
 
584
        _findDescriptor: function(name) {
 
585
          if (!this._analyzer) return null;
 
586
 
 
587
          var descriptor = this._analyzer.elementsByTagName[name];
 
588
          if (descriptor) return descriptor;
 
589
 
 
590
          for (var i = 0; i < this._analyzer.behaviors.length; i++) {
 
591
            if (this._analyzer.behaviors[i].is === name) {
 
592
              return this._analyzer.behaviors[i];
 
593
            }
 
594
          }
 
595
          return null;
 
596
        },
 
597
 
 
598
        _activeChanged: function(active, analyzer) {
 
599
          if (active === '') {
 
600
            this.active = this._getDefaultActive();
 
601
            return;
 
602
          }
 
603
          this.async(function() { this.$.active.value = active; });
 
604
          if (analyzer && analyzer.elementsByTagName) {
 
605
            this.$.headerPanel.scroller.scrollTop = 0;
 
606
            this._activeDescriptor = this._findDescriptor(active);
 
607
            if (this._activeDescriptor) {
 
608
              var hasDemo;
 
609
              var demos = this._activeDescriptor.demos;
 
610
              if (this.view && demos && demos.length) {
 
611
                var parts = this.view.split(':');
 
612
                if (parts[0] == 'demo') {
 
613
                  if (parts[1]) {
 
614
                    hasDemo = demos.some(function(d, i) {
 
615
                      if (d.path == parts[1]) {
 
616
                        return true;
 
617
                      }
 
618
                    });
 
619
                  }
 
620
                  if (!hasDemo) {
 
621
                    this.view = 'demo:' + demos[0].path;
 
622
                    hasDemo = true;
 
623
                  }
 
624
                }
 
625
              }
 
626
              if (!hasDemo == undefined) {
 
627
                this.view = 'docs';
 
628
              }
 
629
              if (this._activeDescriptor.is && !document.title) {
 
630
                document.title = this._activeDescriptor.is + " documentation";
 
631
              }
 
632
              if (this._activeDescriptor.is && !this.catalog) {
 
633
                this._fragmentPrefix = this._activeDescriptor.is + ':';
 
634
              } else {
 
635
                this._fragmentPrefix = '';
 
636
              }
 
637
              // On initial load, scroll to the selected anchor (if any).
 
638
              // This probably shouldn't be required when we're running
 
639
              // in the catalog, but at the moment it is.
 
640
              this.$.viewer.scrollToAnchor(window.location.hash);
 
641
            }
 
642
            this._setDocDemos(this._activeDescriptor ? this._activeDescriptor.demos : []);
 
643
          }
 
644
        },
 
645
 
 
646
        _loadingChanged: function() {
 
647
          this.toggleClass('loaded', !this._loading);
 
648
        },
 
649
 
 
650
        _detectLoading: function() {
 
651
          this._loading = this.docSrc ? this._ajaxLoading : this._hydroLoading;
 
652
        },
 
653
 
 
654
        _analyzerChanged: function() {
 
655
          var analyzer = this._analyzer;
 
656
          this._setDocElements(analyzer && analyzer.elements ? analyzer.elements : []);
 
657
          this._setDocBehaviors(analyzer && analyzer.behaviors ? analyzer.behaviors : []);
 
658
 
 
659
          if (!this._findDescriptor(this.active)) {
 
660
            this.active = this._getDefaultActive();
 
661
          }
 
662
        },
 
663
 
 
664
        _detectAnalyzer: function() {
 
665
          this._analyzer = this.docSrc ? this._ajaxDesc : this._hydroDesc;
 
666
        },
 
667
 
 
668
        _handleMenuItemSelected: function(e) {
 
669
          if (e.target && e.target.value) {
 
670
            window.location.hash = '#' + e.target.value;
 
671
          }
 
672
        },
 
673
 
 
674
        _handleAjaxResponse: function(e, req) {
 
675
          this._ajaxLoading = false;
 
676
          this._ajaxLastUrl = req.url;
 
677
          this._ajaxDesc = req.response;
 
678
        },
 
679
 
 
680
        _handleError: function(e) {
 
681
          this.fire('iron-component-page-error', e.detail);
 
682
        },
 
683
 
 
684
        _handleComponentSelectedEvent: function(ev) {
 
685
          var descriptor = this._findDescriptor(ev.detail);
 
686
          if (!descriptor) {
 
687
            console.warn("Could not navigate to ", ev.detail);
 
688
          }
 
689
          else {
 
690
            this.active = ev.detail;
 
691
          }
 
692
        },
 
693
 
 
694
        /**
 
695
         * Renders this element into static HTML for offline use.
 
696
         *
 
697
         * This is mostly useful for debugging and one-off documentation generation.
 
698
         * If you want to integrate doc generation into your build process, you
 
699
         * probably want to be calling `hydrolysis.Analyzer.analyze()` directly.
 
700
         *
 
701
         * @return {string} The HTML for this element with all state baked in.
 
702
         */
 
703
        marshal: function() {
 
704
          var jsonText = JSON.stringify(this.docElements || [], null, '  ');
 
705
          return '<' + this.is + '>\n' +
 
706
                 jsonText.replace(/</g, '&lt;').replace(/>/g, '&gt;') + '\n' +
 
707
                 '</' + this.is + '>';
 
708
        },
 
709
 
 
710
        _demoView: function(path) {
 
711
          return "demo:" + path;
 
712
        },
 
713
 
 
714
        _viewType: function(view) {
 
715
          return view ? view.split(":")[0] : null;
 
716
        }
 
717
      });
 
718
    })();
 
719
  </script>
 
720
</dom-module>