/**
  * Add the link to render the javascript
  * 
  * @param string $page
  * @param boolean $backend
  */
 public function add_link_to_render_js($page, $backend)
 {
     $load_backend_script = 'false';
     if (true === $backend) {
         $load_backend_script = self::TRUE_PARAM;
     }
     $is_calendar_page = false;
     if (true === is_page($this->settings->calendar_page_id)) {
         $is_calendar_page = self::TRUE_PARAM;
     }
     $url = $this->template_adapter->get_site_url() . '?' . self::LOAD_JS_PARAMETER . '=' . $page . '&' . self::IS_BACKEND_PARAMETER . '=' . $load_backend_script . '&' . self::IS_CALENDAR_PAGE . '=' . $is_calendar_page;
     if (true === $backend) {
         $this->ai1ec_scripts->enqueue_admin_script(self::JS_HANDLE, $url, array('postbox'), true);
     } else {
         $this->ai1ec_scripts->enqueue_admin_script(self::JS_HANDLE, $url, array(), true);
     }
 }
 /**
  * Load javascript files for frontend pages.
  *
  * @param $is_calendar_page boolean Whether we are displaying the main
  *                                  calendar page or not
  */
 public function load_frontend_js($is_calendar_page)
 {
     global $ai1ec_settings;
     $data = $this->get_translation_data();
     // Load requirejs
     $this->ai1ec_scripts->enqueue_admin_script(self::JS_HANDLE, 'require.js');
     // This is to avoid loading the common scripts twice when loading the widget
     // on a wordpress site with our plugin active because the widget already
     // loads them.
     if (!isset($_GET[self::WEB_WIDGET_GET_PARAMETER])) {
         // Load common frontend scripts
         $this->ai1ec_scripts->enqueue_admin_script('ai1ec_common_frontend', 'pages/common_frontend.js', array('ai1ec_requirejs'), true);
         $this->load_frontend_js_translations('ai1ec_common_frontend');
     }
     // ======
     // = JS =
     // ======
     if ($this->are_we_accessing_the_single_event_page() === true) {
         $this->ai1ec_scripts->enqueue_admin_script('ai1ec_event_category', 'pages/event.js', array(self::JS_HANDLE), true);
         // This is needed by gmaps.
         $this->ai1ec_scripts->localize_script_for_requirejs('ai1ec_event_category', 'ai1ec_config', $data, true);
         $this->load_frontend_js_translations('ai1ec_event_category');
     }
     if ($is_calendar_page === true) {
         // Require the correct script to load
         $this->ai1ec_scripts->enqueue_admin_script('ai1ec_calendar_requirejs', 'pages/calendar.js', array(self::JS_HANDLE), true);
         // Need also to load back-end "translation" data (config settings) for
         // front-end. We should discuss how to streamline this; separation of
         // back-end and front-end data has become arbitrary.
         $this->ai1ec_scripts->localize_script_for_requirejs('ai1ec_calendar_requirejs', 'ai1ec_config', $data, true);
         // Now it's time to load custom functions from the themes
         try {
             $this->ai1ec_scripts->enqueue_admin_script('ai1ec_calendar_theme_require', "themes/vortex/pages/calendar.js", array(self::JS_HANDLE), true);
         } catch (Ai1ec_File_Not_Found $e) {
             // There is no custom file to load.
         }
         $this->load_frontend_js_translations('ai1ec_calendar_requirejs');
     }
 }