///
(function ($) {
$.sideBarImpl = {
isSearchOpen: false,
isContactOpen: false,
isShareOpen: false,
isRssOpen: false,
iconSize: 86,
init: function () {
$("#sidebarContact").hide();
$("#sidebarSearch").hide();
$("#contactLink").click(function (e) {
$.sideBarImpl.handleContactClick();
});
$("#searchLink").click(function (e) {
$.sideBarImpl.handleSearchClick();
});
$("#shareLink").click(function (e) {
$.sideBarImpl.handleShareClick();
});
$("#sidebarSearchTextbox").bind("keyup", function () {
$.sideBarImpl.handleSearchTextBoxChange();
});
$("#rssLink").click(function (e) {
$.sideBarImpl.handleRssClick();
});
$("div.sideBar").click(function (e) {
if ($.sideBar.get_isOpen()) {
e.stopPropagation();
}
});
$(document).click(function (e) {
if ($.sideBar.get_isOpen()) {
$.sideBarImpl.closeAll();
}
});
},
handleContactClick: function () {
$.sideBarImpl.isShareOpen = false;
$("#sidebarShare").hide();
$.sideBarImpl.isSearchOpen = false;
$("#sidebarSearch").hide();
$.sideBarImpl.isRssOpen = false;
$("#sidebarRSS").hide();
if (!$.sideBarImpl.isContactOpen) {
$("#sidebarContact").show();
var NewElementWidth = $("#sidebarContact img").width();
var animateWidthTo = NewElementWidth + $.sideBarImpl.iconSize;
$("div.sideBar").animate({ width: animateWidthTo, duration: 600 });
$.sideBarImpl.isContactOpen = !$.sideBarImpl.isContactOpen;
}
else {
$("div.sideBar").animate({ width: $.sideBarImpl.iconSize, duration: 600 }, function () {
$("#sidebarContact").hide();
});
$.sideBarImpl.isContactOpen = !$.sideBarImpl.isContactOpen;
}
},
handleSearchClick: function () {
$.sideBarImpl.isContactOpen = false;
$("#sidebarContact").hide();
$.sideBarImpl.isShareOpen = false;
$("#sidebarShare").hide();
$.sideBarImpl.isRssOpen = false;
$("#sidebarRSS").hide();
if (!$.sideBarImpl.isSearchOpen) {
$("#sidebarSearch").show();
var NewElementWidth = 300;
var animateWidthTo = NewElementWidth + $.sideBarImpl.iconSize;
$("div.sideBar").animate({ width: animateWidthTo, duration: 600 }, function () {
$.sideBarImpl.handleFocusOnSearchTextBox();
});
$.sideBarImpl.isSearchOpen = true;
}
else {
$("div.sideBar").animate({ width: $.sideBarImpl.iconSize, duration: 600 }, function () {
$("#sidebarSearch").hide();
});
$.sideBarImpl.isSearchOpen = false;
$.sideBarImpl.handleFocusOnSearchTextBox();
}
},
handleFocusOnSearchTextBox: function () {
if ($.sideBarImpl.isSearchOpen) {
$("#sidebarSearchTextbox").show();
setTimeout(function () {
$("#sidebarSearchTextbox").focus();
}, 100);
$.sideBarImpl.handleSearchTextBoxChange();
}
else {
$("#sidebarSearchTextbox").hide();
$("#sidebarSearchTextbox").blur();
}
},
handleShareClick: function () {
$.sideBarImpl.isContactOpen = false;
$("#sidebarContact").hide();
$.sideBarImpl.isSearchOpen = false;
$("#sidebarSearch").hide();
$.sideBarImpl.isRssOpen = false;
$("#sidebarRSS").hide();
if (!$.sideBarImpl.isShareOpen) {
$("#sidebarShare").show();
var NewElementWidth = 86;
var animateWidthTo = NewElementWidth + $.sideBarImpl.iconSize;
$("div.sideBar").animate({ width: animateWidthTo, duration: 600 });
$.sideBarImpl.isShareOpen = true;
}
else {
$("div.sideBar").animate({ width: $.sideBarImpl.iconSize, duration: 600 }, function () {
$("#sidebarShare").hide();
});
$.sideBarImpl.isShareOpen = false;
}
},
handleRssClick: function () {
$.sideBarImpl.isContactOpen = false;
$("#sidebarContact").hide();
$.sideBarImpl.isSearchOpen = false;
$("#sidebarSearch").hide();
$.sideBarImpl.isShareOpen = false;
$("#sidebarShare").hide();
if (!$.sideBarImpl.isRssOpen) {
if ($("#sidebarRSS iframe").length == 0) {
$("#sidebarRSS").append($(""));
}
$("#sidebarRSS").show();
var NewElementWidth = 86;
var animateWidthTo = NewElementWidth + 600;
$("div.sideBar").animate({ width: animateWidthTo, duration: 600 });
$.sideBarImpl.isRssOpen = true;
}
else {
$("div.sideBar").animate({ width: $.sideBarImpl.iconSize, duration: 600 }, function () {
$("#sidebarRSS").hide();
});
$.sideBarImpl.isRssOpen = false;
}
},
closeAll: function () {
$("div.sideBar").animate({ width: $.sideBarImpl.iconSize, duration: 600 }, function () {
$.sideBarImpl.isContactOpen = false;
$("#sidebarContact").hide();
$.sideBarImpl.isSearchOpen = false;
$("#sidebarSearch").hide();
$.sideBarImpl.isShareOpen = false;
$("#sidebarShare").hide();
$.sideBarImpl.isRssOpen = false;
$("#sidebarRSS").hide();
});
},
hardcodedSearchOptions: [
{ text: "Pre-beta Windows 8.1 WinRT Developer APIs", link: "http://justinangel.net/Win81APIs" },
{ text: "About Justin Angel", link: "http://justinangel.net/About" },
{ text: "All new Windows Phone 7.5 Mango APIs", link: "http://justinangel.net/AllWp7MangoAPIs" },
{ text: "MetroBlog: Windows8 Metro Styled Blog", link: "http://justinangel.net/Windows8MetroBlog" },
{ text: "Reverse Engineering and Modifying Windows 8 apps", link: "http://justinangel.net/ReverseEngineerWin8Apps" },
{ text: "Windows Phone 7 Marketplace Statistics", link: "http://justinangel.net/WindowsPhone7MarketplaceStatistics" },
{ text: "Windows Phone 7 Development Best Practices Wiki", link: "http://justinangel.net/WindowsPhone7DevBestPracticesWiki" },
{ text: "Windows Phone 7 “Neurons” App", link: "http://justinangel.net/WindowsPhone7NeuronsApp" },
{ text: "Windows Phone 7 supports VB.Net and F#", link: "http://justinangel.net/WindowsPhone7VBnetAndFSharp" },
{ text: "TFS2010 WP7 Continuous Integration", link: "http://justinangel.net/TFS2010WP7ContinuousIntegration" },
{ text: "Windows Phone 7 – Emulator Automation", link: "http://justinangel.net/WindowsPhone7EmulatorAutomation" },
{ text: "Windows Phone 7 – Unlocked ROMs", link: "http://justinangel.net/WindowsPhone7UnlockedRoms" },
{ text: "Silverlight 5 Future Features", link: "http://justinangel.net/Silverlight5FutureFeatures" },
{ text: "Silverlight Isn’t Fully Cross-Platform", link: "http://justinangel.net/SilverlightIsnTFullyCrossPlatform" },
{ text: "“Advanced MVVM” Book Review", link: "http://justinangel.net/AdvancedMvvmBookReview" },
{ text: "Cutting Edge Silverlight4 COM+ Features", link: "http://justinangel.net/CuttingEdgeSilverlight4ComFeatures" },
{ text: "AutoMagically Implementing INotifyPropertyChanged", link: "http://justinangel.net/AutomagicallyImplementingINotifyPropertyChanged" },
{ text: "Mix10 And Molecular Biology DNA Visualizer", link: "http://justinangel.net/Mix10AndMolecularBiologyDnaVisualizer" },
{ text: "Silverlight Weblog Features Overview", link: "http://justinangel.net/SilverlightWeblogFeaturesOverview" },
{ text: "Silverlight", link: "http://justinangel.net/Silverlight" },
{ text: "Personal", link: "http://justinangel.net/About" },
{ text: "Windows Phone 7", link: "http://justinangel.net/WP7" },
{ text: "Windows 8", link: "http://justinangel.net/Win8" },
],
handleSearchTextBoxChange: function () {
var text = $("#sidebarSearchTextbox").val();
$("#searchResults").children().remove();
for (itemIndex in $.sideBarImpl.hardcodedSearchOptions) {
var item = $.sideBarImpl.hardcodedSearchOptions[itemIndex];
if (item.text.toLowerCase().indexOf(text.toLowerCase()) != -1) {
$("#searchResults").append($("
").html("" + item.text + ""));
}
}
if (text.length > 0)
$("#searchResults li a").highlightText(text);
}
};
$.sideBar = function () {
new $.sideBarImpl.init();
};
$.sideBar.get_isOpen = function () {
return $.sideBarImpl.isContactOpen ||
$.sideBarImpl.isSearchOpen ||
$.sideBarImpl.isShareOpen ||
$.sideBarImpl.isRssOpen;
};
})(jQuery);
// https://github.com/tentonaxe/jQuery-highlightText/blob/master/jquery.highlighttext.js
// This jQuery plugin implements the $.fn.highlightText method
// making it easy to highlight text within an element by wrapping
// it in a span with a given class.
//
// To use this plugin, first select the element that contains the text
// that you want to replace, then call .highlightText() on it.
// the plugin has one required parameter and two optional parameters.
//
// The plugin is always called in the same way:
// $(sel).highlightText();
// It accepts three parameters.
//
// The first parameter decides what text will be matched. It can be a
// string, a regular expression in string format, a regular expression
// object, or an array of words.
//
// The second parameter is the class that will be added to the matched
// text. it is optional and can be a space delimited list of classes to
// add to the element that wraps the matched text. It is set to "highlight"
// by default.
//
// The third parameter lets you decide whether or not the plugin should
// only match full matches. It is defaulted to false, meaning it will
// match partial matches. However, this third parameter is ignored if
// the first parameter is a regular expression object.
(function ($) {
$.fn.highlightText = function () {
// handler first parameter
// is the first parameter a regexp?
var re,
hClass,
reStr,
argType = $.type(arguments[0]),
defaultTagName = $.fn.highlightText.defaultTagName;
if (argType === "regexp") {
// first argument is a regular expression
re = arguments[0];
}
// is the first parameter an array?
else if (argType === "array") {
// first argument is an array, generate
// regular expression string for later use
reStr = arguments[0].join("|");
}
// is the first parameter a string?
else if (argType === "string") {
// store string in regular expression string
// for later use
reStr = arguments[0];
}
// else, return out and do nothing because this
// argument is required.
else {
return;
}
// the second parameter is optional, however,
// it must be a string or boolean value. If it is
// a string, it will be used as the highlight class.
// If it is a boolean value and equal to true, it
// will be used as the third parameter and the highlight
// class will default to "highlight". If it is undefined,
// the highlight class will default to "highlight" and
// the third parameter will default to false, allowing
// the plugin to match partial matches.
// ** The exception is if the first parameter is a regular
// expression, the third parameter will be ignored.
argType = $.type(arguments[1]);
if (argType === "string") {
hClass = arguments[1];
}
else if (argType === "boolean") {
hClass = "highlight";
if (reStr) {
reStr = "\\b" + reStr + "\\b";
}
}
else {
hClass = "highlight";
}
if (arguments[2] && reStr) {
reStr = reStr = "\\b" + reStr + "\\b";
}
// if re is not defined ( which means either an array or
// string was passed as the first parameter ) create the
// regular expression.
if (!re) {
re = new RegExp("(" + reStr + ")", "ig");
}
// iterate through each matched element
return this.each(function () {
// select all contents of this element
$(this).find("*").andSelf().contents()
// filter to only text nodes that aren't already highlighted
.filter(function () {
return this.nodeType === 3 && $(this).closest("." + hClass).length === 0;
})
// loop through each text node
.each(function () {
var output;
output = this.nodeValue
.replace(re, "<" + defaultTagName + " class='" + hClass + "'>$1" + defaultTagName + ">");
if (output !== this.nodeValue) {
$(this).wrap("").parent()
.html(output).contents().unwrap();
}
});
});
};
$.fn.highlightText.defaultTagName = "span";
})(jQuery);