This object is in archive! 

How to override main.js for each of the sections

Archived Kevin M. 10 years ago

I am needing to override the main.js files to add functionality when someone click the section icon in the modal. I thought could modify view themes/module , but it does not work. How would I go about this?

Replies (5)

photo
1

Denis,


On the first point here is what I am needing to do. I am adding

  1. var color = window.getComputedStyle($(this).find('i')[0], ':before').getPropertyCSSValue('color').cssText;
  2. $('.slogan-comunity').css({'border-bottom-color':color});

to the main.js file for (ideas, problems, thanks, questions) as part of a customization to the behavior when each module tab is click in the modal. So adding js to the assets/js is less than optimal.

For modify modules do have to put in full paths to get to the js / css files. I not in the modules there are

  1. <?php echo $this->headTitle() . PHP_EOL ?>
  2. <?php echo $this->headMeta() . PHP_EOL ?>
  3. <?php echo $this->headLink() . PHP_EOL ?>
  4. <?php echo $this->headScript() . PHP_EOL ?>

Which point to the main files and not my module override paths. Ideally I though that if I created /module/js , that it would override and use mine. So guess not sure how to best to reference my custom css and js within a new template.

photo
1

Hello Kevin,

In order for you to use new css and js in theme, you don't need to stick to any module, but use global script.js located in /assets/js

So that js file will load and be used system wide. The same is with css file in theme.

As I can see, you are going in the wrong direction, as this method is incorrect /module/js

Please review Themes and Customize Interface articles to get more information on theme development.

photo
1

Stas,


Thanks. Yeah I kinda figured that on the modules. Though it made logical sense from an override perspective.


It was the issue of doing a override of existing js that makes the global js files more difficult because I have to add additional jQuery listeners for elements which just adds unecessary bloat. But no worries I'll make it work.

photo
1

Hi Kevin,

Glad that you figured it out. Hope customization won't bring you much trouble.

Have a great day

photo
1

that is what version control is for :)


thanks

Replies have been locked on this page!