PHP code example of coderius / yii2-jqcloud2-widget
1. Go to this page and download the library: Download coderius/yii2-jqcloud2-widget library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
coderius / yii2-jqcloud2-widget example snippets
use coderius\jqcloud2;
<?= \coderius\jqcloud2\jQCloud::widget([
'tagOptions' => [
'style' => 'width:100%; height: 350px; border: 1px solid #ccc;',
],
'wordsOptions' => [
['text'=>"Lorem",'weight' => 13, 'link' =>"#"],
['text'=>"Ipsum",'weight' => 10.5, 'html' => ['title' => "My Title", "class" => "custom-class"], 'link' => ['href' => "http://jquery.com/", 'target' => "_blank"]],
[
'text'=>"Dolor",
'weight' => 9.4,
'handlers' => [
'click' => new \yii\web\JsExpression("
function() {
alert('You clicked the word !');
}
"),
]
],
['text'=>"Sit",'weight' => 8],
['text'=>"Amet",'weight' => 6.2],
['text'=>"Consectetur",'weight' => 5],
['text'=>"Adipiscing",'weight' => 5],
['text'=>"Elit",'weight' => 5],
['text'=>"Nam et", 'weight' => 5]
],
]);
use coderius\jqcloud2;
<?= \coderius\jqcloud2\jQCloud::widget([
'tagOptions' => [
'style' => 'width:100%; height: 350px; border: 1px solid #ccc;',
// 'id' => 'myid',
],
'wordsOptions' => [
['text'=>"Lorem",'weight' => 13, 'link' =>"#"],
['text'=>"Ipsum",'weight' => 10.5, 'html' => ['title' => "My Title", "class" => "custom-class"], 'link' => ['href' => "http://jquery.com/", 'target' => "_blank"]],
[
'text'=>"Dolor",
'weight' => 9.4,
'handlers' => [
'click' => new \yii\web\JsExpression("
function() {
alert('You clicked the word !');
}
"),
]
],
['text'=>"Sit",'weight' => 8],
['text'=>"Amet",'weight' => 6.2],
['text'=>"Consectetur",'weight' => 5],
['text'=>"Adipiscing",'weight' => 5],
['text'=>"Elit",'weight' => 5],
['text'=>"Nam et", 'weight' => 5]
],
'cloudOptions' => [
'delay' => 50,
'autoResize' => true,
// 'colors' => ["#800026", "#bd0026", "#e31a1c", "#fc4e2a", "#fd8d3c", "#feb24c", "#fed976", "#ffeda0", "#ffffcc"],
'fontSize' => [
'from' => 0.1,
'to' => 0.02
]
],
'methods' => function($containerId, $words){
return new \yii\web\JsExpression("
var arr = arr || $words;
$('#update-demo').on('click', function(e) {
e.preventDefault();
arr.splice(0, 1);
$('#{$containerId}').jQCloud('update', arr);
});
// $('#{$containerId}').jQCloud('destroy');
");
}
]);
php composer.phar