Ink's Javascript core

The framework for extensibility.

Ink includes a group of UI components out of the box.
Those components depend on Ink's Javascript core, which provides a set of methods and modules that help developers extending the features of this framework.

The Javascript core can be loaded in one of the following forms:

Loading Ink's Javascript core Bundle from CDN

<script type="text/javascript" src="../js/ink.min.js"></script>

Loading Ink's Javascript core Bundle from your localhost
<script type="text/javascript" src="/js/ink.min.js"></script>

This Bundle is a compressed and minified version of the following "methods and modules":

  • Ink - Ink's Javascript ecosystem. Provides the necessary methods to create and load the different Ink's Javascript modules:
    • Ink.bind - This method is a cross-browser Function.prototype.bind alternative. Allows the developer to define in which context a function is called.
    • Ink.bindEvent - Like Ink.bind this method is a cross-browser Function.prototype.bind alternative. The difference is that it maintains the window.event object as first argument in the function's call.
    • Ink.createModule - This method is used to create several of Ink's Javascript components. Want to create a custom component? Check here.
    • Ink.extendObj - This method enriches the destination object with values from source object whenever the key is missing in destination.
    • Ink.getModule - Synchronous way to use a module. This method assumes that the module is already loaded!
    • Ink.getModulesLoadOrder - This method returns a list of module names, ordered by loaded time.
    • Ink.i - This method is an alias to document.getElementById
    • Ink.loadScript - Method for loading a javascript script in the <head>
    • Ink.namespace - Method for creating namespaces inside the Ink's Javascript ecosystem.
    • Ink.requireModules - Method used to load modules asynchronously, being able to define a callback function to run whenever the specified modules are loaded. This is the recommended way to load modules, because when the callback runs you know for sure that the modules are loaded.
    • Ink.s - Alias for the querySelector method. Fallbacks to Ink.Dom.Selector if querySelector not available.
    • Ink.ss - Alias for the querySelectorAll method. Fallbacks to Ink.Dom.Selector if querySelectorAll not available.

  • Ink.Dom - Set of modules that helps the developer navigate and manipulate the DOM:
    • Ink.Dom.Browser - This module provides informations about the users' browsers.
    • Ink.Dom.Css - This module provides a method for getting, manipulating the CSS features of DOM Elements.
    • Ink.Dom.Element - This module provides methods to manipulate the DOM, get and set attributes of DOM elements, amongst others.
    • Ink.Dom.Event - This module provides methods for adding and removing event listeners, as well as stopping the propagation ( also known as bubbling) and preventing the default behavior of events.
    • Ink.Dom.Loaded - This module provides a method for running functions when the page is loaded ( document.ready ).
    • Ink.Dom.Selector - This module provides methods for selecting elements in the DOM.
    • Ink.Dom.Loaded - Use this module to add code to be executed when the browser loads your web pages. Handy when you are not sure whether the elements you need are available yet.
    • Ink.Dom.FormSerialize - Serialize or unserialize your form data to and from JavaScript object structures. Useful when you want to juice up an existing form using AJAX.

  • Ink.Net - Set of modules related with communication and external requests:
    • Ink.Net.Ajax - Cross-browser module that has functions to do AJAX requests.
    • Ink.Net.JsonP - This module provides functions to make JSONP requests.

  • Ink.Util - Set of utility modules to assist the developer (and the Javascript components) in some more common tasks:
    • Ink.Util.Array - This module provides cross-browser methods to manipulate arrays.
    • Ink.Util.Cookie - This module provides cross-browser methods for setting, reading and removing cookies with Javascript.
    • Ink.Util.Date - This module provide several utility functions to manipulate dates.
    • Ink.Util.Dumper - This module provides methods to assist the developer to dump/profile code.
    • Ink.Util.String - This module contains string handling and manipulation functions.
    • Ink.Util.Swipe - This module provides a set of cross-browser, cross-device functions to detect swiping. That includes direction, velocity, coordinates.
    • Ink.Util.Url - This module provides methods to handle and manipulate URLs.
    • Ink.Util.Validator - This module provides methods to help the developer in validation processes.


All of these components are in the Bundle, but in case you don't need all of them, you can load only some.

Loading Javascript components from CDN

This file is required and should always be loaded first:

<script type="text/javascript" src="../js/ink.min.js"></script>

And then the different components... Example:
<script type="text/javascript" src="../js/ink.modal.js"></script>

Save your code as a js file, include it as a <script> tag, and then just use it like a normal component:

<script type="text/javascript">
    Ink.requireModules(['Ink.YourNameSpace.YourClassModule_1'],function( yourClass ){
        window.yourObj = new yourClass( Ink.i('testArea'),{
            event: 'mouseover'
        } );
    });
</script>