card-mod-script 0.14.2 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/real.yml +50 -0
- data/lib/ansi2html.rb +69 -0
- data/lib/card/mod/script.rb +1 -0
- data/set/abstract/00_script.rb +4 -4
- data/set/abstract/02_coffee_script.rb +9 -1
- data/set/all/head_javascript.rb +13 -22
- data/set/right/script.rb +1 -1
- data/set/type/coffee_script.rb +6 -0
- data/set/type/java_script.rb +6 -0
- data/set/type/local_script_folder_group.rb +2 -0
- data/set/type/local_script_manifest_group.rb +2 -0
- data/set/type_plus_right/mod/script.rb +1 -5
- data/set/type_plus_right/set/script.rb +3 -1
- metadata +13 -119
- data/assets/script/decko/autosave.js.coffee +0 -30
- data/assets/script/decko/bridge.js.coffee +0 -31
- data/assets/script/decko/card_menu.js.coffee +0 -26
- data/assets/script/decko/components.js.coffee +0 -49
- data/assets/script/decko/decko.js.coffee +0 -82
- data/assets/script/decko/doubleclick.js.coffee +0 -30
- data/assets/script/decko/editor.js.coffee +0 -57
- data/assets/script/decko/filter.js.coffee +0 -183
- data/assets/script/decko/filter_items.js.coffee +0 -128
- data/assets/script/decko/filter_links.js.coffee +0 -81
- data/assets/script/decko/follow.js.coffee +0 -22
- data/assets/script/decko/layout.js.coffee +0 -76
- data/assets/script/decko/link_editor.js.coffee +0 -61
- data/assets/script/decko/mod.js.coffee +0 -79
- data/assets/script/decko/modal.js.coffee +0 -113
- data/assets/script/decko/name_editor.js.coffee +0 -40
- data/assets/script/decko/navbox.js.coffee +0 -74
- data/assets/script/decko/nest_editor.js.coffee +0 -166
- data/assets/script/decko/nest_editor_name.js.coffee +0 -102
- data/assets/script/decko/nest_editor_options.js.coffee +0 -93
- data/assets/script/decko/nest_editor_rules.js.coffee +0 -3
- data/assets/script/decko/overlay.js.coffee +0 -54
- data/assets/script/decko/pointer_config.js.coffee +0 -79
- data/assets/script/decko/pointer_list_editor.js.coffee +0 -67
- data/assets/script/decko/recaptcha.js.coffee +0 -19
- data/assets/script/decko/selectable_filtered_content.js.coffee +0 -12
- data/assets/script/decko/slot.js.coffee +0 -182
- data/assets/script/decko/slot_ready.js.coffee +0 -12
- data/assets/script/decko/slotter.js.coffee +0 -268
- data/assets/script/decko/type_editor.js.coffee +0 -21
- data/assets/script/decko/upload.js.coffee +0 -64
- data/assets/script/jquery-ui.min.js +0 -13
- data/assets/script/jquery.autosize.js +0 -274
- data/assets/script/manifest.yml +0 -57
- data/db/migrate_core_cards/20200804112348_add_mod_script_assets_type.rb +0 -30
- data/vendor/jquery_file_upload/LICENSE.txt +0 -20
- data/vendor/jquery_file_upload/README.md +0 -224
- data/vendor/jquery_file_upload/SECURITY.md +0 -227
- data/vendor/jquery_file_upload/VULNERABILITIES.md +0 -118
- data/vendor/jquery_file_upload/cors/postmessage.html +0 -85
- data/vendor/jquery_file_upload/cors/result.html +0 -26
- data/vendor/jquery_file_upload/css/jquery.fileupload-noscript.css +0 -22
- data/vendor/jquery_file_upload/css/jquery.fileupload-ui-noscript.css +0 -17
- data/vendor/jquery_file_upload/css/jquery.fileupload-ui.css +0 -68
- data/vendor/jquery_file_upload/css/jquery.fileupload.css +0 -36
- data/vendor/jquery_file_upload/docker-compose.yml +0 -55
- data/vendor/jquery_file_upload/img/loading.gif +0 -0
- data/vendor/jquery_file_upload/img/progressbar.gif +0 -0
- data/vendor/jquery_file_upload/index.html +0 -357
- data/vendor/jquery_file_upload/js/cors/jquery.postmessage-transport.js +0 -126
- data/vendor/jquery_file_upload/js/cors/jquery.xdr-transport.js +0 -97
- data/vendor/jquery_file_upload/js/demo.js +0 -75
- data/vendor/jquery_file_upload/js/jquery.fileupload-audio.js +0 -101
- data/vendor/jquery_file_upload/js/jquery.fileupload-image.js +0 -347
- data/vendor/jquery_file_upload/js/jquery.fileupload-process.js +0 -170
- data/vendor/jquery_file_upload/js/jquery.fileupload-ui.js +0 -759
- data/vendor/jquery_file_upload/js/jquery.fileupload-validate.js +0 -119
- data/vendor/jquery_file_upload/js/jquery.fileupload-video.js +0 -101
- data/vendor/jquery_file_upload/js/jquery.fileupload.js +0 -1604
- data/vendor/jquery_file_upload/js/jquery.iframe-transport.js +0 -227
- data/vendor/jquery_file_upload/js/vendor/jquery.ui.widget.js +0 -805
- data/vendor/jquery_file_upload/package-lock.json +0 -6853
- data/vendor/jquery_file_upload/package.json +0 -116
- data/vendor/jquery_file_upload/server/gae-python/app.yaml +0 -18
- data/vendor/jquery_file_upload/server/gae-python/main.py +0 -204
- data/vendor/jquery_file_upload/server/gae-python/static/favicon.ico +0 -0
- data/vendor/jquery_file_upload/server/gae-python/static/robots.txt +0 -2
- data/vendor/jquery_file_upload/server/php/Dockerfile +0 -44
- data/vendor/jquery_file_upload/server/php/UploadHandler.php +0 -1480
- data/vendor/jquery_file_upload/server/php/index.php +0 -15
- data/vendor/jquery_file_upload/server/php/php.ini +0 -5
- data/vendor/jquery_file_upload/test/index.html +0 -49
- data/vendor/jquery_file_upload/test/unit.js +0 -989
- data/vendor/jquery_file_upload/test/vendor/chai.js +0 -10854
- data/vendor/jquery_file_upload/test/vendor/mocha.css +0 -325
- data/vendor/jquery_file_upload/test/vendor/mocha.js +0 -18178
- data/vendor/jquery_file_upload/wdio/LICENSE.txt +0 -20
- data/vendor/jquery_file_upload/wdio/assets/black+white-3x2.jpg +0 -0
- data/vendor/jquery_file_upload/wdio/assets/black+white-60x40.gif +0 -0
- data/vendor/jquery_file_upload/wdio/conf/chrome.js +0 -40
- data/vendor/jquery_file_upload/wdio/conf/firefox.js +0 -25
- data/vendor/jquery_file_upload/wdio/hooks/index.js +0 -36
- data/vendor/jquery_file_upload/wdio/test/pages/file-upload.js +0 -79
- data/vendor/jquery_file_upload/wdio/test/specs/01-file-upload.js +0 -25
- data/vendor/jquery_file_upload/wdio/wdio.conf.js +0 -4
- data/vendor/jquery_rails/CHANGELOG.md +0 -359
- data/vendor/jquery_rails/CONTRIBUTING.md +0 -132
- data/vendor/jquery_rails/Gemfile +0 -22
- data/vendor/jquery_rails/MIT-LICENSE +0 -21
- data/vendor/jquery_rails/README.md +0 -75
- data/vendor/jquery_rails/Rakefile +0 -59
- data/vendor/jquery_rails/VERSIONS.md +0 -62
- data/vendor/jquery_rails/jquery-rails.gemspec +0 -26
- data/vendor/jquery_rails/lib/jquery/assert_select.rb +0 -149
- data/vendor/jquery_rails/lib/jquery/rails/engine.rb +0 -6
- data/vendor/jquery_rails/lib/jquery/rails/version.rb +0 -9
- data/vendor/jquery_rails/lib/jquery/rails.rb +0 -8
- data/vendor/jquery_rails/lib/jquery-rails.rb +0 -1
- data/vendor/jquery_rails/test/assert_select_jquery_test.rb +0 -85
- data/vendor/jquery_rails/test/test_helper.rb +0 -6
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery.js +0 -11008
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery.min.js +0 -5
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery.min.map +0 -1
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.js +0 -9814
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.min.js +0 -4
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery2.min.map +0 -1
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.js +0 -10364
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.min.js +0 -2
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery3.min.map +0 -1
- data/vendor/jquery_rails/vendor/assets/javascripts/jquery_ujs.js +0 -555
@@ -1,268 +0,0 @@
|
|
1
|
-
# There are three places that can control what happens after an ajax request
|
2
|
-
# 1. the element that triggered the request (eg. a link or a button)
|
3
|
-
# 2. the closest ".slotter" element
|
4
|
-
# (if the trigger itself isn't a slotter,
|
5
|
-
# a common example is that a form is a slotter but the form buttons aren't)
|
6
|
-
# 3. the slot returned by the request
|
7
|
-
#
|
8
|
-
# A slot is an element marked with "card-slot" class, a slotter has a "slotter" class.
|
9
|
-
# By the default, the closest slot of the slotter is replaced with the new slot that the
|
10
|
-
# request returned. The behavior can be changed with css classes and data attributes.
|
11
|
-
#
|
12
|
-
# To 1. The trigger element has only a few options to override the slotter.
|
13
|
-
# classes:
|
14
|
-
# "_close-modal-on-success"
|
15
|
-
# "_close-overlay-on-success"
|
16
|
-
# "_update-origin"
|
17
|
-
#
|
18
|
-
# To 2. The slotter is the standard way to define what happens with request result
|
19
|
-
# data:
|
20
|
-
# slot-selector
|
21
|
-
# a css selector that defines which slot will be replaced.
|
22
|
-
# You can also use "modal-origin" and "overlay-origin" to refer to the origin slots.
|
23
|
-
# slot-success-selector/slot-error-selector
|
24
|
-
# the same as slot-selector but only used
|
25
|
-
# for success case or error case, respectively
|
26
|
-
# update-foreign-slot
|
27
|
-
# a css selector to specify an additional slot that will be
|
28
|
-
# updated after the request.
|
29
|
-
# update-foreign-slot-url
|
30
|
-
# a url to fetch the new content for the additional slot
|
31
|
-
# if not given the slot is updated with the same card and view that was used before
|
32
|
-
# update-origin
|
33
|
-
# if present then the slot from where the current modal or overlay slot was opened
|
34
|
-
# will be updated
|
35
|
-
# slotter-mode
|
36
|
-
# possible values are
|
37
|
-
# replace (default)
|
38
|
-
# replace the closest slot with new slot
|
39
|
-
# modal
|
40
|
-
# show new slot in modal; if there is already a modal then put it on top
|
41
|
-
# modal-replace
|
42
|
-
# replace existing modal
|
43
|
-
# overlay
|
44
|
-
# show new slot in overlay
|
45
|
-
# update-origin
|
46
|
-
# update closest slot of the slotter that opened the modal or overlay
|
47
|
-
# (assumes that the request was triggered from a modal or overlay)
|
48
|
-
# If you need the update-origin mode together with another mode then use
|
49
|
-
# data-update-origin="true".
|
50
|
-
# silent-success
|
51
|
-
# do nothing
|
52
|
-
#
|
53
|
-
# classes:
|
54
|
-
# _close-overlay
|
55
|
-
# _close-modal
|
56
|
-
#
|
57
|
-
# To 3. Similar as 1, the slot has only overlay and modal options.
|
58
|
-
# classes:
|
59
|
-
# _modal
|
60
|
-
# show slot in modal
|
61
|
-
# _overlay
|
62
|
-
# show slot in overlay
|
63
|
-
#
|
64
|
-
#
|
65
|
-
$(window).ready ->
|
66
|
-
$('body').on 'ajax:success', '.slotter', (event, data) ->
|
67
|
-
$(this).slotterSuccess event, data
|
68
|
-
|
69
|
-
$('body').on 'ajax:error', '.slotter', (event, xhr) ->
|
70
|
-
$(this).showErrorResponse xhr.status, xhr.responseText
|
71
|
-
|
72
|
-
$('body').on 'click', 'button.slotter', (event)->
|
73
|
-
return false if !$.rails.allowAction $(this)
|
74
|
-
$.rails.handleRemote $(this)
|
75
|
-
|
76
|
-
$('body').on 'click', '._clickable.slotter', (event)->
|
77
|
-
$(this)[0].href = $(this).attr("href") # that's where rails.handleRemote
|
78
|
-
# expects the url
|
79
|
-
$.rails.handleRemote $(this)
|
80
|
-
|
81
|
-
$('body').on 'click', '[data-dismiss="overlay"]', (event) ->
|
82
|
-
$(this).findSlot(".card-slot._overlay").removeOverlay()
|
83
|
-
|
84
|
-
$('body').on 'click', '._close-overlay-on-success', (event) ->
|
85
|
-
$(this).closeOnSuccess("overlay")
|
86
|
-
|
87
|
-
$('body').on 'click', '._close-modal-on-success', (event) ->
|
88
|
-
$(this).closeOnSuccess("modal")
|
89
|
-
|
90
|
-
$('body').on 'click', '._close-on-success', (event) ->
|
91
|
-
$(this).closeOnSuccess()
|
92
|
-
|
93
|
-
$('body').on 'click', '._update-origin', (event) ->
|
94
|
-
$(this).closest('.slotter').data("slotter-mode", "update-origin")
|
95
|
-
|
96
|
-
$('body').on 'submit', 'form.slotter', (event)->
|
97
|
-
form = $(this)
|
98
|
-
if form.data("main-success") and form.isMainOrMainModal()
|
99
|
-
form.mainSuccess()
|
100
|
-
if form.data('recaptcha') == 'on'
|
101
|
-
return form.handleRecaptchaBeforeSubmit(event)
|
102
|
-
|
103
|
-
$('body').on 'ajax:beforeSend', '.slotter', (event, xhr, opt)->
|
104
|
-
$(this).slotterBeforeSend opt
|
105
|
-
|
106
|
-
jQuery.fn.extend
|
107
|
-
mainSuccess: ()->
|
108
|
-
form = $(this)
|
109
|
-
$.each form.data("main-success"), (key, value)->
|
110
|
-
inputSelector = "[name=success\\[" + key + "\\]]"
|
111
|
-
input = form.find inputSelector
|
112
|
-
unless input[0]
|
113
|
-
input = $('<input type="hidden" name="success[' + key + ']"/>')
|
114
|
-
form.append input
|
115
|
-
input.val value
|
116
|
-
|
117
|
-
slotterSuccess: (event, responseData) ->
|
118
|
-
debugger
|
119
|
-
unless @hasClass("slotter")
|
120
|
-
console.log "warning: slotterSuccess called on non-slotter element #{this}"
|
121
|
-
return
|
122
|
-
|
123
|
-
return if event.slotSuccessful
|
124
|
-
|
125
|
-
@showSuccessResponse responseData, @data("slotter-mode")
|
126
|
-
|
127
|
-
if @hasClass "_close-overlay"
|
128
|
-
@removeOverlay()
|
129
|
-
if @hasClass "_close-modal"
|
130
|
-
@closest('.modal').modal('hide')
|
131
|
-
|
132
|
-
# should scroll to top after clicking on new page
|
133
|
-
if @hasClass "card-paging-link"
|
134
|
-
slot_top_pos = @slot().offset().top
|
135
|
-
$("body").scrollTop slot_top_pos
|
136
|
-
if @data("update-foreign-slot")
|
137
|
-
$slot = @findSlot @data("update-foreign-slot")
|
138
|
-
reload_url = @data("update-foreign-slot-url")
|
139
|
-
$slot.reloadSlot reload_url
|
140
|
-
|
141
|
-
if @data('original-slotter-mode')
|
142
|
-
@attr 'data-slotter-mode', @data('original-slotter-mode')
|
143
|
-
if @data('original-slot-selector')
|
144
|
-
@attr 'data-slot-selector', @data('original-slot-selector')
|
145
|
-
|
146
|
-
event.slotSuccessful = true
|
147
|
-
|
148
|
-
showSuccessResponse: (responseData, mode) ->
|
149
|
-
if responseData.redirect
|
150
|
-
window.location = responseData.redirect
|
151
|
-
else if responseData.reload
|
152
|
-
window.location.reload(true)
|
153
|
-
else
|
154
|
-
switch mode
|
155
|
-
when "silent-success" then return
|
156
|
-
when "update-modal-origin" then @updateModalOrigin()
|
157
|
-
when "update-origin" then @updateOrigin()
|
158
|
-
else @updateSlot responseData, mode
|
159
|
-
|
160
|
-
showErrorResponse: (status, result) ->
|
161
|
-
if status == 403 #permission denied
|
162
|
-
$(result).showAsModal $(this)
|
163
|
-
else if status == 900
|
164
|
-
$(result).showAsModal $(this)
|
165
|
-
else
|
166
|
-
@notify result, "error"
|
167
|
-
|
168
|
-
if status == 409 #edit conflict
|
169
|
-
@slot().find('.current_revision_id').val(
|
170
|
-
@slot().find('.new-current-revision-id').text()
|
171
|
-
)
|
172
|
-
|
173
|
-
updateModalOrigin: () ->
|
174
|
-
if @overlaySlot()
|
175
|
-
overlayOrigin = @findOriginSlot("overlay")
|
176
|
-
overlayOrigin.updateOrigin()
|
177
|
-
else if @closest("#modal-container")[0]
|
178
|
-
@updateOrigin()
|
179
|
-
|
180
|
-
updateOrigin: () ->
|
181
|
-
type = if @overlaySlot()
|
182
|
-
"overlay"
|
183
|
-
else if @closest("#modal-container")[0]
|
184
|
-
"modal"
|
185
|
-
|
186
|
-
return unless type?
|
187
|
-
|
188
|
-
origin = @findOriginSlot(type)
|
189
|
-
if origin && origin[0]?
|
190
|
-
origin.reloadSlot()
|
191
|
-
|
192
|
-
registerAsOrigin: (type, slot) ->
|
193
|
-
if slot.hasClass("_modal-slot")
|
194
|
-
slot = slot.find(".modal-body") # put the origin slot id on the modal-body instead
|
195
|
-
# of on the slot, so that it survives slot reloads
|
196
|
-
slot.attr("data-#{type}-origin-slot-id", @closest(".card-slot").data("slot-id"))
|
197
|
-
|
198
|
-
updateSlot: (newContent, mode) ->
|
199
|
-
mode ||= "replace"
|
200
|
-
@setSlotContent newContent, mode, $(this)
|
201
|
-
|
202
|
-
# close modal or overlay
|
203
|
-
closeOnSuccess: (type) ->
|
204
|
-
slotter = @closest('.slotter')
|
205
|
-
if !type?
|
206
|
-
type = if @isInOverlay() then "overlay" else "modal"
|
207
|
-
slotter.addClass "_close-#{type}"
|
208
|
-
|
209
|
-
slotterBeforeSend: (opt) ->
|
210
|
-
return if opt.skip_before_send
|
211
|
-
|
212
|
-
# avoiding duplication. could be better test?
|
213
|
-
unless (opt.url.match(/home_view/) or @data("slotter-mode") == "modal")
|
214
|
-
opt.url = decko.slotPath opt.url, @slot()
|
215
|
-
|
216
|
-
if @is('form')
|
217
|
-
if data = @data 'file-data'
|
218
|
-
# NOTE - this entire solution is temporary.
|
219
|
-
@uploadWithBlueimp(data, opt)
|
220
|
-
false
|
221
|
-
|
222
|
-
uploadWithBlueimp: (data, opt) ->
|
223
|
-
input = @find '.file-upload'
|
224
|
-
if input[1]
|
225
|
-
@notify(
|
226
|
-
"Decko does not yet support multiple files in a single form.",
|
227
|
-
"error"
|
228
|
-
)
|
229
|
-
return false
|
230
|
-
|
231
|
-
widget = input.data 'wblueimpFileupload' #jQuery UI widget
|
232
|
-
|
233
|
-
# browsers that can't do ajax uploads use iframe
|
234
|
-
unless widget._isXHRUpload(widget.options)
|
235
|
-
# can't do normal redirects.
|
236
|
-
@find('[name=success]').val('_self')
|
237
|
-
# iframe response not passed back;
|
238
|
-
# all responses treated as success. boo
|
239
|
-
opt.url += '&simulate_xhr=true'
|
240
|
-
# iframe is not xhr request,
|
241
|
-
# so would otherwise get full response with layout
|
242
|
-
iframeUploadFilter = (data)-> data.find('body').html()
|
243
|
-
opt.dataFilter = iframeUploadFilter
|
244
|
-
# gets rid of default html and body tags
|
245
|
-
|
246
|
-
args = $.extend opt, (widget._getAJAXSettings data), url: opt.url
|
247
|
-
# combines settings from decko's slotter and jQuery UI's upload widget
|
248
|
-
args.skip_before_send = true #avoid looping through this method again
|
249
|
-
|
250
|
-
$.ajax( args )
|
251
|
-
|
252
|
-
handleRecaptchaBeforeSubmit: (event) ->
|
253
|
-
recaptcha = @find("input._recaptcha-token")
|
254
|
-
|
255
|
-
if !recaptcha[0]?
|
256
|
-
# monkey error (bad form)
|
257
|
-
recaptcha.val "recaptcha-token-field-missing"
|
258
|
-
else if recaptcha.hasClass "_token-updated"
|
259
|
-
# recaptcha token is fine - continue submitting
|
260
|
-
recaptcha.removeClass "_token-updated"
|
261
|
-
else if !grecaptcha?
|
262
|
-
# shark error (probably recaptcha keys of pre v3 version)
|
263
|
-
recaptcha.val "grecaptcha-undefined"
|
264
|
-
else
|
265
|
-
@updateRecaptchaToken(event)
|
266
|
-
# this stops the submit here
|
267
|
-
# and submits again when the token is ready
|
268
|
-
|
@@ -1,21 +0,0 @@
|
|
1
|
-
$(window).ready ->
|
2
|
-
$('body').on "change", '._live-type-field', ->
|
3
|
-
$this = $(this)
|
4
|
-
|
5
|
-
setSlotMode($this)
|
6
|
-
debugger
|
7
|
-
$this.data 'params', $this.closest('form').serialize()
|
8
|
-
$this.data 'url', $this.attr 'href'
|
9
|
-
|
10
|
-
$('body').on 'change', '.edit-type-field', ->
|
11
|
-
$(this).closest('form').submit()
|
12
|
-
|
13
|
-
setSlotMode = ($el, mode=null) ->
|
14
|
-
$slotter = $el.closest(".slotter")
|
15
|
-
if $slotter.length
|
16
|
-
if $slotter.attr('data-slotter-mode')
|
17
|
-
$slotter.attr 'data-original-slotter-mode', $slotter.attr('data-slotter-mode')
|
18
|
-
$slotter.attr 'data-slotter-mode', mode
|
19
|
-
if $slotter.attr('data-slot-selector')
|
20
|
-
$slotter.attr 'data-original-slot-selector', $slotter.attr('data-slot-selector')
|
21
|
-
$slotter.removeAttr 'data-slot-selector'
|
@@ -1,64 +0,0 @@
|
|
1
|
-
$.extend decko,
|
2
|
-
upload_file: (fileupload) ->
|
3
|
-
# for file as a subcard in a form,
|
4
|
-
# excess parameters are included in the request which cause errors.
|
5
|
-
# only the file, type_id and attachment_card_name are needed
|
6
|
-
# attachment_card_name is the original card name,
|
7
|
-
# ex: card[subcards][+logo][image], card[file]
|
8
|
-
$(fileupload).on 'fileuploadsubmit', (e,data) ->
|
9
|
-
$_this = $(this)
|
10
|
-
card_name = $_this.siblings(".attachment_card_name:first").attr("name")
|
11
|
-
type_id = $_this.siblings("#attachment_type_id").val()
|
12
|
-
data.formData = {
|
13
|
-
"card[type_id]": type_id,
|
14
|
-
"attachment_upload": card_name
|
15
|
-
}
|
16
|
-
$_fileupload = $(fileupload)
|
17
|
-
if $_fileupload.closest("form").attr("action").indexOf("update") > -1
|
18
|
-
url = "card/update/"+$(fileupload).siblings("#file_card_name").val()
|
19
|
-
else
|
20
|
-
url = "card/create"
|
21
|
-
$(fileupload).fileupload(
|
22
|
-
url: decko.path(url),
|
23
|
-
dataType: 'html',
|
24
|
-
done: decko.doneFile,
|
25
|
-
add: decko.chooseFile,
|
26
|
-
progressall: decko.progressallFile
|
27
|
-
)#, forceIframeTransport: true )
|
28
|
-
|
29
|
-
chooseFile: (e, data) ->
|
30
|
-
data.form.find('button[type=submit]').attr('disabled',true)
|
31
|
-
editor = $(this).closest '.card-editor'
|
32
|
-
$('#progress').show()
|
33
|
-
editor.append '<input type="hidden" class="extra_upload_param" ' +
|
34
|
-
'value="true" name="attachment_upload">'
|
35
|
-
editor.append '<input type="hidden" class="extra_upload_param" ' +
|
36
|
-
'value="preview_editor" name="view">'
|
37
|
-
data.submit()
|
38
|
-
editor.find('.choose-file').hide()
|
39
|
-
# editor.find(".file-upload").prop "disabled", true
|
40
|
-
editor.find('.extra_upload_param').remove()
|
41
|
-
|
42
|
-
progressallFile: (e, data) ->
|
43
|
-
progress = parseInt(data.loaded / data.total * 100, 10)
|
44
|
-
$('#progress .progress-bar').css('width', progress + '%')
|
45
|
-
|
46
|
-
doneFile: (e, data) ->
|
47
|
-
editor = $(this).closest '.card-editor'
|
48
|
-
editor.find('.chosen-file').replaceWith data.result
|
49
|
-
data.form.find('button[type=submit]').attr('disabled',false)
|
50
|
-
|
51
|
-
$(window).ready ->
|
52
|
-
$('body').on 'click', '.cancel-upload', ->
|
53
|
-
editor = $(this).closest '.card-editor'
|
54
|
-
editor.find('.choose-file').show()
|
55
|
-
# editor.find(".file-upload").prop "disabled", false
|
56
|
-
editor.find('.chosen-file').empty()
|
57
|
-
editor.find('.progress').show()
|
58
|
-
editor.find('#progress .progress-bar').css('width', '0%')
|
59
|
-
editor.find('#progress').hide()
|
60
|
-
|
61
|
-
$('body').on "submit", "form", ->
|
62
|
-
uploader = $(this).find ".file-upload[type=file]"
|
63
|
-
if uploader[0]
|
64
|
-
uploader.prop "disabled", true
|