Ejemplo n.º 1
0
 public function testCssClasses()
 {
     $tag = new Tag('p', 'content text');
     $tag->setAttrib('class', 'lead')->addClass('text-center bg-primary text-muted')->removeClass('text-muted');
     $this->assertFalse($tag->hasClass('text-muted'));
     $this->assertEquals(['lead', 'text-center', 'bg-primary'], $tag->getClass());
     $this->assertEquals('<p class="lead text-center bg-primary">content text</p>', $tag->render());
 }
Ejemplo n.º 2
0
 /**
  * 
  * @param string $device xs|sm|md|lg|print
  * @param string $type   block|inline|inline-block|print
  * @return \PhpBootstrap\Html\Form\Element
  */
 public function setVisibility($device, $type = 'block')
 {
     if (!in_array($device, array('xs', 'sm', 'md', 'lg', 'print'))) {
         return $this;
     }
     if (!in_array($type, array('block', 'inline', 'inline-block', 'hidden'))) {
         return $this;
     }
     $classes = $this->tag->getClass();
     foreach ($classes as $class) {
         if (strstr($class, "visible-{$device}") || $class == "hidden-{$device}") {
             $this->tag->removeClass($class);
         }
     }
     if ($type == 'hidden') {
         $this->tag->addClass("hidden-{$device}");
     } else {
         $this->tag->addClass("visible-{$device}-{$type}");
     }
     return $this;
 }