npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngDfp

v0.16.1

Published

ngDfp is a simple library for Angular JS that allows you to add DoubleClick for Publishers tags to your Angular site.

Downloads

4

Readme

ngDfp

ngDfp is a simple library for Angular JS that allows you to add DoubleClick for Publishers tags to your Angular site.

Requirements

This library requires Angular JS 1.2 or higher. It might work with older versions but I can't guarantee it.

Getting Started

Just install via bower:

bower install ngDfp --save

or npm:

npm install ngDfp --save

Then, include it as a dependency:

angular.module('your.module', ['ngDfp'])

and configure your slots in your app's config:

.config(function (DoubleClickProvider) {
  DoubleClickProvider.defineSlot('/123456/Your_Slot', [100, 500], 'div-gpt-ad-1234567890123-0')
                     .defineSlot('/123456/Your_Slot', [300, 200], 'div-gpt-ad-1234567890123-1');
});

Now, to show an ad, simply use the ng-dfp-ad:

<div data-ng-dfp-ad="div-gpt-ad-1234567890123-0"></div>

Refreshing Ads

Ads can be refreshed with a global interval or individually. To configure a global interval:

// Refresh all ads every 30 seconds
DoubleClickProvider.setRefreshInterval(30000);

To refresh an ad individually you can do two things:

<!-- Refresh this ad every `refreshInterval` seconds -->
<div ng-dfp-ad="div-gpt-ad-1234567890123-0" ng-dfp-ad-refresh-interval="{{refreshInterval}}"></div>

Or programatically with the provider:

app.controller(function (DoubleClick) {
  DoubleClick.refreshAds('div-gpt-ad-1234567890123-0', 'div-gpt-ad-1234567890123-1');
});

Optionally, you can refresh an ad individually immediately or after a defined timeout:

<!-- Refresh this ad immediately -->
<div ng-dfp-ad="div-gpt-ad-1234567890123-0" ng-dfp-ad-refresh></div>
<!-- Refresh this ad after `refreshTimeout` seconds -->
<div ng-dfp-ad="div-gpt-ad-1234567890123-0" ng-dfp-ad-refresh-timeout="{{refreshTimeout}}"></div>

Hiding Emtpy Ads

Ads can be hidden by adding the attribute data-ng-dfp-ad-hide-when-empty to the ad tag. You have to specify the container of the ad using the data-ng-dfp-ad-container directive. This is useful if you contain the ad in a parent div with some styles. For example, the following snippet will hide itself when empty:

<div data-ng-dfp-ad="div-gpt-ad-1234567890123-0" data-ng-dfp-ad-hide-when-empty data-ng-dfp-ad-container></div>

And the following will hide the container

<div class="my-fancy-ad-container" data-ng-dfp-ad-container>
  <div data-ng-dfp-ad="div-gpt-ad-1234567890123-0" data-ng-dfp-ad-hide-when-empty></div>
</div>

Responsive Ads

You can use Google Publisher Tags (GPT) to build responsive ads that fit the browser your visitors use to view your website. This means that your ads will look good whether your visitors are using a desktop, tablet, or smartphone.
More information about Building Responsive Ads.

DoubleClickProvider.defineSlot('/123456/Your_Slot', [[970, 90], [728, 90], [88, 31]], 'div-gpt-ad-1431622560634-6');
DoubleClickProvider
    .defineSizeMapping('div-gpt-ad-1431622560634-6')
    .addSize([1024, 768], [970, 90])
    .addSize([980, 690], [728, 90])
    .addSize([640, 480], [728, 90])
    // Fits browsers of any size smaller than 640 x 480
    .addSize([0, 0], [88, 31]);

Minimizing

Closure Compiler is used to minimize the code. It is minimized using this command

closure-compiler --js_output_file=angular-dfp.min.js --compilation_level SIMPLE angular-dfp.js

Advanced optimizations are not used because as of now the AngularJS codebase does not support it.

Issues

Please file issues using GitHub's issue tracker.

Contributing

Pull requests are more than welcome!