file manger preview and pagination is done.

This commit is contained in:
harrybomrah authored and saurabhbhatia committed 2013-12-11 14:41:08 +08:00
1 parent 800f108be3
commit a02cd97880
6 files changed
+51 -21

No files matched your search

@@ -33,14 +33,47 @@ $(document).ready(function(){
var insertBtn = $("#insert_btn"),
deleteBtn = $("#delete_btn"),
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(){
if($("#asset_sort_list input[type=checkbox]:checked").length == 1){
url = window.location.protocol + "//" + window.location.host + $("#url_" + $("input[type=checkbox]:checked").val()).val();
insertBtn.show();
showPreview($("input[type=checkbox]:checked"))
}else{
insertBtn.hide();
url = null;
$( ".preview-area" ).empty();
}
if($("#asset_sort_list input[type=checkbox]:checked").length)
deleteBtn.show();