FManager.min.js
4.3 KB
/* NKeditor 5.0.3 (2018-10-25), Copyright (C) r9it.com,*/
!function(a){if(!window.applicationCache)throw new Error("您当前的浏览器不支持HTML5,请先升级浏览器才能使用该上传插件!");a.fn.imageCrop=function(b,c){a(this).on("load",function(){var d,e,f,g,h=this.width/this.height,i=b/c;h>=i?(e=c,d=b*h,g=0,f=(d-b)/2):(d=b,e=c/h,f=0,g=0),a(this).css({position:"absolute",top:-g+"px",left:-f+"px",width:d+"px",height:e+"px"})})},a.fn.draggable=function(b){var c={handler:null};b=a.extend(c,b);var d=this;a(b.handler).mousedown(function(b){var c=b.pageX-a(d).position().left,e=b.pageY-a(d).position().top;a(document).mousemove(function(b){window.getSelection?window.getSelection().removeAllRanges():document.selection.empty(),a(d).css({top:b.pageY-e+"px",left:b.pageX-c+"px"})})}).mouseup(function(){a(document).unbind("mousemove")})},void 0==Array.prototype.remove&&(Array.prototype.remove=function(a){for(var b=0;b<this.length;b++)if(this[b]==a){this.splice(b,1);break}}),void 0==Array.prototype.uinque&&(Array.prototype.uinque=function(){for(var a,b=[],c={},d=0;null!=(a=this[d]);d++)c[a]||(b.push(a),c[a]=!0);return b}),window.FManager=function(c){function d(){var d=new b;d.append('<div class="uedbody ke-animated"><div class="ued_title">'),d.append('<div class="uedbar"><span>'+c.lang.title+'</span></div><div class="close_btn icon" title="'+c.lang.closeText+'"></div>'),d.append('</div><div class="wrapper"><div class="wra_body wra_body_server">'),d.append('<div class="tab-panel online"><div class="imagelist"><ul class="list clearfix"></ul><div class="no-data"></div></div></div>'),d.append('<div class="loading-icon"></div></div></div><div class="wra-btn-group">'),d.append('<div class="tip-text">'+c.lang.loadMoreData+"</div>"),d.append('<span class="btn btn-primary btn-confirm">'+c.lang.confirmBtnText+"</span>"),d.append('<span class="btn btn-default btn-cancel">'+c.lang.cancelBtnText+"</span></div></div>"),k.dialog=a(d.toString()),a("body").append(k.dialog),0==c.top&&(c.top=(a(window).height()-k.dialog.height())/2),k.dialog.css({left:(a(window).width()-k.dialog.width())/2+"px",top:c.top+"px"}),k.dialog.draggable({handler:k.dialog.find(".ued_title")}),g()}function e(){f(".close_btn").on("click",function(){k.close()}),f(".btn-confirm").on("click",function(){c.callback(k.selectedList),k.close()}),f(".btn-cancel").on("click",function(){k.close()}),f(".imagelist").on("scroll",function(){this.scrollTop+this.clientHeight>=this.scrollHeight&&g()})}function f(a){return k.dialog.find(a)}function g(){return c.list_url?k.noRecord?!1:(f(".loading-icon").show(),void a.get(c.list_url,{page:k.page,marker:k.marker,fileType:c.fileType},function(a){if(f(".loading-icon").hide(),"000"==a.code){if(!a.data[0])return void f(".online .no-data").html(c.lang.noDataText).show();k.page++,k.marker=a.extra,h(a.data)}else f(".online .no-data").text(c.lang.noDataText).show(),k.noRecord=!0},"json")):(f(".online .no-data").html('<span class="error">'+c.lang.noListUrl+"</span>").show(),!1)}function h(c){a.each(c,function(c,d){var e=new b;e.append("<li>");var g=i(d.thumbURL);""==g&&(g="default"),g=g.toLowerCase();var h=d.width+"x"+d.height;-1=="jpg|jpeg|gif|png|bmp".indexOf(g)?(h=j(d.filesize),e.append('<span class="icon-placeholder icon-default icon-'+g+'" data-src="'+d.oriURL+'"></span>')):e.append('<img src="'+d.thumbURL+'" data-src="'+d.oriURL+'" border="0">'),e.append('<span class="ic"><em class="img-size">'+h+"</em></span></li>");var l=a(e.toString());l.find(".ic").on("click",function(){var b=a(this).prev().attr("data-src"),c=a(".selected:eq(0)").prev().attr("data-src");a(".selected:eq(0)").removeClass("selected"),k.selectedList.remove(c),a(this).addClass("selected"),k.selectedList.push(b)}),l.find("img").imageCrop(113,113),f(".imagelist .list").append(l)})}function i(a){if(!a)return!1;var b=a.lastIndexOf(".");return-1!=b?a.substr(b+1).toLowerCase():!1}function j(a){return a/1048576>1?(a/1048576).toFixed(2)+"MB":(a/1024).toFixed(2)+"KB"}c=a.extend({lang:{},list_url:null,data_type:"json",fileType:"image",top:20,callback:function(a){console.log(a)}},c);var k={};return k.dialog=null,k.selectedList=new Array,k.page=1,k.marker=null,k.noRecord=!1,k.close=function(){k.dialog.remove();try{JDialog.lock.hide()}catch(a){}"function"==typeof c.close&&c.close()},d(),e(),k};var b=function(){var a=new Array;b.prototype.append=function(b){a.push(b)},b.prototype.toString=function(){return a.join("")}}}(jQuery);