oxen_media 0.0.6 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/components/dropzone.js.jsx.coffee +298 -0
- data/app/assets/javascripts/components/photocard.js.jsx.coffee +77 -0
- data/app/assets/javascripts/components/photos.js.jsx.coffee +68 -0
- data/app/assets/javascripts/oxen_media.js +1 -3
- data/app/assets/stylesheets/oxen_media/drop_zone.css +86 -0
- data/app/assets/stylesheets/oxen_media.css +3 -0
- data/app/controllers/photos_controller.rb +26 -0
- data/app/models/ox_photo.rb +17 -0
- data/app/policies/ox_photo_policy.rb +3 -0
- data/app/uploaders/photo_uploader.rb +53 -0
- data/app/views/photos/_photo.html.haml +11 -0
- data/app/views/photos/create.js.haml +1 -0
- data/app/views/photos/index.json.jbuilder +5 -0
- data/lib/oxen_media/version.rb +1 -1
- data/lib/oxen_media.rb +1 -1
- data/oxen_media.gemspec +4 -4
- metadata +15 -86
- data/app/assets/javascripts/jsrender.min.js +0 -4
- data/app/assets/javascripts/jsrender.min.js.map +0 -463
- data/app/assets/javascripts/oxen_media/carrier_wave_cropper.js.coffee +0 -22
- data/app/assets/javascripts/oxen_media/media.js.coffee +0 -469
- data/app/assets/javascripts/oxen_media/medium_pane.js.coffee +0 -107
- data/app/assets/javascripts/templates/selected_files.html +0 -35
- data/app/assets/stylesheets/media.css +0 -10
- data/app/assets/stylesheets/scaffold.css +0 -56
- data/app/controllers/media_controller.rb +0 -106
- data/app/helpers/media_helper.rb +0 -2
- data/app/models/medium.rb +0 -25
- data/app/policies/oxen_medium_policy.rb +0 -12
- data/app/uploaders/medium_uploader.rb +0 -153
- data/app/views/media/_fields.html.haml +0 -42
- data/app/views/media/_form.html.haml +0 -48
- data/app/views/media/_media.html.haml +0 -18
- data/app/views/media/_medium.html.haml +0 -25
- data/app/views/media/_medium_fields.html.haml +0 -4
- data/app/views/media/create.js.haml +0 -2
- data/app/views/media/crop.html.haml +0 -3
- data/app/views/media/edit.html.haml +0 -2
- data/app/views/media/index.html.haml +0 -29
- data/app/views/media/index.json.jbuilder +0 -4
- data/app/views/media/new.html.erb +0 -5
- data/app/views/media/show.html.haml +0 -21
- data/app/views/media/show.json.jbuilder +0 -1
- data/app/views/media/update_crop.js.haml +0 -1
- /data/app/assets/javascripts/{oxen_media/.keep → components/.gitkeep} +0 -0
@@ -1,22 +0,0 @@
|
|
1
|
-
class CarrierWaveCropperClass
|
2
|
-
constructor: ->
|
3
|
-
$('#medium_medium_cropbox').Jcrop
|
4
|
-
setSelect: [0, 0, 200, 200]
|
5
|
-
onSelect: @update
|
6
|
-
onChange: @update
|
7
|
-
|
8
|
-
update: (coords) =>
|
9
|
-
$('#medium_medium_crop_x').val(coords.x)
|
10
|
-
$('#medium_medium_crop_y').val(coords.y)
|
11
|
-
$('#medium_medium_crop_w').val(coords.w)
|
12
|
-
$('#medium_medium_crop_h').val(coords.h)
|
13
|
-
@updatePreview(coords)
|
14
|
-
|
15
|
-
updatePreview: (coords) =>
|
16
|
-
$('#medium_medium_previewbox').css
|
17
|
-
width: Math.round(100/coords.w * $('#medium_medium_cropbox').width()) + 'px'
|
18
|
-
height: Math.round(100/coords.h * $('#medium_medium_cropbox').height()) + 'px'
|
19
|
-
marginLeft: '-' + Math.round(100/coords.w * coords.x) + 'px'
|
20
|
-
marginTop: '-' + Math.round(100/coords.h * coords.y) + 'px'
|
21
|
-
|
22
|
-
@CarrierWaveCropper = CarrierWaveCropperClass
|
@@ -1,469 +0,0 @@
|
|
1
|
-
# Place all the behaviors and hooks related to the matching controller here.
|
2
|
-
# All this logic will automatically be available in application.js.
|
3
|
-
# You can use CoffeeScript in this file: http://coffeescript.org/
|
4
|
-
class MediumClass
|
5
|
-
|
6
|
-
constructor: (@dropbox_element='.dropbox') ->
|
7
|
-
@filesForUpload = new Array
|
8
|
-
@all_files = 0
|
9
|
-
@uploaded_files = 0
|
10
|
-
@dropbox = $(@dropbox_element)
|
11
|
-
|
12
|
-
initializeBindings: (dragdrop=document) ->
|
13
|
-
@unBinds()
|
14
|
-
@doBinds()
|
15
|
-
|
16
|
-
#
|
17
|
-
# first unbind clicks
|
18
|
-
unBinds: () ->
|
19
|
-
$(document.body).unbind('click.media_start')
|
20
|
-
$(document.body).unbind('click.media_delete')
|
21
|
-
$(document.body).unbind('drop.media')
|
22
|
-
$(document.body).unbind('click.media_pick')
|
23
|
-
|
24
|
-
# draggable
|
25
|
-
$(document.body).unbind("dragleave.media")
|
26
|
-
$(document.body).unbind("dragover.media")
|
27
|
-
$(document.body).unbind("drop.media")
|
28
|
-
$(document.body).unbind("drag.media")
|
29
|
-
$(document.body).unbind("dragenter.media")
|
30
|
-
$(document.body).unbind('change.media')
|
31
|
-
|
32
|
-
$(document.body).unbind('click.preventDefaultClick')
|
33
|
-
$(document.body).unbind('click.cropFile')
|
34
|
-
$(document.body).unbind('click.uploadFile')
|
35
|
-
$(document.body).unbind('click.deleteFile')
|
36
|
-
$(document.body).unbind('click.toggleCardReveal')
|
37
|
-
$(document.body).unbind('click.clickMediumInput')
|
38
|
-
|
39
|
-
# @dropbox.unbind('click.media_cancel')
|
40
|
-
# $(document.body).unbind('click.cancelFile')
|
41
|
-
|
42
|
-
|
43
|
-
#
|
44
|
-
# bind clicks
|
45
|
-
doBinds: () ->
|
46
|
-
$(document.body).on 'click.media_show', '.edit_link', @show_media
|
47
|
-
$(document.body).on 'click.media_start', 'span.btn.hover_green.start', @uploadFile
|
48
|
-
$(document.body).on 'click.media_delete', 'span.btn.delete', @deleteFile
|
49
|
-
$(document.body).on 'click.clickMediumInput', '.fileinput-button', @clickMediumInput
|
50
|
-
$(document.body).on 'click.preventDefaultClick', '.fileinput-button, a.file-upload', @preventDefaultClick
|
51
|
-
$(document.body).on 'click.cropFile', 'a.edit_link.file-upload', @cropFile
|
52
|
-
$(document.body).on 'click.uploadFile', 'a.start.file-upload', @uploadFile
|
53
|
-
$(document.body).on 'click.deleteFile', 'a.delete.file-upload', @deleteFile
|
54
|
-
$(document.body).on 'click.toggleCardReveal', '.card_properties', @toggleCardReveal
|
55
|
-
|
56
|
-
$(document.body).on "drag.media", @dropbox_element, @dragMedia
|
57
|
-
$(document.body).on "dragenter.media", @dropbox_element, @dragEnterMedia
|
58
|
-
$(document.body).on "dragleave.media", @dropbox_element, @dragLeaveMedia
|
59
|
-
$(document.body).on "dragover.media", @dropbox_element, @dragOverMedia
|
60
|
-
$(document.body).on "drop.media", @dropbox_element, @dropMedia
|
61
|
-
$(document.body).on 'change.media', '#medium_medium', @updateSelectedFiles
|
62
|
-
|
63
|
-
# $(document.body).on 'click.cancelFile', 'a.cancel.file-upload', @cancelFile
|
64
|
-
# $(document.body).on 'click.media_cancel', 'span.btn.hover_yellow.cancel', @cancelUploading
|
65
|
-
|
66
|
-
preventDefaultClick: (e) ->
|
67
|
-
e.preventDefault()
|
68
|
-
e.stopPropagation()
|
69
|
-
|
70
|
-
toggleCardReveal: (e) =>
|
71
|
-
@preventDefaultClick(e)
|
72
|
-
$(e.currentTarget).closest('.card').find('.card-reveal').toggle()
|
73
|
-
|
74
|
-
clickMediumInput: (e) =>
|
75
|
-
@preventDefaultClick()
|
76
|
-
$('#medium_medium').click()
|
77
|
-
|
78
|
-
dragEnterMedia: (e) =>
|
79
|
-
@preventDefaultClick(e)
|
80
|
-
|
81
|
-
dragMedia: (e) =>
|
82
|
-
@preventDefaultClick(e)
|
83
|
-
# ev.dataTransfer.setData("text", ev.target.id);
|
84
|
-
|
85
|
-
dragOverMedia: (e) =>
|
86
|
-
@preventDefaultClick(e)
|
87
|
-
$(@dropbox_element).addClass('drop-ready')
|
88
|
-
|
89
|
-
dragLeaveMedia: (e) =>
|
90
|
-
@preventDefaultClick(e)
|
91
|
-
$(@dropbox_element).removeClass('drop-ready')
|
92
|
-
|
93
|
-
#
|
94
|
-
# dropMedia handles the 'drop' event
|
95
|
-
#
|
96
|
-
dropMedia: (e) =>
|
97
|
-
@preventDefaultClick(e)
|
98
|
-
# ev.preventDefault();
|
99
|
-
# var data = ev.dataTransfer.getData("text");
|
100
|
-
# ev.target.appendChild(document.getElementById(data));
|
101
|
-
|
102
|
-
$(e.currentTarget).removeClass('drop-ready')
|
103
|
-
dt = e.originalEvent.dataTransfer
|
104
|
-
files = dt.files
|
105
|
-
@handleFiles(files)
|
106
|
-
|
107
|
-
#
|
108
|
-
# show_media opens a modal window and presents the images
|
109
|
-
#
|
110
|
-
show_media: (e) =>
|
111
|
-
@preventDefaultClick(e)
|
112
|
-
$elem = $(e.currentTarget).closest('a')
|
113
|
-
_id = $elem.data('id')
|
114
|
-
url = $elem.attr('href') + '/crop.js'
|
115
|
-
$.ajax
|
116
|
-
url: url,
|
117
|
-
type: "get",
|
118
|
-
dataType: 'html'
|
119
|
-
.done (r) ->
|
120
|
-
$modal = $('#modal1')
|
121
|
-
$modal.find('.modal-content').html(r)
|
122
|
-
$modal.openModal
|
123
|
-
ready: () ->
|
124
|
-
$('a.close-modal').on 'click', (e) ->
|
125
|
-
e.preventDefault()
|
126
|
-
e.stopPropagation()
|
127
|
-
jqxhr = $.ajax
|
128
|
-
url: '/media/' + _id + '/update_crop.js'
|
129
|
-
method: 'POST'
|
130
|
-
dataType: 'html'
|
131
|
-
data:
|
132
|
-
id: _id,
|
133
|
-
medium:
|
134
|
-
medium_crop_x: $('#medium_medium_crop_x').val(),
|
135
|
-
medium_crop_y: $('#medium_medium_crop_y').val(),
|
136
|
-
medium_crop_w: $('#medium_medium_crop_w').val(),
|
137
|
-
medium_crop_h: $('#medium_medium_crop_h').val()
|
138
|
-
.fail (r) ->
|
139
|
-
console.log r
|
140
|
-
.done (r) ->
|
141
|
-
$elem.closest('.card').find('.card-image').html(r)
|
142
|
-
$modal.closeModal()
|
143
|
-
|
144
|
-
new CarrierWaveCropper()
|
145
|
-
|
146
|
-
# statusCode:
|
147
|
-
# 200: (response,textStatus,jqXHR) ->
|
148
|
-
# $modal = $('#modal1')
|
149
|
-
# $modal.find('.modal-content').html(response.responseText)
|
150
|
-
# $modal.attr('task_id', _id)
|
151
|
-
# $modal.openModal()
|
152
|
-
# set_close_event(elem)
|
153
|
-
# 401: () ->
|
154
|
-
# alert 'Du har ikke lov at se denne opgave!?!'
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
# delete all files ready for upload - or if non exists - delete all
|
159
|
-
# media attached to this object
|
160
|
-
#
|
161
|
-
deleteFile: (elem='all') =>
|
162
|
-
deleteAllFiles = elem == 'all'
|
163
|
-
if deleteAllFiles
|
164
|
-
elem = $($(@dropbox_element).find('.card.new_upload'))
|
165
|
-
if elem.length==0
|
166
|
-
$('.sweet-overlay').show()
|
167
|
-
elem = swal
|
168
|
-
title: "Ingen filer der skal overføres?",
|
169
|
-
text: "Vil du istedet slette alle tilknyttede medier, vist herunder permanent! Du vil ikke kunne hente dem frem igen!",
|
170
|
-
type: "warning",
|
171
|
-
html: true,
|
172
|
-
showCancelButton: true,
|
173
|
-
confirmButtonColor: "#DD6B55",
|
174
|
-
confirmButtonText: "Ja, slet dem!",
|
175
|
-
cancelButtonText: "Nej - jeg har fortrudt!"
|
176
|
-
closeOnConfirm: false,
|
177
|
-
closeOnCancel: false,
|
178
|
-
(confirmed) ->
|
179
|
-
if confirmed
|
180
|
-
elem= $('#media').find('.delete_link:visible')
|
181
|
-
elem.push(e) for e in $('.files').find('.delete_link:visible')
|
182
|
-
for f in elem
|
183
|
-
deletePost $(f)
|
184
|
-
f.remove()
|
185
|
-
else
|
186
|
-
elem = []
|
187
|
-
closeSweetAlert()
|
188
|
-
elem
|
189
|
-
else
|
190
|
-
for f in elem
|
191
|
-
f.remove()
|
192
|
-
@filesForUpload = new Array
|
193
|
-
else
|
194
|
-
elem = elem.currentTarget
|
195
|
-
elem = $(elem).closest('.card')[0]
|
196
|
-
img = $(elem).find('img')[0]
|
197
|
-
if img
|
198
|
-
for card in $('.files .new_upload') #$($(@dropbox_element).find('.card.new_upload'))
|
199
|
-
if card==elem
|
200
|
-
tmp = @filesForUpload.slice()
|
201
|
-
for f in tmp
|
202
|
-
if ''+f.id == ''+img.id
|
203
|
-
@filesForUpload.splice( @filesForUpload.indexOf(f),1)
|
204
|
-
elem.remove()
|
205
|
-
|
206
|
-
showProgress: (card,percent,direction) ->
|
207
|
-
card.find(".progress.fileupload-progress").show()
|
208
|
-
card.find(".progress.fileupload-progress .determinate").css('width',percent)
|
209
|
-
|
210
|
-
# prepare upload for one file
|
211
|
-
# setup eventListeners
|
212
|
-
# before, during and after upload has completed
|
213
|
-
#
|
214
|
-
ajx: (_card, formData) =>
|
215
|
-
deferred = $.Deferred()
|
216
|
-
jqxhr = $.ajax
|
217
|
-
url : '/media.js'
|
218
|
-
type : 'POST'
|
219
|
-
data : formData
|
220
|
-
processData: false
|
221
|
-
contentType: false
|
222
|
-
dataType: 'html'
|
223
|
-
beforeSend: (req) =>
|
224
|
-
_card.find('.progress').show()
|
225
|
-
xhr: () =>
|
226
|
-
xhr = new window.XMLHttpRequest()
|
227
|
-
# Upload progress
|
228
|
-
xhr.upload.addEventListener "progress", (e) =>
|
229
|
-
# console.log 'progressing with upload'
|
230
|
-
if e.lengthComputable
|
231
|
-
percent = Math.round( e.loaded * 100 / e.total) + '%'
|
232
|
-
@showProgress _card,percent,'uploaded'
|
233
|
-
# console.log( percent + ' uploaded')
|
234
|
-
|
235
|
-
# Download progress
|
236
|
-
xhr.addEventListener "progress", (e) =>
|
237
|
-
# console.log 'progressing with download'
|
238
|
-
if (e.lengthComputable)
|
239
|
-
percent = (e.loaded * 100 / e.total) + '%'
|
240
|
-
@showProgress _card,percent,'downloaded'
|
241
|
-
# console.log( percent + ' downloaded')
|
242
|
-
xhr
|
243
|
-
|
244
|
-
.done (r) =>
|
245
|
-
$.when _card.remove()
|
246
|
-
.done () =>
|
247
|
-
@uploaded_files += 1
|
248
|
-
percent = Math.round( @uploaded_files * 100 / @all_files ) + '%'
|
249
|
-
@showProgress $('.fileupload-buttonbar'), percent, 'uploaded'
|
250
|
-
$('#media').prepend r
|
251
|
-
.then () =>
|
252
|
-
console.log 'ajx resolved ---'
|
253
|
-
deferred.resolve()
|
254
|
-
|
255
|
-
.fail (e,msg) =>
|
256
|
-
swal "Fejl!", "Der opstod desværre en fejl - beskrivelsen er:\n" + msg, "error"
|
257
|
-
deferred.resolve()
|
258
|
-
|
259
|
-
deferred.promise()
|
260
|
-
|
261
|
-
#
|
262
|
-
# collect and prepare all files ready for upload
|
263
|
-
# defer xfer files
|
264
|
-
#
|
265
|
-
xfer: (formData,img,uploadAllFiles) =>
|
266
|
-
deferred = $.Deferred()
|
267
|
-
_processes = []
|
268
|
-
if uploadAllFiles
|
269
|
-
@uploaded_files = 0
|
270
|
-
@all_files = $('.files .new_upload').length
|
271
|
-
while @filesForUpload.length>0
|
272
|
-
try
|
273
|
-
f = @filesForUpload.pop()
|
274
|
-
_card = $($('#'+ f.id).closest('.card:visible'))
|
275
|
-
if _card
|
276
|
-
formData.append 'medium[medium]', f
|
277
|
-
_processes.push( @ajx(_card,formData))
|
278
|
-
catch err
|
279
|
-
console.log err
|
280
|
-
|
281
|
-
$.when.apply $, _processes
|
282
|
-
.done () ->
|
283
|
-
console.log 'xfer resolved ---'
|
284
|
-
deferred.resolve()
|
285
|
-
|
286
|
-
else
|
287
|
-
@all_files = 1
|
288
|
-
console.log 'filesForUpload: ' + @filesForUpload
|
289
|
-
tmp = @filesForUpload.slice()
|
290
|
-
console.log '# of files: ' + tmp.length
|
291
|
-
console.log 'tmp: ' + tmp
|
292
|
-
while tmp.length > 0
|
293
|
-
f = tmp.pop()
|
294
|
-
console.log 'f: ' + f
|
295
|
-
try
|
296
|
-
if (''+f.id)==(''+img.id)
|
297
|
-
console.log 'hit: ' + f
|
298
|
-
@filesForUpload.splice( @filesForUpload.indexOf(f),1)
|
299
|
-
console.log '# of filesForUpload: ' + @filesForUpload.length
|
300
|
-
_card = $($('#'+ f.id).closest('.card'))
|
301
|
-
formData.append 'medium[medium]', f
|
302
|
-
_processes.push( @ajx(_card,formData))
|
303
|
-
catch err
|
304
|
-
console.log f
|
305
|
-
console.log img
|
306
|
-
|
307
|
-
$.when.apply $, _processes
|
308
|
-
.done () ->
|
309
|
-
deferred.resolve()
|
310
|
-
|
311
|
-
deferred.promise()
|
312
|
-
|
313
|
-
|
314
|
-
uploadFile: (elem='all') =>
|
315
|
-
formData = new FormData()
|
316
|
-
uploadAllFiles = elem == 'all'
|
317
|
-
if uploadAllFiles
|
318
|
-
elem = $('.files .new_upload')
|
319
|
-
return if $('.files .new_upload').length < 1
|
320
|
-
else
|
321
|
-
$elem = $(elem.currentTarget)
|
322
|
-
img = $elem.closest('.card').find('img')[0]
|
323
|
-
_id = $elem.closest(@dropbox_element).find('#medium_imageable_id').val()
|
324
|
-
_type = $elem.closest(@dropbox_element).find('#medium_imageable_type').val()
|
325
|
-
if img
|
326
|
-
formData.append 'medium[imageable_id]', _id
|
327
|
-
formData.append 'medium[imageable_type]', _type
|
328
|
-
$.when @xfer(formData,img,uploadAllFiles)
|
329
|
-
.done () =>
|
330
|
-
# console.log 'uploadFile will move on --'
|
331
|
-
$('.fileupload-buttonbar .fileupload-progress').hide()
|
332
|
-
|
333
|
-
|
334
|
-
updateSelectedFiles: (elem) =>
|
335
|
-
# nBytes = 0
|
336
|
-
elem = e.currentTarget
|
337
|
-
oFiles = $(elem)[0].files
|
338
|
-
console.log oFiles
|
339
|
-
# nFiles = oFiles.length
|
340
|
-
# nBytes += v.size for v in oFiles
|
341
|
-
#
|
342
|
-
# sOutput = nBytes + " bytes"
|
343
|
-
# nApprox = nBytes / 1024
|
344
|
-
# aMultiples = ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]
|
345
|
-
# nMultiple = 0
|
346
|
-
# nApprox /= 1024
|
347
|
-
# nMultiple = while nApprox > 1.0
|
348
|
-
# console.log nApprox + ' ' + nMultiple
|
349
|
-
# nApprox /= 1024
|
350
|
-
# nMultiple += 1
|
351
|
-
#
|
352
|
-
# sOutput = nApprox.toFixed(3) + " " + aMultiples[nMultiple] + " (" + nBytes + " bytes)"
|
353
|
-
#
|
354
|
-
# $(".fileNum").html nFiles + ' filer'
|
355
|
-
# $(".fileSize").html sOutput
|
356
|
-
# $('.files').html tmpl('uploads',data)
|
357
|
-
@handleFiles(oFiles)
|
358
|
-
|
359
|
-
lazyGetTemplate: (name) =>
|
360
|
-
deferred = $.Deferred()
|
361
|
-
|
362
|
-
if $.templates[name]
|
363
|
-
deferred.resolve()
|
364
|
-
else
|
365
|
-
$.get "/assets/templates/" + name + ".html"
|
366
|
-
.fail (r,msg) ->
|
367
|
-
if r.status==200
|
368
|
-
$.templates(name,r.responseText)
|
369
|
-
deferred.resolve()
|
370
|
-
else
|
371
|
-
swal 'Fejl', 'Der opstod en fejl! Ordlyden er:\n ' + msg + '\n' + r.status + ': ' + r.statusText + '\n kontakt ALCO på tlf: 9791 1470!', "error"
|
372
|
-
.done (r) ->
|
373
|
-
$.templates(name,r)
|
374
|
-
if $.templates[name]
|
375
|
-
deferred.resolve()
|
376
|
-
else
|
377
|
-
swal "Fejl", "Der opstod en fejl under hentningen af en skabelon til billed visning! Kontakt ALCO på tlf: 9791 1470", "error"
|
378
|
-
deferred.reject()
|
379
|
-
|
380
|
-
return deferred.promise()
|
381
|
-
|
382
|
-
|
383
|
-
handleFiles: (f) =>
|
384
|
-
$.when( @lazyGetTemplate('selected_files'))
|
385
|
-
.done () =>
|
386
|
-
for file in f
|
387
|
-
imageType = /^image\//
|
388
|
-
|
389
|
-
# if (!imageType.test(file.type))
|
390
|
-
# continue
|
391
|
-
|
392
|
-
file.id = Date.now()
|
393
|
-
$.when $('.files').prepend $.templates.selected_files.render(file)
|
394
|
-
.done () ->
|
395
|
-
img = $('#'+file.id)
|
396
|
-
img.file = file
|
397
|
-
if (!imageType.test(file.type))
|
398
|
-
src = switch
|
399
|
-
when /application.*pdf/.exec file.type then '/assets/2.jpg'
|
400
|
-
when /mp4/.exec file.type then '/assets/2.jpg'
|
401
|
-
when /applica.*sql/.exec file.type then '/assets/2.jpg'
|
402
|
-
when /applica.*zip/.exec file.type then '/assets/2.jpg'
|
403
|
-
when /applica.*csv/.exec file.type then '/assets/2.jpg'
|
404
|
-
when /applica.*sheet/.exec file.type then '/assets/2.jpg'
|
405
|
-
when /applica.*document/.exec file.type then '/assets/2.jpg'
|
406
|
-
else "#{ image_url('logo.png') }"
|
407
|
-
console.log 'src: ' + src
|
408
|
-
$(img).attr('src', src )
|
409
|
-
else
|
410
|
-
reader = new FileReader()
|
411
|
-
reader.onload = (e) ->
|
412
|
-
$(img).attr('src', e.target.result)
|
413
|
-
reader.readAsDataURL(file)
|
414
|
-
|
415
|
-
@filesForUpload.push(file)
|
416
|
-
|
417
|
-
freshImageSrcPattern = /// ^
|
418
|
-
data
|
419
|
-
.* ///i
|
420
|
-
|
421
|
-
cropFile: (e) =>
|
422
|
-
@preventDefaultClick(e)
|
423
|
-
$elem = $(e.currentTarget)
|
424
|
-
img = $elem.closest('.card').find('img')[0]
|
425
|
-
if $(img).attr('src').match freshImageSrcPattern
|
426
|
-
$('#medium_medium_cropbox').attr('src',$(img).attr('src'))
|
427
|
-
$modal = $('#modal1')
|
428
|
-
$modal.openModal
|
429
|
-
new CarrierWaveCropper()
|
430
|
-
else
|
431
|
-
# _edit = "/crop"
|
432
|
-
# _id = "0"
|
433
|
-
# url = '/media/' + _id + _edit + '.js'
|
434
|
-
jqxhr = $.ajax
|
435
|
-
url: $(elem).attr('href') + '/edit.js',
|
436
|
-
type: "get",
|
437
|
-
data:
|
438
|
-
id: _id,
|
439
|
-
dataType: 'html'
|
440
|
-
.fail (r) ->
|
441
|
-
console.log r
|
442
|
-
.done (r) ->
|
443
|
-
$modal = $('#modal1')
|
444
|
-
$('.modal-content').html(r)
|
445
|
-
$modal.openModal
|
446
|
-
ready: () ->
|
447
|
-
$('.close-modal').on 'click', (e) ->
|
448
|
-
e.preventDefault()
|
449
|
-
$.ajax
|
450
|
-
url: '/media/' + _id + '/update_crop.js'
|
451
|
-
method: 'POST'
|
452
|
-
data:
|
453
|
-
id: _id,
|
454
|
-
medium:
|
455
|
-
medium_crop_x: $('#medium_medium_crop_x').val(),
|
456
|
-
medium_crop_y: $('#medium_medium_crop_y').val(),
|
457
|
-
medium_crop_w: $('#medium_medium_crop_w').val(),
|
458
|
-
medium_crop_h: $('#medium_medium_crop_h').val()
|
459
|
-
.fail (r) ->
|
460
|
-
console.log r
|
461
|
-
.done (r) ->
|
462
|
-
$modal.closeModal()
|
463
|
-
|
464
|
-
new CarrierWaveCropper()
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
@Medium = MediumClass
|
@@ -1,107 +0,0 @@
|
|
1
|
-
class MediumPaneClass
|
2
|
-
|
3
|
-
constructor: (@list, @loader='span.medium-loader') ->
|
4
|
-
@media = []
|
5
|
-
|
6
|
-
listFile: (template,data,selector) ->
|
7
|
-
$.tmpl(template, data).prependTo(selector)
|
8
|
-
|
9
|
-
#
|
10
|
-
# set Buttons
|
11
|
-
#
|
12
|
-
setButtons: (c) ->
|
13
|
-
@setNewLink(c)
|
14
|
-
@setLinks(c)
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
# set links for Uri, and current Contact
|
19
|
-
#
|
20
|
-
setFormLinks: (self) ->
|
21
|
-
@setCancel(self)
|
22
|
-
@setSave(self)
|
23
|
-
|
24
|
-
|
25
|
-
setCancel: (self) ->
|
26
|
-
me=self
|
27
|
-
$('.cancel_medium').on 'click', () ->
|
28
|
-
$(me.list + ' .medium-form').remove()
|
29
|
-
|
30
|
-
setNewLink: (self) ->
|
31
|
-
me=self
|
32
|
-
try
|
33
|
-
me=self
|
34
|
-
$('a.new_medium').on 'click', (e) ->
|
35
|
-
e.preventDefault()
|
36
|
-
e.stopPropagation()
|
37
|
-
setLoader $(me.loader)
|
38
|
-
url = $(this).attr('href') + '?scope=' + me.list.replace('#','')
|
39
|
-
|
40
|
-
$.ajax
|
41
|
-
url: url,
|
42
|
-
type: 'GET'
|
43
|
-
success: (data, textStatus, jqXHR) ->
|
44
|
-
releaseLoader $(me.loader)
|
45
|
-
$(me.list).prepend(data)
|
46
|
-
error: (jqXHR, textStatus, errorThrown) ->
|
47
|
-
releaseLoader $(me.loader)
|
48
|
-
swal 'Fejl!!', textStatus, 'error'
|
49
|
-
catch e
|
50
|
-
console.log e
|
51
|
-
|
52
|
-
|
53
|
-
setLinks: (self) ->
|
54
|
-
try
|
55
|
-
me=self
|
56
|
-
$(".medium.collection-item i.circle").on 'click', (e) ->
|
57
|
-
setLoader $(me.loader)
|
58
|
-
elem = $(this).closest('li')
|
59
|
-
_id = elem.data('id')
|
60
|
-
$.ajax
|
61
|
-
url: '/uris/' + _id + '/edit?scope='+me.list.replace('#',''),
|
62
|
-
type: 'GET'
|
63
|
-
success: (data, textStatus, jqXHR) ->
|
64
|
-
releaseLoader $(me.loader)
|
65
|
-
$(me.list).prepend(data)
|
66
|
-
error: (jqXHR, textStatus, errorThrown) ->
|
67
|
-
releaseLoader $(me.loader)
|
68
|
-
swal 'Fejl!!',textStatus, 'error'
|
69
|
-
catch e
|
70
|
-
console.log e
|
71
|
-
|
72
|
-
setSave: (self) ->
|
73
|
-
me=self
|
74
|
-
$('.save_medium').on 'click', () ->
|
75
|
-
setLoader $(me.loader)
|
76
|
-
elem = $(this).closest('form')
|
77
|
-
type = elem.attr('method')
|
78
|
-
url = elem.attr('action')
|
79
|
-
if elem.attr('id')=='new_medium'
|
80
|
-
elem= $(me.list + ' ul.collection')
|
81
|
-
else
|
82
|
-
elem=$('#' + url.replace('/media/','medium-'))
|
83
|
-
url = url + '.js'
|
84
|
-
#type = "#{params[:action]=='edit' ? 'PUT' : 'POST'}"
|
85
|
-
$inputs = $(this).closest('form').find "input, select, button, textarea"
|
86
|
-
serializedData = $inputs.serialize()
|
87
|
-
|
88
|
-
$.ajax
|
89
|
-
url: url
|
90
|
-
type: type
|
91
|
-
data: serializedData
|
92
|
-
statusCode:
|
93
|
-
200: (response,textStatus,jqXHR) ->
|
94
|
-
releaseLoader $(me.loader)
|
95
|
-
console.log elem
|
96
|
-
console.log me.list
|
97
|
-
if $(me.list + ' form').attr('id')=='new_medium'
|
98
|
-
elem.prepend(response.responseText)
|
99
|
-
else
|
100
|
-
elem.replaceWith(response.responseText)
|
101
|
-
$(me.list + ' .uri-form').remove()
|
102
|
-
me.setLinks(me)
|
103
|
-
301: (response,textStatus,jqXHR) ->
|
104
|
-
$('body').append "301 response to AJAX call: #{response}"
|
105
|
-
|
106
|
-
|
107
|
-
@MediumPane = MediumPaneClass
|
@@ -1,35 +0,0 @@
|
|
1
|
-
<div class="col s4">
|
2
|
-
<div class="card small new_upload" id="" data="" >
|
3
|
-
<div class="card-image new_upload waves-effect waves-block waves-light">
|
4
|
-
<img id="{{:id}}" src="" class="activator">
|
5
|
-
<input name="media[{{:id}}][file]" type="file" style="display:none" />
|
6
|
-
</div>
|
7
|
-
<div class="card-action">
|
8
|
-
<div class="progress fileupload-progress fade" style="display:none"><div class="determinate" style:"width:0%;"></div></div>
|
9
|
-
<div class="row">
|
10
|
-
<div class="col s12">
|
11
|
-
<!-- <i class="material-icons activator right" style="margin-top: 6px; margin-top: 5px">mort_vert</i> -->
|
12
|
-
<!-- <strong class="error text-danger"></strong> -->
|
13
|
-
<!-- <a class="edit_link file-upload" href="#!">
|
14
|
-
<i class="material-icons edit green-text">mode_edit</i>
|
15
|
-
</a> -->
|
16
|
-
<a class="start file-upload" href="#!">
|
17
|
-
<i class="material-icons file_upload green-text">file_upload</i>
|
18
|
-
</a>
|
19
|
-
<!-- <a class="cancel file-upload" href="#!">
|
20
|
-
<i class="material-icons cancel orange-text">cancel</i>
|
21
|
-
</a> -->
|
22
|
-
<a class="delete file-upload" href="#!">
|
23
|
-
<i class="material-icons delete red-text">delete</i>
|
24
|
-
</a>
|
25
|
-
</div>
|
26
|
-
</div>
|
27
|
-
</div>
|
28
|
-
<div class="card-reveal">
|
29
|
-
<span class="card-title grey-text text-darken-4">Billed egenskaber<i class="material-icons right">close</i></span>
|
30
|
-
<p><span class="card-title grey-text text-darken-4">{{:name}}</span></p>
|
31
|
-
<p><input class="string optional" name="media[{{:id}}][name]" placeholder="Titel" /></p>
|
32
|
-
<p><textarea class="text optional materialize-textarea" name="media[{{:id}}][description]" placeholder="Beskrivelse" /></p>
|
33
|
-
</div>
|
34
|
-
</div>
|
35
|
-
</div>
|
@@ -1,10 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Place all the styles related to the matching controller here.
|
3
|
-
They will automatically be included in application.css.
|
4
|
-
*/
|
5
|
-
*= require jquery.jcrop
|
6
|
-
/*
|
7
|
-
@media only screen (min-width : 971px) and (max-width : 600px) {
|
8
|
-
.card.small { height: 180px}
|
9
|
-
span.card-title { display:none}
|
10
|
-
}*/
|
@@ -1,56 +0,0 @@
|
|
1
|
-
body { background-color: #fff; color: #333; }
|
2
|
-
|
3
|
-
body, p, ol, ul, td {
|
4
|
-
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
-
font-size: 13px;
|
6
|
-
line-height: 18px;
|
7
|
-
}
|
8
|
-
|
9
|
-
pre {
|
10
|
-
background-color: #eee;
|
11
|
-
padding: 10px;
|
12
|
-
font-size: 11px;
|
13
|
-
}
|
14
|
-
|
15
|
-
a { color: #000; }
|
16
|
-
a:visited { color: #666; }
|
17
|
-
a:hover { color: #fff; background-color:#000; }
|
18
|
-
|
19
|
-
div.field, div.actions {
|
20
|
-
margin-bottom: 10px;
|
21
|
-
}
|
22
|
-
|
23
|
-
#notice {
|
24
|
-
color: green;
|
25
|
-
}
|
26
|
-
|
27
|
-
.field_with_errors {
|
28
|
-
padding: 2px;
|
29
|
-
background-color: red;
|
30
|
-
display: table;
|
31
|
-
}
|
32
|
-
|
33
|
-
#error_explanation {
|
34
|
-
width: 450px;
|
35
|
-
border: 2px solid red;
|
36
|
-
padding: 7px;
|
37
|
-
padding-bottom: 0;
|
38
|
-
margin-bottom: 20px;
|
39
|
-
background-color: #f0f0f0;
|
40
|
-
}
|
41
|
-
|
42
|
-
#error_explanation h2 {
|
43
|
-
text-align: left;
|
44
|
-
font-weight: bold;
|
45
|
-
padding: 5px 5px 5px 15px;
|
46
|
-
font-size: 12px;
|
47
|
-
margin: -7px;
|
48
|
-
margin-bottom: 0px;
|
49
|
-
background-color: #c00;
|
50
|
-
color: #fff;
|
51
|
-
}
|
52
|
-
|
53
|
-
#error_explanation ul li {
|
54
|
-
font-size: 12px;
|
55
|
-
list-style: square;
|
56
|
-
}
|