npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquery.moxa

v0.6.5

Published

Dividing a JavaScript file for jQuery

Downloads

6

Readme

jQuery.Moxa

Dividing a JavaScript file. No global pollution. Lightweight simple library.

Get

You can get it on npm or bower.

npm install jquery.moxa --save

bower install jquery.moxa --save

If you're not into package management, download a file.

Setup

Include script after the jQuery library.

<script src="/path/to/jquery.moxa.min.js"></script>

Usage

// Controller
$.moxa.controller(function(aViews, aObserver, aDef, aUtil, aAjax){
    // set view -> controller received functions
    aObserver.set({
        some: function(data){
        	// do something.
        }
    });

    // ajax data.
    var mData = {
     	some: null
    };

    // get somejson
    aAjax.get('some.json', function(data){
    	// save data.
    	mData.some = data;
        // send data to view
        aViews.top.init(mData.some);
    });

    // window.Moxa is assigned the object. be able to access of global.
    return {
     	swf: function(){
     		// do something.
     	}
    }
});
// Top View
$.moxa.view('top', function(aController, aDef, aUtil, aViewObserver){
    // set controller -> view received functions
    aController.set({
        init: function(data){
            // do something.
        }
    });

    // click events.
    (function(){
        $('#button').on('click', function(){
            // trigger to controller.
            aController.some();
        });
    })();

    // define functions.
    // $.append(), $.remove(), $hide(), $.addClass()........etc
});

controller's function is executed from $(document).ready() or Ext.onReady().

jQuery.Moxa By is to implement the process for each role(controller, view..etc) to provide, is suppressed to be a global function definition.

Each role function of the argument , or , is done via observer of jQuery.Moxa. And also it works to concat files and minify by gulp.

Features

  • Dividing a JavaScript file
  • Lightweight, simple, easy
  • No Single Pag Applicatin framework
  • It is also possible to concat files and minify by gulp

Targets

  • Page that performs Ajax request
  • 1000 or more lines of JavaScript code in a file
  • Interactive UI ( click , message box , CSS operation ... etc)
  • Want to utilize the existing assets (jQuery , etc.)
  • Angular, React, Backbone are difficult , or there are not enough to use

Rules

Just observe the following rules, readability, maintainability will be greatly improved.

  • Controller run Ajax request(Don't run Ajax request in View)
  • The data gotten from Ajax is held by Controller, and passes to View, if necessary(Owner clarification of data)
  • DOM operation perform in the View(It is not the $.find ()..etc in Controller)
  • Click event handler registration is done in the immediate function of View.

jQuery.Moxa Objects

image

Controller

$.moxa.controller(callback)

The callback is run from the $(document).ready() or Ext.onReady(). Please implement the mainly call divided of view, ajax of execution, data processing. It can be only one registration.

callback(views, observer, def, util, ajax)

  • views: View objects that are registered with $.moxa.view(). You can notify the function that has been registered in the View.
  • observer: By registering the object for reception in observer.set() function, you can receive notification of observers from View.
  • def: Def object that was registered at $.moxa.def()
  • util: Util object
  • ajax: Ajax object

View

$.moxa.view(name, callback)

The name, please specify a string that is easy to identify in Controller callback. The callback is run from the $ (document).ready() or Ext.onReady(). Please implement the mainly Click · DOM · CSS -related processing. View you can be multiple registration.

callback(controller, def, util, viewObserver)

  • controller: By registering the object for reception in controller.set() function, you can receive notification of observers from Controller. In addition, you can also call notifying the registered function in Controller.
  • def: Def object that was registered at $.moxa.def()
  • util: Util object
  • viewObserver: By registering the object for reception in viewObserver.set() function, you can receive a notification observer from another View. In addition, you can the child be notified by calling the registered function in another View.

Util

isEmpty(data)

It will return false if the empty string, null, [ ].

isShow(el)

It will return false if el is hidden(display: none).

$.moxa.util(properties)

By passing an object that keys and functions as a set in it, you will be able to extend the Util.

Def

$.moxa.def(properties)

By keys and values ​​to pass an object as a set, you can be registered in the Def. When you register a URL · setting flag · message string , etc. It is convenient.

Ajax

get(url, data, success, error)

This will contact the server at the GET request.

  • url: Contact URL
  • data: The value to be transmitted to the server
  • success: Ajax event that will be called on success
  • error: Ajax event that will be called on failure

post(url, data, success, error)

This will contact the server at the POST request.

  • url: Contact URL
  • data: The value to be transmitted to the server
  • success: Ajax event that will be called on success
  • error: Ajax event that will be called on failure

$.moxa.ajax(properties)

By passing an object that keys and functions as a set in it, you will be able to extend the Ajax. Common ajax processing, for example, it is useful to register and the like want to do a specific process in the request failure.

Examples

License

Licensed under MIT License