Giter Club home page Giter Club logo

angularplus's Introduction

AngularPlus

AngularPlus (ngplus) contains a set of helpers, directives and services for AngularJS, under MIT license.

Version 0.9.2

Authors: John Papa and Dan Wahlin

Use, reproduction, distribution, and modification of this code is subject to the terms and conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php

ngplusOverlay Directive

ngplusOverlay Directive Example

The ngplusOverlay directive intercepts $http and jQuery XHR calls and displays and overlay. To get started using it follows these steps:

  1. Add the directive script located in scripts/ngplus-overlay.js into your project and reference the ngplus module:
  2. Reference the ngplus module:
angular.module('app', ['ngRoute', 'ngAnimate', 'ngplus']);
  1. Add the following styles into a CSS stylesheet (tweak as needed):
.ngplus-overlay-background {
    top: 0px;
    left: 0px;
    padding-left: 100px;
    position: absolute;
    z-index: 10000;
    height: 100%;
    width: 100%;
    background-color: #808080;
    opacity: 0.2;
}

.ngplus-overlay-content {
    position: absolute;
    /*border: 1px solid #000;*/
    /*background-color: #fff;*/
    font-weight: bold;
    height: 100px;
    width: 300px;
    height: 15em;
    width: 20em;
    z-index: 10000;
    text-align: center;
}

/*Optional Animations*/
.dissolve-animation.ng-hide-remove,
.dissolve-animation.ng-hide-add {
    display: inline !important;
    -webkit-transition: 0.5s linear all;
    -moz-transition: 0.5s linear all;
    -o-transition: 0.5s linear all;
    transition: 0.5s linear all;
}

    .dissolve-animation.ng-hide-remove.ng-hide-remove-active,
    .dissolve-animation.ng-hide-add {
        opacity: 1;
    }

        .dissolve-animation.ng-hide-add.ng-hide-add-active,
        .dissolve-animation.ng-hide-remove {
            opacity: 0;
        }
  1. Add the directive into your main shell page:
<div ngplus-overlay
     ngplus-overlay-delay-in="50"
     ngplus-overlay-delay-out="700"
     ngplus-overlay-animation="dissolve-animation">
    <img src="../../content/images/busy.gif"/>
 	  Optional loading message or HTML content goes here
</div>

Once you have the code locally, install Node.js, open a command-prompt and run:

node server.js

ngplusOverlay directive in action.

Note: This directive was created for a prototype project and has only been tested with Chrome and IE10+. It's intended to provide a starting point, evolve over time (please contribute!), and hopefully save someone some time.

Options

  • ngplus-overlay-delay-in="50" indicates the number of milliseconds to wait before showing the overlay. This is useful so we do not have a flicker for super short XHR. Default is 500 ms.
  • ngplus-overlay-delay-out="700" indicates the number of milliseconds to keep the overlay around after the last XHR has completed. Default is 500 ms.
  • ngplus-overlay-animation="dissolve-animation" indicates the CSS animation to apply. Must be an animation that supports the AngularJS standard for ngShow/ngHide. This is an optional setting.

Disable ngPlus Overlay

The ngPlus overlay can be disabled for specific requests by setting the hideOverlay option to true on either the angular http request config or the jquery ajax options objects.

  • Angular

$http

$http({
    url: 'http://www.google.com',
    // ...
    hideOverlay: true,
});

$resource

return $resource('http://www.google.com', {}, {
    get : {
        'hideOverlay':true
    }
});
  • jQuery
$.ajax({
    url: 'http://www.google.com',
    // ...
    hideOverlay: true,
});

If you don't have control over the xhr being made you can create an angular interceptor to modify the request config and register that before the ngPlus interceptor. In jQuery you can register an $.ajaxSend handler before the ngPlus handler to check the request object and add the hideOverlay attribute if needed.

angularplus's People

Contributors

johnpapa avatar abombss avatar danwahlin avatar wardbell avatar

Watchers

Edwin Joel Ulloa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.