Skip to content
floorplanner edited this page Sep 13, 2010 · 16 revisions

The Floorplanner application notifies its environment about what is happening inside by events. These events can be observed with Javascript to implement custom behavior when such an event happens. For instance, a LOADED event is fired when the project is loaded. You can observe this event and change some elements on your page when it occurs.

Observing events using the observe-method

Observing events is loosely based on the Prototype event system. You can observe an event by calling the observe method on your Floorplanner-object, passing the name of the event you want to observe and specifying an event handler. It is possible to add more event handlers to a single event. All registered event handlers will be called when the event is fired.

In the event handler, the this-variable will point to the Floorplanner object instance the event was fired in. Some events will send an argument along with the event when it is fired. The argument is a Javascript hash that can contain several parameters. To catch this argument, add a parameter to the event handler function.

function doSomething( pArgument ) {
  alert('Project LOADED');
}

var fp = new Floorplanner({ project_id: 123, ... });

fp.observe('LOADED', doSomething);
fp.observe('LOADED', function( pArgument ) {
  alert('Project LOADED once more');
});

window.onload = function() { fp.embed('div_id'); } 

Event reference

Event name Description (Is dispatched when…) Argument
LOADED The project is loaded floorId the id of the active floor
designId the id of the active design
FINISHED All the required assets of the design are loaded floorId the id of the active floor
designId the id of the active design
SAVED A design is successfully saved floorId the id of the active floor
designId the id of the active design
designNamethe name of the active design
CHANGED_PROJECT The user has changed one or more project settings (for example the name, description or the number of floors) null
ADDED_OBJECT The user has added an object (furniture) to the design All the info about the object
REMOVED_OBJECT The user has removed an object from the design All the info about the object
DRAGGED_OBJECT The user has dragged an object in or to the design null
ADDED_AREA The user has drawn an area on the design All the info about the area
REMOVED_AREA The user has removed an area from the design All the info about the area
SHOW2D The application is switching to 2D view null
SHOW3D The application is switching to 3D view null

Clone this wiki locally