/**
  * Add a new javascript file in page header.
  *
  * @param      $name
  * @param null $folder
  * @param bool $css
  */
 public function addJqueryPlugin($name, $folder = null, $css = true)
 {
     if (!is_array($name)) {
         $name = array($name);
     }
     if (is_array($name)) {
         foreach ($name as $plugin) {
             $plugin_path = Media::getJqueryPluginPath($plugin, $folder);
             if (!empty($plugin_path['js'])) {
                 $this->addJS($plugin_path['js']);
             }
             if ($css && !empty($plugin_path['css'])) {
                 $this->addCSS(key($plugin_path['css']), 'all');
             }
         }
     }
 }
 /**
  * Adds JS files to product page
  */
 public function hookDisplayFooterProduct()
 {
     if (Configuration::get('PS_DISPLAY_JQZOOM') == 1) {
         // Remove jQuery Zoom
         $jqZoomPluginPath = Media::getJqueryPluginPath('jqzoom');
         $this->context->controller->removeJS($jqZoomPluginPath['js']);
         $this->context->controller->removeCSS($jqZoomPluginPath['css']);
         // Add new version of jqZoom plugin
         $this->context->controller->addJS($this->_path . 'views/js/vendor/jquery.zoom.min.js');
     }
 }
Example #3
0
 /**
  * Add a new javascript file in page header.
  *
  * @param mixed $js_uri
  * @return void
  */
 public function addJqueryPlugin($name, $folder = null)
 {
     $plugin_path = array();
     if (is_array($name)) {
         foreach ($name as $plugin) {
             $plugin_path = Media::getJqueryPluginPath($plugin, $folder);
             $this->addJS($plugin_path['js']);
             $this->addCSS($plugin_path['css']);
         }
     } else {
         $plugin_path = Media::getJqueryPluginPath($name, $folder);
     }
     $this->addCSS($plugin_path['css']);
     $this->addJS($plugin_path['js']);
 }
 /**
  * _displayHeader() method add to header JS and CSS
  *
  * @return array
  */
 private function _displayHeader()
 {
     // set
     $aAssign = array();
     // set js msg translation
     BT_FPCModuleTools::translateJsMsg();
     $aAssign['oJsTranslatedMsg'] = BT_FPCModuleTools::jsonEncode($GLOBALS[_FPC_MODULE_NAME . '_JS_MSG']);
     // old version
     if (version_compare(_PS_VERSION_, '1.4.1', '<')) {
         $aAssign['bAddJsCss'] = true;
     } else {
         // use case - get context
         if (version_compare(_PS_VERSION_, '1.5', '>')) {
             // add in minify process by prestahsop
             Context::getContext()->controller->addCSS(_FPC_URL_CSS . 'hook.css');
             Context::getContext()->controller->addJS(_FPC_URL_JS . 'module.js');
             if (Tools::getValue('controller') == 'myaccount') {
                 // get fancybox plugin
                 $aJsCss = Media::getJqueryPluginPath('fancybox');
                 // add fancybox plugin
                 if (!empty($aJsCss['js']) && !empty($aJsCss['css'])) {
                     Context::getContext()->controller->addCSS($aJsCss['css']);
                     Context::getContext()->controller->addJS($aJsCss['js']);
                 }
             }
         } else {
             // add in minify process by prestahsop
             Tools::addCSS(_FPC_URL_CSS . 'hook.css');
             Tools::addJS(_FPC_URL_JS . 'module.js');
             // add fancybox plugin
             Tools::addCSS(_PS_CSS_DIR_ . 'jquery.fancybox-1.3.4.css');
             Tools::addJS(_PS_JS_DIR_ . 'jquery/jquery.fancybox-1.3.4.js');
         }
         $aAssign['bAddJsCss'] = false;
     }
     return array('tpl' => _FPC_TPL_HEADER, 'assign' => $aAssign);
 }