added a function to make closures (for use in callbacks). popcorn-port
authorhamidouk
Thu, 13 Oct 2011 17:11:20 +0200
branchpopcorn-port
changeset 73 a8192c57c87d
parent 72 c4a36ea700d4
child 74 d7a7d7216371
added a function to make closures (for use in callbacks).
src/js/utils.js
--- a/src/js/utils.js	Thu Oct 13 17:10:35 2011 +0200
+++ b/src/js/utils.js	Thu Oct 13 17:11:20 2011 +0200
@@ -4,13 +4,25 @@
 
 IriSP.traceNum = 0;
 IriSP.trace = function( msg, value ) {
-
+/*
 	if( IriSP.config.gui.debug === true ) {
 		IriSP.traceNum += 1;
 		IriSP.jQuery( "<div>"+IriSP.traceNum+" - "+msg+" : "+value+"</div>" ).appendTo( "#Ldt-output" );
 	}
+*/
 };
 
+/* used in callbacks - because in callbacks we lose "this",
+   we need to have a special function which wraps "this" in 
+   a closure. This way, the 
+*/   
+IriSP.wrap = function (obj, fn) {
+  return function() {
+    args = [].slice.call(this, arguments);
+    fn.call(obj, args);
+  }
+}
+
 /* for ie compatibility
 if (Object.prototype.__defineGetter__&&!Object.defineProperty) {
    Object.defineProperty=function(obj,prop,desc) {