simple_form_custom_inputs 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -8
  3. data/example/Gemfile +0 -1
  4. data/example/Gemfile.lock +1 -4
  5. data/example/app/assets/javascripts/application.js +1 -2
  6. data/example/app/assets/stylesheets/application.scss +1 -1
  7. data/lib/simple_form_custom_inputs/simple_form/button_file_input.rb +1 -0
  8. data/lib/simple_form_custom_inputs/version.rb +1 -1
  9. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.bg.js +14 -0
  10. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ca.js +14 -0
  11. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.cs.js +15 -0
  12. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.da.js +14 -0
  13. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.de.js +15 -0
  14. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.el.js +13 -0
  15. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.es.js +14 -0
  16. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.fi.js +14 -0
  17. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.fr.js +15 -0
  18. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.he.js +15 -0
  19. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.hr.js +13 -0
  20. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.id.js +13 -0
  21. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.is.js +14 -0
  22. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.it.js +14 -0
  23. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ja.js +13 -0
  24. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.kr.js +13 -0
  25. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.lt.js +16 -0
  26. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.lv.js +16 -0
  27. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ms.js +14 -0
  28. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.nb.js +14 -0
  29. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.nl.js +14 -0
  30. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.pl.js +15 -0
  31. data/vendor/assets/javascripts/{I18n/pt-BR.js → bootstrap-datepicker/locales/bootstrap-datepicker.pt-BR.js} +5 -1
  32. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.pt.js +14 -0
  33. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ro.js +15 -0
  34. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.rs-latin.js +14 -0
  35. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.rs.js +14 -0
  36. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.ru.js +14 -0
  37. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.sk.js +15 -0
  38. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.sl.js +14 -0
  39. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.sv.js +14 -0
  40. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.sw.js +15 -0
  41. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.th.js +14 -0
  42. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.tr.js +15 -0
  43. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.uk.js +14 -0
  44. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.js +14 -0
  45. data/vendor/assets/javascripts/bootstrap-datepicker/locales/bootstrap-datepicker.zh-TW.js +13 -0
  46. data/vendor/assets/javascripts/ezdz.js +423 -0
  47. data/vendor/assets/javascripts/simple_form_custom_inputs.js +16 -18
  48. data/vendor/assets/stylesheets/ezdz.css +119 -0
  49. data/vendor/assets/stylesheets/simple_form_custom_inputs.scss +1 -0
  50. metadata +41 -2
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Polish translation for bootstrap-datepicker
3
+ * Robert <rtpm@gazeta.pl>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['pl'] = {
7
+ days: ["Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota", "Niedziela"],
8
+ daysShort: ["Nie", "Pn", "Wt", "Śr", "Czw", "Pt", "So", "Nie"],
9
+ daysMin: ["N", "Pn", "Wt", "Śr", "Cz", "Pt", "So", "N"],
10
+ months: ["Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień"],
11
+ monthsShort: ["Sty", "Lu", "Mar", "Kw", "Maj", "Cze", "Lip", "Sie", "Wrz", "Pa", "Lis", "Gru"],
12
+ today: "Dzisiaj",
13
+ weekStart: 1
14
+ };
15
+ }(jQuery));
@@ -1,4 +1,8 @@
1
- (function($){
1
+ /**
2
+ * Brazilian translation for bootstrap-datepicker
3
+ * Cauan Cabral <cauan@radig.com.br>
4
+ */
5
+ ;(function($){
2
6
  $.fn.datepicker.dates['pt-BR'] = {
3
7
  days: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo"],
4
8
  daysShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb", "Dom"],
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Portuguese translation for bootstrap-datepicker
3
+ * Original code: Cauan Cabral <cauan@radig.com.br>
4
+ * Tiago Melo <tiago.blackcode@gmail.com>
5
+ */
6
+ ;(function($){
7
+ $.fn.datepicker.dates['pt'] = {
8
+ days: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo"],
9
+ daysShort: ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb", "Dom"],
10
+ daysMin: ["Do", "Se", "Te", "Qu", "Qu", "Se", "Sa", "Do"],
11
+ months: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
12
+ monthsShort: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"]
13
+ };
14
+ }(jQuery));
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Romanian translation for bootstrap-datepicker
3
+ * Cristian Vasile <cristi.mie@gmail.com>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['ro'] = {
7
+ days: ["Duminică", "Luni", "Marţi", "Miercuri", "Joi", "Vineri", "Sâmbătă", "Duminică"],
8
+ daysShort: ["Dum", "Lun", "Mar", "Mie", "Joi", "Vin", "Sâm", "Dum"],
9
+ daysMin: ["Du", "Lu", "Ma", "Mi", "Jo", "Vi", "Sâ", "Du"],
10
+ months: ["Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie"],
11
+ monthsShort: ["Ian", "Feb", "Mar", "Apr", "Mai", "Iun", "Iul", "Aug", "Sep", "Oct", "Nov", "Dec"],
12
+ today: "Astăzi",
13
+ weekStart: 1
14
+ };
15
+ }(jQuery));
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Serbian latin translation for bootstrap-datepicker
3
+ * Bojan Milosavlević <milboj@gmail.com>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['rs'] = {
7
+ days: ["Nedelja","Ponedeljak", "Utorak", "Sreda", "Četvrtak", "Petak", "Subota", "Nedelja"],
8
+ daysShort: ["Ned", "Pon", "Uto", "Sre", "Čet", "Pet", "Sub", "Ned"],
9
+ daysMin: ["N", "Po", "U", "Sr", "Č", "Pe", "Su", "N"],
10
+ months: ["Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"],
11
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Avg", "Sep", "Okt", "Nov", "Dec"],
12
+ today: "Danas"
13
+ };
14
+ }(jQuery));
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Serbian cyrillic translation for bootstrap-datepicker
3
+ * Bojan Milosavlević <milboj@gmail.com>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['rs'] = {
7
+ days: ["Недеља","Понедељак", "Уторак", "Среда", "Четвртак", "Петак", "Субота", "Недеља"],
8
+ daysShort: ["Нед", "Пон", "Уто", "Сре", "Чет", "Пет", "Суб", "Нед"],
9
+ daysMin: ["Н", "По", "У", "Ср", "Ч", "Пе", "Су", "Н"],
10
+ months: ["Јануар", "Фебруар", "Март", "Април", "Мај", "Јун", "Јул", "Август", "Септембар", "Октобар", "Новембар", "Децембар"],
11
+ monthsShort: ["Јан", "Феб", "Мар", "Апр", "Мај", "Јун", "Јул", "Авг", "Сеп", "Окт", "Нов", "Дец"],
12
+ today: "Данас"
13
+ };
14
+ }(jQuery));
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Russian translation for bootstrap-datepicker
3
+ * Victor Taranenko <darwin@snowdale.com>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['ru'] = {
7
+ days: ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота", "Воскресенье"],
8
+ daysShort: ["Вск", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Суб", "Вск"],
9
+ daysMin: ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"],
10
+ months: ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"],
11
+ monthsShort: ["Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"],
12
+ today: "Сегодня"
13
+ };
14
+ }(jQuery));
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Slovak translation for bootstrap-datepicker
3
+ * Marek Lichtner <marek@licht.sk>
4
+ * Fixes by Michal Remiš <michal.remis@gmail.com>
5
+ */
6
+ ;(function($){
7
+ $.fn.datepicker.dates["sk"] = {
8
+ days: ["Nedeľa", "Pondelok", "Utorok", "Streda", "Štvrtok", "Piatok", "Sobota", "Nedeľa"],
9
+ daysShort: ["Ned", "Pon", "Uto", "Str", "Štv", "Pia", "Sob", "Ned"],
10
+ daysMin: ["Ne", "Po", "Ut", "St", "Št", "Pia", "So", "Ne"],
11
+ months: ["Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December"],
12
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "Máj", "Jún", "Júl", "Aug", "Sep", "Okt", "Nov", "Dec"],
13
+ today: "Dnes"
14
+ };
15
+ }(jQuery));
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Slovene translation for bootstrap-datepicker
3
+ * Gregor Rudolf <gregor.rudolf@gmail.com>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['sl'] = {
7
+ days: ["Nedelja", "Ponedeljek", "Torek", "Sreda", "Četrtek", "Petek", "Sobota", "Nedelja"],
8
+ daysShort: ["Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob", "Ned"],
9
+ daysMin: ["Ne", "Po", "To", "Sr", "Če", "Pe", "So", "Ne"],
10
+ months: ["Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December"],
11
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Avg", "Sep", "Okt", "Nov", "Dec"],
12
+ today: "Danes"
13
+ };
14
+ }(jQuery));
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Swedish translation for bootstrap-datepicker
3
+ * Patrik Ragnarsson <patrik@starkast.net>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['sv'] = {
7
+ days: ["Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag", "Söndag"],
8
+ daysShort: ["Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör", "Sön"],
9
+ daysMin: ["Sö", "Må", "Ti", "On", "To", "Fr", "Lö", "Sö"],
10
+ months: ["Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"],
11
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
12
+ today: "I Dag"
13
+ };
14
+ }(jQuery));
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Swahili translation for bootstrap-datepicker
3
+ * Edwin Mugendi <https://github.com/edwinmugendi>
4
+ * Source: http://scriptsource.org/cms/scripts/page.php?item_id=entry_detail&uid=xnfaqyzcku
5
+ */
6
+ ;(function($){
7
+ $.fn.datepicker.dates['sw'] = {
8
+ days: ["Jumapili", "Jumatatu", "Jumanne", "Jumatano", "Alhamisi", "Ijumaa", "Jumamosi", "Jumapili"],
9
+ daysShort: ["J2", "J3", "J4", "J5", "Alh", "Ij", "J1", "J2"],
10
+ daysMin: ["2", "3", "4", "5", "A", "I", "1", "2"],
11
+ months: ["Januari", "Februari", "Machi", "Aprili", "Mei", "Juni", "Julai", "Agosti", "Septemba", "Oktoba", "Novemba", "Desemba"],
12
+ monthsShort: ["Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ago", "Sep", "Okt", "Nov", "Des"],
13
+ today: "Leo"
14
+ };
15
+ }(jQuery));
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Thai translation for bootstrap-datepicker
3
+ * Suchau Jiraprapot <seroz24@gmail.com>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['th'] = {
7
+ days: ["อาทิตย์", "จันทร์", "อังคาร", "พุธ", "พฤหัส", "ศุกร์", "เสาร์", "อาทิตย์"],
8
+ daysShort: ["อา", "จ", "อ", "พ", "พฤ", "ศ", "ส", "อา"],
9
+ daysMin: ["อา", "จ", "อ", "พ", "พฤ", "ศ", "ส", "อา"],
10
+ months: ["มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม"],
11
+ monthsShort: ["ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค."],
12
+ today: "วันนี้"
13
+ };
14
+ }(jQuery));
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Turkish translation for bootstrap-datepicker
3
+ * Serkan Algur <kaisercrazy_2@hotmail.com>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['tr'] = {
7
+ days: ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi", "Pazar"],
8
+ daysShort: ["Pz", "Pzt", "Sal", "Çrş", "Prş", "Cu", "Cts", "Pz"],
9
+ daysMin: ["Pz", "Pzt", "Sa", "Çr", "Pr", "Cu", "Ct", "Pz"],
10
+ months: ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"],
11
+ monthsShort: ["Oca", "Şub", "Mar", "Nis", "May", "Haz", "Tem", "Ağu", "Eyl", "Eki", "Kas", "Ara"],
12
+ today: "Bugün"
13
+ };
14
+ }(jQuery));
15
+
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Ukrainian translation for bootstrap-datepicker
3
+ * Andrey Vityuk <andrey [dot] vityuk [at] gmail.com>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['uk'] = {
7
+ days: ["Неділя", "Понеділок", "Вівторок", "Середа", "Четвер", "П'ятниця", "Субота", "Неділя"],
8
+ daysShort: ["Нед", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Суб", "Нед"],
9
+ daysMin: ["Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Нд"],
10
+ months: ["Січень", "Лютий", "Березень", "Квітень", "Травень", "Червень", "Липень", "Серпень", "Вересень", "Жовтень", "Листопад", "Грудень"],
11
+ monthsShort: ["Січ", "Лют", "Бер", "Кві", "Тра", "Чер", "Лип", "Сер", "Вер", "Жов", "Лис", "Гру"],
12
+ today: "Сьогодні"
13
+ };
14
+ }(jQuery));
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Simplified Chinese translation for bootstrap-datepicker
3
+ * Yuan Cheung <advanimal@gmail.com>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['zh-CN'] = {
7
+ days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
8
+ daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
9
+ daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
10
+ months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
11
+ monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
12
+ today: "今日"
13
+ };
14
+ }(jQuery));
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Traditional Chinese translation for bootstrap-datepicker
3
+ * Rung-Sheng Jang <daniel@i-trend.co.cc>
4
+ */
5
+ ;(function($){
6
+ $.fn.datepicker.dates['zh-TW'] = {
7
+ days: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"],
8
+ daysShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六", "周日"],
9
+ daysMin: ["日", "一", "二", "三", "四", "五", "六", "日"],
10
+ months: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
11
+ monthsShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"]
12
+ };
13
+ }(jQuery));
@@ -0,0 +1,423 @@
1
+ /* ----------------------------------------------------------------------------
2
+ // Ezdz [izy-dizy]
3
+ // Licensed under the MIT license.
4
+ // http://github.com/jaysalvat/ezdz/
5
+ // ----------------------------------------------------------------------------
6
+ // Copyright (C) 2014 Jay Salvat
7
+ // http://jaysalvat.com/
8
+ // --------------------------------------------------------------------------*/
9
+
10
+ /* global define: true, require: true, jQuery */
11
+
12
+ (function (factory) {
13
+ "use strict";
14
+
15
+ if (typeof define === 'function' && define.amd) {
16
+ define(['jquery'], factory);
17
+ } else if (typeof exports === 'object') {
18
+ factory(require('jquery'));
19
+ } else {
20
+ factory(jQuery);
21
+ }
22
+ }(function ($) {
23
+ "use strict";
24
+
25
+ // Default settings
26
+ var defaults = {
27
+ className: '',
28
+ text: 'Drop a file',
29
+ previewImage: true,
30
+ value: null,
31
+ classes: {
32
+ main: 'ezdz-dropzone',
33
+ enter: 'ezdz-enter',
34
+ reject: 'ezdz-reject',
35
+ accept: 'ezdz-accept',
36
+ focus: 'ezdz-focus'
37
+ },
38
+ validators: {
39
+ maxSize: null,
40
+ width: null,
41
+ maxWidth: null,
42
+ minWidth: null,
43
+ height: null,
44
+ maxHeight: null,
45
+ minHeight: null,
46
+ maxNumber: null
47
+ },
48
+ init: function() {},
49
+ enter: function() {},
50
+ leave: function() {},
51
+ reject: function() {},
52
+ accept: function() {},
53
+ format: function(filename) {
54
+ return filename;
55
+ }
56
+ };
57
+
58
+ // Main plugin
59
+ $.ezdz = function(element, options) {
60
+ this.settings = $.extend(true, {}, defaults, $.ezdz.defaults, options);
61
+ this.$input = $(element);
62
+
63
+ var self = this,
64
+ settings = self.settings,
65
+ $input = self.$input;
66
+
67
+ if (!$input.is('input[type="file"]')) {
68
+ return;
69
+ }
70
+
71
+ // Stop if not compatible with HTML5 file API
72
+ if (!$.ezdz.isBrowserCompatible()) {
73
+ return;
74
+ }
75
+
76
+ // private: Init the plugin
77
+ var init = function() {
78
+ var $ezdz, $container, value;
79
+
80
+ // Build the container
81
+ $container = $('<div class="' + settings.classes.main + '" />')
82
+
83
+ .on('dragover.ezdz', function() {
84
+ $(this).addClass(settings.classes.enter);
85
+
86
+ if ($.isFunction(settings.enter)) {
87
+ settings.enter.apply(this);
88
+ }
89
+ })
90
+
91
+ .on('dragleave.ezdz', function() {
92
+ $(this).removeClass(settings.classes.enter);
93
+
94
+ if ($.isFunction(settings.leaved)) {
95
+ settings.leaved.apply(this);
96
+ }
97
+ })
98
+
99
+ .addClass(settings.className);
100
+
101
+ // Build the whole dropzone
102
+ $input
103
+ .wrap($container)
104
+ .before('<div>' + settings.text + '</div>');
105
+
106
+ $ezdz = $input.parent('.' + settings.classes.main);
107
+
108
+ // Preview a file at start if it's defined
109
+ value = settings.value || $input.data('value');
110
+
111
+ if (value) {
112
+ self.preview(value);
113
+ }
114
+
115
+ // Trigger the init callback
116
+ if ($.isFunction(settings.init)) {
117
+ settings.init.apply($input, [ value ]);
118
+ }
119
+
120
+ // Events on the input
121
+ $input
122
+
123
+ .on('focus.ezdz', function() {
124
+ $ezdz.addClass(settings.classes.focus);
125
+ })
126
+
127
+ .on('blur.ezdz', function() {
128
+ $ezdz.removeClass(settings.classes.focus);
129
+ })
130
+
131
+ .on('change.ezdz', function() {
132
+
133
+
134
+ // No file, so user has cancelled
135
+ if (this.files.length == 0) {
136
+ return;
137
+ }
138
+
139
+ // Mime-Types
140
+ var allowed = $input.attr('accept'),
141
+ accepted = false,
142
+ valid = true,
143
+ errors = {
144
+ 'mimeType': false,
145
+ 'maxSize': false,
146
+ 'width': false,
147
+ 'minWidth': false,
148
+ 'maxWidth': false,
149
+ 'height': false,
150
+ 'minHeight': false,
151
+ 'maxHeight': false,
152
+ 'maxNumber': false
153
+ };
154
+
155
+ //Check the maximum number of files
156
+
157
+ if (settings.validators.maxNumber && this.files.length > settings.validators.maxNumber) {
158
+ valid = false;
159
+ errors.maxNumber = true;
160
+ }
161
+
162
+ var imgArr = new Array();
163
+ var isImage = true;
164
+
165
+ var i=0;
166
+ for(i=0;i<this.files.length;i++){
167
+
168
+ var file = this.files[i];
169
+
170
+
171
+ // Info about the dropped or selected file
172
+ var basename = file.name.replace(/\\/g,'/').replace( /.*\//, ''),
173
+ extension = file.name.split('.').pop(),
174
+ formatted = settings.format(basename);
175
+
176
+ file.extension = extension;
177
+
178
+
179
+ // Check the accepted Mime-Types from the input file
180
+ if (allowed) {
181
+ var types = allowed.split(/[,|]/);
182
+
183
+ $.each(types, function(i, type) {
184
+ type = $.trim(type);
185
+
186
+ if (file.type === type) {
187
+ accepted = true;
188
+ return false;
189
+ }
190
+
191
+ // Mime-Type with wildcards ex. image/*
192
+ if (type.indexOf('/*') !== false) {
193
+ var a = type.replace('/*', ''),
194
+ b = file.type.replace(/(\/.*)$/g, '');
195
+
196
+ if (a === b) {
197
+ accepted = true;
198
+ return false;
199
+ }
200
+ }
201
+ });
202
+
203
+ if (accepted === false) {
204
+ errors.mimeType = true;
205
+ }
206
+ } else {
207
+ accepted = true;
208
+ }
209
+
210
+ // Reset the accepted / rejected classes
211
+ $ezdz.removeClass(settings.classes.reject + ' ' + settings.classes.accept);
212
+
213
+ // If the Mime-Type is not accepted
214
+ if (accepted !== true) {
215
+ $input.val('');
216
+
217
+ $ezdz.addClass(settings.classes.reject);
218
+
219
+ // Trigger the reject callback
220
+ if ($.isFunction(settings.reject)) {
221
+ settings.reject.apply($input, [ file, errors ]);
222
+ }
223
+ return false;
224
+ }
225
+
226
+ // Read the added file
227
+ var reader = new FileReader(file);
228
+
229
+ reader.readAsDataURL(file);
230
+
231
+ reader.onload = function(e) {
232
+ var img = new Image();
233
+
234
+ imgArr.push(img);
235
+
236
+ file.data = e.target.result;
237
+ img.src = file.data;
238
+
239
+ setTimeout(function() {
240
+ if(img.width && img.height){
241
+
242
+ }else{
243
+ isImage = false;
244
+ }
245
+
246
+ // Validator
247
+ if (settings.validators.maxSize && file.size > settings.validators.maxSize) {
248
+ valid = false;
249
+ errors.maxSize = true;
250
+ }
251
+
252
+ if (isImage) {
253
+ file.width = img.width;
254
+ file.height = img.height;
255
+
256
+ if (settings.validators.width && img.width !== settings.validators.width) {
257
+ valid = false;
258
+ errors.width = true;
259
+ }
260
+
261
+ if (settings.validators.maxWidth && img.width > settings.validators.maxWidth) {
262
+ valid = false;
263
+ errors.maxWidth = true;
264
+ }
265
+
266
+ if (settings.validators.minWidth && img.width < settings.validators.minWidth) {
267
+ valid = false;
268
+ errors.minWidth = true;
269
+ }
270
+
271
+ if (settings.validators.height && img.height !== settings.validators.height) {
272
+ valid = false;
273
+ errors.height = true;
274
+ }
275
+
276
+ if (settings.validators.maxHeight && img.height > settings.validators.maxHeight) {
277
+ valid = false;
278
+ errors.maxHeight = true;
279
+ }
280
+
281
+ if (settings.validators.minHeight && img.height < settings.validators.minHeight) {
282
+ valid = false;
283
+ errors.minHeight = true;
284
+ }
285
+ }
286
+
287
+
288
+ }, 100);
289
+ };
290
+ }
291
+
292
+ setTimeout(function() {
293
+
294
+ // The file is validated, so added to input
295
+ if (valid === true) {
296
+ $ezdz.find('img').remove();
297
+
298
+
299
+
300
+ if (isImage && settings.previewImage === true) {
301
+ var $image_wrapper = $("<ul></ul>");
302
+ $image_wrapper.addClass("image-g");
303
+ var i;
304
+ for (i=0;i<imgArr.length;i++){
305
+ var img_obj = imgArr[i];
306
+ var $image_item = $("<li></li>").append(img_obj);
307
+ $image_wrapper.append($image_item);
308
+ }
309
+ $ezdz.find('div').html($image_wrapper.fadeIn());
310
+ } else {
311
+ $ezdz.find('div').html('<span>' + formatted + '</span>');
312
+ }
313
+
314
+ $ezdz.addClass(settings.classes.accept);
315
+
316
+ // Trigger the accept callback
317
+ if ($.isFunction(settings.accept)) {
318
+ settings.accept.apply($input, [ file ]);
319
+ }
320
+ // The file is invalidated, so rejected
321
+ } else {
322
+ $input.val('');
323
+
324
+ $ezdz.addClass(settings.classes.reject);
325
+
326
+ // Trigger the reject callback
327
+ if ($.isFunction(settings.reject)) {
328
+ settings.reject.apply($input, [ file, errors ]);
329
+ }
330
+ }
331
+
332
+ }, 1000);
333
+
334
+
335
+ });
336
+ };
337
+
338
+ init();
339
+ };
340
+
341
+ // Inject a file or image in the preview
342
+ $.ezdz.prototype.preview = function(path, callback) {
343
+ var settings = this.settings,
344
+ $input = this.$input,
345
+ $ezdz = $input.parent('.' + settings.classes.main),
346
+ basename = path.replace(/\\/g,'/').replace( /.*\//, ''),
347
+ formatted = settings.format(basename);
348
+
349
+ var img = new Image();
350
+ img.src = path;
351
+
352
+ // Is an image
353
+ img.onload = function() {
354
+ $ezdz.find('div').html($(img).fadeIn());
355
+
356
+ if ($.isFunction(callback)) {
357
+ callback.apply(this);
358
+ }
359
+ };
360
+
361
+ // Is not an image
362
+ img.onerror = function() {
363
+ $ezdz.find('div').html('<span>' + formatted + '</span>');
364
+
365
+ if ($.isFunction(callback)) {
366
+ callback.apply(this);
367
+ }
368
+ };
369
+
370
+ $ezdz.addClass(settings.classes.accept);
371
+ };
372
+
373
+ // Destroy ezdz
374
+ $.ezdz.prototype.destroy = function() {
375
+ var settings = this.settings,
376
+ $input = this.$input;
377
+
378
+ $input.parent('.' + settings.classes.main).replaceWith($input);
379
+ $input.off('*.ezdz');
380
+ $input.removeData('ezdz');
381
+ };
382
+
383
+ // Extend settings
384
+ $.ezdz.prototype.options = function(options) {
385
+ var settings = this.settings;
386
+
387
+ if (!options) {
388
+ return settings;
389
+ }
390
+
391
+ $.extend(true, this.settings, options);
392
+ };
393
+
394
+ // Get input container
395
+ $.ezdz.prototype.container = function() {
396
+ var settings = this.settings,
397
+ $input = this.$input;
398
+
399
+ return $input.parent('.' + settings.classes.main);
400
+ };
401
+
402
+ // Is browser compatible
403
+ $.ezdz.isBrowserCompatible = function() {
404
+ return !!(window.File && window.FileList && window.FileReader);
405
+ };
406
+
407
+ // Default options
408
+ $.ezdz.defaults = defaults;
409
+
410
+ // jQuery plugin
411
+ $.fn.ezdz = function(options) {
412
+ var args = arguments,
413
+ plugin = $(this).data('ezdz');
414
+
415
+ if (!plugin) {
416
+ return $(this).data('ezdz', new $.ezdz(this, options));
417
+ } if (plugin[options]) {
418
+ return plugin[options].apply(plugin, Array.prototype.slice.call(args, 1));
419
+ } else {
420
+ $.error('Ezdz error - Method ' + options + ' does not exist.');
421
+ }
422
+ };
423
+ }));