Same functionality, same UI, but different controller in AngularJS

I am relatively new to AngularJS, but I don’t miss occasion to be surprised by the simplicity of this spectacular framework.

First of all we define a service which contains the functionality we need. In this case is a “Welcome panel”, where it’s visibility can be managed from different points.
Continue reading Same functionality, same UI, but different controller in AngularJS

Setting Page titles with AngularJS


In AngularJS if we want to share informations across multiple controllers we should use factories.

I needed to change the page titles from multiple locations, so I made use of an extremely simple factory. We are going to use a local variable, named title which contains the title, and two exposed methods: title, which is going to be in charge of returning the title, and setTitle which we’ll call from the controllers to change the title page.
Continue reading Setting Page titles with AngularJS

Using the page visibility API in an AngularJS project

The page visibility api allows developers and designers to
control when the user is actually on the page, and when the user is away, for example the tab is
opened but not in focus, or the browser is minimized.

The first use I did of this api is to interrupt server side refreshes of the data, while the user is
not on the page, to avoid consumption of server side resources.

The specification gives us two tools: the first one is a variable document.hidden which is
true if the page is not on focus, and false while the user is actually on the page. The second tool we have is
an event: visibilitychange which tells us when to look for the value of that variable.

So far so good, but how can we use this?
Continue reading Using the page visibility API in an AngularJS project

How to setup global git hooks

What is a Git Hook

Git hooks are basically bash scripts which are going to run before or after a git command is run.
By default git hooks are located under /usr/share/git-core/templates. If you are using brew for
managing your git, then the location of the default hooks will be under the folder: usr/local/Cellar/git/VERSION/share/git-core/contrib/hooks.
In these folders you can see examples of them.

What I use git hooks for

Continue reading How to setup global git hooks

Git Rebase to keep a clean history

Since I started working on TinyMCE here at ephox, I found the importance of commands I never used in previous project.
The goal here it’s to keep the history of the repository as clean as possible, to keep a meaning when somebody in the future is going to look at that history.
Git has all the tools needed for the job of course. The path we chosen it’s to use the git rebase command.

git rebase master
git checkout master
git merge forkedBranch

Float label pattern with AngularJS

Recently I sow an article about the float label pattern. There is also an article on tutsplus, which explains how to get this using standard jQuery. This is the exact same trick, but using AngularJS:

<form action="">
  <label for="name" ng-show="">Name</label>
  <input type="text" id="name" placeholder="Name" ng-model="" >

Yes, it needs to be polished and styled a bit, but it is really easy!

The best panorama photo I have ever seen.

Quiver Trees by Night – by Florian Breuer

This picture happened to be on “Bing photo of the day”, last year. I immediately fallen in love with it.
Few days ago, I was speaking with a friend of mine, he also passionate about photography, speaking about this picture.

Took me few hours of research, since, apart from the image in my mind,

Quiver Trees by Night byFlorian Breuer

Alert is not defined in JSHint

Maybe you just started looking into jshint, or jsline for better JavaScript authoring, then when it comes to poorly debug or test something and you type alert(‘something’). This makes jshint unhappy, but can be useful sometimes, expecially if you have to debug something in old IE.

In jshit options the devel option allow you to use console.log and alerts without warnings. Personally I switch this setting only when really needed, to prevent annoying alerts or console logging in production.