2.5.4 • Published 1 year ago

viewly v2.5.4

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Viewly

A Javascript framework created by Speakly

Features

Shortcuts

There are some shortcuts you can access with the V property:

  • V(element).on(event, callback)
  • V.undefined(value)
  • V.type(value, type)
  • V.is(value)
  • V.format(content)
  • V.self
  • V.dev()
  • V.on(event, callback)
  • V.data(key, value)
  • V.store(key, value)

If translation plugin is being used and the translation json is provided in the config:

  • V.locale(key)

Base

<script>
	viewly.add('view_name', {
		config: {
			view: {lock: true}, // Should the view start locked
			footer: {active: 'view_name'} // Set the active footer item
		},
		init: function() {
			// This function is only called once when the view is loaded for the first time.
		},
		show: function() {
			// This function is called every time when the view appears
		},

		hide: function() {
			// This function is called every time when the view disappears
		}
	});
</script>

<style>
	/* CSS */
</style>

<div id="{id}" class="{{{data}.display}} view" header="Header text">
	 <!-- HTML -->
</div>

Placeholders

We have a couple of placeholders in viewly that can be used in your views to create a custom id of your current view.

<!-- The view name for this example = welcome -->
{code} = welcome
{view} = welcome
{id} = view_welcome
{data} = view.welcome
{style} = #welcome
{t9n} = t9n.welcome
{form} = form_welcome

Snippets

In your view you can use snippets, for every snippet you have to create a custom .js file in your snippet folder. For example:

View:

<script>
	viewly.add('view_name', {
		config: {
			view: {lock: true}, // Should the view start locked
			footer: {active: 'view_name'} // Set the active footer item
		},
		init: function() {
			<!-- This includes to provided js when the total html has been build -->

			{view_name/custom.js}
		}
	});
</script>

snippet/view_name/custom.js

var test = 1;
console.log(test);

Notice

// Icon = font awesome 5 icon
viewly.ui.success(message, icon)
viewly.ui.info(message, icon)
viewly.ui.warning(message, icon)
viewly.ui.error(message, icon)

You can also use the notice functions directly on a html element

<button success="You successfully submitted this form">Submit</button>

Self

// Get the data of the current view
V.self.data(key);
// Get the config of the current view
V.self.config(key);

Data

// Set the global data by key
viewly.data.set('key', 'value');
// OR
V.data('key', 'value');

// Get the global data by key
viewly.data.get('key');
// OR
V.data('key');

// Get the root of the key
var rootKey = viewly.data.keyRoot('key1.key2.key3');
// rootKey = 'key1'

// Get the path of the key
var keyPath = viewly.data.keyPath('key1.key2.key3');
// keyPath = 'key2.key3'

// Watch all registered keys in the data store
viewly.data.watch(callback);

// Watch a single data key in the data store
viewly.data.watchKey('key', callback)

//Remove watcher from a key
viewly.data.unwatch(id);

Form

// Get the data of a form
var formData = viewly.form.data('formName');

Locale

// Get the translation for the provided code
viewly.locale.get(code)
// OR
V.locale(code)

Route

// Go to the provided view. Route = config you can send with the view
viewly.route.view(code, route);

// Get the hash of the current url
viewly.route.hash();

// Go to previous view
viewly.route.back();

// Check if view exists
viewly.route.exists();

Store

The store in Viewly is being used for writing cookies or writing in the localstorage

// Check if browser supports localstorage
var supported = viewly.store.supported();
// Returns a true/false

// Set a storage item. Checks automaticly if localstorage is available if not it uses Cookies
viewly.store.set(name, value, day)

// Get a storage item. Checks automaticly if localstorage is available if not it uses Cookies
viewly.store.get(name)

// Removes a storage item from either the localstorage or the Cookie
viewly.store.remove(name);

// Dynamic set/get items from the storage
// Set
V.store(name, value);
// Get
V.store(name);

View

// Check if a view exists
var exists = viewly.view.exists(code);
// Returns true/false

// Get the view
viewly.view.get(code);

Form Validation

You can use regular expressions to validate form inputs or you can create your own custom functions to validate inputs

<!-- require gets triggered once something is entered or when you try to submit the form -->
<input name="name" type="text" require="[^0-9]{2,}"/>

<!-- validate only gets triggered when something is entered in the input field -->
<input name="name" type="text" validate="[^0-9]{2,}"/>

<!-- You can use a custom validator when you have the validator javascript created -->

<input name="name" type="text" validate="custom"/>

app/validator.js

app.validator = {
	custom: function(value, callback) {
		if(value == 1)
			callback(true);
		else
			callback(false);
	}
}
2.5.4

1 year ago

2.5.3

3 years ago

2.5.21

3 years ago

2.5.20

3 years ago

2.5.19

3 years ago

2.5.18

3 years ago

2.5.17

4 years ago

2.5.16

4 years ago

2.5.14

4 years ago

2.5.8

4 years ago

2.5.13

4 years ago

2.5.6

4 years ago

2.4.4

4 years ago

2.4.1

4 years ago

2.4.0

4 years ago

2.4.3

4 years ago

2.4.2

4 years ago

2.3.9

4 years ago

2.3.8

4 years ago

2.3.6

4 years ago

2.3.2

4 years ago

2.3.1

4 years ago

2.3.4

4 years ago

2.3.5

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.11

4 years ago

2.1.10

4 years ago

2.0.1

4 years ago

2.1.6

4 years ago

1.7.20

4 years ago

1.7.19

4 years ago

1.7.18

4 years ago

1.7.16

4 years ago

1.7.17

4 years ago

1.7.15

4 years ago

1.7.14

4 years ago

1.7.12

4 years ago

1.7.13

4 years ago

1.7.11

4 years ago

1.7.10

4 years ago

1.7.9

4 years ago

1.7.8

4 years ago

1.7.6

4 years ago

1.7.5

4 years ago

1.7.4

4 years ago

1.7.3

4 years ago

1.7.2

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.6

4 years ago

1.6.5

4 years ago

1.6.4

4 years ago

1.6.3

4 years ago

1.6.2

4 years ago

1.5.9

4 years ago

1.5.10

4 years ago

1.5.8

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.9

4 years ago

1.4.8

4 years ago

1.4.7

4 years ago

1.4.6

4 years ago

1.4.5

4 years ago

1.3.10

4 years ago

1.3.9

4 years ago

1.3.8

4 years ago

1.3.7

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.9

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago