Polymer 2.0 - Trying to implement HTML5 drag and drop - polymer

I am trying to implement HTML5 drag and drop for polymer2.0 components similar to the drag and drop option as in http://jsfiddle.net/U55rc/
HTML:
<base href="https://raw-dot-custom-elements.appspot.com/PolymerElements/iron-flex-layout/v2.0.0/iron-flex-layout/">
<script src="../webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="iron-flex-layout-classes.html">
<dom-module id="demo-element">
<template>
<style include="shared-styles">
:host {
display: block;
padding: 10px;
}
.card {
margin: 24px;
padding: 16px;
color: #757575;
border-radius: 5px;
background-color: #fff;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
}
</style>
<div draggable="true" ondragstart="{{drag(event)}}" >
Input:
<input type="text"/>
</div>
<div class="card" id="div1" ondrop="{{drop(event)}}" ondragover="{{allowDrop(event)}}"></div>
</template>
<script>
Polymer({
is: 'demo-element',
allowDrop:function(ev){
ev.preventDefault();
},
drag: function(ev){
ev.dataTransfer.setData("text",ev.target.id);
},
drop:function(ev){
ev.preventDefault();
var data=ev.dataTransfer.getData("text");
console.log(ev)
ev.target.appendChild(document.getElementById(data));
}
});
</script>
<script>Polymer({is: "demo-element"});</script>
</dom-module>
<demo-element></demo-element>
JSFiddle for reference:
https://jsfiddle.net/Nagasai_Aytha/b62to481/

The key here is to use the on-<event> notation for the native HTML5 drag and drop events. Also, you don't need data binding notation for the events.
Here is your corrected markup.
HTML:
<base href="https://raw-dot-custom-elements.appspot.com/PolymerElements/iron-flex-layout/v2.0.0/iron-flex-layout/">
<script src="../webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="iron-flex-layout-classes.html">
<dom-module id="demo-element">
<template>
<style include="shared-styles">
:host {
display: block;
padding: 10px;
}
.card {
margin: 24px;
padding: 16px;
color: #757575;
border-radius: 5px;
background-color: #fff;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
}
</style>
<div id="draggedDiv" draggable="true" on-dragstart="drag" >
Input:
<input type="text"/>
</div>
<div class="card" id="div1" on-drop="drop" on-dragover="allowDrop"></div>
</template>
<script>
Polymer({
is: 'demo-element',
allowDrop:function(ev){
ev.preventDefault();
},
drag: function(ev){
ev.dataTransfer.setData("text",ev.target.id);
},
drop:function(ev){
ev.preventDefault();
var data=ev.dataTransfer.getData("text");
console.log(ev)
ev.target.appendChild(this.shadowRoot.querySelector('#' + data));
}
});
</script>
<script>Polymer({is: "demo-element"});</script>
</dom-module>
<demo-element></demo-element>

For Polymer 2.0 change this.$$ to this.shadowRoot.querySelector:
drop (ev){
ev.preventDefault();
var data=ev.dataTransfer.getData("text");
ev.target.appendChild(this.shadowRoot.querySelector('#' + data));
}

Related

Why does the box not move freely despite using cdkDrag and cdkDragBoundary?

I am using "Drag and Drop" angular material.
https://material.angular.io/cdk/drag-drop/overview
When I create it with an external component as a child to the cdkDrag section it will only move up and down.
However, if I remove the boundary it will move freely.
Or, if I keep the boundary and have a generic div as a child to the cdkDrag section, then it will move freely within the boundary.
It seems the cdkDragBoundary does not like components inside. Does anyone know if this is just incompatible or am I doing something wrong?
Tabletop-creator-pagestructure
<main>
<div class="example-boundary">
<!--Creation field and actual placable objects-->
<div cdkDrag cdkDragBoundary=".example-boundary">
<!--This component being present along with the cdkDragBoundary causes problem-->
<app-tabletop-creator-placeable ></app-tabletop-creator-placeable>
</div>
</div>
</main>
.example-boundary {
position: absolute;
left: 300px;
top: 200px;
height: 600px;
width: 600px;
background: rgba(128, 128, 128, 0.351);
border: solid 3px rgb(255, 0, 0);
}
import { Component, OnInit} from '#angular/core';
import { navDataCard } from './nav-data-card';
import { CdkDragDrop} from '#angular/cdk/drag-drop';
#Component({
selector: 'app-tabletop-creator-pagestructure',
templateUrl: './tabletop-creator-pagestructure.component.html',
styleUrls: ['./tabletop-creator-pagestructure.component.scss']
})
export class TabletopCreatorPagestructureComponent implements OnInit {
data = navDataCard;
masterPlacableList = [];
topPlaceableList = ["test 1", "test 2", "test 3"];
constructor(){}
ngOnInit(){ }
}
tabletop-creator-placeable
<div class="example-placable" >
</div>
.example-placable {
width: 200px;
height: 200px;
border: solid 1px #ccc;
color: rgba(0, 0, 0, 0.87);
cursor: move;
display: inline-flex;
justify-content: center;
align-items: center;
text-align: center;
background: #fff;
border-radius: 4px;
margin-right: 25px;
position: absolute;
z-index: 1;
padding: 10px;
transition: box-shadow 200ms cubic-bezier(0, 0, 0.2, 1);
box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2),
0 2px 2px 0 rgba(0, 0, 0, 0.14),
0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
.example-box.free-dragging {
box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2),
0 8px 10px 1px rgba(0, 0, 0, 0.14), 0 3px 14px 2px rgba(0, 0, 0, 0.12);
}
import { Component, OnInit} from '#angular/core';
#Component({
selector: 'app-tabletop-creator-placeable',
templateUrl: './tabletop-creator-placeable.component.html',
styleUrls: ['./tabletop-creator-placeable.component.css']
})
export class TabletopCreatorPlaceableComponent implements OnInit {
constructor(){
}
ngOnInit(): void {
}
}
The "cdkDrag" and "cdkDragBoundary" must be on the component selector.
<main>
<div class="example-boundary">
<!--Creation field and actual placable objects-->
<app-tabletop-creator-placeable cdkDrag cdkDragBoundary=".example-boundary">
</app-tabletop-creator-placeable>
</div>
</main>

How to display a short message next to button when it's pressed?

I have the following html code:
<button onclick="copyText()">copy</button>
<script>
function copyText() {
navigator.clipboard.writeText
("Hello world");
}
</script>
How do I change the word "copy" to a checkmark and display a short message like "copied to clipboard" next to the button once it's pressed for 1 second and preferably that after 1 second the green checkmark is replaced by the text "copy" again?
Afaik, you cannot display native prompts using plain JavaScript. You would have to use something like an alert or a dialog or have a div hide and show the message.
What you need to do is structure your button in such a way that it sits next to an element with your message all aligned inline. You need CSS to accomplish this.
Then when you click on the button, the text gets copied (the code you've wrote so far) and then it should call a function which would then show the "copied" message.
You will again have to call another function to remove the message after a few seconds (or you could could leave it?) This can be done using setTimeout function.
See my example for a POC
HTH
function copyText() {
var secretKey = document.querySelector('samp.my-secret-key').innerText;
if (secretKey) {
navigator.clipboard.writeText(secretKey);
showNotification();
}
}
function showNotification() {
var notificationEl = document.querySelector('.copy-control p.notification-message');
notificationEl.classList.add('notify');
setTimeout(function() {
notificationEl.classList.remove('notify');
}, 1000);
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: system-ui, -apple-system, system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.secret {
margin: 2rem auto;
display: flex;
justify-content: center;
}
.secret samp {
padding: .5rem 1rem;
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: .25rem;
box-shadow: rgba(0, 0, 0, 0.02) 0 1px 3px 0;
background: #f0f0f0;
}
.copy-control {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
position: relative;
}
.notification-message {
margin: auto 1rem;
padding: .5rem 1rem;
background: black;
color: white;
border-radius: .25rem;
position: absolute;
right: 25%;
display: none;
}
.notification-message.notify {
display: block;
}
/* https://getcssscan.com/css-buttons-examples */
.copy-button {
align-items: center;
background-color: #FFFFFF;
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: .25rem;
box-shadow: rgba(0, 0, 0, 0.02) 0 1px 3px 0;
box-sizing: border-box;
color: rgba(0, 0, 0, 0.65);
cursor: pointer;
display: inline-flex;
font-size: 16px;
font-weight: 600;
justify-content: center;
line-height: 1.25;
margin: 0;
min-height: 3rem;
padding: calc(.875rem - 1px) calc(1.5rem - 1px);
position: relative;
text-decoration: none;
transition: all 250ms;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
vertical-align: baseline;
width: auto;
}
.copy-button:hover,
.copy-button:focus {
border-color: rgba(0, 0, 0, 0.15);
box-shadow: rgba(0, 0, 0, 0.1) 0 4px 12px;
color: rgba(0, 0, 0, 0.85);
}
.copy-button:hover {
transform: translateY(-1px);
}
.copy-button:active {
background-color: #F0F0F1;
border-color: rgba(0, 0, 0, 0.15);
box-shadow: rgba(0, 0, 0, 0.06) 0 2px 4px;
color: rgba(0, 0, 0, 0.85);
transform: translateY(0);
}
<div class="secret-text">
<div class="secret">
<samp class="my-secret-key">45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2</samp>
</div>
<div class="copy-control">
<button class="copy-button" onclick="copyText()">Copy Text</button>
<p class="notification-message">Copied!</p>
</div>
</div>
Not do it by functional approach...
Do it by id approach, like:-
<body>
<span id="cpnCode">Cupon_Code</span>
<button id="cpnBtn">Copy</button>
<script>
const btn = document.getElementById('cpnBtn');
const code = document.getElementById('cpnCode');
btn.addEventListener('click', () => {
// By clicking, just copy ==> this INNER HTML Content
navigator.clipboard.writeText(code.innerHTML);
btn.innerHTML = 'Copied To Clipboard';
// after clicking 3 second, reset it.
setTimeout(() => {
btn.innerHTML = 'Copy';
}, 3000);
});
</script>
</body>
Hope its will work in your case...

How do I use the new css feature in Polymer?

I am trying to change the css on a paper-header-panel. According to the docs on Polymers website I can simple change the shadow with:
paper-header-panel {
--paper-header-panel-shadow: {
height: 6px;
bottom: -6px;
box-shadow: inset 0px 5px 6px -3px rgba(0, 0, 0, 0.4);
};
}
sadly I can't get it to work... I also tried to change the color on the paper-toolbar, it also does not work.
Here is my code:
<!doctype html>
<html>
<head>
<!-- Polymer -->
<script src='bower_components/webcomponentsjs/webcomponents.js'></script>
<link rel='import' href='bower_components/polymer/polymer.html'>
<link rel='import' href='bower_components/paper-header-panel/paper-header-panel.html'>
<link rel='import' href='bower_components/paper-toolbar/paper-toolbar.html'>
<link rel='import' href='bower_components/paper-icon-button/paper-icon-button.html'>
<meta charset='utf-8'>
<title>Test</title>
<style>
paper-header-panel {
--paper-header-panel-shadow: {
height: 6px;
bottom: -6px;
box-shadow: inset 0px 5px 6px -3px rgba(0, 255, 0, 0.4);
};
}
paper-toolbar {
--paper-toolbar-background: green;
--paper-toolbar-color: white;
}
</style>
</head>
<body class='fullbleed layout vertical'>
<paper-header-panel class='flex'>
<paper-toolbar>
<div>Title</div>
</paper-toolbar>
</paper-header-panel>
</body>
</html>
Where do things go wrong?
I found the reason. I had to set my style as is='custom-style'.
<style is='custom-style'>
paper-header-panel {
--paper-header-panel-shadow: {
height: 6px;
bottom: -6px;
box-shadow: inset 0px 5px 6px -3px rgba(0, 255, 0, 0.4);
};
}
paper-toolbar {
--paper-toolbar-background: green;
--paper-toolbar-color: white;
}
</style>

Extra space is coming in html output

here i am pasting html & css and when UI comes then extra space was coming. just could not understand why it is coming and how to make it look proper.
HTML
<div style="display: block; z-index: 1001; outline: 0px none; height: 400px; width: 400px; top: 77px; left: 428px;" class="ui-dialog ui-widget ui-widget-content ui-corner-all noTitleStuff ui-draggable" tabindex="-1" role="dialog" aria-labelledby="ui-dialog-title-dialog2"><div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"><span class="ui-dialog-title" id="ui-dialog-title-dialog2"> </span><span class="ui-icon ui-icon-closethick">close</span></div><div id="dialog2" class="ui-dialog-content ui-widget-content" style="width: auto; min-height: 0px; height: auto;">
<div id="Container">
<div id="acloginpod">
<div id="caption"> Enter Login Information </div>
<div class="acloginform">
<fieldset>
<span id="ctl00_mstPartBase_rptlogin_ctl00_Label1">Email Address:</span>
<input type="text" name="ctl00$mstPartBase$rptlogin$ctl00$txtEmail" id="ctl00_mstPartBase_rptlogin_ctl00_txtEmail" tabindex="1" class="textinput">
<span id="ctl00_mstPartBase_rptlogin_ctl00_Label2">Password:</span>
<input type="password" name="ctl00$mstPartBase$rptlogin$ctl00$txtPassword" id="ctl00_mstPartBase_rptlogin_ctl00_txtPassword" tabindex="2" class="textinput">
<div class="aclogin-action">
<div class="fl-left">
<div class="item">
<label>
<input type="checkbox" id="ctl00_mstPartBase_rptlogin_ctl00_chkRemember" name="ctl00$mstPartBase$rptlogin$ctl00$chkRemember" tabindex="3">
Remember me
</label>
</div>
<a id="ctl00_mstPartBase_rptlogin_ctl00_LinkButton1" tabindex="5" class="forgotpass" href="javascript:__doPostBack('ctl00$mstPartBase$rptlogin$ctl00$LinkButton1','')">Forgot password?</a>
</div>
<div id="btn" style="float:right;">
<input type="submit" name="ctl00$mstPartBase$rptlogin$ctl00$btnLogin" value="Login" id="ctl00_mstPartBase_rptlogin_ctl00_btnLogin" class="btnlogin" de="" style="margin-left: 83px">
<input type="submit" name="ctl00$mstPartBase$rptlogin$ctl00$btnRegister" value="Register" id="ctl00_mstPartBase_rptlogin_ctl00_btnRegister" class="btnlogin">
</div>
<div class="clearfix">
</div>
<br>
</div>
</fieldset>
</div>
</div>
</div>
</div></div>
CSS
#acloginpod {
background: url("../Images/acloginpodbg.gif") repeat-x scroll 0 0 #ebebeb;
border: 1px solid #d3d3d3;
}
#acloginpod label {
color: #444;
display: block;
font-size: 15px;
margin-bottom: 3px;
}
#caption {
background: url("../Images/button-background-1.jpg") repeat scroll 0 0 rgba(0, 0, 0, 0);
border: 1px solid #1db74b;
border-radius: 3px;
color: White;
font-family: arial;
font-size: 14px;
font-weight: bold;
padding: 10px;
text-align: center;
text-shadow: 0 2px 1px #000;
}
.btnlogin {
background: url("../Images/button-background-1.jpg") repeat scroll 0 0 rgba(0, 0, 0, 0);
border: 1px solid #1db74b;
border-radius: 6px;
box-shadow: 0 0 2px #333;
color: #ffffff;
display: inline-block;
font-family: arial;
font-size: 13px;
font-weight: bold;
height: 33px;
padding: 3px 10px;
text-decoration: none;
text-shadow: 0 2px 1px #000;
}
.btnlogin:hover {
background: url("../Images/button-background-2.jpg") repeat scroll 0 0 rgba(0, 0, 0, 0);
box-shadow: 0 0 3px #046629 inset;
text-shadow: 0 2px 3px #333;
}
.btnlogin:active {
position: relative;
top: 1px;
}
#acloginpod input.textinput {
background: url("../Images/textinputbg.gif") repeat-x scroll 0 0 #ffffff;
border: 1px solid #d3d3d3;
color: #000000;
font-size: 15px;
margin-bottom: 10px;
padding: 7px 0;
text-indent: 7px;
width: 100%;
}
#acloginpod .acloginform {
margin: 22px;
}
#acloginpod form, #acloginpod fieldset {
border-width: 0;
margin: 0 !important;
padding: 0 !important;
}
also here i am pasting screen shot.
extra space is coming between two div called dialog2 & container so just guide me which css i need to modify as a result extra space will not come in left,right,top & bottom side. thanks
here is the js fiddle demo of my code http://jsfiddle.net/tridip/jj2cM/
here is my full code which is working
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="stylesheet" href="Styles/ui-lightness/jquery-ui-1.7.2.custom.css" />
<style type="text/css">
.noTitleStuff .ui-dialog-titlebar {display:none}
.offscreen {position: absolute; left: -999em;}
.BusyStyles
{
background-image: url('../Images/ajax-loader.gif');
background-repeat: no-repeat;
background-position: center center;
height: 350px;
width: 300px;
}
.ui-dialog .ui-dialog-content{
padding:0 !important;
}
</style>
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#opener2").click(function () {
var $this = $(this);
$this.toggleClass('show');
if ($this.hasClass('show')) {
$("<div id='dialog2'/>").dialog(
{
autoOpen: false,
width: 50,
height: 50,
dialogClass: 'noTitleStuff',
draggable: true,
resizable: false,
open: function (event, ui) {
$(this).dialog("widget").addClass('BusyStyles');
$(this).parent().appendTo("form");
}
}).dialog('open').show()
.load('login.aspx', function (responseTxt, statusTxt, xhr) {
if (statusTxt == "success") {
//alert('data found');
// sHtml = responseTxt;
// var element = $(this).find('#Container'); ;
// //$(element).addClass('offscreen').show();
// var width = element.width();
// var height = element.height();
// //alert('h ' + height + ' w ' + width);
// sHtml = $(sHtml).find('#Container').html();
// $sHtml = $(sHtml)
// $sHtml.css({ 'display': 'none' }).appendTo('div#dialog2');
$(this).dialog("widget").removeClass('BusyStyles');
$("#dialog2").dialog("widget").animate({
width: '346px',
height: 'auto'
}, {
duration: 200,
step: function () {
$("#dialog2").dialog('option', 'position', 'center');
}
});
$("#dialog2").css({ height: 'auto', width: 'auto' });
//$("#dialog2").html(sHtml);
}
if (statusTxt == "error") {
alert("Error: " + xhr.status + ": " + xhr.statusText);
}
});
//$("#dialog2").dialog('open').show();
}
else {
$("#dialog2").dialog("close").dialog('destroy').remove();
}
return false;
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<button id="opener2">open the dialog2</button>
</form>
</body>
</html>
I think you have to set padding:0 to this class:
.ui-dialog .ui-dialog-content{
padding:0 !important;
}
fiddle

CSS not displaying inline on first page load

My page renders incorrectly (not how I want) on the first load, then when refreshed is correct. It's has to do with the "display:inline-block" I think. I've done a lot of research but I can't seem to figure this one out. And yes.... I've cleared my cache before loading it, I get the same result.
first load:
after refresh:
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="header">
<div id="ribbon-start"></div>
<div id="ribbon-shade"></div>
<div id="banner">
<div id="titles">
<div id="name">The Person</div>
<div id="profession">Their Profession</div>
</div>
<div class="tip"></div>
<div class="nav-butts">
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
</div>
</div> <!-- header -->
<div style="height:900px; width:1px"></div><!-- SCROLL TEST -->
<div id="footer">
<div id="toTop">^</div>
</div> <!-- footer -->
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jqueryeasing.js"></script>
<script type="text/javascript" src="js/sticky.js"></script>
<script type="text/javascript" src="js/behaviour.js"></script>
</body>
</html>
and the CSS
body{
background-color:#00FFFF;
}
#ribbon-start{
z-index:-2;
position:absolute;
top:10px;
left:0px;
width:49px;
height:100px;
background-color:#181818 ;
}
#ribbon-shade{
z-index:-1;
position:absolute;
top:10px;
left:25px;
width: 0;
height: 0;
border-top: 11px solid transparent;
border-bottom: 10px solid transparent;
border-right:24px solid #909090 ;
}
#banner{
margin:21px 0 0 17px;
width:90%;
height:100px;
background-color:black ;
-webkit-box-shadow: -6px -4px 17px rgba(0, 0, 0, 0.75);
-moz-box-shadow: -6px -4px 17px rgba(0, 0, 0, 0.75);
box-shadow: -6px -4px 17px rgba(0, 0, 0, 0.75);
}
#titles{
display:inline-block;
}
#name{
margin: 0 0 0 80px;
font-size:84px;
font-family: 'RalewayLight', sans-serif;
color: white;
display:inline-block;
}
#profession{
margin: 0 0 0 10px;
font-size:34px;
font-family: 'RalewayLight', sans-serif;
color: white;
display:inline-block;
}
#banner .tip{
display:inline-block;
margin: 0 -49px 0 0;
float:right;
width: 0;
height: 0;
border-top: 50px solid transparent;
border-bottom: 50px solid transparent;
border-left: 50px solid black;
}
.nav{
margin:0 0 0 17px;
width:90%;
height:100px;
}
.nav-butts{
display:inline-block;
padding:8px 8px 8px 8px;
background-color:black;
border-radius:38px;
margin:8px 0 0 0;
float:right;
}
.circle{
margin:5px 8px 0 8px;
display:inline-block;
height:60px;
width:60px;
background-color:white;
border-radius:30px;
}
.sticky {
margin-top:10px;
position: fixed;
left:-8px;
top:-8px;
z-index: 100;
border-top: 0;
}
.sticky .nav-butts{
-webkit-box-shadow: 0px -2px 30px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 0px -2px 30px rgba(0, 0, 0, 0.75);
box-shadow: 0px -2px 30px rgba(0, 0, 0, 0.75);
}
#toTop{
position:fixed;
text-align:center;
left:10%;
bottom:-15px;
height:60px;
width:70px;
font-size:64px;
background-color:black;
font-family: 'RalewayThin', sans-serif;
color: white;
border-radius:20px;
cursor:pointer;
}
#font-face
{
font-family: RalewayBold;
src: url('fonts/Raleway-Bold.otf');
}
#font-face
{
font-family: RalewayLight;
src: url('fonts/Raleway-light.otf');
}
It worked fine for me on the first load. I have worked with php in the past and found that an error appears underneath at the first load but disappears at the second load. Try different browsers. One may just be acting up.
I've included this line
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
This clears the problem but isn't really the answer to this question. This code makes the browser call for the styles instead of using cached ones for every load, I believe.