/**
  * if used as a filter add in some JS code to watch observed filter element's changes
  * when it changes update the contents of this elements dd filter's options
  * @param bol is the filter a normal (true) or advanced filter
  * @param string container
  */
 function _filterJS($normal, $container)
 {
     $params =& $this->getParams();
     $element =& $this->getElement();
     $observerid =& $this->_getWatchId();
     $observerid .= "value";
     if ($element->filter_type == 'auto-complete') {
         FabrikHelperHTML::autoCompleteScript();
         $htmlid = $this->getHTMLId() . 'value';
         $opts = new stdClass();
         $opts->observerid = $observerid;
         $opts->url = COM_FABRIK_LIVESITE . 'index.php?option=com_fabrik&format=raw&controller=plugin&task=pluginAjax&g=element&element_id=' . $element->id . '&plugin=' . $this->_pluginName . '&method=autocomplete_options';
         $opts = json_encode($opts);
         FabrikHelperHTML::addScriptDeclaration("window.addEvent('domready', function() { new FabCddAutocomplete('{$htmlid}', {$opts}); });");
     }
     if ($element->filter_type == 'dropdown') {
         $default = $this->getDefaultFilterVal($normal);
         $observed =& $this->_getObserverElement();
         $filterid = $this->getHTMLId() . 'value';
         $tableModel =& $this->getTableModel();
         $formModel =& $tableModel->getForm();
         FabrikHelperHTML::script('filter.js', 'components/com_fabrik/plugins/element/fabrikcascadingdropdown/');
         $opts = new stdClass();
         $opts->formid = $formModel->_id;
         $opts->filterid = $filterid;
         $opts->elid = $this->_id;
         $opts->liveSite = COM_FABRIK_LIVESITE;
         $opts->def = $default;
         $opts->filterobj = 'filter_' . $container;
         $opts = json_encode($opts);
         return "filter_{$container}.addFilter('{$element->plugin}', new CascadeFilter('{$observerid}', {$opts}));\n";
     }
 }
示例#2
0
 /**
  * Add autocomplete JS code to head
  * @param string $htmlid of element to turn into autocomplete
  * @param int $elementid
  * @param string $plugin
  * @param array $opts (currently only takes 'onSelection')
  */
 public function autoComplete($htmlid, $elementid, $plugin = 'field', $opts = array())
 {
     FabrikHelperHTML::autoCompleteScript();
     $json = FabrikHelperHTML::autoCompletOptions($htmlid, $elementid, $plugin, $opts);
     $str = json_encode($json);
     FabrikHelperHTML::addScriptDeclaration("head.ready(function() { new FbAutocomplete('{$htmlid}', {$str}); });");
 }
示例#3
0
 /**
  * Add autocomplete JS code to head
  * @param string $htmlid of element to turn into autocomplete
  * @param int $elementid
  * @param string $plugin
  * @param array $opts (currently only takes 'onSelection')
  */
 public function autoComplete($htmlid, $elementid, $plugin = 'fabrikfield', $opts = array())
 {
     FabrikHelperHTML::autoCompleteScript();
     $json = FabrikHelperHTML::autoCompletOptions($htmlid, $elementid, $plugin, $opts);
     $str = FastJSON::encode($json);
     FabrikHelperHTML::addScriptDeclaration("window.addEvent('domready', function() { new FabAutocomplete('{$htmlid}', {$str}); });");
 }
示例#4
0
	/**
	 * if used as a filter add in some JS code to watch observed filter element's changes
	 * when it changes update the contents of this elements dd filter's options
	 * @param bol is the filter a normal (true) or advanced filter
	 * @param string container
	 */

	function _filterJS($normal, $container)
	{
		$params 		=& $this->getParams();
		$element 		= $this->getElement();
		$observerid 	=& $this->_getWatchId();
		$observerid .= "value";
		if ($element->filter_type == 'auto-complete') {
			FabrikHelperHTML::autoCompleteScript();
			$htmlid				= $this->getHTMLId() . 'value';
			$opts = new stdClass();
			$opts->observerid = $observerid;
			$opts->url = COM_FABRIK_LIVESITE.'/index.php?option=com_fabrik&format=raw&view=plugin&task=pluginAjax&g=element&element_id='.$element->id.'&plugin=cascadingdropdown&method=autocomplete_options';
			$opts = json_encode($opts);

			FabrikHelperHTML::addScriptDeclaration(
		"head.ready(function() { new FabCddAutocomplete('$htmlid', $opts); });"
			);
		}
		if ($element->filter_type == 'dropdown') {
			$default			= $this->getDefaultFilterVal($normal);
			$observed 		=& $this->_getObserverElement();
			$filterid			= $this->getHTMLId() . 'value';
			$listModel 	=& $this->getlistModel();
			$formModel 		=& $listModel->getForm();
			FabrikHelperHTML::script('plugins/fabrik_element/cascadingdropdown/filter.js');
			$opts = new stdClass();
			$opts->formid = $formModel->get('id');
			$opts->filterid = $filterid;
			$opts->elid = $this->_id;
			$opts->def = $default;
			$opts->filterobj = 'filter_' . $container;
			$opts = json_encode($opts);
			return "filter_{$container}.addFilter('$element->plugin', new CascadeFilter('$observerid', $opts));\n";
		}
	}
示例#5
0
 /**
  * If used as a filter add in some JS code to watch observed filter element's changes
  * when it changes update the contents of this elements dd filter's options
  *
  * @param   bool    $normal     is the filter a normal (true) or advanced filter
  * @param   string  $container  container
  *
  * @return  void
  */
 public function filterJS($normal, $container)
 {
     $params = $this->getParams();
     $element = $this->getElement();
     $observerid = $this->_getWatchId();
     $observerid .= 'value';
     if ($element->filter_type == 'auto-complete') {
         FabrikHelperHTML::autoCompleteScript();
         $htmlid = $this->getHTMLId() . 'value';
         $opts = new stdClass();
         $opts->observerid = $observerid;
         $app = JFactory::getApplication();
         $package = $app->getUserState('com_fabrik.package', 'com_fabrik');
         $opts->url = COM_FABRIK_LIVESITE . '/index.php?option=com_fabrik&format=raw&view=plugin&task=pluginAjax&g=element&element_id=' . $element->id . '&plugin=cascadingdropdown&method=autocomplete_options&package=' . $package;
         $opts = json_encode($opts);
         FabrikHelperHTML::addScriptDeclaration("head.ready(function() { new FabCddAutocomplete('{$htmlid}', {$opts}); });");
     }
     if ($element->filter_type == 'dropdown') {
         $default = $this->getDefaultFilterVal($normal);
         $observed = $this->_getObserverElement();
         $filterid = $this->getHTMLId() . 'value';
         $formModel = $this->getForm();
         FabrikHelperHTML::script('plugins/fabrik_element/cascadingdropdown/filter.js');
         $opts = new stdClass();
         $opts->formid = $formModel->get('id');
         $opts->filterid = $filterid;
         $opts->elid = $this->_id;
         $opts->def = $default;
         $opts->filterobj = 'Fabrik.filter_' . $container;
         $opts = json_encode($opts);
         return "Fabrik.filter_{$container}.addFilter('{$element->plugin}', new CascadeFilter('{$observerid}', {$opts}));\n";
     }
 }