mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
modified 修复固定布局的bug,优化table的生成,优化refresh调用方式
This commit is contained in:
parent
d3091a140f
commit
68fee5803f
@ -66,7 +66,7 @@ class Base extends Controller {
|
||||
if( $sidOld != $sidNow ){
|
||||
$this->error("您的账号在别的地方登录了,请重新登录!", url('User/login'));
|
||||
}else{
|
||||
// cache($this->uid, $sidNow, config('online_time'));
|
||||
cache($this->uid, $sidNow, config('online_time'));
|
||||
// $this->userInfo = User::get([ $this->primaryKey => $this->uid ]);
|
||||
// if( $this->userInfo['updateTime'] === 0 ){
|
||||
// $this->error('初次登录请重置用户密码!', url('User/changePassWord'));
|
||||
|
@ -115,14 +115,111 @@ class Menu extends Base {
|
||||
}
|
||||
|
||||
public function add(){
|
||||
$form = [
|
||||
'formAttr' => [
|
||||
'action' => '',
|
||||
'id' => '',
|
||||
if( $this->request->isPost() ){
|
||||
|
||||
],
|
||||
];
|
||||
$this->result($form, ReturnCode::GET_TEMPLATE_SUCCESS);
|
||||
}else{
|
||||
$form = [
|
||||
'tempType' => 'add',
|
||||
'formAttr' => [
|
||||
'target' => '',
|
||||
'formId' => '',
|
||||
'backUrl' => '',
|
||||
],
|
||||
'formList' => [
|
||||
[
|
||||
'module' => 'text',
|
||||
'description' => '',
|
||||
'info' => '菜单名称:',
|
||||
'attr' => [
|
||||
'name' => 'name',
|
||||
'value' => '',
|
||||
'placeholder' => ''
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'select',
|
||||
'description' => '',
|
||||
'info' => '父级菜单:',
|
||||
'attr' => [
|
||||
'name' => 'fid',
|
||||
'value' => '',
|
||||
'options' => []
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'select',
|
||||
'description' => '',
|
||||
'info' => '菜单等级:',
|
||||
'attr' => [
|
||||
'name' => 'level',
|
||||
'value' => '',
|
||||
'options' => []
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'radio',
|
||||
'description' => '',
|
||||
'info' => '菜单类型:',
|
||||
'attr' => [
|
||||
'name' => 'type',
|
||||
'value' => '',
|
||||
'options' => []
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'radio',
|
||||
'description' => '',
|
||||
'info' => '是否显示:「该配置只对模块类功能生效」',
|
||||
'attr' => [
|
||||
'name' => 'hide',
|
||||
'value' => '',
|
||||
'options' => []
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'radio',
|
||||
'description' => '',
|
||||
'info' => '是否推荐:「该配置只对模块类功能生效」',
|
||||
'attr' => [
|
||||
'name' => 'recommend',
|
||||
'value' => '',
|
||||
'options' => []
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'text',
|
||||
'description' => '',
|
||||
'info' => '菜单图标:「该配置只对模块类功能生效」',
|
||||
'attr' => [
|
||||
'name' => 'icon',
|
||||
'value' => '',
|
||||
'placeholder' => ''
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'text',
|
||||
'description' => '',
|
||||
'info' => '菜单URL:「该配置只对无模块类功能子菜单的菜单生效」[具体格式为:控制器/方法名]',
|
||||
'attr' => [
|
||||
'name' => 'url',
|
||||
'value' => '',
|
||||
'placeholder' => ''
|
||||
]
|
||||
],
|
||||
[
|
||||
'module' => 'text',
|
||||
'description' => '',
|
||||
'info' => '排序:「数字越小顺序越靠前」',
|
||||
'attr' => [
|
||||
'name' => 'order',
|
||||
'value' => '',
|
||||
'placeholder' => ''
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
$this->result($form, ReturnCode::GET_TEMPLATE_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
|
@ -331,7 +331,7 @@
|
||||
</span>
|
||||
</a>
|
||||
<ul class="treeview-menu">
|
||||
<li class="active"><a href="javascript:refresh('{:url(\'Menu/index\')}');" ><i class="fa fa-circle-o"></i> 菜单管理</a></li>
|
||||
<li class="active"><a url="{:url('Menu/index')}" class="refresh"><i class="fa fa-circle-o"></i> 菜单管理</a></li>
|
||||
<li><a href="javascript:void(0);"><i class="fa fa-circle-o"></i> 用户管理</a></li>
|
||||
<li><a href="javascript:void(0);"><i class="fa fa-circle-o"></i> 权限管理</a></li>
|
||||
<li><a href="javascript:void(0);"><i class="fa fa-circle-o"></i> 操作日志</a></li>
|
||||
@ -592,14 +592,17 @@
|
||||
<!-- Bootstrap 3.3.6 -->
|
||||
<script src="__PLUGIN__/bootstrap/js/bootstrap.min.js"></script>
|
||||
<!-- FastClick -->
|
||||
<script src="__PLUGIN__/fastclick/fastclick.js"></script>
|
||||
<script src="__PLUGIN__/fastClick/fastclick.js"></script>
|
||||
<!-- slimScroll -->
|
||||
<script src="__PLUGIN__/slimScroll/jquery.slimscroll.min.js"></script>
|
||||
<!-- BootBox -->
|
||||
<script src="__PLUGIN__/bootBox/bootbox.min.js"></script>
|
||||
<!-- Vue -->
|
||||
<script src="__PLUGIN__/vue/vue.min.js"></script>
|
||||
<!-- AdminLTE App -->
|
||||
<script src="__JS__/app.min.js"></script>
|
||||
<!-- AdminLTE for demo purposes -->
|
||||
<script src="__JS__/demo.js"></script>
|
||||
<script src="__PLUGIN__/vue/vue.min.js"></script>
|
||||
<script>
|
||||
var JS_PATH = '__JS__';
|
||||
var CSS_PATH = '__CSS__';
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
(function ($) {
|
||||
"use strict";
|
||||
var bodyDom = $('body');
|
||||
/**
|
||||
* 格式化时间戳(为了和PHP的date函数统一,这里的时间戳都是10位,不包含毫秒)
|
||||
* @param timestamp
|
||||
@ -41,81 +42,94 @@
|
||||
/**
|
||||
* Ajax Post 表单提交
|
||||
*/
|
||||
$('body').on('click', '.ajax-post', function() {
|
||||
bodyDom.on('click', '.ajax-post', function() {
|
||||
var message,query,form,target;
|
||||
var target_form = $(this).attr('target-form');
|
||||
|
||||
if ( $(this).attr('type') == 'submit' ) {
|
||||
form = $('#' + target_form);
|
||||
query = form.serialize();
|
||||
target = form.attr('action');
|
||||
$.post(target, query).success(function(data) {
|
||||
var wait = 1000*data.wait;
|
||||
if (data.code == 1) {
|
||||
if (data.url) {
|
||||
message = data.msg + ' 页面即将自动跳转...';
|
||||
} else {
|
||||
message = data.msg;
|
||||
}
|
||||
$.alertMsg(message);
|
||||
setTimeout(function() {
|
||||
if (data.url) {
|
||||
location.href = data.url;
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
}, wait);
|
||||
form = $('#' + target_form);
|
||||
query = form.serialize();
|
||||
target = form.attr('action');
|
||||
$.post(target, query).success(function(data) {
|
||||
var wait = 1000*data.wait;
|
||||
if (data.code == 1) {
|
||||
if (data.url) {
|
||||
message = data.msg + ' 页面即将自动跳转...';
|
||||
} else {
|
||||
$.alertMsg(data.msg);
|
||||
setTimeout(function() {
|
||||
if (data.url) {
|
||||
location.href = data.url;
|
||||
}
|
||||
}, wait);
|
||||
message = data.msg;
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
var refresh = function(url) {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
success: function(data){
|
||||
if( data.code == 200 ){
|
||||
if( data.data.tempType == 'table' ){
|
||||
if( $.buildTable ){
|
||||
$('#content').html($.buildTable(data.data));
|
||||
$('#tableBox').hide().fadeIn(800);
|
||||
}else{
|
||||
$.getScript(JS_PATH + '/template/table.js', function (){
|
||||
$('#content').html($.buildTable(data.data));
|
||||
$('#tableBox').hide().fadeIn(800);
|
||||
});
|
||||
$.alertMsg(message);
|
||||
setTimeout(function() {
|
||||
if (data.url) {
|
||||
location.href = data.url;
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
if( data.data.tempType == 'form' ){
|
||||
if( $.buildForm ){
|
||||
$('#content').html($.buildForm(data.data));
|
||||
$('#tableBox').hide().fadeIn(800);
|
||||
}else{
|
||||
$.getScript(JS_PATH + '/template/form.js', function (){
|
||||
$('#content').html($.buildForm(data.data));
|
||||
$('#formBox').hide().fadeIn(800);
|
||||
});
|
||||
}
|
||||
}
|
||||
}else{
|
||||
}, wait);
|
||||
} else {
|
||||
$.alertMsg(data.msg);
|
||||
setTimeout(function() {
|
||||
if (data.url) {
|
||||
location.href = data.url;
|
||||
}
|
||||
}, 1000*data.wait);
|
||||
}, wait);
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
bodyDom.on('click', '.refresh', function() {
|
||||
var url = $(this).attr('url'), urlData = '';
|
||||
if( $(this).attr('data') ){
|
||||
urlData = $(this).attr('data');
|
||||
}
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
data: urlData,
|
||||
success: function(data){
|
||||
if( data.code == 200 ){
|
||||
if( data.data.tempType == 'table' ){
|
||||
if( $.buildTable ){
|
||||
$('#content').html($.buildTable(data.data));
|
||||
$('#tableBox').hide().fadeIn(800);
|
||||
}else{
|
||||
$.getScript(JS_PATH + '/template/table.js', function (){
|
||||
$('#content').html($.buildTable(data.data));
|
||||
$('#tableBox').hide().fadeIn(800);
|
||||
});
|
||||
}
|
||||
}
|
||||
if( data.data.tempType == 'add' ){
|
||||
if( $.buildAddForm ){
|
||||
$('#content').html($.buildAddForm(data.data));
|
||||
$('#formBox').hide().fadeIn(800);
|
||||
}else{
|
||||
$.getScript(JS_PATH + '/template/form.js', function (){
|
||||
$('#content').html($.buildAddForm(data.data));
|
||||
$('#formBox').hide().fadeIn(800);
|
||||
});
|
||||
}
|
||||
}
|
||||
if( data.data.tempType == 'edit' ){
|
||||
if( $.buildEditForm ){
|
||||
$('#content').html($.buildEditForm(data.data));
|
||||
$('#formBox').hide().fadeIn(800);
|
||||
}else{
|
||||
$.getScript(JS_PATH + '/template/form.js', function (){
|
||||
$('#content').html($.buildEditForm(data.data));
|
||||
$('#formBox').hide().fadeIn(800);
|
||||
});
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$.alertMsg(data.msg);
|
||||
setTimeout(function() {
|
||||
if (data.url) {
|
||||
location.href = data.url;
|
||||
}
|
||||
}, 1000*data.wait);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
@ -122,6 +122,8 @@
|
||||
var paramStr = '', buttonStr = '';
|
||||
if( buttonValue.confirm ){
|
||||
buttonValue.class += ' confirm';
|
||||
}else{
|
||||
buttonValue.class += ' refresh';
|
||||
}
|
||||
if( dataValue ){
|
||||
paramStr = prepareParamStr( buttonValue, dataValue );
|
||||
|
474
public/admin/static/plugin/slimScroll/jquery.slimscroll.js
Normal file
474
public/admin/static/plugin/slimScroll/jquery.slimscroll.js
Normal file
@ -0,0 +1,474 @@
|
||||
/*! Copyright (c) 2011 Piotr Rochala (http://rocha.la)
|
||||
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
||||
*
|
||||
* Version: 1.3.8
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
$.fn.extend({
|
||||
slimScroll: function(options) {
|
||||
|
||||
var defaults = {
|
||||
|
||||
// width in pixels of the visible scroll area
|
||||
width : 'auto',
|
||||
|
||||
// height in pixels of the visible scroll area
|
||||
height : '250px',
|
||||
|
||||
// width in pixels of the scrollbar and rail
|
||||
size : '7px',
|
||||
|
||||
// scrollbar color, accepts any hex/color value
|
||||
color: '#000',
|
||||
|
||||
// scrollbar position - left/right
|
||||
position : 'right',
|
||||
|
||||
// distance in pixels between the side edge and the scrollbar
|
||||
distance : '1px',
|
||||
|
||||
// default scroll position on load - top / bottom / $('selector')
|
||||
start : 'top',
|
||||
|
||||
// sets scrollbar opacity
|
||||
opacity : .4,
|
||||
|
||||
// enables always-on mode for the scrollbar
|
||||
alwaysVisible : false,
|
||||
|
||||
// check if we should hide the scrollbar when user is hovering over
|
||||
disableFadeOut : false,
|
||||
|
||||
// sets visibility of the rail
|
||||
railVisible : false,
|
||||
|
||||
// sets rail color
|
||||
railColor : '#333',
|
||||
|
||||
// sets rail opacity
|
||||
railOpacity : .2,
|
||||
|
||||
// whether we should use jQuery UI Draggable to enable bar dragging
|
||||
railDraggable : true,
|
||||
|
||||
// defautlt CSS class of the slimscroll rail
|
||||
railClass : 'slimScrollRail',
|
||||
|
||||
// defautlt CSS class of the slimscroll bar
|
||||
barClass : 'slimScrollBar',
|
||||
|
||||
// defautlt CSS class of the slimscroll wrapper
|
||||
wrapperClass : 'slimScrollDiv',
|
||||
|
||||
// check if mousewheel should scroll the window if we reach top/bottom
|
||||
allowPageScroll : false,
|
||||
|
||||
// scroll amount applied to each mouse wheel step
|
||||
wheelStep : 20,
|
||||
|
||||
// scroll amount applied when user is using gestures
|
||||
touchScrollStep : 200,
|
||||
|
||||
// sets border radius
|
||||
borderRadius: '7px',
|
||||
|
||||
// sets border radius of the rail
|
||||
railBorderRadius : '7px'
|
||||
};
|
||||
|
||||
var o = $.extend(defaults, options);
|
||||
|
||||
// do it for every element that matches selector
|
||||
this.each(function(){
|
||||
|
||||
var isOverPanel, isOverBar, isDragg, queueHide, touchDif,
|
||||
barHeight, percentScroll, lastScroll,
|
||||
divS = '<div></div>',
|
||||
minBarHeight = 30,
|
||||
releaseScroll = false;
|
||||
|
||||
// used in event handlers and for better minification
|
||||
var me = $(this);
|
||||
|
||||
// ensure we are not binding it again
|
||||
if (me.parent().hasClass(o.wrapperClass))
|
||||
{
|
||||
// start from last bar position
|
||||
var offset = me.scrollTop();
|
||||
|
||||
// find bar and rail
|
||||
bar = me.siblings('.' + o.barClass);
|
||||
rail = me.siblings('.' + o.railClass);
|
||||
|
||||
getBarHeight();
|
||||
|
||||
// check if we should scroll existing instance
|
||||
if ($.isPlainObject(options))
|
||||
{
|
||||
// Pass height: auto to an existing slimscroll object to force a resize after contents have changed
|
||||
if ( 'height' in options && options.height == 'auto' ) {
|
||||
me.parent().css('height', 'auto');
|
||||
me.css('height', 'auto');
|
||||
var height = me.parent().parent().height();
|
||||
me.parent().css('height', height);
|
||||
me.css('height', height);
|
||||
} else if ('height' in options) {
|
||||
var h = options.height;
|
||||
me.parent().css('height', h);
|
||||
me.css('height', h);
|
||||
}
|
||||
|
||||
if ('scrollTo' in options)
|
||||
{
|
||||
// jump to a static point
|
||||
offset = parseInt(o.scrollTo);
|
||||
}
|
||||
else if ('scrollBy' in options)
|
||||
{
|
||||
// jump by value pixels
|
||||
offset += parseInt(o.scrollBy);
|
||||
}
|
||||
else if ('destroy' in options)
|
||||
{
|
||||
// remove slimscroll elements
|
||||
bar.remove();
|
||||
rail.remove();
|
||||
me.unwrap();
|
||||
return;
|
||||
}
|
||||
|
||||
// scroll content by the given offset
|
||||
scrollContent(offset, false, true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if ($.isPlainObject(options))
|
||||
{
|
||||
if ('destroy' in options)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// optionally set height to the parent's height
|
||||
o.height = (o.height == 'auto') ? me.parent().height() : o.height;
|
||||
|
||||
// wrap content
|
||||
var wrapper = $(divS)
|
||||
.addClass(o.wrapperClass)
|
||||
.css({
|
||||
position: 'relative',
|
||||
overflow: 'hidden',
|
||||
width: o.width,
|
||||
height: o.height
|
||||
});
|
||||
|
||||
// update style for the div
|
||||
me.css({
|
||||
overflow: 'hidden',
|
||||
width: o.width,
|
||||
height: o.height
|
||||
});
|
||||
|
||||
// create scrollbar rail
|
||||
var rail = $(divS)
|
||||
.addClass(o.railClass)
|
||||
.css({
|
||||
width: o.size,
|
||||
height: '100%',
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
display: (o.alwaysVisible && o.railVisible) ? 'block' : 'none',
|
||||
'border-radius': o.railBorderRadius,
|
||||
background: o.railColor,
|
||||
opacity: o.railOpacity,
|
||||
zIndex: 90
|
||||
});
|
||||
|
||||
// create scrollbar
|
||||
var bar = $(divS)
|
||||
.addClass(o.barClass)
|
||||
.css({
|
||||
background: o.color,
|
||||
width: o.size,
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
opacity: o.opacity,
|
||||
display: o.alwaysVisible ? 'block' : 'none',
|
||||
'border-radius' : o.borderRadius,
|
||||
BorderRadius: o.borderRadius,
|
||||
MozBorderRadius: o.borderRadius,
|
||||
WebkitBorderRadius: o.borderRadius,
|
||||
zIndex: 99
|
||||
});
|
||||
|
||||
// set position
|
||||
var posCss = (o.position == 'right') ? { right: o.distance } : { left: o.distance };
|
||||
rail.css(posCss);
|
||||
bar.css(posCss);
|
||||
|
||||
// wrap it
|
||||
me.wrap(wrapper);
|
||||
|
||||
// append to parent div
|
||||
me.parent().append(bar);
|
||||
me.parent().append(rail);
|
||||
|
||||
// make it draggable and no longer dependent on the jqueryUI
|
||||
if (o.railDraggable){
|
||||
bar.bind("mousedown", function(e) {
|
||||
var $doc = $(document);
|
||||
isDragg = true;
|
||||
t = parseFloat(bar.css('top'));
|
||||
pageY = e.pageY;
|
||||
|
||||
$doc.bind("mousemove.slimscroll", function(e){
|
||||
currTop = t + e.pageY - pageY;
|
||||
bar.css('top', currTop);
|
||||
scrollContent(0, bar.position().top, false);// scroll content
|
||||
});
|
||||
|
||||
$doc.bind("mouseup.slimscroll", function(e) {
|
||||
isDragg = false;hideBar();
|
||||
$doc.unbind('.slimscroll');
|
||||
});
|
||||
return false;
|
||||
}).bind("selectstart.slimscroll", function(e){
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// on rail over
|
||||
rail.hover(function(){
|
||||
showBar();
|
||||
}, function(){
|
||||
hideBar();
|
||||
});
|
||||
|
||||
// on bar over
|
||||
bar.hover(function(){
|
||||
isOverBar = true;
|
||||
}, function(){
|
||||
isOverBar = false;
|
||||
});
|
||||
|
||||
// show on parent mouseover
|
||||
me.hover(function(){
|
||||
isOverPanel = true;
|
||||
showBar();
|
||||
hideBar();
|
||||
}, function(){
|
||||
isOverPanel = false;
|
||||
hideBar();
|
||||
});
|
||||
|
||||
// support for mobile
|
||||
me.bind('touchstart', function(e,b){
|
||||
if (e.originalEvent.touches.length)
|
||||
{
|
||||
// record where touch started
|
||||
touchDif = e.originalEvent.touches[0].pageY;
|
||||
}
|
||||
});
|
||||
|
||||
me.bind('touchmove', function(e){
|
||||
// prevent scrolling the page if necessary
|
||||
if(!releaseScroll)
|
||||
{
|
||||
e.originalEvent.preventDefault();
|
||||
}
|
||||
if (e.originalEvent.touches.length)
|
||||
{
|
||||
// see how far user swiped
|
||||
var diff = (touchDif - e.originalEvent.touches[0].pageY) / o.touchScrollStep;
|
||||
// scroll content
|
||||
scrollContent(diff, true);
|
||||
touchDif = e.originalEvent.touches[0].pageY;
|
||||
}
|
||||
});
|
||||
|
||||
// set up initial height
|
||||
getBarHeight();
|
||||
|
||||
// check start position
|
||||
if (o.start === 'bottom')
|
||||
{
|
||||
// scroll content to bottom
|
||||
bar.css({ top: me.outerHeight() - bar.outerHeight() });
|
||||
scrollContent(0, true);
|
||||
}
|
||||
else if (o.start !== 'top')
|
||||
{
|
||||
// assume jQuery selector
|
||||
scrollContent($(o.start).position().top, null, true);
|
||||
|
||||
// make sure bar stays hidden
|
||||
if (!o.alwaysVisible) { bar.hide(); }
|
||||
}
|
||||
|
||||
// attach scroll events
|
||||
attachWheel(this);
|
||||
|
||||
function _onWheel(e)
|
||||
{
|
||||
// use mouse wheel only when mouse is over
|
||||
if (!isOverPanel) { return; }
|
||||
|
||||
var e = e || window.event;
|
||||
|
||||
var delta = 0;
|
||||
if (e.wheelDelta) { delta = -e.wheelDelta/120; }
|
||||
if (e.detail) { delta = e.detail / 3; }
|
||||
|
||||
var target = e.target || e.srcTarget || e.srcElement;
|
||||
if ($(target).closest('.' + o.wrapperClass).is(me.parent())) {
|
||||
// scroll content
|
||||
scrollContent(delta, true);
|
||||
}
|
||||
|
||||
// stop window scroll
|
||||
if (e.preventDefault && !releaseScroll) { e.preventDefault(); }
|
||||
if (!releaseScroll) { e.returnValue = false; }
|
||||
}
|
||||
|
||||
function scrollContent(y, isWheel, isJump)
|
||||
{
|
||||
releaseScroll = false;
|
||||
var delta = y;
|
||||
var maxTop = me.outerHeight() - bar.outerHeight();
|
||||
|
||||
if (isWheel)
|
||||
{
|
||||
// move bar with mouse wheel
|
||||
delta = parseInt(bar.css('top')) + y * parseInt(o.wheelStep) / 100 * bar.outerHeight();
|
||||
|
||||
// move bar, make sure it doesn't go out
|
||||
delta = Math.min(Math.max(delta, 0), maxTop);
|
||||
|
||||
// if scrolling down, make sure a fractional change to the
|
||||
// scroll position isn't rounded away when the scrollbar's CSS is set
|
||||
// this flooring of delta would happened automatically when
|
||||
// bar.css is set below, but we floor here for clarity
|
||||
delta = (y > 0) ? Math.ceil(delta) : Math.floor(delta);
|
||||
|
||||
// scroll the scrollbar
|
||||
bar.css({ top: delta + 'px' });
|
||||
}
|
||||
|
||||
// calculate actual scroll amount
|
||||
percentScroll = parseInt(bar.css('top')) / (me.outerHeight() - bar.outerHeight());
|
||||
delta = percentScroll * (me[0].scrollHeight - me.outerHeight());
|
||||
|
||||
if (isJump)
|
||||
{
|
||||
delta = y;
|
||||
var offsetTop = delta / me[0].scrollHeight * me.outerHeight();
|
||||
offsetTop = Math.min(Math.max(offsetTop, 0), maxTop);
|
||||
bar.css({ top: offsetTop + 'px' });
|
||||
}
|
||||
|
||||
// scroll content
|
||||
me.scrollTop(delta);
|
||||
|
||||
// fire scrolling event
|
||||
me.trigger('slimscrolling', ~~delta);
|
||||
|
||||
// ensure bar is visible
|
||||
showBar();
|
||||
|
||||
// trigger hide when scroll is stopped
|
||||
hideBar();
|
||||
}
|
||||
|
||||
function attachWheel(target)
|
||||
{
|
||||
if (window.addEventListener)
|
||||
{
|
||||
target.addEventListener('DOMMouseScroll', _onWheel, false );
|
||||
target.addEventListener('mousewheel', _onWheel, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
document.attachEvent("onmousewheel", _onWheel)
|
||||
}
|
||||
}
|
||||
|
||||
function getBarHeight()
|
||||
{
|
||||
// calculate scrollbar height and make sure it is not too small
|
||||
barHeight = Math.max((me.outerHeight() / me[0].scrollHeight) * me.outerHeight(), minBarHeight);
|
||||
bar.css({ height: barHeight + 'px' });
|
||||
|
||||
// hide scrollbar if content is not long enough
|
||||
var display = barHeight == me.outerHeight() ? 'none' : 'block';
|
||||
bar.css({ display: display });
|
||||
}
|
||||
|
||||
function showBar()
|
||||
{
|
||||
// recalculate bar height
|
||||
getBarHeight();
|
||||
clearTimeout(queueHide);
|
||||
|
||||
// when bar reached top or bottom
|
||||
if (percentScroll == ~~percentScroll)
|
||||
{
|
||||
//release wheel
|
||||
releaseScroll = o.allowPageScroll;
|
||||
|
||||
// publish approporiate event
|
||||
if (lastScroll != percentScroll)
|
||||
{
|
||||
var msg = (~~percentScroll == 0) ? 'top' : 'bottom';
|
||||
me.trigger('slimscroll', msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
releaseScroll = false;
|
||||
}
|
||||
lastScroll = percentScroll;
|
||||
|
||||
// show only when required
|
||||
if(barHeight >= me.outerHeight()) {
|
||||
//allow window scroll
|
||||
releaseScroll = true;
|
||||
return;
|
||||
}
|
||||
bar.stop(true,true).fadeIn('fast');
|
||||
if (o.railVisible) { rail.stop(true,true).fadeIn('fast'); }
|
||||
}
|
||||
|
||||
function hideBar()
|
||||
{
|
||||
// only hide when options allow it
|
||||
if (!o.alwaysVisible)
|
||||
{
|
||||
queueHide = setTimeout(function(){
|
||||
if (!(o.disableFadeOut && isOverPanel) && !isOverBar && !isDragg)
|
||||
{
|
||||
bar.fadeOut('slow');
|
||||
rail.fadeOut('slow');
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// maintain chainability
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
$.fn.extend({
|
||||
slimscroll: $.fn.slimScroll
|
||||
});
|
||||
|
||||
})(jQuery);
|
16
public/admin/static/plugin/slimScroll/jquery.slimscroll.min.js
vendored
Normal file
16
public/admin/static/plugin/slimScroll/jquery.slimscroll.min.js
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/*! Copyright (c) 2011 Piotr Rochala (http://rocha.la)
|
||||
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
||||
*
|
||||
* Version: 1.3.8
|
||||
*
|
||||
*/
|
||||
(function(e){e.fn.extend({slimScroll:function(f){var a=e.extend({width:"auto",height:"250px",size:"7px",color:"#000",position:"right",distance:"1px",start:"top",opacity:.4,alwaysVisible:!1,disableFadeOut:!1,railVisible:!1,railColor:"#333",railOpacity:.2,railDraggable:!0,railClass:"slimScrollRail",barClass:"slimScrollBar",wrapperClass:"slimScrollDiv",allowPageScroll:!1,wheelStep:20,touchScrollStep:200,borderRadius:"7px",railBorderRadius:"7px"},f);this.each(function(){function v(d){if(r){d=d||window.event;
|
||||
var c=0;d.wheelDelta&&(c=-d.wheelDelta/120);d.detail&&(c=d.detail/3);e(d.target||d.srcTarget||d.srcElement).closest("."+a.wrapperClass).is(b.parent())&&n(c,!0);d.preventDefault&&!k&&d.preventDefault();k||(d.returnValue=!1)}}function n(d,g,e){k=!1;var f=b.outerHeight()-c.outerHeight();g&&(g=parseInt(c.css("top"))+d*parseInt(a.wheelStep)/100*c.outerHeight(),g=Math.min(Math.max(g,0),f),g=0<d?Math.ceil(g):Math.floor(g),c.css({top:g+"px"}));l=parseInt(c.css("top"))/(b.outerHeight()-c.outerHeight());g=
|
||||
l*(b[0].scrollHeight-b.outerHeight());e&&(g=d,d=g/b[0].scrollHeight*b.outerHeight(),d=Math.min(Math.max(d,0),f),c.css({top:d+"px"}));b.scrollTop(g);b.trigger("slimscrolling",~~g);w();p()}function x(){u=Math.max(b.outerHeight()/b[0].scrollHeight*b.outerHeight(),30);c.css({height:u+"px"});var a=u==b.outerHeight()?"none":"block";c.css({display:a})}function w(){x();clearTimeout(B);l==~~l?(k=a.allowPageScroll,C!=l&&b.trigger("slimscroll",0==~~l?"top":"bottom")):k=!1;C=l;u>=b.outerHeight()?k=!0:(c.stop(!0,
|
||||
!0).fadeIn("fast"),a.railVisible&&m.stop(!0,!0).fadeIn("fast"))}function p(){a.alwaysVisible||(B=setTimeout(function(){a.disableFadeOut&&r||y||z||(c.fadeOut("slow"),m.fadeOut("slow"))},1E3))}var r,y,z,B,A,u,l,C,k=!1,b=e(this);if(b.parent().hasClass(a.wrapperClass)){var q=b.scrollTop(),c=b.siblings("."+a.barClass),m=b.siblings("."+a.railClass);x();if(e.isPlainObject(f)){if("height"in f&&"auto"==f.height){b.parent().css("height","auto");b.css("height","auto");var h=b.parent().parent().height();b.parent().css("height",
|
||||
h);b.css("height",h)}else"height"in f&&(h=f.height,b.parent().css("height",h),b.css("height",h));if("scrollTo"in f)q=parseInt(a.scrollTo);else if("scrollBy"in f)q+=parseInt(a.scrollBy);else if("destroy"in f){c.remove();m.remove();b.unwrap();return}n(q,!1,!0)}}else if(!(e.isPlainObject(f)&&"destroy"in f)){a.height="auto"==a.height?b.parent().height():a.height;q=e("<div></div>").addClass(a.wrapperClass).css({position:"relative",overflow:"hidden",width:a.width,height:a.height});b.css({overflow:"hidden",
|
||||
width:a.width,height:a.height});var m=e("<div></div>").addClass(a.railClass).css({width:a.size,height:"100%",position:"absolute",top:0,display:a.alwaysVisible&&a.railVisible?"block":"none","border-radius":a.railBorderRadius,background:a.railColor,opacity:a.railOpacity,zIndex:90}),c=e("<div></div>").addClass(a.barClass).css({background:a.color,width:a.size,position:"absolute",top:0,opacity:a.opacity,display:a.alwaysVisible?"block":"none","border-radius":a.borderRadius,BorderRadius:a.borderRadius,MozBorderRadius:a.borderRadius,
|
||||
WebkitBorderRadius:a.borderRadius,zIndex:99}),h="right"==a.position?{right:a.distance}:{left:a.distance};m.css(h);c.css(h);b.wrap(q);b.parent().append(c);b.parent().append(m);a.railDraggable&&c.bind("mousedown",function(a){var b=e(document);z=!0;t=parseFloat(c.css("top"));pageY=a.pageY;b.bind("mousemove.slimscroll",function(a){currTop=t+a.pageY-pageY;c.css("top",currTop);n(0,c.position().top,!1)});b.bind("mouseup.slimscroll",function(a){z=!1;p();b.unbind(".slimscroll")});return!1}).bind("selectstart.slimscroll",
|
||||
function(a){a.stopPropagation();a.preventDefault();return!1});m.hover(function(){w()},function(){p()});c.hover(function(){y=!0},function(){y=!1});b.hover(function(){r=!0;w();p()},function(){r=!1;p()});b.bind("touchstart",function(a,b){a.originalEvent.touches.length&&(A=a.originalEvent.touches[0].pageY)});b.bind("touchmove",function(b){k||b.originalEvent.preventDefault();b.originalEvent.touches.length&&(n((A-b.originalEvent.touches[0].pageY)/a.touchScrollStep,!0),A=b.originalEvent.touches[0].pageY)});
|
||||
x();"bottom"===a.start?(c.css({top:b.outerHeight()-c.outerHeight()}),n(0,!0)):"top"!==a.start&&(n(e(a.start).position().top,null,!0),a.alwaysVisible||c.hide());window.addEventListener?(this.addEventListener("DOMMouseScroll",v,!1),this.addEventListener("mousewheel",v,!1)):document.attachEvent("onmousewheel",v)}});return this}});e.fn.extend({slimscroll:e.fn.slimScroll})})(jQuery);
|
Loading…
x
Reference in New Issue
Block a user