1/** 2 * Created by toplan on 15/7/11. 3 */ 4 5(function($){ 6 var config = {}; 7 8 $.loading = function (options) { 9 10 var opts = $.extend( 11 $.loading.default, 12 options 13 ); 14 15 config = opts; 16 init(opts); 17 18 var selector = '#' + opts.id; 19 20 $(document).on('ajaxStart', function(){ 21 if (config.ajax) { 22 $(selector).show(); 23 } 24 }); 25 26 $(document).on('ajaxComplete', function(){ 27 setTimeout(function(){ 28 $(selector).hide(); 29 }, opts.minTime); 30 }); 31 32 return $.loading; 33 }; 34 35 $.loading.open = function (time) { 36 var selector = '#' + config.id; 37 $(selector).show(); 38 if (time) { 39 setTimeout(function(){ 40 $(selector).hide(); 41 }, parseInt(time)); 42 } 43 }; 44 45 $.loading.close = function () { 46 var selector = '#' + config.id; 47 $(selector).hide(); 48 }; 49 50 $.loading.ajax = function (isListen) { 51 config.ajax = isListen; 52 }; 53 54 $.loading.default = { 55 ajax : true, 56 //wrap div 57 id : 'ajaxLoading', 58 zIndex : '1000', 59 background : 'rgba(0, 0, 0, 0.7)', 60 minTime : 200, 61 radius : '4px', 62 width : '85px', 63 height : '85px', 64 65 //loading img/gif 66 imgPath : 'images/ajax-loading.gif', 67 imgWidth : '45px', 68 imgHeight : '45px', 69 70 //loading text 71 tip : 'loading...', 72 fontSize : '14px', 73 fontColor : '#fff' 74 }; 75 76 function init (opts) { 77 //wrap div style 78 var wrapCss = 'display: none;position: fixed;top: 0;bottom: 0;left: 0;right: 0;margin: auto;padding: 8px;text-align: center;vertical-align: middle;'; 79 var cssArray = [ 80 'width:' + opts.width, 81 'height:' + opts.height, 82 'z-index:' + opts.zIndex, 83 'background:' + opts.background, 84 'border-radius:' + opts.radius 85 ]; 86 wrapCss += cssArray.join(';'); 87 88 //img style 89 var imgCss = 'margin-bottom:8px;'; 90 cssArray = [ 91 'width:' + opts.imgWidth, 92 'height:' + opts.imgWidth 93 ]; 94 imgCss += cssArray.join(';'); 95 96 //text style 97 var textCss = 'margin:0;'; 98 cssArray = [ 99 'font-size:' + opts.fontSize, 100 'color:' + opts.fontColor 101 ]; 102 textCss += cssArray.join(';'); 103 104 var html = '<div id="' + opts.id + '" style="' + wrapCss + '">' 105 +'<img src="' + opts.imgPath + '" style="' + imgCss + '">' 106 +'<p style="' + textCss + '">' + opts.tip + '</p></div>'; 107 108 $(document).find('body').append(html); 109 } 110 111})(window.jQuery||window.Zepto);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.