|
72 | 72 | buttons: { |
73 | 73 | 'Usuń': function () { |
74 | 74 | $.post(o.removeUrl, {cmsFileId: el.attr('data-id'), object: o.params.formObject, objectId: o.params.formObjectId}, 'json') |
75 | | - .done(function (data) { |
76 | | - if (data.result === 'OK') { |
77 | | - el.parents('li:first').remove(); |
78 | | - } else { |
| 75 | + .done(function (data) { |
| 76 | + if (data.result === 'OK') { |
| 77 | + el.parents('li:first').remove(); |
| 78 | + } else { |
| 79 | + $('#error').html('Usunięcie pliku nie powiodło się'); |
| 80 | + } |
| 81 | + }) |
| 82 | + .fail(function () { |
79 | 83 | $('#error').html('Usunięcie pliku nie powiodło się'); |
80 | | - } |
81 | | - }) |
82 | | - .fail(function () { |
83 | | - $('#error').html('Usunięcie pliku nie powiodło się'); |
84 | | - }); |
| 84 | + }); |
85 | 85 | $(this).dialog('close'); |
86 | 86 | }, |
87 | 87 | 'Anuluj': function () { |
|
136 | 136 |
|
137 | 137 | //okienko edycji - pobieramy dane rekordu z bazy |
138 | 138 | $.post('/cmsAdmin/upload/details', {cmsFileId: el.attr('data-id')}, 'json') |
139 | | - .done(function (data) { |
140 | | - if (data.result === 'OK' && data.record) { |
141 | | - //przygotowujemy zawartość okienka edycji i pokazujemy go |
142 | | - var edit = 'div#dialog-edit'; |
143 | | - |
144 | | - //video poster |
145 | | - if( data.data['urlFile'] != undefined ){ |
146 | | - $('#video').find('#urlVideo').attr('src', data.data['urlFile']); |
147 | | - $(edit + ' input[name="poster"]').val(data.data['poster']); |
148 | | - new VideoFrameExtractor().initialize({ |
149 | | - input: '#poster', |
150 | | - video: '#video', |
151 | | - btn: '#frame-camera', |
152 | | - output: '#output', |
153 | | - dialog: '.ui-dialog' |
154 | | - }); |
155 | | - } |
| 139 | + .done(function (data) { |
| 140 | + if (data.result === 'OK' && data.record) { |
| 141 | + //przygotowujemy zawartość okienka edycji i pokazujemy go |
| 142 | + var edit = 'div#dialog-edit'; |
| 143 | + |
| 144 | + //video poster |
| 145 | + if( data.data['urlFile'] != undefined ){ |
| 146 | + $('#video').find('#urlVideo').attr('src', data.data['urlFile']); |
| 147 | + $(edit + ' input[name="poster"]').val(data.data['poster']); |
| 148 | + new VideoFrameExtractor().initialize({ |
| 149 | + input: '#poster', |
| 150 | + video: '#video', |
| 151 | + btn: '#frame-camera', |
| 152 | + output: '#output', |
| 153 | + dialog: '.ui-dialog' |
| 154 | + }); |
| 155 | + } |
156 | 156 |
|
157 | | - $(edit + ' input[name="title"]').val(data.data.title); |
158 | | - $(edit + ' input[name="author"]').val(data.data.author); |
159 | | - $(edit + ' .dialog-error').hide().find('p').text(''); |
| 157 | + $(edit + ' input[name="title"]').val(data.data.title); |
| 158 | + $(edit + ' input[name="author"]').val(data.data.author); |
| 159 | + $(edit + ' .dialog-error').hide().find('p').text(''); |
160 | 160 |
|
161 | | - $("div#dialog-edit select[name='source']").change(function () { |
162 | | - $("div#dialog-edit #img-edit").attr('src', 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'); |
163 | | - if ($(this).val() != "") { |
164 | | - $("div#dialog-edit #img-edit").attr('src', $(this).val()); |
165 | | - } |
166 | | - }); |
| 161 | + $("div#dialog-edit select[name='source']").change(function () { |
| 162 | + $("div#dialog-edit #img-edit").attr('src', 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'); |
| 163 | + if ($(this).val() != "") { |
| 164 | + $("div#dialog-edit #img-edit").attr('src', $(this).val()); |
| 165 | + } |
| 166 | + }); |
167 | 167 |
|
168 | | - var editDialog = $(edit).dialog({ |
169 | | - width: ((screen.width * 0.5) * 0.8), |
170 | | - height: ((screen.height * 0.8) * 0.8), |
171 | | - maximiziable: true, |
172 | | - modal: true, |
173 | | - resizable: false, |
174 | | - closeText: 'Zamknij', |
175 | | - title: 'Edycja pliku', |
176 | | - dialogClass: 'dialogEdit', |
177 | | - buttons: { |
178 | | - 'Zapisz': function () { |
179 | | - //trigger odświeżający dane |
180 | | - //tinymce.triggerSave(); |
181 | | - $.post('/cmsAdmin/upload/describe', |
182 | | - {cmsFileId: el.attr('data-id'), |
183 | | - form: $(edit + ' input,' + edit + ' select,' + edit + ' textarea').serializeArray() |
184 | | - }, 'json') |
185 | | - .done(function (data) { |
186 | | - if (data.result === 'OK') { |
187 | | - editDialog.dialog('close'); |
188 | | - var posterSource = $("div#dialog-edit select[name='source']").val() |
189 | | - || $("div#dialog-edit input[name='poster']").val(); |
190 | | - el.parent().find('a.insert').attr('data-poster', posterSource); |
191 | | - |
192 | | - //odswiezenie listy |
193 | | - $.ajax({ |
194 | | - url: o.galleryUrl, |
195 | | - success: function (response) { |
196 | | - $('#lionite-gallery').html(response); |
| 168 | + var editDialog = $(edit).dialog({ |
| 169 | + width: ((screen.width * 0.5) * 0.8), |
| 170 | + height: ((screen.height * 0.8) * 0.8), |
| 171 | + maximiziable: true, |
| 172 | + modal: true, |
| 173 | + resizable: false, |
| 174 | + closeText: 'Zamknij', |
| 175 | + title: 'Edycja pliku', |
| 176 | + dialogClass: 'dialogEdit', |
| 177 | + buttons: { |
| 178 | + 'Zapisz': function () { |
| 179 | + //trigger odświeżający dane |
| 180 | + //tinymce.triggerSave(); |
| 181 | + $.post('/cmsAdmin/upload/describe', |
| 182 | + {cmsFileId: el.attr('data-id'), |
| 183 | + form: $(edit + ' input,' + edit + ' select,' + edit + ' textarea').serializeArray() |
| 184 | + }, 'json') |
| 185 | + .done(function (data) { |
| 186 | + if (data.result === 'OK') { |
| 187 | + editDialog.dialog('close'); |
| 188 | + var posterSource = $("div#dialog-edit select[name='source']").val() |
| 189 | + || $("div#dialog-edit input[name='poster']").val(); |
| 190 | + el.parent().find('a.insert').attr('data-poster', posterSource); |
| 191 | + |
| 192 | + //odswiezenie listy |
| 193 | + $.ajax({ |
| 194 | + url: o.galleryUrl, |
| 195 | + success: function (response) { |
| 196 | + $('#lionite-gallery').html(response); |
| 197 | + } |
| 198 | + }); |
| 199 | + |
| 200 | + } else { |
| 201 | + $(edit + ' .dialog-error p').text('Nie udało się zapisać zmian! Spróbuj ponownie!').parent().show(); |
197 | 202 | } |
| 203 | + }) |
| 204 | + .fail(function () { |
| 205 | + $(edit + ' .dialog-error p').text('Nie udało się zapisać zmian! Spróbuj ponownie!').parent().show(); |
198 | 206 | }); |
199 | | - |
200 | | - } else { |
201 | | - $(edit + ' .dialog-error p').text('Nie udało się zapisać zmian! Spróbuj ponownie!').parent().show(); |
202 | | - } |
203 | | - }) |
204 | | - .fail(function () { |
205 | | - $(edit + ' .dialog-error p').text('Nie udało się zapisać zmian! Spróbuj ponownie!').parent().show(); |
206 | | - }); |
207 | | - }, |
208 | | - 'Anuluj': function () { |
209 | | - $(this).dialog('close'); |
| 207 | + }, |
| 208 | + 'Anuluj': function () { |
| 209 | + $(this).dialog('close'); |
| 210 | + } |
210 | 211 | } |
211 | | - } |
212 | | - }); |
213 | | - } else { |
| 212 | + }); |
| 213 | + } else { |
| 214 | + alert('Pobranie opisu pliku nie powiodło się! Spróbuj ponownie'); |
| 215 | + } |
| 216 | + }) |
| 217 | + .fail(function () { |
214 | 218 | alert('Pobranie opisu pliku nie powiodło się! Spróbuj ponownie'); |
215 | | - } |
216 | | - }) |
217 | | - .fail(function () { |
218 | | - alert('Pobranie opisu pliku nie powiodło się! Spróbuj ponownie'); |
219 | | - }); |
| 219 | + }); |
220 | 220 |
|
221 | 221 | } |
222 | 222 |
|
|
244 | 244 | ajaxUpload: function (el, connector) { |
245 | 245 | var o = this.options; |
246 | 246 | var url = connector, |
247 | | - uploadButton = $('<button/>') |
| 247 | + uploadButton = $('<button/>') |
248 | 248 | .addClass('btn btn-primary') |
249 | 249 | .prop('disabled', true) |
250 | 250 | .text('Processing...') |
251 | 251 | .on('click', function () { |
252 | 252 | var $this = $(this), |
253 | | - data = $this.data(); |
| 253 | + data = $this.data(); |
254 | 254 | $this |
255 | | - .off('click') |
256 | | - .text('Abort') |
257 | | - .on('click', function () { |
258 | | - $this.remove(); |
259 | | - data.abort(); |
260 | | - }); |
| 255 | + .off('click') |
| 256 | + .text('Abort') |
| 257 | + .on('click', function () { |
| 258 | + $this.remove(); |
| 259 | + data.abort(); |
| 260 | + }); |
261 | 261 | data.submit().always(function () { |
262 | 262 | $this.remove(); |
263 | 263 | }); |
|
309 | 309 | }); |
310 | 310 | $(el).on('fileuploadprocessalways', function (e, data) { |
311 | 311 | var index = data.index, |
312 | | - file = data.files[index], |
313 | | - node = $(data.context.children()[index]); |
| 312 | + file = data.files[index], |
| 313 | + node = $(data.context.children()[index]); |
314 | 314 |
|
315 | 315 |
|
316 | 316 | if (file.preview) { |
317 | 317 | node |
318 | | - .prepend('<br>') |
319 | | - .prepend(file.preview); |
| 318 | + .prepend('<br>') |
| 319 | + .prepend(file.preview); |
320 | 320 | } |
321 | 321 | if (file.error) { |
322 | 322 | var txt = file.error + ' : ' + file.name; |
323 | 323 | $('#error') |
324 | | - .append('<br>') |
325 | | - .append($('<span class="text-danger"/>').text(txt)); |
| 324 | + .append('<br>') |
| 325 | + .append($('<span class="text-danger"/>').text(txt)); |
326 | 326 | } |
327 | 327 | if (index + 1 === data.files.length) { |
328 | 328 | data.context.find('button') |
329 | | - .text('Upload') |
330 | | - .prop('disabled', !!data.files.error); |
| 329 | + .text('Upload') |
| 330 | + .prop('disabled', !!data.files.error); |
331 | 331 | } |
332 | 332 | }); |
333 | 333 | $(el).on('fileuploadprogressall', function (e, data) { |
334 | 334 | var progress = parseInt(data.loaded / data.total * 100, 10); |
335 | 335 | $('#progress .progress-bar').css( |
336 | | - 'width', |
337 | | - progress + '%' |
338 | | - ); |
| 336 | + 'width', |
| 337 | + progress + '%' |
| 338 | + ); |
339 | 339 | }); |
340 | 340 | $(el).on('fileuploadfail', function (e, data) { |
341 | 341 | $.each(data.files, function (index, file) { |
342 | 342 | var error = $('<span class="text-danger"/>').text('File upload failed.'); |
343 | 343 | $(data.context.children()[index]) |
344 | | - .append('<br>') |
345 | | - .append(error); |
| 344 | + .append('<br>') |
| 345 | + .append(error); |
346 | 346 | }); |
347 | 347 | }).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled'); |
348 | 348 |
|
|
0 commit comments