]> git.nbdom.net Git - nb.git/commitdiff
www/dbq/dbq.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 13 Oct 2017 15:29:08 +0000 (16:29 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 13 Oct 2017 15:29:08 +0000 (16:29 +0100)
lib/php/page.php
www/dbq/dbq.php
www/dbq/html/default.js
www/dbq/html/default.min.css
www/dbq/html/default.min.js

index a5a48a46b74e6ec68791b833a3aa15b22df4aae8..f9b065165dc14871ceb87ce70fa83843243f38aa 100644 (file)
@@ -501,7 +501,26 @@ class Page extends nb {
           $html = empty($v[2]) ? $v[1] : self::tag('a',$v[1],'href="'.$v[2].'"');
         } else {
           $text = $v[0];
-          $html = empty($v[1]) ? $v[0] : self::tag('a',$v[0],'href="'.$v[1].'"');
+          $attr = $v[1];
+
+            if (is_array($attr)) {
+          # k => v
+            $attr_ = $attr;
+            $attr = [];
+
+            foreach ($attr_ as $kk=>$vv) {
+              $attr[] = $kk. '="' . $vv .'"';
+            }
+
+            $attr = join(' ',$attr);
+
+          } else {
+            # href
+            $attr = 'href="'.$v[1].'"';
+
+          }
+
+          $html = empty($v[1]) ? $v[0] : self::tag('a',$v[0],$attr);
         }
 
       } else {
index 629c9f0ae7fbce5a3e7b987fb8dde7a9ae4cfc33..85b08aa7f055bd6e4b68f54499a6b632d3476542 100644 (file)
@@ -355,13 +355,14 @@ class DbQ extends nb {
     $params = $this->params;
     $ext = $this->ext;
 
-    $title = array_filter(array_unique(array_slice(array_values($params),1,3)),
-      function($v){
-        return(in_array($v,self::ACTIONS_NO_TITLE) ? '' : trim($v));
-      }
-    );
+    $title = [];
+    if (!empty($this->title)) $title['title'] = $this->title;
+    foreach (array_unique(array_slice(array_keys($params),1,3)) as $k) {
+      if (in_array($k,self::ACTIONS_NO_TITLE)) continue;
+      $v = $params[$k];
+      $title[$k] = $v;
+    }
 
-    if (!empty($this->title)) array_unshift($title,$this->title);
 
     $path = '/';
     $nav = [];
@@ -373,7 +374,14 @@ class DbQ extends nb {
         $nav[] = [$v,'/'];
 
       } else {
-        $nav[] = [$this->prettyText($v),"$path".urlencode($v).".".$ext];
+
+        $nav[] = [
+          $this->prettyText($v),
+          [
+            'href' => "$path" . urlencode($v) . "." . $ext,
+            'class' => $k,
+          ],
+        ];
         $path .= $v."/";
 
       }
index 2164f4bd0ddac6e6209c10f415c7758febb0a9aa..ff9d76db5979a2f61c638ac78197e0b02780bea6 100644 (file)
@@ -104,6 +104,10 @@ document.addEventListener("DOMContentLoaded", function() {
 
   });
 
+// NB 13.10.17   if (document.querySelector("h1")) {
+// NB 13.10.17     document.querySelector("h1").insertAdjacentHTML("afterbegin",'zaza');
+// NB 13.10.17   }
+
   if (document.querySelector(".nav.bottom") && document.querySelector("table.rows")) {
     document.querySelector("table.rows").insertAdjacentHTML("beforebegin","<div class=\"nav top\">"+document.querySelector(".nav.bottom").innerHTML+"</div>");
   }
index bed61032ce640cbd07dee1302bf3a19799dcc372..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1 +0,0 @@
-html{font:90% 'Trebuchet MS',sans-serif;background-color:#eee}body{display:table;margin-left:auto;margin-right:auto;padding-left:1em;padding-right:1em;color:#444}h1{margin:0 0 .2em 0;font-size:180%;padding-bottom:.3em;margin-bottom:.5em;border-bottom:dashed 1px #444}a{color:inherit}div>a,li a,p a,td a{color:#3572b0}a,a:visited{text-decoration:none}.button:hover,a:hover{opacity:.8}ul{padding:0;margin:0}li{list-style:none;padding:0 0 0 .3em}table{border-collapse:collapse}td,th{padding:.2em .7em}th a.sort{padding:0 .3em}input:not([type]),input[type=''],input[type=date],input[type=email],input[type=password],input[type=text],input[type=url],select,textarea{border-radius:3px;border:solid 1px #ddd;padding:.3em .4em;box-shadow:0 1px 1px #eee}input[size]{max-width:70%}div.row div label:after,form label:after{content:':'}form input,form label,form select{vertical-align:middle;margin:.2em .4em .2em 0}.block,.menu,div.row,form.edit,iframe,object,pre,table.rows,ul.row{border-radius:4px;border-spacing:0;padding:.5em .2em;margin-bottom:.5em;border:solid 1px #ddd;background-color:#fafafa;box-shadow:0 1px 2px #eee}.rows{padding:0}table.rows{border-style:hidden;border-collapse:collapse;box-shadow:0 0 0 1px #ddd;table-layout:fixed}table.rows.fixed{width:100%}table.rows tr:nth-child(even) td{background-color:#fefefe}div.row div,table.rows td,table.rows th,ul.row li{border-bottom:solid 1px #ddd}div.row div,table.rows tr:last-child td,ul.row li{border-bottom:none}table.rows td,table.rows th{border-right:dashed 1px #ddd}table.rows th{text-align:left}table.rows td{padding:.3em .3em}table.rows.fixed td{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}table.rows td.delete,table.rows td.view{width:1%;white-space:nowrap}table.rows.fixed th.view{width:2em}table.rows.fixed th.delete{width:2.7em}div.row div{margin:0}div.row div label,ul.row li label{padding:.1em .5em .1em 0;min-width:20%;display:inline-block}.button{font:inherit;display:inline-block;text-decoration:none;line-height:1.5em;cursor:pointer;border-radius:4px;white-space:nowrap;box-sizing:border-box;margin:0 .1em 0 0;cursor:pointer;padding:0 .3em;border:none;color:#3572b0;background-color:#eee;background:linear-gradient(to bottom right,#eee,#dddDDD);box-shadow:0 1px 1px #bbb}.buttons,.center,.menu,.nav,.rows,td.button{margin-left:auto;margin-right:auto;display:table}form.menu{padding:.5em;background-color:#fafafa}form.menu .button.add{float:right;margin-top:.3ex;display:inline}form.menu .criterias{border-top:dashed 1px #ddd;margin-top:.3em;padding-top:.3em}form.menu .criterias span.label{border-right:solid 1px #fff;padding:.2em .1em;margin:.2em .2em 0 0;border-radius:3px}form.menu .criterias span.label:last-child{border-right:none}form.menu select:focus{max-width:auto}form.menu select{max-width:20%}form.menu .criterias input[type=text]:focus{width:auto}form.menu .criterias input[type=text]{width:4em}form.edit .fields label{width:25%;text-align:right;display:inline-block;margin-right:1em;vertical-align:top}form.edit .fields .label span{width:54%;display:inline-block;text-align:left;vertical-align:middle;margin-top:.2em}form.Wedit .fields .label span input{vertical-align:bottom!important}form.edit .fields input[size],form.edit .fields select,form.edit .fields textarea{width:65%}
index 0302e723fd2eb39a4f54ebd17269c3ad362e0ec9..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1 +0,0 @@
-function form_clean(e){var t;for(i=0;i<e.length;i++)"none"!=(t=e.elements[i]).style.display&&("text"==t.type?t.value="":!t.type.match(/^select/)||"limit"!=t.name&&"format"!=t.name||(t.selectedIndex=0))}function form_submit_clean(e){var t=0,n="",o=e.getAttribute("action");if("get"!=e.getAttribute("method"))return!0;for(t=0;t<e.length;t++){var r=e[t];r.name&&(""!=r.value&&"undefined"!=r.value&&(n+=(n?"&":"?")+encodeURI(r.name)+"="+encodeURI(r.value)))}return n=("?"==o?"":o)+n,e.reset(),window.location=n,!1}document.addEventListener("DOMContentLoaded",function(){NodeList.prototype.forEach=Array.prototype.forEach,document.querySelectorAll("form").forEach(function(e){e.onsubmit=function(){if(this.elements.limit){var e=this.elements.limit;"undefined"!=window._dbq.default_limit&&e.value==window._dbq.default_limit&&e.removeAttribute("value")}return form_submit_clean(this)}}),document.querySelectorAll("form.menu").forEach(function(e){e.setAttribute("action",window.location.toString().replace(/\?.*$/,"")),e.querySelectorAll("form.menu select.format").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["table.base"]+"."+this.value),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.tables").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",window._dbq["db.base"]+"/"+this.value+".html"),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.limit").forEach(function(e){e.onchange=function(){return this.form.onsubmit()}})}),document.querySelector(".nav.bottom")&&document.querySelector("table.rows")&&document.querySelector("table.rows").insertAdjacentHTML("beforebegin",'<div class="nav top">'+document.querySelector(".nav.bottom").innerHTML+"</div>"),document.querySelectorAll("table").forEach(function(e){parseInt(e.offsetWidth)>parseInt(window.innerWidth)&&(e.className=e.className.replace(/(^| +)fixed($| )/,"")+" fixed",e.className=e.className.trim())}),window._dbq.perm<window._dbq.perms.write&&(document.querySelectorAll("form.edit").forEach(function(e){e.setAttribute("onsubmit","return false")}),document.querySelectorAll("form.edit input[type=submit],form.edit input[type=reset]").forEach(function(e){e.setAttribute("style","display:none")})),document.querySelectorAll("form.menu input[type=submit]").forEach(function(e){e.insertAdjacentHTML("afterend",'&nbsp;<input type="button" class="clear '+e.className+'" onclick="form_clean(this.form)" value="'+window._dbq["text.clear"]+'" />'+(window._dbq.perm>=window._dbq.perms.write?'&nbsp;<input type="button" class="add '+e.className+'" onclick="window.location=\''+window._dbq["table.base"]+'/add/\'" value="'+window._dbq["text.add"]+'"/>':""))})});