DailyJS

jQuery 1.11.1, 2.1.1, PositionCalculator, YModules

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

jquery plugins module-loaders

jQuery 1.11.1, 2.1.1, PositionCalculator, YModules

Posted by Alex R. Young on .
Featured

jquery plugins module-loaders

jQuery 1.11.1, 2.1.1, PositionCalculator, YModules

Posted by Alex R. Young on .

jQuery 1.11.1 Beta 1 and 2.1.1 Beta 1 Released

New jQuery betas are out. These are maintenance releases with bug fixes, including a tweak that helps create builds with custom names, so you can use a different name in AMD loaders like RequireJS.

PositionCalculator

PositionCalculator (GitHub: tlindig / position-calculator, License: MIT) by Tobias Lindig is a jQuery UI Position replacement:

This plugin will not manipulate any CSS settings or DOM-trees, it only calculate values. To be more exact, it calculates the difference of current position to target position and the overflow over boundary. Thus you are all paths open to implement the positioning according to your requirements. You can apply the new position by using top and left or using the css3 transform function or by setting margin. It is up to you.

YModules

Vladimir Varankin sent in YModules (GitHub: ymaps / modules) by Dmitry Filatov is an asynchronous modular loading system that works with Node and browsers.

The syntax looks like this:

modules.define(  
  'jquery',
  ['loader'],
  function(provide, loader) {

  loader('//yandex.st/jquery/2.1.0/jquery.min.js', function() {
    provide(jQuery.noConflict(true));
  });
});

modules.define(  
  'my-module',
  ['jquery'],
  function(provide, $) {
    function MyModule() { /* do something here */ }
    provide(MyModule);
  });

modules.require('my-module', function(MyModule) {  
  // `MyModule` will be available here after
  // Its dependencies will be resolved and its `provide` will fire.
});

It has a feature that allows existing modules to be redeclared, which can help with component-based libraries:

modules.define('button', function(provide) {  
    function Button() { /* our button's constructor */ });
    Button.prototype.doAction = function() {};

    provide(Button);
});

// on the end user's space we could redefine the same Button
modules.define('button', ['jquery'], function(provide, $, Button) {  
  // We're declaring the same module "button",
  // so we have an access to the module's previous definition
  // through the last define's argument (`Button` here), which
  // is appended automatically and known as "previousModuleDeclaration"
  Button.prototype.doAnOtherAction = function() {};
  provide(Button);
});

modules.require('button', function(Button) {  
  Button.doAction();
  Button.doAnOtherAction();
});