Less variable issue in jquery - less

I have a less file which uses multiple less variable and and a less variable used inside another less variable to calculate darkness and brightness. I need to change thse variables value to change the color from color picker at run time.
Code as
#base: #35414E; // #35414E
#hue-control: contrast(#base, lighten(#base, (100 - lightness(#base)) * (#amount / 100)), darken(#base, lightness(#base) * (#amount / 100)), 50%);
We need to update at rum time and show immediately.

example
<!DOCTYPE html>
<html>
<head>
<title>Less</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet/less" type="text/css" href="styles.less" />
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/2.1.0/less.min.js"></script>
</head>
<body>
<button class="color-button">Change background</button>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script>
var colors = ['red','blue','yellow','green','black' ];
$('.color-button').on('click', function () {
less.modifyVars({ 'body-bg' : colors[Math.floor(Math.random() * colors.length )] });
less.refreshStyles();
});
</script>
</body>
</html>
With styles.less:
#body-bg: white;
body {
background-color: #body-bg;
}

Related

Missing html elements in index.html except elm div - Elm 0.19

My index page is displaying only "elm" div in the body and not the google-sign-in div and testing h1 as I have in the following index.html.
When I inspected them using browser tools, I did not see the elements.
When I comment out or remove var app = Elm.Main.init({
node: document.getElementById('elm')
}); the browser displays the google div and h1 elements.
What is the reason and how can I solve it?
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Main</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="google-signin-client_id" content="XXXXX.apps.googleusercontent.com">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="main.js"></script>
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<br>
<br>
<h1>Testing</h1>
<div id="elm"></div>
<script>
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
}
var app = Elm.Main.init({
node: document.getElementById('elm')
});
</script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
My Elm program.
-- MAIN
main : Program () Model Msg
main =
Browser.application
{ init = init
, view = view
, update = update
, subscriptions = subscriptions
, onUrlChange = UrlChanged
, onUrlRequest = LinkClicked
}
I also tried changing style of the elm div <div id="elm" style="width:50%; height:400px;"></div>
elm 0.19
Firefox
If you want access to elements in your body along with elm then I would use Browser.element. Otherwise Browser.document and Browser.application manage the body for you (what you are seeing currently).
More information here:
https://package.elm-lang.org/packages/elm/browser/latest/Browser#element

context is not defined

I am trying to draw a picture into a div to be able to make the drag effect later. It seems that the function that has to draw the image is not working right. Maybe someone has a hint why?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>canvas</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.0.1/utils/Draggable.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.0.1/plugins/CSSPlugin.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.0.1/TweenMax.min.js"></script>
<script src="main.js"></script>
</head>
<body>
<div id="myCanvas" width="600" height="400" style="border:1px solid #000000;">
<div id="imagen" class="mover"></div>
</div>
</body>
</html>
here the js code..
context.getContext("2d");
var movibles = $(".mover");
var myCanvas = document.getElementById("myCanvas");
make_base();
function make_base()
{
base_image = new Image();
base_image.src = 'img/image.jpg';
base_image.onload = function(){
context.drawImage(base_image, 0, 0);
}
}
Draggable.create("movibles" , {
type:"y",
bounds: document.getElementById("myCanvas"),
throwProps:true,
onClick: function() {
console.log("clicked");
},
onDragEnd:function() {
console.log("drag ended");
}
});
Much appreciated..

SummerNote Information / notification area not displayed

I am trying to get notification area in summer note to work but It doens't showup.
In the example below I expect the area to show at the bottom once the button is pressed.
What am I missing ?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Summernote</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.9/summernote.css" rel="stylesheet">
<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.9/summernote.js"></script>
</head>
<body>
<button onclick="test()">hello</button>
<div id="summernote"><p>Hello Summernote</p></div>
<script>
$(document).ready(function() {
$('#summernote').summernote();
$('#summernote').summernote({
maxHeight: 300,
dialogsInBody: true,
dialogsFade: true // Add fade effect on dialogs
});
});
function test(){
$('.note-status-output').html('<div class="alert alert-danger">' +
'This is an error using a Bootstrap alert that has been restyled to fit here.' +
'</div>'
);
}
</script>
</body>
</html>

Polymer 2.0 Styling component distributed children from main doc

I am trying to style some distributed children in Polymer 2.0. I can't seem to get it working following the docs.
https://www.polymer-project.org/2.0/docs/devguide/style-shadow-dom
I could do this in Polymer 1.x using
<style is="custom-style">
paper-tabs ::content .tab-content {
background:red;
}
</style>
Here's my Polymer 2.0 setup trying to change the style of paper-tabs .tab-content
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="import" href="bower_components/paper-tabs/paper-tabs.html">
<link rel="import" href="bower_components/polymer/lib/elements/custom-style.html">
</head>
<body>
<custom-style>
<style>
paper-tabs .tab-content {
background:red;
}
</style>
</custom-style>
<paper-tabs selected="0" scrollable>
<paper-tab>The first tab</paper-tab>
<paper-tab>Tab two</paper-tab>
<paper-tab>The third tab</paper-tab>
<paper-tab>Fourth tab</paper-tab>
</paper-tabs>
</body>
</html>
If you are trying to just change the background color of the tabs, just do:
paper-tabs {
background:red;
}
If you want to style the tab content, there are some paper-tab styling's:
--paper-tab-content -- Mixin applied to the tab content
--paper-tab-content-unselected -- Mixin applied to the tab content when the tab is not selected
Taken from: https://www.webcomponents.org/element/PolymerElements/paper-tabs/elements/paper-tab
It doesn't look like its possible to target .tab-content specifically.
To start with, ::content is replaced with ::slotted but that still doesn't work in this example.
https://developers.google.com/web/fundamentals/getting-started/primers/shadowdom#stylinglightdom
You can use the exposed mixin as RivG also mentioned.
--paper-tab-content

datatimepicker jquery display not correct in localhost

I have setup jquery datetimepicker but it not display correctly in localhost (but online is ok). Picture 1 is datetimepicker localhost, picture 2 is datetimepicker online:
Picture 1
Picture 2
Who have any ideal?
Thank you!
Please check whether you have included the below files:
1. jquery-ui-1.8.custom.css
2. jquery-1.7.1.min.js
3. jquery-ui-1.8.custom.min.js
Sample html code as below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>DistribuTix</title>
<meta http-equiv="expires" content="">
<meta http-equiv="ImageToolbar" content="No">
<link href="css/style.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" media="all" type="text/css" href="css/ui-lightness/jquery-ui-1.8.custom.css" />
<script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.custom.min.js"></script>
<style type="text/css">
#ui-datepicker-div{ font-size: 80%; }
/* css for timepicker */
#ui-timepicker-div dl{ text-align: left; }
#ui-timepicker-div dl dt{ height: 25px; }
#ui-timepicker-div dl dd{ margin: -25px 0 10px 65px; }
</style>
</head>
<body>
<input name="eventDate" id="eventDate" maxlength="20" size="17">
</body>
<script type="text/javascript">
$('#eventDate').datepicker({
dateFormat: 'mm-dd-yy',
showOn: "button",
buttonImage: "../images/calendar.gif",
buttonImageOnly: true
});
</script>
</html>
Also check the included files are in correct path..