spina-template 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/app/.DS_Store +0 -0
- data/app/assets/.DS_Store +0 -0
- data/app/assets/images/.DS_Store +0 -0
- data/app/assets/images/spina/arrow-left.png +0 -0
- data/app/assets/images/spina/arrow-right.png +0 -0
- data/app/assets/images/spina/bg.jpg +0 -0
- data/app/assets/images/spina/danger-zone-ribbon.png +0 -0
- data/app/assets/images/spina/datepicker.png +0 -0
- data/app/assets/images/spina/divider.png +0 -0
- data/app/assets/images/spina/marker.png +0 -0
- data/app/assets/images/spina/mask.png +0 -0
- data/app/assets/images/spina/wheel.png +0 -0
- data/app/assets/javascripts/.DS_Store +0 -0
- data/app/assets/javascripts/spina/dropdown.js.coffee +64 -0
- data/app/assets/javascripts/spina/galleryselect.js.coffee +12 -0
- data/app/assets/javascripts/spina/modal.js.coffee +54 -0
- data/app/assets/javascripts/spina/switch.js.coffee +41 -0
- data/app/assets/javascripts/spina/tabs.js.coffee +13 -0
- data/app/assets/javascripts/spina/uploads.js.coffee +45 -0
- data/app/assets/javascripts/spina.js.coffee.erb +154 -0
- data/app/assets/stylesheets/.DS_Store +0 -0
- data/app/assets/stylesheets/spina/_admin_editing.css.sass +29 -0
- data/app/assets/stylesheets/spina/_buttons.css.sass +334 -0
- data/app/assets/stylesheets/spina/_cards.css.sass +57 -0
- data/app/assets/stylesheets/spina/_configuration.css.sass +16 -0
- data/app/assets/stylesheets/spina/_custom_animations.css.sass +61 -0
- data/app/assets/stylesheets/spina/_farbtastic.css.sass +37 -0
- data/app/assets/stylesheets/spina/_fonts.css.sass +14 -0
- data/app/assets/stylesheets/spina/_forms.css.sass +473 -0
- data/app/assets/stylesheets/spina/_gallery.css.sass +121 -0
- data/app/assets/stylesheets/spina/_grid.css.sass +12 -0
- data/app/assets/stylesheets/spina/_labels.css.sass +28 -0
- data/app/assets/stylesheets/spina/_login.css.sass +32 -0
- data/app/assets/stylesheets/spina/_mixins.css.scss +13 -0
- data/app/assets/stylesheets/spina/_modal.css.sass +158 -0
- data/app/assets/stylesheets/spina/_sortable_lists.css.sass +161 -0
- data/app/assets/stylesheets/spina/_tables.css.sass +144 -0
- data/app/assets/stylesheets/spina/_wysihtml5.css.sass +73 -0
- data/app/assets/stylesheets/spina/wysihtml5_textarea.css.sass +14 -0
- data/app/assets/stylesheets/spina.css.sass +521 -0
- data/lib/spina/template/version.rb +5 -0
- data/lib/spina/template.rb +12 -0
- data/spina-template.gemspec +26 -0
- data/vendor/.DS_Store +0 -0
- data/vendor/assets/.DS_Store +0 -0
- data/vendor/assets/javascripts/.DS_Store +0 -0
- data/vendor/assets/javascripts/spina/jquery.customfileinput.js +85 -0
- data/vendor/assets/javascripts/spina/jquery.datatables.js +12099 -0
- data/vendor/assets/javascripts/spina/jquery.farbtastic.js +345 -0
- data/vendor/assets/javascripts/spina/jquery.nestable.js +485 -0
- data/vendor/assets/javascripts/spina/jquery.sortable.js +3 -0
- data/vendor/assets/javascripts/spina/jquery.ui.datepicker-nl.js +23 -0
- data/vendor/assets/javascripts/spina/jquery.ui.js +6 -0
- data/vendor/assets/javascripts/spina/morris.js +1767 -0
- data/vendor/assets/javascripts/spina/nprogress.js +274 -0
- data/vendor/assets/javascripts/spina/raphael.js +8111 -0
- data/vendor/assets/javascripts/spina/wysihtml5.js +269 -0
- data/vendor/assets/javascripts/spina/wysihtml5_parser_rules.js +551 -0
- data/vendor/assets/stylesheets/.DS_Store +0 -0
- data/vendor/assets/stylesheets/spina/_animate.css +1 -0
- data/vendor/assets/stylesheets/spina/_morris.css +2 -0
- data/vendor/assets/stylesheets/spina/_normalize.css +396 -0
- data/vendor/assets/stylesheets/spina/_nprogress.css.scss +85 -0
- metadata +197 -0
@@ -0,0 +1,521 @@
|
|
1
|
+
// Frameworks
|
2
|
+
@import bourbon
|
3
|
+
@import neat
|
4
|
+
|
5
|
+
// Configuration
|
6
|
+
@import spina/configuration
|
7
|
+
|
8
|
+
// Normalizing
|
9
|
+
@import spina/normalize
|
10
|
+
|
11
|
+
@import spina/mixins
|
12
|
+
|
13
|
+
// Grid
|
14
|
+
@import spina/grid
|
15
|
+
|
16
|
+
// Fonts
|
17
|
+
@import spina/fonts
|
18
|
+
|
19
|
+
// Animations
|
20
|
+
@import spina/animate
|
21
|
+
@import spina/custom_animations
|
22
|
+
|
23
|
+
// Elements
|
24
|
+
@import spina/forms
|
25
|
+
@import spina/tables
|
26
|
+
@import spina/buttons
|
27
|
+
@import spina/labels
|
28
|
+
@import spina/modal
|
29
|
+
@import spina/sortable_lists
|
30
|
+
@import spina/gallery
|
31
|
+
@import spina/login
|
32
|
+
@import spina/cards
|
33
|
+
|
34
|
+
// Plugins
|
35
|
+
@import spina/morris
|
36
|
+
@import spina/nprogress
|
37
|
+
@import spina/wysihtml5
|
38
|
+
@import spina/farbtastic
|
39
|
+
|
40
|
+
html
|
41
|
+
min-height: 100%
|
42
|
+
|
43
|
+
html, body
|
44
|
+
height: 100%
|
45
|
+
font-family: $font-family
|
46
|
+
font-weight: 600
|
47
|
+
|
48
|
+
body
|
49
|
+
@include display(flex)
|
50
|
+
|
51
|
+
// Primary navigation
|
52
|
+
|
53
|
+
nav#primary
|
54
|
+
background: #111
|
55
|
+
height: 100%
|
56
|
+
padding-top: 10px
|
57
|
+
position: relative
|
58
|
+
text-align: center
|
59
|
+
width: 100px
|
60
|
+
|
61
|
+
@include media($tablet)
|
62
|
+
width: 80px
|
63
|
+
|
64
|
+
ul li a
|
65
|
+
color: #999
|
66
|
+
display: block
|
67
|
+
font-size: 10px
|
68
|
+
font-weight: 700
|
69
|
+
padding: 20px 0
|
70
|
+
position: relative
|
71
|
+
text-decoration: none
|
72
|
+
text-transform: uppercase
|
73
|
+
width: 100%
|
74
|
+
@include transition(color .15s ease)
|
75
|
+
|
76
|
+
@include media($tablet)
|
77
|
+
padding: 12px 0
|
78
|
+
|
79
|
+
ul li.active a, ul li a:hover
|
80
|
+
color: #fff
|
81
|
+
|
82
|
+
ul li.bottom a
|
83
|
+
bottom: 0
|
84
|
+
left: 0
|
85
|
+
position: absolute
|
86
|
+
|
87
|
+
ul li a:before
|
88
|
+
display: block
|
89
|
+
font-size: 26px
|
90
|
+
margin-bottom: 8px
|
91
|
+
text-transform: none
|
92
|
+
|
93
|
+
@include media($tablet)
|
94
|
+
font-size: 20px
|
95
|
+
|
96
|
+
ul li a[data-badge]:after
|
97
|
+
background: $danger-color
|
98
|
+
border-radius: 8px
|
99
|
+
color: #fff
|
100
|
+
content: attr(data-badge)
|
101
|
+
display: block
|
102
|
+
font-size: 12px
|
103
|
+
font-weight: bold
|
104
|
+
line-height: 16px
|
105
|
+
min-width: 10px
|
106
|
+
padding: 0 3px
|
107
|
+
position: absolute
|
108
|
+
right: 28px
|
109
|
+
top: 12px
|
110
|
+
|
111
|
+
// Secondary navigation
|
112
|
+
|
113
|
+
nav#secondary
|
114
|
+
background: #f5f5f5
|
115
|
+
border-right: 1px solid #ccc
|
116
|
+
height: 100%
|
117
|
+
padding: 30px 0
|
118
|
+
width: 300px
|
119
|
+
|
120
|
+
@include media($tablet)
|
121
|
+
left: 80px
|
122
|
+
padding-top: 12px
|
123
|
+
width: 200px
|
124
|
+
|
125
|
+
h1
|
126
|
+
color: #333
|
127
|
+
font-size: 24px
|
128
|
+
font-weight: 300
|
129
|
+
margin-bottom: 36px
|
130
|
+
padding: 0 30px
|
131
|
+
|
132
|
+
@include media($tablet)
|
133
|
+
display: none
|
134
|
+
|
135
|
+
ul li
|
136
|
+
position: relative
|
137
|
+
|
138
|
+
ul li a
|
139
|
+
color: #333
|
140
|
+
display: block
|
141
|
+
font-size: 15px
|
142
|
+
font-weight: 600
|
143
|
+
line-height: 15px
|
144
|
+
margin-left: 36px
|
145
|
+
padding: 16px 30px
|
146
|
+
text-decoration: none
|
147
|
+
|
148
|
+
@include media($tablet)
|
149
|
+
margin-left: 24px
|
150
|
+
padding-left: 0
|
151
|
+
|
152
|
+
small
|
153
|
+
color: #666
|
154
|
+
display: block
|
155
|
+
font-size: 14px
|
156
|
+
font-weight: normal
|
157
|
+
line-height: 18px
|
158
|
+
margin-top: 2px
|
159
|
+
@include transition(color .15s ease)
|
160
|
+
|
161
|
+
@include media($tablet)
|
162
|
+
display: none
|
163
|
+
|
164
|
+
ul li a:hover
|
165
|
+
color: #333
|
166
|
+
|
167
|
+
small, &:before
|
168
|
+
color: inherit
|
169
|
+
|
170
|
+
ul li.active a
|
171
|
+
color: $primary-color
|
172
|
+
|
173
|
+
small, &:before
|
174
|
+
color: inherit
|
175
|
+
|
176
|
+
ul li a:before
|
177
|
+
color: #666
|
178
|
+
display: block
|
179
|
+
float: left
|
180
|
+
font-size: 24px
|
181
|
+
margin-left: -36px
|
182
|
+
width: 24px
|
183
|
+
@include transition(color .15s ease)
|
184
|
+
|
185
|
+
@include media($tablet)
|
186
|
+
display: none
|
187
|
+
|
188
|
+
ul li.active
|
189
|
+
&:before
|
190
|
+
content: ""
|
191
|
+
display: block
|
192
|
+
position: absolute
|
193
|
+
right: -12px
|
194
|
+
top: 33%
|
195
|
+
@include triangle(23px, #ccc, right)
|
196
|
+
|
197
|
+
&:after
|
198
|
+
content: ""
|
199
|
+
display: block
|
200
|
+
position: absolute
|
201
|
+
right: -11px
|
202
|
+
top: 33%
|
203
|
+
@include triangle(22px, #f5f5f5, right)
|
204
|
+
|
205
|
+
// Tabs
|
206
|
+
|
207
|
+
nav.tabs
|
208
|
+
border-bottom: 1px solid #ddd
|
209
|
+
margin: 0 -40px 30px -40px
|
210
|
+
padding: 0 40px 0 24px
|
211
|
+
|
212
|
+
ul li
|
213
|
+
display: inline
|
214
|
+
|
215
|
+
ul li a
|
216
|
+
border: 1px solid transparent
|
217
|
+
color: #444
|
218
|
+
display: inline-block
|
219
|
+
font-size: 14px
|
220
|
+
font-weight: 600
|
221
|
+
margin-bottom: -1px
|
222
|
+
margin-top: 20px
|
223
|
+
padding: 12px 16px
|
224
|
+
text-decoration: none
|
225
|
+
|
226
|
+
ul li a:hover
|
227
|
+
color: #222
|
228
|
+
|
229
|
+
ul li.active a
|
230
|
+
border-color: #ddd
|
231
|
+
border-bottom: 1px solid #fff
|
232
|
+
border-radius: 3px 3px 0 0
|
233
|
+
color: $primary-color
|
234
|
+
|
235
|
+
.tab-content
|
236
|
+
display: none
|
237
|
+
|
238
|
+
&.active
|
239
|
+
display: block
|
240
|
+
|
241
|
+
// Notifications
|
242
|
+
|
243
|
+
.notification
|
244
|
+
position: relative
|
245
|
+
color: $info-color
|
246
|
+
margin: 20px 0
|
247
|
+
overflow: hidden
|
248
|
+
font-size: 14px
|
249
|
+
padding-left: 32px
|
250
|
+
|
251
|
+
&:before
|
252
|
+
position: absolute
|
253
|
+
left: 0px
|
254
|
+
color: #77caf9
|
255
|
+
display: block
|
256
|
+
font-size: 18px
|
257
|
+
margin-top: 1em
|
258
|
+
|
259
|
+
p
|
260
|
+
color: $info-color
|
261
|
+
font-weight: 600
|
262
|
+
line-height: 18px
|
263
|
+
margin-bottom: 0
|
264
|
+
|
265
|
+
small
|
266
|
+
display: block
|
267
|
+
font-size: 14px
|
268
|
+
font-weight: normal
|
269
|
+
|
270
|
+
ul
|
271
|
+
margin: 0
|
272
|
+
|
273
|
+
li
|
274
|
+
font-weight: normal
|
275
|
+
|
276
|
+
&.notification-error
|
277
|
+
color: $error-color
|
278
|
+
|
279
|
+
p
|
280
|
+
color: $error-color
|
281
|
+
|
282
|
+
&:before
|
283
|
+
color: #e7baba
|
284
|
+
|
285
|
+
&.notification-danger
|
286
|
+
color: $danger-color
|
287
|
+
|
288
|
+
p
|
289
|
+
color: $danger-color
|
290
|
+
|
291
|
+
&:before
|
292
|
+
color: $danger-color
|
293
|
+
|
294
|
+
// Permanent notice
|
295
|
+
.permanent-notice
|
296
|
+
background: #eee
|
297
|
+
border-bottom: 1px solid #ddd
|
298
|
+
color: #333
|
299
|
+
margin: -30px -40px 30px -40px
|
300
|
+
padding: 0 40px
|
301
|
+
position: relative
|
302
|
+
|
303
|
+
&:before
|
304
|
+
font-size: 16px
|
305
|
+
left: 14px
|
306
|
+
opacity: .25
|
307
|
+
position: absolute
|
308
|
+
top: 12px
|
309
|
+
|
310
|
+
p
|
311
|
+
font-size: 13px
|
312
|
+
line-height: 18px
|
313
|
+
margin: 0
|
314
|
+
padding: 12px 0
|
315
|
+
|
316
|
+
small
|
317
|
+
display: block
|
318
|
+
font-size: 12px
|
319
|
+
font-weight: 400
|
320
|
+
|
321
|
+
&.permanent-notice-info
|
322
|
+
background: #eef6fe
|
323
|
+
border-color: #def
|
324
|
+
color: #12659b
|
325
|
+
|
326
|
+
p
|
327
|
+
color: inherit
|
328
|
+
|
329
|
+
// Filters
|
330
|
+
|
331
|
+
.filters
|
332
|
+
margin: 20px 0
|
333
|
+
|
334
|
+
// Datepicker
|
335
|
+
|
336
|
+
.ui-datepicker
|
337
|
+
background: #fff
|
338
|
+
border: none
|
339
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, .25)
|
340
|
+
width: 250px
|
341
|
+
|
342
|
+
.ui-datepicker-header
|
343
|
+
border: none
|
344
|
+
font-weight: 300
|
345
|
+
|
346
|
+
a.ui-datepicker-prev, a.ui-datepicker-next
|
347
|
+
background: none
|
348
|
+
border: none
|
349
|
+
color: transparent
|
350
|
+
cursor: pointer
|
351
|
+
display: block
|
352
|
+
height: 36px
|
353
|
+
opacity: .6
|
354
|
+
padding: 8px 0
|
355
|
+
position: absolute
|
356
|
+
right: 0
|
357
|
+
top: 0
|
358
|
+
width: 36px
|
359
|
+
|
360
|
+
a.ui-datepicker-prev
|
361
|
+
left: 0
|
362
|
+
|
363
|
+
a.ui-datepicker-prev:hover, a.ui-datepicker-next:hover
|
364
|
+
opacity: 1
|
365
|
+
|
366
|
+
a.ui-datepicker-prev span
|
367
|
+
background: url(asset_path("spina/arrow-left.png", "image")) no-repeat center
|
368
|
+
background-size: 10px 13px
|
369
|
+
display: block
|
370
|
+
|
371
|
+
a.ui-datepicker-next span
|
372
|
+
background: url(asset_path("spina/arrow-right.png", "image")) no-repeat center
|
373
|
+
background-size: 10px 13px
|
374
|
+
display: block
|
375
|
+
|
376
|
+
.ui-datepicker-title
|
377
|
+
line-height: 42px
|
378
|
+
text-align: center
|
379
|
+
|
380
|
+
.ui-datepicker-calendar
|
381
|
+
width: 100%
|
382
|
+
|
383
|
+
tr td:first-child, tr th:first-child
|
384
|
+
padding-left: 0px
|
385
|
+
|
386
|
+
tr td:last-child, tr th:last-child
|
387
|
+
padding-right: 0px
|
388
|
+
|
389
|
+
thead th
|
390
|
+
color: #444
|
391
|
+
font-weight: 600
|
392
|
+
|
393
|
+
tbody tr, thead tr
|
394
|
+
border: none
|
395
|
+
|
396
|
+
tbody tr td
|
397
|
+
background: none
|
398
|
+
|
399
|
+
tbody tr td a
|
400
|
+
display: block
|
401
|
+
line-height: 28px
|
402
|
+
text-align: center
|
403
|
+
padding: 2px 4px
|
404
|
+
width: 32px
|
405
|
+
|
406
|
+
tbody tr td a.ui-state-default
|
407
|
+
background: none
|
408
|
+
border: none
|
409
|
+
color: #777
|
410
|
+
font-weight: 600
|
411
|
+
|
412
|
+
tr:hover
|
413
|
+
background: none
|
414
|
+
|
415
|
+
tbody tr td a:hover
|
416
|
+
color: #000
|
417
|
+
|
418
|
+
tbody tr td a.ui-state-highlight
|
419
|
+
background: #eee
|
420
|
+
border-radius: 2px
|
421
|
+
|
422
|
+
tbody tr td a.ui-state-active
|
423
|
+
background: #444
|
424
|
+
border-radius: 2px
|
425
|
+
color: #fff
|
426
|
+
|
427
|
+
// Main content
|
428
|
+
|
429
|
+
section#main
|
430
|
+
padding: 30px 40px
|
431
|
+
height: 100%
|
432
|
+
overflow: scroll
|
433
|
+
@include flex(1)
|
434
|
+
|
435
|
+
// Danger zone
|
436
|
+
.danger-zone
|
437
|
+
background: url(asset_path('spina/danger-zone-ribbon.png', 'image')) repeat-x #fcfcfc
|
438
|
+
margin: 60px -40px 0 -40px
|
439
|
+
padding: 26px 40px
|
440
|
+
|
441
|
+
h2
|
442
|
+
color: #777
|
443
|
+
font-size: 16px
|
444
|
+
font-weight: 600
|
445
|
+
|
446
|
+
&:before
|
447
|
+
margin-right: 6px
|
448
|
+
vertical-align: middle
|
449
|
+
|
450
|
+
// Breadcrumbs
|
451
|
+
|
452
|
+
#main_content_header
|
453
|
+
min-height: 50px
|
454
|
+
|
455
|
+
@include media($tablet)
|
456
|
+
.button
|
457
|
+
overflow: hidden
|
458
|
+
height: 32px
|
459
|
+
width: 35px
|
460
|
+
|
461
|
+
&:before
|
462
|
+
margin-right: 200px
|
463
|
+
|
464
|
+
.breadcrumbs
|
465
|
+
color: #333
|
466
|
+
font-size: 24px
|
467
|
+
font-weight: 300
|
468
|
+
|
469
|
+
a
|
470
|
+
color: #999
|
471
|
+
|
472
|
+
@include media($tablet)
|
473
|
+
display: none
|
474
|
+
|
475
|
+
.divider
|
476
|
+
background: url(asset_path('spina/divider.png', 'image'))
|
477
|
+
color: #999
|
478
|
+
display: inline-block
|
479
|
+
height: 17px
|
480
|
+
margin: 0 20px
|
481
|
+
width: 6px
|
482
|
+
|
483
|
+
@include media($tablet)
|
484
|
+
display: none
|
485
|
+
|
486
|
+
// General styles
|
487
|
+
|
488
|
+
h1, h2, h3, h4, h5, h6
|
489
|
+
font-weight: 300
|
490
|
+
margin: 0
|
491
|
+
|
492
|
+
h1, h2
|
493
|
+
color: #333
|
494
|
+
font-size: 24px
|
495
|
+
|
496
|
+
ul
|
497
|
+
list-style: none
|
498
|
+
margin: 0
|
499
|
+
padding: 0
|
500
|
+
|
501
|
+
p
|
502
|
+
color: #333
|
503
|
+
font-size: 14px
|
504
|
+
line-height: 18px
|
505
|
+
|
506
|
+
a
|
507
|
+
color: $primary-color
|
508
|
+
text-decoration: none
|
509
|
+
|
510
|
+
label
|
511
|
+
color: #333
|
512
|
+
font-size: 11px
|
513
|
+
font-weight: 600
|
514
|
+
margin-right: 14px
|
515
|
+
text-transform: uppercase
|
516
|
+
|
517
|
+
.pull-left
|
518
|
+
float: left
|
519
|
+
|
520
|
+
.pull-right
|
521
|
+
float: right
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spina/template/version"
|
2
|
+
require 'bourbon'
|
3
|
+
require 'neat'
|
4
|
+
require 'jquery-fileupload-rails'
|
5
|
+
|
6
|
+
module Spina
|
7
|
+
module Template
|
8
|
+
class Engine < ::Rails::Engine
|
9
|
+
config.assets.precompile += %w(spina/wysihtml5_textarea.css)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
require 'spina/template/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "spina-template"
|
8
|
+
spec.version = Spina::Template::VERSION
|
9
|
+
spec.authors = ["Bram Jetten"]
|
10
|
+
spec.email = ["bram@denkgroot.com"]
|
11
|
+
spec.description = "Template"
|
12
|
+
spec.summary = "Spina"
|
13
|
+
spec.homepage = "http://www.denkgroot.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
|
22
|
+
spec.add_dependency "bourbon", "~> 3.2.1"
|
23
|
+
spec.add_dependency "neat", "~> 1.5.0"
|
24
|
+
spec.add_dependency "coffee-rails"
|
25
|
+
spec.add_dependency 'jquery-fileupload-rails'
|
26
|
+
end
|
data/vendor/.DS_Store
ADDED
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,85 @@
|
|
1
|
+
/**
|
2
|
+
* --------------------------------------------------------------------
|
3
|
+
* jQuery customfileinput plugin
|
4
|
+
* Author: Scott Jehl, scott@filamentgroup.com
|
5
|
+
* Copyright (c) 2009 Filament Group
|
6
|
+
* licensed under MIT (filamentgroup.com/examples/mit-license.txt)
|
7
|
+
* --------------------------------------------------------------------
|
8
|
+
*/
|
9
|
+
$.fn.customFileInput = function(){
|
10
|
+
//apply events and styles for file input element
|
11
|
+
var fileInput = $(this)
|
12
|
+
.addClass('customfile-input') //add class for CSS
|
13
|
+
.mouseover(function(){ upload.addClass('customfile-hover'); })
|
14
|
+
.mouseout(function(){ upload.removeClass('customfile-hover'); })
|
15
|
+
.focus(function(){
|
16
|
+
upload.addClass('customfile-focus');
|
17
|
+
fileInput.data('val', fileInput.val());
|
18
|
+
})
|
19
|
+
.blur(function(){
|
20
|
+
upload.removeClass('customfile-focus');
|
21
|
+
$(this).trigger('checkChange');
|
22
|
+
})
|
23
|
+
.bind('disable',function(){
|
24
|
+
fileInput.attr('disabled',true);
|
25
|
+
upload.addClass('customfile-disabled');
|
26
|
+
})
|
27
|
+
.bind('enable',function(){
|
28
|
+
fileInput.removeAttr('disabled');
|
29
|
+
upload.removeClass('customfile-disabled');
|
30
|
+
})
|
31
|
+
.bind('checkChange', function(){
|
32
|
+
if(fileInput.val() && fileInput.val() != fileInput.data('val')){
|
33
|
+
fileInput.trigger('change');
|
34
|
+
}
|
35
|
+
})
|
36
|
+
.bind('change',function(){
|
37
|
+
//get file name
|
38
|
+
var fileName = $(this).val().split(/\\/).pop();
|
39
|
+
//get file extension
|
40
|
+
var fileExt = 'customfile-ext-' + fileName.split('.').pop().toLowerCase();
|
41
|
+
//update the feedback
|
42
|
+
uploadFeedback
|
43
|
+
.text(fileName) //set feedback text to filename
|
44
|
+
.removeClass(uploadFeedback.data('fileExt') || '') //remove any existing file extension class
|
45
|
+
.addClass(fileExt) //add file extension class
|
46
|
+
.data('fileExt', fileExt) //store file extension for class removal on next change
|
47
|
+
.addClass('customfile-feedback-populated'); //add class to show populated state
|
48
|
+
//change text of button
|
49
|
+
uploadButton.text('Kies een bestand');
|
50
|
+
})
|
51
|
+
.click(function(){ //for IE and Opera, make sure change fires after choosing a file, using an async callback
|
52
|
+
fileInput.data('val', fileInput.val());
|
53
|
+
setTimeout(function(){
|
54
|
+
fileInput.trigger('checkChange');
|
55
|
+
},100);
|
56
|
+
});
|
57
|
+
|
58
|
+
//create custom control container
|
59
|
+
var upload = $('<div class="customfile"></div>');
|
60
|
+
//create custom control button
|
61
|
+
var uploadButton = $('<span class="customfile-button" aria-hidden="true">voeg foto toe</span>').appendTo(upload);
|
62
|
+
//create custom control feedback
|
63
|
+
var uploadFeedback = $('<span class="customfile-feedback" aria-hidden="true">Geen bestand geselecteerd...</span>').appendTo(upload);
|
64
|
+
|
65
|
+
//match disabled state
|
66
|
+
if(fileInput.is('[disabled]')){
|
67
|
+
fileInput.trigger('disable');
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
//on mousemove, keep file input under the cursor to steal click
|
72
|
+
upload
|
73
|
+
.mousemove(function(e){
|
74
|
+
fileInput.css({
|
75
|
+
'left': e.pageX - upload.offset().left - fileInput.outerWidth() + 20, //position right side 20px right of cursor X)
|
76
|
+
'top': e.pageY - upload.offset().top - $(window).scrollTop() - 3
|
77
|
+
});
|
78
|
+
})
|
79
|
+
.insertAfter(fileInput); //insert after the input
|
80
|
+
|
81
|
+
fileInput.appendTo(upload);
|
82
|
+
|
83
|
+
//return jQuery
|
84
|
+
return $(this);
|
85
|
+
};
|