/* Handler functions
*****************
973776
function _handleConnection(client) {
	client.on('message', curry(_handleMessage, client))
	client.on('disconnect', curry(_handleDisconnect, client))
	client.pubsub = _engine.getPubSub()
	_emitter.emit('client_connect', client)
}
819401
function handle() {
          self.removeListener(event, reset);
          callback.apply(self, [event].concat(args));
        }
2615
function handle() {
          for (
            var i = 0
              , length = args.length;

            i < length;
            self.removeListener(args[i++], handle)
          ){}

          // call the function as last as the function might be calling on of
          // events that where in our either queue, so we need to make sure that
          // everything is removed
          callback.apply(self, arguments);
        }
476826
public function handle() {
        $actions = func_get_args();

        if ($actions === array('*') || empty($actions)) {
            $this->_handled = array('*');
        } else {
            $this->_handled = array_unique(array_intersect($actions, get_class_methods($this->controller)));
        }
    }
600050
function facebookClickHandler(e){
    
    // This method will only get called if we are auth'd
    // Fetch photo galleries from facebook
    
    var url = $facebook.attr('href') // /facebook/get_photo_albums

    $
    .get(url)
    .success(function(data, resp){ 
      
      $spin.hide()
      
      // console.dir(data)

      var thumbs = ""
        ,  overall = data.length
      
      // We have to fetch each album image by id via ajax
      $.each(data, function(i,el){
        
        $
        .get('/facebook/get_photo_album_cover?cover_photo='+el.cover_photo)
        .success(function(data){ 

          thumbs += "<div class='inline-block gallery-wrapper'>"+
                      "<img data-album-id='"+el.id+"' src='"+data+"'/>"+
                      "<span class='fb-gallery-label'>"+el.name+"</span>"+
                    "</div>"

          --overall

        })
        .error(function(e){
          --overall 
          alert(e.responseText || "Error") 
        })
        .complete(function(){ 
          
          if(!overall){
            
            $spin.hide()
            // append the gallery thumbs
            $facebookGallery
              .append(thumbs)
              .show()
            
            // Show the photo picker fb section
            $galleryPickerFacebook
              .show()
            
            // Wire up the events to the galleries' containers...
            wireFacebookGalleryGroups()

            // Progress to Step 2
            progressToNextStep($stepOne, function(){

              $stepTwo.slideDown(333)

            })
            
          } // end if !overall
          
        }) // end complete()
        
      }) // end $.each()
      
    })
    .error(function(e,b){
      $spin.hide()
      if(e.status === 400) alert(e.responseText || 'Bad request.')
      if(e.status === 401) alert(e.responseText || 'Unauthorized request.')
      if(e.status === 402) alert(e.responseText || 'Forbidden request.')
      if(e.status === 403) alert(e.responseText || 'Forbidden request.')
      if(e.status === 404) alert(e.responseText || 'Images were not found.')
      if(e.status === 405) alert(e.responseText || 'That method is not allowed.')
      if(e.status === 408) alert(e.responseText || 'The request timed out. Try again.')
      if(e.status === 500) alert(e.responseText || 'Something went really wrong.')
    })
    
    return false
    
  }
1307226
function handler(req, res) {

        var path = cog.getConfig('options.api_data');
        var urlRegex = cog.getConfig('options.api_url_regex');
        var url = req.url.replace(/^\//, '').replace(/\/$/, '');

        console.log(req.method + ' ' + req.url);

        // Find the JSON-data file and serve it, if URL points to the API.
        if (path && urlRegex && urlRegex.test(url)) {
            var file = path + '/' + url + '.json';
            if (grunt.file.exists(file)) {
                res.end(grunt.file.read(file));
                return;
            }
        }

        if (req.method == 'POST') {
            // TODO: This needs fixing, since it throws an error.
            res.end('{"message": "OK"}');
        }

    }
1215059
function handler ( err, data ){
      if ( callback != null ){
        callback.apply( b9, arguments );
      }
      // only emit events when there is no error
      if ( err == null ){
        b9.emit.call( b9, method, data );
      }
    }
162924
function(error) {
      this.errors.push(error);

      for (var i = 0, length = this.handlers.length; i < length; i++) {
        this.handlers[i](error);
      }
    }
415051
function handleRequest(url, options, callback) {
  let req = {
    url: url,
    headers: {},
    qs: {},
    json: {},
  }

  req = parseOptions(req, options)
  callback(req)
}
1198958
function (type, handler) {

            // Validate arguments
            if (typeof type !== 'string') {
                throw new Error('Type must be a string');
            }
            if (typeof handler !== 'function') {
                throw new Error('Handler must be a function');
            }

            // Check for presence of event store
            if (!this._events) {
                this._events = {};
            }
            if (!this._events[type]) {
                this._events[type] = [];
            }

            // Add handler
            this._events[type].push(handler);

        }
1055053
function(handleObj) {
            // Since window has its own native 'resize' event, return false so that
            // jQuery doesn't modify the event object. Unless, of course, we're
            // throttling the 'resize' event for window.
            if(!jq_resize[str_throttle] && this[str_setTimeout]) {
                return false;
            }

            var old_handler;

            // The new_handler function is executed every time the event is triggered.
            // This is used to update the internal element data store with the width
            // and height when the event is triggered manually, to avoid double-firing
            // of the event callback. See the "Double firing issue in jQuery 1.3.2"
            // comments above for more information.

            function new_handler(e, w, h) {
                var elem = $(this),
                    data = $.data(this, str_data) || {};

                // If called from the polling loop, w and h will be passed in as
                // arguments. If called manually, via .trigger( 'resize' ) or .resize(),
                // those values will need to be computed.
                data.w = w !== undefined ? w : elem.width();
                data.h = h !== undefined ? h : elem.height();

                old_handler.apply(this, arguments);
            };

            // This may seem a little complicated, but it normalizes the special event
            // .add method between jQuery 1.4/1.4.1 and 1.4.2+
            if($.isFunction(handleObj)) {
                // 1.4, 1.4.1
                old_handler = handleObj;
                return new_handler;
            } else {
                // 1.4.2+
                old_handler = handleObj.handler;
                handleObj.handler = new_handler;
            }
        }
726429
function tryCall(handler, data, callback)
{
  try {
    handler(data, callback);
  } catch (e) {
    callback(e);
  }
}
615268
function handler(req, res) {

  var parsedUrl = url.parse(req.url)
  var callback = qs.parse(parsedUrl.query).callback
  var filename = decodeURI(parsedUrl.path.substr(1).split('?')[0])
  var basename = path.basename(filename.split('?')[0])
  var extname = path.extname(basename)
  var response = reswrap(res);
  var notfound = function() {
    response.writeHead(404, 'text').end('');
  };

  if (req.method === 'GET' && parsedUrl.pathname === '/jsonp-request') {
    if (!!exitCountdown) {
      exitCountdown.restart();
    }

    response
      .writeHead(200, 'js')
      .end(callback +'('+ R.get('stamp') +')');

    return;
  }

  var serve;
  if (/^\/template/.test(parsedUrl.pathname)) {
    serve = check(join(__dirname, '..', filename))
  } else if (/^\/node_modules/.test(parsedUrl.pathname)) {
    serve = check(join(__dirname, '..', filename))
  }
  if (serve) {
    serve.pass(function(name, type) {
      response
        .writeHead(200, extname.substr(1))
        .pipeWith(fs.createReadStream(
          path.resolve(name)
        ))
    }).fail(notfound);
    return;
  }

  if (/^\.(md|mkd|markdown|html)$/.test(extname)) {
    check(filename)
      .pass(function() {
        response
          .writeHead(200, 'html')
          .end(template.render({
            title: basename,
            highlight: R.get('highlight') || 'default',
            theme: getTheme(R.get('css')),
            width: R.get('width'),
            body: parser.parse(read(path.resolve(filename)))
          }));
      }).fail(notfound);

    return;
  }

  // Image or some other resources.
  check(filename)
    .pass(function(name) {
      response
        .writeHead(200, name)
        .pipeWith(fs.createReadStream(name));
    }).fail(notfound)
}
1221144
function ajax(url, callback, data) {
  if (data) {
    request.post({url: url, body: data, json: true}, function(err, res, body) {
      if (err) console.log(err);
      callback(err, body, res);
    });
  } else {
    request(url, function(err, res, body) {
      if (err) console.log(err);
      callback(err, body, res);
    });
  }
}
132395
function () {
            this._handler = $B.bind( function (e) {
                var evt = {target: this, img: this.img, data: this._data};
    
                switch (e.type) {
                    case 'load':
                        evt.type = 'complete';
                        this._isComplete = true;
                        this.dispatch( 'complete', evt );
                        break;
                    case 'error':
                        this.dispatch( 'error', evt );
                        break;
                }
    
                this._removeEvents();
            }, this);
        }
52406
function ( eventName, handler ) {
        var events = this.events[ eventName ],
            handlers = [],
            i;
        if ( !events ) {
            return;
        }
        if ( $.isArray( events ) ) {
            for ( i = 0; i < events.length; i++ ) {
                if ( events[i].handler !== handler ) {
                    handlers.push( events[ i ] );
                }
            }
            this.events[ eventName ] = handlers;
        }
    }
14690
function listenHandler( event ) {
				var handler = rawHandler.apply( this, arguments );
				if ( handler === false) {
					event.stopPropagation();
					event.preventDefault();
				}
				return( handler );
		}