From 1db9f295fa3e98a1f1472d2a8eda881333db5a43 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 5 Mar 2011 06:35:26 +0000 Subject: [PATCH] libs/web: repair and modernize FileBrowser widget, patches by Kevin Locke (#207) --- libs/web/htdocs/luci-static/resources/cbi.js | 18 ++++++++++++++++++ libs/web/htdocs/luci-static/resources/cbi/file.gif | Bin 0 -> 371 bytes libs/web/htdocs/luci-static/resources/cbi/folder.gif | Bin 0 -> 698 bytes libs/web/luasrc/view/cbi/browser.htm | 5 +++-- libs/web/luasrc/view/cbi/filebrowser.htm | 8 ++++---- 5 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 libs/web/htdocs/luci-static/resources/cbi/file.gif create mode 100644 libs/web/htdocs/luci-static/resources/cbi/folder.gif diff --git a/libs/web/htdocs/luci-static/resources/cbi.js b/libs/web/htdocs/luci-static/resources/cbi.js index 2bcfb8c3d..be0a5a8d7 100644 --- a/libs/web/htdocs/luci-static/resources/cbi.js +++ b/libs/web/htdocs/luci-static/resources/cbi.js @@ -402,6 +402,23 @@ function cbi_filebrowser(id, url, defpath) { browser.focus(); } +function cbi_browser_init(id, respath, url, defpath) +{ + function cbi_browser_btnclick(e) { + cbi_filebrowser(id, url, defpath); + return false; + } + + var field = document.getElementById(id); + + var btn = document.createElement('img'); + btn.className = 'cbi-image-button'; + btn.src = respath + '/cbi/folder.gif'; + field.parentNode.insertBefore(btn, field.nextSibling); + + cbi_bind(btn, 'click', cbi_browser_btnclick); +} + function cbi_dynlist_init(name, respath) { function cbi_dynlist_renumber(e) @@ -587,6 +604,7 @@ function cbi_dynlist_init(name, respath) for( var i = 0; i < inputs.length; i++ ) { var btn = document.createElement('img'); + btn.className = 'cbi-image-button'; btn.src = respath + ( (i+1) < inputs.length ? '/cbi/remove.gif' : '/cbi/add.gif' ); diff --git a/libs/web/htdocs/luci-static/resources/cbi/file.gif b/libs/web/htdocs/luci-static/resources/cbi/file.gif new file mode 100644 index 0000000000000000000000000000000000000000..3b1217dd654c6959b4dd97fad83ef626186aac32 GIT binary patch literal 371 zcmZ?wbhEHb6krfwSgOwO=;a5`&}?V#n2z-)rk?s^=Nj6%`^~-Q?==mbXC1h9`pm_a zJ=P67ET*3H=saLQ{j_)8HuL@?E|ZSCPdMs&_4bo#r@XE{|4_Brxch*^ymP;U605@t zCcgRjt!Rzz)3;yCrf*qt@%P5-e?EQtb>RNr-FN=3zVdt9tv~;%2NZv@FfuUMGw3h? z0mx4bY!ePlF7S}~*Qf5ia!Ljt+x!>LTXZ6AWOA+@HqBYFd{VlL+GG#qi3hcPI!-;^ zoUtx*|HG8YnkuX2->FckQdF&VVlG!suWo5&Z0~ILR#1@ZSC>~xZ|a>QDaYg_FVj6& zK~j=o;fy7d=CQD_vo4xdJ$c0jna%3bB1+K=2N~F9xHuL`pOlhfWMpDuW#y=Iz3Sq~ GU=08%rO(X( literal 0 HcmV?d00001 diff --git a/libs/web/htdocs/luci-static/resources/cbi/folder.gif b/libs/web/htdocs/luci-static/resources/cbi/folder.gif new file mode 100644 index 0000000000000000000000000000000000000000..22b583bb59d0ce46153152c18a33219a0b7c2944 GIT binary patch literal 698 zcmV;r0!95tNk%w1VGsZi0LFR%5=C(rN^}@XbQnr?8A@~+OLZAbb{|oDB~^bgUx+wp zk~?aWKWvgjZIMB7nn7`!LUEZwahgMNnnZG%P?O73md<9Byj7UcR+-RPo6=aE(`}i- zTAkEeoz+~P)?J|2UZB`sq1a!d*2kE{g|XOkwd;Ab>T|a1bhhkywd#Ad>UFp6cDL<(x9okm?0&fIc)IU+y6}9u?s>cL zfV%E`yz-8@;ex#Gf4%XLy5fSp@qxbce!umEzVU^>^M=3jgu(QP!1I*9=ZV7fhQs%Y z!}W;8`Hsf-i^%(t$N7xO{E^A|kjnj(%lw$n{+-VKn$iE9(f_H_`l{6Xr`i9>)!(q% z|FPQtvD^Q);Q!Lxt%1@HYPm;<{lFCn#%1@HYA^uK7a%Ew3Wn>^? zc_2$=c4=-POmAarWh@{vFflPLFf%PMG$3Ygav)4~LrE?mAW~&)Wnpt=WFTp7bZ;PZ zXk{Q!bz*F3V<1FtZDDC{E&w6<1OW;Fe*i210000G01yBG2gQJYf`f#Ge|UL`iiU%E z4Fdv^0C9|ec>{8Eb8>YId5n1ib8n<>Ks|P;sdtD5UQ)1C8wn8(4i5?li3bZ45)%*> zXk1rRPHh5-0dQtyVqi@~J~=fnVacIvSW!$zKRPxsEGSyo0%}i4K|41xEh!};Rs@Lx zX+u0XGcGD7A|D)}m^+h$#)}mvMu6y$;erx+p~k=%M <% - local t = require("luci.tools.webadmin") local v = self:cfgvalue(section) -%> <%+cbi/valueheader%> /> - '<%=self.default_path and ", '"..self.default_path.."'"%>);return false" alt="<%:Search file...%>" title="<%:Search file...%>" src="<%=resource%>/cbi/folder.png" style="vertical-align:bottom" /> + <%+cbi/valuefooter%> diff --git a/libs/web/luasrc/view/cbi/filebrowser.htm b/libs/web/luasrc/view/cbi/filebrowser.htm index f82957221..40480ec9d 100644 --- a/libs/web/luasrc/view/cbi/filebrowser.htm +++ b/libs/web/luasrc/view/cbi/filebrowser.htm @@ -54,10 +54,10 @@ $Id$ require("luci.dispatcher") local field = luci.http.formvalue('field') - local request = luci.dispatcher.context.path + local request = luci.dispatcher.context.args local path = { '' } - for i = 3, #request do + for i = 1, #request do if request[i] ~= '..' and #request[i] > 0 then path[#path+1] = request[i] end @@ -103,7 +103,7 @@ $Id$ if stat and stat.type == 'dir' then -%>
  • - Directory + <%:Directory%> <%=e%>/
  • <% end end -%> @@ -113,7 +113,7 @@ $Id$ if stat and stat.type ~= 'dir' then -%>
  • - File + <%:File%> <%=e%>
  • <% end end -%> -- 2.11.0