Introduction
In this article we are going to have a very interesting section related to designing. In this the pointer has a radius of 60 and appears to spin while you run the application in the browser.
Here we will use some JavaScript and some styles along with HTML code. Just go through the steps to see how to create this application.
Let's see how the Spinningpoints application can be created. To do so go through the following steps.
Step 1 : Open a HTML editor or Visual Studio.
Open File menu ->select new ->Choose Website then.
This is where we will create the HTML5 application.
- Go to Solution Explorer
- Right-click on the Application name
- Select Add-->add new item
- Now in the window that opens, select an HTML page or new Web form
- Rename it to Spinningpoint.aspx
Step 2 : In this section we will create the style for the media and create the .css on the media screen. Put the given script in the Head section of the HTML or between the <head>--</head> tags.
Here two CSS files are used for design purposes; one is for the section div, named d1.css and the other d2.css for the whole body of the web page as added in the Spinningpoints.rar file. Here are the media script.
Script for the Media screen
<style media="screen">
html
{
height: 100%;
}
body
{
color: #222;
font: 20px/1.4 "Lucida Grande" , Lucida, Verdana, Helvetica, sans-serif;
height: 100%;
}
#holder
{
height: 300px;
left: 0;
overflow: hidden;
position: absolute;
top: 0;
width: 300px;
margin: 0;
}
#form
{
height: 300px;
left: 50%;
margin: -150px 0 0 -300px;
overflow: hidden;
position: absolute;
top: 50%;
width: 600px;
}
form
{
color: #fff;
left: 300px;
margin: 0;
padding: 0;
position: absolute;
top: 0;
width: 300px;
}
dt
{
clear: left;
float: left;
height: 2em;
width: 150px;
}
dd
{
float: left;
height: 2em;
margin: 0;
padding: 0;
}
input
{
font-size: 1em;
width: 4em;
}
p
{
font: italic 20px/1.4 "Hoefler Text" , Georgia, serif;
height: 100%;
margin: -3em;
width: 750px;
}
#copy
{
bottom: auto;
color: #fff;
font-size: .5em;
right: 4em;
top: 300px;
}
</style>
Step 3 : In this part we need to work on some JavaScript. For fully understanding how the JavaScript works, download the attached .rar file and run the Spinningpoints application.
The whole JavaScript looks as in the following.
window.onload = function ()
{
var remove = spinner("holder", 70, 120, 12, 25, "#fff");
var form =
{
form: document.getElementsByTagName("form")[0],
r1: document.getElementById("radius1"),
r2: document.getElementById("radius2")
};
form.form.onsubmit = function ()
{
remove();
remove = spinner("holder", +form.r1.value, +form.r2.value);
return false;
};
};
function spinner(holderid, R1, R2, count, stroke_width, colour)
{
var sectorsCount = count || 12,
color = colour || "#fff",
width = stroke_width || 15,
r1 = Math.min(R1, R2) || 35,
r2 = Math.max(R1, R2) || 60,
sectors = [],
opacity = [],
beta = 2 * Math.PI / sectorsCount,
pathParams = { stroke: color, "stroke-width": width, "stroke-linecap": "round" };
}
var tick;
(function ticker()
{
opacity.unshift(opacity.pop());
for (var i = 0; i < sectorsCount; i++)
{
sectors[i].attr("opacity", opacity[i]);
}
tick = setTimeout(ticker, 1000 / sectorsCount);
})();
return function ()
{
clearTimeout(tick);
r.remove();
};
}
Step 4 : In this section we are going to become familiar with the body part of HTML scripting. Replace this script from the body section of the Spinningpoint.aspx page. Here we pass a #holder in the div id that is defined in the d1.css file.
<body>
<center><h2>SPINNING THE POINTS </h2><hr />
<div id="form">
<div id="holder"></div>
<form action="#">
<dl>
<dt><label for="radius1">Radius 1</label></dt>
<dd><input type="text" value="60" id="radius1"></dd>
<dt><label for="radius2">Radius 2</label></dt>
<dd><input type="text" value="100" id="radius2"></dd>
<dd><input type="submit" value="Update"></dd>
</dl>
</form>
</div>
</center>
</body>
Step 5 : The complete code for the Spinningpoints application is:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Spinningpoint.aspx.cs" Inherits="Spinningpoints._Default" %>
<!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 runat="server">
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="d1.css" type="text/css" media="screen">
<link rel="stylesheet" href="d1.css" type="text/css" media="print">
<script src="javascript.js"></script>
<style media="screen">
copy n paste the step 2 script here.
</style>
</head>
<body>
<center><h2>SPINNING THE POINTS </h2><hr />
<div id="form">
<div id="holder"></div>
<form action="#">
<dl>
<dt><label for="radius1">Radius 1</label></dt>
<dd><input type="text" value="60" id="radius1"></dd>
<dt><label for="radius2">Radius 2</label></dt>
<dd><input type="text" value="100" id="radius2"></dd>
<dd><input type="submit" value="Update"></dd>
</dl>
</form>
</div>
</center>
</body>
</html>
Step 6 : Output Press F5
Note : For the accurate output of HTML5 applications, you must have the Google Chrome browser in your PC. You will see the pointer having radius of 60 appears to spin while you run the application in the browser.
You can change the Radius 1 and Radius 2 values. After changing the values the points look like as below.
Here are some useful resources
Share Point Designer Work Flow: Part IV
Cascading Dropdown in Share point using JQuery
Console Application Wait/Busy Spin Animation
Customize share point List Form using XSLT
Working With Growing Pie-chart Using HTML