Ejemplo n.º 1
0
 /**
  * Method to load the MooTools framework into the document head
  *
  * If debugging mode is on an uncompressed version of MooTools is included for easier debugging.
  *
  * @param   string   $extras  MooTools file to load
  * @param   boolean  $debug   Is debugging mode on? [optional]
  *
  * @return  void
  *
  * @since   11.1
  */
 public static function framework($extras = false, $debug = null)
 {
     // $$$ rob this is to stop mootools from being re-loaded when in an ajax loaded page, as that
     // resets the window events, stopping Fabriks mediator js system from working (e.g. fabrik.form.submitted will not
     // fire the events added when the url initially loads.)
     if (FabrikHelperHTML::inAjaxLoadedPage()) {
         return;
     }
     static $loaded = array();
     $type = $extras ? 'more' : 'core';
     // Only load once
     if (!empty($loaded[$type])) {
         return;
     }
     JHtml::core($debug);
     // If no debugging value is set, use the configuration setting
     if ($debug === null) {
         $config = JFactory::getConfig();
         $debug = $config->get('debug');
     }
     $uncompressed = $debug ? '-uncompressed' : '';
     if ($type != 'core' && empty($loaded['core'])) {
         self::framework(false, $debug);
     }
     JHtml::_('script', 'system/mootools-' . $type . $uncompressed . '.js', false, true, false, false);
     $loaded[$type] = true;
     return;
 }
Ejemplo n.º 2
0
 /**
  * Append the form javascript into the document head
  *
  * @param   int $listId table id
  *
  * @return  void|boolean
  */
 protected function _addJavascript($listId)
 {
     $pluginManager = FabrikWorker::getPluginManager();
     /** @var FabrikFEModelForm $model */
     $model = $this->getModel();
     $aLoadedElementPlugins = array();
     $jsActions = array();
     $bKey = $model->jsKey();
     $srcs = FabrikHelperHTML::framework();
     $shim = array();
     if (!defined('_JOS_FABRIK_FORMJS_INCLUDED')) {
         define('_JOS_FABRIK_FORMJS_INCLUDED', 1);
         FabrikHelperHTML::slimbox();
         $dep = new stdClass();
         $dep->deps = array('fab/element', 'lib/form_placeholder/Form.Placeholder', 'fab/encoder');
         $shim['fabrik/form'] = $dep;
         $deps = new stdClass();
         $deps->deps = array('fab/fabrik', 'fab/element', 'fab/form-submit');
         $framework['fab/elementlist'] = $deps;
         $srcs[] = 'media/com_fabrik/js/lib/form_placeholder/Form.Placeholder.js';
         FabrikHelperHTML::addToFrameWork($srcs, 'media/com_fabrik/js/form');
         FabrikHelperHTML::addToFrameWork($srcs, 'media/com_fabrik/js/form-submit');
         FabrikHelperHTML::addToFrameWork($srcs, 'media/com_fabrik/js/element');
     }
     $aWYSIWYGNames = array();
     // $$$ hugh - yet another one where if we =, the $groups array pointer get buggered up and it
     // skips a group
     $groups = $model->getGroupsHiarachy();
     foreach ($groups as $groupModel) {
         $elementModels = $groupModel->getPublishedElements();
         foreach ($elementModels as $elementModel) {
             $res = $elementModel->useEditor();
             if ($res !== false && $elementModel->canUse() && $model->isEditable()) {
                 $aWYSIWYGNames[] = $res;
             }
             // Load in once the element js class files
             $element = $elementModel->getElement();
             if (!in_array($element->plugin, $aLoadedElementPlugins)) {
                 /* $$$ hugh - certain elements, like file-upload, need to load different JS files
                  * on a per-element basis, so as a test fix, I modified the file-upload's formJavaScriptClass to return false,
                  * and test for that here, so as to not add it to aLoadedElementPlugins[].  The existing 'static' tests in
                  * formJavascriptClass() should still prevent scripts being added twice.
                  */
                 if ($elementModel->formJavascriptClass($srcs, '', $shim) !== false) {
                     $aLoadedElementPlugins[] = $element->plugin;
                 }
             }
             $eventMax = $groupModel->repeatTotal == 0 ? 1 : $groupModel->repeatTotal;
             for ($c = 0; $c < $eventMax; $c++) {
                 $jsAct = $elementModel->getFormattedJSActions($bKey, $c);
                 if (!empty($jsAct)) {
                     $jsActions[] = $jsAct;
                 }
             }
         }
     }
     FabrikHelperHTML::iniRequireJS($shim);
     $actions = trim(implode("\n", $jsActions));
     FabrikHelperHTML::windows('a.fabrikWin');
     FabrikHelperHTML::tips('.hasTip', array(), "\$('{$bKey}')");
     $model->getFormCss();
     $opts = $this->jsOpts();
     $model->jsOpts = $opts;
     $pluginManager->runPlugins('onJSOpts', $model);
     $opts = json_encode($model->jsOpts);
     if (!FabrikHelperHTML::inAjaxLoadedPage()) {
         JText::script('COM_FABRIK_VALIDATING');
         JText::script('COM_FABRIK_SUCCESS');
         JText::script('COM_FABRIK_NO_REPEAT_GROUP_DATA');
         JText::script('COM_FABRIK_VALIDATION_ERROR');
         JText::script('COM_FABRIK_CONFIRM_DELETE_1');
     }
     JText::script('COM_FABRIK_FORM_SAVED');
     // $$$ rob don't declare as var $bKey, but rather assign to window, as if loaded via ajax window the function is wrapped
     // inside an anonymous function, and therefore $bKey wont be available as a global var in window
     $script = array();
     $script[] = "\t\tvar {$bKey} = Fabrik.form('{$bKey}', " . $model->getId() . ", {$opts});";
     // Instantiate js objects for each element
     $vstr = "\n";
     $groups = $model->getGroupsHiarachy();
     $script[] = "\tFabrik.blocks['{$bKey}'].addElements(";
     $groupedJs = new stdClass();
     foreach ($groups as $groupModel) {
         $groupId = $groupModel->getGroup()->id;
         $groupedJs->{$groupId} = array();
         if (!$groupModel->canView('form')) {
             continue;
         }
         $elementJs = array();
         $elementModels = $groupModel->getPublishedElements();
         // $$$ rob if repeatTotal is 0 we still want to add the js objects as the els are only hidden
         $max = $groupModel->repeatTotal > 0 ? $groupModel->repeatTotal : 1;
         foreach ($elementModels as $elementModel) {
             $element = $elementModel->getElement();
             if ($element->published == 0) {
                 continue;
             }
             // If the view is a form then we should always add the js as long as the element is editable or viewable
             // if the view is details then we should only add the js if the element is viewable.
             if ($elementModel->canUse() && $model->isEditable() || $elementModel->canView()) {
                 for ($c = 0; $c < $max; $c++) {
                     $ref = $elementModel->elementJavascript($c);
                     if (!empty($ref)) {
                         $elementJs[] = $ref;
                     }
                     $validations = $elementModel->validator->findAll();
                     if (!empty($validations) && $elementModel->isEditable()) {
                         $watchElements = $elementModel->getValidationWatchElements($c);
                         foreach ($watchElements as $watchElement) {
                             $vstr .= "\tFabrik.blocks['{$bKey}'].watchValidation('" . $watchElement['id'] . "', '" . $watchElement['triggerEvent'] . "');\n";
                         }
                     }
                 }
             }
         }
         $groupedJs->{$groupId} = $elementJs;
     }
     $script[] = json_encode($groupedJs);
     $script[] = "\t);";
     $script[] = $actions;
     $script[] = $vstr;
     // Placeholder
     $script[] = "\tnew Form.Placeholder('.fabrikForm input');";
     $this->_addJavascriptSumbit($script, $listId, $aWYSIWYGNames);
     if (FabrikHelperHTML::inAjaxLoadedPage()) {
         $tipOpts = FabrikHelperHTML::tipOpts();
         $script[] = "new FloatingTips('#" . $bKey . " .fabrikTip', " . json_encode($tipOpts) . ");";
     }
     $res = $pluginManager->runPlugins('onJSReady', $model);
     if (in_array(false, $res)) {
         return false;
     }
     $str = implode("\n", $script);
     $model->getCustomJsAction($srcs);
     $pluginManager->runPlugins('onAfterJSLoad', $model);
     // 3.1 call form js plugin code within main require method
     $srcs = array_merge($srcs, $model->formPluginShim);
     $str .= $model->formPluginJS;
     FabrikHelperHTML::script($srcs, $str);
 }
Ejemplo n.º 3
0
 /**
  * @deprecated use ::framework instead
  */
 function mootools()
 {
     if (!FabrikHelperHTML::inAjaxLoadedPage()) {
         //JHtml::_('behavior.framework');
         //JHtml::_('behavior.framework', true);
     }
 }
Ejemplo n.º 4
0
	/**
	 */

	public function framework(){
		if (!self::$framework) {
			$config = JFactory::getConfig();
			$debug = $config->get('debug');
			//$uncompressed	= $debug ? '-uncompressed' : '';
			$src = array();
			//loading here as well as normal J behavior call makes document.body not found for gmap element when
			// rendered in the form
			if (JRequest::getInt('ajax') !== 1 && JRequest::getVar('tmpl') !== 'component') {
			//	$src[] = 'media/system/js/mootools-core'.$uncompressed.'.js';
			//	$src[] = 'media/system/js/mootools-more'.$uncompressed.'.js';
			}

			JHtml::_('behavior.framework', true);

			if (!FabrikHelperHTML::inAjaxLoadedPage()) {
				JDEBUG ? JHtml::_('script', 'media/com_fabrik/js/lib/head/head.js'): JHtml::_('script', 'media/com_fabrik/js/lib/head/head.min.js');
			}

			$src[] = 'media/com_fabrik/js/mootools-ext.js';
			$src[] = 'media/com_fabrik/js/lib/art.js';
			$src[] = 'media/com_fabrik/js/icons.js';
			$src[] = 'media/com_fabrik/js/icongen.js';
			$src[] = 'media/com_fabrik/js/fabrik.js';
			$src[] = 'media/com_fabrik/js/lib/tips/floatingtips.js';
			$src[] = 'media/com_fabrik/js/window.js';

			FabrikHelperHTML::styleSheet(COM_FABRIK_LIVESITE.'/media/com_fabrik/css/fabrik.css');
			FabrikHelperHTML::addScriptDeclaration("head.ready(function() { Fabrik.liveSite = '".COM_FABRIK_LIVESITE."';});");
			FabrikHelperHTML::script($src, true, "window.fireEvent('fabrik.framework.loaded');");
			self::$framework = true;
		}
	}
Ejemplo n.º 5
0
 /**
  * wrapper for JHTML::Script()
  * @param mixed, string or array of files to load
  * @param string optional js to run if format=raw (as we first load the $file via Asset.Javascript()
  */
 public static function script($file, $onLoad = '')
 {
     if (empty($file)) {
         return;
     }
     $config = JFactory::getConfig();
     $debug = $config->get('debug');
     //$uncompressed	= $debug ? '-uncompressed' : '';
     $ext = $debug || JRequest::getInt('fabrikdebug', 0) === 1 ? '.js' : '-min.js';
     $file = (array) $file;
     $src = array();
     foreach ($file as $f) {
         if (!(stristr($f, 'http://') || stristr($f, 'https://'))) {
             if (!JFile::exists(COM_FABRIK_BASE . '/' . $f)) {
                 continue;
             }
         }
         if (stristr($f, 'http://') || stristr($f, 'https://')) {
             $f = $f;
         } else {
             $compressedFile = str_replace('.js', $ext, $f);
             if (JFile::exists($compressedFile)) {
                 $f = $compressedFile;
             }
             $f = COM_FABRIK_LIVESITE . $f;
         }
         if (JRequest::getCmd('format') == 'raw') {
             $opts = trim($onLoad) !== '' ? '\'onLoad\':function(){' . $onLoad . '}' : '';
             echo '<script type="text/javascript">Asset.javascript(\'' . $f . '\', {' . $opts . '});</script>';
         } else {
             $src[] = "'" . $f . "'";
         }
     }
     if ($onLoad !== '' && JRequest::getCmd('format') != 'raw' && !empty($src)) {
         //$onLoad = "head.ready(function() {\n " . $onLoad . "\n});\n";
         //FabrikHelperHTML::addScriptDeclaration($onLoad);
         if (FabrikHelperHTML::inAjaxLoadedPage()) {
             $onLoad = "(function() {\n " . $onLoad . "\n //end load func \n})";
         } else {
             $onLoad = "(function() { head.ready(function() {\n" . $onLoad . "\n})\n})";
         }
         $src[] = $onLoad;
     }
     if (!empty($src)) {
         JFactory::getDocument()->addScriptDeclaration('head.js(' . implode(",\n", array_unique($src)) . ');' . "\n");
     }
 }
Ejemplo n.º 6
0
 /**
  * Append the form javascript into the document head
  *
  * @param   int  $tableId  table id
  *
  * @return  void
  */
 protected function _addJavascript($tableId)
 {
     $app = JFactory::getApplication();
     $document = JFactory::getDocument();
     $model = $this->getModel();
     $aLoadedElementPlugins = array();
     $jsActions = array();
     $jsControllerKey = $model->isEditable() ? 'form_' . $model->getId() : 'details_' . $model->getId();
     $srcs = FabrikHelperHTML::framework();
     if (!defined('_JOS_FABRIK_FORMJS_INCLUDED')) {
         define('_JOS_FABRIK_FORMJS_INCLUDED', 1);
         FabrikHelperHTML::slimbox();
         $srcs[] = 'media/com_fabrik/js/form.js';
         $srcs[] = 'media/com_fabrik/js/element.js';
         $srcs[] = 'media/com_fabrik/js/lib/form_placeholder/Form.Placeholder.js';
     }
     $aWYSIWYGNames = array();
     // $$$ hugh - yeat another one where if we =, the $groups array pointer get buggered up and it
     // skips a group
     $groups = $model->getGroupsHiarachy();
     foreach ($groups as $groupModel) {
         $elementModels = $groupModel->getPublishedElements();
         foreach ($elementModels as $elementModel) {
             $res = $elementModel->useEditor();
             if ($res !== false) {
                 $aWYSIWYGNames[] = $res;
             }
             $eparams = $elementModel->getParams();
             /* load in once the element js class files
              * $$$ hugh - only needed getParent when we weren't saving changes to parent params to child
              * which we should now be doing ... and getParent() causes an extra table lookup for every child
              * element on the form.
              * $element = $elementModel->getParent();
              */
             $element = $elementModel->getElement();
             if (!in_array($element->plugin, $aLoadedElementPlugins)) {
                 /* $$$ hugh - certain elements, like fileupload, need to load different JS files
                  * on a per-element basis, so as a test fix, I modified the fileupload's formJavaScriptClass to return false,
                  * and test for that here, so as to not add it to aLoadedElementPlugins[].  The existing 'static' tests in
                  * formJavascriptClass() should still prevent scripts being added twice.
                  */
                 if ($elementModel->formJavascriptClass($srcs) !== false) {
                     $aLoadedElementPlugins[] = $element->plugin;
                 }
             }
             $eventMax = $groupModel->repeatTotal == 0 ? 1 : $groupModel->repeatTotal;
             for ($c = 0; $c < $eventMax; $c++) {
                 $jsActions[] = $elementModel->getFormattedJSActions($jsControllerKey, $c);
             }
         }
     }
     $actions = trim(implode("\n", $jsActions));
     $params = $model->getParams();
     $listModel = $model->getlistModel();
     $table = $listModel->getTable();
     $form = $model->getForm();
     FabrikHelperHTML::mocha();
     $bkey = $model->isEditable() ? 'form_' . $model->getId() : 'details_' . $model->getId();
     FabrikHelperHTML::tips('.hasTip', array(), "\$('{$bkey}')");
     $key = FabrikString::safeColNameToArrayKey($table->db_primary_key);
     $this->get('FormCss');
     $start_page = isset($model->sessionModel->last_page) ? (int) $model->sessionModel->last_page : 0;
     if ($start_page !== 0) {
         $app->enqueueMessage(JText::_('COM_FABRIK_RESTARTING_MUTLIPAGE_FORM'));
     } else {
         // Form submitted but fails validation - needs to go to the last page
         $start_page = JRequest::getInt('currentPage', 0);
     }
     $opts = new stdClass();
     $opts->admin = $app->isAdmin();
     $opts->ajax = $model->isAjax();
     $opts->ajaxValidation = (bool) $params->get('ajax_validations');
     $opts->primaryKey = $key;
     $opts->error = @$form->origerror;
     $opts->pages = $model->getPages();
     $opts->plugins = array();
     $opts->multipage_save = (int) $model->saveMultiPage();
     $opts->editable = $model->isEditable();
     $opts->start_page = $start_page;
     $opts->inlineMessage = (bool) $this->isMambot;
     // $$$rob dont int this as keys may be string
     $opts->rowid = (string) $model->_rowId;
     // 3.0 needed for ajax requests
     $opts->listid = (int) $this->get('ListModel')->getId();
     $imgs = new stdClass();
     $imgs->alert = FabrikHelperHTML::image('alert.png', 'form', $this->tmpl, '', true);
     $imgs->action_check = FabrikHelperHTML::image('action_check.png', 'form', $this->tmpl, '', true);
     $imgs->ajax_loader = FabrikHelperHTML::image('ajax-loader.gif', 'form', $this->tmpl, '', true);
     $opts->images = $imgs;
     // $$$rob if you are loading a table in a window from a form db join select record option
     // then we want to know the id of the window so we can set its showSpinner() method
     // 3.0 changed to fabrik_window_id (automatically appended by Fabrik.Window xhr request to load window data
     $opts->fabrik_window_id = JRequest::getVar('fabrik_window_id', '');
     $opts->submitOnEnter = (bool) $params->get('submit_on_enter', false);
     // For editing groups with joined data and an empty joined record (ie no joined records)
     $hidden = array();
     $maxRepeat = array();
     $showMaxRepeats = array();
     foreach ($this->groups as $g) {
         $hidden[$g->id] = $g->startHidden;
         $maxRepeat[$g->id] = $g->maxRepeat;
         $showMaxRepeats[$g->id] = $g->showMaxRepeats;
     }
     $opts->hiddenGroup = $hidden;
     $opts->maxRepeat = $maxRepeat;
     $opts->showMaxRepeats = $showMaxRepeats;
     // $$$ rob 26/04/2011 joomfish translations of password validation error messages
     // $opts->lang = FabrikWorker::getJoomfishLang();
     // $$$ hugh adding these so calc element can easily find joined and repeated join groups
     // when it needs to add observe events ... don't ask ... LOL!
     $opts->join_group_ids = array();
     $opts->group_repeats = array();
     $opts->group_joins_ids = array();
     $groups = $model->getGroupsHiarachy();
     foreach ($groups as $groupModel) {
         if ($groupModel->getGroup()->is_join) {
             $joinParams = new JRegistry($groupModel->getJoinModel()->getJoin()->params);
             $opts->group_pk_ids[$groupModel->getGroup()->id] = FabrikString::safeColNameToArrayKey($joinParams->get('pk'));
             $opts->join_group_ids[$groupModel->getGroup()->join_id] = (int) $groupModel->getGroup()->id;
             $opts->group_join_ids[$groupModel->getGroup()->id] = (int) $groupModel->getGroup()->join_id;
             $opts->group_repeats[$groupModel->getGroup()->id] = $groupModel->canRepeat();
             $opts->group_copy_element_values[$groupModel->getGroup()->id] = $groupModel->canCopyElementValues();
         }
     }
     $opts = json_encode($opts);
     if (!FabrikHelperHTML::inAjaxLoadedPage()) {
         JText::script('COM_FABRIK_VALIDATING');
         JText::script('COM_FABRIK_SUCCESS');
         JText::script('COM_FABRIK_NO_REPEAT_GROUP_DATA');
         JText::script('COM_FABRIK_VALIDATION_ERROR');
         JText::script('COM_FABRIK_FORM_SAVED');
         Jtext::script('COM_FABRIK_CONFIRM_DELETE');
     }
     // $$$ rob dont declare as var $bkey, but rather assign to window, as if loaded via ajax window the function is wrapped
     // inside an anoymous function, and therefore $bkey wont be available as a global var in window
     $script = array();
     $script[] = "window.{$bkey} = new FbForm(" . $model->getId() . ", {$opts});";
     $script[] = "if(typeOf(Fabrik) !== 'null') {";
     $script[] = "Fabrik.addBlock('{$bkey}', {$bkey});";
     $script[] = "}";
     // Instantaite js objects for each element
     $vstr = "\n";
     $groups = $model->getGroupsHiarachy();
     $script[] = "{$bkey}.addElements({";
     $gs = array();
     foreach ($groups as $groupModel) {
         $showGroup = $groupModel->getParams()->get('repeat_group_show_first');
         if ($showGroup == -1 || $showGroup == 2 && $model->isEditable()) {
             // $$$ rob unpublished group so dont include the element js
             continue;
         }
         $aObjs = array();
         $elementModels = $groupModel->getPublishedElements();
         // $$$ rob if repeatTotal is 0 we still want to add the js objects as the els are only hidden
         $max = $groupModel->repeatTotal > 0 ? $groupModel->repeatTotal : 1;
         foreach ($elementModels as $elementModel) {
             $element = $elementModel->getElement();
             if ($element->published == 0) {
                 continue;
             }
             $fullName = $elementModel->getFullName();
             $id = $elementModel->getHTMLId();
             $elementModel->setEditable($model->isEditable());
             // If the view is a form then we should always add the js as long as the element is editable or viewable
             // if the view is details then we should only add hte js if the element is viewable.
             if ($elementModel->canUse() && $model->isEditable() || $elementModel->canView()) {
                 for ($c = 0; $c < $max; $c++) {
                     // $$$ rob ensure that some js code has been returned otherwise dont add empty data to array
                     $ref = trim($elementModel->elementJavascript($c));
                     if ($ref !== '') {
                         $aObjs[] = $ref;
                     }
                     $validations = $elementModel->getValidations();
                     if (!empty($validations) && $elementModel->isEditable()) {
                         $watchElements = $elementModel->getValidationWatchElements($c);
                         foreach ($watchElements as $watchElement) {
                             $vstr .= "{$bkey}.watchValidation('" . $watchElement['id'] . "', '" . $watchElement['triggerEvent'] . "');\n";
                         }
                     }
                 }
             }
         }
         $gs[] = $groupModel->getGroup()->id . ':[' . implode(",\n", $aObjs) . ']';
     }
     $script[] = implode(", ", $gs);
     $script[] = '});';
     $script[] = $actions;
     $script[] = $vstr;
     // Placholder test
     $script[] = "new Form.Placeholder('.fabrikForm input');";
     $script[] = "function submit_form() {";
     if (!empty($aWYSIWYGNames)) {
         jimport('joomla.html.editor');
         $editor = JFactory::getEditor();
         $script[] = $editor->save('label');
         foreach ($aWYSIWYGNames as $parsedName) {
             $script[] = $editor->save($parsedName);
         }
     }
     $script[] = "\treturn false;";
     $script[] = "}";
     $script[] = "function submitbutton(button) {";
     $script[] = "\tif (button==\"cancel\") {";
     $script[] = "\t\tdocument.location = '" . JRoute::_('index.php?option=com_fabrik&task=viewTable&cid=' . $tableId) . "';";
     $script[] = "\t}";
     $script[] = "\tif (button == \"cancelShowForm\") {";
     $script[] = "\t\treturn false;";
     $script[] = "\t}";
     $script[] = "}";
     if (FabrikHelperHTML::inAjaxLoadedPage()) {
         $tipOpts = FabrikHelperHTML::tipOpts();
         $script[] = "new FloatingTips('#" . $bkey . " .fabrikTip', " . json_encode($tipOpts) . ");";
     }
     $pluginManager = FabrikWorker::getPluginManager();
     $res = $pluginManager->runPlugins('onJSReady', $model);
     if (in_array(false, $res)) {
         return false;
     }
     $str = implode("\n", $script);
     $model->getCustomJsAction($srcs);
     $srcs[] = 'media/com_fabrik/js/encoder.js';
     FabrikHelperHTML::script($srcs, $str);
     $pluginManager->runPlugins('onAfterJSLoad', $model);
 }
Ejemplo n.º 7
0
 /**
  * wrapper for JHTML::Script()
  */
 function script($filename, $path = 'media/system/js/', $mootools = true)
 {
     static $rawmootools;
     global $combine;
     $app =& JFactory::getApplication();
     if (FabrikHelperHTML::inAjaxLoadedPage()) {
         // $$$rob TEST!!!! - this may mess up stuff
         //no need to reload mootools as if this is an ajax request it has already been loaded
         //FabrikHelperHTML::mootools();
         static $ajaxJsFiles;
         if (!is_array($ajaxJsFiles)) {
             $ajaxJsFiles = array();
         }
         // $$$rob TEST!!!! - this may mess up stuff
         //send an inline script back which will inject the javascript file into the doc head
         // note your ajax call must have 'evalScripts':true set in its properties
         // $$$ hugh - yeah, it messes up :) "Fatal error: Class 'FastJSON' not found"
         // for instance when creating a calendar viz event ... added require_once
         if (!in_array($path . $filename, $ajaxJsFiles)) {
             $attribs = FastJSON::encode(JArrayHelper::toObject($attribs));
             $file = $path . $filename;
             if (substr($file, 0, 4) !== 'http') {
                 $file = COM_FABRIK_LIVESITE . $file;
             }
             echo "<script type=\"text/javascript\">var v = new Asset.javascript('" . $file . "', {});</script>\n";
             $ajaxJsFiles[] = $path . $filename;
         }
         return;
     }
     // $$$ - hugh - something, somewhere is trying to add a blank filename
     // with '/' as the directory, which ends up trying to load the main page
     // as a JS file.  So some defensive coding to avoid this!
     // @TODO - really need to find out who is doing it tho!
     if (empty($filename)) {
         return;
     }
     FabrikHelperHTML::_getCombine();
     $fbConfig =& JComponentHelper::getParams('com_fabrik');
     if ($mootools) {
         FabrikHelperHTML::mootools();
     }
     if (FabrikWorker::getMooVersion() == 1) {
         $mootools = false;
     }
     if ($fbConfig->get('merge_js', false) && !$app->isAdmin()) {
         $combine->addFile($path . $filename);
     } else {
         JHTML::script($filename, $path, $mootools);
     }
 }