Coder Social home page Coder Social logo

ng-filedialog's Introduction

ng-fileDialog

angular file dialog for nw

What is it

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

Dependencies

  1. AngularJS
  2. nw

Usage

  1. Include the script into your HTML document after the AngularJS.
<script src="path/to/the/angular.js"></script>
<script src="path/to/the/ng-fileDialog.js"></script>
<script src="path/to/the/your-app-code.js"></script>
  1. Inject ng-fileDialog as dependency into your module.
var app = angular.module('app', ['ng-fileDialog']);
  1. Use the provided fileDialog service
app.controller('SomeCtrl', function($scope, FileDialog) {
    $scope.saveFile = function() {
      FileDialog.saveAs(function(filename) {
        // your code
      });
    };
});

API

fileDialog.selectFile(callback, acceptTypes)

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(files).

acceptTypes - string/array - an array of accepted file types. See HTML5 specification.

fileDialog.selectFiles(callback, acceptTypes)

Opens the "open files" 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(files).

acceptTypes - string/array - an array of accepted file types. See HTML5 specification.

fileDialog.selectDir(callback)

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(file).

fileDialog.saveAs(callback, defaultFilename, acceptTypes)

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(file).

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.

fileDialog.open(options, callback)

Opens dialog.

options - Object - options.

multiple - *boolean * - a flag which the user to select multiple files. Default = false.

accept - string/array - an array of accepted file types.

webkitdirectory - boolean - WebKit show a directory select dialog. Default = false.

nwdirectory - boolean - node-webkit show a directory select dialog. Default = false.

nwworkingdir - string - default directory.

nwsaveas - boolean/string - open a 'save as' dialog, which lets user enter the path of a file. It's possible to select a non-existing file.

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(file).

Important note

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!

ng-filedialog's People

Contributors

marcopesani avatar ymyang avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.