[0] | 1 | $(function() { |
---|
| 2 | // Replace remove links by a POST on hidden form |
---|
| 3 | fileRemoveAct(); |
---|
| 4 | |
---|
| 5 | function fileRemoveAct() { |
---|
| 6 | $('a.media-remove').click(function() { |
---|
| 7 | var m_name = $(this).parents('ul').find('li:first>a').text(); |
---|
| 8 | if (window.confirm(dotclear.msg.confirm_delete_media.replace('%s',m_name))) { |
---|
| 9 | var f = $('#media-remove-hide').get(0); |
---|
| 10 | f.elements['remove'].value = this.href.replace(/^(.*)&remove=(.*?)(&|$)/,'$2'); |
---|
| 11 | this.href = ''; |
---|
| 12 | f.submit(); |
---|
| 13 | } |
---|
| 14 | return false; |
---|
| 15 | }); |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | if (!$.browser.opera) { |
---|
[241] | 19 | if (dotclear.candyUpload_force_init == '1') { |
---|
[0] | 20 | candyUploadInit(); |
---|
| 21 | } |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | function candyUploadInit() |
---|
| 25 | { |
---|
| 26 | var candy_upload_success = false; |
---|
| 27 | var candy_upload_form_url = $('#media-upload').attr('action') + '&file_sort=date-desc&d=' + $('#media-upload input[name=d]').val(); |
---|
| 28 | var candy_upload_limit = $('#media-upload input[name=MAX_FILE_SIZE]').val(); |
---|
| 29 | $('#media-upload').candyUpload({ |
---|
| 30 | upload_url: dotclear.candyUpload.base_url + '/media.php', |
---|
| 31 | flash_movie: dotclear.candyUpload.movie_url, |
---|
| 32 | file_size_limit: candy_upload_limit + 'b', |
---|
| 33 | params: 'swfupload=1&' + dotclear.candyUpload.params, |
---|
| 34 | |
---|
| 35 | callbacks: { |
---|
| 36 | createControls: function() { |
---|
| 37 | var _this = this; |
---|
[224] | 38 | this.ctrl.btn_browse.hide(); |
---|
| 39 | this.ctrl.msg.html(dotclear.msg.load_enhanced_uploader); |
---|
[0] | 40 | }, |
---|
| 41 | flashReady: function() { |
---|
[224] | 42 | var _this = this; |
---|
| 43 | this.ctrl.msg.fadeOut('fast',function() { |
---|
| 44 | $(this).text(_this.locales.no_file_in_queue).fadeIn('fast'); |
---|
| 45 | _this.ctrl.btn_browse.fadeIn('fast',function() { |
---|
| 46 | _this.upldr.container.children().css({ |
---|
| 47 | width: $('.cu-btn-browse').width(), |
---|
| 48 | height: $('.cu-btn-browse').height() |
---|
| 49 | }); |
---|
| 50 | }); |
---|
| 51 | }); |
---|
[0] | 52 | }, |
---|
| 53 | uploadSuccess: function(o,data) { |
---|
| 54 | if (data == 'ok') { |
---|
| 55 | candy_upload_success = true; |
---|
| 56 | this.fileMsg(o.id,this.locales.file_uploaded); |
---|
| 57 | } else { |
---|
| 58 | this.fileErrorMsg(o.id,data); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | // uploads finished and at least one success |
---|
| 62 | if (candy_upload_success && $('div.cu-file:has(span.cu-filecancel a)',this.ctrl.files).length == 0) { |
---|
| 63 | $.cookie('dc_candy_upl','1',{expires: 30}); |
---|
| 64 | $.get(candy_upload_form_url,function(data) { |
---|
| 65 | var media = $('div.media-list'); |
---|
| 66 | media.after($('div.media-list',data)).remove(); |
---|
| 67 | fileRemoveAct(); |
---|
| 68 | }); |
---|
| 69 | } |
---|
[740] | 70 | }, |
---|
| 71 | fileQueued: function() { |
---|
| 72 | positionFooter(); |
---|
[0] | 73 | } |
---|
| 74 | } |
---|
| 75 | }); |
---|
| 76 | } |
---|
[250] | 77 | }); |
---|