__('jQuery Wire Tabs Plugin', __FILE__), 'summary' => __('Provides a jQuery plugin for generating tabs in ProcessWire.', __FILE__), 'version' => 110, 'permanent' => true, ); } const rememberTabsNever = -1; const rememberTabsSubmit = 0; const rememberTabsAlways = 1; // extending this class causes the class named JS and CSS files to automatically be loaded public function init() { $defaults = array( 'ulClass' => 'WireTabs nav', 'ulAttrs' => '', 'liActiveClass' => '', 'requestID' => ((string) $this->wire('process')) . ((int) $this->wire('input')->get('id')), 'aActiveClass' => 'on', 'rememberTabs' => (int) $this->rememberTabs, 'loadStyles' => true, 'cookieName' => 'WireTabs', 'tooltipAttr' => array( 'class' => 'tooltip', 'title' => '{tip}', ), ); $config = $this->wire()->config; $className = 'JqueryWireTabs'; $settings = $config->get($className); if(is_array($settings)) { $settings = array_merge($defaults, $settings); } else { $settings = $defaults; } $this->loadStyles = $settings['loadStyles']; /** @var JqueryCore $jQueryCore */ $jQueryCore = $this->wire()->modules->get('JqueryCore'); $jQueryCore->use('cookie'); $config->js($className, $settings); parent::init(); } public function getModuleConfigInputfields(array $data) { $inputfields = $this->wire(new InputfieldWrapper()); $f = $this->wire('modules')->get('InputfieldRadios'); $f->attr('name', 'rememberTabs'); $f->label = $this->_('Remember tab positions between requests?'); $f->addOption(self::rememberTabsNever, $this->_('Never')); $f->addOption(self::rememberTabsSubmit, $this->_('Only after form submit')); $f->addOption(self::rememberTabsAlways, $this->_('Always')); $f->attr('value', (isset($data['rememberTabs']) ? (int) $data['rememberTabs'] : self::rememberTabsSubmit)); $inputfields->add($f); return $inputfields; } /** * Pre-render a tab list (optional, as this is JS generated if not pre-rendered) * * @param array $tabs array of (tabID => title) * @param array $options to modify behavior * @return string * */ public function renderTabList(array $tabs, array $options = array()) { $settings = $this->wire('config')->get('JqueryWireTabs'); $defaults = array( 'class' => isset($options['class']) ? $options['class'] : $settings['ulClass'], 'id' => '', ); $options = array_merge($defaults, $options); $attrs = "class='$options[class]'" . ($options['id'] ? " id='$options[id]'" : ""); if(!empty($settings['ulAttrs'])) $attrs .= " $settings[ulAttrs]"; $out = "