1 | # zeynepjs
|
2 | > A lightweight multi-level jQuery side menu plugin.
|
3 |
|
4 | [![NPM](https://nodei.co/npm/zeynepjs.png)](https://nodei.co/npm/zeynepjs/)
|
5 |
|
6 | `zeynepjs` is a light-weight multi-level jQuery side menu plugin. It's fully customizable and is compatible with modern browsers such as Google Chrome, Mozilla Firefox, Safari, Edge and Internet Explorer.
|
7 |
|
8 | ## Options
|
9 |
|
10 | | Option | Type | Default | Description |
|
11 | | --- | --- | --- | --- |
|
12 | | htmlClass | boolean | true | If `true` zeynepjs will add some classes to `<html/>` element like `zeynep-initialized`, `zeynep-opened` |
|
13 |
|
14 | ## Methods
|
15 |
|
16 | `zeynepjs` exposes those:
|
17 |
|
18 | | Option | Type | Parameters | Description |
|
19 | | --- | --- | --- | --- |
|
20 | | on | function | `event name` and `handler function` | To dynamically event binding |
|
21 | | open | function | - | To open the menu |
|
22 | | close | function | `disableEvent` (optional) | To close the menu. If `disableEvent` is passed true, no close event will be fired |
|
23 | | destroy | function | - | To destroy the zeynepjs instance on initialized element |
|
24 |
|
25 | ## Events
|
26 |
|
27 | > Events can also be defined in options.
|
28 |
|
29 | ### `loading(element, options)`
|
30 |
|
31 | Fired when the menu is being loaded. This event cannot be defined dynamically. It needs to be defined in options.
|
32 |
|
33 | `element` is the element that zeynepjs is being loaded on.
|
34 |
|
35 | `options` is the initialized zeynepjs instance options.
|
36 |
|
37 | ### `load(element, options)`
|
38 |
|
39 | Fired when the menu is loaded. This event cannot be defined dynamically. It needs to be defined in options.
|
40 |
|
41 | `element` is the element that zeynepjs has been loaded on.
|
42 |
|
43 | `options` is the initialized zeynepjs instance options.
|
44 |
|
45 | ### `opening(element, options, details)`
|
46 |
|
47 | Fired when the menu or a sub-menu is being opened.
|
48 |
|
49 | `element` is the zeynepjs instance element.
|
50 |
|
51 | `options` is the initialized zeynepjs instance options.
|
52 |
|
53 | `details` contains a flag which indicates the item that is being opened is the menu or a sub-menu and the sub-menu DOM Element ID.
|
54 |
|
55 | ### `opened(element, options, details)`
|
56 |
|
57 | Fired when the menu or a sub-menu is opened.
|
58 |
|
59 | `element` is the zeynepjs instance element.
|
60 |
|
61 | `options` is the initialized zeynepjs instance options.
|
62 |
|
63 | `details` contains a flag which indicates the opened item is the menu or a sub-menu and the opened sub-menu DOM Element ID.
|
64 |
|
65 | ### `closing(element, options, details)`
|
66 |
|
67 | Fired when the menu or a sub-menu is being closed.
|
68 |
|
69 | `element` is the zeynepjs instance element.
|
70 |
|
71 | `options` is the initialized zeynepjs instance options.
|
72 |
|
73 | `details` contains a flag which indicates the item that is being closing is the menu or a sub-menu and the sub-menu DOM Element ID.
|
74 |
|
75 | ### `closed(element, options, details)`
|
76 |
|
77 | Fired when the menu or a sub-menu is closed.
|
78 |
|
79 | `element` is the zeynepjs instance element.
|
80 |
|
81 | `options` is the initialized zeynepjs instance options.
|
82 |
|
83 | `details` contains a flag which indicates the closed item is the menu or a sub-menu and the closed sub-menu DOM Element ID.
|
84 |
|
85 | ### `destroying(element, options)`
|
86 |
|
87 | Fired when the menu is being destroyed.
|
88 |
|
89 | `element` is the zeynepjs instance element.
|
90 |
|
91 | `options` is the zeynepjs instance options that is being destroyed.
|
92 |
|
93 | ### `destroyed(element, options)`
|
94 |
|
95 | Fired when the menu is destroyed.
|
96 |
|
97 | `element` is the destroyed zeynepjs instance element.
|
98 |
|
99 | `options` is the destroyed zeynepjs instance options.
|
100 |
|
101 | ## Usage
|
102 |
|
103 | ```js
|
104 | // initialize zeynepjs and get the instance into a variable
|
105 | var zeynep = $('.zeynep').zeynep({
|
106 | load: function (element, options) {
|
107 | console.log('zeynepjs menu is successfully loaded')
|
108 | }
|
109 | })
|
110 |
|
111 | // opens the menu
|
112 | zeynep.open()
|
113 |
|
114 | // closes the menu
|
115 | zeynep.close()
|
116 |
|
117 | // dynamically event binding
|
118 | zeynep.on('closing', function () {
|
119 | console.log('guys, the side menu is closing')
|
120 | })
|
121 |
|
122 | // destroys the menu
|
123 | zeynep.destroy()
|
124 | ```
|
125 |
|
126 | ## Using with Webpack
|
127 | Once the library installed in your project, just import it:
|
128 |
|
129 | ```js
|
130 | import 'zeynepjs'
|
131 | ```
|
132 |
|
133 | ## Contribution
|
134 | Contributions and pull requests are kindly welcomed!
|
135 |
|
136 | ## License
|
137 | This project is licensed under the terms of the [MIT license](https://github.com/hsynlms/zeynepjs/blob/master/LICENSE).
|