_Tobias

Untitled

Apr 3rd, 2015
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This retrieves the tab number from the cookies. The return value is either undefined or "0", "1", "2".
  2. var defaultLang = Cookies.get('language');
  3.  
  4. // So defaultLang is a string. In order to pass it to Spry, we need to convert it to a number. This can be done by multiplying it by 1.
  5.  
  6. (function() {
  7.     if(defaultLang)
  8.         return defaultLang * 1;
  9.     else
  10.         return 0;
  11. })()
  12.  
  13. // This function returns the numeric value of defaultLang if it is set. If not, it returns 0. This function can be replaced by the following "short-hand expression". The top line is meant to explain what is happening.
  14.  
  15. //        if(x)     x * 1   else 0
  16. defaultLang ? defaultLang * 1 : 0
  17.  
  18. var tp1 = Spry.Widget.TabbedPanels("streamtabs", { defaultTab: defaultLang ? defaultLang * 1 : 0 });
Advertisement
Add Comment
Please, Sign In to add comment