This is a simple module for node-webkit applications written with AngularJS. It provides a service
called fileDialog
which allows you to show the user file dialogs like "save as" or "open file".
You can find more information in the
File dialogs
section of node-webkit's wiki.
This module allows you to
- Call "Save as" dialog
- Call "Open file" dialog
- Call "Open directory" dialog
- Provide filters by file types
- Allow user to select multiple files
- Specify a default name for the file
- Include the script into your HTML document after the AngularJS.
<script src="path/to/the/angular.js"></script>
<script src="path/to/the/nw-fileDialog.js"></script>
<script src="path/to/the/your-app-code.js"></script>
- Inject
nw-fileDialog
as dependency into your module.
var app = angular.module('app', ['DWand.nw-fileDialog']);
- Use the provided
fileDialog
service
app.controller('SomeCtrl', ['$scope', 'fileDialog', function($scope, fileDialog) {
$scope.saveFile = function() {
fileDialog.saveAs(function(filename) {
// your code
});
};
}]);
Opens the "save as" dialog, which allows the user to input a name of the file to be saved.
callback - function - function, which will be called if the user enters a name of the file to
save and clicks OK button. Required interface: function(filename)
.
defaultFilename - string - a default name of the file. Can be omitted by setting false.
acceptTypes - string/array - an array of accepted file types. See HTML5 specification.
Opens the "open file" dialog, which allows the user to choose some file.
callback - function - function, which will be called if the user choose the file and clicks OK
button. Required interface: function(filename)
.
multiple - boolean - a flag which the user to select multiple files. Default = false.
acceptTypes - string/array - an array of accepted file types. See HTML5 specification.
Opens the "open directory" dialog, which allows the user to choose some directory.
callback - function - function, which will be called if the user choose the directory and
clicks OK button. Required interface: function(dirname)
.
Please, keep in mind that there is no warranty that the callback function will be called each time you call any of the provided methods. If the user clicks the Cancel button the callback will not be called!
Copyright © 2013 Max Prichinenko dwand.dev@gmail.com
This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details.