|
1 | 1 | // Init kinda namespace object |
2 | 2 | var VE = { // Vesta Events object |
3 | 3 | core: {}, // core functions |
| 4 | + navigation: { |
| 5 | + state: { |
| 6 | + active_menu: 1, |
| 7 | + menu_selector: '.l-stat__col', |
| 8 | + menu_active_selector: '.l-stat__col--active' |
| 9 | + } |
| 10 | + }, // menu and element navigation functions |
4 | 11 | callbacks: { // events callback functions |
5 | 12 | click: {}, |
6 | 13 | mouseover: {}, |
@@ -225,6 +232,75 @@ VE.helpers.refresh_timer = { |
225 | 232 | } |
226 | 233 | } |
227 | 234 |
|
| 235 | +VE.navigation.enter_focused = function() { |
| 236 | + if($(VE.navigation.state.menu_selector + '.focus a').attr('href')){ |
| 237 | + location.href=($(VE.navigation.state.menu_selector + '.focus a').attr('href')); |
| 238 | + } |
| 239 | +} |
| 240 | + |
| 241 | +VE.navigation.move_focus_left = function(){ |
| 242 | + var index = parseInt($(VE.navigation.state.menu_selector).index($(VE.navigation.state.menu_selector+'.focus'))); |
| 243 | + if(index == -1) |
| 244 | + index = parseInt($(VE.navigation.state.menu_selector).index($(VE.navigation.state.menu_active_selector))); |
| 245 | + if(index > 0){ |
| 246 | + $(VE.navigation.state.menu_selector).removeClass('focus'); |
| 247 | + $($(VE.navigation.state.menu_selector)[index-1]).addClass('focus'); |
| 248 | + } else { |
| 249 | + $($(VE.navigation.state.menu_selector)[0]).addClass('focus'); |
| 250 | + } |
| 251 | +} |
228 | 252 |
|
| 253 | +VE.navigation.move_focus_right = function(){ |
| 254 | + var max_index = $(VE.navigation.state.menu_selector).length-1; |
| 255 | + var index = parseInt($(VE.navigation.state.menu_selector).index($(VE.navigation.state.menu_selector+'.focus'))); |
| 256 | + if(index == -1) |
| 257 | + index = parseInt($(VE.navigation.state.menu_selector).index($(VE.navigation.state.menu_active_selector))) || 0; |
| 258 | + |
| 259 | + if(index < max_index){ |
| 260 | + $(VE.navigation.state.menu_selector).removeClass('focus'); |
| 261 | + $($(VE.navigation.state.menu_selector)[index+1]).addClass('focus'); |
| 262 | + } |
| 263 | +} |
| 264 | + |
| 265 | +VE.navigation.switch_menu = function(){ |
| 266 | + if(VE.navigation.state.active_menu == 0){ |
| 267 | + VE.navigation.state.active_menu = 1; |
| 268 | + VE.navigation.state.menu_selector = '.l-stat__col'; |
| 269 | + VE.navigation.state.menu_active_selector = '.l-stat__col--active'; |
| 270 | + $('.l-menu').removeClass('active'); |
| 271 | + $('.l-stat').addClass('active'); |
| 272 | + } else { |
| 273 | + VE.navigation.state.active_menu = 0; |
| 274 | + VE.navigation.state.menu_selector = '.l-menu__item'; |
| 275 | + VE.navigation.state.menu_active_selector = '.l-menu__item--active'; |
| 276 | + $('.l-menu').addClass('active'); |
| 277 | + $('.l-stat').removeClass('active'); |
| 278 | + } |
| 279 | + |
| 280 | + |
| 281 | + var index = parseInt($(VE.navigation.state.menu_selector).index($(VE.navigation.state.menu_selector+'.focus'))); |
| 282 | + if(index == -1){ |
| 283 | + index = parseInt($(VE.navigation.state.menu_selector).index($(VE.navigation.state.menu_active_selector))) || 0; |
| 284 | + if(index == -1) |
| 285 | + index = 0; |
| 286 | + $($(VE.navigation.state.menu_selector)[index]).addClass('focus'); |
| 287 | + } |
| 288 | +} |
| 289 | + |
| 290 | +VE.navigation.init = function(){ |
| 291 | + if($('.l-menu__item.l-menu__item--active').length){ |
| 292 | +// VE.navigation.switch_menu(); |
| 293 | + VE.navigation.state.active_menu = 0; |
| 294 | + VE.navigation.state.menu_selector = '.l-menu__item'; |
| 295 | + VE.navigation.state.menu_active_selector = '.l-menu__item--active'; |
| 296 | + $('.l-menu').addClass('active'); |
| 297 | + $('.l-stat').removeClass('active'); |
| 298 | + |
| 299 | + } else { |
| 300 | + $('.l-stat').addClass('active'); |
| 301 | + } |
| 302 | +} |
229 | 303 |
|
230 | 304 | VE.helpers.extendPasswordFields(); |
| 305 | + |
| 306 | + |
0 commit comments