├── .bowerrc ├── .editorconfig ├── .ember-cli ├── .gitignore ├── .jshintrc ├── .npmignore ├── .travis.yml ├── .watchmanconfig ├── LICENSE.md ├── README.md ├── addon ├── .gitkeep └── mixins │ └── ember-filepicker.js ├── app ├── .gitkeep ├── components │ └── ember-filepicker.js └── services │ └── filepicker.js ├── bower.json ├── config ├── ember-try.js └── environment.js ├── ember-cli-build.js ├── index.js ├── package.json ├── testem.js ├── testem.json ├── tests ├── .jshintrc ├── dummy │ ├── app │ │ ├── app.js │ │ ├── components │ │ │ └── .gitkeep │ │ ├── controllers │ │ │ ├── .gitkeep │ │ │ └── application.js │ │ ├── helpers │ │ │ └── .gitkeep │ │ ├── index.html │ │ ├── models │ │ │ └── .gitkeep │ │ ├── resolver.js │ │ ├── router.js │ │ ├── routes │ │ │ └── .gitkeep │ │ ├── styles │ │ │ └── app.css │ │ ├── templates │ │ │ └── application.hbs │ │ └── views │ │ │ └── .gitkeep │ ├── config │ │ └── environment.js │ └── public │ │ ├── crossdomain.xml │ │ └── robots.txt ├── helpers │ ├── destroy-app.js │ ├── module-for-acceptance.js │ ├── resolver.js │ └── start-app.js ├── index.html ├── test-helper.js └── unit │ ├── .gitkeep │ ├── components │ └── ember-filepicker-test.js │ └── services │ └── filepicker-test.js └── vendor └── .gitkeep /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower_components", 3 | "analytics": false 4 | } 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.js] 17 | indent_style = space 18 | indent_size = 2 19 | 20 | [*.hbs] 21 | insert_final_newline = false 22 | indent_style = space 23 | indent_size = 2 24 | 25 | [*.css] 26 | indent_style = space 27 | indent_size = 2 28 | 29 | [*.html] 30 | indent_style = space 31 | indent_size = 2 32 | 33 | [*.{diff,md}] 34 | trim_trailing_whitespace = false 35 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": false 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | 7 | # dependencies 8 | /node_modules 9 | /bower_components 10 | 11 | # misc 12 | /.sass-cache 13 | /connect.lock 14 | /coverage/* 15 | /libpeerconnection.log 16 | npm-debug.log 17 | testem.log 18 | 19 | #idea 20 | /.idea -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "-Promise" 6 | ], 7 | "browser": true, 8 | "boss": true, 9 | "curly": true, 10 | "debug": false, 11 | "devel": true, 12 | "eqeqeq": true, 13 | "evil": true, 14 | "forin": false, 15 | "immed": false, 16 | "laxbreak": false, 17 | "newcap": true, 18 | "noarg": true, 19 | "noempty": false, 20 | "nonew": false, 21 | "nomen": false, 22 | "onevar": false, 23 | "plusplus": false, 24 | "regexp": false, 25 | "undef": true, 26 | "sub": true, 27 | "strict": false, 28 | "white": false, 29 | "eqnull": true, 30 | "esnext": true, 31 | "unused": true 32 | } 33 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /bower_components 2 | /config/ember-try.js 3 | /dist 4 | /tests 5 | /tmp 6 | **/.gitkeep 7 | .bowerrc 8 | .editorconfig 9 | .ember-cli 10 | .gitignore 11 | .jshintrc 12 | .watchmanconfig 13 | ember-cli-build.js 14 | testem.js 15 | .travis.yml 16 | .npmignore 17 | bower.json 18 | Brocfile.js 19 | testem.json 20 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: node_js 3 | node_js: 4 | - "4" 5 | 6 | sudo: false 7 | 8 | cache: 9 | directories: 10 | - node_modules 11 | 12 | env: 13 | - EMBER_TRY_SCENARIO=default 14 | - EMBER_TRY_SCENARIO=ember-1.13 15 | - EMBER_TRY_SCENARIO=ember-release 16 | - EMBER_TRY_SCENARIO=ember-beta 17 | - EMBER_TRY_SCENARIO=ember-canary 18 | 19 | matrix: 20 | fast_finish: true 21 | allow_failures: 22 | - env: EMBER_TRY_SCENARIO=ember-canary 23 | 24 | before_install: 25 | - npm config set spin false 26 | - npm install -g bower 27 | - npm install phantomjs-prebuilt 28 | 29 | install: 30 | - npm install 31 | - bower install 32 | 33 | script: 34 | # Usually, it's ok to finish the test scenario without reverting 35 | # to the addon's original dependency state, skipping "cleanup". 36 | - ember try $EMBER_TRY_SCENARIO test --skip-cleanup 37 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ember-cli-filepicker 2 | 3 | [![npm version](https://badge.fury.io/js/ember-cli-filepicker.svg)](http://badge.fury.io/js/ember-cli-filepicker) 4 | [![Build Status](https://travis-ci.org/DudaDev/ember-cli-filepicker.svg)](https://travis-ci.org/DudaDev/ember-cli-filepicker) 5 | [![Ember Observer Score](http://emberobserver.com/badges/ember-cli-filepicker.svg)](http://emberobserver.com/addons/ember-cli-filepicker) 6 | 7 | ## Installation 8 | 9 | * `ember install ember-cli-filepicker` 10 | 11 | ## Usage 12 | * Create your filepicker.io key using the following URL: https://www.filepicker.io/. 13 | * Add your filepicker.io key in your config/environment.js 14 | ```javascript 15 | //config/environment.js 16 | module.exports = function(environment) { 17 | var ENV = { 18 | //... 19 | filepickerKey: '' 20 | }; 21 | //... 22 | } 23 | ``` 24 | * Use the filepicker.io documentation for options like extensions and services. 25 | * In your template: 26 | ```handlebars 27 | {{ember-filepicker pickerOptions=pickerOptions onSelection='fileSelected' onClose='onClose' onError='onError'}} 28 | ``` 29 | * The above will use the pick method. 30 | * You should pass pickerOptions with the pick options (mimetype, services, etc). 31 | 32 | * If you want to use [pickAndStore](https://www.filepicker.com/documentation/file_ingestion/javascript_api/pick_and_store?v=v2), also pass storeOptions (location, etc): 33 | ```handlebars 34 | {{ember-filepicker pickerOptions=pickerOptions storeOptions=storeOptions onSelection='fileSelected' onClose='onClose' onError='onError'}} 35 | ``` 36 | * If you want to use [pickMultiple](https://www.filepicker.com/documentation/file_ingestion/javascript_api/pick_multiple?v=v2) files (without storing them), pass multiple=true : 37 | ```handlebars 38 | {{ember-filepicker pickerOptions=pickerOptions multiple=true onSelection='fileSelected' onClose='onClose' onError='onError'}} 39 | ``` 40 | 41 | 42 | ## Notes 43 | In order to have access to the `filepicker` instance you can: 44 | * If `Ember.inject.service` is supported then in your object you can use: 45 | ```javascript 46 | export default Ember.Component.extend({ 47 | //injecting the filepicker object 48 | filepicker: Ember.inject.service(), 49 | 50 | someFunction: function(){ 51 | //Use the promise in case you are not sure that your component will be surly initialized after filepicker has been loaded 52 | this.get('filepicker.promise').then(function(filepicker){ 53 | //do something with filepicker 54 | }); 55 | 56 | //OR if you are sure filepicker has already been loaded use: 57 | this.get('filepicker.instance') 58 | } 59 | }); 60 | ``` 61 | * Otherwise, you can use the lookup method: 62 | ```javascript 63 | export default Ember.Component.extend({ 64 | //injecting the filepicker object 65 | filepicker: Ember.inject.service(), 66 | 67 | someFunction: function(){ 68 | var filepicker = this.container.lookup('service:filepicker'); 69 | //do something with the filepicker.instance or filepicker.promise 70 | } 71 | }); 72 | ``` 73 | 74 | ## Running 75 | 76 | * `ember server` 77 | * Visit your app at http://localhost:4200. 78 | 79 | ## Running Tests 80 | 81 | * `npm test` (Runs `ember try:testall` to test your addon against multiple Ember versions) 82 | * `ember test` 83 | * `ember test --server` 84 | 85 | ## Building 86 | 87 | * `ember build` 88 | 89 | For more information on using ember-cli, visit [http://ember-cli.com/](http://ember-cli.com/). 90 | -------------------------------------------------------------------------------- /addon/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DudaDev/ember-cli-filepicker/03120962fb9250f2ec50be896ea921c658641455/addon/.gitkeep -------------------------------------------------------------------------------- /addon/mixins/ember-filepicker.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | var isServiceInjectionSupported = Ember.inject && Ember.inject.service; 4 | 5 | var PICK_METHOD_NAME = 'pick', 6 | PICK_MULTIPLE_METHOD_NAME = 'pickMultiple', 7 | PICK_AND_STORE_METHOD_NAME = 'pickAndStore'; 8 | 9 | export default Ember.Mixin.create({ 10 | injectFilepickerService: Ember.on('init', function() { 11 | if (!isServiceInjectionSupported) { 12 | this.set('filepicker', this.container.lookup('service:filepicker')); 13 | } 14 | }), 15 | 16 | handleSelection: function(data) { 17 | if (this.get('onSelection')) { 18 | this.sendAction('onSelection', data); 19 | } 20 | }, 21 | handleError: function(data) { 22 | if (data.code === 101 && this.get('onClose')) { 23 | this.sendAction('onClose'); 24 | } else if (this.get('onError')) { 25 | this.sendAction('onError', data); 26 | } 27 | }, 28 | onSelection: null, 29 | onError: null, 30 | onClose: null, 31 | options: null, 32 | pickerOptions: {}, 33 | storeOptions: null, 34 | multiple: false, 35 | filepicker: Ember.inject ? Ember.inject.service() : null, 36 | openFilepicker: Ember.on('didInsertElement', function() { 37 | Ember.run.scheduleOnce('afterRender', this, function() { 38 | this.get('filepicker.promise').then(Ember.run.bind(this, function(filepicker) { 39 | var pickerOptions, storeOptions, 40 | options = this.get('options'), 41 | usePickAndStore, 42 | filepickerMethod, 43 | args = []; 44 | 45 | if (options) { 46 | 47 | pickerOptions = options.picker; 48 | storeOptions = options.store; 49 | usePickAndStore = (pickerOptions && options.useStore); 50 | Ember.deprecate("'options' was passed instead of 'pickerOptions' and possibly 'storeOptions'. The options parameter has been split into these parameters."); 51 | 52 | } else { 53 | 54 | pickerOptions = this.get('pickerOptions'); 55 | storeOptions = this.get('storeOptions'); 56 | usePickAndStore = (pickerOptions && storeOptions); 57 | 58 | } 59 | 60 | if (usePickAndStore) { 61 | 62 | if (this.get('multiple') && (pickerOptions && !pickerOptions.multiple)) { 63 | pickerOptions = Ember.merge({ 64 | multiple: true 65 | }, pickerOptions); 66 | } 67 | filepickerMethod = PICK_AND_STORE_METHOD_NAME; 68 | args.push(pickerOptions); 69 | args.push(storeOptions); 70 | 71 | } else { 72 | args.push(pickerOptions); 73 | } 74 | 75 | args.push(Ember.run.bind(this, this.handleSelection)); 76 | args.push(Ember.run.bind(this, this.handleError)); 77 | 78 | if (!filepickerMethod) { 79 | if (this.get('multiple')) { 80 | filepickerMethod = PICK_MULTIPLE_METHOD_NAME; 81 | } else { 82 | filepickerMethod = PICK_METHOD_NAME; 83 | } 84 | } 85 | 86 | filepicker[filepickerMethod].apply(filepicker, args); 87 | })); 88 | }); 89 | }) 90 | 91 | }); 92 | -------------------------------------------------------------------------------- /app/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DudaDev/ember-cli-filepicker/03120962fb9250f2ec50be896ea921c658641455/app/.gitkeep -------------------------------------------------------------------------------- /app/components/ember-filepicker.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import EmberFilepickerMixin from 'ember-cli-filepicker/mixins/ember-filepicker'; 3 | export default Ember.Component.extend(EmberFilepickerMixin); -------------------------------------------------------------------------------- /app/services/filepicker.js: -------------------------------------------------------------------------------- 1 | import config from '../config/environment'; 2 | import injectScript from 'ember-inject-script'; 3 | import Ember from 'ember'; 4 | 5 | 6 | export default (Ember.Service || Ember.Object).extend({ 7 | 8 | _isPromiseFulfilled: false, 9 | _initFilepicker: Ember.on('init', function() { 10 | var _resolveFn, _rejectFn, 11 | _isPromiseFulfilled = false; 12 | 13 | this.set('promise', new Ember.RSVP.Promise(function(resolve, reject) { 14 | _resolveFn = resolve; 15 | _rejectFn = reject; 16 | })); 17 | 18 | injectScript(this.get('scriptURL')) 19 | .then(Ember.run.bind(this, function() { 20 | var filepicker = window.filepicker; 21 | if (filepicker && filepicker.pick) { 22 | filepicker.setKey(this.get('key')); 23 | if (!(this.isDestroyed || this.isDestroying)) { 24 | this.set('instance', filepicker); 25 | } 26 | _resolveFn.call(null, filepicker); 27 | _isPromiseFulfilled = true; 28 | } else { 29 | _rejectFn.call(null, new Error("Could not load filepicker. Please check 'scriptURL' directs to filepicker script.")); 30 | } 31 | 32 | })) 33 | .catch(Ember.run.bind(this, function(error) { 34 | _rejectFn.call(null, error); 35 | })); 36 | 37 | Ember.run.later(this, function(){ 38 | if (!_isPromiseFulfilled){ 39 | _rejectFn.call(null, new Error('Filepicker script load timeout.')); 40 | } 41 | }, this.get('scriptLoadTimeout')); 42 | 43 | }), 44 | key: config.filepickerKey || config.APP.filepickerKey, 45 | scriptURL : config.filepickerURL || config.APP.filepickerURL || '//api.filepicker.io/v2/filepicker.js', 46 | scriptLoadTimeout: config.filepickerScriptLoadTimeout || config.APP.filepickerScriptLoadTimeout || 10000, 47 | promise: null, 48 | instance: null 49 | }); 50 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-cli-filepicker", 3 | "dependencies": { 4 | "ember": "~2.6.0", 5 | "ember-cli-shims": "0.1.1", 6 | "ember-cli-test-loader": "0.2.2", 7 | "ember-qunit-notifications": "0.1.0" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | module.exports = { 3 | scenarios: [ 4 | { 5 | name: 'default', 6 | bower: { 7 | dependencies: { } 8 | } 9 | }, 10 | { 11 | name: 'ember-1.13', 12 | bower: { 13 | dependencies: { 14 | 'ember': '~1.13.0' 15 | }, 16 | resolutions: { 17 | 'ember': '~1.13.0' 18 | } 19 | } 20 | }, 21 | { 22 | name: 'ember-release', 23 | bower: { 24 | dependencies: { 25 | 'ember': 'components/ember#release' 26 | }, 27 | resolutions: { 28 | 'ember': 'release' 29 | } 30 | } 31 | }, 32 | { 33 | name: 'ember-beta', 34 | bower: { 35 | dependencies: { 36 | 'ember': 'components/ember#beta' 37 | }, 38 | resolutions: { 39 | 'ember': 'beta' 40 | } 41 | } 42 | }, 43 | { 44 | name: 'ember-canary', 45 | bower: { 46 | dependencies: { 47 | 'ember': 'components/ember#canary' 48 | }, 49 | resolutions: { 50 | 'ember': 'canary' 51 | } 52 | } 53 | } 54 | ] 55 | }; 56 | -------------------------------------------------------------------------------- /config/environment.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | 'use strict'; 3 | 4 | module.exports = function(/* environment, appConfig */) { 5 | return { }; 6 | }; 7 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | /* global require, module */ 3 | var EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); 4 | 5 | module.exports = function(defaults) { 6 | var app = new EmberAddon(defaults, { 7 | // Add options here 8 | }); 9 | 10 | /* 11 | This build file specifies the options for the dummy test app of this 12 | addon, located in `/tests/dummy` 13 | This build file does *not* influence how the addon or the app using it 14 | behave. You most likely want to be modifying `./index.js` or app's build file 15 | */ 16 | 17 | return app.toTree(); 18 | }; 19 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 'use strict'; 3 | 4 | module.exports = { 5 | name: 'ember-cli-filepicker' 6 | }; 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ember-cli-filepicker", 3 | "version": "0.1.96", 4 | "description": "Ember cli file picker using filepicker.io", 5 | "directories": { 6 | "doc": "doc", 7 | "test": "tests" 8 | }, 9 | "scripts": { 10 | "build": "ember build", 11 | "start": "ember server", 12 | "test": "ember try:each" 13 | }, 14 | "repository": "https://github.com/DudaDev/ember-cli-filepicker.git", 15 | "engines": { 16 | "node": ">= 0.10.0" 17 | }, 18 | "author": "", 19 | "license": "MIT", 20 | "devDependencies": { 21 | "broccoli-asset-rev": "^2.4.2", 22 | "ember-ajax": "^2.0.1", 23 | "ember-cli": "2.6.2", 24 | "ember-cli-app-version": "^1.0.0", 25 | "ember-cli-dependency-checker": "^1.2.0", 26 | "ember-cli-htmlbars": "^1.0.3", 27 | "ember-cli-htmlbars-inline-precompile": "^0.3.1", 28 | "ember-cli-inject-live-reload": "^1.4.0", 29 | "ember-cli-jshint": "^1.0.0", 30 | "ember-cli-qunit": "^1.4.0", 31 | "ember-cli-release": "^0.2.9", 32 | "ember-cli-sri": "^2.1.0", 33 | "ember-cli-uglify": "^1.2.0", 34 | "ember-data": "^2.6.0", 35 | "ember-disable-prototype-extensions": "^1.1.0", 36 | "ember-export-application-global": "^1.0.5", 37 | "ember-load-initializers": "^0.5.1", 38 | "ember-resolver": "^2.0.3", 39 | "ember-welcome-page": "^1.0.1", 40 | "loader.js": "^4.0.1" 41 | }, 42 | "keywords": [ 43 | "ember-addon", 44 | "filepicker.io", 45 | "filepicker" 46 | ], 47 | "ember-addon": { 48 | "configPath": "tests/dummy/config" 49 | }, 50 | "dependencies": { 51 | "ember-cli-babel": "^5.1.6", 52 | "ember-inject-script": "0.0.2" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /testem.js: -------------------------------------------------------------------------------- 1 | /*jshint node:true*/ 2 | module.exports = { 3 | "framework": "qunit", 4 | "test_page": "tests/index.html?hidepassed", 5 | "disable_watching": true, 6 | "launch_in_ci": [ 7 | "PhantomJS" 8 | ], 9 | "launch_in_dev": [ 10 | "PhantomJS", 11 | "Chrome" 12 | ] 13 | }; 14 | -------------------------------------------------------------------------------- /testem.json: -------------------------------------------------------------------------------- 1 | { 2 | "framework": "qunit", 3 | "test_page": "tests/index.html?hidepassed", 4 | "launch_in_ci": [ 5 | "PhantomJS" 6 | ], 7 | "launch_in_dev": [ 8 | "PhantomJS", 9 | "Chrome" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /tests/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "predef": [ 3 | "document", 4 | "window", 5 | "location", 6 | "setTimeout", 7 | "$", 8 | "-Promise", 9 | "define", 10 | "console", 11 | "visit", 12 | "exists", 13 | "fillIn", 14 | "click", 15 | "keyEvent", 16 | "triggerEvent", 17 | "find", 18 | "findWithAssert", 19 | "wait", 20 | "DS", 21 | "andThen", 22 | "currentURL", 23 | "currentPath", 24 | "currentRouteName" 25 | ], 26 | "node": false, 27 | "browser": false, 28 | "boss": true, 29 | "curly": true, 30 | "debug": false, 31 | "devel": false, 32 | "eqeqeq": true, 33 | "evil": true, 34 | "forin": false, 35 | "immed": false, 36 | "laxbreak": false, 37 | "newcap": true, 38 | "noarg": true, 39 | "noempty": false, 40 | "nonew": false, 41 | "nomen": false, 42 | "onevar": false, 43 | "plusplus": false, 44 | "regexp": false, 45 | "undef": true, 46 | "sub": true, 47 | "strict": false, 48 | "white": false, 49 | "eqnull": true, 50 | "esnext": true, 51 | "unused": true 52 | } 53 | -------------------------------------------------------------------------------- /tests/dummy/app/app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import Resolver from './resolver'; 3 | import loadInitializers from 'ember-load-initializers'; 4 | import config from './config/environment'; 5 | 6 | let App; 7 | 8 | Ember.MODEL_FACTORY_INJECTIONS = true; 9 | 10 | App = Ember.Application.extend({ 11 | modulePrefix: config.modulePrefix, 12 | podModulePrefix: config.podModulePrefix, 13 | Resolver 14 | }); 15 | 16 | loadInitializers(App, config.modulePrefix); 17 | 18 | export default App; 19 | -------------------------------------------------------------------------------- /tests/dummy/app/components/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DudaDev/ember-cli-filepicker/03120962fb9250f2ec50be896ea921c658641455/tests/dummy/app/components/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DudaDev/ember-cli-filepicker/03120962fb9250f2ec50be896ea921c658641455/tests/dummy/app/controllers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/controllers/application.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default Ember.ObjectController.extend({ 4 | 5 | showFilePicker: false, 6 | 7 | actions : { 8 | showPicker: function() { 9 | this.set('showFilePicker', true); 10 | }, 11 | hidePicker: function() { 12 | this.set('showFilePicker', false); 13 | }, 14 | fileSelected: function(data) { 15 | this.send('hidePicker', data); 16 | }, 17 | onClose: function() { 18 | this.send('hidePicker'); 19 | }, 20 | onError: function(error) { 21 | this.send('hidePicker', error); 22 | } 23 | } 24 | 25 | }); -------------------------------------------------------------------------------- /tests/dummy/app/helpers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DudaDev/ember-cli-filepicker/03120962fb9250f2ec50be896ea921c658641455/tests/dummy/app/helpers/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | 12 | 13 | 14 | 15 | {{content-for "head-footer"}} 16 | 17 | 18 | {{content-for "body"}} 19 | 20 | 21 | 22 | 23 | {{content-for "body-footer"}} 24 | 25 | 26 | -------------------------------------------------------------------------------- /tests/dummy/app/models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DudaDev/ember-cli-filepicker/03120962fb9250f2ec50be896ea921c658641455/tests/dummy/app/models/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from 'ember-resolver'; 2 | 3 | export default Resolver; 4 | -------------------------------------------------------------------------------- /tests/dummy/app/router.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import config from './config/environment'; 3 | 4 | const Router = Ember.Router.extend({ 5 | location: config.locationType 6 | }); 7 | 8 | Router.map(function() { 9 | }); 10 | 11 | export default Router; 12 | -------------------------------------------------------------------------------- /tests/dummy/app/routes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DudaDev/ember-cli-filepicker/03120962fb9250f2ec50be896ea921c658641455/tests/dummy/app/routes/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/app/styles/app.css: -------------------------------------------------------------------------------- 1 | .ember-test-body #filepicker_dialog, .ember-test-body #filepicker_shade { 2 | display: none; 3 | } -------------------------------------------------------------------------------- /tests/dummy/app/templates/application.hbs: -------------------------------------------------------------------------------- 1 |

Ember cli filepicker Demo

2 | 3 | {{#if showFilePicker}} 4 | {{ember-filepicker onSelection='fileSelected' onClose='onClose' onError='onError'}} 5 | {{/if}} 6 | 7 | {{outlet}} 8 | -------------------------------------------------------------------------------- /tests/dummy/app/views/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DudaDev/ember-cli-filepicker/03120962fb9250f2ec50be896ea921c658641455/tests/dummy/app/views/.gitkeep -------------------------------------------------------------------------------- /tests/dummy/config/environment.js: -------------------------------------------------------------------------------- 1 | /* jshint node: true */ 2 | 3 | module.exports = function(environment) { 4 | var ENV = { 5 | modulePrefix: 'dummy', 6 | environment: environment, 7 | baseURL: '/', 8 | locationType: 'auto', 9 | EmberENV: { 10 | FEATURES: { 11 | // Here you can enable experimental features on an ember canary build 12 | // e.g. 'with-controller': true 13 | } 14 | }, 15 | filepickerKey: 'Afrmw9gPxQauAjV7GFKOYz', 16 | APP: { 17 | 18 | } 19 | }; 20 | 21 | if (environment === 'development') { 22 | // ENV.APP.LOG_RESOLVER = true; 23 | // ENV.APP.LOG_ACTIVE_GENERATION = true; 24 | // ENV.APP.LOG_TRANSITIONS = true; 25 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; 26 | // ENV.APP.LOG_VIEW_LOOKUPS = true; 27 | } 28 | 29 | if (environment === 'test') { 30 | // Testem prefers this... 31 | ENV.baseURL = '/'; 32 | ENV.locationType = 'none'; 33 | 34 | // keep test console output quieter 35 | ENV.APP.LOG_ACTIVE_GENERATION = false; 36 | ENV.APP.LOG_VIEW_LOOKUPS = false; 37 | 38 | ENV.APP.rootElement = '#ember-testing'; 39 | } 40 | 41 | if (environment === 'production') { 42 | 43 | } 44 | 45 | return ENV; 46 | }; 47 | -------------------------------------------------------------------------------- /tests/dummy/public/crossdomain.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | -------------------------------------------------------------------------------- /tests/dummy/public/robots.txt: -------------------------------------------------------------------------------- 1 | # http://www.robotstxt.org 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /tests/helpers/destroy-app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | export default function destroyApp(application) { 4 | Ember.run(application, 'destroy'); 5 | } 6 | -------------------------------------------------------------------------------- /tests/helpers/module-for-acceptance.js: -------------------------------------------------------------------------------- 1 | import { module } from 'qunit'; 2 | import Ember from 'ember'; 3 | import startApp from '../helpers/start-app'; 4 | import destroyApp from '../helpers/destroy-app'; 5 | 6 | const { RSVP: { Promise } } = Ember; 7 | 8 | export default function(name, options = {}) { 9 | module(name, { 10 | beforeEach() { 11 | this.application = startApp(); 12 | 13 | if (options.beforeEach) { 14 | return options.beforeEach.apply(this, arguments); 15 | } 16 | }, 17 | 18 | afterEach() { 19 | let afterEach = options.afterEach && options.afterEach.apply(this, arguments); 20 | return Promise.resolve(afterEach).then(() => destroyApp(this.application)); 21 | } 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /tests/helpers/resolver.js: -------------------------------------------------------------------------------- 1 | import Resolver from '../../resolver'; 2 | import config from '../../config/environment'; 3 | 4 | const resolver = Resolver.create(); 5 | 6 | resolver.namespace = { 7 | modulePrefix: config.modulePrefix, 8 | podModulePrefix: config.podModulePrefix 9 | }; 10 | 11 | export default resolver; 12 | -------------------------------------------------------------------------------- /tests/helpers/start-app.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | import Application from '../../app'; 3 | import config from '../../config/environment'; 4 | 5 | export default function startApp(attrs) { 6 | let application; 7 | 8 | let attributes = Ember.merge({}, config.APP); 9 | attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; 10 | 11 | Ember.run(() => { 12 | application = Application.create(attributes); 13 | application.setupForTesting(); 14 | application.injectTestHelpers(); 15 | }); 16 | 17 | return application; 18 | } 19 | -------------------------------------------------------------------------------- /tests/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Dummy Tests 7 | 8 | 9 | 10 | {{content-for "head"}} 11 | {{content-for "test-head"}} 12 | 13 | 14 | 15 | 16 | 17 | {{content-for "head-footer"}} 18 | {{content-for "test-head-footer"}} 19 | 20 | 21 | {{content-for "body"}} 22 | {{content-for "test-body"}} 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | {{content-for "body-footer"}} 32 | {{content-for "test-body-footer"}} 33 | 34 | 35 | -------------------------------------------------------------------------------- /tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import resolver from './helpers/resolver'; 2 | import { 3 | setResolver 4 | } from 'ember-qunit'; 5 | 6 | setResolver(resolver); 7 | -------------------------------------------------------------------------------- /tests/unit/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DudaDev/ember-cli-filepicker/03120962fb9250f2ec50be896ea921c658641455/tests/unit/.gitkeep -------------------------------------------------------------------------------- /tests/unit/components/ember-filepicker-test.js: -------------------------------------------------------------------------------- 1 | import { 2 | moduleForComponent, 3 | test 4 | } 5 | from 'ember-qunit'; 6 | import Ember from 'ember'; 7 | 8 | moduleForComponent('ember-filepicker', { 9 | // specify the other units that are required for this test 10 | needs: ['service:filepicker'] 11 | }); 12 | 13 | test('it renders', function(assert) { 14 | assert.expect(2); 15 | 16 | // creates the component instance 17 | var component = this.subject(); 18 | assert.equal(component._state, 'preRender'); 19 | 20 | // renders the component to the page 21 | this.render(); 22 | assert.equal(component._state, 'inDOM'); 23 | }); 24 | 25 | test('it opens filepicker on component element insertion', function(assert) { 26 | return new Ember.RSVP.Promise(function(resolve, reject){ 27 | var subscriber, 28 | interval = 100, 29 | counter = -1 * interval, 30 | timeout = 10000; 31 | 32 | subscriber = window.setInterval(function(){ 33 | counter += interval; 34 | if (timeout > counter) { 35 | if ($('#filepicker_dialog').length === 1) { 36 | resolve(); 37 | window.clearInterval(subscriber); 38 | } 39 | } else { 40 | reject(); 41 | window.clearInterval(subscriber); 42 | } 43 | }, interval); 44 | }).then(function(){ 45 | assert.ok(true); 46 | }).catch(function(){ 47 | assert.ok(false, 'Filepicker dialog did not load on component element insertion'); 48 | }); 49 | }); -------------------------------------------------------------------------------- /tests/unit/services/filepicker-test.js: -------------------------------------------------------------------------------- 1 | import { 2 | moduleFor, 3 | test 4 | } 5 | from 'ember-qunit'; 6 | import Ember from 'ember'; 7 | 8 | moduleFor('service:filepicker', { 9 | // Specify the other units that are required for this test. 10 | // needs: ['service:foo'] 11 | }); 12 | 13 | // Replace this with your real tests. 14 | test('it exists', function(assert) { 15 | var service = this.subject(); 16 | assert.ok(service); 17 | }); 18 | 19 | test('it resolves the promise ', function(assert) { 20 | assert.expect(3); 21 | 22 | var service = this.subject(); 23 | var promise = service.get('promise'); 24 | 25 | assert.ok(promise instanceof Ember.RSVP.Promise, "promise' value is not an intance of proper RSVP.Promise"); 26 | 27 | return promise.then(function(filepicker) { 28 | assert.ok(!!filepicker, 'Resolved a falsy value as filepicker'); 29 | assert.equal(typeof filepicker.pick, "function", 'The resolved filepicker object does not have pick method'); 30 | }); 31 | }); 32 | 33 | test('it returns a proper filepicker instance', function(assert) { 34 | var service = this.subject(); 35 | return service.get('promise').then(function(filepicker) { 36 | assert.equal(service.get('instance'), filepicker, "'instance' value is not the resolved filepicker object"); 37 | }); 38 | }); 39 | 40 | test('it fails when script url is wrong', function(assert) { 41 | var service = this.subject({ 42 | scriptURL: '//not-a-filepicker.com/script.js', 43 | scriptLoadTimeout: 500 44 | }); 45 | var promise = service.get('promise'); 46 | return promise.then(function() { 47 | assert.ok(false, "Promise resolved successfully while it shouldn't have"); 48 | }) 49 | .catch(function(error) { 50 | assert.ok(!!error); 51 | }); 52 | }); 53 | 54 | test("unless promise resolved, 'instance' is null", function(assert) { 55 | var service = this.subject(); 56 | assert.ok(service.get('instance') === null, "'instance' value is not null even without promise resolution"); 57 | }); -------------------------------------------------------------------------------- /vendor/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DudaDev/ember-cli-filepicker/03120962fb9250f2ec50be896ea921c658641455/vendor/.gitkeep --------------------------------------------------------------------------------