1jQuery(function(exports) { 2 exports.sample = exports.sample || {}; 3 var module = exports.sample; 4 5 /** 6 * ç»åã®èªã¿è¾¼ã¿ã管ç 7 * 8 * @constructor 9 */ 10 module.ImageManager = function(){ 11 12 }; 13 //----------------------------------------- 14 // Header 15 //----------------------------------------- 16 17 // ãªã¹ãã¼ç®¡ç 18 module.ImageManager.listeners = {}; 19 20 /** 21 * ç»åèªã¿è¾¼ã¿ãç£è¦ããã 22 * 23 * @param target 24 * @param completeFunc 25 * @param scope 26 * @param origin 27 */ 28 module.ImageManager.watch = function(target, completeFunc, scope, origin){ 29 var offset = new Date().getMilliseconds(); 30 if(module.ImageManager.listeners[target[0].src + offset]) return; 31 var struct = new ImageStruct(target, completeFunc, scope, origin); 32 module.ImageManager.listeners[target[0].src] = struct; 33 struct.loadImage(); 34 return struct; 35 }; 36 37 /** 38 * ç»åèªã¿è¾¼ã¿æ§é ä½ 39 * 40 * @param target 41 * @param scope 42 * @param compFunc 43 * @param args 44 * @constructor 45 */ 46 var ImageStruct = function(target, scope, compFunc, args){ 47 this.target = target; 48 this.scope = scope; 49 this.callBacks = []; 50 this.addCallBack(scope, compFunc, args); 51 this.counter = 0; 52 this.counterMax = this.target.length; 53 }; 54 55 /** 56 * ç»åèªã¿è¾¼ã¿ 57 */ 58 ImageStruct.prototype['loadImage'] = function(){ 59 var _this = this; 60 this.target.each(function(key, image){ 61 image.orginSrc = image.src; 62 image.src = ""; 63 64 jQuery(image).bind("load", function(){ 65 _this.counter++; 66 if(_this.counter == _this.counterMax){ 67 //console.log("complete = ", _this.counter); 68 _this.execute(); 69 } 70 }); 71 72 image.src = image.orginSrc; 73 }); 74 }; 75 76 /** 77 * ã³ã¼ã«ããã¯å¦çã®ç»é² 78 * @param scope 79 * @param func 80 * @param args 81 */ 82 ImageStruct.prototype['addCallBack'] = function(scope, func, args){ 83 var callBack = new CallBack(scope, func, args); 84 this.callBacks.push(callBack); 85 }; 86 87 /** 88 * ã³ã¼ã«ããã¯ãå®è¡ 89 */ 90 ImageStruct.prototype['execute'] = function(){ 91 for(var i = 0; i < this.callBacks.length; ++i){ 92 var callBack = this.callBacks[i]; 93 callBack.execute(); 94 } 95 }; 96 97 /** 98 * ã³ã¼ã«ããã¯ãªãã¸ã§ã¯ã 99 * @param scope 100 * @param func 101 * @param args 102 * @constructor 103 */ 104 var CallBack = function(scope, func, args) { 105 this.scope = scope; 106 this.func = func; 107 this.args = args; 108 } 109 110 /** 111 * ã³ã¼ã«ããã¯å¦çãå®è¡ 112 */ 113 CallBack.prototype['execute'] = function(){ 114 this.func.apply(this.scope, [this.args]); 115 } 116});
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.