2013-05-28 18:45:39 -07:00
|
|
|
|
(function (window, document, $) {
|
|
|
|
|
|
|
|
|
|
function getPickerHtml() {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<a href="#">#</a>';
|
|
|
|
|
html += '<a href="#">A</a>';
|
|
|
|
|
html += '<a href="#">B</a>';
|
|
|
|
|
html += '<a href="#">C</a>';
|
|
|
|
|
html += '<a href="#">D</a>';
|
|
|
|
|
html += '<a href="#">E</a>';
|
|
|
|
|
html += '<a href="#">F</a>';
|
|
|
|
|
html += '<a href="#">G</a>';
|
|
|
|
|
html += '<a href="#">H</a>';
|
|
|
|
|
html += '<a href="#">I</a>';
|
|
|
|
|
html += '<a href="#">J</a>';
|
|
|
|
|
html += '<a href="#">K</a>';
|
|
|
|
|
html += '<a href="#">L</a>';
|
|
|
|
|
html += '<a href="#">M</a>';
|
|
|
|
|
html += '<a href="#">N</a>';
|
|
|
|
|
html += '<a href="#">O</a>';
|
|
|
|
|
html += '<a href="#">P</a>';
|
|
|
|
|
html += '<a href="#">Q</a>';
|
|
|
|
|
html += '<a href="#">R</a>';
|
|
|
|
|
html += '<a href="#">S</a>';
|
|
|
|
|
html += '<a href="#">T</a>';
|
|
|
|
|
html += '<a href="#">U</a>';
|
|
|
|
|
html += '<a href="#">V</a>';
|
|
|
|
|
html += '<a href="#">W</a>';
|
|
|
|
|
html += '<a href="#">X</a>';
|
|
|
|
|
html += '<a href="#">Y</a>';
|
|
|
|
|
html += '<a href="#">Z</a>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
function init(container, picker) {
|
2013-05-28 18:45:39 -07:00
|
|
|
|
|
2015-08-15 11:17:22 -07:00
|
|
|
|
$('.itemsContainer', container).addClass('itemsContainerWithAlphaPicker');
|
2013-05-28 18:45:39 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
picker.innerHTML = getPickerHtml();
|
2013-05-28 18:45:39 -07:00
|
|
|
|
|
2015-12-23 10:46:01 -07:00
|
|
|
|
$(picker).on('click', 'a', function () {
|
2013-05-28 18:45:39 -07:00
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var elem = this;
|
|
|
|
|
|
|
|
|
|
var isSelected = elem.classList.contains('selectedCharacter');
|
2013-05-28 18:45:39 -07:00
|
|
|
|
|
|
|
|
|
$('.selectedCharacter', picker).removeClass('selectedCharacter');
|
|
|
|
|
|
|
|
|
|
if (!isSelected) {
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
elem.classList.add('selectedCharacter');
|
2015-12-23 10:46:01 -07:00
|
|
|
|
$(picker).trigger('alphaselect', [this.innerHTML]);
|
2013-05-28 18:45:39 -07:00
|
|
|
|
} else {
|
2015-12-23 10:46:01 -07:00
|
|
|
|
$(picker).trigger('alphaclear');
|
2013-05-28 18:45:39 -07:00
|
|
|
|
}
|
|
|
|
|
});
|
2015-08-15 11:17:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-07 21:22:38 -07:00
|
|
|
|
pageClassOn('pageinit', "libraryPage", function () {
|
2015-08-15 11:17:22 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
var pickers = page.querySelectorAll('.alphabetPicker');
|
|
|
|
|
|
|
|
|
|
if (!pickers.length) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (page.classList.contains('pageWithAbsoluteTabs')) {
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = pickers.length; i < length; i++) {
|
|
|
|
|
init($(pickers[i]).parents('.pageTabContent'), pickers[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
init(page, pickers[0]);
|
|
|
|
|
}
|
2013-05-28 18:45:39 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$.fn.alphaValue = function (val) {
|
|
|
|
|
|
|
|
|
|
if (val == null) {
|
|
|
|
|
return $('.selectedCharacter', this).html();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val = val.toLowerCase();
|
|
|
|
|
|
|
|
|
|
$('.selectedCharacter', this).removeClass('selectedCharacter');
|
|
|
|
|
|
|
|
|
|
$('a', this).each(function () {
|
|
|
|
|
|
|
|
|
|
if (this.innerHTML.toLowerCase() == val) {
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
this.classList.add('selectedCharacter');
|
2013-05-28 18:45:39 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
2015-06-28 07:45:21 -07:00
|
|
|
|
this.classList.remove('selectedCharacter');
|
2013-05-28 18:45:39 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
};
|
|
|
|
|
|
2013-09-06 12:17:15 -07:00
|
|
|
|
$.fn.alphaClear = function (val) {
|
|
|
|
|
|
|
|
|
|
return this.alphaValue('');
|
|
|
|
|
};
|
|
|
|
|
|
2013-05-28 18:45:39 -07:00
|
|
|
|
})(window, document, jQuery);
|