Skip to content
Snippets Groups Projects
Commit 1db9780c authored by Frank Duncan's avatar Frank Duncan
Browse files

Add widget stub

parent b4da7ad8
No related branches found
No related tags found
No related merge requests found
<?php
$magicWords = [];
$magicWords['en'] = [
'rankedchoice' => [ 0, 'rankedchoice'],
];
?>
......@@ -15,7 +15,9 @@
"i18n"
]
},
"ExtensionMessagesFiles": {
"RankedChoiceMagic": "RankedChoice.i18n.php"
},
"ResourceFileModulePaths": {
"localBasePath": ""
},
......@@ -26,6 +28,7 @@
},
"Hooks": {
"LoadExtensionSchemaUpdates": "MediaWiki\\Extension\\RankedChoice\\Hooks::onLoadExtensionSchemaUpdates",
"ParserFirstCallInit": "MediaWiki\\Extension\\RankedChoice\\Hooks::onParserFirstCallInit"
},
"APIModules": {
},
......@@ -33,24 +36,10 @@
},
"manifest_version": 1,
"ResourceModules": {
"ext.sitemanager.css": {
"styles": [ "resources/css/sitemanager.less" ]
},
"ext.sitemanager.manager": {
"styles": [ "resources/css/sitemanager-manager.less" ],
"scripts": [ "resources/js/sitemanager-manager.js" ],
"dependencies": [ "mediawiki.api" ],
"messages": []
},
"ext.sitemanager.sitenotice": {
"scripts": [ "resources/js/sitemanager-sitenotice.js" ],
"dependencies": [ "mediawiki.api" ],
"messages": []
},
"ext.sitemanager.embed": {
"scripts": [ "resources/js/sitemanager-embed.js" ],
"dependencies": [ "mediawiki.api" ],
"messages": []
"ext.rankedchoice": {
"styles": [ "resources/css/widget.less" ],
"scripts": [ "resources/js/widget.js" ],
"dependencies": [ "mediawiki.api" ]
}
},
"ResourceFileModulePaths": {
......
{
"@metadata": {
"authors": [
"Open Tech Strategies"
]
},
"rankedchoice": "Ranked Choice",
"rankedchoice-desc": "Specialized Extension to rank pages for purposes of voting and scoring"
}
......@@ -2,6 +2,11 @@
namespace MediaWiki\Extension\RankedChoice;
class Hooks {
public static function onParserFirstCallInit( \Parser $parser ) {
#$parser->setFunctionHook('rankedchoice', [ self::class, "render"]);
$parser->setFunctionHook('rankedchoice', "MediaWiki\Extension\RankedChoice\Render\RankedChoiceWidget::render");
}
public static function onLoadExtensionSchemaUpdates($updater) {
}
}
......
<?php
namespace MediaWiki\Extension\RankedChoice\Render;
class RankedChoiceWidget {
public static function render($parser) {
$parser->getOutput()->updateCacheExpiry(0);
$parser->getOutput()->addModules('ext.rankedchoice');
$parser->getOutput()->addModuleStyles('ext.rankedchoice');
$templateParser = new \TemplateParser(
__DIR__ .
DIRECTORY_SEPARATOR .
".." .
DIRECTORY_SEPARATOR .
".." .
DIRECTORY_SEPARATOR .
"templates"
);
return [$templateParser->processTemplate("widget", $params), "isHTML" => true];
}
}
?>
.--rankedchoice--widget {
span.clickme {
text-decoration: underline;
cursor: pointer;
}
span.currently-selected {
font-style: italic;
font-weight: bold;
}
}
(function ($, mw) {
$(function() {
$(".--rankedchoice--widget span.clickme").on("click", function() {
window.alert("You clicked me!");
})
$(".--rankedchoice--widget button").on("click", function() {
window.alert("You saved a comment!");
})
});
}(jQuery, mediaWiki));
<div class="--rankedchoice--widget">
<ul>
<li>Choice #1: <a href="SomeOtherPage">Some Other Page</a>
<li>Choice #2: <span class="clickme">Assign this page</span>
<li>Choice #3: <span class="currently-selected">Currently Selected</span> <span class="clickme">Unselect</span>
<li>Choice #4: <a href="YetAnotherPage">Yet Another Page</a>
<li>Choice #5: <a href="AWholeOtherPage">A Whole Other Page</a>
</ul>
<div>
Extra Comments:
<textarea></textarea>
<button>Save</button>
</div>
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment