Autofill with LinkedIn form - wordpress

I have applied the Linked Autofill function but I have 2 questions about it:
Here is the page link : The page is hosted on HubSpot CMS - https://inboundmarketing.inboundmantra.com/inbound-marketing-company-contact-inbound-mantra
Here is code of the linkedIn autofill button for the above page:
<button id="autofill-button">
<span class="logo">IN</span>
<div class="button-text-container">
<span class="button-text">
AutoFill with <strong>LinkedIn</strong>
</span>
</div>
</button>
<style>
#autofill-button {
height: 33px;
width: 174px;
cursor: pointer;
color: #FFF;
padding: 0;
border: 1px #2D6FA8 solid;
border-radius: 3px;
font-size: 12px;
position: relative;
overflow: hidden;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: #79adcb;
background: -webkit-linear-gradient(top, #79adcb 15%, #2373ac 100%);
background: linear-gradient(to bottom, #79adcb 15%, #2373ac 100%);
-ms-user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
font-family: Arial;
font-size: 12px;
display: inline-block;
}
#autofill-button:hover {
background: #5a8193;
background: -webkit-linear-gradient(top, #5a8193 15%, #1e4d72 100%);
background: linear-gradient(to bottom, #5a8193 15%, #1e4d72 100%);
}
#autofill-button:active {
background: #1e4d72;
background: -webkit-linear-gradient(top, #1e4d72 15%, #5a8193 100%);
background: linear-gradient(to bottom, #1e4d72 15%, #5a8193 100%);
}
#autofill-button .logo {
position: absolute;
top: 0;
bottom: 0;
right: 0;
width: 34px;
color: transparent;
background: url(https://www.linkedin.com/scds/common/u/img/sprite/sprite_connect_v13.png) no-repeat scroll 0 -347px transparent;
}
#autofill-button .button-text-container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: table;
width: 171px;
height: 33px;
}
#autofill-button .button-text {
display: table-cell;
vertical-align: middle;
}
span.IN-widget {
height: 0 !important;
visibility: hidden;
opacity: 0;
}
</style>
<script>
$('#autofill-button').click(function(){
$('span.IN-widget *').click();
});
</script>
<script type="in/Login"></script>
<script type="text/javascript" src="//platform.linkedin.com/in.js">// <![CDATA[
api_key: 81ndwffuhqmres
authorize: false
lang: en_US
</script>
<script>
setTimeout(function(){
var callbackScope, extraData;
function callback(args) {
var fields = ['first-name', 'last-name', 'email-address', 'id', 'headline', 'pictureUrl', 'positions', 'num-connections'];
IN.API.Profile("me").fields(fields).result(function(profiles) {
member = profiles.values[0];
console.log(member);
$('[id*="firstname"]').val(member.firstName);
$('[id*="lastname"]').val(member.lastName);
$('[id*="email"]').val(member.emailAddress);
$('#headline').val(member.headline);
$('#picture').attr("src", member.pictureUrl);
var i = 0;
for (position of member.positions.values) {
$('#position' + (i++)).val(position.company.name + " - " + position.title);
}
}).error(function(data) {
console.log(data);
});
}
IN.Event.on(IN, 'auth', callback, callbackScope, extraData);
},500);
</script>
There are entire fields autofilled but the phone number field is not working.
This code is not working when I'm running this code in WordPress.
Here is the page link : https://www.inboundmantra.com/predictive-lead-scoring
Please let me know how to fix it.
Thanks in advance...

have you whitelisted your domain? you need to contact a linkedin representative to whitelist your domain in order to use this feature.

Related

Input range slider progress for Chrome browser

I am working on an input type range slider. I found out that the Chrome version of input[type=range]::-moz-range-thumb is input[type=range]::-webkit-slider-thumb .
Now, I want the same for input[type=range]::-moz-range-progress.
I have tried input[type=range]::-webkit-slider-progress , input[type=range]::-webkit-slider-runnable-progress .
Still not working so far. Any alternative?
It is totally possible with CSS only.
This dude has done it: https://codepen.io/ShadowShahriar/pen/zYPPYrQ
HTML:
<main>
<input type="range" class="win10-thumb" />
<input type="range" class="win10-thumb" min="0" max="100" value="25" step="5" />
<input type="range" class="win10-thumb" disabled value="64" />
<input type="range" />
<input type="range" min="0" max="100" value="40" step="5" />
<input type="range" disabled value="80" />
</main>
CSS:
html,
body {
height: 100%;
}
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
display: grid;
place-items: center;
}
main {
display: flex;
flex-direction: column;
gap: 2.2em;
padding: 1em 0;
}
html::before {
content: "";
position: fixed;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
background: radial-gradient(circle at center, #fff, #fafafa);
display: block;
}
/* === range theme and appearance === */
input[type="range"] {
font-size: 1.5rem;
width: 12.5em;
}
input[type="range"] {
color: #ef233c;
--thumb-height: 1.125em;
--track-height: 0.125em;
--track-color: rgba(0, 0, 0, 0.2);
--brightness-hover: 180%;
--brightness-down: 80%;
--clip-edges: 0.125em;
}
input[type="range"].win10-thumb {
color: #2b2d42;
--thumb-height: 1.375em;
--thumb-width: 0.5em;
--clip-edges: 0.0125em;
}
#media (prefers-color-scheme: dark) {
html {
background-color: #000;
}
html::before {
background: radial-gradient(circle at center, #101112, #000);
}
input[type="range"] {
color: #f07167;
--track-color: rgba(255, 255, 255, 0.1);
}
input[type="range"].win10-thumb {
color: #3a86ff;
}
}
/* === range commons === */
input[type="range"] {
position: relative;
background: #fff0;
overflow: hidden;
}
input[type="range"]:active {
cursor: grabbing;
}
input[type="range"]:disabled {
filter: grayscale(1);
opacity: 0.3;
cursor: not-allowed;
}
/* === WebKit specific styles === */
input[type="range"],
input[type="range"]::-webkit-slider-runnable-track,
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
transition: all ease 100ms;
height: var(--thumb-height);
}
input[type="range"]::-webkit-slider-runnable-track,
input[type="range"]::-webkit-slider-thumb {
position: relative;
}
input[type="range"]::-webkit-slider-thumb {
--thumb-radius: calc((var(--thumb-height) * 0.5) - 1px);
--clip-top: calc((var(--thumb-height) - var(--track-height)) * 0.5 - 0.5px);
--clip-bottom: calc(var(--thumb-height) - var(--clip-top));
--clip-further: calc(100% + 1px);
--box-fill: calc(-100vmax - var(--thumb-width, var(--thumb-height))) 0 0
100vmax currentColor;
width: var(--thumb-width, var(--thumb-height));
background: linear-gradient(currentColor 0 0) scroll no-repeat left center /
50% calc(var(--track-height) + 1px);
background-color: currentColor;
box-shadow: var(--box-fill);
border-radius: var(--thumb-width, var(--thumb-height));
filter: brightness(100%);
clip-path: polygon(
100% -1px,
var(--clip-edges) -1px,
0 var(--clip-top),
-100vmax var(--clip-top),
-100vmax var(--clip-bottom),
0 var(--clip-bottom),
var(--clip-edges) 100%,
var(--clip-further) var(--clip-further)
);
}
input[type="range"]:hover::-webkit-slider-thumb {
filter: brightness(var(--brightness-hover));
cursor: grab;
}
input[type="range"]:active::-webkit-slider-thumb {
filter: brightness(var(--brightness-down));
cursor: grabbing;
}
input[type="range"]::-webkit-slider-runnable-track {
background: linear-gradient(var(--track-color) 0 0) scroll no-repeat center /
100% calc(var(--track-height) + 1px);
}
input[type="range"]:disabled::-webkit-slider-thumb {
cursor: not-allowed;
}
/* === Firefox specific styles === */
input[type="range"],
input[type="range"]::-moz-range-track,
input[type="range"]::-moz-range-thumb {
appearance: none;
transition: all ease 100ms;
height: var(--thumb-height);
}
input[type="range"]::-moz-range-track,
input[type="range"]::-moz-range-thumb,
input[type="range"]::-moz-range-progress {
background: #fff0;
}
input[type="range"]::-moz-range-thumb {
background: currentColor;
border: 0;
width: var(--thumb-width, var(--thumb-height));
border-radius: var(--thumb-width, var(--thumb-height));
cursor: grab;
}
input[type="range"]:active::-moz-range-thumb {
cursor: grabbing;
}
input[type="range"]::-moz-range-track {
width: 100%;
background: var(--track-color);
}
input[type="range"]::-moz-range-progress {
appearance: none;
background: currentColor;
transition-delay: 30ms;
}
input[type="range"]::-moz-range-track,
input[type="range"]::-moz-range-progress {
height: calc(var(--track-height) + 1px);
border-radius: var(--track-height);
}
input[type="range"]::-moz-range-thumb,
input[type="range"]::-moz-range-progress {
filter: brightness(100%);
}
input[type="range"]:hover::-moz-range-thumb,
input[type="range"]:hover::-moz-range-progress {
filter: brightness(var(--brightness-hover));
}
input[type="range"]:active::-moz-range-thumb,
input[type="range"]:active::-moz-range-progress {
filter: brightness(var(--brightness-down));
}
input[type="range"]:disabled::-moz-range-thumb {
cursor: not-allowed;
}
On Internet Explorer you can use ::-ms-fill-lower to do this thing and firefox supports ::-moz-range-progress, but on chrome this is not possible only using css.
However, there is a good example below using JS.
It changes the background of the range element using linear-gradient.
https://codepen.io/duplich/pen/qjYQEZ

Opacity on body not affecting background color on body

I am trying to set an opacity on the body. However, I have run into an issue.
When setting the opacity on the body, only its content will be affected. The background is not affected by the opacity.
$("button").click(function() {
$("body").toggleClass("opacity");
});
* {
box-sizing: border-box;
}
body {
background: linear-gradient(to right, #1BBCB1, #37B9E9);
font-family: 'Arial';
margin: 0;
text-align: center;
opacity: 1;
}
body.opacity {
opacity: .3;
}
button {
background-color: transparent;
border: 2px solid #000;
border-radius: 3px;
margin-top: 15px;
padding: 10px;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>The background gradient disapears when I set the opacity smaller then 1</p>
<button>Toggle opacity</button>
When doing the same on a div it works fine.
$("button").click(function() {
$("div").toggleClass("opacity");
});
* {
box-sizing: border-box;
}
body {
font-family: 'Arial';
margin: 0;
text-align: center;
}
div {
background: linear-gradient(to right, #1BBCB1, #37B9E9);
opacity: 1;
}
div.opacity {
opacity: .3;
}
button {
background-color: transparent;
border: 2px solid #000;
border-radius: 3px;
margin-top: 15px;
padding: 10px;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<p>The background gradient disapears when I set the opacity smaller than 1</p>
<button>Toggle opacity</button>
</div>
But I can't do this with a div. I have to set it on the body. How can I make the opacity affect the body's background?
P.S. Happy new year!
This is because the background of body is propagated to the html element (since this one doesn't have a background set) thus the html is also having the same background of the body. In your case, the opacity works fine with background also but you simply see the one of the html element.
Add a background to html to see the difference:
$("button").click(function() {
$("body").toggleClass("opacity");
});
* {
box-sizing: border-box;
}
html {
background:red;
}
body {
background: linear-gradient(to right, #1BBCB1, #37B9E9);
font-family: 'Arial';
margin: 0;
text-align: center;
opacity: 1;
}
body.opacity {
opacity: .3;
}
button {
background-color: transparent;
border: 2px solid #000;
border-radius: 3px;
margin-top: 15px;
padding: 10px;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>The background gradient disapears when I set the opacity smaller then 1</p>
<button>Toggle opacity</button>
Some usefull links to understand this behavior:
https://www.w3.org/TR/css-backgrounds-3/#special-backgrounds
https://css-tricks.com/just-one-of-those-weird-things-about-css-background-on-body/
https://stackoverflow.com/a/47998865/8620333
What's the meaning of "propagated to the viewport" in the CSS spec?
Use rgba() for your linear gradient colors. That way you can set the transparency of the colors. By default have the alpha transparency value set to 1 (a.k.a. 100% opacity = no transparency). Then change the value to something less than 1 so the background becomes semi-transparent.
Note: This solution will only affect the background and not child elements. Of which, may or may not be the intended result.
$("button").click(function() {
$("body").toggleClass("opacity");
});
* {
box-sizing: border-box;
}
body {
background: linear-gradient(to right, rgba(27, 188, 177, 1), rgba(55, 185, 233, 1));
font-family: 'Arial';
margin: 0;
text-align: center;
opacity: 1;
}
body.opacity {
background: linear-gradient(to right, rgba(27, 188, 177, 0.3), rgba(55, 185, 233, 0.3));
}
button {
background-color: transparent;
border: 2px solid #000;
border-radius: 3px;
margin-top: 15px;
padding: 10px;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>The background gradient disapears when I set the opacity smaller than 1</p>
<button>Toggle opacity</button>
As far as I know, the opacity property of the body does not exist. So you can obtain the desired effect with something like this:
https://codepen.io/calexandru/pen/YYQLmW
$( function () {
$("#target").on("click", function() {
$('body').addClass('opacity-container');
});
} );
.opacity-container::after {
/*CSS*/
content: "";
background: url(https://firebasestorage.googleapis.com/v0/b/betaproject-8a669.appspot.com/o/Quote-Generator%2F1.jpg?alt=media&token=4de18117-665f-4166-9111-4401af0cd555);
opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>Click the button for background with opacity</p>
<button id="target">Click me</button>

How to fill HTML5 input[type=range] on the left side of the thumb with CSS only?

Is there a possibility to get the same effect as ::-ms-fill-lower on Firefox? Without using JS?
I've already found a workaround in order to achieve that effect on webkit based browsers (e.g. Google Chrome) which uses the pseudo elements :before and :after. But it won't work on the Firefox elements. It seems like ::-moz-range-thumb::before and ::-moz-range-thumb::after aren't legal operations on Firefox, while Google Chrome supports ::-webkit-slider-thumb::before and ::-webkit-slider-thumb::after
Here's a fiddle of the basic outline for the Firefox version:
input[type="range"].slider-track {
border: none;
margin: 10px 0;
width: 100%;
height: 30px;
padding: 0;
overflow-x: hidden;
overflow-y: visible;
background: transparent;
}
input[type="range"].slider-track::-moz-range-thumb {
box-shadow: none;
border: 2px solid grey;
height: 16px;
width: 16px;
border-radius: 16px;
background: white;
}
input[type="range"].slider-track::-moz-range-track {
width: 100%;
height: 2px;
box-shadow: none;
background: blue;
border-radius: 0px;
border: 0px;
}
<div style="max-width: 380px;">
<input type="range" class="slider-track" id="mySlider1"></input>
</div>
Sorry! I've found the answer 20 minutes after posting this... I was searching for that all day long...
Here's the answer:
Use the ::-moz-range-progress element!
Example (works for the snippet)
input[type="range"].slider-track::-moz-range-progress {
background: red;
}
Here you are in Vanilla JS - using gradients for Chrome range input:
<div class="chrome">
<input id="myinput" type="range" value="50" />
</div>
#myinput {background: linear-gradient(to right, #82CFD0 0%, #82CFD0 50%, #fff 50%, #fff 100%);
border: solid 1px #82CFD0;
border-radius: 8px;
height: 7px;
width: 356px;
outline: none;
transition: background 450ms ease-in;
-webkit-appearance: none;
}
document.getElementById("myinput").oninput = function() {
this.style.background = 'linear-gradient(to right, #82CFD0 0%, #82CFD0 '+this.value +'%, #fff ' + this.value + '%, white 100%)'
};
https://codepen.io/saintwycliffe/pen/VBGYXN
You can try this :
$('input[type="range"]').change(function () {
var val = $(this).val()/100;
$(this).css('background-image',
'-webkit-gradient(linear, left top, right top, '
+ 'color-stop(' + val + ', #94A14E), '
+ 'color-stop(' + val + ', #C5C5C5)'
+ ')'
);
});
input[type="range"]{
-webkit-appearance: none;
-moz-apperance: none;
border-radius: 6px;
height: 6px;
background-image: -webkit-gradient(
linear,
left top,
right top,
color-stop(0.15, #94A14E),
color-stop(0.15, #C5C5C5)
);
}
input[type='range']::-webkit-slider-thumb {
-webkit-appearance: none !important;
background-color: #E9E9E9;
border: 1px solid #CECECE;
height: 15px;
width: 15px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="range" min="0" max="100" step="1" value="15">
use input change instead of change, so in all browsers the color should fill up while the user is dragging, and not when the user stops dragging
$(document).on('input change', '#slider', function() {
// codes
});

Kendo legacy theme's problems

This is a self-answered question
I'd like to use Kendo legacy themes for my app, since default themes are extremely ugly. I chose Office 2007 theme. I've included the following files:
<link href="~/Content/kendo/legacy/telerik.common.css" rel="stylesheet" />
<link href="~/Content/kendo/legacy/telerik.office2007.min.css" rel="stylesheet" />
I came across several problems with this themes that I'm not able to get ride of them and any help is appreciated.
Aligning buttons. Custom buttons are higher in the grid than the Grid's buttons.
Paging. Current page's number is shown in the corner. Also pagination's buttons are reverse, and page number's box is too big.
Multi select's wheel doesn't stop, even after loading items!
And finally, window's minimize button isn't visible.
This is the CSS I have used for buttons:
.k-grid .k-button{
width: 10px;
min-width: 10px !important;
}
.k-grid-custom,
.k-grid-custom:hover{
background-image: url('/Content/Images/Icon/icon.png');
height: 20px;
background-position: center;
background-repeat: no-repeat;
}
.k-edit{
background-image: url('/Content/Images/Icon/Edit.png');
background-position: 0 0 ;
}
Well, I worked around the multiselect's problem with robbing some of CSS from kendo.common.css.
.k-multiselect-wrap {
position: relative;
border-width: 0;
border-style: solid;
border-radius: 4px;
border-color: #c5c5c5;
background-color: #FFF;
min-height: 2.04em;
}
.k-multiselect-wrap .k-input {
background-color: transparent;
height: 1.31em;
line-height: 1.31em;
padding: .18em 0;
text-indent: .33em;
border: 0;
margin: 1px 0 0;
float: left;
}
.k-multiselect-wrap li {
margin: 1px 0 1px 1px;
padding: .1em 1.6em .1em .4em;
line-height: 1.5em;
float: left;
position: relative;
}
.k-autocomplete .k-loading, .k-multiselect .k-loading {
position: absolute;
right: 3px;
bottom: 4px;
}
.k-multiselect .k-loading-hidden {
visibility: hidden;
}
.k-multiselect-wrap .k-select {
position: absolute;
top: 0;
bottom: 0;
right: 0;
padding: .1em .2em;
}
You can hide current page's number:
.k-pager-numbers .k-current-page {
display: none;
}
Page numbers' size:
.k-pager-wrap .k-dropdown {
width: 4.500em;
}
For pagination's arrows, if you're using left-to-right you won't have any problem. In case you're using right-to-left, k-rtl, replace following CSS in telerik.common.css, line #230:
.k-i-seek-w { background-position: -48px -192px; }
.k-i-arrow-w { background-position: -32px -192px; }
.k-i-arrow-e { background-position: -16px -192px; }
.k-i-seek-e { background-position: 0 -192px; }
.k-state-disabled .k-i-seek-w { background-position: -48px -208px; }
.k-state-disabled .k-i-arrow-w { background-position: -32px -208px; }
.k-state-disabled .k-i-arrow-e { background-position: -16px -208px; }
.k-state-disabled .k-i-seek-e { background-position: 0 -208px; }
.k-state-hover .k-i-seek-w { background-position: -48px -224px; }
.k-state-hover .k-i-arrow-w { background-position: -32px -224px; }
.k-state-hover .k-i-arrow-e { background-position: -16px -224px; }
.k-state-hover .k-i-seek-e { background-position: 0 -224px; }
For the minimize button in Kendo Window, it seems they forgot to add the CSS!
.k-i-minimize {background-position: -32px -368px; }
Use the following CSS to align custom buttons with grid's buttons.
.k-grid .k-button {
vertical-align: bottom;
}

CSS3 Transitioning Transforms in Mobile WebKit

I have a transition transform on an element in CSS3, but whenever I run the animation, it seems that one of the elements involved in the animation is always hidden for the duration of the animation.
Here is the CSS, HTML and JavaScript code:
CSS
div.toggle {
font-family: Arial, Helvetica, sans-serif;
width: 92px;
overflow: hidden;
cursor: default;
border-radius: 3px;
border: 1px solid #919191;
float: right;
position: relative;
height: 26px
}
div.toggle div.control-cont {
display: -webkit-box;
position: absolute;
-webkit-transition:all 0.2s ease-in-out;
width: 155px;
}
div.toggle span {
display: inline-block;
float: left;
text-transform: uppercase;
position: relative;
float: left;
}
div.toggle span.on {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(41,90,178,1)), color-stop(50%,rgba(64,133,236,1)), color-stop(51%,rgba(77,143,239,1)), color-stop(100%,rgba(118,173,252,1)));
background: -webkit-linear-gradient(top, rgba(41,90,178,1) 0%,rgba(64,133,236,1) 50%,rgba(77,143,239,1) 51%,rgba(118,173,252,1) 100%);
font-weight: bold;
color: #fff;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5);
font-size: 16px;
width: 57px;
text-align: center;
padding-top: 4px;
}
div.toggle.important span.on {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(210,102,8,1)), color-stop(2%,rgba(234,115,10,1)), color-stop(4%,rgba(248,123,12,1)), color-stop(50%,rgba(255,140,14,1)), color-stop(51%,rgba(255,153,33,1)), color-stop(100%,rgba(254,188,86,1)));
background: -webkit-linear-gradient(top, rgba(210,102,8,1) 0%,rgba(234,115,10,1) 2%,rgba(248,123,12,1) 4%,rgba(255,140,14,1) 50%,rgba(255,153,33,1) 51%,rgba(254,188,86,1) 100%);
}
div.toggle span.handle {
border-radius: 3px;
height: 26px;
border-left: 1px solid #9f9f9f;
border-right: 1px solid #9f9f9f;
width: 39px;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(239,239,239,1)), color-stop(3%,rgba(206,206,206,1)), color-stop(100%,rgba(251,251,251,1)));
background: -webkit-linear-gradient(top, rgba(239,239,239,1) 0%,rgba(206,206,206,1) 3%,rgba(251,251,251,1) 100%);
z-index: 10;
left: -5px
}
div.toggle span.off {
font-size: 16px;
font-weight: bold;
color: #7e7e7e;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(181,181,181,1)), color-stop(2%,rgba(207,207,207,1)), color-stop(4%,rgba(223,223,223,1)), color-stop(6%,rgba(231,231,231,1)), color-stop(50%,rgba(239,239,239,1)), color-stop(51%,rgba(249,249,249,1)), color-stop(100%,rgba(254,254,254,1)), color-stop(100%,rgba(251,251,251,1)));
background: -webkit-linear-gradient(top, rgba(181,181,181,1) 0%,rgba(207,207,207,1) 2%,rgba(223,223,223,1) 4%,rgba(231,231,231,1) 6%,rgba(239,239,239,1) 50%,rgba(249,249,249,1) 51%,rgba(254,254,254,1) 100%,rgba(251,251,251,1) 100%);
left: -10px;
text-align: center;
padding-top: 4px;
width: 57px;
}
div.toggle input {
display: none;
}
JavaScript:
(function($) {
$.fn.toggle = function()
{
this.each(function() {
var toggle_class = ($(this).attr('checked')) ? 'checked' : '';
var important_class = ($(this).hasClass('important')) ? 'important' : '';
var this_transformed = false;
var this_toggle = $('<div class="toggle">\
<div class="control-cont">\
<span class="on">on</span>\
<span class="handle"></span>\
<span class="off">off</span>\
</div>\
</div>');
this_toggle.addClass(toggle_class);
this_toggle.addClass(important_class);
var thecheckbox = this;
$(this).replaceWith(this_toggle);
this_toggle.append(thecheckbox);
if(toggle_class != 'checked')
{
this_toggle.find('.control-cont').css({ left: '-53px' });
}
this_toggle.click(toggle_switch);
$(thecheckbox).change(toggle_switch);
function toggle_switch() {
var self = $(this);
var this_off = $(this).find('.off');
var this_on = $(this).find('.on');
var this_container = $(this).find('.control-cont');
var the_checkbox = $(this).find('input[type="checkbox"]');
if($(this).hasClass('checked'))
{
if(!this_transformed)
{
this_container.css("-webkit-transform", "translate(-53px, 0px)");
this_transformed = true;
}
else
{
this_container.css("-webkit-transform", "translate(53px, 0px)");
}
self.removeClass('checked');
the_checkbox.attr('checked', false);
}
else
{
if(!this_transformed)
{
this_container.css("-webkit-transform", "translate(53px, 0px)");
this_transformed = true;
}
else
{
this_container.css("-webkit-transform", "translate(0px, 0px)");
}
self.addClass('checked');
the_checkbox.attr('checked', true);
}
};
});
};
}) ( jQuery );
Essentially, the animation moves the entire div.control-con along or backwards, depending on the checkbox's status. Everything works fine in Chrome and Safari, but when running in Mobile Safari, for some reason the span.off and span.on elements are not displayed when the animation is run.
Which span element is hidden depends on the direction of the animation. Here's a screenshot of the problem, you'll notice that the span.off isn't displayed until the animation is complete:
I've also put this into a jsFiddle for reference: http://jsfiddle.net/kShEQ/
Mobile Safari is not an exact clone of normal safari and the webkit engine. It's a myth that there's a single webkit engine haha. Mobile Safari renders transitions differently. From what I've seen, the syntax in which you enter the transition values differs slightly. Check out this semi-similar stackoverflow question:
Scaling problem with -webkit-transform with mobile safari on iPad

Resources