<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>后台管理</title>
    <link rel="stylesheet" href="p.css">
    <script src="../dialogs/internal.js"></script>
    <link href="loading.css" rel="stylesheet" media="screen" />

</head>
<body id="loading"> 
<div id="online" class="panel">
    <div id="imageList"><var id="lang_imgLoading"></var>
        <ul id="listbox" class="filelist">
        </ul>
    </div>
    <div id="load-more-images">加载更多</div>  
</div>  
 
<script src="../../jQuery/jQuery-2.1.4.min.js"></script>
<script src="loading.js"></script>
<script src="../../handlerbar/handlebars.min-latest.js"></script>
<script>   

    $(function () {
        var p = this;
        p.pageNo = 1;
        p.pageSize = 12;
        p.loading = false;



        var content =
                '{{#each aaData}}'+
                '<li tid="{{id}}" data-img="{{qcloudUrl}}">' +
                '<img src="{{qcloudUrl}}" data-src="{{wxUrl}}">'+
                '</li>'+
                '{{/each}}';
        var template = Handlebars.compile(content);
 
        var getMediaUri = "/cfwechat/a/imageMedia/fetchData";
        //编辑器插件开始  
        function uetTotal(){
        	 var formdata = {
        	        	iDisplayStart: (p.pageNo-1)*p.pageSize,
        	        	iDisplayLength: p.pageSize
        	 }; 
            $('#loading').showLoading();
            $.ajax({
                url:getMediaUri,
                type:"get",
                data: formdata,
                dataType:"json",
                success:function(retdata){
                    $('#loading').hideLoading();
                        var htmlStr = template(retdata);
                        $('#listbox').append(htmlStr);
                        p.pageNo++; 
                        p.loading = false;
                }
            });
        }
        uetTotal();
        $("#listbox").on("click",'li', function () {
            var imgStr = $(this).html();
            editor.execCommand("inserthtml", imgStr);
        });
        $('#load-more-images').on("click", function() {
            if(p.loading) return;
            p.loading = true;
            setTimeout(function () {
                uetTotal();
            }, 1000);
        });
        //编辑器插件结束
    })
</script>
</body>
</html>

