MDL-57490 scorm: convert legacy js to jquery
authorDan Poltawski <dan@moodle.com>
Wed, 21 Dec 2016 16:07:31 +0000 (16:07 +0000)
committerDan Poltawski <dan@moodle.com>
Mon, 16 Jan 2017 13:22:50 +0000 (13:22 +0000)
mod/scorm/report/basic/classes/report.php
mod/scorm/report/interactions/classes/report.php
mod/scorm/report/objectives/classes/report.php

index 6c3da63..5b8a490 100644 (file)
@@ -492,10 +492,20 @@ class report extends \mod_scorm\report {
                     if ($candelete) {
                         echo \html_writer::start_tag('table', array('id' => 'commands'));
                         echo \html_writer::start_tag('tr').\html_writer::start_tag('td');
-                        echo \html_writer::link('javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');',
-                                                    get_string('selectall', 'scorm')).' / ';
-                        echo \html_writer::link('javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');',
-                                                    get_string('selectnone', 'scorm'));
+                        echo \html_writer::link('#', get_string('selectall', 'scorm'), array('id' => 'checkattempts'));
+                        echo ' / ';
+                        echo \html_writer::link('#', get_string('selectnone', 'scorm'), array('id' => 'uncheckattempts'));
+                        $PAGE->requires->js_amd_inline("
+                        require(['jquery'], function($) {
+                            $('#checkattempts').click(function(e) {
+                                $('#attemptsform').find('input:checkbox').prop('checked', true);
+                                e.preventDefault();
+                            });
+                            $('#uncheckattempts').click(function(e) {
+                                $('#attemptsform').find('input:checkbox').prop('checked', false);
+                                e.preventDefault();
+                            });
+                        });");
                         echo '&nbsp;&nbsp;';
                         echo \html_writer::empty_tag('input', array('type' => 'submit',
                                                                     'value' => get_string('deleteselected', 'scorm'),
index 0def88c..41b24f8 100644 (file)
@@ -582,10 +582,20 @@ class report extends \mod_scorm\report {
                     if ($candelete) {
                         echo \html_writer::start_tag('table', array('id' => 'commands'));
                         echo \html_writer::start_tag('tr').\html_writer::start_tag('td');
-                        echo \html_writer::link('javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');',
-                                                    get_string('selectall', 'scorm')).' / ';
-                        echo \html_writer::link('javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');',
-                                                    get_string('selectnone', 'scorm'));
+                        echo \html_writer::link('#', get_string('selectall', 'scorm'), array('id' => 'checkattempts'));
+                        echo ' / ';
+                        echo \html_writer::link('#', get_string('selectnone', 'scorm'), array('id' => 'uncheckattempts'));
+                        $PAGE->requires->js_amd_inline("
+                        require(['jquery'], function($) {
+                            $('#checkattempts').click(function(e) {
+                                $('#attemptsform').find('input:checkbox').prop('checked', true);
+                                e.preventDefault();
+                            });
+                            $('#uncheckattempts').click(function(e) {
+                                $('#attemptsform').find('input:checkbox').prop('checked', false);
+                                e.preventDefault();
+                            });
+                        });");
                         echo '&nbsp;&nbsp;';
                         echo \html_writer::empty_tag('input', array('type' => 'submit',
                                                                     'value' => get_string('deleteselected', 'scorm'),
index 9d60756..68a7764 100644 (file)
@@ -582,10 +582,20 @@ class report extends \mod_scorm\report {
                     if ($candelete) {
                         echo \html_writer::start_tag('table', array('id' => 'commands'));
                         echo \html_writer::start_tag('tr').\html_writer::start_tag('td');
-                        echo \html_writer::link('javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');',
-                                                    get_string('selectall', 'scorm')).' / ';
-                        echo \html_writer::link('javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');',
-                                                    get_string('selectnone', 'scorm'));
+                        echo \html_writer::link('#', get_string('selectall', 'scorm'), array('id' => 'checkattempts'));
+                        echo ' / ';
+                        echo \html_writer::link('#', get_string('selectnone', 'scorm'), array('id' => 'uncheckattempts'));
+                        $PAGE->requires->js_amd_inline("
+                        require(['jquery'], function($) {
+                            $('#checkattempts').click(function(e) {
+                                $('#attemptsform').find('input:checkbox').prop('checked', true);
+                                e.preventDefault();
+                            });
+                            $('#uncheckattempts').click(function(e) {
+                                $('#attemptsform').find('input:checkbox').prop('checked', false);
+                                e.preventDefault();
+                            });
+                        });");
                         echo '&nbsp;&nbsp;';
                         echo \html_writer::empty_tag('input', array('type' => 'submit',
                                                                     'value' => get_string('deleteselected', 'scorm'),