1compJSLib = { 2 childs:[], 3 ajaxDataType:"json", 4 //object main functions(methods) section 5 init:function(options){ 6 let _this=this 7 $.each(options, function(i,v){ 8 _this[i]=v; 9 }); 10 this.eventsChecker(); 11 this.listenersChecker(); 12 }, 13 //object events checker method, provides binding functions on events from the "events" property of object 14 eventsChecker:function(){ 15 let thisObj=this; 16 $.each(thisObj.events, function(eventType, eventData) { 17 $.each(eventData, function(selector, callback){ 18 if(Array.isArray(callback)){ 19 $.each(callback, function(index, callbackFunction){ 20 if(eventType=="load"){ 21 thisObj[callbackFunction].call($(selector), thisObj); 22 }else if(eventType=="ready"){ 23 $(document).ready(function(){ 24 thisObj[callbackFunction].call($(selector), thisObj); 25 }); 26 }else if(eventType=="custom"){ 27 $(document).off(selector, thisObj[callbackFunction]); 28 $(document).on(selector, thisObj[callbackFunction]); 29 }else if(eventType=="scroll"){ 30 selector=selector=="window"?window:selector; 31 $(selector).off(eventType, thisObj[callbackFunction]); 32 $(selector).on(eventType, thisObj[callbackFunction]); 33 }else if(eventType=="wheel" || eventType=="touchmove"){ 34 $(selector).off(eventType, { passive: false }, thisObj[callbackFunction]); 35 $(selector).on(eventType, { passive: false }, thisObj[callbackFunction]); 36 }else{ 37 $(document).off(eventType, selector, thisObj[callbackFunction]); 38 $(document).on(eventType, selector, thisObj[callbackFunction]); 39 } 40 }) 41 }else{ 42 if(eventType=="load"){ 43 thisObj[callback].call($(selector), thisObj); 44 }else if(eventType=="ready"){ 45 $(document).ready(function(){ 46 thisObj[callback].call($(selector), thisObj); 47 }); 48 }else if(eventType=="custom"){ 49 $(document).off(selector, thisObj[callback]); 50 $(document).on(selector, thisObj[callback]); 51 }else if(eventType=="scroll"){ 52 selector=selector=="window"?window:selector; 53 $(selector).off(eventType, thisObj[callback]); 54 $(selector).on(eventType, thisObj[callback]); 55 }else if(eventType=="wheel" || eventType=="touchmove"){ 56 $(selector).off(eventType, { passive: false }, thisObj[callback]); 57 $(selector).on(eventType, { passive: false }, thisObj[callback]); 58 }else{ 59 $(document).off(eventType, selector, thisObj[callback]); 60 $(document).on(eventType, selector, thisObj[callback]); 61 } 62 } 63 }) 64 }); 65 }, 66 addListener:function(event, params=false, context=false){ 67 var customEvent=$.Event(event); 68 if(context) 69 customEvent.context = context; 70 $(document).trigger(customEvent, context); 71 }, 72 //common ajax request metod 73 sendRequest: async function(Callback){ 74 let _this=this; 75 let result=new Promise((resolve, reject) =>{ 76 $.ajax({
77 url: _this.ajaxUrl, 78 method: 'POST', 79 data: this.ajaxParams, 80 dataType: _this.ajaxDataType, 81 success: function(data) { 82 setTimeout(function(){ 83 _this[Callback](data); 84 resolve(true); 85 }, 10); 86 }, 87 error: function(xhr, status, error) { // добавлÑем аÑгÑменÑÑ xhr, status и error 88 console.log('XHR status:', xhr); 89 console.log('Error status:', status); 90 console.log('Error message:', error); 91 resolve(false); 92 } 93 }); 94 }); 95 return result; 96 }, 97 listenersChecker:function(){ 98 let thisObj=this; 99 this.Proxy=new Proxy(thisObj, { 100 set: function(target, prop, value) { 101 Reflect.set(target, prop, value); 102 Object.keys(thisObj.propListeners).forEach(function(propName){ 103 if(prop==propName){ 104 thisObj[thisObj.propListeners[propName]](); 105 } 106 }); 107 } 108 }) 109 }, 110 extend:function (Child) { 111 object=this; 112 for(var key in object) { 113 if(key!="childs") 114 Child[key]=object[key]; 115 } 116 117 }, 118};
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.