Giter Club home page Giter Club logo

bootstrap-file-dialog's Introduction

Bootstrap & jQuery File Dialog

Dependencies

Uses only jQuery and Bootstrap. Tested on jQuery 1.9.0 and Bootstrap 3.2.0.

Install

Install via bower:

$ bower install --save bootstrap-file-dialog

Usage

Basic usage example can be found in example.html.

To create (and open) a file dialog, run

var fd = $.FileDialog(options);

Supported options:

  • accept: MIME type of accepted files, e. g. image/jpeg. String. Default: *.
  • dropheight: the height of drop zone in pixels. Number. Default: 400.
  • multiple: whether it is possible to choose multiple files or not. Boolean. Default: true. Choosing single file is not yet implemented, sorry.
  • readAs: file reading mode. String. Supported values: BinaryString, Text, DataURL, ArrayBuffer (case sensitive). Default: DataURL.

Auxiliary string options for internationalization:

  • title: the dialog title. Default: Load file(s).
  • ok_button: caption of the OK button. Default: OK.
  • cancel_button: caption of the Cancel button. Default: Close.
  • drag_message: the central text of drop zone. Default: Drop files here.
  • error_message: the message displayed on files that could not be loaded. Default: An error occured while loading file.
  • remove_message: popup hint to remove file button. Default: Remove file.

To handle files choice when done, bind an event handler:

fd.on('files.bs.filedialog', function(ev) {
    var files_list = ev.files;
    // ...
});

Every item in files_list is a File object, extended with property content containing loaded file contents:

$("img#my_img").attr('url', files_list[0].content);

To handle dialog cancelling, bind one more event handler:

fd.on('cancel.bs.filedialog', function(ev) {
    // ...
});

Contributing

# Clone repository
git clone [email protected]:Saluev/bootstrap-file-dialog.git
cd bootstrap-file-dialog

# Install required packages
npm install
bower install

# Install gulp globally
sudo npm install -g gulp

# Run server (using default task)
gulp

# Now, open your browser at 0.0.0.0:8000/example.html and start edit sources

License

This "software" is proudly "distributed" under the MIT License, see LICENSE.


© Tigran Saluev, 2014-2015

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.