/*!
* jQuery pinify Plugin v1.2
* http://ie9ify.codeplex.com
*
* Copyright 2011, Brandon Satrom and Clark Sell
* Licensed under MS-PL.
* http://ie9ify.codeplex.com/license
*
* Date: Wednesday May 11 2011 11:47:27 -05
*/
(function ($, undefined) {
//private functions
function createMetaTag(name, content, head) {
if ($('meta[name=' + name + ']').length && name !== 'msapplication-task') {
return;
}
if (!content.length) { return; }
$('', {
name: name,
content: content
}).appendTo(head);
}
function siteModeSupported() {
return (!!window.external) && ('msIsSiteMode' in window.external);
}
/* pinify jQuery Functions:
* init: Adds meta tags and startup tasks to a page
* enablePinning: Enables a content item to be enabled for pinning (meaning that it can be dragged to the taskbar to pin a site)
* enableSiteMode: Enables binding of an event that triggers a site mode dialog (asking if the user wants to pin the site to the *start* menu)
* pinTeaser: Adds a teaser bar to the site, directly underneath the address bar. Teaser bar encourages the user to pin the site.
*/
var methods = {
init: function (options) {
var defaultOptions = {
applicationName: document.title.toString(),
favIcon: 'http://' + location.host + '/favicon.ico',
navColor: '',
startUrl: 'http://' + location.host,
tooltip: document.title.toString(),
window: 'width=800;height=600',
tasks: []
};
options = $.extend({}, defaultOptions, options);
return this.each(function () {
var taskList = options.tasks;
var head = this;
if ($('link[type^=image]').length === 0) {
$("", {
rel: "shortcut icon",
type: "image/ico",
href: options.favIcon
}).appendTo(this);
}
createMetaTag('application-name', options.applicationName, this);
createMetaTag('msapplication-tooltip', options.tooltip, this);
createMetaTag('msapplication-starturl', options.startUrl, this);
createMetaTag('msapplication-navbutton-color', options.navColor, this);
createMetaTag('msapplication-window', options.window, this);
$.each(taskList, function (key, value) {
createMetaTag('msapplication-task', 'name=' + value.name + ';action-uri=' + value.action + ';icon-uri=' + value.icon, head);
});
});
},
enablePinning: function (title) {
return this.each(function () {
title = title || "Drag this image to your Windows 7 Taskbar to pin this site with IE9";
$(this).addClass('msPinSite').attr("title", title);
});
},
enableSiteMode: function (eventName) {
eventName = eventName || "click";
return this.each(function () {
$(this).bind(eventName, function (event) {
event.preventDefault();
try {
window.external.msAddSiteMode();
} catch (e) { }
});
});
},
pinTeaser: function (options) {
if (window.external.msIsSiteMode()) {
return this;
}
var teaser = $(this);
var defaultOptions = {
type: 'hangingChad', //Options are: hangingChad, topHat, brandedTopHat and doubleTopHat
icon: 'http://' + location.host + '/favicon.ico',
pinText: 'Drag this image to the taskbar to pin this site',
secondaryText: 'Simply drag the icon or tab to taskbar to pin.',
addStartLink: true,
linkText: 'Click here to add this site to the start menu',
sticky: true,
timeout: 10000,
style: {
linkColor: 'rgb(0, 108, 172)',
backgroundColor: 'rgb(0, 108, 172)',
textColor: 'white',
backgroundImage: null,
leftBackgoundImage: null,
rightBackgoundImage: null,
closeButtonImage: null
}
};
var alignmentDiv, contentDiv, leftDiv, leftBar, rightDiv, mainContent;
var builder = {
topHat: function () {
teaser.addClass('pinify-topHat-container pinify-teaser').css('color', options.style.textColor);
if (options.style.backgoundImage) {
teaser.css('background-image', options.style.backgroundImage);
}
alignmentDiv = $('
', { id: 'pinify-pinText' }).text(options.pinText).appendTo(teaser);
teaser.fadeIn('slow');
}
};
options = $.extend({}, defaultOptions, options);
return this.each(function () {
//Call the correct builder function based on the type passed in
builder[options.type]();
//If it's not a sticky teaser, fade it out after a delay. Otherwise put a close button on the div
if (!options.sticky) {
this.delay(options.timeout).fadeOut('slow');
} else {
$('