FelixLuciano / Classy.js

An easy and clear way to define element function(s)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Source it!

https://rawgit.com/TecIce/Classy.js/master/source/Classy.min.js


Classy constructor: Classy(Name, Callback(Arguments, $Classy));

  • Alias

    • Classy().register(Name, Callback(Arguments, $Classy));
  • Name
    Type: "String"
    rule: Can not contain hyphens
    Sets the Classye to call to execute the callback.

  • Callback
    Type: Function(Arguments)
    Sets the Classye to call to execute the callback.

    • Arguments
      type: [Array]
      Returns the arguments defined next to Classy in HTML.

    • $Classy
      type: {Object}
      Returns classy having the class name and current as predefined arguments.

    • this
      type:
      Return the element where the callback is performing the actions. // If jQuery is imported, the return will be given by the element through jQuery

  Classy('Classye', function(arguments, $Classy) {
    this.innerHTML = arguments[0];
    //If jQuery is installed
    this.on('click', function() {
      alert('Hello world!');
    });
    console.log($Classy.scope());
  });

Element definition: <any class="[Classy name]_[argument1]_[argument2]_[arg...]">...</any>

  • Classy name
    Type: "String"
    rule: Can not contain hyphens
    Defines the classye that the element will execute upon loading.

  • Arguments
    Type: "String"
    rule: Can not contain hyphens
    Sets the Classye to be established for the HTML element.

  • Character: _
    Type: Argument separador Separates the Classye name and its arguments.

  <div class='Classy_argument_1_2_3'></div>

Element reloading: Classy(Name, Element).apply()

  • Alias

    • Classy().apply(Name, Element));
  • Return
    Type: Function() Rerun the callback for an element of a specific classye.


Classye reloading: Classy(name).applyAll()

  • Alias

    • Classy().applyAll(Name));
  • Return
    Type: Function() Rerun the callback for all elements of the classye with the given name.


Scope: Classy().scope()

  • Return
    Type: {Object}
    Returns all defined Classyes, with their respective elements, which in turn, their arguments.

      {
        MyClassy: {
          action: ƒ (arguments, $Classy),
          elements: [
            0: div#element.MyClassy_arg1_2_3
              Classy: {
                MyClassy: [
                  0: 'arg1',
                  1: 2,
                  2: 3
              ]
            }
          ]
        }
      }
  • Return
    Type: {Object}
    Returns all defined Classyes, with their respective elements, which in turn, their arguments.


See this working

About

An easy and clear way to define element function(s)


Languages

Language:JavaScript 61.2%Language:CoffeeScript 38.8%