Sha256: f259427084bc310adda5bc3d9d31bb1b86a0eccff5dd2acde3527bda41bc3a4f

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

angular.module("oxymoron.notifier", [])
  .run(['$rootScope', 'ngNotify', 'Validate', '$state', '$http', '$location', function ($rootScope, ngNotify, Validate, $state, $http, $location) {
    ngNotify.config({
        theme: 'pure',
        position: 'top',
        duration: 2000,
        type: 'info'
    });

    $rootScope.$on('loading:finish', function (h, res) {
      callback('success', res)
    })

    $rootScope.$on('loading:error', function (h, res, p) {
      callback('error', res)
    })

    function callback (type, res) {
      if (res.data && angular.isObject(res.data)) {
        if (res.data.msg) {
          ngNotify.set(res.data.msg, type);
        }

        if (res.data.errors) {
          Validate(res.data.form_name || res.config.data.form_name, res.data.errors)
        }

        if (res.data.redirect_to_url) {
          $location.url(res.data.redirect_to_url);
        } else if (res.data.redirect_to) {
          $state.go(res.data.redirect_to, res.data.redirect_options || {});
        }

        if (res.data.reload) {
          window.location.reload();
        }
      }
    }
  }])

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
oxymoron-1.0.2 app/assets/javascripts/oxymoron/notifier.js.erb
oxymoron-1.0.1 app/assets/javascripts/oxymoron/notifier.js.erb
oxymoron-1.0.0 app/assets/javascripts/oxymoron/notifier.js.erb