app.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. (function(document) {
  2. 'use strict';
  3. var app = document.querySelector('#app');
  4. // Sets app default base URL
  5. app.baseUrl = '/';
  6. // don't display the install prompt if the user has *already* installed
  7. window.addEventListener('beforeinstallprompt', function(event) {
  8. if (window.matchMedia('(display-mode: standalone)').matches) {
  9. return event.preventDefault();
  10. }
  11. });
  12. app.displayInstalledToast = function() {
  13. // Check to make sure caching is actually enabled—it won't be in the dev environment.
  14. if (!Polymer.dom(document).querySelector('platinum-sw-cache').disabled) {
  15. Polymer.dom(document).querySelector('#caching-complete').show();
  16. }
  17. };
  18. app.displayToast = function(msg) {
  19. var toast = Polymer.dom(document).querySelector('#toast');
  20. toast.text = msg;
  21. toast.show();
  22. };
  23. // Listen for template bound event to know when bindings
  24. // have resolved and content has been stamped to the page
  25. app.addEventListener('dom-change', function() {
  26. console.log('Our app is ready to rock!');
  27. app.conn = document.querySelector('connection-wrapper');
  28. });
  29. // See https://github.com/Polymer/polymer/issues/1381
  30. window.addEventListener('WebComponentsReady', function() {
  31. // imports are loaded and elements have been registered
  32. });
  33. app._showAbout=function(){
  34. document.querySelector('#pages').select(0);
  35. };
  36. })(document);