Created
October 30, 2012 21:02
-
-
Save dantuck/3983038 to your computer and use it in GitHub Desktop.
Enables adding links to the SharePoint 2012 chrome navigation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#suiteBarLeft').chromeSuiteLinks({ | |
"links": [ | |
{ | |
"linkUrl": "link1.html?" + document.URL.split("?")[1], | |
"displayName": "Link" | |
}, | |
{ | |
"linkUrl": "link2.html?" + document.URL.split("?")[1], | |
"displayName": "Link2" | |
} | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!function ($, window) { | |
"use strict"; // jshint ;_; | |
/* CHROMESUITELINKS PUBLIC CLASS DEFINITION | |
* =============================== */ | |
var ChromeSuiteLinks = function (target, options) { | |
this.$target = $(target) | |
this.options = $.extend({}, $.fn.chromeSuiteLinks.defaults, options) | |
if (this.options.links === $.noop) return; | |
this.init() | |
} | |
ChromeSuiteLinks.prototype = { | |
constructor: ChromeSuiteLinks | |
, init: function () { | |
var $ul | |
, $linksWrapper = $(this.options.linksWrapper) | |
$ul = $('ul', $linksWrapper); | |
this.updateLinks($ul) | |
this.$target.append($linksWrapper); | |
} | |
, updateLinks: function (ul) { | |
var $ul = ul | |
$ul.empty() | |
$.each(this.options.links, function (i, o) { | |
$('<li class="ms-core-suiteLink"><a class="ms-core-suiteLink-a" href="' + o.linkUrl + '"><span class="ms-verticalAlignMiddle">' + o.displayName + '</span></a></li>').appendTo($ul) | |
}) | |
} | |
// , destroy: function () { | |
// this.hide().$element.off('.' + this.type).removeData(this.type) | |
// } | |
} | |
/* CHROMESUITELINKS PLUGIN DEFINITION | |
* ======================= */ | |
$.fn.chromeSuiteLinks = function (option) { | |
return this.each(function () { | |
var $this = $(this) | |
, data = $this.data('popover') | |
, options = typeof option == 'object' && option | |
if (!data) $this.data('chromeSuiteLinks', (data = new ChromeSuiteLinks(this, options))) | |
if (typeof option == 'string') data[option]() | |
}) | |
} | |
$.fn.chromeSuiteLinks.defaults = { | |
links: $.noop | |
, linksWrapper: '<div id="AppSuiteLinks" class="ms-core-deltaSuiteLinks ms-fullWidth"><div id="appSuiteLinksBox"><ul class="ms-core-suiteLinkList"></ul></div></div>' | |
} | |
$.fn.chromeSuiteLinks.Constructor = ChromeSuiteLinks | |
}(window.jQuery, window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment