Range Slider for text values - rangeslider

I need a range slider just like below site has the options cut, Clarity and color has slider
http://www.lumeradiamonds.com/diamonds/search?shapes=B,PR,O,M,P,C,E,AS,R,H&
how to add range slider for color or text values like good better best
If anybody tell me how can i implement same slider in my site than its very helpful to me
Thanks

Try this out:
function updateTextInput() {
var value1 = Number(document.getElementById("range").value);
var value2 = "";
if ( value1 === 0 ) {
value2 = "Blue Diamonds";
// Insert more code here for what you intend to do
}
else if ( value1 === 1 ) {
value2 = "Blue Diamonds";
// Insert more code here for what you intend to do
}
else if ( value1 === 2 ) {
value2 = "Red Diamonds";
// Insert more code here for what you intend to do
}
else if ( value1 === 3 ) {
value2 = "Black Diamonds";
// Insert more code here for what you intend to do
}
else if ( value1 === 4 ) {
value2 = "Green Diamonds";
// Insert more code here for what you intend to do
}
document.getElementById('value2').innerHTML = value2;
}
<form>
<input id="range" type="range" name="rangeInput" min="0" step="1" max="4" value="2" class="white" onchange="updateTextInput(this.value);" onchange="updateTextInput(this.value);" oninput="amount.value=rangeInput.value">
<input oninput="rangeInput.value=amount.value" id="box" type="text" value="0" name="amount" for="rangeInput" onkeyup="updateTextInput(this.value);" oninput="amount.value=rangeInput.value" />
</form>
<p id="value2">Red Diamonds</p>

Related

Update cell update without scroll to top

I have an issue where on updating a cell with cellEdited, The page jumps back to the top of the page when the mutator or formatter is called.
I've tried setting table.redraw(false) and then the formatter/mutator doesn't seem to do anything.
When a user updates the proficiency level the formatter or mutator should add a button if it's above 3. It works perfectly. However it jumps to the top of the screen.
Any help appreciated.
var evidenceMutator = function(value, data, type, params, component){
skillsTable.redraw(false);
var claimedProficiency = data.Proficiency;
var skillClaimed = data.SkillID;
var Evidence = data.Evidence;
var memberID = $("#user").data("memberid");
if (claimedProficiency >= 3 ) {
// has provided evidence
if (Evidence == 1) {
return '<a class="btn btn-outline-success btn-xs btn-slim evidence" href="#" id="'+ skillClaimed + '" onclick="openEvidenceModal(this, this.id, '+ memberID +')"> <i class="fas fa-check-circle cssover"></i> Edit Evidence </a>';
} else { // needs to provide
return '<a class="btn btn-outline-danger btn-xs btn-slim evidence" href="#" id="'+ skillClaimed + '" onclick="openEvidenceModal(this, this.id, '+ memberID +')"> <i class="fas fa-times-circle cssover"></i> Add Evidence </a>';
}
} else {
// cell.getElement().style.color = "#CCD1D1";
//cell.getElement().style.fontStyle ="italic";
// cell.getElement().style.fontSize = "0.75em";
return ' No Evidence Needed';
}
}
function complianceTick(cell) {
var isCompliant = cell.getData().Compliance;
var Evidence = cell.getData().Evidence;
var claimedProficiency = cell.getData().Proficiency;
// style all with sucesss and only change if we need to
cell.getElement().style.color = "#33CC66";
cell.getElement().style.fontSize = "0.85em";
cell.getElement().style.fontStyle = "italic";
if (claimedProficiency >= 3 ) {
if (Evidence == '1') {
return '<i class="fas fa-check-circle"></i>';
} else {
cell.getElement().style.color = "#FF0000";
cell.getElement().style.fontSize = "0.85em";
cell.getElement().style.fontWeight = "bold";
return '<i class="fas fa-times-circle"></i>';
}
} else {
return '';
}
}
var skillsTable = new Tabulator("#SkillsTable", {
index: "SkillID",
height:"100%",
headerVisible:false,
autoResize:true,
layout:"fitColumns", //fit columns to width of table
groupBy:"SkillCatID",
groupHeader: groupMaker,
initialSort:[ //set the initial sort order of the data
{column:"RowOrder", dir:"asc"}
],
columns:[ //define the table columns
{title:"", field:"SkillID", visible:false},
{title:"Skill", field:"SkillName", visible:true, headerSort:false, formatter: skillName},
{title:"", field:"SkillCatID", visible:false},
{title:"", field:"SkillCatName", visible:false},
{title:"My Level", field:"Proficiency", visible:true, editor:inputEditor, formatter:prof, width:"7%", headerSort:false, align:"center",
cellEdited:function(cell, row, success){ // EDITING FUNCTION
var $value = cell.getValue();
var $field = cell.getField();
var $row = cell.getRow();
var $id = $row.getData().SkillID;
var integer = parseInt($value, 10);
if ($value != "" && integer < 5 && integer >= 0) {
// update record
updateRecord($id, $field, $value, $row);
//$row.update({"Proficiency" : $value});
//$row.update({"Evidencer" : $value});
skillsTable.updateRow($id, {id:$id,"Proficiency":$value});
skillsTable.updateRow($id, {id:$id,"Evidencer":$value});
} else {
cell.restoreOldValue();
if ($value != "") {
alert ("Values should be between 0 and 4, the cell has been restored to its previous value.")
}
}
},
},
{title:"Target", field:"MinLevel", visible:false, headerSort:false},
{title:"", field:"Proficiency", visible:true, formatter: skillDec, headerSort:false},
{title:"Evidence", field:"Evidencer", visible:true, hozAlign:"center", formatter: evidenceCell, mutator: evidenceMutator, width:"10.5%", headerSort:false},
{title:"", field:"RowOrder", visible:false, sorter:"number"},
{title:"disc", field:"DisciplineID", visible:false, headerFilter:true}
],
});
UPDATE
I think I've narrowed down the issue to the formatter:
```
function evidenceCell(cell, formatterParms, onRendered) {
var claimedProficiency = cell.getData().Proficiency;
var skillClaimed = cell.getData().SkillID;
var Evidence = cell.getData().Evidence;
var memberID = $("#user").data("memberid");
if (claimedProficiency >= 3 ) {
// has provided evidence
if (Evidence == 1) {
return '<a class="btn btn-outline-success btn-xs btn-slim evidence" href="#" id="'+ skillClaimed + '" onclick="openEvidenceModal(this, this.id, '+ memberID +')"> <i class="fas fa-check-circle cssover"></i> Edit Evidence </a>';
} else { // needs to provide
return '<a class="btn btn-outline-danger btn-xs btn-slim evidence" href="#" id="'+ skillClaimed + '" onclick="openEvidenceModal(this, this.id, '+ memberID +')"> <i class="fas fa-times-circle cssover"></i> Add Evidence </a>';
}
} else {
cell.getElement().style.color = "#CCD1D1";
cell.getElement().style.fontStyle ="italic";
cell.getElement().style.fontSize = "0.75em";
return 'No Evidence Needed';
}
}
```
It looks like the issue is with the cell.getData(). It seems to trigger the scroll to the top of page. I think it may be a bug with the newer version. Testing 4.2 and it seems to not be an issue. However, I have issues with modals going to the top of the page with the older version.
The issue seems to be with the virtual DOM. In my case I can luckily turn it off by using the following:
virtualDom:false,
I'm not sure this would be a good fix for people with hundreds of rows.

Typo3 get link parent page on child page in html template

Hello I have a sub navigation
lib.subnavigation = COA
lib.subnavigation {
10 = HMENU
10 {
entryLevel = 2
1 = TMENU
1 {
expAll = 1
NO {
doNotLinkIt = 1
#wrapItemAndSub = <li>|</li>
stdWrap.cObject = CASE
stdWrap.cObject {
key.field = doktype
default = TEXT
default {
typolink.parameter.field = uid
typolink.additionalParams.insertData = 1
field = title
#wrap = <span>|</span>
stdWrap.htmlSpecialChars = 1
}
# 4 = shortcut
4 = TEXT
#4.wrap = <span>|</span>
4 {
field = title
typolink.parameter.field = shortcut
typolink.ATagBeforeWrap = 1
}
# 3 = external url
3 = TEXT
3 {
field = title
typolink.parameter.field = url
typolink.extTarget.field = target
}
}
}
ACT = 1
ACT {
doNotLinkIt = 1
#wrapItemAndSub = <li class="home-lnk active">|</li>
stdWrap.cObject = COA
stdWrap.cObject {
1 = TEXT
1.wrap = <a href="
1.typolink.parameter.data = field:uid
1.typolink.returnLast = url
2 = TEXT
2.wrap = " class="active">
3 = TEXT
3.data = field:title
4 = TEXT
4.wrap = </a>
}
}
}
}
I need to get a link to the parent page in the HTML template, how can I do this? Through what variable can I get a link to the parent page?
My html template:
<f:layout name="DefaultLayout" />
<f:section name="content">
<f:format.raw>{content_100}</f:format.raw>
<div class="page-title-wrap">
<div class="container">
<div class="page-title">Regionalstelle <f:format.raw>{pagetitle_sub}</f:format.raw></div>
</div>
</div>
<div class="mnu-third-wrap">
<div class="container">
<div class="mnu-third">
<f:format.raw>{subnavigation}</f:format.raw>
</div>
</div>
</div>
<f:format.raw>{content_0}</f:format.raw>
</f:section>
The variable subnavigation contains all the links to the sub-menu.
I need to make a page-title link to the parent page, thanks for the help in advance.
depending on the context you have always a data record. for contentlements it's the tt_content record, and for the page it is pages.
The parent of the current page can be identified by the field pid (Page-/Parent-ID).
so you can build a link to the parent page like:
<f:link.page pageUid="{data.pid}">parent page</f:link.page>
What if you'd replace typolink.parameter.field = uid with typolink.parameter.field = pid in the TS

Auto fields liferay in custom portlet

I have a doubt.
I have a main.jsp that includes another 2 jsp and a submit button. Both of them are part of a form.
The second one includes an auto field with a validator:
<div id="groupwork-fields" >
<div class="lfr-form-row lfr-form-row-inline">
<div class="row-fields">
<aui:input fieldParam='name' id="repetibleName" cssClass="full-size"
name="<%=AwardConstants.FIELD_OTHERS_NAME%>"
label='<%=AwardConstants.LABEL_NAME %>'
value="">
<aui:validator name="custom" errorMessage="fill-name">
function (val, fieldNode, ruleValue) {
var result = true;
var selector = document.getElementById("<portlet:namespace/>select-group").value;
if (selector == 1 && val === "") {
result = false;
}
return result;
}
</aui:validator>
</aui:input>
<aui:input cssClass="full-size"
id="email0" fieldParam='email0'
name="email0"
label='<%=AwardConstants.LABEL_EMAIL %>'
value="">
<aui:validator name="maxLength">100</aui:validator>
<aui:validator name="email"></aui:validator>
<aui:validator name="custom" errorMessage="fill-email">
function (val, fieldNode, ruleValue) {
var result = true;
var name = document.getElementById("<portlet:namespace/>name0").value;
if (name !== "" && val === "") {
result = false;
}
return result;
}
</aui:validator>
</aui:input>
</div>
</div>
</div>
After validating those fields and pressing the submit button goes to the next method:
public void saveAutofieldData(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException, SystemException {
String groupworkIndexes = actionRequest.getParameter("groupworkIndexes");
_log.info("::::::::::::::::groupworkIndexes:::::::::::::::::::::::" + groupworkIndexes);
/**
* Split the row index by comma
*/
String[] indexOfRows = groupworkIndexes.split(",");
_log.info("::::::::::::::::indexOfRows.length:::::::::::::::::::::::"+ indexOfRows.length);
for (int i = 0; i < indexOfRows.length; i++) {
String name = (actionRequest.getParameter("name"+ indexOfRows[i])).trim();
String email = (actionRequest.getParameter("email"+ indexOfRows[i])).trim();
_log.info("::::::::::::Name::::::::::::::" + name);
_log.info("::::::::::::Email::::::::::::::" + email);
}
}
The problem is when It tries to read: actionRequest.getParameter("groupworkIndexes"); I get null.
Thank you in advance
I finally got the solution.
All examples I've seen it have been with "actionRequest" to retrieve the data:
String groupworkIndexes = actionRequest.getParameter("groupworkIndexes");
String name = actionRequest.getParameter("name" + indexOfRows[i]));
But in my case i've used the following lines:
String name = (uploadPortletRequest.getParameter("name" + indexOfRows[i]));
String groupworkIndexes = (uploadPortletRequest.getParameter("groupworkIndexes"));
Not always we would get the prefered values with actionRequest

Semantic UI Numeric Up Down control

Is there any Semantic UI Numeric Up Down control with minimum, maximum and step count options ?
We can use type as 'number' to get the required increment/decrement control.
<Input type="number" />
Not found such control so I made this code:
HTML
<div class="ui right labeled input">
<input type="text" id="txtNum" value="5">
<div class="ui mini vertical buttons">
<button class="ui icon button" command="Up"> <i class="up chevron icon"></i>
</button>
<button class="ui icon button" command="Down"> <i class="down chevron icon"></i>
</button>
</div>
</div>
JS
// Constants
var KEY_UP = 38,
KEY_DOWN = 40;
// Variables
var min = 0,
max = 30,
step = 1;
$('.ui.icon.button').click(function () {
var command = $(this).attr('command');
HandleUpDown(command);
});
$('#txtNum').keypress(function (e) {
var code = e.keyCode;
if (code != KEY_UP && code != KEY_DOWN) return;
var command = code == KEY_UP ? 'Up' : code == KEY_DOWN ? 'Down' : '';
HandleUpDown(command);
});
function HandleUpDown(command) {
var val = $('#txtNum').val().trim();
var num = val !== '' ? parseInt(val) : 0;
switch (command) {
case 'Up':
if (num < max) num += step;
break;
case 'Down':
if (num > min) num -= step;
break;
}
$('#txtNum').val(num);
}
Here is the DEMO.

How can i highlights some text with greasemonkey?

I want select some text highlights with Greasemonkey.When I see that four radio button, Greasemonkey i need highlights my option.
Example: I want auto select label RealMadrid.
<div class="row">
<input type="radio" tabindex="3" value="answer1" name="ctl00$ContentPlaceHolder1$1" id="ContentPlaceHolder1_answer1"><label for="ContentPlaceHolder1_answer1">Bayern</label></div>
<div class="row">
<input type="radio" tabindex="4" value="answer2" name="ctl00$ContentPlaceHolder1$1" id="ContentPlaceHolder1_answer2"><label for="ContentPlaceHolder1_answer2">Barcelona</label></div>
<div class="row">
<input type="radio" tabindex="5" value="answer3" name="ctl00$ContentPlaceHolder1$1" id="ContentPlaceHolder1_answer3"><label for="ContentPlaceHolder1_answer3">RealMadrid</label></div>
<div class="row">
<input type="radio" tabindex="6" value="answer4" name="ctl00$ContentPlaceHolder1$1" id="ContentPlaceHolder1_answer4"><label for="ContentPlaceHolder1_answer4">Lyon</label></div>
</div>
Greasemonkey code: (it's checked radio , but instead i need highlight text)
is it possible ?
var labels = document.getElementsByTagName('label'); //get the labels
for (var i = 0; i < labels.length; ++i) { //loop through the labels
if (labels[i].textContent == "RealMadrid") { //check label text
labels[i].click(); //if correct text, click the label
}
}
Javascript:
var radioButtons = document.querySelectorAll('input[type=radio]');
for(var i = 0; i < radioButtons.length; i++) {
radioButtons[i].addEventListener('change', changeHandler, false);
}
function changeHandler(event) {
var b = event.target;
if(b.checked) {
document.querySelector('label[for=' + b.id + ']').style.background = 'yellow';
var notB = document.querySelectorAll('label:not([for=' + b.id + '])');
for(var j = 0; j < notB.length; j++) {
notB[j].style.background = '';
}
}
}
jQuery:
$(':radio').change(function() {
if($(this).is(':checked')) {
$(this).next().css('background', 'yellow');
$(':radio').not(this).next().css('background', '');
}
});
Demo

Resources