This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/assets/javascripts/lib/module-nav-scroll.js

60 lines
1.8 KiB
JavaScript

// Search Clear
!function ($) {
$.fn.searchClear = function (param){
_defaultSettings = {
inputName: ':input',
inputIcon: 'inputIcon',
clearBtnIcon: 'clearBtnIcon',
};
_set = $.extend(_defaultSettings, param);
$this = this;
$input = this.find(_set.inputName);
$tmp = '<i class="'+_set.inputIcon+'"></i><i class="'+_set.clearBtnIcon+' search-clear"></i>';
$input.wrap('<div class="sc-field" />');
$this.find('.sc-field').prepend($tmp);
$searchClear = $this.find(".search-clear");
function run(e) {
$searchClear.hide();
if($input.val().length > 0) {
$searchClear.show();
}else {
$searchClear.hide();
}
$input.on("blur keyup", function(){
if($(this).val().length > 0) {
$searchClear.show();
}else {
$searchClear.hide();
}
});
$searchClear.on({
click: function(){
$(this).hide();
$input.val("")
},
});
}
// Checking IE10
// if Windows 8 and IE is ture. remove search clear buttom and fix text input padding-right
if(/Windows NT 6.2/g.test(navigator.userAgent)){
if(/MSIE/g.test(navigator.userAgent)){
$searchClear.remove();
$input.css({
'padding-right': '5px',
});
}else{run()}
}else{run()}
}
}(window.jQuery);
var $moduleWidth = 0,
$moduleNav = $('.module-nav');
var navMenu = new iScroll(document.getElementsByClassName('nav-scroll')[0], {
snap: true,
momentum: false,
hScrollbar: false,
});