Topic: Real simple Floatbox plugin

Hi All,

I am a real fan of Floatbox and use it all over my apps. Below is a simple XAJAX plugin that runs an FB window with a couple of simple calls...

floatbox.inc.php - goes in the xajax plugins/response directory

<?php
/*
  6/15/09
  Author: Ed Robinson 

  This is a REALLY simple XAJAX plugin to handle
  floatbox windows on XAJAX'ed pages.
  
  As written, the plugin doesn't do anything but open and close
  a window on the page. Extend it to fit your needs...
  
  The code assumes Floatbox V3.52.2 or later.
  
  The target page must have the following floatbox references in its <head> section
  with the paths adjusted to fit your layout.

  <link type="text/css" rel="stylesheet" href="floatbox/floatbox.css" />
  <script type="text/javascript" src="floatbox/floatbox.js"></script> 
  
  Note: Floatbox will not work on a page running in the "quirks" mode.
        Use a good doctype tag...
*/

class floatbox extends xajaxResponsePlugin
{
  var $sCallName = "floatbox";

/*
  Function: makeWindow
  This function displays an FB window

  Params:
  $content - the content to be displayed in the FB window.
  $fbtitle - Optional title for the FB window.
  
  Usage: $resp->plugin("floatbox","makeWindow", $content [, $title]);
*/
  function makeWindow($content, $fbtitle='')
  {
      //Invoke the fb start() function. See the fb api documentation. 
      $this->objResponse->script("fb.start({ href:\"#\", 
                                          rev:\"width:max height:max scrolling:yes showPrint:true\",
                                          html:\"$content\",
                                                 title:\"$fbtitle\" })");
  }
  
/*
  Function: closeWindow
  Closes the top most Fb window.
  No parameters.
  Usage: $resp->plugin("floatbox","closeWindow");
*/  
  function closeWindow()
  {
    //Invoke the fb end() function. See the fb api documentation.
    $this->objResponse->script("fb.end()");
  }
}
$pluginManager = &xajaxPluginManager::getInstance();
$pluginManager->registerPlugin(new floatbox);
?>

Sample usage:

<?php
/*
  6/15/09
  Sample using floatbox plugin
*/
require_once("xajax/xajax_core/xajax.inc.php");
$xajax = new xajax();
$xajax->register(XAJAX_FUNCTION,'test');
include("xajax/xajax_plugins/response/floatbox.inc.php");
$xajax->configure('javascript URI', 'xajax/');
$xajax->processRequest();

function test()
{
    $resp= new xajaxResponse();
    $resp->plugin("floatbox","makeWindow","This is the content","Testing Floatbox");
    return $resp;   
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<? $xajax->printJavascript(); ?>
<title>test</title>
<!-- Floatbox css and js inclusions -->
<link type="text/css" rel="stylesheet" href="floatbox/floatbox.css" />
<script type="text/javascript" src="floatbox/floatbox.js"></script> 
</head>
<div id="fbhelpdiv" style="display:none"></div>
<body>
<input type="button" value="Go" onclick="xajax_test();"> 
</body>
</html>

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: Real simple Floatbox plugin

tried to use this and it works fine smile

a great plugin

thank you ed

Re: Real simple Floatbox plugin

Ed you are great!!!! thanks for all!!!

Re: Real simple Floatbox plugin

thnx nice sharing and Sharing is good