Google analytics code

Friday, October 2, 2015

Ionic Framework / UI Router: Remove a query parameter from the URI

I've been working with Ionic Framework for most of the year and finally launched the alpha version of my project. I've enjoyed working with it, but like everything you'll run into something that makes you bang your head on the desk for a few days. The most recent case of this was trying to remove a parameter from the URI.

If a user needs to reset their password I send them a URI that looks something like this.
http://this.that/login?resetKey=1234

After the user finishes the steps to reset I want to clean up the URI so if they hit the refresh button it doesn't trigger the reset process again.
http://this.that/login

I had the worse time finding an answer on google. After a few days of digging through UI Router documentation I finally found a combination that worked.

First you need to inject the $state param into your controller. We'll use the go method and redirect to the current URI using the current router name. The current route name can be accessed through the $state.current.name property. Next we need to specify the parameter we want to remove from the URI. We'll use an object with the key as the param name and the value will be null. Lastly we don't want to trigger the route again so we'll set the notify property to false.

The final command looks like this.
$state.go($state.current.name,{'resetKey': null},{'notify': false});

Such a simple command. So much digging. UGH!

Tuesday, June 23, 2015

HTML / CSS 3: Progress bar example

I've been working with the progress element and trying to get it to look nice across different browsers. It doesn't help that most of the styling elements are pseudo elements.

Here's the MDN page on the progress element.

The big issue I ran into was trying to style the element for Chrome and Firefox.
Chrome uses the following styles to change the look of the element:

progress::-webkit-progress-bar
This will style the background of the progress bar.

progress::-webkit-progress-value
This will style the growing value inside of the progress bar.

Firefox uses the following value:
progress::-moz-progress-value
This will only let you style the growing value inside of the progress bar. You can't style the background.

The other catch is you can't combine the values in your css. For example this won't work

progress::-moz-progress-value,
progress::-webkit-progress-value{

}

None of your styles will take and the bar will fall back to it's unstyled default.

Here's the html I was playing with.
Here's a link to a jsFiddle of the following code


/* http://www.hongkiat.com/blog/html5-progress-bar/ */
.progress-bar{
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Can't share styles. Chome gets angry */
/* FF style the progress bar */
.progress-bar::-moz-progress-value{
    background: #3399ff;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) inset;
}

/* Chrome style the background of the progress bar */
.progress-bar::-webkit-progress-bar{
    background: silver;
    border-radius: 12px;
}

/* Chrome style the progress value */
.progress-bar::-webkit-progress-value{
    background: #3399ff;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) inset;
}