Skip to content

Client optimization, auto deploy static files, build more css/js files in one file

Notifications You must be signed in to change notification settings

aberdnikov/kohana-static-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How To Use

To add style or javascript in any place (Controller or View):

  • Adding real existing files of styles on server or other host

      StaticCss::instance()->addCss('/css/admin.css');
      StaticCss::instance()->addCss('http://jquickform.ru/cms/quickform.css');
    
  • The same but with browser condition

      // <!--[lte IE 7]><link rel="stylesheet" href="****.css" media="all" type="text/css" /><![endif]-->
      StaticCss::instance()->addCss('http://jquickform.ru/cms/quickform.css', 'lte IE 7');
    
  • Adding virtual stylesheet file (will be searching in APPDIR.'static-files'.$file and MODDIR.$module.'static-files'.$file)

      StaticCss::instance()->addCssStatic('style.css');
    
  • Inline styles adding

      StaticCss::instance()->addCssInline('.a:hover{color:red}');
    
  • Adding real existing files of scripts on server or other host

      StaticJs::instance()->addJs('/js/pirobox.js');
      StaticJs::instance()->addJs('http://jquickform.ru/vendors/jQuickForm/quickform.js');
    
  • Adding virtual javascript file

      StaticJs::instance()->addJsStatic('jquery/jquery-1.4.3.min.js');
    
  • Inline scripts adding

      StaticJs::instance()->addJsInline('alert(\'test!\');');
    
  • Adding scrripts that must be executed on page load

      StaticJs::instance()->addJsOnload(
          'jQuery(".del_link").click(
              function(){
                  alert("Mes-mes-messsssage!");
              }
          );',
          'qweq'
      );
    
  • Also creates gzipped static file for some hostings who not allow compress static files using apache

To load all added javascripts or scripts

    StaticJs::instance()->getJsAll();
    StaticCss::instance()->getCssAll();

About

Client optimization, auto deploy static files, build more css/js files in one file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages