Sophivorus has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/363739 )

Change subject: General update for a cleaner syntax compatible with VisualEditor
......................................................................


General update for a cleaner syntax compatible with VisualEditor

Change-Id: I5afebd177c1a1c0ccaf21fe3bec94c80f9ae9bb5
---
M DebateTree.css
M DebateTree.js
M DebateTree.php
M extension.json
M i18n/en.json
M i18n/es.json
M i18n/qqq.json
7 files changed, 56 insertions(+), 63 deletions(-)

Approvals:
  Sophivorus: Verified; Looks good to me, approved



diff --git a/DebateTree.css b/DebateTree.css
index ed1bad1..b6588a1 100644
--- a/DebateTree.css
+++ b/DebateTree.css
@@ -1,23 +1,20 @@
-.debatetree-argument,
-.debatetree-dummy {
-       background: #f9f9f9;
-       border: 1px solid #aaa;
-       border-radius: 10px;
-       box-shadow: 5px 5px 10px #aaa;
+.debatetree ul {
+       list-style: none;
+       margin: 0 !important;
+}
+
+.debatetree ul li {
+       background: #f8f9fa;
+       border: 1px solid #a2a9b1;
        cursor: pointer;
-       margin: 1em 0;
+       margin: 1em 0 0 0 !important;
        padding: 1em;
-       overflow: hidden;
 }
 
 .debatetree-status {
        float: right;
-       margin-left: 10px;
-       padding: 0 5px;
-}
-
-.debatetree-counts {
-       color: #aaa;
+       margin-left: 1em;
+       padding: 0 .5em;
 }
 
 .debatetree-sustained {
@@ -26,4 +23,9 @@
 
 .debatetree-refuted {
        background: #f55;
+}
+
+.debatetree-counts {
+       color: #a2a9b1;
+       font-size: small;
 }
\ No newline at end of file
diff --git a/DebateTree.js b/DebateTree.js
index 3ad6bfc..d2eeee2 100644
--- a/DebateTree.js
+++ b/DebateTree.js
@@ -1,30 +1,39 @@
 var DebateTree = {
 
-       // GETTERS
-
+       /**
+        * Get all the arguments in the page
+        */
        getArguments: function () {
-               return $( '.debatetree-argument' );
+               return $( '.debatetree ul li' );
        },
 
+       /**
+        * Get the objections to the given argument
+        */
        getObjections: function ( argument ) {
-               return $( argument ).children( '.debatetree-argument' );
+               return $( argument ).children( 'ul' ).children( 'li' );
        },
 
-       getDescendants: function ( argument ) {
-               return $( '.debatetree-argument', argument );
-       },
-
+       /**
+        * Get the sustained objections to the given argument
+        */
        getSustainedObjections: function ( argument ) {
                return DebateTree.getObjections( argument ).filter( 
DebateTree.isSustained );   
        },
 
-       // FILTERS
+       /**
+        * Get the nested objections of the given argument
+        */
+       getNestedObjections: function ( argument ) {
+               return $( 'li', argument );
+       },
 
+       /**
+        * Return true if the given argument is sustained
+        */
        isSustained: function ( index, argument ) {
                return DebateTree.getSustainedObjections( argument ).length ? 
false : true;
        },
-
-       // DOM MODIFIERS
 
        /**
         * Prepend the status to the argument
@@ -38,49 +47,38 @@
        },
 
        /**
-        * Append the stats to the argument
+        * Append the counts to the argument
         */
        addCounts: function ( index, argument ) {
                var objectionCount = DebateTree.getObjections( argument 
).length,
                        sustainedObjectionCount = 
DebateTree.getSustainedObjections( argument ).length,
-                       descendantCount = DebateTree.getDescendants( argument 
).length,
-                       text = mw.message( 'debatetree-counts', objectionCount, 
sustainedObjectionCount, descendantCount ),
+                       nestedObjectionCount = DebateTree.getNestedObjections( 
argument ).length,
+                       text = mw.message( 'debatetree-counts', objectionCount, 
sustainedObjectionCount, nestedObjectionCount ),
                        span = $( '<span>' ).addClass( 'debatetree-counts' 
).text( text );
 
                if ( objectionCount ) {
-                       DebateTree.getObjections( argument ).first().before( 
span );
+                       $( argument ).children( 'ul' ).first().before( span );
                } else {
                        $( argument ).append( ' ', span );
                }
        },
 
        /**
-        * Add a dummy objection to the argument
+        * Toggle the objections of the clicked argument
         */
-       addDummyObjection: function ( index, argument ) {
-               var editLink = $( '#ca-edit a' ).attr( 'href' ),
-                       dummyContent = mw.message( 'debatetree-dummy', editLink 
).parse(),
-                       dummyObjection = $( '<div>' ).addClass( 
'debatetree-argument' ).html( dummyContent );
-
-               $( argument ).append( dummyObjection );
-       },
-
-       // EVENT HANDLERS
-
        toggleObjections: function ( event ) {
                DebateTree.getObjections( this ).toggle();
                event.stopPropagation();
        },
 
        /**
-        * Initialisation script
+        * Initialization script
         */
        init: function () {
-               var arguments = DebateTree.getArguments();
-               arguments.each( DebateTree.addStatus );
-               arguments.each( DebateTree.addCounts );
-               arguments.each( DebateTree.addDummyObjection );
-               arguments.click( DebateTree.toggleObjections ).click();
+               var args = DebateTree.getArguments();
+               args.each( DebateTree.addStatus );
+               args.each( DebateTree.addCounts );
+               args.click( DebateTree.toggleObjections ).click();
        }
 };
 
diff --git a/DebateTree.php b/DebateTree.php
index 2e1200d..bc80f2e 100644
--- a/DebateTree.php
+++ b/DebateTree.php
@@ -8,19 +8,15 @@
        }
 
        static function onParserFirstCallInit( Parser &$parser ) {
-               $parser->setHook( 'argument', 'DebateTree::renderArgument' );
-               $parser->setHook( 'objection', 'DebateTree::renderArgument' );
+               $parser->setHook( 'debatetree', 'DebateTree::render' );
        }
 
-       static function renderArgument( $input, array $args, Parser $parser, 
PPFrame $frame ) {
-
-               $content = $parser->recursiveTagParse( $input, $frame );
-
+       static function render( $input, array $ARGS, Parser $parser, PPFrame 
$frame ) {
                return Html::rawElement(
                        'div', [
-                               'class' => 'debatetree-argument'
+                               'class' => 'debatetree'
                        ],
-                       $content
+                       $input
                );
        }
 }
\ No newline at end of file
diff --git a/extension.json b/extension.json
index 7e1fa6d..d52a8bc 100644
--- a/extension.json
+++ b/extension.json
@@ -1,7 +1,7 @@
 {
        "manifest_version": 1,
        "name": "DebateTree",
-       "version": "3.1",
+       "version": "4.0",
        "author": "[http://mediawiki.org/wiki/User:Sophivorus Sophivorus]",
        "url": "https://www.mediawiki.org/wiki/Extension:DebateTree";,
        "descriptionmsg": "debatetree-desc",
@@ -17,15 +17,15 @@
        },
        "ResourceModules": {
                "ext.DebateTree.css": {
-                       "styles": "DebateTree.css"
+                       "styles": "DebateTree.css",
+                       "position": "top"
                },
                "ext.DebateTree": {
                        "scripts": "DebateTree.js",
                        "messages": [
                                "debatetree-sustained",
                                "debatetree-refuted",
-                               "debatetree-counts",
-                               "debatetree-dummy"
+                               "debatetree-counts"
                        ]
                }
        },
@@ -37,4 +37,4 @@
                "BeforePageDisplay": "DebateTree::onBeforePageDisplay",
                "ParserFirstCallInit": "DebateTree::onParserFirstCallInit"
        }
-}
+}
\ No newline at end of file
diff --git a/i18n/en.json b/i18n/en.json
index 7151639..0437e12 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -7,6 +7,5 @@
        "debatetree-desc": "Debates structured by the dialectic algorithm",
        "debatetree-sustained": "SUSTAINED",
        "debatetree-refuted": "REFUTED",
-       "debatetree-dummy": "To add an objection, [$1 edit this page]. To 
understand how the debate system works, 
[https://en.wikiversity.org/wiki/Dialectic_algorithm click here].",
        "debatetree-counts": "($1 {{PLURAL:$1|objection|objections}}, $2 
sustained, $3 nested)"
 }
\ No newline at end of file
diff --git a/i18n/es.json b/i18n/es.json
index e3c30c3..131b6bb 100644
--- a/i18n/es.json
+++ b/i18n/es.json
@@ -7,6 +7,5 @@
        "debatetree-desc": "Debates estructurados por el algoritmo dialéctico",
        "debatetree-sustained": "SOSTENIDO",
        "debatetree-refuted": "REFUTADO",
-       "debatetree-dummy": "Para agregar una objeción, [$1 edita esta página]. 
Para entender como funciona el sistema de debate, haz 
[https://es.wikiversity.org/wiki/Algoritmo_dial%C3%A9ctico click aquí].",
        "debatetree-counts": "($1 {{PLURAL:$1|objeción|objeciones}}, $2 
{{PLURAL:$2|sostenida|sostenidas}}, $3 {{PLURAL:$3|anidada|anidadas}})"
 }
\ No newline at end of file
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 51ddd9c..a8a2b8a 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -4,9 +4,8 @@
                        "Sophivorus"
                ]
        },
-       "debatetree-desc": 
"{{desc|name=WikipediaExtracts|url=https://www.mediawiki.org/wiki/Extension:DebateTree}}";,
+       "debatetree-desc": 
"{{desc|name=DebateTree|url=https://www.mediawiki.org/wiki/Extension:DebateTree}}";,
        "debatetree-sustained": "Tag for the sustained arguments",
        "debatetree-refuted": "Tag for the refuted arguments",
-       "debatetree-dummy": "Dummy text for dummy objections",
        "debatetree-counts": "Objection counts"
 }
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/363739
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5afebd177c1a1c0ccaf21fe3bec94c80f9ae9bb5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DebateTree
Gerrit-Branch: master
Gerrit-Owner: Sophivorus <[email protected]>
Gerrit-Reviewer: Sophivorus <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to