From fbf9e9d682e580dc2d020d23ecc173315327ec1e Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 9 Mar 2017 16:15:10 +0100 Subject: [PATCH 01/10] integrate QC plugin (ajax branch) This refactors the page-attribute area a bit and intergrates the new ajax branch of the QC plugin. I'm not really happy about the included file - it should probably be moved to our Template class instead. --- css/area_nav-breadcrumb.less | 139 ------------------------------ css/area_nav-page-attributes.less | 30 +++++++ css/plugins/qc.less | 28 +++++- js/plugins/do_tasks.js | 94 ++++++++++---------- js/plugins/qc.js | 37 ++++++++ main.php | 3 +- script.js | 1 + style.ini | 1 + tpl/nav-page-attributes.php | 57 ++++++++++++ tpl/nav-page-quality-tasks.php | 54 ------------ 10 files changed, 200 insertions(+), 244 deletions(-) create mode 100644 css/area_nav-page-attributes.less create mode 100644 js/plugins/qc.js create mode 100755 tpl/nav-page-attributes.php delete mode 100755 tpl/nav-page-quality-tasks.php diff --git a/css/area_nav-breadcrumb.less b/css/area_nav-breadcrumb.less index cd3f5b6..4376701 100755 --- a/css/area_nav-breadcrumb.less +++ b/css/area_nav-breadcrumb.less @@ -67,145 +67,6 @@ padding: .1em .1em 0; } } - - -/* + + + + + icon list + + + + + */ - .page-attributes { - list-style: none; - float: right; - display: inline-block; - max-width: 30%; - margin: -.45em 0 0; - padding: 0; - @media @screen_max-xs{ - max-width: 90%; - } - - > li { - .btn-usertools-wrapper(); // uniform li - .btn-usertools-num(); - - float: left; - - > strong, - > a { - display: block; - width: auto; - min-height: 2em; - border: 1px solid @color-border; - border-radius: @border-radius; - color: @color-nav; - text-align: center; - margin: 0; - } - - .prefix { - .btn-prefix (); - .icon-clipboard(); - } - -/* check !!! */ - &.do_none { - position: relative; - - strong { - background-color: @color-site-bg; - } - - .num { - background-color: @color-border; - color: @color-nav; - } - } -/* end check !!! */ - - &.plugin__qc { - display: inline-block; - overflow: visible; - position: static; - } - } // li - - a { - transition: @transition color, @transition background-color, @transition border-color; - - &[aria-expanded="false"] + #plugin__qc__wrapper { - display: none; - } - - &:hover, - &:active, - &:focus { - background-color: @button_color; - border-color: @button_background; - color: @button_background; - - .prefix { - color: @button_background; - } - } - } - - #plugin__qc__wrapper { - position: absolute; - right: 0; - width: auto; - border: 0 none; - background: @background_page-header; - background: -webkit-linear-gradient(top, @background_page-header, @color-content-bg); - background: linear-gradient(top, @background_page-header, @color-content-bg); - box-shadow: @box-shadow-bottom; - z-index: 2000; - - #plugin__qc__out{ - h1 { - font-size: @font-size-head3; - } - - h2 { - margin-top: 1.6em; - font-size: @font-size-head5; - } - > h1, - > h2, - > p, - > dl, - > div { - padding-left: 1rem; - margin-left: 0; - } - - > div p { - padding-left: 0; - margin-left: 0; - } - } - - &[aria-hidden="false"] { - margin-top: .5rem; - } - } - - #plugin__qc__icon { - display: none; - } - - #plugin__qc__link { - position: relative; - - .prefix { - .icon-emo-happy(); - - width: 100%; - font-size: @font-size-default; - - &::before { - width: 100%; - margin: .1em 0 0; - } - } - } - } } diff --git a/css/area_nav-page-attributes.less b/css/area_nav-page-attributes.less new file mode 100644 index 0000000..228f667 --- /dev/null +++ b/css/area_nav-page-attributes.less @@ -0,0 +1,30 @@ +/** + * Page Attribute Icons in the breadcrumb bar + */ +.page-attributes { + list-style: none; + float: right; + display: inline-block; + max-width: 30%; + margin: -.45em 0 0; + padding: 0; + @media @screen_max-xs { + max-width: 90%; + } + + > li { + .btn-usertools-wrapper(); // uniform li + .btn-usertools-num(); + + position: relative; + float: left; + display: block; + width: auto; + min-height: 2em; + border: 1px solid @color-border; + border-radius: @border-radius; + color: @color-nav; + text-align: center; + margin: 0; + } +} diff --git a/css/plugins/qc.less b/css/plugins/qc.less index dff5a32..42c57a5 100644 --- a/css/plugins/qc.less +++ b/css/plugins/qc.less @@ -1,6 +1,26 @@ -#plugin__qc__wrapper{ - font-size: @font-size-default; - p{ - font-size: @font-size-default; +/** + * Styles for the QC plugin + */ + +// icon in page attributes +.page-attributes .plugin_qc { + .qc_icon { + margin: 0; + width: 2em; + height: 2em; + + svg { + margin-top: 0.1em; + margin-left: 0.1em; + width: 1.6em; + height: 1.6em; + } } } + +// output +.qc-output { + font-size: 90%; + border-bottom: 1px solid @ini_border; +} + diff --git a/js/plugins/do_tasks.js b/js/plugins/do_tasks.js index 78a8f34..1ff8717 100755 --- a/js/plugins/do_tasks.js +++ b/js/plugins/do_tasks.js @@ -1,47 +1,49 @@ -( function( $, spc ) { - - var togglePageAnalysis = function(){ - var $this = $('.page-attributes').find('.plugin__qc'); - try{ - var $link = $this.find('#plugin__qc__link'), - $container = $this.find('#plugin__qc__wrapper'); - - if($container.length < 1){ - $this.remove(); - }else{ - $container.attr('aria-hidden','true'); - var $icon = $container.find('#plugin__qc__icon'); - $container.find('#plugin__qc__out').removeAttr('style'); - $link.on( 'click', function(e){ - e.preventDefault(); - $icon.trigger('click'); - var oldState = ($link.attr('aria-expanded')=== "true" ); - $container.attr('aria-hidden',oldState); - $(this).attr('aria-expanded',!oldState); - - }); - - if($container.length > 0){ - var num = $container.attr('data-errors'); - if(num){ - $link.find('.num').empty().append(num); - $link.closest('li').removeClass('do_none'); - } - } - - } - - }catch(err){ - $this.remove(); - } - }; - - $(function(){ - togglePageAnalysis(); - }); - -} )( jQuery, spc ); - - - +// FIXME figure out what this did and why +// ( function( $, spc ) { +// +// var togglePageAnalysis = function(){ +// var $this = $('.page-attributes').find('.plugin__qc'); +// try{ +// var $link = $this.find('#plugin__qc__link'), +// $container = $this.find('#plugin__qc__wrapper'); +// +// if($container.length < 1){ +// $this.remove(); +// }else{ +// $container.attr('aria-hidden','true'); +// var $icon = $container.find('#plugin__qc__icon'); +// $container.find('#plugin__qc__out').removeAttr('style'); +// $link.on( 'click', function(e){ +// e.preventDefault(); +// $icon.trigger('click'); +// var oldState = ($link.attr('aria-expanded')=== "true" ); +// $container.attr('aria-hidden',oldState); +// $(this).attr('aria-expanded',!oldState); +// +// }); +// +// if($container.length > 0){ +// var num = $container.attr('data-errors'); +// if(num){ +// $link.find('.num').empty().append(num); +// $link.closest('li').removeClass('do_none'); +// } +// } +// +// } +// +// }catch(err){ +// $this.remove(); +// } +// }; +// +// $(function(){ +// togglePageAnalysis(); +// }); +// +// } )( jQuery, spc ); +// +// +// +// diff --git a/js/plugins/qc.js b/js/plugins/qc.js new file mode 100644 index 0000000..65d795b --- /dev/null +++ b/js/plugins/qc.js @@ -0,0 +1,37 @@ +/** + * Add custom QC functionality instead of using the plugin's mechanism + */ +jQuery(function () { + var $panel = jQuery('div.qc-output').hide(); + + // load summary + jQuery('.page-attributes .plugin_qc a').load( + DOKU_BASE + '/lib/exe/ajax.php', + { + call: 'plugin_qc_short', + id: JSINFO['id'] + }, + function () { + jQuery(this).find('span span').addClass('num'); + } + ).click(function (e) { + e.preventDefault(); + + if ($panel.html() == '') { + // load output + $panel.load( + DOKU_BASE + '/lib/exe/ajax.php', + { + call: 'plugin_qc_long', + id: JSINFO['id'] + }, + function () { + $panel.dw_show(); + } + ); + } else { + $panel.dw_toggle(); + } + }); + +}); diff --git a/main.php b/main.php index 2934e3f..22fa813 100755 --- a/main.php +++ b/main.php @@ -230,7 +230,7 @@ $classWideContent = ($ACT === "show") ? "": "wide-content "; /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ /* page quality / page tasks */ /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ - include('tpl/nav-page-quality-tasks.php'); + include('tpl/nav-page-attributes.php'); ?> +
'; +} + + +if($qcPlugin && $qcPlugin->shouldShow()) { + echo '
  • '; // filled by javascript +} + + +if($doPlugin !== null) { + $count = $doPlugin->getPageTaskCount(); + $num = $count['count']; + $title = ""; + + if($num == 0) { // no tasks - does not exist do in plug-in + $class = "do_none"; + $title = tpl_getLang('tasks_page_none'); + } elseif($count['undone'] == 0) { // all tasks done + $class = 'do_done'; + $title = $this->getLang('title_alldone'); + } elseif($count['late'] == 0) { // open tasks but none late + $class = 'do_undone'; + $title = sprintf($this->getLang('title_intime'), $count['undone']); + } else { // late tasks + $class = 'do_late'; + $title = sprintf($this->getLang('title_late'), $count['undone'], $count['late']); + } + $markup = "
  • " . tpl_getLang('prefix_tasks_page') . " " . $num . "
  • "; + + echo $markup; +} + +if($doPlugin !== null || $qcPlugin !== null) { + echo ""; +} + + + +/* + + +$out = '
    '; +$out .= $count['undone']; +$out .= '
    '; + +if($return) return $out; +echo $out;*/ diff --git a/tpl/nav-page-quality-tasks.php b/tpl/nav-page-quality-tasks.php deleted file mode 100755 index 2a1977c..0000000 --- a/tpl/nav-page-quality-tasks.php +++ /dev/null @@ -1,54 +0,0 @@ - - -"; - } - if ($qc) { - echo "
  • ".tpl_getLang('quality_trigger')."0"; - $qc->tplErrorCount(); - echo "
  • "; - } - if ($doPlugin !== null ) { - $count = $doPlugin->getPageTaskCount(); - $num = $count['count']; - $title = ""; - - if($num == 0){ // no tasks - does not exist do in plug-in - $class = "do_none"; - $title = tpl_getLang('tasks_page_none'); - } elseif($count['undone'] == 0){ // all tasks done - $class = 'do_done'; - $title = $this->getLang('title_alldone'); - }elseif($count['late'] == 0) { // open tasks but none late - $class = 'do_undone'; - $title = sprintf($this->getLang('title_intime'), $count['undone']); - } else { // late tasks - $class = 'do_late'; - $title = sprintf($this->getLang('title_late'), $count['undone'], $count['late']); - } - $markup = "
  • ".tpl_getLang('prefix_tasks_page')." ".$num."
  • "; - - echo $markup; - } - - if ($doPlugin !== null ||$qc ) { - echo ""; - } - -/* - - -$out = '
    '; -$out .= $count['undone']; -$out .= '
    '; - -if($return) return $out; -echo $out;*/ From a94fc7a514a474778ffdc5e7e998f441ce1d2576 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 9 Mar 2017 16:16:19 +0100 Subject: [PATCH 02/10] give tabs a class for special styling I nearly needed that but then didn't. but it might come in handy --- tpl/nav-meta-box.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tpl/nav-meta-box.php b/tpl/nav-meta-box.php index 77328c5..abf95a3 100755 --- a/tpl/nav-meta-box.php +++ b/tpl/nav-meta-box.php @@ -9,7 +9,7 @@ $tabs = \dokuwiki\template\sprintdoc\Template::getInstance()->getMetaBoxTabs();
  •  
  • '; + echo '
  • '; echo '