diff --git a/app/views/dmsf/show.html.erb b/app/views/dmsf/show.html.erb index b8b1ab09..c2ce2188 100644 --- a/app/views/dmsf/show.html.erb +++ b/app/views/dmsf/show.html.erb @@ -125,8 +125,8 @@ <%= context_menu %> <% content_for :header_tags do %> - <%= stylesheet_link_tag 'jquery.dataTables/datatables.min.css', :plugin => 'redmine_dmsf' %> - <%= javascript_include_tag 'jquery.dataTables/datatables.min.js', :plugin => 'redmine_dmsf' %> + <%= stylesheet_link_tag 'jquery.dataTables/datatables.min.css', :plugin => :redmine_dmsf %> + <%= javascript_include_tag 'jquery.dataTables/datatables.min.js', :plugin => :redmine_dmsf, defer: true %> <% title = DmsfFolder.get_column_position('title') %> <% position = DmsfFolder.get_column_position('position') %> diff --git a/app/views/dmsf/trash.html.erb b/app/views/dmsf/trash.html.erb index 1bc35b32..9349eb77 100644 --- a/app/views/dmsf/trash.html.erb +++ b/app/views/dmsf/trash.html.erb @@ -170,8 +170,8 @@ <%= context_menu %> <% content_for :header_tags do %> - <%= stylesheet_link_tag 'jquery.dataTables/datatables.min.css', :plugin => 'redmine_dmsf' %> - <%= javascript_include_tag 'jquery.dataTables/datatables.min.js', :plugin => 'redmine_dmsf' %> + <%= stylesheet_link_tag 'jquery.dataTables/datatables.min.css', :plugin => :redmine_dmsf %> + <%= javascript_include_tag 'jquery.dataTables/datatables.min.js', :plugin => :redmine_dmsf, defer: true %> <% title = DmsfFolder.get_column_position('title') %> <% position = DmsfFolder.get_column_position('position') %> diff --git a/app/views/dmsf_files/show.html.erb b/app/views/dmsf_files/show.html.erb index 30bb2010..7ea67540 100644 --- a/app/views/dmsf_files/show.html.erb +++ b/app/views/dmsf_files/show.html.erb @@ -220,6 +220,6 @@ <% end %> <% content_for :header_tags do %> - <%= stylesheet_link_tag 'jquery.dataTables/datatables.min.css', :plugin => 'redmine_dmsf' %> - <%= javascript_include_tag 'jquery.dataTables/datatables.min.js', :plugin => 'redmine_dmsf' %> + <%= stylesheet_link_tag 'jquery.dataTables/datatables.min.css', :plugin => :redmine_dmsf %> + <%= javascript_include_tag 'jquery.dataTables/datatables.min.js', :plugin => :redmine_dmsf, defer: true %> <% end %> diff --git a/app/views/dmsf_upload/_multi_upload.html.erb b/app/views/dmsf_upload/_multi_upload.html.erb index da4d3b07..0b2529bc 100644 --- a/app/views/dmsf_upload/_multi_upload.html.erb +++ b/app/views/dmsf_upload/_multi_upload.html.erb @@ -45,8 +45,7 @@ <% end %> -<%# TODO: late_javascript_tag is not working here %> -<%= javascript_tag do %> +<%= late_javascript_tag do %> var originalUploaderContent; var uploader = $('#dmsf_uploader'); originalUploaderContent = uploader.html(); @@ -59,15 +58,15 @@ } }); initPlUploader(uploader); - var dmsfFileFieldCount = 1; + window.dmsfFileFieldCount = 1; <% end %> <% content_for :header_tags do %> - <%= stylesheet_link_tag 'plupload/jquery.ui.plupload.css', :plugin => 'redmine_dmsf' %> - <%= javascript_include_tag 'plupload/js/plupload.full.min.js', :plugin => 'redmine_dmsf' %> - <%= javascript_include_tag 'plupload/js/jquery.ui.plupload/jquery.ui.plupload.js', :plugin => 'redmine_dmsf' %> - <%= javascript_include_tag(js_url, :plugin => 'redmine_dmsf') %> - <%= javascript_tag do %> + <%= stylesheet_link_tag 'plupload/jquery.ui.plupload.css', :plugin => :redmine_dmsf %> + <%= javascript_include_tag 'plupload/js/plupload.full.min.js', :plugin => :redmine_dmsf, defer: true %> + <%= javascript_include_tag 'plupload/js/jquery.ui.plupload/jquery.ui.plupload.js', :plugin => :redmine_dmsf, defer: true %> + <%= javascript_include_tag(js_url, :plugin => :redmine_dmsf, defer: true) %> + <%= late_javascript_tag do %> function initPlUploader(uploader) { uploader.html('
'); uploader = $('div', uploader); @@ -107,19 +106,19 @@ } else { if (responseObject.error == null) { var disk_filename_input = $('').attr('type', 'hidden') - .attr('name', 'uploaded[' + dmsfFileFieldCount + '][disk_filename]') + .attr('name', 'uploaded[' + window.dmsfFileFieldCount + '][disk_filename]') .val(responseObject.disk_filename); uploader.append(disk_filename_input); var content_type_input = $('').attr('type', 'hidden') - .attr('name', 'uploaded[' + dmsfFileFieldCount + '][content_type]') + .attr('name', 'uploaded[' + window.dmsfFileFieldCount + '][content_type]') .val(responseObject.content_type); uploader.append(content_type_input); var original_filename_input = $('').attr('type', 'hidden') - .attr('name', 'uploaded[' + dmsfFileFieldCount + '][original_filename]') + .attr('name', 'uploaded[' + window.dmsfFileFieldCount + '][original_filename]') .val(responseObject.original_filename); uploader.append(original_filename_input); var tempfile_path = $('').attr('type', 'hidden') - .attr('name', 'uploaded[' + dmsfFileFieldCount + '][tempfile_path]') + .attr('name', 'uploaded[' + window.dmsfFileFieldCount + '][tempfile_path]') .val(responseObject.tempfile_path); uploader.append(tempfile_path); } else { @@ -130,7 +129,7 @@ } if(pluploader.total.uploaded == pluploader.files.length) $('#uploadform').submit(); else if((pluploader.total.uploaded + pluploader.total.failed) == pluploader.files.length) setTimeout(function() {$('#uploadform').submit();}, 2000); - else dmsfFileFieldCount++; + else window.dmsfFileFieldCount++; return true; }); } diff --git a/lib/redmine_dmsf/hooks/views/base_view_hooks.rb b/lib/redmine_dmsf/hooks/views/base_view_hooks.rb index f475cb0b..60c20084 100644 --- a/lib/redmine_dmsf/hooks/views/base_view_hooks.rb +++ b/lib/redmine_dmsf/hooks/views/base_view_hooks.rb @@ -28,9 +28,9 @@ module RedmineDmsf return if defined?(EasyExtensions) "\n".html_safe + stylesheet_link_tag('redmine_dmsf.css', :plugin => :redmine_dmsf) + "\n".html_safe + stylesheet_link_tag('select2.min.css', :plugin => :redmine_dmsf) + - "\n".html_safe + javascript_include_tag('select2.min.js', :plugin => :redmine_dmsf) + - "\n".html_safe + javascript_include_tag('redmine_dmsf.js', :plugin => :redmine_dmsf) + - "\n".html_safe + javascript_include_tag('attachments_dmsf.js', :plugin => :redmine_dmsf) + "\n".html_safe + javascript_include_tag('select2.min.js', :plugin => :redmine_dmsf, defer: true) + + "\n".html_safe + javascript_include_tag('redmine_dmsf.js', :plugin => :redmine_dmsf, defer: true) + + "\n".html_safe + javascript_include_tag('attachments_dmsf.js', :plugin => :redmine_dmsf, defer: true) end def easy_extensions_javascripts_hook(context={})