Giter Club home page Giter Club logo

loadpicker's Introduction

Filepicker.io on demand package for Meteor

Package to use Filepicker in Meteor, loads on demand, optional callback.

How to install

  1. Install Meteorite (if not already installed)

     npm install -g meteorite
    
  2. Add package

     mrt add loadpicker
    

A. How to use with upload button

  1. Set your Filepicker key on client JS

     var key = "your filepicker key";
    
  2. Call the script on demand from template.yourTemplate.created or template.yourTemplate.rendered

     loadPicker(key);
    
  3. Call Filepicker from template.yourTemplate.events with a click or submit event

     filepicker.pick();
    

Sample integration

if (Meteor.isClient) {
  Session.set("widgetSet", false);
  var key = "xxxxxxxxxxxxxxxxx";

  Template.home.rendered = function ( ) { 
    if (!Session.get("widgetSet")) {  
      loadPicker(key);
    }
  };

  Template.home.events({
    'click button' : function () {
      filepicker.pick();
    }
  });
}

B. How to use with drop widget or drop area

  1. Set your Filepicker key on client JS

     var key = "your filepicker key";
    
  2. Call the script on demand from template.yourTemplate.created or template.yourTemplate.rendered with callback

     loadPicker(key, callback);
    
  3. Call Filepicker from template.yourTemplate.events and include callback function to create widget or drop pane

     var cb = function () {
       filepicker.constructWidget(document.getElementById('constructed-widget'));
       filepicker.makeDropPane($('#exampleDropPane')[0], { });
     };
    
     loadPicker(key, cb);
    

Sample integration with widget or drop pane and callback

if (Meteor.isClient) {
  Session.set("widgetSet", false);
  var key = "insert key here";

Template.hello.rendered = function () {
    if (!Session.get("widgetSet")) {  
      var cb = function () {
        filepicker.constructWidget(document.getElementById('constructed-widget'));
        filepicker.makeDropPane($('#exampleDropPane')[0], { });
      };
      loadPicker(key, cb);
    }
  };

HTML (include the type tag for the widget!):

<h1>Widget</h1>
  <div id="constructed-widget" value="empty" type="filepicker-dragdrop" style="display: none;">
  </div>
<h1>Drop Pane</h1>
  <div id="exampleDropPane">Drop Here!</div>
  <div><pre id="localDropResult"></pre></div>

CSS for drop pane

#exampleDropPane {
  text-align: center;
  padding: 20px;
  background-color: #F6F6F6;
  border: 1px dashed #666;
  border-radius: 6px;
  margin-bottom: 20px;
}

loadpicker's People

Contributors

guido4000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

rcy gist- wulx

loadpicker's Issues

Update version number...

Even though the package is adjusted for Meteor 0.6.5, this update doesn't show up in Atmosphere/Meteorite. Most likely, you just need to update the version number?

Doesn't work with 0.6.5

Hi, I think you need to do api.export loadPicker in order to use it in the new Meteor 0.6.5 package system.

Documentation... Template.smth.rendered ---> created

It shows in the example to call the func when it is renderd, but when i click the button nothing appears.


  Template.home.rendered = function ( ) { 
    if (!Session.get("widgetSet")) {  
      loadPicker(key);
    }
  };

so ...


  Template.home.created = function ( ) { 
    if (!Session.get("widgetSet")) {  
      loadPicker(key);
    }
  };

did the job :)

Filepicker modal only displayed after initial page load

Hi!

So I just found a bug.
When I call filepicker.pick() for the first time in a template everything works fine. Also closing the modal and clicking the button again works fine (modal is displayed again). When I click on a link inside my meteor app to get to another page (of course via html5 pushstate like on every meteor page, no standard a links with a real page refresh) and then go back to the page with the filepicker stuff in it, the button does not do anything anymore. The filepicker modal or anything is NOT displayed.

I hope you understand the bug. Any ideas? :)

best regards
Patrick

real key in your README

Hi,

In the second example: "Sample integration with widget or drop pane and callback", it looks like you have a real filepicker key. The first sample integration uses "xxxxxxxxxxxxxxxxx". Just thought you may want to change it if it's one you own.

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.