]> source.dussan.org Git - nextcloud-server.git/commitdiff
add js versions of linkTo, imagePath,addScript and addStyle
authorRobin Appelman <icewind1991@gmail.com>
Mon, 25 Jul 2011 20:30:55 +0000 (22:30 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Mon, 25 Jul 2011 20:30:55 +0000 (22:30 +0200)
core/js/js.js

index 9a14cb8ed4f9389143c111b0be9e6233c75bdcbd..1c66e1873665b919484c40ac999f768c199d960d 100644 (file)
@@ -18,6 +18,44 @@ function t(app,text){
        }
 }
 
+OC={
+       webroot:oc_webroot,
+       coreApps:['files','admin','log','search','settings'],
+       linkTo:function(app,file){
+               return OC.filePath(app,'',file);
+       },
+       filePath:function(app,type,file){
+               var isCore=OC.coreApps.indexOf(app)!=-1;
+               app+='/';
+               var link=OC.webroot+'/';
+               if(!isCore){
+                       link+='apps/';
+               }
+               link+=app;
+               if(type){
+                       link+=type+'/'
+               }
+               link+=file;
+               return link;
+       },
+       imagePath:function(app,file){
+               return OC.filePath(app,'img',file);
+       },
+       addScript:function(app,script,ready){
+               var path=OC.filePath(app,'js',script+'.js');
+               if(ready){
+                       $.getScript(path,ready);
+               }else{
+                       $.getScript(path);
+               }
+       },
+       addStyle:function(app,style){
+               var path=OC.filePath(app,'css',style+'.css');
+               var style=$('<link rel="stylesheet" type="text/css" href="'+path+'"/>');
+               $('head').append(style);
+       }
+}
+
 $(document).ready(function(){
        // Put fancy stuff in here
 });