Skip to content
Daryl Hedley edited this page Aug 5, 2014 · 9 revisions

Origin has an internal notifications system and can trigger four types of notifications:

  • Popup - Used for when you need to popup some additional information. Similar to the feedback plugin Tutor.
  • Alert - Used to get the users attention. Has a confirm button that needs clicking before progressing further in the course. The confirm button triggers a callback event.
  • Prompt - Used for when the learner needs to make a choice. The prompts can have unlimited button options but we suggest three is the maximum. Each prompt button triggers a callback event.
  • Push - Used to push an unobtrusive message to the learner. Similar to Mac OS growl. Only two push notifications are displayed at once whilst the others are push into a queue.

How to activate a popup:

var popupObject = {
    title: "Popup title",
    body: "This is a popup to add additional information - please close me by pressing the 'x'",
    _classes: ""
};

Origin.trigger('notify:popup', popupObject);

How to activate an alert:

var alertObject = {
    title: "Alert",
    body: "Oops - looks like you've not passed this assessment. Please try again.",
    confirmText: "Ok",
    _callbackEvent: "assessment:notPassedAlert",
    _showIcon: true,
    _classes: "alert-color"
};

Origin.trigger('notify:alert', alertObject);

How to activate a prompt dialogue:

var promptObject = {
    title: "Leaving so soon?",
    body: "Looks like you're trying to leave this page, yet you haven't completed all the learning. Would you like to stay on this page and complete it?",
    _prompts:[
        {
            promptText: "Yes",
            _callbackEvent: "pageLevelProgress:stayOnPage"
        },
        {
            promptText: "No",
            _callbackEvent: "pageLevelProgress:leavePage"
        }
    ],
    _showIcon: true,
    _classes: "primary-color"
}

Origin.trigger('notify:prompt', promptObject);

How to active a push notification:

var pushObject = {
    title: "Great work!",
    body: "You've just completed a page",
    _timeout:5000,
    _callbackEvent: "pageCompletion:complete",
    _classes: "primary-color"
};
// The _callbackEvent is called when the push notification is clicked.
// This callback event is not fired when closed.
Origin.on('pageCompletion:complete', function() {
    console.log('A push alert was clicked');
});

Origin.trigger('notify:push', pushObject);

Clone this wiki locally