Example #1
0
 /**
  * Page header blade directive compiler.
  * @pageHeader($title, $description, $icon, $template)
  *
  * @param string|array $styles
  * @param null $category
  * @param string $group
  */
 public function handle($styles, $group = 'footer', $category = null)
 {
     foreach ((array) $styles as $style) {
         if (!str_contains('.css', $style)) {
             $style .= ".css";
         }
         /** @var \Yajra\CMS\Entities\FileAsset $getData */
         $getData = app(Repository::class)->getByName($style, $category);
         Asset::add($getData ? $getData->url : $style, $group, $category);
     }
 }
 /**
  * Page header blade directive compiler.
  * @pageHeader($title, $description, $icon, $template)
  *
  * @param string $add
  * @param string $after
  */
 public function handle($add, $after)
 {
     Asset::addAfter($add, $after);
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function getLayout($id)
 {
     Asset::add(['common/js/jquery.gridster.with-extras.js', 'admin/js/layout.js', 'common/css/gridster.min.css']);
     $page = Page::whereId($id)->first();
     foreach ($page->widgets as &$widget) {
         if ($widget->widget_name == 'text') {
             $text = Text::whereId($widget->widget_id)->first();
             $widget['title'] = $text['title'];
             $widget['text'] = $text['text'];
         }
     }
     return view('admin.pages.layout', ['page' => $page]);
 }
 /**
  * Create a new controller instance.
  *
  * @return void
  */
 public function __construct()
 {
     $this->middleware('guest');
     Asset::add(['common/js/jquery-2.1.4.min.js', 'common/js/bootstrap.min.js', 'http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css', 'https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.5/flatly/bootstrap.min.css']);
 }
 /**
  * Page header blade directive compiler.
  * @pageHeader($title, $description, $icon, $template)
  *
  * @param string $add
  * @param string $before
  */
 public function handle($add, $before)
 {
     Asset::addAfter($add, $before);
 }
 /**
  * Test the addAfter method.
  *
  * @return void
  */
 public function testAddAfter()
 {
     Asset::$css = [];
     $res = new Resource();
     $asset1 = 'style.css';
     $res->add($asset1);
     $asset2 = 'style1.css';
     $res->add($asset2);
     $asset3 = 'style2.css';
     $res->addAfter($asset3, $asset1);
     $styles = array_keys(Asset::$css);
     $this->assertEquals('/asset/' . $asset3, $styles[1]);
 }
Example #7
0
 public function testCachebusterFunction()
 {
     Asset::$js = array();
     Asset::$css = array();
     function _hash($name)
     {
         if ($name == '1.js') {
             return '';
         }
         if ($name == '2.css') {
             return null;
         }
         return substr($name, 0, 1);
     }
     Asset::setCacheBusterGeneratorFunction('_hash');
     Asset::add(array('1.js', '2.js', '3.js'));
     Asset::add(array('1.css', '2.css', '3.css'));
     $this->expectOutputString('/1.js,/2.js?2,/3.js?3,/1.css?1,/2.css,/3.css?3,', Asset::jsRaw(','), Asset::cssRaw(','));
 }
 /**
  * Return scripts.
  *
  * @param array $arguments
  *
  * @return string
  */
 public function scripts(...$arguments)
 {
     return Asset::scripts(...$arguments);
 }