UNPKG

api-console-assets

Version:

This repo only exists to publish api console components to npm

129 lines (115 loc) 4.38 kB
<!doctype html> <!-- @license Copyright (c) 2015 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt --> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes"> <title>form-data-editor demo</title> <script src="../../webcomponentsjs/webcomponents-lite.js"></script> <link rel="import" href="../../arc-demo-helpers/raml-demo-page.html"> <link rel="import" href="../../paper-dropdown-menu/paper-dropdown-menu.html"> <link rel="import" href="../../paper-listbox/paper-listbox.html"> <link rel="import" href="../../paper-item/paper-item.html"> <link rel="import" href="../../font-roboto/roboto.html"> <link rel="import" href="../form-data-editor.html"> <style is="custom-style"> :root { } html, body { margin: 0; padding: 0; font-family: 'Roboto', 'Noto', sans-serif; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; font-size: 14px; font-weight: 400; line-height: 20px; } .output { margin: 40px 16px 16px 16px; word-break: break-all; } </style> </head> <body unresolved> <template is="dom-bind" id="app"> <raml-demo-page raml="{{raml}}" selected-object="{{selected}}" is-method="{{isMethod}}" path="{{path}}" narrow="{{narrow}}"> <paper-item data-url$="[[testRaml]]">Test case with RAML 1.0</paper-item> <paper-item data-url$="[[testRaml08]]">Test case with RAML 0.8</paper-item> <h1>The body-form-editor element</h1> <div main> <template is="dom-if" if="[[isMethod]]"> <paper-dropdown-menu label="Select mime type"> <paper-listbox class="dropdown-content" attr-for-selected="data-value" selected="{{mime}}"> <template is="dom-repeat" items="[[mimes]]"> <paper-item data-value="[[item]]">[[item]]</paper-item> </template> </paper-listbox> </paper-dropdown-menu> <template is="dom-if" if="[[selectedBody]]"> <form-data-editor value="{{body}}" raml-type="[[selectedBody]]" narrow="[[narrow]]"></form-data-editor> <div class="output"> <h4>Form value:</h4> <output>{{body}}</output> </div> </template> </template> <p hidden$="[[isMethod]]">Select a method</p> </div> </raml-demo-page> <paper-toast text="Methods are not supported in this demo." id="noMethods"></paper-toast> </template> <script> (function(app) { app.selectedBody = null; app.mimes = []; app.mime = null; app.observers = ['_selectedChanged(selected.body)', '_mimeChanged(mime, selected.body)']; app._selectedChanged = function(body) { app.mime = null; if (!body || !(body instanceof Array)) { app.mimes = []; return; } var mimes = body.map(function(item) { return item.key; }); app.mimes = mimes; if (mimes.indexOf('application/x-www-form-urlencoded') !== -1) { app.mime = 'application/x-www-form-urlencoded'; } }; app._mimeChanged = function(mimeType, body) { if (!mimeType || !body || !body.length) { app.selectedBody = null; return; } for (var i = 0, len = body.length; i < len; i++) { if (body[i].key === mimeType) { app.selectedBody = body[i]; return; } } app.selectedBody = null; }; var path = location.pathname; if (~path.indexOf('.html')) { path = path.substr(0, path.lastIndexOf('/') + 1); } var ramlRoot = location.protocol + '//' + location.host + path.replace('demo', 'test'); app.testRaml = ramlRoot + 'test-10.raml'; app.testRaml08 = ramlRoot + 'test-08.raml'; })(document.querySelector('template[is="dom-bind"]')); </script> </body> </html>