Generates a CustomJS callback by generating the required JS
        code and gathering all plotting handles and installs it on
        the requested callback handle.
507865
def set_customjs_callback(self, js_callback, handle):
        
        if self.on_events:
            for event in self.on_events:
                handle.js_on_event(event, js_callback)
        if self.on_changes:
            for change in self.on_changes:
                handle.js_on_change(change, js_callback)
        elif hasattr(handle, 'callback'):
            handle.callback = js_callback
80561
def resjs(url, dest='./res.js', prefix=None, node=False, min=False):
    """"""
    meta = requests.get(url, headers={'Accept': 'application/json'}).json()
    code = generate_code(meta, prefix, node, min)
    save_file(dest, code)
427325
def extend_js(mod)
      extend mod
      mod.public_instance_methods.each do |method_name|
        add_function(sym_to_css(method_name)) { |tree, cxt|
          send method_name.to_sym, unquote(cxt.toCSS())
        }
      end
    end
1193614
function() {
            var self = this;

            $.each(self.customEventHandlers, function(eventName) {
                // Namespace the custom event
                // This allow to easily unbound only custom events and not regular ones
                var fullEventName = eventName + '.' + pluginName + ".custom";
                self.$container.off(fullEventName).on(fullEventName, "[data-id]", function (e) {
                    var $elem = $(this);
                    var id = $elem.attr('data-id');
                    var type = $elem.attr('data-type').replace('-text', '');

                    if (!self.panning &&
                        self.customEventHandlers[eventName][type] !== undefined &&
                        self.customEventHandlers[eventName][type][id] !== undefined)
                    {
                        // Get back related elem
                        var elem = self.customEventHandlers[eventName][type][id];
                        // Run callback provided by user
                        elem.options.eventHandlers[eventName](e, id, elem.mapElem, elem.textElem, elem.options);
                    }
                });
            });

        }
697718
function generateCode (config, is_all_yes) {

	console.log(colors.bold('--------------- Code Generator ---------------\n'));

	// Check the configuration
	if (!config.commands) {
		throw new Error('commands undefined in your config.js');
	}

	// Start the processes
	var entry_js = null, handler_js = null, package_json = null, is_modules_installed = false;
	Promise.resolve()
	.then(function () {

		// Generate the entry point script
		entry_js = generateCodeEntryJs(config);

		// Preview of the entry point script
		console.log(entry_js);

		// To skip mode
		if (is_all_yes) return {isSaveEntryJs: true};

		// Confirm to user
		return inquirer.prompt([{
			type: 'confirm',
			name: 'isSaveEntryJs',
			message: 'The entry point was generated. Would you write it to ' + ENTRY_POINT_FILENAME + ' ?'
		}]);

	}).then(function (answer) {

		if (!answer.isSaveEntryJs) {
			entry_js = null;
			return false;
		}

		// Save the entry point script
		console.log('\nWriting to ' + process.cwd() + '/' + ENTRY_POINT_FILENAME);
		fs.writeFileSync(ENTRY_POINT_FILENAME, entry_js);
		console.log('Writing has been completed.\n\n');

		return true;

	}).then(function (result) {

		// Generate the commands handler script
		handler_js = generateCodeHandlerJs(config);

		// Preview of the commands handler script
		console.log(handler_js);

		// To skip mode
		if (is_all_yes) return {isSaveHandlerJs: true};

		// Confirm to user
		return inquirer.prompt([{
			type: 'confirm',
			name: 'isSaveHandlerJs',
			message: 'The commands handler was generated. Would you write it to ' + HANDLER_FILENAME + ' ?'
		}]);

	}).then(function (answer) {

		if (!answer.isSaveHandlerJs) {
			handler_js = null;
			return false;
		}

		// Save the commands handler script
		console.log('\nWriting to ' + process.cwd() + '/' + HANDLER_FILENAME);
		fs.writeFileSync(HANDLER_FILENAME, handler_js);
		console.log('Writing has been completed.\n\n');

		return true;

	}).then(function (result) {

		// Generate the package.json
		package_json = generatePackageJson(config);
		if (package_json == null) { // If user's package.json exists and invalid
			// Skip
			return { answer: { isSavePackageJson: false} };
		}

		// Preview of the package.json
		console.log(package_json + '\n');

		// To skip mode
		if (is_all_yes) return {isSavePackageJson: true};

		// Confirm to user
		return inquirer.prompt([{
			type: 'confirm',
			name: 'isSavePackageJson',
			message: 'The package.json was generated. Would you write it to package.json ?'
		}]);

	}).then(function (answer) {

		if (!answer.isSavePackageJson) {
			package_json = null;
			return false;
		}

		// Save the commands handler script
		console.log('\nWriting to ' + process.cwd() + '/package.json');
		fs.writeFileSync('package.json', package_json);
		console.log('Writing has been completed.\n\n');
		return true;

	}).then(function (result) {

		// Confirm to whether the dependency modules are installed
		var dir_list = [];
		try {
			dir_list = fs.readdirSync('./node_modules/');
		} catch (e) {
			dir_list = [];
		}

		is_modules_installed = false;
		dir_list.forEach(function (name, i) {
			if (name == 'denhub-device') {
				is_modules_installed = true;
			}
		});

		if (is_modules_installed || is_all_yes) {
			return {isDependencyInstall: false};
		}

		// Confirm to user
		return inquirer.prompt([{
			type: 'confirm',
			name: 'isDependencyInstall',
			message: 'The required modules are not installed. Would you install it now ?'
		}]);

	}).then(function (answer) {

		if (!answer.isDependencyInstall) {
			return false;
		}

		// Install the dependency modules
		is_modules_installed = true;
		return execDependencyInstall();

	}).then(function (result) {

		console.log(colors.bold.green('All was completed.'));

		if (!entry_js && !handler_js) {
			console.log('');
			process.exit(0);
			return;
		}

		// Show the guide
		console.log(colors.bold('Enjoy :)\n'));
		if (!is_modules_installed) console.log('$ npm install');
		console.log('$ npm start -- --dev\n');
		console.log('For details, please refer to https://github.com/odentools/denhub-device/\n');

	});

}
1305475
function build(projectInfo, backendProject, callback){
    if(isNewBuildNeeded(projectInfo)){
        console.log('   generating backend project content')
        backendContentManager.generateContents(projectInfo, backendProject, function(){
            console.log('   done')
            if(callback){
                callback(true)
            }
        })
    }else{
        if(callback){
            callback(false)
        }
    }
}
1111053
function _transform() {
	var codeIn = $('#codeIn').val();
	try {
		var codeOut = Streamline.transform(codeIn, {
			runtime: _generators ? "generators" : "callbacks",
		});
		$('#codeOut').val(codeOut);
		info("ready");
	} catch (ex) {
		console.error(ex);
		error(ex.message);
	}
}
758703
function generateRerenderCallback(scope) {
        return function () {
            var remodel = scope.remodel || function () { return true; };
            return $q.when(remodel(scope))
                .then(function () {
                    return scope.rerenderComponent();
                });
        };
    }
690724
function compileCallback(callback, method) {
    var client = this.client;

    // Build the callback
    var builder = client.queryBuilder();
    callback.call(builder, builder);

    // Compile the callback, using the current formatter (to track all bindings).
    var compiler = client.queryCompiler(builder);
    compiler.formatter = this;

    // Return the compiled & parameterized sql.
    return compiler.toSQL(method || 'select');
  }
1107330
function runScripts() {
  var scripts = document.getElementsByTagName('script');

  // Array.prototype.slice cannot be used on NodeList on IE8
  var jsxScripts = [];
  for (var i = 0; i < scripts.length; i++) {
    if (/^text\/jsx(;|$)/.test(scripts.item(i).type)) {
      jsxScripts.push(scripts.item(i));
    }
  }

  if (jsxScripts.length < 1) {
    return;
  }

  console.warn(
    'You are using the in-browser JSX transformer. Be sure to precompile ' +
    'your JSX for production - ' +
    'http://facebook.github.io/react/docs/tooling-integration.html#jsx'
  );

  loadScripts(jsxScripts);
}
268873
function customStrategy(projectDir, builder, cb)
{
  const dest = builder.getTargetDestination(projectDir);
  shelljs.rm('-rf', dest);

  const copyOptions = { overwrite: true, expand: true, dot: true };

  const onCustomInstallerFilesReady = function (err) {
    builder.buildFromSource(dest, projectDir);
    cb();
  };

  const onInstallerFilesReady = function (err) {
    if (err) {
      cb(err);
      return;
    }

    let customInstallerSrc = path.resolve(projectDir, "src", "installer");
    customInstallerSrc = fs.realpathSync(customInstallerSrc);

    const customInstallerTarget = path.resolve(dest, "src", "settings");
    copy(customInstallerSrc, customInstallerTarget, copyOptions, onCustomInstallerFilesReady);
  };

  let installerDir = path.resolve(projectDir, "node_modules", "@deskpro", INSTALLER_PACKAGE_NAME);
  installerDir = fs.realpathSync(installerDir);
  copy(installerDir, dest, copyOptions, onInstallerFilesReady);
}
471555
function generateLayers () {
			grunt.log.write("Generating layers...");

			var config = lang.extend({}, requireConfig, {
				isPrepareStage: true,
				optimize: "none",
				optimizeCss: "none",
				appDir: buildDir,
				dir: tempDir,
				baseUrl: "./",
				logLevel: 2, // WARN
				removeCombined: false,
				skipDirOptimize: true,
				keepBuildDir: false,
				skipSemiColonInsertion: true,
				pragmas: {
					prepare: true,
					build: true
				},
				// Pragmas for rjs plugins:
				pragmasOnSave: {
					prepareSave: true
				},
				// main (root) modules:
				modules: modules.map(function (module) { return { name: module }; }),
				onBuildWrite: function (moduleName, modulePath, contents) {
					// put moduleName into some layer basing on its path
					layers.some(function (layer) {
						var relPath = path.relative(path.resolve(config.dir), modulePath);
						var layerDir = layer.dir;
						if (!Array.isArray(layerDir)) {
							layerDir = [layerDir];
						}
						layerDir.forEach(function(dir) {
							if (relPath.indexOf(dir) === 0) {
								if (options.ignoreModules) {
									if (options.ignoreModules.some(function (m) {
										return m === moduleName;
									})) {
										return;
									}
								}
								layer.modules[moduleName] = true;
							}
						});
					});
					if (moduleName.indexOf('xhtmpl!') === 0) {
						modulesToDelete.push(path.join(outputDir, modulePath.slice('xhtmpl!'.length)));

						// Manually save pre-compiled template back into buildDir as
						// we're currently saving into tempDir (that's why we can't rely on returning content)

						// NOTE: manually remove leading semicolon
						// TODO: the code should be removed after migrating on 2.1.9 (with skipSemiColonInsertion support)
						if (contents.charAt(contents.length-1) === ";") {
							contents = contents.slice(0, contents.length-1);
						}
						file.saveFile(path.join(buildDir, modulePath.slice('xhtmpl!'.length)), contents);
					}
					//return contents;
					return "// this is a stub for finding layer's dependencies: moduleName=" + moduleName;
				}
			});

			requirejs.optimize(
				config,
				lang.safeCallback(function () {
					// create layer modules using 'layers' structure created in onBuildWrite:
					// every 'layer module' is an empty RJS module with imports (via define([..])) of all modules inside this layer
					layers.forEach(function (layer) {
						var modules = Object.keys(layer.modules).sort(),
							content = "define([\n\t\"" + modules.join("\",\n\t\"") + "\"\n], function () {});";
						file.saveFile(path.join(buildDir, layer.name) + ".js", content);
					});

					grunt.log.writeln('OK'.green);

					// Go to next step
					optimizeModules();
				}),
				lang.errorCallback
			);
		}
1233787
function runLoadHooks(name, object) {
    loaded[name] = object;
    var window = _emberEnvironment.environment.window;

    if (window && typeof CustomEvent === 'function') {
      var event = new CustomEvent(name, { detail: object, name: name });
      window.dispatchEvent(event);
    }

    if (loadHooks[name]) {
      loadHooks[name].forEach(function (callback) {
        return callback(object);
      });
    }
  }
676419
def build_js(ctx, force=False):
    
    for fname in JSX_FILENAMES:
        jstools.babel(
            ctx,
            '{pkg.source_js}/' + fname,
            '{pkg.django_static}/{pkg.name}/js/' + fname + '.js',
            force=force
        )
917797
function(app, results, callback) {

    // Figure out where our app skeleton lives
    var dir = (results.dir) ? results.dir : process.cwd();
    var appPath = path.join(dir, results.name);

    // Get paths to our config files
    var kalaboxFile = path.join(appPath, 'kalabox.yml');
    var pkgFile = path.join(appPath, 'package.json');

    // Load up the config
    var defaultConf = kbox.util.yaml.toJson(kalaboxFile);
    var pkgConf = require(pkgFile);

    // Create a starting point for our config that events can
    // hook into and mod
    var data = {
      config: _.merge(defaultConf, getOverrides(app.options, results)),
      results: results,
      pkg: pkgConf
    };

    // Customize pkg.json with our app name
    pkgConf.name = results.name;

    // Let other things mod conf
    return kbox.core.events.emit('pre-create-configure', data)

    // Update source files with our new stuff
    .then(function() {
      kbox.util.yaml.toYamlFile(data.config, kalaboxFile);
      fs.writeFileSync(pkgFile, JSON.stringify(pkgConf, null, 2));
    })

    // This is probably not very helpful but symmetry and all
    .then(function() {
      return kbox.core.events.emit('post-create-configure', data);
    })

    // Return.
    .nodeify(callback);
  }
69821
function buildScripts() {
  return Promise.resolve()
    // Create the dist folder if it doesn't exist
    .then(() => {
      if(!FS.existsSync(Path.join(__dirname, 'dist'))) {
        return FS.mkdirAsync(Path.join(__dirname, 'dist'));
      }
    })

    // Generate minified scripts
    .then(() => new Promise((resolve, reject) => {
      let scripts = {
        'dropdowns.js': FS.readFileSync(Path.join(__dirname, 'source/js/dropdowns.js'), 'utf8'),
        'tabs.js': FS.readFileSync(Path.join(__dirname, 'source/js/tabs.js'), 'utf8')
      };

      let result = UglifyJS.minify(scripts, {
        output: {
          comments: /^!/
        }
      });
      if(result.error) {
        reject(result.error);
        return;
      }

      resolve(result.code);
    }))

    // Write minified scripts to dist
    .then((scripts) => {
      let file = Path.join(__dirname, 'dist/shoelace.js');

      // Update {{version}} in JS since it's not processed with Handlebars
      scripts = scripts.replace(/\{\{version\}\}/g, __version);

      // Output a message
      console.log(Chalk.green('JS processed: %s! 🐭'), Path.relative(__dirname, file));

      // Write output file
      return FS.writeFileAsync(file, scripts, 'utf8');
    });
}
543756
function () {
		var chart = this,
			options = chart.options,
			callback = chart.callback;

		// Check whether the chart is ready to render
		if (!chart.isReadyToRender()) {
			return;
		}

		// Create the container
		chart.getContainer();

		// Run an early event after the container and renderer are established
		fireEvent(chart, 'init');

		
		chart.resetMargins();
		chart.setChartSize();

		// Set the common chart properties (mainly invert) from the given series
		chart.propFromSeries();

		// get axes
		chart.getAxes();

		// Initialize the series
		each(options.series || [], function (serieOptions) {
			chart.initSeries(serieOptions);
		});

		chart.linkSeries();

		// Run an event after axes and series are initialized, but before render. At this stage,
		// the series data is indexed and cached in the xData and yData arrays, so we can access
		// those before rendering. Used in Highstock. 
		fireEvent(chart, 'beforeRender'); 

		// depends on inverted and on margins being set
		chart.pointer = new Pointer(chart, options);

		chart.render();

		// add canvas
		chart.renderer.draw();
		// run callbacks
		if (callback) {
			callback.apply(chart, [chart]);
		}
		each(chart.callbacks, function (fn) {
			fn.apply(chart, [chart]);
		});
		
		
		// If the chart was rendered outside the top container, put it back in
		chart.cloneRenderTo(true);

		fireEvent(chart, 'load');

	}