Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
shirne committed Aug 17, 2024
1 parent 5f4117e commit ede5c57
Show file tree
Hide file tree
Showing 20 changed files with 1,278 additions and 1,031 deletions.
58 changes: 29 additions & 29 deletions resource/js/front.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
function setNav(nav) {
var current=findCurrentNav(nav);

var current = findCurrentNav(nav);
setNavHover(current);

var intval=0;
$('.nav-box .navbar-collapse').hover(function(){
var intval = 0;
$('.nav-box .navbar-collapse').hover(function () {
clearInterval(intval)
},function(){
intval = setInterval(function(){
}, function () {
intval = setInterval(function () {
setNavHover(current);
},500)
}, 500)
})
$('.nav-box .nav-item').hover(function(){
$('.nav-box .nav-item').hover(function () {
var index = $('.main-nav .nav-item').index(this);
setNavHover(index);
},function(){
}, function () {

})
}

function setNavHover(index){
var items=$('.main-nav .nav-item');
function setNavHover(index) {
var items = $('.main-nav .nav-item');
items.removeClass('active prev-hover')
items.eq(index).addClass('active');
$('.main-nav .nav-item.active').prev().addClass('prev-hover');

$('.nav-box .nav-bg').css('right',(items.length-index-1)*items.eq(0).outerWidth())
$('.nav-box .nav-bg').css('right', (items.length - index - 1) * items.eq(0).outerWidth())
}

function findCurrentNav(nav){
var items=$('.main-nav .nav-item');
for(var i=0;i<items.length;i++){
if(items.eq(i).data('model')===nav){
function findCurrentNav(nav) {
var items = $('.main-nav .nav-item');

for (var i = 0; i < items.length; i++) {
if (items.eq(i).data('model') === nav) {
return i;
}
}
var pnav=nav.substr(0,nav.lastIndexOf('-'));
if(pnav == nav || !pnav){
var pnav = nav.substr(0, nav.lastIndexOf('-'));
if (pnav == nav || !pnav) {
return 0;
}
return findCurrentNav(pnav);
}

jQuery(function($){
if($(window).width()>=991){
jQuery(function ($) {
if ($(window).width() >= 991) {
$('.main-nav>.dropdown').hover(
function () {
$(this).find('.dropdown-menu').stop(true,false).slideDown();
$(this).find('.dropdown-menu').stop(true, false).slideDown();
},
function () {
$(this).find('.dropdown-menu').stop(true,false).slideUp();
$(this).find('.dropdown-menu').stop(true, false).slideUp();
}
);
}else{
} else {
$('.main-nav>.dropdown>.dropdown-toggle').click(function (e) {
e.preventDefault();
e.stopPropagation();
var opened=$(this).data('opened');
var opened = $(this).data('opened');
var p = $(this).parents('.dropdown');
if(opened){
if (opened) {
p.find('.dropdown-menu').stop(true, false).slideUp();
}else {
} else {
p.siblings().children('.dropdown-menu').stop(true, false).slideUp();
p.siblings().children('.dropdown-toggle').data('opened',false);
p.siblings().children('.dropdown-toggle').data('opened', false);
p.find('.dropdown-menu').stop(true, false).slideDown();
}
$(this).data('opened',!opened);
$(this).data('opened', !opened);
})
}
});
2 changes: 1 addition & 1 deletion resource/js/mobile.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
jQuery(function($){
jQuery(function ($) {
$('');
});
28 changes: 14 additions & 14 deletions resource/js/model/common.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
function del(obj,msg) {
dialog.confirm(msg,function(){
location.href=$(obj).attr('href');
function del(obj, msg) {
dialog.confirm(msg, function () {
location.href = $(obj).attr('href');
});
return false;
}

function lang(key) {
if(window.language && window.language[key]){
if (window.language && window.language[key]) {
return window.language[key];
}
return key;
}

function randomString(len, charSet) {
charSet = charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var str = '',allLen=charSet.length;
var str = '', allLen = charSet.length;
for (var i = 0; i < len; i++) {
var randomPoz = Math.floor(Math.random() * allLen);
str += charSet.substring(randomPoz,randomPoz+1);
str += charSet.substring(randomPoz, randomPoz + 1);
}
return str;
}

function copy_obj(arr){
function copy_obj(arr) {
return JSON.parse(JSON.stringify(arr));
}

function isObjectValueEqual(a, b) {
if(!a && !b)return true;
if(!a || !b)return false;
if (!a && !b) return true;
if (!a || !b) return false;

// Of course, we can do it use for in
// Create arrays of property names
Expand Down Expand Up @@ -56,11 +56,11 @@ function isObjectValueEqual(a, b) {
return true;
}

function array_combine(a,b) {
var obj={};
for(var i=0;i<a.length;i++){
if(b.length<i+1)break;
obj[a[i]]=b[i];
function array_combine(a, b) {
var obj = {};
for (var i = 0; i < a.length; i++) {
if (b.length < i + 1) break;
obj[a[i]] = b[i];
}
return obj;
}
54 changes: 27 additions & 27 deletions resource/js/model/jquery.tag.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@

jQuery.extend(jQuery.fn,{
tags:function(nm,onupdate){
var data=[];
var tpl='<span class="badge badge-info">{@label}<input type="hidden" name="'+nm+'" value="{@label}"/><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></span>';
var item=$(this).parents('.form-control');
var labelgroup=$('<span class="badge-group"></span>');
var input=this;
jQuery.extend(jQuery.fn, {
tags: function (nm, onupdate) {
var data = [];
var tpl = '<span class="badge badge-info">{@label}<input type="hidden" name="' + nm + '" value="{@label}"/><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></span>';
var item = $(this).parents('.form-control');
var labelgroup = $('<span class="badge-group"></span>');
var input = this;
this.before(labelgroup);
this.on('keyup',function(){
var val=$(this).val().replace(//g,',');
var updated=false;
if(val && val.indexOf(',')>-1){
var vals=val.split(',');
for(var i=0;i<vals.length;i++){
vals[i]=vals[i].replace(/^\s|\s$/g,'');
if(vals[i] && data.indexOf(vals[i])===-1){
this.on('keyup', function () {
var val = $(this).val().replace(//g, ',');
var updated = false;
if (val && val.indexOf(',') > -1) {
var vals = val.split(',');
for (var i = 0; i < vals.length; i++) {
vals[i] = vals[i].replace(/^\s|\s$/g, '');
if (vals[i] && data.indexOf(vals[i]) === -1) {
data.push(vals[i]);
labelgroup.append(tpl.compile({label:vals[i]}));
updated=true;
labelgroup.append(tpl.compile({ label: vals[i] }));
updated = true;
}
}
input.val('');
if(updated && onupdate)onupdate(data);
if (updated && onupdate) onupdate(data);
}
}).on('blur',function(){
var val=$(this).val();
if(val) {
}).on('blur', function () {
var val = $(this).val();
if (val) {
$(this).val(val + ',').trigger('keyup');
}
}).trigger('blur');
labelgroup.on('click','.close',function(){
var tag=$(this).parents('.badge').find('input').val();
var id=data.indexOf(tag);
if(id)data.splice(id,1);
labelgroup.on('click', '.close', function () {
var tag = $(this).parents('.badge').find('input').val();
var id = data.indexOf(tag);
if (id) data.splice(id, 1);
$(this).parents('.badge').remove();
if(onupdate)onupdate(data);
if (onupdate) onupdate(data);
});
item.click(function(){
item.click(function () {
input.focus();
});
}
Expand Down
84 changes: 42 additions & 42 deletions resource/js/model/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,70 +56,70 @@
* s2-默认选中的市名称,用法同上。
* s3-默认选中的县区名称,用法同省。
*/
(function($) {
$.fn.jChinaArea = function(o) {
(function ($) {
$.fn.jChinaArea = function (o) {
o = $.extend({
aspnet:false,
s1:null,
s2:null,
s3:null,
onEmpty:function(){}
}, o || {});
var wrap=$(this);
var sel=$("select",wrap);
var sProvince=sel.eq(0);
var sCity=sel.eq(1);
var sCounty=sel.eq(2);
var loc = new Location();
aspnet: false,
s1: null,
s2: null,
s3: null,
onEmpty: function () { }
}, o || {});
var wrap = $(this);
var sel = $("select", wrap);
var sProvince = sel.eq(0);
var sCity = sel.eq(1);
var sCounty = sel.eq(2);
var loc = new Location();

sProvince.empty();
sCity.empty();
sCounty.empty();
loc.fillOption(sProvince , '0',o.s1);
loc.fillOption(sCity , '0,'+sProvince.val(),o.s2);
o.onEmpty(sCity);
loc.fillOption(sCounty , '0,' + sProvince.val() + ',' + sCity.val(),o.s3);
o.onEmpty(sCounty);
loc.fillOption(sProvince, '0', o.s1);
loc.fillOption(sCity, '0,' + sProvince.val(), o.s2);
o.onEmpty(sCity);
loc.fillOption(sCounty, '0,' + sProvince.val() + ',' + sCity.val(), o.s3);
o.onEmpty(sCounty);

if(o.aspnet){
var input=$("input",wrap);
var tProvince=input.eq(0);
var tCity=input.eq(1);
var tCounty=input.eq(2);
if (o.aspnet) {
var input = $("input", wrap);
var tProvince = input.eq(0);
var tCity = input.eq(1);
var tCounty = input.eq(2);
writeInput();
}
sProvince.change(function() {

sProvince.change(function () {
sCity.empty();
loc.fillOption(sCity , '0,'+sProvince.val());
o.onEmpty(sCity);
loc.fillOption(sCity, '0,' + sProvince.val());
o.onEmpty(sCity);
sCounty.empty();
loc.fillOption(sCounty , '0,' + sProvince.val() + ',' + sCity.val());
o.onEmpty(sCounty);
if(o.aspnet){
loc.fillOption(sCounty, '0,' + sProvince.val() + ',' + sCity.val());
o.onEmpty(sCounty);
if (o.aspnet) {
writeInput();
}
});

sCity.change(function() {
sCity.change(function () {
sCounty.empty();
loc.fillOption(sCounty , '0,' + sProvince.val() + ',' + sCity.val());
o.onEmpty(sCounty);
if(o.aspnet){
loc.fillOption(sCounty, '0,' + sProvince.val() + ',' + sCity.val());
o.onEmpty(sCounty);
if (o.aspnet) {
writeInput();
}
});
sCounty.change(function(){
if(o.aspnet){
sCounty.change(function () {
if (o.aspnet) {
writeInput();
}
});

function writeInput(){
tProvince.val($(":selected",sProvince).text());
tCity.val($(":selected",sCity).text());
tCounty.val($(":selected",sCounty).text());
function writeInput() {
tProvince.val($(":selected", sProvince).text());
tCity.val($(":selected", sCity).text());
tCounty.val($(":selected", sCounty).text());
}
};

})(jQuery);
Loading

0 comments on commit ede5c57

Please sign in to comment.