Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. namespace('example');
  2. example.InstagramViewer = function (options) {
  3. // this works when called within buildFramework()
  4. this.settings = $.extend({
  5. currentView: 'grid'
  6. }, options);
  7.  
  8. // this doesn't work when called within buildFramework()
  9. var settings = $.extend({
  10. currentView: 'grid'
  11. }, options);
  12.  
  13. var viewer;
  14.  
  15. this.init = function () {
  16. buildFramework();
  17. };
  18.  
  19. var buildFramework = function() {
  20. viewer = $(viewerWrapper).append('<div id="instagramViewer" class="' + settings.currentView + '"></div>'); // this doesn't work
  21. viewer = $(viewerWrapper).append('<div id="instagramViewer" class="' + this.settings.currentView + '"></div>'); // this does work
  22. };
  23. }
  24.  
  25. $(function () {
  26. var viewer = new connectionsAcademy.publicWebsite.web.js.teenWebsite.InstagramViewer();
  27. viewer.init();
  28. });
  29.  
  30. InstagramViewer();
  31. console.log(window.settings);
  32.  
  33. var obj = {InstagramViewer: InstagramViewer};
  34. obj.InstagramViewer();
  35. console.log(obj.settings);
  36.  
  37. var F = function() {
  38. this.foo = 'foo';
  39. var bar = 'bar';
  40.  
  41. delete(bar);
  42. delete(this.foo);
  43.  
  44. alert(bar);
  45. alert(this.foo);
  46. };
  47.  
  48.  
  49. F();
  50.  
  51. function ObjectWithPrivateFunction() {
  52.  
  53. var _privateVariable = 0;
  54.  
  55. function _privateFunction(someValue) {
  56. _privateVariable = someValue;
  57. } // _privateFunction()
  58.  
  59. this.publicAccessToPrivateFunction = _privateFunction;
  60.  
  61. } // ObjectWithPrivateFunction()
  62.  
  63. var object = {
  64. x:10,
  65. func: function(){
  66. var x = 1;
  67. console.log(x, this.x);
  68. }
  69. }
  70.  
  71. function testPublic(str)
  72. {
  73. this.getTHIS=function()
  74. {
  75. alert(str)
  76. }
  77. }
  78.  
  79. function testPrivate(str)
  80. {
  81. var getTHIS=function()
  82. {
  83. alert(str);
  84. }
  85. }
  86.  
  87.  
  88. //now run the code
  89. new testPublic('hello there').getTHIS(); //alert hello there
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement