first commit

This commit is contained in:
pakerpale
2020-06-10 06:19:03 +09:00
commit cd6b5b7832
6081 changed files with 624389 additions and 0 deletions

231
public/js/admin/common.js Executable file
View File

@@ -0,0 +1,231 @@
//layer popup
function commonLayerOpen(thisId){
$('#'+thisId).show();
}
function commonLayerClose(thisId){
$('#'+thisId).hide();
}
// 날짜포맷
Date.prototype.format = function(f) {
if (!this.valueOf()) return " ";
var weekName = ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"];
var d = this;
return f.replace(/(yyyy|yy|MM|dd|E|hh|mm|ss|a\/p)/gi, function($1) {
switch ($1) {
case "yyyy": return d.getFullYear();
case "yy": return (d.getFullYear() % 1000).zf(2);
case "MM": return (d.getMonth() + 1).zf(2);
case "dd": return d.getDate().zf(2);
case "E": return weekName[d.getDay()];
case "HH": return d.getHours().zf(2);
case "hh": return ((h = d.getHours() % 12) ? h : 12).zf(2);
case "mm": return d.getMinutes().zf(2);
case "ss": return d.getSeconds().zf(2);
case "a/p": return d.getHours() < 12 ? "오전" : "오후";
default: return $1;
}
});
};
String.prototype.string = function(len){var s = '', i = 0; while (i++ < len) { s += this; } return s;};
String.prototype.zf = function(len){return "0".string(len - this.length) + this;};
Number.prototype.zf = function(len){return this.toString().zf(len);};
// 주소검색
//본 예제에서는 도로명 주소 표기 방식에 대한 법령에 따라, 내려오는 데이터를 조합하여 올바른 주소를 구성하는 방법을 설명합니다.
function execDaumPostcode() {
new daum.Postcode({
oncomplete: function(data) {
// 팝업에서 검색결과 항목을 클릭했을때 실행할 코드를 작성하는 부분.
// 도로명 주소의 노출 규칙에 따라 주소를 조합한다.
// 내려오는 변수가 값이 없는 경우엔 공백('')값을 가지므로, 이를 참고하여 분기 한다.
var fullRoadAddr = data.roadAddress; // 도로명 주소 변수
var extraRoadAddr = ''; // 도로명 조합형 주소 변수
// 법정동명이 있을 경우 추가한다. (법정리는 제외)
// 법정동의 경우 마지막 문자가 "동/로/가"로 끝난다.
if(data.bname !== '' && /[동|로|가]$/g.test(data.bname)){
extraRoadAddr += data.bname;
}
// 건물명이 있고, 공동주택일 경우 추가한다.
if(data.buildingName !== '' && data.apartment === 'Y'){
extraRoadAddr += (extraRoadAddr !== '' ? ', ' + data.buildingName : data.buildingName);
}
// 도로명, 지번 조합형 주소가 있을 경우, 괄호까지 추가한 최종 문자열을 만든다.
if(extraRoadAddr !== ''){
extraRoadAddr = ' (' + extraRoadAddr + ')';
}
// 도로명, 지번 주소의 유무에 따라 해당 조합형 주소를 추가한다.
if(fullRoadAddr !== ''){
fullRoadAddr += extraRoadAddr;
}
// 우편번호와 주소 정보를 해당 필드에 넣는다.
$("#postcode").val(data.zonecode); //5자리 새우편번호 사용
$("#address").val(fullRoadAddr);
//document.getElementById('main_jibunAddress').value = data.jibunAddress;
window.close();
}
}).open();
}
// 숫자체크
function checkNumber(val){
var regexp = /^[0-9]*$/
if( !regexp.test(val) ) {
return false;
}
return true;
}
// 이메일체크
function checkEmail(val){
var regexp=/^[-A-Za-z0-9_]+[-A-Za-z0-9_.]*[@]{1}[-A-Za-z0-9_]+[-A-Za-z0-9_.]*[.]{1}[A-Za-z]{1,5}$/;
if( !regexp.test(val) ) {
return false;
}
return true;
}
// 전화번호체크
function checkPhone(val){
var regexp= /^\d{2,3}-\d{3,4}-\d{4}$/;
if( !regexp.test(val) ) {
return false;
}
return true;
}
function setComma(_no) {
return _no.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
function sortJSON(data, key, way) {
return data.sort(function(a, b) {
var x = a[key]; var y = b[key];
if (way === '123' ) { return ((x < y) ? -1 : ((x > y) ? 1 : 0)); }
if (way === '321') { return ((x > y) ? -1 : ((x < y) ? 1 : 0)); }
});
}
$(document).ready(function(){
$(".no_ready").click(function(){
alert("준비중인 페이지입니다 빠른시일내에 오픈할 예정입니다.");
return false;
});
// 그리드용 스크립트
$(".grid_children").addClass("moving_all");
$("#tablet_gnb ul").addClass("moving_all");
$("#container_wrap").addClass("moving_all")
$("#tablet_gnb li a").addClass("moving_all2");
$(".top_wrap").addClass("moving_all");
$(".grid").addClass("clearfix");
//left menu script
$("#tablet_gnb>li").click(function(){
if($(this).children("a").hasClass("onar")){
$("#tablet_gnb>li>a").removeClass("onar");
$("#tablet_gnb>li").find(".depth2").slideUp(100);
}else{
$("#tablet_gnb>li>a").removeClass("onar");
$(this).children("a").addClass("onar");
$("#tablet_gnb>li").find(".depth2").slideUp(100);
$(this).find(".depth2").slideDown(300);
}
});
//left 메뉴 감추기
$(".bars .b1").click(function(){
$("#tablet_wrap").addClass("notive");
$("#container_wrap").addClass("notive");
$(this).hide(100);
$(this).siblings(".a1").show(100);
if($(".bars .a1").hasClass("min")){
$("#tablet_wrap").removeClass("mintive");
}
})
$(".bars .a1").click(function(){
$("#tablet_wrap").removeClass("notive");
$("#container_wrap").removeClass("notive");
$(this).hide(100);
$(this).siblings(".b1").show(100);
if($(".bars .a1").hasClass("min")){
$("#tablet_wrap").addClass("mintive");
}
});
//공통 tep
$(".depth3_tep li a").click(function(){
$(".depth3_tep li a").removeClass("on");
$(this).addClass("on");
});
//type1
$(".common_tep.type01 ul li a").click(function(){
$(".common_tep.type01 ul li a").removeClass("on");
$(this).addClass("on");
})
//type2
$(".common_tep.type2 ul li a").click(function(){
$(".common_tep.type2 ul li a").removeClass("on");
$(this).addClass("on");
});
// table 내용보기
$(".common_table table td.title").click(function(){
if(!$(this).hasClass("on")){
$(this).parent("tr").next(".docu").slideDown(300);
$(this).addClass("on");
}else if($(this).hasClass("on")){
$(this).parent("tr").next(".docu").slideUp(100);
$(this).removeClass("on");
}
});
var triggerBookmark = $('.add_bookmark');
triggerBookmark.click(function() {
if (window.sidebar && window.sidebar.addPanel) { // Firefox <23
window.sidebar.addPanel(document.title,window.location.href,'');
} else if(window.external && ('AddFavorite' in window.external)) { // Internet Explorer
window.external.AddFavorite(location.href,document.title);
} else if(window.opera && window.print || window.sidebar && ! (window.sidebar instanceof Node)) { // Opera <15 and Firefox >23
triggerBookmark.attr('rel', 'sidebar').attr('title', document.title);
return true;
} else { // other browsers (WebKit)
alert((navigator.userAgent.toLowerCase().indexOf('mac') != - 1 ? 'Command/Cmd' : 'Ctrl') + '+D 키를 누르시면 즐겨찾기에 추가하실 수 있습니다.');
}
return false;
});
if ($('#iquersier').is(':hidden')){
$(".bars .a1").show(100);
$(".bars .a1").addClass("min");
}
var wh=$(this).height();
var th=$("#tablet_gnb").height();
$("#tablet_gnb").height(wh-80);
})

14
public/js/admin/ie8-body.js Executable file
View File

@@ -0,0 +1,14 @@
$(document).ready(function(){
$('*').each(function(){
var font_weight = $(this).css('font-weight');
if (font_weight == '100') {
$(this).addClass('fw100');
} else if(font_weight == '300') {
$(this).addClass('fw300');
} else if(font_weight == '500') {
$(this).addClass('fw500');
} else if(font_weight == '700' || font_weight == 'bold') {
$(this).addClass('fw700');
}
});
});

View File

@@ -0,0 +1,278 @@
/*
EasySlides - слидер
Autor 2017 Shabanov Ivan (Шабанов Иван)
Usage:
$('.slider').EasySlides({
'autoplay': true,
'timeout': 3000,
'show': 5, //Сколь-ко позывать слайдов (по умолчанию 5: 1-активный, 2-предыдущих и 2-следующих)
'vertical': false, //Если True то слайдер вертикальный, слайды листаются движением вверх/вниз
'reverse': false, //Перевернутый слайдер
'touchevents': true, //Вкючено ли события на прикосновения к сладеру (листания и т.п)
'delayaftershow': 300, //Задержка после смены слайдера, в это время слайдер нельзя листать
'stepbystep': true, //При клике на далекий слайд перейти к нему последовательно, а не сразу
'startslide': 0, //Стартовый слайд
'beforeshow': function () {},
'aftershow': function () {},
});
*/
(function( $ ){
$.fn.EasySlides = function( options ) {
var settings = $.extend( {
'autoplay': false,
'timeout': 3000,
'show': 5,
'vertical': false,
'reverse': false,
'touchevents': true,
'delayaftershow': 300,
'stepbystep': true,
'startslide': 0,
'distancetochange': 10,
'beforeshow': function () {},
'aftershow': function () {},
}, options);
return this.each(function() {
var this_slider = this;
var EasySlidesTimer;
var EasySlidesCanChange = true;
var count = $(this_slider).children('*:not(.next_button, .prev_button, .nav_indicators)').length;
var cur_slide = 0;
var mousedowned = false;
var need_slide = 0;
var slides;
if (count > 0) {
while (count < settings['show']) {
var html = $(this_slider).html();
$(html).appendTo(this_slider);
$(this_slider).children('.next_button:eq(0), .prev_button:eq(0), .nav_indicators:eq(0)').remove();
slides = $(this_slider).children('*:not(.next_button, .prev_button, .nav_indicators)');
count = $(slides).length;
}
slides = $(this_slider).children('*:not(.next_button, .prev_button, .nav_indicators)');
if ($(this_slider).children('.nav_indicators').length > 0) {
var nav_indicators = '<ul>';
while (need_slide < count) {
need_slide ++;
nav_indicators = nav_indicators + '<li>' + need_slide + '</li>';
}
nav_indicators = nav_indicators + '</ul>';
$(this_slider).children('.nav_indicators').html(nav_indicators);
need_slide = 0
}
var EasySlidesLoopToNeeded = function() {
var next;
var left = need_slide - cur_slide;
var right = cur_slide - need_slide
if (left < 0) {left = left + count;}
if (right < 0) {right = right + count;}
if (cur_slide != need_slide) {
if ((left) < (right)) {
console.log('+');
next = cur_slide + 1;
} else {
console.log('-');
next = cur_slide - 1;
}
EasySlidesNext(next);
setTimeout(EasySlidesLoopToNeeded, settings['delayaftershow']);
};
}
var EasySlidesNext = function (nextslide) {
if (EasySlidesCanChange) {
EasySlidesCanChange = false;
setTimeout(function() {EasySlidesCanChange = true;}, settings['delayaftershow']);
clearTimeout(EasySlidesTimer);
if (typeof settings['beforeshow'] == 'function') {
settings['beforeshow'];
};
var i = 0;
if (count > 0) {
if (typeof nextslide == 'number') {
cur_slide = nextslide;
} else {
cur_slide ++;
nextslide = cur_slide;
}
while (cur_slide < 0) {cur_slide = cur_slide + count;}
while (cur_slide >= count) {cur_slide = cur_slide - count;}
while (nextslide < 0) {nextslide = nextslide + count;}
while (nextslide >= count) {nextslide = nextslide - count;}
$(this_slider).children('.nav_indicators').find('ul').find('li').removeClass('active');
$(this_slider).find('.nav_indicators ul li:nth-child(' + (nextslide + 1) + ')').addClass('active');
i = 0;
/*
$(this_slider).children('*:not(.next_button, .prev_button, .nav_indicators)').each(function() {
*/
$(slides).each(function() {
var cssclass = '';
var icount = 0;
icount = i - nextslide ;
while (icount < 0) {
icount = icount + count;
};
while (icount > count) {
icount = icount - count;
};
if (icount == 0) {
cssclass = 'active';
$(this_slider).find('.' + cssclass+ ':not(.nav_indicators ul li)').removeClass(cssclass);
$(this).removeClass('hidden');
$(this).addClass(cssclass);
} else if (icount < settings['show'] / 2) {
cssclass = 'next' + icount;
$(this_slider).find('.' + cssclass).removeClass(cssclass);
$(this).removeClass('hidden');
$(this).addClass(cssclass);
} else if (icount > count - (settings['show'] / 2)) {
cssclass = 'prev' + (count - icount);
$(this_slider).find('.' + cssclass).removeClass(cssclass);
$(this).removeClass('hidden');
$(this).addClass(cssclass);
} else {
$(this).addClass('hidden');
}
i++;
});
if (settings['autoplay']) {
clearTimeout(EasySlidesTimer);
EasySlidesTimer = setTimeout(function() {
EasySlidesNext();
}, settings['timeout']);
}
}
if (typeof settings['aftershow'] == 'function') {
settings['aftershow'];
};
};
};
EasySlidesNext(settings['startslide']);
/*
$(this_slider).children(':not(.next_button, .prev_button, .nav_indicators)').click(function () {
*/
$(slides).click(function () {
need_slide = $(this_slider).children().index(this);
if (settings['stepbystep']) {
EasySlidesLoopToNeeded()
} else {
EasySlidesNext( need_slide );
}
});
$(this_slider).children('.nav_indicators').find('ul').find('li').click(function () {
need_slide = $(this_slider).find('.nav_indicators ul li').index(this);
if (settings['stepbystep']) {
EasySlidesLoopToNeeded()
} else {
EasySlidesNext( need_slide );
}
});
$(this_slider).find('.next_button').click(function() {
EasySlidesCanChange = true;
EasySlidesNext();
});
$(this_slider).find('.prev_button').click(function() {
EasySlidesCanChange = true;
cur_slide --;
EasySlidesNext(cur_slide);
});
if (settings['touchevents']) {
var EasySliderMoved = function (xcur, ycur) {
var offset = $(slides).find('.active').offset();
var left = 0;
var top = 0;
if (typeof offset !== 'undefined') {
left = offset.left;
top = offset.top;
}
var p0 = $(this_slider).data('posstart'),
p1 = { x: xcur,
y: ycur,
l: left,
t: top,
},
d = 0;
if (typeof p0 === 'undefined') {
p0 = p1;
$(this_slider).data('posstart', p1);
}
if (settings['vertical']) {
d = p1.y - p0.y;
top = p0.t + d;
//$(this_slider).find('.active:not(.nav_indicators ul li)').offset({'top': top});
} else {
d = p1.x - p0.x;
left = p0.l + d;
//$(this_slider).find('.active:not(.nav_indicators ul li)').offset({'left': left});
}
if (settings['reverse']) {
d = -d;
}
if ((Math.abs(d) > settings['distancetochange']) && (EasySlidesCanChange)) {
$(this_slider).data('posstart' , p1);
if (d > 0) {
cur_slide --;
} else {
cur_slide ++;
}
EasySlidesNext(cur_slide);
}
}
/*События*/
$(this_slider).bind('mousemove', function(e) {
e.preventDefault();
if (e.buttons > 0) {
EasySliderMoved(e.pageX , e.pageY);
mousedowned = true;
} else {
if (mousedowned) {
EasySliderMoved(e.pageX , e.pageY);
$(this_slider).removeData('posstart');
mousedowned = false;
}
}
});
$(this_slider).bind('mouseup', function(e) {
e.preventDefault();
if (mousedowned) {
EasySliderMoved(e.pageX , e.pageY);
$(this_slider).removeData('posstart');
mousedowned = false;
}
})
$(this_slider).bind('touchmove', function(e) {
e.preventDefault();
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
EasySliderMoved(touch.pageX , touch.pageY);
});
$(this_slider).bind('touchend', function(e) {
e.preventDefault();
$(this_slider).removeData('posstart');
});
}
}
});
}
})( jQuery );

View File

@@ -0,0 +1,544 @@
/*
* MultiSelect v0.9.12
* Copyright (c) 2012 Louis Cuny
*
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
*/
!function ($) {
"use strict";
/* MULTISELECT CLASS DEFINITION
* ====================== */
var MultiSelect = function (element, options) {
this.options = options;
this.$element = $(element);
this.$container = $('<div/>', { 'class': "ms-container" });
this.$selectableContainer = $('<div/>', { 'class': 'ms-selectable' });
this.$selectionContainer = $('<div/>', { 'class': 'ms-selection' });
this.$selectableUl = $('<ul/>', { 'class': "ms-list", 'tabindex' : '-1' });
this.$selectionUl = $('<ul/>', { 'class': "ms-list", 'tabindex' : '-1' });
this.scrollTo = 0;
this.elemsSelector = 'li:visible:not(.ms-optgroup-label,.ms-optgroup-container,.'+options.disabledClass+')';
};
MultiSelect.prototype = {
constructor: MultiSelect,
init: function(){
var that = this,
ms = this.$element;
if (ms.next('.ms-container').length === 0){
ms.css({ position: 'absolute', left: '-9999px' });
ms.attr('id', ms.attr('id') ? ms.attr('id') : Math.ceil(Math.random()*1000)+'multiselect');
this.$container.attr('id', 'ms-'+ms.attr('id'));
this.$container.addClass(that.options.cssClass);
ms.find('option').each(function(){
that.generateLisFromOption(this);
});
this.$selectionUl.find('.ms-optgroup-label').hide();
if (that.options.selectableHeader){
that.$selectableContainer.append(that.options.selectableHeader);
}
that.$selectableContainer.append(that.$selectableUl);
if (that.options.selectableFooter){
that.$selectableContainer.append(that.options.selectableFooter);
}
if (that.options.selectionHeader){
that.$selectionContainer.append(that.options.selectionHeader);
}
that.$selectionContainer.append(that.$selectionUl);
if (that.options.selectionFooter){
that.$selectionContainer.append(that.options.selectionFooter);
}
that.$container.append(that.$selectableContainer);
that.$container.append(that.$selectionContainer);
ms.after(that.$container);
that.activeMouse(that.$selectableUl);
that.activeKeyboard(that.$selectableUl);
var action = that.options.dblClick ? 'dblclick' : 'click';
that.$selectableUl.on(action, '.ms-elem-selectable', function(){
that.select($(this).data('ms-value'));
});
that.$selectionUl.on(action, '.ms-elem-selection', function(){
that.deselect($(this).data('ms-value'));
});
that.activeMouse(that.$selectionUl);
that.activeKeyboard(that.$selectionUl);
ms.on('focus', function(){
that.$selectableUl.focus();
});
}
var selectedValues = ms.find('option:selected').map(function(){ return $(this).val(); }).get();
that.select(selectedValues, 'init');
if (typeof that.options.afterInit === 'function') {
that.options.afterInit.call(this, this.$container);
}
},
'generateLisFromOption' : function(option, index, $container){
var that = this,
ms = that.$element,
attributes = "",
$option = $(option);
for (var cpt = 0; cpt < option.attributes.length; cpt++){
var attr = option.attributes[cpt];
if(attr.name !== 'value' && attr.name !== 'disabled'){
attributes += attr.name+'="'+attr.value+'" ';
}
}
var selectableLi = $('<li '+attributes+'><span>'+that.escapeHTML($option.text())+'</span></li>'),
selectedLi = selectableLi.clone(),
value = $option.val(),
elementId = that.sanitize(value);
selectableLi
.data('ms-value', value)
.addClass('ms-elem-selectable')
.attr('id', elementId+'-selectable');
selectedLi
.data('ms-value', value)
.addClass('ms-elem-selection')
.attr('id', elementId+'-selection')
.hide();
if ($option.prop('disabled') || ms.prop('disabled')){
selectedLi.addClass(that.options.disabledClass);
selectableLi.addClass(that.options.disabledClass);
}
var $optgroup = $option.parent('optgroup');
if ($optgroup.length > 0){
var optgroupLabel = $optgroup.attr('label'),
optgroupId = that.sanitize(optgroupLabel),
$selectableOptgroup = that.$selectableUl.find('#optgroup-selectable-'+optgroupId),
$selectionOptgroup = that.$selectionUl.find('#optgroup-selection-'+optgroupId);
if ($selectableOptgroup.length === 0){
var optgroupContainerTpl = '<li class="ms-optgroup-container"></li>',
optgroupTpl = '<ul class="ms-optgroup"><li class="ms-optgroup-label"><span>'+optgroupLabel+'</span></li></ul>';
$selectableOptgroup = $(optgroupContainerTpl);
$selectionOptgroup = $(optgroupContainerTpl);
$selectableOptgroup.attr('id', 'optgroup-selectable-'+optgroupId);
$selectionOptgroup.attr('id', 'optgroup-selection-'+optgroupId);
$selectableOptgroup.append($(optgroupTpl));
$selectionOptgroup.append($(optgroupTpl));
if (that.options.selectableOptgroup){
$selectableOptgroup.find('.ms-optgroup-label').on('click', function(){
var values = $optgroup.children(':not(:selected, :disabled)').map(function(){ return $(this).val();}).get();
that.select(values);
});
$selectionOptgroup.find('.ms-optgroup-label').on('click', function(){
var values = $optgroup.children(':selected:not(:disabled)').map(function(){ return $(this).val();}).get();
that.deselect(values);
});
}
that.$selectableUl.append($selectableOptgroup);
that.$selectionUl.append($selectionOptgroup);
}
index = index === undefined ? $selectableOptgroup.find('ul').children().length : index + 1;
selectableLi.insertAt(index, $selectableOptgroup.children());
selectedLi.insertAt(index, $selectionOptgroup.children());
} else {
index = index === undefined ? that.$selectableUl.children().length : index;
selectableLi.insertAt(index, that.$selectableUl);
selectedLi.insertAt(index, that.$selectionUl);
}
},
'addOption' : function(options){
var that = this;
if (options.value !== undefined && options.value !== null){
options = [options];
}
$.each(options, function(index, option){
if (option.value !== undefined && option.value !== null &&
that.$element.find("option[value='"+option.value+"']").length === 0){
var $option = $('<option value="'+option.value+'">'+option.text+'</option>'),
$container = option.nested === undefined ? that.$element : $("optgroup[label='"+option.nested+"']"),
index = parseInt((typeof option.index === 'undefined' ? $container.children().length : option.index));
if (option.optionClass) {
$option.addClass(option.optionClass);
}
if (option.disabled) {
$option.prop('disabled', true);
}
$option.insertAt(index, $container);
that.generateLisFromOption($option.get(0), index, option.nested);
}
});
},
'escapeHTML' : function(text){
return $("<div>").text(text).html();
},
'activeKeyboard' : function($list){
var that = this;
$list.on('focus', function(){
$(this).addClass('ms-focus');
})
.on('blur', function(){
$(this).removeClass('ms-focus');
})
.on('keydown', function(e){
switch (e.which) {
case 40:
case 38:
e.preventDefault();
e.stopPropagation();
that.moveHighlight($(this), (e.which === 38) ? -1 : 1);
return;
case 37:
case 39:
e.preventDefault();
e.stopPropagation();
that.switchList($list);
return;
case 9:
if(that.$element.is('[tabindex]')){
e.preventDefault();
var tabindex = parseInt(that.$element.attr('tabindex'), 10);
tabindex = (e.shiftKey) ? tabindex-1 : tabindex+1;
$('[tabindex="'+(tabindex)+'"]').focus();
return;
}else{
if(e.shiftKey){
that.$element.trigger('focus');
}
}
}
if($.inArray(e.which, that.options.keySelect) > -1){
e.preventDefault();
e.stopPropagation();
that.selectHighlighted($list);
return;
}
});
},
'moveHighlight': function($list, direction){
var $elems = $list.find(this.elemsSelector),
$currElem = $elems.filter('.ms-hover'),
$nextElem = null,
elemHeight = $elems.first().outerHeight(),
containerHeight = $list.height(),
containerSelector = '#'+this.$container.prop('id');
$elems.removeClass('ms-hover');
if (direction === 1){ // DOWN
$nextElem = $currElem.nextAll(this.elemsSelector).first();
if ($nextElem.length === 0){
var $optgroupUl = $currElem.parent();
if ($optgroupUl.hasClass('ms-optgroup')){
var $optgroupLi = $optgroupUl.parent(),
$nextOptgroupLi = $optgroupLi.next(':visible');
if ($nextOptgroupLi.length > 0){
$nextElem = $nextOptgroupLi.find(this.elemsSelector).first();
} else {
$nextElem = $elems.first();
}
} else {
$nextElem = $elems.first();
}
}
} else if (direction === -1){ // UP
$nextElem = $currElem.prevAll(this.elemsSelector).first();
if ($nextElem.length === 0){
var $optgroupUl = $currElem.parent();
if ($optgroupUl.hasClass('ms-optgroup')){
var $optgroupLi = $optgroupUl.parent(),
$prevOptgroupLi = $optgroupLi.prev(':visible');
if ($prevOptgroupLi.length > 0){
$nextElem = $prevOptgroupLi.find(this.elemsSelector).last();
} else {
$nextElem = $elems.last();
}
} else {
$nextElem = $elems.last();
}
}
}
if ($nextElem.length > 0){
$nextElem.addClass('ms-hover');
var scrollTo = $list.scrollTop() + $nextElem.position().top -
containerHeight / 2 + elemHeight / 2;
$list.scrollTop(scrollTo);
}
},
'selectHighlighted' : function($list){
var $elems = $list.find(this.elemsSelector),
$highlightedElem = $elems.filter('.ms-hover').first();
if ($highlightedElem.length > 0){
if ($list.parent().hasClass('ms-selectable')){
this.select($highlightedElem.data('ms-value'));
} else {
this.deselect($highlightedElem.data('ms-value'));
}
$elems.removeClass('ms-hover');
}
},
'switchList' : function($list){
$list.blur();
this.$container.find(this.elemsSelector).removeClass('ms-hover');
if ($list.parent().hasClass('ms-selectable')){
this.$selectionUl.focus();
} else {
this.$selectableUl.focus();
}
},
'activeMouse' : function($list){
var that = this;
this.$container.on('mouseenter', that.elemsSelector, function(){
$(this).parents('.ms-container').find(that.elemsSelector).removeClass('ms-hover');
$(this).addClass('ms-hover');
});
this.$container.on('mouseleave', that.elemsSelector, function () {
$(this).parents('.ms-container').find(that.elemsSelector).removeClass('ms-hover');
});
},
'refresh' : function() {
this.destroy();
this.$element.multiSelect(this.options);
},
'destroy' : function(){
$("#ms-"+this.$element.attr("id")).remove();
this.$element.off('focus');
this.$element.css('position', '').css('left', '');
this.$element.removeData('multiselect');
},
'select' : function(value, method){
if (typeof value === 'string'){ value = [value]; }
var that = this,
ms = this.$element,
msIds = $.map(value, function(val){ return(that.sanitize(val)); }),
selectables = this.$selectableUl.find('#' + msIds.join('-selectable, #')+'-selectable').filter(':not(.'+that.options.disabledClass+')'),
selections = this.$selectionUl.find('#' + msIds.join('-selection, #') + '-selection').filter(':not(.'+that.options.disabledClass+')'),
options = ms.find('option:not(:disabled)').filter(function(){ return($.inArray(this.value, value) > -1); });
if (method === 'init'){
selectables = this.$selectableUl.find('#' + msIds.join('-selectable, #')+'-selectable'),
selections = this.$selectionUl.find('#' + msIds.join('-selection, #') + '-selection');
}
if (selectables.length > 0){
selectables.addClass('ms-selected').hide();
selections.addClass('ms-selected').show();
options.prop('selected', true);
that.$container.find(that.elemsSelector).removeClass('ms-hover');
var selectableOptgroups = that.$selectableUl.children('.ms-optgroup-container');
if (selectableOptgroups.length > 0){
selectableOptgroups.each(function(){
var selectablesLi = $(this).find('.ms-elem-selectable');
if (selectablesLi.length === selectablesLi.filter('.ms-selected').length){
$(this).find('.ms-optgroup-label').hide();
}
});
var selectionOptgroups = that.$selectionUl.children('.ms-optgroup-container');
selectionOptgroups.each(function(){
var selectionsLi = $(this).find('.ms-elem-selection');
if (selectionsLi.filter('.ms-selected').length > 0){
$(this).find('.ms-optgroup-label').show();
}
});
} else {
if (that.options.keepOrder && method !== 'init'){
var selectionLiLast = that.$selectionUl.find('.ms-selected');
if((selectionLiLast.length > 1) && (selectionLiLast.last().get(0) != selections.get(0))) {
selections.insertAfter(selectionLiLast.last());
}
}
}
if (method !== 'init'){
ms.trigger('change');
if (typeof that.options.afterSelect === 'function') {
that.options.afterSelect.call(this, value);
}
}
}
},
'deselect' : function(value){
if (typeof value === 'string'){ value = [value]; }
var that = this,
ms = this.$element,
msIds = $.map(value, function(val){ return(that.sanitize(val)); }),
selectables = this.$selectableUl.find('#' + msIds.join('-selectable, #')+'-selectable'),
selections = this.$selectionUl.find('#' + msIds.join('-selection, #')+'-selection').filter('.ms-selected').filter(':not(.'+that.options.disabledClass+')'),
options = ms.find('option').filter(function(){ return($.inArray(this.value, value) > -1); });
if (selections.length > 0){
selectables.removeClass('ms-selected').show();
selections.removeClass('ms-selected').hide();
options.prop('selected', false);
that.$container.find(that.elemsSelector).removeClass('ms-hover');
var selectableOptgroups = that.$selectableUl.children('.ms-optgroup-container');
if (selectableOptgroups.length > 0){
selectableOptgroups.each(function(){
var selectablesLi = $(this).find('.ms-elem-selectable');
if (selectablesLi.filter(':not(.ms-selected)').length > 0){
$(this).find('.ms-optgroup-label').show();
}
});
var selectionOptgroups = that.$selectionUl.children('.ms-optgroup-container');
selectionOptgroups.each(function(){
var selectionsLi = $(this).find('.ms-elem-selection');
if (selectionsLi.filter('.ms-selected').length === 0){
$(this).find('.ms-optgroup-label').hide();
}
});
}
ms.trigger('change');
if (typeof that.options.afterDeselect === 'function') {
that.options.afterDeselect.call(this, value);
}
}
},
'select_all' : function(){
var ms = this.$element,
values = ms.val();
ms.find('option:not(":disabled")').prop('selected', true);
this.$selectableUl.find('.ms-elem-selectable').filter(':not(.'+this.options.disabledClass+')').addClass('ms-selected').hide();
this.$selectionUl.find('.ms-optgroup-label').show();
this.$selectableUl.find('.ms-optgroup-label').hide();
this.$selectionUl.find('.ms-elem-selection').filter(':not(.'+this.options.disabledClass+')').addClass('ms-selected').show();
this.$selectionUl.focus();
ms.trigger('change');
if (typeof this.options.afterSelect === 'function') {
var selectedValues = $.grep(ms.val(), function(item){
return $.inArray(item, values) < 0;
});
this.options.afterSelect.call(this, selectedValues);
}
},
'deselect_all' : function(){
var ms = this.$element,
values = ms.val();
ms.find('option').prop('selected', false);
this.$selectableUl.find('.ms-elem-selectable').removeClass('ms-selected').show();
this.$selectionUl.find('.ms-optgroup-label').hide();
this.$selectableUl.find('.ms-optgroup-label').show();
this.$selectionUl.find('.ms-elem-selection').removeClass('ms-selected').hide();
this.$selectableUl.focus();
ms.trigger('change');
if (typeof this.options.afterDeselect === 'function') {
this.options.afterDeselect.call(this, values);
}
},
sanitize: function(value){
var hash = 0, i, character;
if (value.length == 0) return hash;
var ls = 0;
for (i = 0, ls = value.length; i < ls; i++) {
character = value.charCodeAt(i);
hash = ((hash<<5)-hash)+character;
hash |= 0; // Convert to 32bit integer
}
return hash;
}
};
/* MULTISELECT PLUGIN DEFINITION
* ======================= */
$.fn.multiSelect = function () {
var option = arguments[0],
args = arguments;
return this.each(function () {
var $this = $(this),
data = $this.data('multiselect'),
options = $.extend({}, $.fn.multiSelect.defaults, $this.data(), typeof option === 'object' && option);
if (!data){ $this.data('multiselect', (data = new MultiSelect(this, options))); }
if (typeof option === 'string'){
data[option](args[1]);
} else {
data.init();
}
});
};
$.fn.multiSelect.defaults = {
keySelect: [32],
selectableOptgroup: false,
disabledClass : 'disabled',
dblClick : false,
keepOrder: false,
cssClass: ''
};
$.fn.multiSelect.Constructor = MultiSelect;
$.fn.insertAt = function(index, $parent) {
return this.each(function() {
if (index === 0) {
$parent.prepend(this);
} else {
$parent.children().eq(index - 1).after(this);
}
});
};
}(window.jQuery);

View File

@@ -0,0 +1,143 @@
(function($) {
var options = {};
$.fn.gs_multiselect = function(params) {
options = $.extend({}, $.fn.gs_multiselect.defaults, params);
return this.each(function() {
var list_options={};
var list_names={};
var idx={};
var rw=Math.min(400,this.offsetWidth);
var rh=this.offsetHeight;
var t=document.createElement('table');
var to_sel=this.parentNode.replaceChild(t,this);
var from_sel=$('<select multiple="multiple"></select>').get(0);
var r=t.insertRow(0);
if (options.buttons) {
var c1=r.insertCell(0);
var c2=r.insertCell(1);
var c3=r.insertCell(2);
var btl_all=$('<input type="button" value="+">').get(0);
//var tl_filter=$('<input type="text">').get(0);
//c1.appendChild(tl_filter);
c1.appendChild(btl_all);
var btr_all=btl_all.cloneNode(true);
c3.appendChild(btr_all);
btl_all.onclick=function () {
$('option',from_sel).each(function() {this.selected=!this.selected;});
$('option',to_sel).attr('selected',false);
}
btr_all.onclick=function () {
$('option',from_sel).attr('selected',false);
$('option',to_sel).each(function() {this.selected=!this.selected;});
}
r=t.insertRow(1);
}
var fc=r.insertCell(0);
var mc=r.insertCell(1);
var lc=r.insertCell(2);
var o_lc=lc;
lc.appendChild(to_sel);
$(fc).append($(from_sel));
//var from_sel=fc.firstChild;
var sel_name=to_sel.getAttribute('name');
to_sel.setAttribute('name','');
$(from_sel).html($(to_sel).html());
$(this).html('');
from_sel.style.height=to_sel.style.height=rh+'px';
from_sel.style.width=to_sel.style.width=rw+'px';
var fb=$('<input type="button" value="&raquo;">');
var bb=$('<input type="button" value="&laquo;">');
mc.appendChild(fb.get(0));
mc.appendChild(document.createElement('br'));
mc.appendChild(bb.get(0));
var list=from_sel.cloneNode(true);
//if (list.innerHTML!='') $(list).filter('option').each(function (i) {
if (list.innerHTML!='') $('option',list).each(function (i) {
list_options[this.value]=i;
list_names[i]=this.innerHTML;
})
// start of functions
fbutton=function (){
var ol=[];
var os=from_sel.getElementsByTagName('option');
for (var key=0;key<os.length;key++) {
if (os[key].selected) {
ol.push(os[key]);
idx[os[key].value]=list_options[os[key].value];
}
}
for (var key=0;key<ol.length;key++) {
var n=from_sel.removeChild(ol[key]);
}
to_sel.innerHTML='';
$('input',o_lc).remove();
for (key in list_options) {
var add=false;
for (i in idx) {
if (list_options[key]==idx[i]) {
add=true;
break;
}
}
if (add) {
to_sel.appendChild($('<option value="'+key+'">'+list_names[list_options[key]]+'</option>').get(0));
o_lc.appendChild($('<input type="hidden" name="'+sel_name+'" value="'+key+'">').get(0));
}
}
}
bbutton=function (){
var ol=[];
var os=to_sel.getElementsByTagName('option');
for (var key=os.length-1;key>=0;key--) {
if (os[key].selected) {
ol.push(os[key]);
to_sel.removeChild(os[key]);
}
}
idx={};
var os=to_sel.getElementsByTagName('option');
for (var key=0;key<os.length;key++) {
idx[os[key].value]=list_options[os[key].value];
}
from_sel.innerHTML='';
$('input',o_lc).remove();
for (key in list_options) {
var add=true;
for (i in idx) {
if (list_options[key]==idx[i]) {
add=false;
break;
}
}
if (add) {
from_sel.appendChild($('<option value="'+key+'">'+list_names[list_options[key]]+'</option>').get(0));
} else {
o_lc.appendChild($('<input type="hidden" name="'+sel_name+'" value="'+key+'">').get(0));
}
}
}
// end of functions
fb.click(fbutton);
bb.click(bbutton);
$(from_sel).dblclick(fbutton);
$(to_sel).dblclick(bbutton);
fbutton();
});
};
$.fn.gs_multiselect.defaults = {
};
})(jQuery);

View File

@@ -0,0 +1,181 @@
(function($, window, document, undefined) {
$.fn.quicksearch = function (target, opt) {
var timeout, cache, rowcache, jq_results, val = '', e = this, options = $.extend({
delay: 100,
selector: null,
stripeRows: null,
loader: null,
noResults: '',
matchedResultsCount: 0,
bind: 'keyup',
onBefore: function () {
return;
},
onAfter: function () {
return;
},
show: function () {
this.style.display = "";
},
hide: function () {
this.style.display = "none";
},
prepareQuery: function (val) {
return val.toLowerCase().split(' ');
},
testQuery: function (query, txt, _row) {
for (var i = 0; i < query.length; i += 1) {
if (txt.indexOf(query[i]) === -1) {
return false;
}
}
return true;
}
}, opt);
this.go = function () {
var i = 0,
numMatchedRows = 0,
noresults = true,
query = options.prepareQuery(val),
val_empty = (val.replace(' ', '').length === 0);
for (var i = 0, len = rowcache.length; i < len; i++) {
if (val_empty || options.testQuery(query, cache[i], rowcache[i])) {
options.show.apply(rowcache[i]);
noresults = false;
numMatchedRows++;
} else {
options.hide.apply(rowcache[i]);
}
}
if (noresults) {
this.results(false);
} else {
this.results(true);
this.stripe();
}
this.matchedResultsCount = numMatchedRows;
this.loader(false);
options.onAfter();
return this;
};
/*
* External API so that users can perform search programatically.
* */
this.search = function (submittedVal) {
val = submittedVal;
e.trigger();
};
/*
* External API to get the number of matched results as seen in
* https://github.com/ruiz107/quicksearch/commit/f78dc440b42d95ce9caed1d087174dd4359982d6
* */
this.currentMatchedResults = function() {
return this.matchedResultsCount;
};
this.stripe = function () {
if (typeof options.stripeRows === "object" && options.stripeRows !== null)
{
var joined = options.stripeRows.join(' ');
var stripeRows_length = options.stripeRows.length;
jq_results.not(':hidden').each(function (i) {
$(this).removeClass(joined).addClass(options.stripeRows[i % stripeRows_length]);
});
}
return this;
};
this.strip_html = function (input) {
var output = input.replace(new RegExp('<[^<]+\>', 'g'), "");
output = $.trim(output.toLowerCase());
return output;
};
this.results = function (bool) {
if (typeof options.noResults === "string" && options.noResults !== "") {
if (bool) {
$(options.noResults).hide();
} else {
$(options.noResults).show();
}
}
return this;
};
this.loader = function (bool) {
if (typeof options.loader === "string" && options.loader !== "") {
(bool) ? $(options.loader).show() : $(options.loader).hide();
}
return this;
};
this.cache = function () {
jq_results = $(target);
if (typeof options.noResults === "string" && options.noResults !== "") {
jq_results = jq_results.not(options.noResults);
}
var t = (typeof options.selector === "string") ? jq_results.find(options.selector) : $(target).not(options.noResults);
cache = t.map(function () {
return e.strip_html(this.innerHTML);
});
rowcache = jq_results.map(function () {
return this;
});
/*
* Modified fix for sync-ing "val".
* Original fix https://github.com/michaellwest/quicksearch/commit/4ace4008d079298a01f97f885ba8fa956a9703d1
* */
val = val || this.val() || "";
return this.go();
};
this.trigger = function () {
this.loader(true);
options.onBefore();
window.clearTimeout(timeout);
timeout = window.setTimeout(function () {
e.go();
}, options.delay);
return this;
};
this.cache();
this.results(true);
this.stripe();
this.loader(false);
return this.each(function () {
/*
* Changed from .bind to .on.
* */
$(this).on(options.bind, function () {
val = $(this).val();
e.trigger();
});
});
};
}(jQuery, this, document));