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 <richard.mansfield@catalyst.net.nz>
parent 662aec08
......@@ -16,3 +16,13 @@ function TaskPager(blockid) {
paginatorProxy.addObserver(self);
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));
}
rewriteTaskTitles(blockid);
}
......@@ -59,7 +59,7 @@ class PluginBlocktypePlans extends PluginBlocktype {
return array(
array(
'file' => 'js/plansblock.js',
'initjs' => "rewriteTaskTitles($blockid);",
'initjs' => "initNewPlansBlock($blockid);",
)
);
}
......
......@@ -14,20 +14,8 @@
</tbody>
</table>
{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}
{if $tasks.pagination_js}
<script>
{literal}
addLoadEvent(function() {{/literal}
{$tasks.pagination_js|safe}
removeElementClass('plans_page_container_{$blockid}', 'hidden');
{literal}}{/literal});
var taskPager_{$blockid} = new TaskPager({$blockid});
addLoadEvent(partial(rewriteTaskTitles, {$blockid}));
</script>
{/if} {* pagination_js *}
{else}
<p>{str tag='notasks' section='artefact.plans'}</p>
{/if}
......
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