Commit f4cc34f0 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Remove plans block javascript from template (bug #1002168)

By putting more javascript into the static plansblock.js file, it's
possible to remove the script element from the template.  This is
better for exports, which should not include javascript designed for
the site.  Putting the entire block initialisation into a separate
function also allows the pagination links to be made available when a
new plans block is first dragged into a page.

Change-Id: I7a5e6448c14272660b317b55b4db7cd2829576f7
Signed-off-by: default avatarRichard Mansfield <>
parent 662aec08
......@@ -16,3 +16,13 @@ function TaskPager(blockid) {
connect(self, 'pagechanged', partial(rewriteTaskTitles, blockid));
var taskPagers = [];
function initNewPlansBlock(blockid) {
if ($('plans_page_container_' + blockid)) {
new Paginator('block' + blockid + '_pagination', 'tasktable_' + blockid, 'artefact/plans/viewtasks.json.php', null);
taskPagers.push(new TaskPager(blockid));
......@@ -59,7 +59,7 @@ class PluginBlocktypePlans extends PluginBlocktype {
return array(
'file' => 'js/plansblock.js',
'initjs' => "rewriteTaskTitles($blockid);",
'initjs' => "initNewPlansBlock($blockid);",
......@@ -14,20 +14,8 @@
{if $tasks.pagination}
<div id="plans_page_container_{$blockid}" class="hidden">{$tasks.pagination|safe}</div>
<div id="plans_page_container_{$blockid}" class="nojs-hidden-block">{$tasks.pagination|safe}</div>
{if $tasks.pagination_js}
addLoadEvent(function() {{/literal}
removeElementClass('plans_page_container_{$blockid}', 'hidden');
var taskPager_{$blockid} = new TaskPager({$blockid});
addLoadEvent(partial(rewriteTaskTitles, {$blockid}));
{/if} {* pagination_js *}
<p>{str tag='notasks' section='artefact.plans'}</p>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment