Return to Snippet

Revision: 60207
at October 27, 2012 19:31 by XtreamIT


Updated Code
/*jshint browser:true, jquery:true, undef:true, devel:true, unused:false, curly:true, strict:true,
noarg:true, noempty:true, eqeqeq:true, bitwise:true, quotmark:true, indent:2, maxerr:50 */
/*global window:true */

/**
 Global Class collection with a class(klass) object with private and public variables/methods without using this.
 @author John Doe
 @namespace classLib
*/
(function (window) {
  'use strict';
  
  var classLib = window.classLib || {};

  /**
   @class klass
   @namespace classLib
   */
  classLib.klass = function () { 
    /*  Private variables  */
    var _foo, _bar;

    _foo = 'foo';
    _bar = 'bar'; 
    /*-------------------------------------------------------*/
    /*  Private functions  */
    var _privateFunc = function () {
      _foo = _bar;
    }; 

    return {
      /*  Public functions  */
      init: function () {
        privateFunc();
      },
      getFoo: function () {
        return _foo;
      },
      setFoo: function (value) {
        _foo = value || _foo;
      }
    };
  }();

  // Expose klass to the global object
  window.classLib = classLib;

}(window));

Revision: 60206
at October 27, 2012 12:01 by XtreamIT


Updated Code
/*jshint browser:true, jquery:true, undef:true, devel:true, unused:false, curly:true, strict:true,
noarg:true, noempty:true, eqeqeq:true, bitwise:true, quotmark:true, indent:2, maxerr:50 */
/*global window:true */

/**
 Global Klass object with private and public variables/methods without using this.
 @author John Doe
 @namespace klass
*/
(function (window) {
  'use strict';
  
  var klass = window.klass || {};

  klass.config = {};

  /**
   @class main
   @namespace klass
   */
  klass.main = function () { 
    /*  Private variables  */
    var foo, bar;

    foo = 'foo';
    bar = 'bar'; 
    /*-------------------------------------------------------*/
    /*  Private functions  */
    var privateFunc = function () {
      foo = bar;
    }; 

    return {
      /*  Public functions  */
      init: function () {
        privateFunc();
      },
      getFoo: function () {
        return foo;
      },
      setFoo: function (value) {
        foo = value || foo;
      }
    };
  }();

  // Expose klass to the global object
  window.klass = klass;

}(window));

Revision: 60205
at October 25, 2012 19:28 by XtreamIT


Initial Code
/**
 Holds xxx scripts and functionality.
 @author John Doe
 @module klass
 @requires Jquery
*/

if (typeof klass === 'undefined') {
  var klass = klass || {};
}

klass.config = {};

/**
 @class main
 @namespace klass
 */
klass.main = function () {

  var publicFunc = function() {
    
  };

  return {
    init: function () {
  };

}();

Initial URL


Initial Description
jsHint happy class template for javascript

Initial Title
Javascript Class Template

Initial Tags
javascript, class, template

Initial Language
JavaScript