Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cjsbaseclass

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cjsbaseclass

Base Development Javascript Class

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

CjsBaseClass

DRY Javascript Class with inheritance, with embedded jQuery 2.2.3.

Install

bower install cjsbaseclass --save

Windows

goto root package folder

copy dist\*.sublime-snippet "%APPDATA%\Sublime Text 3\Packages\User\base_js_main_class.sublime-snippet"

Embedded libraries:

  • is.js
  • jQuery

Command reference


waitReady('ClassName', callback)
// Waits another class (CjsBaseClass based) on ready and call a callback
self.waitReady('TOther', self.otherClassReady.apply());
waitStarted('ClassName', callback)
// Waits another class (CjsBaseClass based) on start and call a callback
self.waitStarted('TOther', self.otherClassStarted.apply());
trigger(trigger_name, trigger_args)
// Fire a jQuery trigger
self.trigger('fire-trigger', { 'name': 'The Name', 'id': 123456 });
waitTrigger(trigger_name, callback, miliseconds)
// Waits a trigger fire with trigger_name param, if this already fired, callback is called immediately
self.waitTrigger
(
    'fire-trigger',
    function(p_args)
    {
        console.log(p_args);
    }
);
browser
// Returns browser name
self.log.info(self.browser); // Returns 'chrome' or 'firefox' or 'safari' or 'ie' or 'other'
pre defined variables
// Returns in case browser (ex: chrome)
self.is.chrome;  // returns true
self.is.firefox; // returns false
self.is.safari;  // returns false
self.is.ie;      // returns false
self.is.ie9;     // returns false
is
// Returns is browser defined
// options: self.is.chrome, self.is.firefox, self.is.safari, self.is.ie, self.is.ie9
var myvar = (self.is.ie9) ? 'IS IE9 :(' : 'IS NOT IE9 :D';
print(string)
// Log to console - only if a debug is true
self.log.print('my chinese variable :P');
alert(string)
// Log to console with alert icon
self.log.alert('Class TOther is ready!');
info(string)
// Log to console with info icon
self.log.info(self.browser);
danger(string)
// Log to console with error icon
self.log.danger(self.browser);
lock(string)
// Add dynamic locker variable
self.lock('scroll');
self.lock('scroll,slide');
isLocked(string)
// Return if dynamic variable is locked
self.isLocked('scroll'); // true
self.islocked('scroll,slide'); // true
self.isLocked('another'); // false
self.islocked('scroll,another'); // false
unlock(string)
// Remove dynamic locker variable
self.unlock('scroll');
self.unlock('scroll,slide');
setDebug(boolean)
// Enable/disble debug mode
self.setDebug(true); // Debug mode on: print logs on console
self.setDebug(false); // Debug mode off: self.log.print does not print console logs
setDebugMode(integer)
// Set debug mode
self.setDebugMode(0); // debug is false, none on console log is printed
self.setDebugMode(1); // debug is true, console log is printed
self.setDebugMode(2); // debug is true, console log is printed (developer's log include)

Usage


var MyApplication = MyApplication || {};
MyApplication.TMyClass = function($, objname, options)
{
    'use strict';
    var self = this;

    this.init = function()
    {
        self.initVars();
        self.processTriggers();
        self.onElementsEvents();
    };

    this.initVars = function()
    {
        
    };

    this.onReady = function()
    {
        // CODE ON APLICATION IS READY
        // TRIGGER ONREADY IS ALREADY FIRED
        self.start();
    };

    this.start = function()
    {
        // CODE ON APLICATION IS STARTED
        self.triggerStarted();
    };

    this.processTriggers = function()
    {

    };

    this.onElementsEvents = function()
    {

    };

    CjsBaseClass.call(this, $, objname, options);

    this.init();
};

MyApplication.MyClass = new MyApplication.TMyClass
(
    window.cjsbaseclass_jquery,
    'MyClass',
    {
        'debug': 1,
        'highlighted': false
    }
);

FAQs

Package last updated on 29 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc