init.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. if(window.widget)
  2. {
  3. widget.setNavigationEnabled(false);
  4. menu.hideSoftkeys();
  5. }
  6. function init()
  7. {
  8. // Initializing the main GBC object, that will initialize and manage the widget
  9. window.GBC = new Nokia.GBC();
  10. // Removing the splash screen IMG node
  11. var splash = document.getElementById('splash_image');
  12. splash.parentNode.removeChild(splash);
  13. // Rendering the first GBC view
  14. GBC.render();
  15. };
  16. /*
  17. * Handles the dynamic load of the widget's CSS and JS resources
  18. */
  19. function loadWidgetResources()
  20. {
  21. // Dynamically loading JavaScript libraries
  22. initJsFile('lib/guarana/lib/jquery/jquery.js');
  23. initJsFile('lib/guarana/lib/Guarana.js');
  24. initJsFile('impl/core-defaults.js');
  25. var width = window.innerWidth;
  26. var height = window.innerHeight;
  27. var deviceResolution = width + 'x' + height;
  28. var themeName = 'default';
  29. // Dynamically loading CSS stylesheets
  30. initCssFile('lib/guarana/themes/themeroller/' + themeName + '-theme/Themeroller.css');
  31. initCssFile('lib/guarana/themes/nokia/ext-theme/' + themeName + '/' + deviceResolution + '/custom.css');
  32. initCssFile('css/reset.css');
  33. initCssFile('css/basic.css');
  34. initCssFile('css/guarana-custom.css');
  35. window.addEventListener('load', widgetResourcesLoaded, false);
  36. };
  37. /*
  38. * Dynamically load a single JavaScript source file
  39. */
  40. function initJsFile(src) {
  41. document.write("<script type=\"text/javascript\" src=\"" + src + "\"></script>");
  42. };
  43. /*
  44. * Dynamically load a single CSS stylesheet
  45. */
  46. function initCssFile(src) {
  47. var style = document.createElement('link');
  48. style.setAttribute('rel', "stylesheet");
  49. style.setAttribute('type', "text/css")
  50. style.setAttribute('href', src);
  51. document.getElementsByTagName('head')[0].appendChild(style);
  52. };
  53. /*
  54. * Method called when the widget's CSS and JS resources are loaded
  55. */
  56. function widgetResourcesLoaded()
  57. {
  58. // Loading the Guarana and widget-specific resources needed by GBC
  59. // (dependencies are defined in the 'impl/core-defaults.js' file)
  60. Nokia.use('gbc', init);
  61. }
  62. loadWidgetResources();