31 Star 51 Fork 15

南漂一卒/EasyWebUI

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
EasyWebUI.js 19.92 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
//
// Generated by https://www.npmjs.com/package/amd-bundle
//
(function (factory) {
if ((typeof define === 'function') && define.amd)
define('EasyWebUI', ['jquery', 'jQueryKit'], factory);
else if (typeof module === 'object')
module.exports = factory(require('jquery'), require('jQueryKit'));
else
this.EasyWebUI = factory(this['jquery'], this['jQueryKit']);
})(function (jquery, jQueryKit) {
(function ($) {
/* ---------- 密码确认插件 v0.3 ---------- */
// By 魏如松
var $_Hint = $('<div class="Hint" />').css({
position: 'absolute',
width: '0.625em',
'font-weight': 'bold'
});
function showHint() {
var iPosition = this.position();
$_Hint.clone().text( arguments[0] ).css({
color: arguments[1],
left: (iPosition.left + this.width() - $_Hint.width()) + 'px',
top: (iPosition.top + this.height() * 0.2) + 'px'
}).appendTo(
this.parent()
);
}
$.fn.pwConfirm = function () {
var pwGroup = { },
$_passwordAll = this.find('input[type="password"][name]');
// 密码明文查看
var $_visible = $('<div class="visible" />').css({
position: 'absolute',
right: '5%',
top: '8%',
'z-index': 1000000,
'font-size': '26px',
cursor: 'pointer'
}),
Icon_Map = {1: 'text', 2: 'password'};
$_passwordAll.parent().css('position', 'relative').append(
$_visible.clone()
).find('.visible').html('&#10002;').click(function () {
var iType = (this.textContent === '') ? 1 : 2;
$( this ).html('&#1000' + iType + ';')
.siblings('input')[0].type = Icon_Map[ iType ];
});
// 密码输入验证
$_passwordAll.each(function () {
if (pwGroup[ this.name ]) return;
pwGroup[ this.name ] = $_passwordAll.filter(
'[name="' + this.name + '"]'
);
var $_password = pwGroup[this.name], _Complete_ = 0;
if ($_password.length < 2) return;
$_password.blur(function () {
var $_this = $( this );
$_this.parent().find('.Hint').remove();
if (! this.value) return;
if (! $_this.validate())
showHint.call($_this, '×', 'red');
else if (++_Complete_ === 2) {
var $_other = $_password.not( this );
showHint.apply(
$_this,
(this.value === $_other[0].value) ?
['', 'green'] : ['×', 'red']
);
_Complete_ = 0;
} else
showHint.call($_this, '', 'green');
});
});
return this;
};
})(jquery);
(function ($) {
/* ---------- Input Range 补丁 v0.1 ---------- */
function Pseudo_Bind() {
var iRule = self.getMatchedCSSRules(this, ':before');
$( this ).change(function () {
var iPercent = ((this.value / this.max) * 100) + '%';
for (var i = 0; iRule[i]; i++)
iRule[i].style.setProperty('width', iPercent, 'important');
});
}
Pseudo_Bind.No_Bug = (Math.floor( $.browser.webkit ) > 533);
$.fn.Range = function () {
return this.each(function () {
var $_This = $( this );
// Fill-Lower for WebKit
if (Pseudo_Bind.No_Bug && (! $_This.hasClass('Detail')))
$_This.cssRule({
':before': {
width: (
($_This[0].value / $_This[0].max) * 100
) + '% !important'
}
}, Pseudo_Bind);
// Data-List for All Cores
var $_List = $('<datalist />', {id: $.uuid('Range')});
$_This.attr('list', $_List[0].id);
if ( this.min )
$($.map(Array((this.max - this.min) / this.step), function () {
return $('<option />', {
value:
$_This[0].min + ($_This[0].step * arguments[1])/*,
text: */
})[0];
})).appendTo( $_List );
$_This.before( $_List );
});
};
})(jquery);
(function ($) {
/* ---------- 元素禁止选中 v0.1 ---------- */
$.fn.noSelect = function () {
return this.attr('unSelectable', 'on').addClass('No_Select')
.bind('selectStart', false).bind('contextmenu', false);
};
})(jquery);
(function ($) {
/* ---------- Input Data-List 补丁 v0.3 ---------- */
var List_Type = 'input[type="' + [
'text', 'tel', 'email', 'url', 'search'
].join(
'"][list], input[type="'
) + '"]';
function Tips_Show($_List) {
if (! this.value) $_List.append( $_List.$_Option );
if (! $_List.height()) $_List.slideDown( 100 );
return this.value;
}
function Tips_Hide() {
if ( this.height() ) this.slideUp( 100 );
return this;
}
function Tips_Match($_List) {
$_List.$_Option = $.unique($.merge(
$_List.$_Option, $_List.children()
));
var iValue = Tips_Show.call(this, $_List);
if (! iValue) return;
$.each($_List.$_Option, function () {
for (var i = 0, _Index_; i < iValue.length; i++) {
if (iValue[i + 1] === undefined) break;
_Index_ = this.value.indexOf( iValue[i] );
if (
(_Index_ < 0) ||
(_Index_ >= this.value.indexOf( iValue[i + 1] ))
) {
if ( this.parentElement ) $( this ).detach();
return;
}
}
if (! this.parentElement) $_List[0].appendChild( this );
});
}
function DL_Change(iCallback) {
return this.change(function () {
var iOption = this.list.options;
for (var i = 0; iOption[i]; i++)
if (this.value === iOption[i].value)
return iCallback.call(this, arguments[0], iOption[i]);
});
}
$.fn.smartInput = function (onChange) {
return this.filter( List_Type ).each(function () {
var $_Input = $(this), iPosition = this.parentNode.style.position;
if (typeof HTMLDataListElement === 'function')
return DL_Change.call($_Input, onChange);
// DOM Property Patch
$_Input[0].list = $('#' + this.getAttribute('list'))[0];
var $_List = $( $_Input[0].list.children[0] );
$_List[0].multiple = $_List[0].multiple || true;
$_Input[0].list.options = $_List[0].children;
if ($_Input.attr('autocomplete') === 'off') return;
// Get Position
if ((! iPosition) || (iPosition === 'static'))
$(this.parentNode).css({
position: 'relative',
zoom: 1
});
iPosition = $_Input.attr('autocomplete', 'off').position();
iPosition.top += $_Input.height();
// DropDown List
$_List.css($.extend(iPosition, {
position: 'absolute',
'z-index': 10000,
height: 0,
width: $_Input.width(),
padding: 0,
border: 0,
overflow: 'hidden',
opacity: 0
})).change(function () {
$_Input[0].value = Tips_Hide.call( $_List )[0].value;
return onChange.call(
$_Input[0],
arguments[0],
this.children[ this.selectIndex ]
);
});
$_List.$_Option = [ ];
var iFilter = $.proxy(Tips_Match, null, $_List);
$_Input.after( $_List )
.dblclick( $.proxy(Tips_Show, null, $_List) )
.blur( $.proxy(Tips_Hide, $_List) )
.keyup( iFilter )
.on('paste', iFilter)
.on('cut', iFilter);
});
};
})(jquery);
(function ($) {
/* ---------- Flex Box 补丁 v0.2 ---------- */
var CSS_Attribute = {
Float: $.makeSet('absolute', 'fixed'),
Display: $.makeSet('block', 'table'),
Prefix: (function (iUA) {
try {
return ({
webkit: '-webkit-',
gecko: '-moz-',
trident: '-ms-'
})[
iUA.match( /Gecko|WebKit|Trident/i )[0].toLowerCase()
];
} catch (iError) { return ''; }
})( navigator.userAgent ),
Flex_Size: {
horizontal: {
length: 'width',
margin: ['left', 'right']
},
vertical: {
length: 'height',
margin: ['top', 'bottom']
}
}
};
function FlexFix() {
var $_Box = $( this );
var Size_Name = CSS_Attribute.Flex_Size[
$_Box.css(CSS_Attribute.Prefix + 'box-orient')
];
var Flex_Child = $.extend([ ], {
sum: 0,
sum_PX: (
$_Box[ Size_Name.length ]() -
parseFloat( $_Box.css('padding-' + Size_Name.margin[0]) ) -
parseFloat( $_Box.css('padding-' + Size_Name.margin[1]) )
)
});
$_Box.children().each(function () {
var $_This = $( this );
if (
($_This.css('position') in CSS_Attribute.Float) ||
($_This.css('display') === 'none')
)
return;
var iDisplay = $_This.css('display').match(
RegExp(
'(' + CSS_Attribute.Prefix + ')?(inline)?-?(.+)?$', 'i'
)
);
if ( iDisplay[2] )
$_This.css({
display: iDisplay[3] ?
(
(
(iDisplay[3] in CSS_Attribute.Display) ?
'' : CSS_Attribute.Prefix
) + iDisplay[3]
) :
'block'
});
var _Index_ = Flex_Child.push( {$_DOM: $_This} ) - 1,
_Length_ = $_This[ Size_Name.length ]();
if (! _Length_) return Flex_Child.pop();
Flex_Child[_Index_].scale = parseInt(
$_This.css(CSS_Attribute.Prefix + 'box-flex')
);
Flex_Child.sum += Flex_Child[_Index_].scale;
Flex_Child.sum_PX -= (
_Length_ +
parseFloat(
$_This.css('margin-' + Size_Name.margin[0])
) +
parseFloat(
$_This.css('margin-' + Size_Name.margin[1])
)
);
});
if (Flex_Child.sum_PX < 0) Flex_Child.sum_PX = 0;
var iUnit = Flex_Child.sum_PX / Flex_Child.sum;
for (var i = 0; Flex_Child[i]; i++)
Flex_Child[i].$_DOM[ Size_Name.length ](
Flex_Child[i].$_DOM[ Size_Name.length ]() +
(Flex_Child[i].scale * iUnit)
);
}
var _addClass_ = $.fn.addClass;
if ('flex' in document.documentElement.style) return;
$.fn.addClass = function () {
_addClass_.apply(this, arguments);
if ($.inArray('Flex-Box', arguments[0].split(/\s+/)) > -1)
return this.each( FlexFix );
return this;
};
$( document ).ready(function () {
$('.Flex-Box').each( FlexFix );
});
})(jquery);
(function ($) {
$.fn.checkAll = function ($_forAll, onChange) {
if ($_forAll instanceof Function) onChange = $_forAll, $_forAll = '';
return this.each(function () {
var $_This = $( this );
var iAll = $_forAll ?
$_This.find( $_forAll )[0] :
$('input[type="checkbox"]', this)[0];
$_This.on('change', 'input[type="checkbox"]', function () {
var $_All = $_This.find('input[type="checkbox"]').not( iAll );
if (this === iAll)
$_All.prop('checked', this.checked);
else
iAll.checked = (! $_All.not(':checked')[0]);
if (typeof onChange === 'function')
onChange.apply($_This[0], [
arguments[0],
$.map($_All.filter(':checked'), function () {
return arguments[0].value;
})
]);
});
});
};
})(jquery);
(function ($) {
/* ---------- 表单对话框 v0.1 ---------- */
var $_BOM = $( self );
function show() {
return this.css({
opacity: 1,
left:
($_BOM.width() - parseFloat( this.css('width') )) / 2,
top:
($_BOM.height() - parseFloat( this.css('height') )) / 2
});
}
function close() {
var $_This = this.css({
opacity: 0,
left: 0,
top: 0
}).off('.Dialog');
return new Promise(function (iResolve) {
$.wait(parseFloat( $_This.css('transition-duration') ), function () {
iResolve(! $_This.hide());
});
});
}
$.fn.formDialog = function () {
var $_This = this.show();
return new Promise(function (iResolve) {
show.call( $_This ).on('submit.Dialog', function () {
close.call( $_This ).then(function () {
iResolve($.paramJSON('?' + $_This.serialize()));
});
}).on('reset.Dialog', function () {
close.call( $_This ).then( iResolve );
}).on('keyup.Dialog', function (iEvent) {
if (
(iEvent.type === 'keyup') &&
(iEvent.which === 27) &&
(! $.expr[':'].field( iEvent.target ))
)
$( this ).trigger('reset')[0].reset();
});
});
};
})(jquery);
(function ($) {
/* ---------- 面板控件 v0.1 ---------- */
$.fn.iPanel = function () {
var $_This = this.is('.Panel') ? this : this.find('.Panel');
return $_This.each(function () {
var $_Body = $( this ).children('.Body');
if (! ($_Body.length && $_Body.height()))
$(this).addClass('closed');
}).children('.Head').dblclick(function () {
var $_Head = $(this); var $_Panel = $_Head.parent();
var $_Head_Height = parseFloat( $_Head.css('height') )
+ parseFloat( $_Head.css('margin-top') )
+ parseFloat( $_Head.css('margin-bottom') )
+ parseFloat( $_Panel.css('padding-top') ) * 2;
if (! $_Panel.hasClass('closed')) {
$_Panel.data('height', $_Panel.height());
$_Panel.stop().animate( {height: $_Head_Height} );
$_Panel.addClass('closed');
} else {
$_Panel.stop().animate( {height: $_Panel.data('height')} );
$_Panel.removeClass('closed');
}
});
};
})(jquery);
(function ($) {
/* ---------- 滚动悬停 v0.2 ---------- */
var $_BOM = $( self ), $_DOM = $( document ), Fixed_List = [ ];
function Scroll_Fixed() {
this.$_View = $( arguments[0] );
this.onChange = arguments[1];
this.$_Shim = $( this.$_View[0].outerHTML ).css('opacity', 0);
this.offset = this.$_View.offset();
}
Scroll_Fixed.limitMap = {
width: ['left', 'Left'],
height: ['top', 'Top']
};
$.extend(Scroll_Fixed.prototype, {
getLimit: function () {
var LM = this.constructor.limitMap,
iLimit = { },
offset = this.$_View.offset();
for (var iKey in LM)
iLimit['max-' + iKey] = $_BOM[ iKey ]()
- (
offset[ LM[iKey][0] ] -
$_DOM['scroll' + LM[iKey][1]]()
)
- ($_DOM[ iKey ]() - (
this.offset[ LM[iKey][0] ] +
parseFloat( this.$_Shim.css( iKey ) )
));
return iLimit;
},
render: function () {
this.$_View.css({
position: 'fixed',
top: 0,
'z-index': 100
}).after( this.$_Shim ).css( this.getLimit() );
if ( this.onChange ) this.onChange.call(this.$_View[0], 'fixed');
return this;
},
destroy: function () {
this.$_View.css({
position: 'static',
'max-width': 'inherit',
'max-height': 'inherit'
});
if ( this.onChange ) this.onChange.call(this.$_View[0], 'static');
this.$_Shim.remove();
return this;
},
toggleAt: function (Scroll_Top) {
var iPosition = this.$_View.css('position');
if (Scroll_Top > this.offset.top) {
if (iPosition != 'fixed') this.render();
} else if (iPosition != 'static') this.destroy();
return this;
}
});
$_DOM.scroll(function () {
var iOffset = $_DOM.scrollTop();
for (var i = 0; Fixed_List[i]; i++)
Fixed_List[i].toggleAt( iOffset );
});
$.fn.scrollFixed = function (iCallback) {
iCallback = (typeof iCallback === 'function') && iCallback;
$.merge(Fixed_List, $.map(this, function () {
return new Scroll_Fixed(arguments[0], iCallback);
}));
return this;
};
})(jquery);
//
// >>> EasyWebUI Component Library <<<
//
//
// [Version] v1.6 (2017-08-08) Stable
//
// [Based on] iQuery v3 or jQuery (with jQueryKit)
//
// [Usage] A jQuery Plugin Library which almost
// isn't dependent on EasyWebUI.css
//
//
// (C)2014-2017 shiy2008@gmail.com
//
/* ---------- 首屏渲染 自动启用组件集 ---------- */
return (function ($) {
var $_DOM = $( document ).ready(function () {
$('form').pwConfirm();
$('form input[type="range"]').Range();
$('.Panel').iPanel();
$('*:button, a.Button, .No_Select, .Panel > .Head, .Tab > label')
.noSelect();
});
if ($.browser.msie < 11) return;
$_DOM.on(
[
'mousedown', 'mousemove', 'mouseup',
'click', 'dblclick', 'mousewheel',
'touchstart', 'touchmove', 'touchend', 'touchcancel',
'tap', 'press', 'swipe'
].join(' '),
'.No_Pointer',
function (iEvent) {
if (iEvent.target !== this) return;
var $_This = $( this ).hide(),
$_Under = $(
$_DOM[0].elementFromPoint(iEvent.pageX, iEvent.pageY)
);
$_This.show(); $_Under.trigger( iEvent );
}
);
})(jquery);
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
CSS
1
https://gitee.com/Tech_Query/EasyWebUI.git
git@gitee.com:Tech_Query/EasyWebUI.git
Tech_Query
EasyWebUI
EasyWebUI
master

搜索帮助