Sha256: 21fff6cf7047ab2b7a88b270d46b2997f7869dae50e0c7c395b4ed71087a45fc

Contents?: true

Size: 1.48 KB

Versions: 12

Compression:

Stored size: 1.48 KB

Contents

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

    var callback = function(type, res) {
      if (res.data && angular.isObject(res.data)) {
        if (res.data.msg || res.data.error) {
          Notice.callback(type, res);
        }

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

        if (res.data.reload) {
          if (res.data.redirect_to_url) {
            window.location = res.data.redirect_to_url;
          } else if (res.data.redirect_to) {
            $state.transitionTo(res.data.redirect_to, res.data.redirect_options || {}, {notify: false, location: true, reload: true});
          }
        } else {
          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();
        }
      }
    }

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

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


  }])

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
oxymoron-1.2.8 app/assets/javascripts/oxymoron/notifier.js.erb
oxymoron-1.2.7 app/assets/javascripts/oxymoron/notifier.js.erb
oxymoron-1.2.6 app/assets/javascripts/oxymoron/notifier.js.erb
oxymoron-1.2.5 app/assets/javascripts/oxymoron/notifier.js.erb
oxymoron-1.2.4 app/assets/javascripts/oxymoron/notifier.js.erb
oxymoron-1.2.3 app/assets/javascripts/oxymoron/notifier.js.erb
oxymoron-1.2.2 app/assets/javascripts/oxymoron/notifier.js.erb
oxymoron-1.2.1 app/assets/javascripts/oxymoron/notifier.js.erb
oxymoron-1.2.0 app/assets/javascripts/oxymoron/notifier.js.erb
oxymoron-1.1.9 app/assets/javascripts/oxymoron/notifier.js.erb
oxymoron-1.1.8 app/assets/javascripts/oxymoron/notifier.js.erb
oxymoron-1.1.7 app/assets/javascripts/oxymoron/notifier.js.erb