function forAjaxTemplate()
 {
     $rendered = parent::forAjaxTemplate();
     if ($scripts = Requirements::get_custom_scripts()) {
         $rendered .= "<script type=\"text/javascript\">\n//<![CDATA[ \n" . $scripts . "</script>";
     }
     return $rendered;
 }
예제 #2
0
 public function testRequireJSIncludesAllConfigs()
 {
     $c = HtmlEditorConfig::get('configA');
     $c = HtmlEditorConfig::get('configB');
     HtmlEditorConfig::require_js();
     $js = Requirements::get_custom_scripts();
     $this->assertContains('"configA":{', $js);
     $this->assertContains('"configB":{', $js);
 }
 /**
  * @test
  */
 public function itDefinesInitialData()
 {
     $this->objFromFixture('File', 'File2');
     $field = $this->getNewField();
     $field->setCurrentPath('Folder2');
     $field->Field();
     $scripts = Requirements::get_custom_scripts();
     $this->assertContains('"title":"The Second File"', $scripts);
     $this->assertNotContains('"title":"The First File"', $scripts);
 }
 public function testNoTestsDoesNotIncludeYepnope()
 {
     Yepnope::eval_yepnope();
     $scripts = Requirements::get_custom_scripts();
     $javascripts = Requirements::backend()->get_javascript();
     $this->assertEquals('', $scripts, 'YepNope output found, even though no test were added');
     $this->assertEquals(array(), $javascripts, 'YepNope lib was included, even though no tests were added');
 }
예제 #5
0
 /**
  * @return string Compiled string of javascript-function-calls (needs to be evaluated on the client-side!)
  */
 protected static function get_javascript()
 {
     $js = "";
     // select only one status message (with priority on "bad" messages)
     $msg = "";
     foreach (self::$status_include_order as $status) {
         if (isset(self::$status_messages[$status])) {
             $msg = self::$status_messages[$status];
             break;
         }
     }
     if (!empty($msg)) {
         self::$rules[] = $msg;
     }
     $js .= implode("\n", self::$rules);
     $js .= Requirements::get_custom_scripts();
     // make sure behaviour is applied AFTER all registers are collected
     $js .= implode("\n", self::$behaviour_apply_rules);
     return $js;
 }