0.0.0 • Published 10 years ago

minow v0.0.0

Weekly downloads
2
License
-
Repository
github
Last release
10 years ago

minowjs

This is a micro version of a jquery type library based on enderjs core modules. It's a direct drop in replacement for jquery.

I want to give major credit to "Dustin Diaz" for all his work on these libraries, and the jeesh script I snagged most of the code from and everyone else who worked on these projects all I "Josh Spivey" did was connect the dots to make a drop in jquery replacement that works for me. This is extremely lightweight and fast micro library approach where you can add what you want and you are not stuck with the limitations for one specific lib. You can pick and choose whatever libs you want to make your own custom library that suits your projects needs. Lighter is better!

##One important note is that I had modified all the libs over a year and half of using this script for various bug fixes it has been stable for about a year now using the libraries I have in this repo...

##Compatible with ie7+ and all modern browsers.

$ bower install minowjs

or

$ git clone git@github.com:Lbox/minowjs.git
$ bower install

##Minow specfic methods

$.parseJSON();
$.fEach();
$.each();
$("#selector").outerWidth();
$("#selector").fadeOut();
$("#selector").fadeIn();
$("#selector").animate();
$("#selector").width();
$("#selector").height();
$("#selector").closest();
$("#selector").children();
$("#selector").siblings();
$("#selector").parents();
$("#selector").inArray();
$("#selector").is();
define([
// Libraries.
"minow"
],

function($) {

	var tmpObject = function(){
		$("#someSelector").html("Josh was here!");

		$("#someSelector").bind("click", function(evt){
			alert("clicked!");
		});

		$.ajax({
		    url: 'path/to/data.jsonp?foo=bar'
		  , dataType: 'jsonp'
		  , jsonp: 'foo'
		  , jsonpCallback: 'bar'
		  , success: function (resp) {
		      console.log(resp.content);
		    }
		});

		$("#avitar").tween(1, {css:{scaleX:0.5, rotation:30}, ease:Power3.easeOut});

	};


return tmpObject;
});

##Bean Events https://github.com/fat/bean/blob/master/README.md

Ender Integration API

If you use Bean with Ender its API is greatly extended through its bridge file. This extension aims to give Bean the look and feel of jQuery.

Add events

  • on - $(element).on('click', fn);
  • addListener - $(element).addListener('click', fn);
  • bind - $(element).bind('click', fn);
  • listen - $(element).listen('click', fn);

Remove events

  • off - $(element).off('click');
  • unbind - $(element).unbind('click');
  • unlisten - $(element).unlisten('click');
  • removeListener - $(element).removeListener('click');

Delegate events

  • on - $(element).on('click', '.foo', fn);
  • delegate - $(element).delegate('.foo', 'click', fn);
  • undelegate - $(element).undelegate('.foo', 'click');

Clone events

  • cloneEvents - $(element).cloneEvents('.foo', fn);

Custom events

  • fire / emit / trigger - $(element).trigger('click')

Special events

  • hover - $(element).hover(enterfn, leavefn);
  • blur - $(element).blur(fn);
  • change - $(element).change(fn);
  • click - $(element).click(fn);
  • dblclick - $(element).dblclick(fn);
  • focusin - $(element).focusin(fn);
  • focusout - $(element).focusout(fn);
  • keydown - $(element).keydown(fn);
  • keypress - $(element).keypress(fn);
  • keyup - $(element).keyup(fn);
  • mousedown - $(element).mousedown(fn);
  • mouseenter - $(element).mouseenter(fn);
  • mouseleave - $(element).mouseleave(fn);
  • mouseout - $(element).mouseout(fn);
  • mouseover - $(element).mouseover(fn);
  • mouseup - $(element).mouseup(fn);
  • mousemove - $(element).mousemove(fn);
  • resize - $(element).resize(fn);
  • scroll - $(element).scroll(fn);
  • select - $(element).select(fn);
  • submit - $(element).submit(fn);
  • unload - $(element).unload(fn);

Contributors

##Bonzo Dom manipulation https://github.com/ded/bonzo/blob/master/README.md

Complete Bonzo API

  • bonzo()

Instance methods

  • bonzo().get()
  • bonzo().each()
  • bonzo().deepEach()
  • bonzo().map()
  • bonzo().html()
  • bonzo().text()
  • bonzo().addClass()
  • bonzo().removeClass()
  • bonzo().hasClass()
  • bonzo().toggleClass()
  • bonzo().show()
  • bonzo().hide()
  • bonzo().toggle()
  • bonzo().first()
  • bonzo().last()
  • bonzo().next()
  • bonzo().previous()
  • bonzo().parent()
  • bonzo().focus()
  • bonzo().blur()
  • bonzo().append()
  • bonzo().appendTo()
  • bonzo().prepend()
  • bonzo().prependTo()
  • bonzo().before()
  • bonzo().insertBefore()
  • bonzo().after()
  • bonzo().insertAfter()
  • bonzo().replaceWith()
  • bonzo().css()
  • bonzo().offset()
  • bonzo().dim()
  • bonzo().attr()
  • bonzo().removeAttr()
  • bonzo().val()
  • bonzo().data()
  • bonzo().remove()
  • bonzo().empty()
  • bonzo().detach()
  • bonzo().scrollLeft()
  • bonzo().scrollTop()

Static methods

  • bonzo.aug()
  • bonzo.doc()
  • bonzo.viewport()
  • bonzo.firstChild()
  • bonzo.isAncestor()
  • bonzo.create()
  • bonzo.setQueryEngine()

Added in the Ender bridge:

  • $().parents()
  • $().closest()
  • $().siblings()
  • $().children()
  • $().width()
  • $().height()

##Qwery query engine https://github.com/ded/qwery/blob/master/README.md

Acceptable selectors

/* basic */
#foo {} /* id */
.bar {} /* class */
a#foo.bar {} /* element attribute combinations */

/* attributes */
#foo a[href] {} /* simple */
#foo a[href=bar] {} /* attribute values */
#foo a[lang|=en] {} /* subcodes */
#foo a[title~=hello] {} /* attribute contains */
#foo a[href^="http://"] {} /* attribute starts with */
#foo a[href$=com] {} /* attribute ends with */
#foo a[href*=twitter] /* {} attribute wildcards */

/* descendants */
#foo a {} /* all descendants */
ul#list > li {} /* direct children */

/* siblings */
span ~ strong {} /* all adjacent */
p + p {} /* immediate adjacent */

/* combos */
div,p {}

/* variations */
#foo.bar.baz {}
div#baz.thunk a[-data-info*="hello world"] span + strong {}
#thunk[title$='huzza'] {}

##Reqwest Ajax https://github.com/ded/reqwest/blob/master/README.md

$.ajax({
    url: 'path/to/data.jsonp?foo=bar'
  , dataType: 'jsonp'
  , jsonp: 'foo'
  , jsonpCallback: 'bar'
  , success: function (resp) {
      console.log(resp.content);
    }
});

API

reqwest('path/to/html', function (resp) {
  qwery('#content').html(resp)
})

reqwest({
    url: 'path/to/html'
  , method: 'post'
  , data: { foo: 'bar', baz: 100 }
  , success: function (resp) {
      qwery('#content').html(resp)
    }
})

reqwest({
    url: 'path/to/html'
  , method: 'get'
  , data: [ { name: 'foo', value: 'bar' }, { name: 'baz', value: 100 } ]
  , success: function (resp) {
      qwery('#content').html(resp)
    }
})

reqwest({
    url: 'path/to/json'
  , type: 'json'
  , method: 'post'
  , error: function (err) { }
  , success: function (resp) {
      qwery('#content').html(resp.content)
    }
})

reqwest({
    url: 'path/to/json'
  , type: 'json'
  , method: 'post'
  , contentType: 'application/json'
  , headers: {
      'X-My-Custom-Header': 'SomethingImportant'
    }
  , error: function (err) { }
  , success: function (resp) {
      qwery('#content').html(resp.content)
    }
})

// Uses XMLHttpRequest2 credentialled requests (cookies, HTTP basic auth) if supported
reqwest({
    url: 'path/to/json'
  , type: 'json'
  , method: 'post'
  , contentType: 'application/json'
  , crossOrigin: true
  , withCredentials: true
  , error: function (err) { }
  , success: function (resp) {
      qwery('#content').html(resp.content)
    }
})

reqwest({
    url: 'path/to/data.jsonp?callback=?'
  , type: 'jsonp'
  , success: function (resp) {
      qwery('#content').html(resp.content)
    }
})

reqwest({
    url: 'path/to/data.jsonp?foo=bar'
  , type: 'jsonp'
  , jsonpCallback: 'foo'
  , jsonpCallbackName: 'bar'
  , success: function (resp) {
      qwery('#content').html(resp.content)
    }
})

reqwest({
    url: 'path/to/data.jsonp?foo=bar'
  , type: 'jsonp'
  , jsonpCallback: 'foo'
  , success: function (resp) {
      qwery('#content').html(resp.content)
    }
  , complete: function (resp) {
      qwery('#hide-this').hide()
    }
})

Promises

reqwest({
    url: 'path/to/data.jsonp?foo=bar'
  , type: 'jsonp'
  , jsonpCallback: 'foo'
})
  .then(function (resp) {
    qwery('#content').html(resp.content)
  }, function (err, msg) {
    qwery('#errors').html(msg)
  })
  .always(function (resp) {
    qwery('#hide-this').hide()
  })
reqwest({
    url: 'path/to/data.jsonp?foo=bar'
  , type: 'jsonp'
  , jsonpCallback: 'foo'
})
  .then(function (resp) {
    qwery('#content').html(resp.content)
  })
  .fail(function (err, msg) {
    qwery('#errors').html(msg)
  })
  .always(function (resp) {
    qwery('#hide-this').hide()
  })
var r = reqwest({
    url: 'path/to/data.jsonp?foo=bar'
  , type: 'jsonp'
  , jsonpCallback: 'foo'
  , success: function () {
      setTimeout(function () {
        r
          .then(function (resp) {
            qwery('#content').html(resp.content)
          }, function (err) { })
          .always(function (resp) {
             qwery('#hide-this').hide()
          })
      }, 15)
    }
})

##Jquery Plugin support For jquery plugin support return the plugin $.fn in a amd wrapper then in your amd module that you want the plugin just add it with

$.plugin("pluginName", jqueryPluginObject);

Then usage is

$("#selector").pluginName();

##Greensock Support

Make sure you follow there license agreements http://www.greensock.com/licensing/, if you cant then try morpheus https://github.com/ded/morpheus or another one of Dustin Diaz scripts

http://api.greensock.com/js/

$("#selector").animate({css:{scaleX:0.5, rotation:30}, ease:Power3.easeOut});

or

$("#selector").tween(1, {css:{scaleX:0.5, rotation:30}, ease:Power3.easeOut});

Contributors