Forms
Examples of code used for forms.
Multiple
Library to add dynamic fields easily.
Library Name |
Unknown
|
Library Version |
Unknown |
Works on |
Everything |
Required Attributes |
data-name |
Optional Attributes |
data-load: if you want that everytime is loaded the script should load a js function.
data-remove: load a function when its removed an object, the item is sent.
data-values
data-not-change: set true to an input so the value will not change dinaymically
|
Returns |
An array with the data
|
Empty
HTML Code
<span id="costs-add">Add</span>
<ul data-type="multiple" data-name="costs">
<li>
<label>Name</label><input type="text" name="name" />
<label>Cost</label><input type="text" name="cost" value="100" />
<span class="costs-remove">Remove</span>
</li>
</ul>
Request sent
$POST['costs'] = [
[
'name' => 'value',
'cost' => 'value'
],
[
'name' => 'value',
'cost' => 'value'
],
....
];
With selected data
PHP Code
<?php
$array = array(
0 => array(
'name' => 'Ejemplo1',
'cost' => '100',
),
1 => array(
'name' => 'Ejemplo2',
'cost' => '200',
),
2 => array(
'name' => 'Ejemplo3',
'cost' => '300',
),
);
$array = json_encode($array);
?>
HTML Code
<span id="costs-add">Add</span>
<ul data-type="multiple" data-name="costs" data-values='<?php echo $array; ?>'>
<li>
<label>Name</label><input type="text" name="name" />
<label>Cost</label><input type="text" name="cost" value="100" />
<span class="costs-remove">Remove</span>
</li>
</ul>
Works with this library
HTML Code
<span id="multiple3-add">Add</span>
<ul data-type="multiple" data-name="multiple3">
<li>
<label>Name</label><input type="text" name="name" />
<label>Date</label><input type="text" data-type="date" name="name" />
<label>Color</label><input type="text" data-type="color" name="name" />
<span class="multiple3-remove">Remove</span>
</li>
</ul>
Bidimensional
Library to add bidimensional dynamic fields easily.
Library Name |
Unknown
|
Library Version |
Unknown |
Works on |
ul |
Required Attributes |
data-name |
Optional Attributes |
data-values
|
Returns |
An array with the data
|
Empty
HTML Code
<span id="multiple4-add-row">Add row</span>
<ul data-type="bimultiple" data-name="multiple4">
<li>
<ul>
<li>
<label>Name</label><input type="text" data-type="color" name="color" />
<span class="multiple4-remove-column">Remove</span>
</li>
</ul>
<span class="multiple4-add-column">Add</span>
<span class="multiple4-remove-row">Remove</span>
</li>
</ul>
Request sent
$POST['multiple4'] = [
0 => [
'color' => [
'#fff',
'#000',
'#ddd',
'#777',
....
]
],
1 => [
'color' => [
'#f9f9f9',
...
]
],
....
];
With default data
HTML Code
<span id="multiple5-add-row">Add row</span>
<ul data-type="bimultiple" data-name="multiple5" data-values='[{"color":["#fff","#000","#ddd"]},{"color":["#333","#fff","#ddd","#888"]},{"color":["#ccc"]}]'>
<li>
<ul>
<li>
<label>Name</label><input type="text" data-type="color" name="color" />
<span class="multiple5-remove-column">Remove</span>
</li>
</ul>
<span class="multiple5-add-column">Add</span>
<span class="multiple5-remove-row">Remove</span>
</li>
</ul>
Empty but with extra fields
Used if you need to send some extra fields
HTML Code
<span id="multiple6-add-row">Add row</span>
<ul data-type="bimultiple" data-name="multiple6">
<li>
<ul>
<li class="extra">
<label>Name</label><input type="text" name="name" />
</li>
<li>
<input type="text" data-type="color" name="color" />
<span class="multiple6-remove-column">Remove</span>
</li>
</ul>
<span class="multiple6-add-column">Add</span>
<span class="multiple6-remove-row">Remove</span>
</li>
</ul>
Request sent
$POST['multiple6'] = [
0 => [
'name' => 'Home',
'color' => [
'#fff',
'#000',
'#ddd',
'#777',
....
]
],
1 => [
'name' => 'Away',
'color' => [
'#f9f9f9',
...
]
],
....
];
Extra fields with data
HTML Code
<span id="multiple7-add-row">Add row</span>
<ul data-type="bimultiple" data-name="multiple7" data-values='[{"name":"Home","color":["#fff","#000","#ddd"]},{"name":"Away","color":["#333","#fff","#ddd","#888"]},{"name":"Special","color":["#ccc"]}]'>
<li>
<ul>
<li class="extra">
<label>Name</label><input type="text" name="name" />
</li>
<li>
<input type="text" data-type="color" name="color" />
<span class="multiple7-remove-column">Remove</span>
</li>
</ul>
<span class="multiple7-add-column">Add</span>
<span class="multiple7-remove-row">Remove</span>
</li>
</ul>
Hierarchical
Sends $_GET["id"] to file, you need to send a json with key and value (title). Add data-parent attribute to select who should be the default parent. With data-value-parent will select automatically the value, add "," to separate actions.
Library Name |
OptionTree
|
Library Version |
Unknown |
Works on |
input |
Required Attributes |
src, name |
Additional Attributes |
data-value-select: Allow to preselect values
|
Returns |
Key of the last selected children.
|
HTML Code
<input
type="text"
name="category"
data-type="hselect"
src="get-subtree.php"
data-value-select="220,226"
/>
PHP Code
<?php
header('Access-Control-Allow-Origin: *');
$id = (isset($_GET['id']) && is_numeric($_GET['id']) ? (int) $_GET['id'] : null);
echo json_encode(getChildsOf($id)); // Call method for getting childs in base of an ID
?>
JSON Example
{
"0":"Animals",
"18":"Arts & Entertainment",
"220":"Baby & Toddler",
"252":"Business & Industrial",
"340":"Cameras & Optics",
"412":"Clothing & Accessories",
"602":"Electronics",
"954":"Food, Beverages & Tobacco",
"1048":"Furniture",
"1123":"Hardware",
"1528":"Health & Beauty",
"1694":"Home & Garden",
"2247":"Luggage",
"2272":"Mature",
"2296":"Media",
"2635":"Office Supplies",
"2744":"Software",
"2790":"Sporting Goods",
"3369":"Toys & Games",
"3496":"Vehicles & Parts"
}
Dates
Library Name |
Unknown
|
Library Version |
Unknown |
Works on |
input |
Required Attributes |
None |
Optional Attributes |
lang: (Default en) for selecting the language (Example en, es, etc) |
Returns |
The date value
|
Date
HTML Code
<input type="text" name="date" data-type="date" lang="es" value="2015-12-01" />
Datetime
HTML Code
<input type="text" name="datetime" data-type="datetime" lang="es" value="2015-12-01 00:00" />
Time
Library Name |
Jquery.timepicker
|
Library Version |
v1.8.8 |
Works on |
input |
Required Attributes |
None |
Returns |
The time value
|
HTML Code
<input type="text" name="time" data-type="time" value="15:06"/>
Date 2nd style
HTML Code
<input type="text" data-type="date2" lang="es" />
WYSIWYG
Library Name |
Froala Editor
|
Library Version |
v2.4.0 |
Works on |
textarea |
Required Attributes |
None |
Optional Attributes |
data-lang (Default en), data-upload-url |
Returns |
The text in HTML Format
|
HTML Code
<textarea data-type="wysiwyg"></textarea>
Autocomplete
Autocompletes a text field. It is necessary the name attribute. The PHP Code recieves $_GET['term'] with the searched word. The php url should accept $_GET Responses.
It generates automatically a new input with name+'_text' with the text value. If you want to remove it use data-text-input=false
Library Name |
Jquery UI
|
Library Version |
v1.12.1 |
Works on |
input |
Required Attributes |
name |
Optional Attributes |
data-selected-value, data-selected-text, data-reload, data-action |
Returns |
The Key of the selected value
|
Empty Field
HTML Code
<input data-type="autocomplete" name="aut" src="autocomplete.php" />
PHP Code
<?php
$res = array();
// id is what is passed to the field
$res[] = array("label"=>$_GET["term"], "id" => 99, "value" => $_GET["term"]);
$res[] = array("label"=>"dos", "id" => 2, "value" => "dos");
$res[] = array("label"=>"tres", "id" => 3, "value" => "tres");
print json_encode($res);
?>
With selected data
HTML Code
<input
data-type="autocomplete"
data-selected-text="Hola"
data-selected-value="valor"
name="aut20"
src="autocomplete.php"
/>
With reload and with action
It will be send a $_POST['result'] variable with the selected data. First the action will be called and then it will be reloaded.
This option is used for saving the selected data and then reload the website, ideally for saving languages, timezones, etc.
HTML Code
<input data-type="autocomplete" name="aut2" src="autocomplete.php" data-reload="true" data-action="sautocomplete.php" />
Example of $_POST["result"]
object(stdClass)#1 (3) {
["label"]=>
string(3) "aaa"
["id"]=>
int(99)
["value"]=>
string(3) "aaa"
}
Sliders
Library Name |
Jquery UI
|
Library Version |
v1.12.1 |
Works on |
input |
Required Attributes |
data-max, data-min, data-slider |
Optional Attributes |
data-step |
Returns |
The value of the slider
|
Range
To show the values dynamictly you should call name+'min' or name+'max'. For example if the name of the input is example to show the minimum value selected you shoud add <span id="example-min"></span>
HTML Code
<p>$<span id="slider-min">100</span> - $<span id="slider-max">200</span></p>
<input data-type="slider" data-slider="range" data-max="200" data-min="100" name="slider" />
Increments
To show the values dynamictly you should call name+'val'. For example if the name of the input is example to show the minimum value selected you shoud add <span id="example-val"></span>
HTML Code
<p>$<span id="slider2-val">100</span></p>
<input data-type="slider" data-slider="increments" data-max="20" data-min="0.5" data-step="0.5" name="slider2" />
Code Editor
Se color can be selected between: black, white, gray and blue with data-color property
Library Name |
Ace
|
Library Version |
Unknown |
Works on |
textarea |
Required Attributes |
data-lang |
Returns |
The code written
|
HTML Code
<textarea data-type="codeeditor" data-lang="javascript" data-color="black" name="code">
function foo(items) {
var x = "All this is syntax highlighted";
return x;
}
</textarea>
Imgur Uploader
Librery used for uploading images easily to Imgur. You will get the final url on the input.
Library Name |
Imgur JS Uploader
|
Library Version |
Newest (Using CDN) |
Works on |
input |
Required Attributes |
None |
Returns |
The image url
|
HTML Code
<input data-type='imgur' type="text" />
Conditional
Library Name |
Conditionize2.js
|
Library Version |
2.0.1 |
Works on |
div |
Required Attributes |
None |
HTML Code
<label><input type="radio" name="example1" value="yes"><span></span> Yes</label>
<label><input type="radio" name="example1" value="no"><span></span> No</label>
<div data-type="conditional2" data-condition="example1=='yes'">
<label><input type="checkbox" name="example2" id="ex2"><span></span> Are you sure?</label>
<label><input type="checkbox" name="example3"><span></span> Really super sure?</label>
<div data-type="conditional2" data-condition="#ex2">
Hooray!
</div>
<div data-type="conditional2" data-condition="example3">
Don't get cocky!
</div>
</div>
<div data-type="conditional2" data-condition="example1=='no'">
<p>That's a shame. Will you change your mind?</p>
<label><input type="radio" name="example4" value="yes"><span></span> Yes</label>
<label><input type="radio" name="example4" value="no"><span></span> No</label>
<div data-type="conditional2" data-condition="example4=='yes'">
Great!
</div>
</div>
<p>
<label>or choose:</label>
<select class="select" name="example5">
<option>Pick one!</option>
<option value="yes">Yes!</option>
<option value="no">No!</option>
</select>
</p>
<div data-type="conditional2" data-condition="example5=='yes'">
Works with selects!
</div>
<p>
<label>or type:</label>
<input type="text" name="example6" placeholder="yay">
</p>
<div data-type="conditional2" data-condition="example6=='yay'">
Works with text input
</div>
Validation
This features add patterns automatically for validating the data.
Library Name |
Unknown
|
Library Version |
Unknown |
Works on |
input |
Required Attributes |
data-validation |
Returns |
Unknown
|
Alpha Numeric
HTML Code
<input type="text" data-validation="alphanumeric" />
Numeric
HTML Code
<input type="text" data-validation="numeric" />
URL
HTML Code
<input type="text" data-validation="url" />
Day
HTML Code
<input type="text" data-validation="day" />
Year
HTML Code
<input type="text" data-validation="year" />
Email
HTML Code
<input type="text" data-validation="email" />
Two fields check
HTML Code
<input type="text" data-validation="same" for="field-two" />
<input type="text" id="field-two" />
Slug Generator
Library Name |
Unknown
|
Library Version |
Unknown |
Works on |
input |
Required Attributes |
None |
Returns |
The slug
|
HTML Code
<input type="text" data-type=&<input type="text" id="copyHere" placeholder="Title" />
<input data-type="slug" for="copyHere" type="text" />
Color Picker
Library Name |
jqColorPicker
|
Library Version |
v1.0.4 |
Works on |
input |
Required Attributes |
None |
Returns |
The color in hexadecimal
|
HTML Code
<input type="text" data-type="color" />
On off
Library Name |
Iphone Style Switchers
|
Library Version |
?? |
Works on |
input |
Required Attributes |
None |
Optional Attributes |
data-on, data-off |
Returns |
Buttons on off
|
HTML Code
<input type="text" data-type="onoff" value="0" data-on="Activar" data-off="Desactivar" />
Image Cropper
This tool allows you to get the x and y coordiates from 2 points from an image
Library Name |
Jcrop
|
Library Version |
v2.0.4 |
Works on |
input |
Required Attributes |
data-image |
Optional Attributes |
data-width, data-height, data-ratio, data-handler |
Normal Use
HTML Code
<img src="https://fengyuanchen.github.io/cropperjs/images/picture.jpg" id="image-to-crop" />
<input type="text" data-type="cropper" data-image="image-to-crop" data-width="100%" />
With Default Values
HTML Code
<img src="https://fengyuanchen.github.io/cropperjs/images/picture.jpg" id="image-to-crop" />
<input type="text" data-type="cropper" data-image="image-to-crop" data-width="500" data-ratio="1" value='{"x":314.88,"y":220.16,"x2":596.48,"y2":501.76,"w":281.6,"h":281.6}' />
With Min and Max sizes
HTML Code
<img src="https://fengyuanchen.github.io/cropperjs/images/picture.jpg" id="image-to-crop-with-min-and-max" />
<input type="text" data-type="cropper" data-image="image-to-crop-with-min-and-max" data-width="500" data-min-sizes="80,80" data-max-sizes="300,300" />
Call handler
To execute a javascript function every time the cropper is moved
HTML Code
<img src="https://fengyuanchen.github.io/cropperjs/images/picture.jpg" id="image-to-crop2" />
<input type="text" data-type="cropper" data-image="image-to-crop2" data-width="500" data-handler="functionName" />
<script type="text/javascript">
function functionName(c) {
console.log('Entra');
}
</script>
Image Coordinate
This tool allows you to get the x and y coordiates from 1 point from an image
Library Name |
Created from scratch
|
Library Version |
?? |
Works on |
input |
Required Attributes |
data-image |
Normal Use
HTML Code
<img src="https://atayahmet.github.io/jquery.easypin/img/avengers.jpg" id="image-to-get-coordinates" width="100%" />
<input type="text" data-type="image-coordinate" data-image="image-to-get-coordinates" />
With Default Value
HTML Code
<img src="https://atayahmet.github.io/jquery.easypin/img/avengers.jpg" id="image-to-get-coordinates" width="100%" />
<input type="text" data-type="image-coordinate" data-image="image-to-get-coordinates" value="1080,429" />
Complements
Examples of code used for complements.
Sortable
This tool allows you to add a drag and drop actions in your website
Library Name |
Jquery UI
|
Library Version |
v1.12.1 |
Works on |
ul |
Optional Attributes |
data-connect |
One sortable
Result
- Item 1
- Item 2
- Item 3
- Item 4
- Item 5
- Item 6
- Item 7
- Item 8
HTML Code
<ul data-type="sort">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
<li>Item 8</li>
</ul>
Multiple sortable
This will allow you to move between lists. When adding data-connect it will connect to every sortable element with the class of the data-connect value
Result
- Item 1
- Item 2
- Item 3
- Item 4
- Item 5
- Item 6
- Item 7
- Item 8
- Item 5
- Item 6
- Item 7
- Item 8
HTML Code
<ul class="connection" data-type="sort" data-connect="connection">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
<li>Item 8</li>
</ul>
<ul class="connection" data-type="sort" data-connect="connection">
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
<li>Item 8</li>
</ul>
<ul class="connection" data-type="sort" data-connect="connection">
<li>Item 1</li>
<li>Item 2</li>
</ul>
Fitty
Automatic fits a text to the container
Library Name |
Fitty
|
Library Version |
v2.3.3 |
Normal use
HTML Code
<h1 data-type="fitty">Fit this</h1>
Show code
Show code in a code tag
Library Name |
Ace
|
Library Version |
Unknown |
Works on |
code |
Required Attributes |
data-lang |
Normal use
Result
function ejemplo() {
console.log("Este es un ejemplo de un codigo javascript");
}
HTML Code
<code data-type="codeeditor" data-lang="javascript">function ejemplo() {
console.log("Este es un ejemplo de un codigo javascript");
}</code>
Change on Click
Change the view of a div when we make a click
Normal use
HTML Code
<div id="country" data-type="changeOnClick">
<img src="http://www.ssn.unam.mx/imagenes/bandera-mexico.png" />México
</div>
<div for="country">
<input data-type="autocomplete" name="aut2" src="autocomplete.php" />
</div>
Click On Change
Automatically make a click on something once an input changes
Normal use
HTML Code
<form action="envia.php">
<input data-type="clickOnChange" type="file" id="coc" name="archivos[]" multiple="true"/>
<input type="submit" for="coc" style="display:none;" />
</form>
Zoom Viewer
Automatically make a click on something once an input changes
Library Name |
Zoom
|
Library Version |
1.7.14 |
Works on |
div |
Normal use
HTML Code
<div data-type="zoom" style="width: 500px;">
<img src="http://www.jacklmoore.com/img/daisy.jpg" style="width:100%" />
</div>
Carousel
Makes an automatically carousel
Library Name |
Owl Carousel
|
Library Version |
1.3.3 |
Works on |
div |
Optional Attributes |
data-carousel-items-desktop, data-carousel-items-desktop-small, data-carousel-items-tablet, data-carousel-items-mobile |
Normal use
Result
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Previous
Next
Autoplay
Stop
HTML Code
<div data-type="carousel" data-carousel-time="1000" data-carousel-items="10" data-carousel-items-tablet="5" id="carousel">
<div class="item"><h1>1</h1></div>
<div class="item"><h1>2</h1></div>
<div class="item"><h1>3</h1></div>
<div class="item"><h1>4</h1></div>
<div class="item"><h1>5</h1></div>
<div class="item"><h1>6</h1></div>
<div class="item"><h1>7</h1></div>
<div class="item"><h1>8</h1></div>
<div class="item"><h1>9</h1></div>
<div class="item"><h1>10</h1></div>
<div class="item"><h1>11</h1></div>
<div class="item"><h1>12</h1></div>
<div class="item"><h1>13</h1></div>
<div class="item"><h1>14</h1></div>
<div class="item"><h1>15</h1></div>
<div class="item"><h1>16</h1></div>
</div>
<span data-carousel-type="prev" for="carousel">Previous</span>
<span data-carousel-type="next" for="carousel">Next</span>
<span data-carousel-type="play" for="carousel">Autoplay</span>
<span data-carousel-type="stop" for="carousel">Stop</span>
Image Tile Viewer
Display large images with Deep Zoom technology.
Library Name |
OpenSeadragon
|
Library Version |
3.0.0 |
Works on |
div |
Required Attributes |
data-dzi: The url of the DZI file |
Optional Attributes |
data-markers: JSON data for the markers.
data-prefix: Prefix URL to prepend on the navigation images
data-icon: url of custom marker icon image
data-icon-size: size of the marker icon image
data-icon-offset: offset size % of the marker from its coordinates
data-disable-zoom: set true to disable zooming
data-disable-pan: set true to disable panning
data-disable-controls: set true to disable controls
data-zoom-default: default zoom level of the viewer
data-zoom-min: minimum zoom level of the viewer
data-zoom-max: maximum zoom level of the viewer
data-custom-controls: set true to show custom made controls
|
Normal Use
Feed to data-markers a JSON array with an object for each marker. The object needs to have X and Y pixel-based coordinates. Example: "x": "1000","y": "1000" will put the marker one thousand pixels from the left and from the top.
If you want to show a note when clicking the marker you can add a "note": "My message" property to the object with the content you want to show (supports HTML). If you want to go to a site instead you can add an "url": "https://weblabor.mx" property with the destination, this will override the "note": property if there's any.
To add more flavor to your markers you can add a tooltip with "tooltip": "My tooltip!", this will override the default tooltip from the markers with "url":.
Finally, you can replace individual markers icon using "icon": "https://mywebsite.com/myicon.jpg".
HTML Code
<div data-type="image-tile-viewer" data-dzi="https://openseadragon.github.io/example-images/duomo/duomo.dzi" data-icon-size="[250,410]" data-markers='[{"x": "1000","y": "1000","url": "https://weblabor.mx", "tooltip": "URL with tooltip →"},{"x": "2000","y": "2000","note": "Easy JS is a cool library!"},{"x": "2000","y": "3000","note": "Check our repository on <a href=\"https://github.com/weblabormx/Easy-JS-Library\">Github</a>!", "tooltip": "Note with tooltip"}]' style="height: 500px;"></div>
Customizing
Using data-icon="https://yoururl.com/icon.jpg" will allow you to customize the icon. And with data-custom-controls="true" you can choose to use a different type of controls.
To change the size of the markers use data-icon-size passing the width and height as a tuple. Example: [1000,1640].
HTML Code
<div data-type="image-tile-viewer" data-dzi="https://openseadragon.github.io/example-images/duomo/duomo.dzi" data-icon-size="[1000,1640]" data-custom-controls="true" data-icon="https://tiuswebs.s3-us-west-1.amazonaws.com/30/multimedia/V3UkyvIdH.png" data-markers='[{"x": "4000","y": "5000","note": "I am big!"}]' style="height: 500px;"></div>
Removing drag
You can choose to remove the dragging of the image with data-disable-pan="true", try moving the image around.
HTML Code
<div data-type="image-tile-viewer" data-dzi="https://openseadragon.github.io/example-images/duomo/duomo.dzi" data-icon-size="[250,410]" data-disable-pan="true" style="height: 500px;"></div>
Removing zoom
You can remove the zoom ability with data-disable-zoom="true", and use data-disable-controls="true" to hide the controls.
HTML Code
<div data-type="image-tile-viewer" data-dzi="https://openseadragon.github.io/example-images/duomo/duomo.dzi" data-icon-size="[250,410]" data-disable-zoom="true" data-disable-controls="true" data-markers='[{"x": 5000","y": "2000","note": "Enjoy the component!"}]' style="height: 500px;"></div>