<script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/angular-route.min.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/ui-bootstrap-tpls.min.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/hotkeys.min.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/angular-file-saver.bundle.min.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/angular-location-update.min.js"></script>
<!-- IDL / opensrf (network) -->
'bower_components/angular-bootstrap/ui-bootstrap.min.js',
'bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
'bower_components/angular-hotkeys/build/hotkeys.min.js',
+ 'bower_components/angular-file-saver/dist/angular-file-saver.bundle.min.js',
'bower_components/angular-location-update/angular-location-update.min.js',
'bower_components/jquery/dist/jquery.min.js',
]
},
"dependencies": {
"angular-hotkeys": "chieffancypants/angular-hotkeys#~1.3.0",
- "angular-location-update": "./extern/angular-location-update/"
+ "angular-location-update": "./extern/angular-location-update/",
+ "angular-file-saver": "~1.0.2"
}
}
* egCoreMod houses all of the services, etc. required by all pages
* for basic functionality.
*/
-angular.module('egCoreMod', ['cfp.hotkeys']);
+angular.module('egCoreMod', ['cfp.hotkeys', 'ngFileSaver']);
});
}
}
-}]);
+}])
+
+.directive('egJsonExporter', ['FileSaver', 'Blob', function(FileSaver, Blob) {
+ return {
+ scope: {
+ container: '=',
+ defaultFileName: '='
+ },
+ link: function (scope, element, attributes) {
+ element.bind('click', function (clickEvent) {
+ var data = new Blob([JSON.stringify(scope.container)], {type : 'application/json'});
+ FileSaver.saveAs(data, scope.defaultFileName);
+ });
+ }
+ }
+}])
+;