/
index.html
150 lines (116 loc) · 4.12 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>z-tags</title>
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
<!-- inital style -->
<link rel="stylesheet" href="css/z-grid.css">
<link rel="stylesheet" href="css/style.css">
<!-- link to include for stylish tags -->
<link rel="stylesheet" href="z-tags/z-tags.css">
</head>
<body>
<section class="sidebar align-center">
<h1 class="light">Z-Tags</h1>
<p>A little VanillaJs plugin displaying stylish tags areas.</p>
<p>
<a href="http://github.com/benavern/z-tags" class="button">Github</a>
<a href="z-tags/" class="button">Download</a>
</p>
<p>
Made with <span class="pink">♥</span> by <br> <a href="http://caradeuc.info">© Benjamin Caradeuc</a>
</p>
</section>
<section class="content">
<h1>
What is Z-Tags?
</h1>
<p>
Z-Tags is a javascript plugin that lets you create tags areas very easily. By using it, you will be able to have tags sections on your webpage, and the possibility to let users add tags in that sections.
</p>
<p>
You won't need any javascript library, it is totally written in vanillaJs.
</p>
<hr>
<h1>
Demo
</h1>
<div id="test"></div>
<button id="get-tags">Get The Data</button>
<p>
Here you can see a default tags section. There are 3 tags predefined, you can add and delete tags in it (by clicking the area). There is also a method to get the data in it (the button just bellow the area).
</p>
<hr>
<h1>
HowTo
</h1>
<ol>
<li>
Include the css and js files in your html file. ("download" button)
</li>
<li>
Create a div with an id or class you will be able to find with javascipt.
<pre><div id="demo1"></div></pre>
</li>
<li>
In your javascript scripts, create an instance of the ZTAGS class for each div that will be transformed in a tags section, add it some arguments if necessary.
<pre>var demo1 = document.getElementById('demo1');<br>var tagsdemo1 = new ZTAGS({<br> element: demo1, <br> options: {readonly: false, pattern: false, color: "#6677CC"}<br>});</pre>
</li>
</ol>
<h3>Arguments</h3>
<p>
2 arguments are available, they have to be given on the instanciation of an object with those names :
</p>
<ul>
<li><b>element</b> : [Dom object] The element (div) that will be transformed in a tags section.</li>
<li><b>options</b> : [Object] The list of options:</li>
<ul>
<li><b>predefined</b> : [Array (optional)] The array of predefined tags.</li>
<li><b>readonly</b> : [boolean (optional)] Whether user can add, delete tags or not. </li>
<li><b>pattern</b> : [Array (optional)] The array of granted words for the tags.</li>
<li><b>color</b> : [String (optional)] the color the tags will appear (like in CSS)</li>
</ul>
</ul>
<h3>Methods</h3>
<p>Some javascript methods have been created:</p>
<ul>
<li><b>ZTAGS.add(newTag)</b> : can be used to add a tag on a ZTAGS instance. (newTag must be a string)</li>
<li><b>ZTAGS.delete(tagToDelete)</b> : can be used to delete a specific tag. (tagToDelete must be a string / will delete all tags with same label)</li>
<li><b>ZTAGS.get()</b> : returns the array of tags.</li>
</ul>
<hr>
<h1>
Examples:
</h1>
<h3>Read-only</h3>
<div id="test2"></div>
<h3>Pattern limited</h3>
<small>( ["apple", "cherry", "lemon"] )</small>
<div id="test3"></div>
<h3>External function calls</h3>
<div id="test4"></div>
<button id="addto4">Add</button>
<button id="removefrom4">Remove</button>
<h3>Colored tags</h3>
<ul>
<li>
<p>color: "red"</p>
<div id="test5"></div>
</li>
<li>
<p>color: "rgb(50, 200, 50)"</p>
<div id="test6"></div>
</li>
<li>
<p>color: "#3355DD</p>
<div id="test7"></div>
</li>
</ul>
</section>
</body>
<!-- my scripts -->
<script src="js/app.js"></script>
<!-- script to include to make tags being displayed -->
<script src="z-tags/z-tags.js"></script>
</html>