Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace('example');
- example.InstagramViewer = function (options) {
- // this works when called within buildFramework()
- this.settings = $.extend({
- currentView: 'grid'
- }, options);
- // this doesn't work when called within buildFramework()
- var settings = $.extend({
- currentView: 'grid'
- }, options);
- var viewer;
- this.init = function () {
- buildFramework();
- };
- var buildFramework = function() {
- viewer = $(viewerWrapper).append('<div id="instagramViewer" class="' + settings.currentView + '"></div>'); // this doesn't work
- viewer = $(viewerWrapper).append('<div id="instagramViewer" class="' + this.settings.currentView + '"></div>'); // this does work
- };
- }
- $(function () {
- var viewer = new connectionsAcademy.publicWebsite.web.js.teenWebsite.InstagramViewer();
- viewer.init();
- });
- InstagramViewer();
- console.log(window.settings);
- var obj = {InstagramViewer: InstagramViewer};
- obj.InstagramViewer();
- console.log(obj.settings);
- var F = function() {
- this.foo = 'foo';
- var bar = 'bar';
- delete(bar);
- delete(this.foo);
- alert(bar);
- alert(this.foo);
- };
- F();
- function ObjectWithPrivateFunction() {
- var _privateVariable = 0;
- function _privateFunction(someValue) {
- _privateVariable = someValue;
- } // _privateFunction()
- this.publicAccessToPrivateFunction = _privateFunction;
- } // ObjectWithPrivateFunction()
- var object = {
- x:10,
- func: function(){
- var x = 1;
- console.log(x, this.x);
- }
- }
- function testPublic(str)
- {
- this.getTHIS=function()
- {
- alert(str)
- }
- }
- function testPrivate(str)
- {
- var getTHIS=function()
- {
- alert(str);
- }
- }
- //now run the code
- new testPublic('hello there').getTHIS(); //alert hello there
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement