├── .gitignore ├── Gruntfile.js ├── Readme.md ├── bower.json ├── config └── eslint.json ├── dist ├── angular-downloader.min.js └── angular-downloader.sourcemap.map ├── package.json └── src └── js └── angular-downloader.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /*global module*/ 2 | (function setUp(module) { 3 | 'use strict'; 4 | 5 | var banner = ['/*!', 6 | ' * Angular Downloader v<%= pkg.version %>', 7 | ' *', 8 | ' * Released under the MIT license', 9 | ' * www.opensource.org/licenses/MIT', 10 | ' *', 11 | ' * <%= grunt.template.today("yyyy-mm-dd") %>', 12 | ' */\n\n'].join('\n'); 13 | 14 | module.exports = function doGrunt(grunt) { 15 | 16 | grunt.initConfig({ 17 | 'pkg': grunt.file.readJSON('package.json'), 18 | 'confs': { 19 | 'dist': 'dist', 20 | 'config': 'config', 21 | 'js': 'src/js', 22 | 'serverPort': 8000 23 | }, 24 | 'eslint': { 25 | 'options': { 26 | 'config': '<%= confs.config %>/eslint.json' 27 | }, 28 | 'target': [ 29 | 'Gruntfile.js', 30 | '<%= confs.js %>/**/*.js' 31 | ] 32 | }, 33 | 'uglify': { 34 | 'options': { 35 | 'sourceMap': true, 36 | 'sourceMapName': '<%= confs.dist %>/angular-downloader.sourcemap.map', 37 | 'preserveComments': false, 38 | 'report': 'gzip', 39 | 'banner': banner 40 | }, 41 | 'minifyTarget': { 42 | 'files': { 43 | '<%= confs.dist %>/angular-downloader.min.js': [ 44 | '<%= confs.js %>/angular-downloader.js' 45 | ] 46 | } 47 | } 48 | } 49 | }); 50 | 51 | grunt.loadNpmTasks('grunt-eslint'); 52 | grunt.loadNpmTasks('grunt-contrib-uglify'); 53 | 54 | grunt.registerTask('default', [ 55 | 'eslint' 56 | ]); 57 | 58 | grunt.registerTask('prod', [ 59 | 'eslint', 60 | 'uglify' 61 | ]); 62 | }; 63 | }(module)); 64 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | Angular Downloader 2 | ================== 3 | 4 | 5 | Angular Downloader is an angularjs directive that enables you to manage browser download. 6 | 7 | 8 | The angular downloader is developed by [720kb](http://720kb.net). 9 | 10 | ## Requirements 11 | 12 | AngularJS v1.2+ 13 | 14 | ### Example 15 | 16 | #### [Live demo](https://720kb.github.io/angular-downloader) 17 | 18 | ### Browser support 19 | 20 | Chrome | Firefox | IE | Opera | Safari 21 | --- | --- | --- | --- | --- | 22 | ✔ | ✔ | NO | ✔ | NO | 23 | 24 | ### Load 25 | 26 | To use the directive, include the javascript file of angular downloader in your web page: 27 | 28 | ```html 29 | 30 | 31 | 32 | //..... 33 | 34 | 35 | 36 | ``` 37 | 38 | ### Install 39 | 40 | #### Bower 41 | 42 | ``` 43 | $ bower install angular-downloader --save 44 | ``` 45 | _then load the js files in your html_ 46 | 47 | ### Add module dependency 48 | 49 | Add the ```720kb.downloader``` module dependency 50 | 51 | ```js 52 | angular.module('app', [ 53 | '720kb.downloader 54 | ]); 55 | ``` 56 | 57 | Call the directive wherever you want in your html page 58 | 59 | ```html 60 | 68 | ``` 69 | ## Options 70 | Angular downloader allows you to use some options via `attribute` datas. 71 | 72 | Passing values from the result of an XHR to the directive is done watching a variable in the scope. That name must be provided in the `downloader` attribute value. 73 | 74 | The style for the download button is provided by the `downloader-classes` attribute value, you concatenate as the class attribute the css classes to assign to download button. 75 | 76 | Custom text can be assigned to download button via the `downloader-custom-text` attribute value. 77 | 78 | If the button that invokes the XHR is needed again `downloader-reset` can be assigned to a boolean variable. 79 | 80 | 81 | ## Contributing 82 | 83 | We will be much grateful if you help us making this project to grow up. 84 | Feel free to contribute by forking, opening issues, pull requests etc. 85 | 86 | ## License 87 | 88 | The MIT License (MIT) 89 | 90 | Copyright (c) 2014 Dario Andrei, Filippo Oretti 91 | 92 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 93 | 94 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 95 | 96 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 97 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-downloader", 3 | "main": "dist/angular-downloader.min.js", 4 | "version": "0.1.3", 5 | "description": "A downloader directive for angularjs.", 6 | "authors": [ 7 | "Dario Andrei ", 8 | "Filippo Oretti