/** * @return string */ public function JS() { $code = $this->getCode(); if (is_string($code)) { $code = array($code); // blöde interfaces vom js helper } elseif ($code instanceof \Psc\JS\Expression) { $code = array($code->JS()); } // load-wrappers (von innen nach außen) if ($this->onPscReady === 'main') { // non blocking mode (is save to use in html inline scripts directly) $this->unshiftRequirement('app/main'); $this->unshiftRequirementAlias('main'); $this->unshiftRequirement('jquery'); $this->unshiftRequirementAlias('jQuery'); $code = Helper::bootLoad($this->getRequirements(), $this->requirementsAliases, $code); } elseif ($this->onPscReady) { // is only save to use in ajax requests / inline scripts where window.requireLoad is already defined $this->unshiftRequirement('jquery'); $this->unshiftRequirementAlias('jQuery'); $code = Helper::requireLoad($this->getRequirements(), $this->requirementsAliases, $code); } elseif (count($req = $this->getRequirements()) > 0) { $code = Helper::requirejs($req, array(), $code); } else { $code = count($code) > 1 ? \Webforge\Common\ArrayUtil::join($code, "%s\n") : current($code); } return TPL::miniTemplate((string) $code, (array) $this->vars); }
/** * Wählt den Index aus, der direkt nach dem Laden der Seite geladen werden soll * * dies initialisiert das widget auch auf Javascript-Basis */ public function select($index) { $this->init(); $this->select = $index; $this->html->getTemplateContent()->select = jsHelper::embed(jsHelper::bootLoad(array('app/main'), array('main'), sprintf("var tabs = main.getTabs(), tab = tabs.tab({index: %d});\n tabs.select(tab);", $this->select))); return $this; }