app-notifications

jifalops

by SlashBunny

HTML

<base href="https://raw-dot-custom-elements.appspot.com/jifalops/app-notifications/1.0.0/app-notifications/">
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="app-notifications.html">
<app-notifications id="notifications"></app-notifications>
Title:
<br/>
<input id="title" value="title" />
<br/> Options:
<br/>
<textarea id="options" rows="3" cols="30">
  {"tag": "app", "body": "body", "icon": "demo/icon.png"}
</textarea>
<br/> Duration (ms):
<br/>
<input id="duration" value="0" />
<br/>
<button onclick="_showNotification();">Show Notification</button>
Last event: <span id="feedback"></span>
<script>
  var notifications = document.getElementById('notifications');
  var title = document.getElementById('title');
  var options = document.getElementById('options');
  var duration = document.getElementById('duration');
  var feedback = document.getElementById('feedback');
  _showNotification = function() {
    notifications.show(
      title.value,
      JSON.parse(options.value),
      duration.value,
      function(e, n) {
        feedback.innerHTML = 'Notification shown';
      },
      function(e, n) {
        feedback.innerHTML = 'Notification clicked';
      },
      function(e, n) {
        feedback.innerHTML = 'Notification closed';
      },
      function(e, n) {
        feedback.innerHTML = 'Notification error';
      });
  }

</script>