file manger preview and pagination is done.
This commit is contained in:
parent
800f108be3
commit
a02cd97880
|
@ -34,13 +34,46 @@ $(document).ready(function(){
|
||||||
deleteBtn = $("#delete_btn"),
|
deleteBtn = $("#delete_btn"),
|
||||||
url = null;
|
url = null;
|
||||||
|
|
||||||
|
var showPreview = function(elem){
|
||||||
|
var type = $("#ext_" + elem.val()).val(),
|
||||||
|
imgexp = new RegExp(/(\.|\/)(gif|jpe?g|png)$/i),
|
||||||
|
otherexp = new RegExp(/(\.|\/)(pdf|doc|docx|ppt|pptx|xls|xlsx)$/i)
|
||||||
|
img = $("<img />"),
|
||||||
|
preview = $( ".preview-area" );
|
||||||
|
preview.text("Preview is loading...");
|
||||||
|
if( imgexp.test(type) ){
|
||||||
|
var url = $("#url_" + elem.val()).val();
|
||||||
|
img.attr("src",url).load(function(){
|
||||||
|
var ratio = this.width / this.height,
|
||||||
|
targetWidth = targetHeight = 200;
|
||||||
|
if( ratio < 1 ){
|
||||||
|
targetWidth = targetHeight * ratio;
|
||||||
|
}else{
|
||||||
|
targetHeight = targetWidth / ratio;
|
||||||
|
}
|
||||||
|
img.height(targetHeight).width(targetWidth);
|
||||||
|
preview.html(img);
|
||||||
|
})
|
||||||
|
}else if( otherexp.test(type) ) {
|
||||||
|
var t = type.replace(".",""),
|
||||||
|
url = "/assets/ft-icons/" + t + "/" + t + "-128_32.png";
|
||||||
|
img.attr('src', url).load(function(){
|
||||||
|
preview.html(img);
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
preview.html("Preview not available.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$("#asset_sort_list").on(clickEvent,"input[type=checkbox]",function(){
|
$("#asset_sort_list").on(clickEvent,"input[type=checkbox]",function(){
|
||||||
if($("#asset_sort_list input[type=checkbox]:checked").length == 1){
|
if($("#asset_sort_list input[type=checkbox]:checked").length == 1){
|
||||||
url = window.location.protocol + "//" + window.location.host + $("#url_" + $("input[type=checkbox]:checked").val()).val();
|
url = window.location.protocol + "//" + window.location.host + $("#url_" + $("input[type=checkbox]:checked").val()).val();
|
||||||
insertBtn.show();
|
insertBtn.show();
|
||||||
|
showPreview($("input[type=checkbox]:checked"))
|
||||||
}else{
|
}else{
|
||||||
insertBtn.hide();
|
insertBtn.hide();
|
||||||
url = null;
|
url = null;
|
||||||
|
$( ".preview-area" ).empty();
|
||||||
}
|
}
|
||||||
if($("#asset_sort_list input[type=checkbox]:checked").length)
|
if($("#asset_sort_list input[type=checkbox]:checked").length)
|
||||||
deleteBtn.show();
|
deleteBtn.show();
|
||||||
|
|
|
@ -26,8 +26,8 @@ CKEDITOR.editorConfig = function( config ) {
|
||||||
// config.filebrowserImageBrowseUrl = '/browser/browse.php?type=Images';
|
// config.filebrowserImageBrowseUrl = '/browser/browse.php?type=Images';
|
||||||
// config.filebrowserUploadUrl = '/uploader/upload.php';
|
// config.filebrowserUploadUrl = '/uploader/upload.php';
|
||||||
|
|
||||||
config.filebrowserBrowseUrl = "<%= Rails.application.routes.url_helpers.admin_assets_path %>?module_app_id=<%= ModuleApp.first(conditions: {title: 'Asset'}).id.to_s %>";
|
config.filebrowserBrowseUrl = "<%= Rails.application.routes.url_helpers.admin_assets_path(:module_app_id=>ModuleApp.where(:key=>'asset').first.id) %>";
|
||||||
config.filebrowserImageBrowseUrl = "<%= Rails.application.routes.url_helpers.admin_assets_path %>?type=images&module_app_id=<%= ModuleApp.first(conditions: {title: 'Asset'}).id.to_s %>";
|
config.filebrowserImageBrowseUrl = "<%= Rails.application.routes.url_helpers.admin_assets_path(:type=>'image',:module_app_id=>ModuleApp.where(:key=>'asset').first.id) %>";
|
||||||
// config.filebrowserUploadUrl = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>";
|
// config.filebrowserUploadUrl = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>";
|
||||||
|
|
||||||
// config.contentsCss = '/orbit_4.0.1/assets/javascripts/lib/ckeditor/plugins/stylesheetparser/samples/assets/sample.css';
|
// config.contentsCss = '/orbit_4.0.1/assets/javascripts/lib/ckeditor/plugins/stylesheetparser/samples/assets/sample.css';
|
||||||
|
|
|
@ -3,8 +3,8 @@ class Admin::AssetsController < OrbitBackendController
|
||||||
before_filter :setup_vars
|
before_filter :setup_vars
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@assets = (params[:sort] || @filter) ? get_sorted_and_filtered("asset") : Asset.all.desc(:created_at).page(params[:page]).per(10)
|
@assets = (params[:sort] || @filter) ? get_sorted_and_filtered("asset") : Asset.all.desc(:created_at)
|
||||||
if params[:type] == "images"
|
if params[:type] == "image"
|
||||||
@assets = @assets.where(:content_type => /^image/)
|
@assets = @assets.where(:content_type => /^image/)
|
||||||
end
|
end
|
||||||
@tag = ModuleTag.new
|
@tag = ModuleTag.new
|
||||||
|
@ -13,6 +13,8 @@ class Admin::AssetsController < OrbitBackendController
|
||||||
raise ModuleAppError, 'Can not find ModuleApp' if @module_app.nil?
|
raise ModuleAppError, 'Can not find ModuleApp' if @module_app.nil?
|
||||||
@module_app_id = @module_app.id rescue nil
|
@module_app_id = @module_app.id rescue nil
|
||||||
|
|
||||||
|
@assets = @assets.page(params[:page]).per(10)
|
||||||
|
|
||||||
render :layout => "assets"
|
render :layout => "assets"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<input type="hidden" value="<%= asset.description_translations[locale] rescue nil %>" id="<%= locale %>_desc_<%= asset.id %>" />
|
<input type="hidden" value="<%= asset.description_translations[locale] rescue nil %>" id="<%= locale %>_desc_<%= asset.id %>" />
|
||||||
<input type="hidden" value="<%= asset.title_translations[locale] rescue nil %>" id="<%= locale %>_title_<%= asset.id %>" />
|
<input type="hidden" value="<%= asset.title_translations[locale] rescue nil %>" id="<%= locale %>_title_<%= asset.id %>" />
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<input type="hidden" value="<%= File.extname(asset.data.url) %>" id="ext_<%= asset.id %>" />
|
||||||
</td>
|
</td>
|
||||||
<td><%= asset.title_translations[I18n.locale.to_s] rescue nil %></td>
|
<td><%= asset.title_translations[I18n.locale.to_s] rescue nil %></td>
|
||||||
<!-- <td>
|
<!-- <td>
|
||||||
|
@ -20,7 +21,7 @@
|
||||||
<!-- <td><%#= asset.data.file.content_type rescue nil %></td> -->
|
<!-- <td><%#= asset.data.file.content_type rescue nil %></td> -->
|
||||||
<td><%= number_to_human_size(asset.data.file.file_length) rescue nil %></td>
|
<td><%= number_to_human_size(asset.data.file.file_length) rescue nil %></td>
|
||||||
<td><%= asset.description rescue nil %></td>
|
<td><%= asset.description rescue nil %></td>
|
||||||
<td>
|
<!-- <td>
|
||||||
<div class="label-group">
|
<div class="label-group">
|
||||||
<div class="label-td">
|
<div class="label-td">
|
||||||
<% asset.sorted_tags.each do |tag| %>
|
<% asset.sorted_tags.each do |tag| %>
|
||||||
|
@ -28,7 +29,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td> -->
|
||||||
<td>
|
<td>
|
||||||
<a href="<%= edit_admin_asset_path(asset) %>" class="editform">Edit</a>
|
<a href="<%= edit_admin_asset_path(asset) %>" class="editform">Edit</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -214,11 +214,14 @@
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane fade in active" id="filemanager">
|
<div class="tab-pane fade in active" id="filemanager">
|
||||||
<div class="input-area clearfix">
|
<div class="input-area clearfix">
|
||||||
<!-- <a href="<%= admin_module_tags_path(:module_app_id => @module_app_id.to_s) %>"> Tag Management </a> -->
|
|
||||||
<div id="panel_r" class="pull-right">
|
<div id="panel_r" class="pull-right">
|
||||||
preview is here
|
<label>Preview</label>
|
||||||
|
<div class="preview-area">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="panel_l" class="tab-pane fade in active pull-left">
|
<div id="panel_l" class="tab-pane fade in active pull-left">
|
||||||
|
<lable>Search Box : </label>
|
||||||
|
<input type="text" name="filter" placeholder="Enter Filename" />
|
||||||
<table id="asset_sort_list" class="table main-list">
|
<table id="asset_sort_list" class="table main-list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -226,7 +229,6 @@
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Size</th>
|
<th>Size</th>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
<th>Tags</th>
|
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -235,24 +237,13 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div class="pagination pagination-centered">
|
<div class="pagination pagination-centered">
|
||||||
<ul>
|
<%= paginate @assets, :params => {:direction => params[:direction], :sort => params[:sort], :type => params[:type]}, :remote => true %>
|
||||||
<li><a href="#">«</a></li>
|
|
||||||
<li><a href="#">1</a></li>
|
|
||||||
<li><a href="#">2</a></li>
|
|
||||||
<li><a href="#">3</a></li>
|
|
||||||
<li><a href="#">4</a></li>
|
|
||||||
<li><a href="#">5</a></li>
|
|
||||||
<li><a href="#">»</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-actions form-fixed pagination-right">
|
<div class="form-actions form-fixed pagination-right">
|
||||||
<button class="btn btn-primary" id="insert_btn" style="display:none;">Insert</button>
|
<button class="btn btn-primary" id="insert_btn" style="display:none;">Insert</button>
|
||||||
<button class="btn btn-primary" id="delete_btn" style="display:none;">Delete</button>
|
<button class="btn btn-primary" id="delete_btn" style="display:none;">Delete</button>
|
||||||
<div id="asset_pagination" class="paginationFixed">
|
|
||||||
<%= paginate @assets, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]}, :remote => true %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane fade" id="upload">
|
<div class="tab-pane fade" id="upload">
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
$("#tbody_assets").html("<%= j render :partial => 'asset', :collection => @assets %>");
|
||||||
|
$(".pagination").html("<%= j paginate @assets, :params => {:direction => params[:direction], :sort => params[:sort], :type => params[:type]}, :remote => true %>");
|
||||||
|
$( ".preview-area" ).empty();
|
Loading…
Reference in New Issue