Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-33113

Add system to $PAGE to add additional classes dependant on javascript

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 2.3
    • JavaScript
    • MOODLE_23_STABLE
    • MDL-33113-master-1
    • Hide

      With javascript enabled in your browser

      • Open a page within moodle
      • Inspect the page
      • Check the classes on the <body> tag
        • Confirm that the 'jsenabled' tag is still present

      With javascript disabled in your browser

      • Open a page within moodle
      • Inspect the page
      • Check the classes on the <body> tag
        • Confirm that the 'jsenabled' tag is (still) not present
      Show
      With javascript enabled in your browser Open a page within moodle Inspect the page Check the classes on the <body> tag Confirm that the 'jsenabled' tag is still present With javascript disabled in your browser Open a page within moodle Inspect the page Check the classes on the <body> tag Confirm that the 'jsenabled' tag is (still) not present

      Just a quick thought and I need to write it down before I forget.
      For the new course and block js changes, it's been suggested that we should hide elements which will be removed by the js, and show elements which would be added by JS.

      At present, a jsenabled class is added to the body tag by a JS script early in the header, however this doesn't determine whether a particular feature is enabled - for example courseajax. Often, these settings rely on many different settings - see /course/lib.php::course_ajax_enabled().

      I propose:

      • adding a new function to the moodle_page class:

        function add_js_class($class) {
            // TODO Check that the page hasn't been rendered yet
            $this->pageclasses[$class] = true;
        }

      • adding a call to display these - this is currently done for the jsenabled class in get_top_of_body_code(). This could be converted to add all required classes very easily.

      Just a thought and I'll try and expand when I get to work. Will help solve MDL-32837

            Unassigned Unassigned
            dobedobedoh Andrew Lyons
            Sam Hemelryk Sam Hemelryk
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.