I had to implement a copy to clipboard functionality for our Control Panel which lists Orders.

Since I’m a total enemy of flash I pursued a solution suitable for my needs and here it is.

This is based on http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript but I removed most of the styling and simply put the textarea outside of the viewport.

 

>> The Code!!

First create the helper function in your controller (this can be move to a helper service as well if you wan’t)

 

And now simply bind it to your Element like this

This solution currently supports the following browsers.

Desktop:

  • IE 9+
  • Firefox 41+ (below that you have to enable copy in the user.js but since it’s enabled by default in the next Stable I don’t really care)
  • Chrome 42+
  • Opera 29+
  • Safari has no support for this sadly 🙁

Mobile:

  • Chrome for Android 42+
  • Firefox Mobile 41+

I’m quite happy with this and maybe someone will find this useful.

 

Well it has been a long while again, but I’ve been crazy busy at work.

I worked on a couple of interesting Single Page Applications written with Angular and I really like it because the Framework is so simple to use and very well documented with a crapload of nice plugins and extensions from the community. Anyhow I needed to implement some sort of internationalization and angular has a nifty extension called angular-translate which I used for that. In the process we created an i18n self hosted service in c# with nancy with a simple rest api where I can get a list of available languages for specific domains. Domains in this context are just language sections so that I only have to request and transfer the sections actually in use. The angular plugin has a nice way of supporting it with „partials“

so include the partials-loader and url-loader for angular-translate and set it up the following way:

 

This sets up the angular-translate plugin to work with partials which are loaded on demand from an rest service.

Since we are lazy we wanted to have some sort of automatically adding missing translations to the system.

The registered function in useMissingTranslationHandler handles this for us.

The handler is implemented as a angular factory and sends missing translations to a Model which hols a queue to bulk insert the translations to the i18n service.

This is done since we would exceed the allowed number of ajax connections on large applications at the first startup

I’m quite happy with this solution even though I think it has some room for Improvement.