app.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. (function(document) {
  2. 'use strict';
  3. // Grab a reference to our auto-binding template
  4. // and give it some initial binding values
  5. // Learn more about auto-binding templates at http://goo.gl/Dx1u2g
  6. var app = document.querySelector('#app');
  7. // Sets app default base URL
  8. app.baseUrl = '/';
  9. if (window.location.port === '') { // if production
  10. // Uncomment app.baseURL below and
  11. // set app.baseURL to '/your-pathname/' if running from folder in production
  12. // app.baseUrl = '/polymer-starter-kit/';
  13. }
  14. // don't display the install prompt if the user has *already* installed
  15. window.addEventListener('beforeinstallprompt', function(event) {
  16. if (window.matchMedia('(display-mode: standalone)').matches) {
  17. return event.preventDefault();
  18. }
  19. });
  20. app.displayInstalledToast = function() {
  21. // Check to make sure caching is actually enabled—it won't be in the dev environment.
  22. if (!Polymer.dom(document).querySelector('platinum-sw-cache').disabled) {
  23. Polymer.dom(document).querySelector('#caching-complete').show();
  24. }
  25. };
  26. app.displayToast = function(msg) {
  27. var toast = Polymer.dom(document).querySelector('#toast');
  28. toast.text = msg;
  29. toast.show();
  30. };
  31. // Listen for template bound event to know when bindings
  32. // have resolved and content has been stamped to the page
  33. app.addEventListener('dom-change', function() {
  34. console.log('Our app is ready to rock!');
  35. app.conn = document.querySelector('connection-wrapper');
  36. });
  37. // See https://github.com/Polymer/polymer/issues/1381
  38. window.addEventListener('WebComponentsReady', function() {
  39. // imports are loaded and elements have been registered
  40. });
  41. app._showAbout=function(){
  42. document.querySelector('#pages').select(1);
  43. };
  44. app._showAbout=function(){
  45. document.querySelector('#pages').select(0);
  46. };
  47. })(document);