You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Restructured and removed namespaces, detailed each component in the README at the top, separated forms into their own files, changed goGlobal to setGlobal, and more
Copy file name to clipboardExpand all lines: README.md
+36-53Lines changed: 36 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,20 @@
1
1
# jPack
2
-
jPack is a library of components, objects, plugin wrappers, and utilities designed to make building custom websites simpler.
3
-
4
-
With jPack, you can easily upgrade your server-side rendered application to a pseudo-SPA using XHR requests for page-loads, get values from the querystring, store and interact with user/multi-tenant website data, and more.
2
+
jPack is a library of components, classes, plugin wrappers, and utilities designed to make building custom websites simpler.
5
3
6
4
# What's Included
7
5
8
-
Four categories of functionality are provided in this library.
9
-
Each one is detailed further in the documentation below.
navigation | object | yes | Grabs HTML from a URL and replaces content on the current page. Handles browser history, meta title swaps, and offers several callbacks
9
+
XHRForm | class | no | Adds an on-submit listener and sends the form values using XHR with callbacks for success/failure
10
+
FormFromURL (extends XHRForm) | class | no | Grabs a form from a URL and places it on the current page (examples/FormModalFromURL shows how to put the form in a modal) and then uses an XHR request to submit the form
11
+
request | object | yes | Provides a wrapper for window.location and easy querystring interaction
12
+
Site | class | no | A generic website class with properties for id, name, and config - useful for multi-tenant applications where you need to know which site is being viewed
13
+
User | class | no | A generic user class with properties for id, name, email, phone, etc - also allows for front-end permission checks
14
+
strings | object | yes | Contains methods for semi-common string manipulation like creating a getter from a string ('hi' = 'getHi')
15
+
data_types | object | yes | Validate the value of a variable with higher specificity than built-in functions. For instance, you can validate an object contains specific keys and throw errors if not, or if it contains keys that you didn't define
16
+
dom | object | yes | Has methods for converting just about anything into a native DOM Element or array of them (you can provide a string selector, jQuery object, native DOM object, etc). Also has some shortcuts for common DOM checks/manipulation (like removing an element, verifying an element exists in the DOM, or replacing an element with HTML)
17
+
events | object | yes | Includes shorthand methods for preventing the browser's default action onsubmit, onclick. Other methods are included for consistency like onchange (which does not prevent default since that is generally not preferred)
17
18
18
19
# Installation
19
20
@@ -30,16 +31,15 @@ Don't forget to also include dependencies (listed in package.json).
30
31
window.addEventListener('load', function() {
31
32
32
33
//now you can take advantage of the jpack library
33
-
var fname =jpack.utilities.strings.ucfirst('bob'); //Bob
34
+
jpack.strings.ucfirst('bob'); //Bob
34
35
35
-
//or if you're feeling lazy, you can tie all jpack components to window for shorter use.
36
-
jpack.goGlobal("jp");
36
+
//if you want to change the namespace
37
+
jpack.setGlobal("$");
37
38
38
-
jp.strings.ucfirst('bob');
39
+
$.strings.ucfirst('bob');
39
40
40
-
//or if you're insanely lazy and want to cross your fingers that nothing conflicts, you can tie
41
-
// everything to window WITHOUT a namespace
42
-
jpack.goGlobal();
41
+
//if you want to make all global without a namespace - do so at your own risk! Things may conflict!
0 commit comments