According to needs in FrameworkJS, we made the controls module. This will provide us with some user interface tools like buttons and text boxes.
app.controls.panel(content, id, options);
Parameters | Type | Description |
---|---|---|
content | String | This is the content HTML |
id | String | Optional. This is referred to key of each made control. |
options | Object | Options are for some customizations. It has two parameters. |
options: For options there are below parameters:
app.controls.panel(content, id, {closeButton: true});
app.controls.panel(content, id, {closeViaOverlay: true});
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>FrameworkJS</title>
<link rel="stylesheet" type="text/css" href="lib/framework.css">
<!-- add your page styles here -->
<!-- <link rel="stylesheet" type="text/css" href="css/"> -->
<link rel="stylesheet" type="text/css" href="css/home.css">
</head>
<body>
<div class="page home">
<h1>Panel Control!</h1>
<div class="button" key="show">Show Panel<div>
<div class="button" key="hide">Hide Panel<div>
</div>
</body>
<script src="lib/cloadio.min.js"></script>
<script src="lib/jquery-2.2.0.min.js"></script>
<script src="lib/framework-a.min.js"></script>
<script src="lib/framework-b.min.js"></script>
<script src="js/app.js"></script>
<!-- add your module scripts here -->
<!-- <script src="modules/"><script> -->
<script src="modules/controls/js/script.js"></script>
<!-- add your page scripts here -->
<!-- <script src="js/"></script> -->
<script src="js/home.js"></script>
</html>
app.ui.button($('.page.home'), 'ripple', {
key: 'show',
color: '#747474',
onPush: function (jButton) {
var html = '<div class="text">Hello World!</div>';
app.controls.panel(html, 'text', {closeButton: true});
}
});
app.ui.button($('.page.home'), 'ripple', {
key: 'hide',
color: '#747474',
onPush: function (jButton) {
app.controls.panel.destroy();
}
});
app.controls.box(type, id, text, align, callback);
The box control has five parameters.
Parameters | Type | Description |
---|---|---|
type | String | This defines the type of alert box. It can be 'alert' or 'confirm'. The 'alert' type just shows an information box to users. The 'confirm' type is to get feedback, so it shows the 'Yes/No' question in the box. |
id | String | Optional. This is the key of each created control box. It is for this purpose that you may have several boxes on one page, so you can separate them by getting id. |
text | String | This contains the message of the alert box. The type is a string. |
align | String | Optional. This determines the direction of the text. |
callback | Function | Optional. This is a function. If you use the 'confirm' type, this parameter returns the result of user selection. |
app.controls.box('alert', 'test', 'Please fill the blank...', 'center');
app.controls.box('confirm', 'test', 'Do you agree to go home page?', 'left', function (result) {
if (result)
homePage.show();
else
chatPage.show();
});
app.controls.options(items, callback, options);
This control has three parameters.
Parameters | Type | Description |
---|---|---|
items | Object | This is the list of items that shows in the control for user. |
callback | Function | When user selects an option, this function returns the result. |
Options | Object | Optional. It contains several items:
|
app.controls.toast(type, id, text, align, callback);
The toast control has five parameters.
Parameters | Type | Description |
---|---|---|
type | String | This defines the type of toast. It should be 'toast'. |
id | String | Optional. This is the key to each created toast box. It is for this purpose that you may have several toasts on one page, so you can separate them by getting id. |
text | String | The content of the toast message. |
align | String | Optional. This determines the direction of the text. |
callback | Function | Optional. This parameter returns the result of user selection when your toast contains a content selection. |
app.controls.toast('toast', 'test', 'Your operation was successful.', 'left');
app.controls.select(title, items, callback);
The select control has three parameters.
Parameters | Type | Description |
---|---|---|
title | String | The string text helps user what to do. |
items | Object | The items contain a list of objects. |
callback | Function | Shows the result of user-selected item. The result of this control is the key of user-selected item. |
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>FrameworkJS</title>
<link rel="stylesheet" type="text/css" href="lib/framework.css">
<!-- add your page styles here -->
<!-- <link rel="stylesheet" type="text/css" href="css/"> -->
<link rel="stylesheet" type="text/css" href="css/home.css">
</head>
<body>
<div class="page home">
<div class="button">Select Item<div>
<div class="item">User Selected Item:<span></span></div>
</div>
</body>
<script src="lib/cloadio.min.js"></script>
<script src="lib/jquery-2.2.0.min.js"></script>
<script src="lib/framework-a.min.js"></script>
<script src="lib/framework-b.min.js"></script>
<script src="js/app.js"></script>
<!-- add your module scripts here -->
<!-- <script src="modules/"><script> -->
<script src="modules/controls/js/script.js"></script>
<!-- add your page scripts here -->
<!-- <script src="js/"></script> -->
<script src="js/home.js"></script>
</html>
$('.page.home > .button').click(function () {
var items = {0: "Jhon", 1: "Jack", 2: "Marya"};
app.controls.select('Please select an item.', items,
function (value) {
$('.page.home > .item > span').html(items[value]);
});
});
app.controls.text(placeholder, callback);
The text control has two parameters.
Parameters | Type | Description |
---|---|---|
placeholder | String | Optional. It can be a description text to help user write their text. |
callback | Function | To show the result user-entered text. |
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>FrameworkJS</title>
<link rel="stylesheet" type="text/css" href="lib/framework.css">
<!-- add your page styles here -->
<!-- <link rel="stylesheet" type="text/css" href="css/"> -->
<link rel="stylesheet" type="text/css" href="css/home.css">
</head>
<body>
<div class="page home">
<div class="button">Description<div>
<div class="description"><div>
</div>
</body>
<script src="lib/cloadio.min.js"></script>
<script src="lib/jquery-2.2.0.min.js"></script>
<script src="lib/framework-a.min.js"></script>
<script src="lib/framework-b.min.js"></script>
<script src="js/app.js"></script>
<!-- add your module scripts here -->
<!-- <script src="modules/"><script> -->
<script src="modules/controls/js/script.js"></script>
<!-- add your page scripts here -->
<!-- <script src="js/"></script> -->
<script src="js/home.js"></script>
</html>
$('.page.home > .button').click(function () {
app.controls.text('Please Write your description compeletly.',
function (value) {
$('.page.home > .description').html(value);
});
});
app.controls.number(label, value, attributes);
The number control has three parameters.
Parameters | Type | Description |
---|---|---|
label | String | The text of the tag. |
value | number | The value of the field. |
attributes | Object | Include a series of HTML tags attributes. |
app.controls.map(title, callback);
The map control has two parameters.
Parameters | Type | Description |
---|---|---|
title | String | Optional. The message title shows to users to help them to select a location from the map. |
callback | Function | This is for showing user-selected location. When user selects a latitude and longitude we can custom that. |
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>FrameworkJS</title>
<link rel="stylesheet" type="text/css" href="lib/framework.css">
<link rel="stylesheet" type="text/css" href="lib/map/leaflet.css">
<!-- add your page styles here -->
<!-- <link rel="stylesheet" type="text/css" href="css/"> -->
<link rel="stylesheet" type="text/css" href="css/home.css">
</head>
<body>
<div class="page home">
<div class="button">Select Location<div>
<div class="map"><div>
</div>
</body>
<script src="lib/cloadio.min.js"></script>
<script src="lib/jquery-2.2.0.min.js"></script>
<script src="lib/map/leaflet.js"></script>
<script src="lib/framework-a.min.js"></script>
<script src="lib/framework-b.min.js"></script>
<script src="js/app.js"></script>
<!-- add your module scripts here -->
<!-- <script src="modules/"><script> -->
<script src="modules/controls/js/script.js"></script>
<!-- add your page scripts here -->
<!-- <script src="js/"></script> -->
<script src="js/home.js"></script>
</html>
$('.page.home > .button').click(function () {
var position, map, marker, jMap = $('.page.home > .map');
app.controls.map('Please select a location', function (coordinate) {
if (coordinate) {
position = {
lng: coordinate.lng,
lat: coordinate.lat
};
map = L.map(jMap[0], {zoomControl: false}).setView([position.lat, position.lng], 11);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: '© OpenStreetMap'}).addTo(map);
marker = new L.marker([position.lat, position.lng]);
marker.addTo(map);
map._onResize();
}
});
});
app.controls.datepicker(title, callback, options);
The datepicker control has three parameters.
Parameters | Type | Description |
---|---|---|
title | String | Optional. This is a title to help users select their own date. |
callback | Function | This is for shows user-selected item. When user selects a time we can custom that. |
options | Object | Optional. It contains several items for customizing user interface of the datepicker. |
options: For options There are several parameters:
app.controls.datepicker(title, callback, {
timePicker: {
enabled: false,
showSeconds: false,
showMeridian: false
}
});
app.controls.datepicker(title, callback, {
toolbox: {
enabled: false
}
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>FrameworkJS</title>
<link rel="stylesheet" type="text/css" href="lib/framework.css">
<!-- add your page styles here -->
<!-- <link rel="stylesheet" type="text/css" href="css/"> -->
<link rel="stylesheet" type="text/css" href="css/home.css">
</head>
<body>
<div class="page home">
<div class="button">Select Date<div>
<div class="date"><div>
</div>
</body>
<script src="lib/cloadio.min.js"></script>
<script src="lib/jquery-2.2.0.min.js"></script>
<script src="lib/framework-a.min.js"></script>
<script src="lib/framework-b.min.js"></script>
<script src="js/app.js"></script>
<!-- add your module scripts here -->
<!-- <script src="modules/"><script> -->
<script src="modules/controls/js/script.js"></script>
<!-- add your page scripts here -->
<!-- <script src="js/"></script> -->
<script src="js/home.js"></script>
</html>
$('.page.home > .button').click(function () {
app.controls.datepicker('Please select a date',
function (value) {
$('.page.home > .date').html(new persianDate(value).format('YYYY/MM/DD'));
},
{
timePicker: {
enabled: false,
showSeconds: false,
showMeridian: false
},
toolbox: {
enabled: false
}
}
);
});