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

angular-placeholder

v1.1.0

Published

Placeholder shim for IE8/IE9 and styling simplification.

Downloads

300

Readme

Angular Placeholder Directive

This directive will shim in placeholder support for browsers that do not support placeholders. The directive may also make styling easier by letting you combine your rules. It does not use a jQuery plugin and simulates the behavior by adding text for input and textarea elements when they do not have focus.

npm version Build Status Dependencies Dev Dependencies

Demo

There's a live demo courtesy of Plunker. In case you want some more advanced styling, there's another demo that helps illustrate what you can do.

Browser Support

Placeholder styling was natively implemented in IE 10, Chrome 4, Firefox 4, Safari 5, Opera 11.6. Internet Explorer 8 and 9 do not support this natively, but many places are forced to still code for those browsers.

How to Use

Using this plugin needs only three easy steps.

  1. Include the plugin into your page.

    <script src="tai-placeholder.js"></script>
  2. Add this somewhere to the module dependencies for your Angular application.

    angular.module('yourApplication', [ 'taiPlaceholder' ]);
  3. Make sure your element has both "ng-model" and "placeholder" attributes.

    <input type="text" ng-model="firstName" placeholder="First Name" />
    
    <textarea ng-model="feedback" placeholder="Provide feedback!"></textarea>
  4. Style the placeholder with some CSS for IE8 and IE9.

    .placeholder {
        color: #aaa;
    }

Further Configuration

There is an extra attribute that you can specify on your input tags to control the name of the class that is applied when the input should be showing placeholder text. The default value for placeholder-class is "placeholder" but you can change it.

<input type="text" ng-model="firstName" placeholder="First Name"
    placeholder-class="placeholder-blue">
<input type="text" ng-model="lastName" placeholder="Last Name"
    placeholder-class="placeholder-red">

The above sample will apply different classes for the first name and the last name. Using this mechanism you can style the inputs differently. You can achieve the same effect by having your inputs use classes - the above is just one path to a goal.

To change the color of the text you still need to write some duplicate CSS. This is what's needed to change the color to red for all browsers.

.placeholder { color: red; }
::-webkit-input-placeholder { color: red; }
:-moz-placeholder { color: red; }
::moz-placeholder { color: red; }
:-ms-input-placeholder { color: red; }

The rules need to be split out because browsers must ignore rules that contain invalid CSS selectors, and the browsers don't understand other browser-specific pseudoclasses and pseudoelements.

Here's a breakdown of the selectors.

  • .placeholder - All browsers get this class, but IE8 and IE9 can style the text when this class is applied to the elements.
  • ::-webkit-input-placeholder - WebKit and Blink (Safari, Chrome, Opera 15+)
  • :-moz-placeholder - Firefox 4 - 18
  • ::-moz-placeholder - Firefox 19+
  • :-ms-input-placeholder - IE 10

Developing

First, clone the repository. Then you need to run npm install to get most of the dependencies and npm run bower for the rest.

Testing

Tests are always included. You can run them with the following command. It runs the test suite with PhantomJS.

grunt test

If live feedback during development is what you would like, use this. It's also easier to run tests in many different browsers with this command - just open up the server with many different browsers and the tests will run in all of them.

grunt watch

LICENSE

This plugin is licensed under an MIT license with an additional non-advertising clause. Read full license.