Fix to tc-scripts.min.js to allow for custom page templates
-
When plugins or individuals create their own page templates for whatever purpose, your tc-scripts.js/.min.js generates a javascript error when no navbar is found on the page. The issue is
this.$_nav_collapse
is being defined as an empty object when there’s no header, and then later you reference properties of that empty object without checking if it’s empty first.Please change this:
this.$_nav_collapse=b.$_tcHeader.length>0?b.$_tcHeader.find(".navbar-wrapper .nav-collapse"):{},this.$_nav=this.$_nav_collapse.length?this.$_nav_collapse.find(".nav"):{},this._has_dd_to_move()&&(this.$_navbar_wrapper=this.$_nav_collapse.closest(".navbar-wrapper"),this.$_nav=this.$_nav_collapse.find(".nav"),this.$_head=a("head"),this._dyn_style_id="tc-dropdown-dyn-style",this._prop=b.$_body.hasClass("rtl")?"right":"left",this.dropdownPlaceEventListener(),this._place_dropdowns())},dropdownPlaceEventListener:function(){var a=this,c="tc-resize sn-open sn-close tc-sticky-enabled tc-place-dropdowns";b.$_body.on(c,function(b){a.dropdownPlaceEventHandler(b,"resize")})},dropdownPlaceEventHandler:function(a,b){var c=this;switch(b){case"resize":setTimeout(function(){c._place_dropdowns()},250)}},_place_dropdowns:function(){var a=this._get_dd_to_move();a.length&&(this._staging(),this._move_dropdown(a),this._write_dyn_style(),this._unstaging())},_has_dd_to_move:function(){return this.$_nav_collapse.length<1?!1:this.$_nav.length&&this.$_nav.find(this._dd_first_selector)<1?!1:!0},_get_dd_to_move:function(){return"absolute"==this.$_nav_collapse.css("position")?{}:this.$_nav.is(":visible")?this.$_nav.find(this._dd_first_selector):{}},
to this:
this.$_nav_collapse=b.$_tcHeader.length>0?b.$_tcHeader.find(".navbar-wrapper .nav-collapse"):{},this.$_nav=this.$_nav_collapse.length?this.$_nav_collapse.find(".nav"):{},this._has_dd_to_move()&&(this.$_navbar_wrapper=this.$_nav_collapse.length>0?this.$_nav_collapse.closest(".navbar-wrapper"):jQuery('body'),this.$_nav=this.$_nav_collapse.length>0?this.$_nav_collapse.find(".nav"):jQuery('body'),this.$_head=a("head"),this._dyn_style_id="tc-dropdown-dyn-style",this._prop=b.$_body.hasClass("rtl")?"right":"left",this.dropdownPlaceEventListener(),this._place_dropdowns())},dropdownPlaceEventListener:function(){var a=this,c="tc-resize sn-open sn-close tc-sticky-enabled tc-place-dropdowns";b.$_body.on(c,function(b){a.dropdownPlaceEventHandler(b,"resize")})},dropdownPlaceEventHandler:function(a,b){var c=this;switch(b){case"resize":setTimeout(function(){c._place_dropdowns()},250)}},_place_dropdowns:function(){var a=this._get_dd_to_move();a.length&&(this._staging(),this._move_dropdown(a),this._write_dyn_style(),this._unstaging())},_has_dd_to_move:function(){return this.$_nav_collapse.length<1?!1:this.$_nav.length&&this.$_nav.find(this._dd_first_selector)<1?!1:!0},_get_dd_to_move:function(){if(this.$_nav_collapse.length===undefined)return{};return"absolute"==this.$_nav_collapse.css("position")?{}:this.$_nav.is(":visible")?this.$_nav.find(this._dd_first_selector):{}},
Thank you.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Fix to tc-scripts.min.js to allow for custom page templates’ is closed to new replies.