升级easyUI到1.9.4版本

This commit is contained in:
季圣华
2020-02-15 00:37:43 +08:00
parent 0527b980ea
commit ab2872c1ed
1197 changed files with 96263 additions and 40643 deletions

View File

@@ -0,0 +1,462 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* easyloader - EasyUI for jQuery
*
*/
(function(){
var modules = {
draggable:{
js:'jquery.draggable.js'
},
droppable:{
js:'jquery.droppable.js'
},
resizable:{
js:'jquery.resizable.js'
},
linkbutton:{
js:'jquery.linkbutton.js',
css:'linkbutton.css'
},
progressbar:{
js:'jquery.progressbar.js',
css:'progressbar.css'
},
tooltip:{
js:'jquery.tooltip.js',
css:'tooltip.css'
},
pagination:{
js:'jquery.pagination.js',
css:'pagination.css',
dependencies:['linkbutton']
},
datagrid:{
js:'jquery.datagrid.js',
css:'datagrid.css',
dependencies:['panel','resizable','linkbutton','pagination']
},
treegrid:{
js:'jquery.treegrid.js',
css:'tree.css',
dependencies:['datagrid']
},
propertygrid:{
js:'jquery.propertygrid.js',
css:'propertygrid.css',
dependencies:['datagrid']
},
datalist:{
js:'jquery.datalist.js',
css:'datalist.css',
dependencies:['datagrid']
},
panel: {
js:'jquery.panel.js',
css:'panel.css'
},
window:{
js:'jquery.window.js',
css:'window.css',
dependencies:['resizable','draggable','panel']
},
dialog:{
js:'jquery.dialog.js',
css:'dialog.css',
dependencies:['linkbutton','window']
},
messager:{
js:'jquery.messager.js',
css:'messager.css',
dependencies:['linkbutton','dialog','progressbar']
},
layout:{
js:'jquery.layout.js',
css:'layout.css',
dependencies:['resizable','panel']
},
form:{
js:'jquery.form.js'
},
menu:{
js:'jquery.menu.js',
css:'menu.css'
},
tabs:{
js:'jquery.tabs.js',
css:'tabs.css',
dependencies:['panel','linkbutton']
},
menubutton:{
js:'jquery.menubutton.js',
css:'menubutton.css',
dependencies:['linkbutton','menu']
},
splitbutton:{
js:'jquery.splitbutton.js',
css:'splitbutton.css',
dependencies:['menubutton']
},
switchbutton:{
js:'jquery.switchbutton.js',
css:'switchbutton.css'
},
accordion:{
js:'jquery.accordion.js',
css:'accordion.css',
dependencies:['panel']
},
calendar:{
js:'jquery.calendar.js',
css:'calendar.css'
},
textbox:{
js:'jquery.textbox.js',
css:'textbox.css',
dependencies:['validatebox','linkbutton']
},
passwordbox:{
js:'jquery.passwordbox.js',
css:'passwordbox.css',
dependencies:['textbox']
},
filebox:{
js:'jquery.filebox.js',
css:'filebox.css',
dependencies:['textbox']
},
radiobutton:{
js:'jquery.radiobutton.js',
css:'radiobutton.css'
},
checkbox:{
js:'jquery.checkbox.js',
css:'checkbox.css'
},
sidemenu:{
js:'jquery.sidemenu.js',
css:'sidemenu.css',
dependencies:['accordion','tree','tooltip']
},
combo:{
js:'jquery.combo.js',
css:'combo.css',
dependencies:['panel','textbox']
},
combobox:{
js:'jquery.combobox.js',
css:'combobox.css',
dependencies:['combo']
},
combotree:{
js:'jquery.combotree.js',
dependencies:['combo','tree']
},
combogrid:{
js:'jquery.combogrid.js',
dependencies:['combo','datagrid']
},
combotreegrid:{
js:'jquery.combotreegrid.js',
dependencies:['combo','treegrid']
},
tagbox:{
js:'jquery.tagbox.js',
dependencies:['combobox']
},
validatebox:{
js:'jquery.validatebox.js',
css:'validatebox.css',
dependencies:['tooltip']
},
numberbox:{
js:'jquery.numberbox.js',
dependencies:['textbox']
},
searchbox:{
js:'jquery.searchbox.js',
css:'searchbox.css',
dependencies:['menubutton','textbox']
},
spinner:{
js:'jquery.spinner.js',
css:'spinner.css',
dependencies:['textbox']
},
numberspinner:{
js:'jquery.numberspinner.js',
dependencies:['spinner','numberbox']
},
timespinner:{
js:'jquery.timespinner.js',
dependencies:['spinner']
},
timepicker:{
js:'jquery.timepicker.js',
css:'timepicker.css',
dependencies:['combo']
},
tree:{
js:'jquery.tree.js',
css:'tree.css',
dependencies:['draggable','droppable']
},
datebox:{
js:'jquery.datebox.js',
css:'datebox.css',
dependencies:['calendar','combo']
},
datetimebox:{
js:'jquery.datetimebox.js',
dependencies:['datebox','timespinner']
},
slider:{
js:'jquery.slider.js',
dependencies:['draggable']
},
parser:{
js:'jquery.parser.js',
css:'flex.css'
},
mobile:{
js:'jquery.mobile.js'
}
};
var locales = {
'af':'easyui-lang-af.js',
'ar':'easyui-lang-ar.js',
'bg':'easyui-lang-bg.js',
'ca':'easyui-lang-ca.js',
'cs':'easyui-lang-cs.js',
'cz':'easyui-lang-cz.js',
'da':'easyui-lang-da.js',
'de':'easyui-lang-de.js',
'el':'easyui-lang-el.js',
'en':'easyui-lang-en.js',
'es':'easyui-lang-es.js',
'fr':'easyui-lang-fr.js',
'it':'easyui-lang-it.js',
'jp':'easyui-lang-jp.js',
'nl':'easyui-lang-nl.js',
'pl':'easyui-lang-pl.js',
'pt_BR':'easyui-lang-pt_BR.js',
'ru':'easyui-lang-ru.js',
'sv_SE':'easyui-lang-sv_SE.js',
'tr':'easyui-lang-tr.js',
'zh_CN':'easyui-lang-zh_CN.js',
'zh_TW':'easyui-lang-zh_TW.js'
};
var queues = {};
function loadJs(url, callback){
var done = false;
var script = document.createElement('script');
script.type = 'text/javascript';
script.language = 'javascript';
script.src = url;
script.onload = script.onreadystatechange = function(){
if (!done && (!script.readyState || script.readyState == 'loaded' || script.readyState == 'complete')){
done = true;
script.onload = script.onreadystatechange = null;
if (callback){
callback.call(script);
}
}
}
document.getElementsByTagName("head")[0].appendChild(script);
}
function runJs(url, callback){
loadJs(url, function(){
document.getElementsByTagName("head")[0].removeChild(this);
if (callback){
callback();
}
});
}
function loadCss(url, callback){
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.media = 'screen';
link.href = url;
document.getElementsByTagName('head')[0].appendChild(link);
if (callback){
callback.call(link);
}
}
function loadSingle(name, callback){
queues[name] = 'loading';
var module = modules[name];
var jsStatus = 'loading';
var cssStatus = (easyloader.css && module['css']) ? 'loading' : 'loaded';
if (easyloader.css && module['css']){
if (/^http/i.test(module['css'])){
var url = module['css'];
} else {
var url = easyloader.base + 'themes/' + easyloader.theme + '/' + module['css'];
}
loadCss(url, function(){
cssStatus = 'loaded';
if (jsStatus == 'loaded' && cssStatus == 'loaded'){
finish();
}
});
}
if (/^http/i.test(module['js'])){
var url = module['js'];
} else {
var url = easyloader.base + 'plugins/' + module['js'];
}
loadJs(url, function(){
jsStatus = 'loaded';
if (jsStatus == 'loaded' && cssStatus == 'loaded'){
finish();
}
});
function finish(){
queues[name] = 'loaded';
easyloader.onProgress(name);
if (callback){
callback();
}
}
}
function loadModule(name, callback){
var mm = [];
var doLoad = false;
if (typeof name == 'string'){
add(name);
} else {
for(var i=0; i<name.length; i++){
add(name[i]);
}
}
mm.unshift('parser');
function add(name){
if (!modules[name]) return;
var d = modules[name]['dependencies'];
if (d){
for(var i=0; i<d.length; i++){
add(d[i]);
}
}
mm.push(name);
}
function finish(){
if (callback){
if (window.jQuery){
window.jQuery.parser.parseVars();
}
callback();
}
easyloader.onLoad(name);
}
var time = 0;
function loadMm(){
if (mm.length){
var m = mm[0]; // the first module
if (!queues[m]){
doLoad = true;
loadSingle(m, function(){
mm.shift();
loadMm();
});
} else if (queues[m] == 'loaded'){
mm.shift();
loadMm();
} else {
if (time < easyloader.timeout){
time += 10;
setTimeout(arguments.callee, 10);
}
}
} else {
if (easyloader.locale && doLoad == true && locales[easyloader.locale]){
var url = easyloader.base + 'locale/' + locales[easyloader.locale];
runJs(url, function(){
finish();
});
} else {
finish();
}
}
}
loadMm();
}
easyloader = {
modules:modules,
locales:locales,
base:'.',
theme:'default',
css:true,
locale:null,
timeout:2000,
load: function(name, callback){
if (/\.css$/i.test(name)){
if (/^http/i.test(name)){
loadCss(name, callback);
} else {
loadCss(easyloader.base + name, callback);
}
} else if (/\.js$/i.test(name)){
if (/^http/i.test(name)){
loadJs(name, callback);
} else {
loadJs(easyloader.base + name, callback);
}
} else {
loadModule(name, callback);
}
},
onProgress: function(name){},
onLoad: function(name){}
};
var scripts = document.getElementsByTagName('script');
for(var i=0; i<scripts.length; i++){
var src = scripts[i].src;
if (!src) continue;
var m = src.match(/easyloader\.js(\W|$)/i);
if (m){
easyloader.base = src.substring(0, m.index);
}
}
window.using = easyloader.load;
if (window.jQuery){
jQuery(function(){
easyloader.load('parser', function(){
jQuery.parser.parse();
});
});
}
})();

View File

@@ -0,0 +1,494 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* accordion - EasyUI for jQuery
*
* Dependencies:
* panel
*
*/
(function($){
// function setSize(container, param){
// var state = $.data(container, 'accordion');
// var opts = state.options;
// var panels = state.panels;
// var cc = $(container);
// if (param){
// $.extend(opts, {
// width: param.width,
// height: param.height
// });
// }
// cc._size(opts);
// var headerHeight = 0;
// var bodyHeight = 'auto';
// var headers = cc.find('>.panel>.accordion-header');
// if (headers.length){
// headerHeight = $(headers[0]).css('height', '')._outerHeight();
// }
// if (!isNaN(parseInt(opts.height))){
// bodyHeight = cc.height() - headerHeight*headers.length;
// }
// _resize(true, bodyHeight - _resize(false) + 1);
// function _resize(collapsible, height){
// var totalHeight = 0;
// for(var i=0; i<panels.length; i++){
// var p = panels[i];
// var h = p.panel('header')._outerHeight(headerHeight);
// if (p.panel('options').collapsible == collapsible){
// var pheight = isNaN(height) ? undefined : (height+headerHeight*h.length);
// p.panel('resize', {
// width: cc.width(),
// height: (collapsible ? pheight : undefined)
// });
// totalHeight += p.panel('panel').outerHeight()-headerHeight*h.length;
// }
// }
// return totalHeight;
// }
// }
function setSize(container, param){
var state = $.data(container, 'accordion');
var opts = state.options;
var panels = state.panels;
var cc = $(container);
var isHorizontal = (opts.halign=='left' || opts.halign=='right');
cc.children('.panel-last').removeClass('panel-last');
cc.children('.panel:last').addClass('panel-last');
if (param){
$.extend(opts, {
width: param.width,
height: param.height
});
}
cc._size(opts);
var headerHeight = 0;
var bodyHeight = 'auto';
var headers = cc.find('>.panel>.accordion-header');
if (headers.length){
if (isHorizontal){
// $(panels[0]).panel('resize', {width:cc.width(),height:cc.height()});
$(headers[0]).next().panel('resize', {width:cc.width(),height:cc.height()});
headerHeight = $(headers[0])._outerWidth();
} else {
headerHeight = $(headers[0]).css('height', '')._outerHeight();
}
}
if (!isNaN(parseInt(opts.height))){
if (isHorizontal){
bodyHeight = cc.width() - headerHeight*headers.length;
} else {
bodyHeight = cc.height() - headerHeight*headers.length;
}
}
// _resize(true, bodyHeight - _resize(false) + 1);
_resize(true, bodyHeight - _resize(false));
function _resize(collapsible, height){
var totalHeight = 0;
for(var i=0; i<panels.length; i++){
var p = panels[i];
if (isHorizontal){
var h = p.panel('header')._outerWidth(headerHeight);
} else {
var h = p.panel('header')._outerHeight(headerHeight);
}
if (p.panel('options').collapsible == collapsible){
var pheight = isNaN(height) ? undefined : (height+headerHeight*h.length);
if (isHorizontal){
p.panel('resize', {
height: cc.height(),
width: (collapsible ? pheight : undefined)
});
totalHeight += p.panel('panel')._outerWidth()-headerHeight*h.length;
} else {
p.panel('resize', {
width: cc.width(),
height: (collapsible ? pheight : undefined)
});
totalHeight += p.panel('panel').outerHeight()-headerHeight*h.length;
}
}
}
return totalHeight;
}
}
/**
* find a panel by specified property, return the panel object or panel index.
*/
function findBy(container, property, value, all){
var panels = $.data(container, 'accordion').panels;
var pp = [];
for(var i=0; i<panels.length; i++){
var p = panels[i];
if (property){
if (p.panel('options')[property] == value){
pp.push(p);
}
} else {
if (p[0] == $(value)[0]){
return i;
}
}
}
if (property){
return all ? pp : (pp.length ? pp[0] : null);
} else {
return -1;
}
}
function getSelections(container){
return findBy(container, 'collapsed', false, true);
}
function getSelected(container){
var pp = getSelections(container);
return pp.length ? pp[0] : null;
}
/**
* get panel index, start with 0
*/
function getPanelIndex(container, panel){
return findBy(container, null, panel);
}
/**
* get the specified panel.
*/
function getPanel(container, which){
var panels = $.data(container, 'accordion').panels;
if (typeof which == 'number'){
if (which < 0 || which >= panels.length){
return null;
} else {
return panels[which];
}
}
return findBy(container, 'title', which);
}
function setProperties(container){
var opts = $.data(container, 'accordion').options;
var cc = $(container);
if (opts.border){
cc.removeClass('accordion-noborder');
} else {
cc.addClass('accordion-noborder');
}
}
function init(container){
var state = $.data(container, 'accordion');
var cc = $(container);
cc.addClass('accordion');
state.panels = [];
cc.children('div').each(function(){
var opts = $.extend({}, $.parser.parseOptions(this), {
selected: ($(this).attr('selected') ? true : undefined)
});
var pp = $(this);
state.panels.push(pp);
createPanel(container, pp, opts);
});
cc._bind('_resize', function(e,force){
if ($(this).hasClass('easyui-fluid') || force){
setSize(container);
}
return false;
});
}
function createPanel(container, pp, options){
var opts = $.data(container, 'accordion').options;
pp.panel($.extend({}, {
collapsible: true,
minimizable: false,
maximizable: false,
closable: false,
doSize: false,
collapsed: true,
headerCls: 'accordion-header',
bodyCls: 'accordion-body',
halign: opts.halign
}, options, {
onBeforeExpand: function(){
if (options.onBeforeExpand){
if (options.onBeforeExpand.call(this) == false){return false}
}
if (!opts.multiple){
// get all selected panel
var all = $.grep(getSelections(container), function(p){
return p.panel('options').collapsible;
});
for(var i=0; i<all.length; i++){
unselect(container, getPanelIndex(container, all[i]));
}
}
var header = $(this).panel('header');
header.addClass('accordion-header-selected');
header.find('.accordion-collapse').removeClass('accordion-expand');
},
onExpand: function(){
$(container).find('>.panel-last>.accordion-header').removeClass('accordion-header-border');
if (options.onExpand){options.onExpand.call(this)}
opts.onSelect.call(container, $(this).panel('options').title, getPanelIndex(container, this));
},
onBeforeCollapse: function(){
if (options.onBeforeCollapse){
if (options.onBeforeCollapse.call(this) == false){return false}
}
$(container).find('>.panel-last>.accordion-header').addClass('accordion-header-border');
var header = $(this).panel('header');
header.removeClass('accordion-header-selected');
header.find('.accordion-collapse').addClass('accordion-expand');
},
onCollapse: function(){
if (isNaN(parseInt(opts.height))){
$(container).find('>.panel-last>.accordion-header').removeClass('accordion-header-border');
}
if (options.onCollapse){options.onCollapse.call(this)}
opts.onUnselect.call(container, $(this).panel('options').title, getPanelIndex(container, this));
}
}));
var header = pp.panel('header');
var tool = header.children('div.panel-tool');
tool.children('a.panel-tool-collapse').hide(); // hide the old collapse button
var t = $('<a href="javascript:;"></a>').addClass('accordion-collapse accordion-expand').appendTo(tool);
t._bind('click', function(){
togglePanel(pp);
return false;
});
pp.panel('options').collapsible ? t.show() : t.hide();
if (opts.halign=='left' || opts.halign=='right'){
t.hide();
}
header._bind('click', function(){
togglePanel(pp);
return false;
})
function togglePanel(p){
var popts = p.panel('options');
if (popts.collapsible){
var index = getPanelIndex(container, p);
if (popts.collapsed){
select(container, index);
} else {
unselect(container, index);
}
}
}
}
/**
* select and set the specified panel active
*/
function select(container, which){
var p = getPanel(container, which);
if (!p){return}
stopAnimate(container);
var opts = $.data(container, 'accordion').options;
p.panel('expand', opts.animate);
}
function unselect(container, which){
var p = getPanel(container, which);
if (!p){return}
stopAnimate(container);
var opts = $.data(container, 'accordion').options;
p.panel('collapse', opts.animate);
}
function doFirstSelect(container){
var opts = $.data(container, 'accordion').options;
$(container).find('>.panel-last>.accordion-header').addClass('accordion-header-border');
var p = findBy(container, 'selected', true);
if (p){
_select(getPanelIndex(container, p));
} else {
_select(opts.selected);
}
function _select(index){
var animate = opts.animate;
opts.animate = false;
select(container, index);
opts.animate = animate;
}
}
/**
* stop the animation of all panels
*/
function stopAnimate(container){
var panels = $.data(container, 'accordion').panels;
for(var i=0; i<panels.length; i++){
panels[i].stop(true,true);
}
}
function add(container, options){
var state = $.data(container, 'accordion');
var opts = state.options;
var panels = state.panels;
if (options.selected == undefined) options.selected = true;
stopAnimate(container);
var pp = $('<div></div>').appendTo(container);
panels.push(pp);
createPanel(container, pp, options);
setSize(container);
opts.onAdd.call(container, options.title, panels.length-1);
if (options.selected){
select(container, panels.length-1);
}
}
function remove(container, which){
var state = $.data(container, 'accordion');
var opts = state.options;
var panels = state.panels;
stopAnimate(container);
var panel = getPanel(container, which);
var title = panel.panel('options').title;
var index = getPanelIndex(container, panel);
if (!panel){return}
if (opts.onBeforeRemove.call(container, title, index) == false){return}
panels.splice(index, 1);
panel.panel('destroy');
if (panels.length){
setSize(container);
var curr = getSelected(container);
if (!curr){
select(container, 0);
}
}
opts.onRemove.call(container, title, index);
}
$.fn.accordion = function(options, param){
if (typeof options == 'string'){
return $.fn.accordion.methods[options](this, param);
}
options = options || {};
return this.each(function(){
var state = $.data(this, 'accordion');
if (state){
$.extend(state.options, options);
} else {
$.data(this, 'accordion', {
options: $.extend({}, $.fn.accordion.defaults, $.fn.accordion.parseOptions(this), options),
accordion: $(this).addClass('accordion'),
panels: []
});
init(this);
}
setProperties(this);
setSize(this);
doFirstSelect(this);
});
};
$.fn.accordion.methods = {
options: function(jq){
return $.data(jq[0], 'accordion').options;
},
panels: function(jq){
return $.data(jq[0], 'accordion').panels;
},
resize: function(jq, param){
return jq.each(function(){
setSize(this, param);
});
},
getSelections: function(jq){
return getSelections(jq[0]);
},
getSelected: function(jq){
return getSelected(jq[0]);
},
getPanel: function(jq, which){
return getPanel(jq[0], which);
},
getPanelIndex: function(jq, panel){
return getPanelIndex(jq[0], panel);
},
select: function(jq, which){
return jq.each(function(){
select(this, which);
});
},
unselect: function(jq, which){
return jq.each(function(){
unselect(this, which);
});
},
add: function(jq, options){
return jq.each(function(){
add(this, options);
});
},
remove: function(jq, which){
return jq.each(function(){
remove(this, which);
});
}
};
$.fn.accordion.parseOptions = function(target){
var t = $(target);
return $.extend({}, $.parser.parseOptions(target, [
'width','height','halign',
{fit:'boolean',border:'boolean',animate:'boolean',multiple:'boolean',selected:'number'}
]));
};
$.fn.accordion.defaults = {
width: 'auto',
height: 'auto',
fit: false,
border: true,
animate: true,
multiple: false,
selected: 0,
halign: 'top', // the header alignment: 'top','left','right'
onSelect: function(title, index){},
onUnselect: function(title, index){},
onAdd: function(title, index){},
onBeforeRemove: function(title, index){},
onRemove: function(title, index){}
};
})(jQuery);

View File

@@ -0,0 +1,456 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* calendar - EasyUI for jQuery
*
*/
(function($){
function setSize(target, param){
var opts = $.data(target, 'calendar').options;
var t = $(target);
if (param){
$.extend(opts, {
width: param.width,
height: param.height
});
}
t._size(opts, t.parent());
t.find('.calendar-body')._outerHeight(t.height() - t.find('.calendar-header')._outerHeight());
if (t.find('.calendar-menu').is(':visible')){
showSelectMenus(target);
}
}
function init(target){
$(target).addClass('calendar').html(
'<div class="calendar-header">' +
'<div class="calendar-nav calendar-prevmonth"></div>' +
'<div class="calendar-nav calendar-nextmonth"></div>' +
'<div class="calendar-nav calendar-prevyear"></div>' +
'<div class="calendar-nav calendar-nextyear"></div>' +
'<div class="calendar-title">' +
'<span class="calendar-text"></span>' +
'</div>' +
'</div>' +
'<div class="calendar-body">' +
'<div class="calendar-menu">' +
'<div class="calendar-menu-year-inner">' +
'<span class="calendar-nav calendar-menu-prev"></span>' +
'<span><input class="calendar-menu-year" type="text"></input></span>' +
'<span class="calendar-nav calendar-menu-next"></span>' +
'</div>' +
'<div class="calendar-menu-month-inner">' +
'</div>' +
'</div>' +
'</div>'
);
$(target)._bind('_resize', function(e,force){
if ($(this).hasClass('easyui-fluid') || force){
setSize(target);
}
return false;
});
}
function bindEvents(target){
var opts = $.data(target, 'calendar').options;
var menu = $(target).find('.calendar-menu');
menu.find('.calendar-menu-year')._unbind('.calendar')._bind('keypress.calendar', function(e){
if (e.keyCode == 13){
setDate(true);
}
});
$(target)._unbind('.calendar')._bind('mouseover.calendar', function(e){
var t = toTarget(e.target);
if (t.hasClass('calendar-nav') || t.hasClass('calendar-text') || (t.hasClass('calendar-day') && !t.hasClass('calendar-disabled'))){
t.addClass('calendar-nav-hover');
}
})._bind('mouseout.calendar', function(e){
var t = toTarget(e.target);
if (t.hasClass('calendar-nav') || t.hasClass('calendar-text') || (t.hasClass('calendar-day') && !t.hasClass('calendar-disabled'))){
t.removeClass('calendar-nav-hover');
}
})._bind('click.calendar', function(e){
var t = toTarget(e.target);
if (t.hasClass('calendar-menu-next') || t.hasClass('calendar-nextyear')){
showYear(1);
} else if (t.hasClass('calendar-menu-prev') || t.hasClass('calendar-prevyear')){
showYear(-1);
} else if (t.hasClass('calendar-menu-month')){
menu.find('.calendar-selected').removeClass('calendar-selected');
t.addClass('calendar-selected');
setDate(true);
} else if (t.hasClass('calendar-prevmonth')){
showMonth(-1);
} else if (t.hasClass('calendar-nextmonth')){
showMonth(1);
} else if (t.hasClass('calendar-text')){
if (menu.is(':visible')){
menu.hide();
} else {
showSelectMenus(target);
}
} else if (t.hasClass('calendar-day')){
if (t.hasClass('calendar-disabled')){return}
var oldValue = opts.current;
t.closest('div.calendar-body').find('.calendar-selected').removeClass('calendar-selected');
t.addClass('calendar-selected');
var parts = t.attr('abbr').split(',');
var y = parseInt(parts[0]);
var m = parseInt(parts[1]);
var d = parseInt(parts[2]);
opts.current = new opts.Date(y, m-1, d);
opts.onSelect.call(target, opts.current);
if (!oldValue || oldValue.getTime() != opts.current.getTime()){
opts.onChange.call(target, opts.current, oldValue);
}
if (opts.year != y || opts.month != m){
opts.year = y;
opts.month = m;
show(target);
}
}
});
function toTarget(t){
var day = $(t).closest('.calendar-day');
if (day.length){
return day;
} else {
return $(t);
}
}
function setDate(hideMenu){
var menu = $(target).find('.calendar-menu');
var year = menu.find('.calendar-menu-year').val();
var month = menu.find('.calendar-selected').attr('abbr');
if (!isNaN(year)){
opts.year = parseInt(year);
opts.month = parseInt(month);
show(target);
}
if (hideMenu){menu.hide()}
}
function showYear(delta){
opts.year += delta;
show(target);
menu.find('.calendar-menu-year').val(opts.year);
}
function showMonth(delta){
opts.month += delta;
if (opts.month > 12){
opts.year++;
opts.month = 1;
} else if (opts.month < 1){
opts.year--;
opts.month = 12;
}
show(target);
menu.find('td.calendar-selected').removeClass('calendar-selected');
menu.find('td:eq(' + (opts.month-1) + ')').addClass('calendar-selected');
}
}
/**
* show the select menu that can change year or month, if the menu is not be created then create it.
*/
function showSelectMenus(target){
var opts = $.data(target, 'calendar').options;
$(target).find('.calendar-menu').show();
if ($(target).find('.calendar-menu-month-inner').is(':empty')){
$(target).find('.calendar-menu-month-inner').empty();
var t = $('<table class="calendar-mtable"></table>').appendTo($(target).find('.calendar-menu-month-inner'));
var idx = 0;
for(var i=0; i<3; i++){
var tr = $('<tr></tr>').appendTo(t);
for(var j=0; j<4; j++){
$('<td class="calendar-nav calendar-menu-month"></td>').html(opts.months[idx++]).attr('abbr',idx).appendTo(tr);
}
}
}
var body = $(target).find('.calendar-body');
var sele = $(target).find('.calendar-menu');
var seleYear = sele.find('.calendar-menu-year-inner');
var seleMonth = sele.find('.calendar-menu-month-inner');
seleYear.find('input').val(opts.year).focus();
seleMonth.find('td.calendar-selected').removeClass('calendar-selected');
seleMonth.find('td:eq('+(opts.month-1)+')').addClass('calendar-selected');
sele._outerWidth(body._outerWidth());
sele._outerHeight(body._outerHeight());
seleMonth._outerHeight(sele.height() - seleYear._outerHeight());
}
/**
* get weeks data.
*/
function getWeeks(target, year, month){
var opts = $.data(target, 'calendar').options;
var dates = [];
var lastDay = new opts.Date(year, month, 0).getDate();
for(var i=1; i<=lastDay; i++) dates.push([year,month,i]);
// group date by week
var weeks = [], week = [];
var memoDay = -1;
while(dates.length > 0){
var date = dates.shift();
week.push(date);
var day = new opts.Date(date[0],date[1]-1,date[2]).getDay();
if (memoDay == day){
day = 0;
} else if (day == (opts.firstDay==0 ? 7 : opts.firstDay) - 1){
weeks.push(week);
week = [];
}
memoDay = day;
}
if (week.length){
weeks.push(week);
}
var firstWeek = weeks[0];
if (firstWeek.length < 7){
while(firstWeek.length < 7){
var firstDate = firstWeek[0];
var date = new opts.Date(firstDate[0],firstDate[1]-1,firstDate[2]-1)
firstWeek.unshift([date.getFullYear(), date.getMonth()+1, date.getDate()]);
}
} else {
var firstDate = firstWeek[0];
var week = [];
for(var i=1; i<=7; i++){
var date = new opts.Date(firstDate[0], firstDate[1]-1, firstDate[2]-i);
week.unshift([date.getFullYear(), date.getMonth()+1, date.getDate()]);
}
weeks.unshift(week);
}
var lastWeek = weeks[weeks.length-1];
while(lastWeek.length < 7){
var lastDate = lastWeek[lastWeek.length-1];
var date = new opts.Date(lastDate[0], lastDate[1]-1, lastDate[2]+1);
lastWeek.push([date.getFullYear(), date.getMonth()+1, date.getDate()]);
}
if (weeks.length < 6){
var lastDate = lastWeek[lastWeek.length-1];
var week = [];
for(var i=1; i<=7; i++){
var date = new opts.Date(lastDate[0], lastDate[1]-1, lastDate[2]+i);
week.push([date.getFullYear(), date.getMonth()+1, date.getDate()]);
}
weeks.push(week);
}
return weeks;
}
/**
* show the calendar day.
*/
function show(target){
var opts = $.data(target, 'calendar').options;
if (opts.current && !opts.validator.call(target, opts.current)){
opts.current = null;
}
var now = new opts.Date();
var todayInfo = now.getFullYear()+','+(now.getMonth()+1)+','+now.getDate();
var currentInfo = opts.current ? (opts.current.getFullYear()+','+(opts.current.getMonth()+1)+','+opts.current.getDate()) : '';
// calulate the saturday and sunday index
var saIndex = 6 - opts.firstDay;
var suIndex = saIndex + 1;
if (saIndex >= 7) saIndex -= 7;
if (suIndex >= 7) suIndex -= 7;
$(target).find('.calendar-title span').html(opts.months[opts.month-1] + ' ' + opts.year);
var body = $(target).find('div.calendar-body');
body.children('table').remove();
var data = ['<table class="calendar-dtable" cellspacing="0" cellpadding="0" border="0">'];
data.push('<thead><tr>');
if (opts.showWeek){
data.push('<th class="calendar-week">'+opts.weekNumberHeader+'</th>');
}
for(var i=opts.firstDay; i<opts.weeks.length; i++){
data.push('<th>'+opts.weeks[i]+'</th>');
}
for(var i=0; i<opts.firstDay; i++){
data.push('<th>'+opts.weeks[i]+'</th>');
}
data.push('</tr></thead>');
data.push('<tbody>');
var weeks = getWeeks(target, opts.year, opts.month);
for(var i=0; i<weeks.length; i++){
var week = weeks[i];
var cls = '';
if (i == 0){cls = 'calendar-first';}
else if (i == weeks.length - 1){cls = 'calendar-last';}
data.push('<tr class="' + cls + '">');
if (opts.showWeek){
var weekNumber = opts.getWeekNumber(new opts.Date(week[0][0], parseInt(week[0][1])-1, week[0][2]));
data.push('<td class="calendar-week">'+weekNumber+'</td>');
}
for(var j=0; j<week.length; j++){
var day = week[j];
var s = day[0]+','+day[1]+','+day[2];
var dvalue = new opts.Date(day[0], parseInt(day[1])-1, day[2]);
var d = opts.formatter.call(target, dvalue);
var css = opts.styler.call(target, dvalue);
var classValue = '';
var styleValue = '';
if (typeof css == 'string'){
styleValue = css;
} else if (css){
classValue = css['class'] || '';
styleValue = css['style'] || '';
}
var cls = 'calendar-day';
if (!(opts.year == day[0] && opts.month == day[1])){
cls += ' calendar-other-month';
}
if (s == todayInfo){cls += ' calendar-today';}
if (s == currentInfo){cls += ' calendar-selected';}
if (j == saIndex){cls += ' calendar-saturday';}
else if (j == suIndex){cls += ' calendar-sunday';}
if (j == 0){cls += ' calendar-first';}
else if (j == week.length-1){cls += ' calendar-last';}
cls += ' ' + classValue;
if (!opts.validator.call(target, dvalue)){
cls += ' calendar-disabled';
}
data.push('<td class="' + cls + '" abbr="' + s + '" style="' + styleValue + '">' + d + '</td>');
}
data.push('</tr>');
}
data.push('</tbody>');
data.push('</table>');
body.append(data.join(''));
body.children('table.calendar-dtable').prependTo(body);
opts.onNavigate.call(target, opts.year, opts.month);
}
$.fn.calendar = function(options, param){
if (typeof options == 'string'){
return $.fn.calendar.methods[options](this, param);
}
options = options || {};
return this.each(function(){
var state = $.data(this, 'calendar');
if (state){
$.extend(state.options, options);
} else {
state = $.data(this, 'calendar', {
options:$.extend({}, $.fn.calendar.defaults, $.fn.calendar.parseOptions(this), options)
});
init(this);
}
if (state.options.border == false){
$(this).addClass('calendar-noborder');
}
setSize(this);
bindEvents(this);
show(this);
$(this).find('div.calendar-menu').hide(); // hide the calendar menu
});
};
$.fn.calendar.methods = {
options: function(jq){
return $.data(jq[0], 'calendar').options;
},
resize: function(jq, param){
return jq.each(function(){
setSize(this, param);
});
},
moveTo: function(jq, date){
return jq.each(function(){
var opts = $(this).calendar('options');
if (!date){
var now = new opts.Date();
$(this).calendar({
year: now.getFullYear(),
month: now.getMonth()+1,
current: date
});
return;
}
if (opts.validator.call(this, date)){
var oldValue = opts.current;
$(this).calendar({
year: date.getFullYear(),
month: date.getMonth()+1,
current: date
});
if (!oldValue || oldValue.getTime() != date.getTime()){
opts.onChange.call(this, opts.current, oldValue);
}
}
});
}
};
$.fn.calendar.parseOptions = function(target){
var t = $(target);
return $.extend({}, $.parser.parseOptions(target, [
'weekNumberHeader',{firstDay:'number',fit:'boolean',border:'boolean',showWeek:'boolean'}
]));
};
$.fn.calendar.defaults = {
Date: Date,
width:180,
height:180,
fit:false,
border:true,
showWeek:false,
firstDay:0,
weeks:['S','M','T','W','T','F','S'],
months:['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
year:new Date().getFullYear(),
month:new Date().getMonth()+1,
current:(function(){
var d = new Date();
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
})(),
weekNumberHeader:'',
getWeekNumber: function(date){
var checkDate = new Date(date.getTime());
checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
var time = checkDate.getTime();
checkDate.setMonth(0);
checkDate.setDate(1);
return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
},
formatter:function(date){return date.getDate()},
styler:function(date){return ''},
validator:function(date){return true},
onSelect: function(date){},
onChange: function(newDate, oldDate){},
onNavigate: function(year, month){}
};
})(jQuery);

View File

@@ -0,0 +1,738 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* combobox - EasyUI for jQuery
*
* Dependencies:
* combo
*
*/
(function($){
function getRowIndex(target, value){
var state = $.data(target, 'combobox');
return $.easyui.indexOfArray(state.data, state.options.valueField, value);
}
/**
* scroll panel to display the specified item
*/
function scrollTo(target, value){
var opts = $.data(target, 'combobox').options;
var panel = $(target).combo('panel');
var item = opts.finder.getEl(target, value);
if (item.length){
if (item.position().top <= 0){
var h = panel.scrollTop() + item.position().top;
panel.scrollTop(h);
} else if (item.position().top + item.outerHeight() > panel.height()){
var h = panel.scrollTop() + item.position().top + item.outerHeight() - panel.height();
panel.scrollTop(h);
}
}
panel.triggerHandler('scroll'); // trigger the group sticking
}
function nav(target, dir){
var opts = $.data(target, 'combobox').options;
var panel = $(target).combobox('panel');
var item = panel.children('div.combobox-item-hover');
if (!item.length){
item = panel.children('div.combobox-item-selected');
}
item.removeClass('combobox-item-hover');
var firstSelector = 'div.combobox-item:visible:not(.combobox-item-disabled):first';
var lastSelector = 'div.combobox-item:visible:not(.combobox-item-disabled):last';
if (!item.length){
item = panel.children(dir=='next' ? firstSelector : lastSelector);
} else {
if (dir == 'next'){
item = item.nextAll(firstSelector);
if (!item.length){
item = panel.children(firstSelector);
}
} else {
item = item.prevAll(firstSelector);
if (!item.length){
item = panel.children(lastSelector);
}
}
}
if (item.length){
item.addClass('combobox-item-hover');
var row = opts.finder.getRow(target, item);
if (row){
$(target).combobox('scrollTo', row[opts.valueField]);
if (opts.selectOnNavigation){
select(target, row[opts.valueField]);
}
}
}
}
/**
* select the specified value
*/
function select(target, value, remainText){
var opts = $.data(target, 'combobox').options;
var values = $(target).combo('getValues');
if ($.inArray(value+'', values) == -1){
if (opts.multiple){
values.push(value);
} else {
values = [value];
}
setValues(target, values, remainText);
}
}
/**
* unselect the specified value
*/
function unselect(target, value){
var opts = $.data(target, 'combobox').options;
var values = $(target).combo('getValues');
var index = $.inArray(value+'', values);
if (index >= 0){
values.splice(index, 1);
setValues(target, values);
}
}
/**
* set values
*/
function setValues(target, values, remainText){
var opts = $.data(target, 'combobox').options;
var panel = $(target).combo('panel');
if (!$.isArray(values)){
values = values.split(opts.separator);
}
if (!opts.multiple){
values = values.length ? [values[0]] : [''];
}
// unselect the old rows
var oldValues = $(target).combo('getValues');
if (panel.is(':visible')){
panel.find('.combobox-item-selected').each(function(){
var row = opts.finder.getRow(target, $(this));
if (row){
if ($.easyui.indexOfArray(oldValues, row[opts.valueField]) == -1){
$(this).removeClass('combobox-item-selected');
}
}
});
}
$.map(oldValues, function(v){
if ($.easyui.indexOfArray(values, v) == -1){
var el = opts.finder.getEl(target, v);
if (el.hasClass('combobox-item-selected')){
el.removeClass('combobox-item-selected');
opts.onUnselect.call(target, opts.finder.getRow(target, v));
}
}
});
var theRow = null;
var vv = [], ss = [];
for(var i=0; i<values.length; i++){
var v = values[i];
var s = v;
var row = opts.finder.getRow(target, v);
if (row){
s = row[opts.textField];
theRow = row;
var el = opts.finder.getEl(target, v);
if (!el.hasClass('combobox-item-selected')){
el.addClass('combobox-item-selected');
opts.onSelect.call(target, row);
}
} else {
s = findText(v, opts.mappingRows) || v;
}
vv.push(v);
ss.push(s);
}
if (!remainText){
$(target).combo('setText', ss.join(opts.separator));
}
if (opts.showItemIcon){
var tb = $(target).combobox('textbox');
tb.removeClass('textbox-bgicon ' + opts.textboxIconCls);
if (theRow && theRow.iconCls){
tb.addClass('textbox-bgicon ' + theRow.iconCls);
opts.textboxIconCls = theRow.iconCls;
}
}
$(target).combo('setValues', vv);
panel.triggerHandler('scroll'); // trigger the group sticking
function findText(value, a){
var item = $.easyui.getArrayItem(a, opts.valueField, value);
return item ? item[opts.textField] : undefined;
}
}
/**
* load data, the old list items will be removed.
*/
function loadData(target, data, remainText){
var state = $.data(target, 'combobox');
var opts = state.options;
state.data = opts.loadFilter.call(target, data);
opts.view.render.call(opts.view, target, $(target).combo('panel'), state.data);
var vv = $(target).combobox('getValues');
$.easyui.forEach(state.data, false, function(row){
if (row['selected']){
$.easyui.addArrayItem(vv, row[opts.valueField]+'');
}
});
if (opts.multiple){
setValues(target, vv, remainText);
} else {
setValues(target, vv.length ? [vv[vv.length-1]] : [], remainText);
}
opts.onLoadSuccess.call(target, data);
}
/**
* request remote data if the url property is setted.
*/
function request(target, url, param, remainText){
var opts = $.data(target, 'combobox').options;
if (url){
opts.url = url;
}
param = $.extend({}, opts.queryParams, param||{});
// param = param || {};
if (opts.onBeforeLoad.call(target, param) == false) return;
opts.loader.call(target, param, function(data){
loadData(target, data, remainText);
}, function(){
opts.onLoadError.apply(this, arguments);
});
}
/**
* do the query action
*/
function doQuery(target, q){
var state = $.data(target, 'combobox');
var opts = state.options;
var highlightItem = $();
var qq = opts.multiple ? q.split(opts.separator) : [q];
if (opts.mode == 'remote'){
_setValues(qq);
request(target, null, {q:q}, true);
} else {
var panel = $(target).combo('panel');
panel.find('.combobox-item-hover').removeClass('combobox-item-hover');
panel.find('.combobox-item,.combobox-group').hide();
var data = state.data;
var vv = [];
$.map(qq, function(q){
q = $.trim(q);
var value = q;
var group = undefined;
highlightItem = $();
for(var i=0; i<data.length; i++){
var row = data[i];
if (opts.filter.call(target, q, row)){
var v = row[opts.valueField];
var s = row[opts.textField];
var g = row[opts.groupField];
var item = opts.finder.getEl(target, v).show();
if (s.toLowerCase() == q.toLowerCase()){
value = v;
if (opts.reversed){
highlightItem = item;
} else {
select(target, v, true);
}
}
if (opts.groupField && group != g){
opts.finder.getGroupEl(target, g).show();
group = g;
}
}
}
vv.push(value);
});
_setValues(vv);
}
function _setValues(vv){
if (opts.reversed){
highlightItem.addClass('combobox-item-hover');
} else {
setValues(target, opts.multiple ? (q?vv:[]) : vv, true);
}
}
}
function doEnter(target){
var t = $(target);
var opts = t.combobox('options');
var panel = t.combobox('panel');
var item = panel.children('div.combobox-item-hover');
if (item.length){
item.removeClass('combobox-item-hover');
var row = opts.finder.getRow(target, item);
var value = row[opts.valueField];
if (opts.multiple){
if (item.hasClass('combobox-item-selected')){
t.combobox('unselect', value);
} else {
t.combobox('select', value);
}
} else {
t.combobox('select', value);
}
}
var vv = [];
$.map(t.combobox('getValues'), function(v){
if (getRowIndex(target, v) >= 0){
vv.push(v);
}
});
t.combobox('setValues', vv);
if (!opts.multiple){
t.combobox('hidePanel');
}
}
/**
* create the component
*/
function create(target){
var state = $.data(target, 'combobox');
var opts = state.options;
$(target).addClass('combobox-f');
$(target).combo($.extend({}, opts, {
onShowPanel: function(){
$(this).combo('panel').find('div.combobox-item:hidden,div.combobox-group:hidden').show();
setValues(this, $(this).combobox('getValues'), true);
$(this).combobox('scrollTo', $(this).combobox('getValue'));
opts.onShowPanel.call(this);
}
}));
}
function mouseoverHandler(e){
$(this).children('div.combobox-item-hover').removeClass('combobox-item-hover');
var item = $(e.target).closest('div.combobox-item');
if (!item.hasClass('combobox-item-disabled')){
item.addClass('combobox-item-hover');
}
e.stopPropagation();
}
function mouseoutHandler(e){
$(e.target).closest('div.combobox-item').removeClass('combobox-item-hover');
e.stopPropagation();
}
function clickHandler(e){
var target = $(this).panel('options').comboTarget;
if (!target){return;}
var opts = $(target).combobox('options');
var item = $(e.target).closest('div.combobox-item');
if (!item.length || item.hasClass('combobox-item-disabled')){return}
var row = opts.finder.getRow(target, item);
if (!row){return;}
if (opts.blurTimer){
clearTimeout(opts.blurTimer);
opts.blurTimer = null;
}
opts.onClick.call(target, row);
var value = row[opts.valueField];
if (opts.multiple){
if (item.hasClass('combobox-item-selected')){
unselect(target, value);
} else {
select(target, value);
}
} else {
$(target).combobox('setValue', value).combobox('hidePanel');
}
e.stopPropagation();
}
function scrollHandler(e){
var target = $(this).panel('options').comboTarget;
if (!target){return;}
var opts = $(target).combobox('options');
if (opts.groupPosition == 'sticky'){
var stick = $(this).children('.combobox-stick');
if (!stick.length){
stick = $('<div class="combobox-stick"></div>').appendTo(this);
}
stick.hide();
var state = $(target).data('combobox');
$(this).children('.combobox-group:visible').each(function(){
var g = $(this);
var groupData = opts.finder.getGroup(target, g);
var rowData = state.data[groupData.startIndex + groupData.count - 1];
var last = opts.finder.getEl(target, rowData[opts.valueField]);
if (g.position().top < 0 && last.position().top > 0){
stick.show().html(g.html());
return false;
}
});
}
}
$.fn.combobox = function(options, param){
if (typeof options == 'string'){
var method = $.fn.combobox.methods[options];
if (method){
return method(this, param);
} else {
return this.combo(options, param);
}
}
options = options || {};
return this.each(function(){
var state = $.data(this, 'combobox');
if (state){
$.extend(state.options, options);
} else {
state = $.data(this, 'combobox', {
options: $.extend({}, $.fn.combobox.defaults, $.fn.combobox.parseOptions(this), options),
data: []
});
}
create(this);
if (state.options.data){
loadData(this, state.options.data);
} else {
var data = $.fn.combobox.parseData(this);
if (data.length){
loadData(this, data);
}
}
request(this);
});
};
$.fn.combobox.methods = {
options: function(jq){
var copts = jq.combo('options');
return $.extend($.data(jq[0], 'combobox').options, {
width: copts.width,
height: copts.height,
originalValue: copts.originalValue,
disabled: copts.disabled,
readonly: copts.readonly
});
},
cloneFrom: function(jq, from){
return jq.each(function(){
$(this).combo('cloneFrom', from);
$.data(this, 'combobox', $(from).data('combobox'));
$(this).addClass('combobox-f').attr('comboboxName', $(this).attr('textboxName'));
});
},
getData: function(jq){
return $.data(jq[0], 'combobox').data;
},
setValues: function(jq, values){
return jq.each(function(){
var opts = $(this).combobox('options');
if ($.isArray(values)){
values = $.map(values, function(value){
if (value && typeof value == 'object'){
$.easyui.addArrayItem(opts.mappingRows, opts.valueField, value);
return value[opts.valueField];
} else {
return value;
}
});
}
setValues(this, values);
});
},
setValue: function(jq, value){
return jq.each(function(){
$(this).combobox('setValues', $.isArray(value)?value:[value]);
});
},
clear: function(jq){
return jq.each(function(){
setValues(this, []);
});
},
reset: function(jq){
return jq.each(function(){
var opts = $(this).combobox('options');
if (opts.multiple){
$(this).combobox('setValues', opts.originalValue);
} else {
$(this).combobox('setValue', opts.originalValue);
}
});
},
loadData: function(jq, data){
return jq.each(function(){
loadData(this, data);
});
},
reload: function(jq, url){
return jq.each(function(){
if (typeof url == 'string'){
request(this, url);
} else {
if (url){
var opts = $(this).combobox('options');
opts.queryParams = url;
}
request(this);
}
});
},
select: function(jq, value){
return jq.each(function(){
select(this, value);
});
},
unselect: function(jq, value){
return jq.each(function(){
unselect(this, value);
});
},
scrollTo: function(jq, value){
return jq.each(function(){
scrollTo(this, value);
});
}
};
$.fn.combobox.parseOptions = function(target){
var t = $(target);
return $.extend({}, $.fn.combo.parseOptions(target), $.parser.parseOptions(target,[
'valueField','textField','groupField','groupPosition','mode','method','url',
{showItemIcon:'boolean',limitToList:'boolean'}
]));
};
$.fn.combobox.parseData = function(target){
var data = [];
var opts = $(target).combobox('options');
$(target).children().each(function(){
if (this.tagName.toLowerCase() == 'optgroup'){
var group = $(this).attr('label');
$(this).children().each(function(){
_parseItem(this, group);
});
} else {
_parseItem(this);
}
});
return data;
function _parseItem(el, group){
var t = $(el);
var row = {};
row[opts.valueField] = t.attr('value')!=undefined ? t.attr('value') : t.text();
row[opts.textField] = t.text();
row['iconCls'] = $.parser.parseOptions(el, ['iconCls']).iconCls;
row['selected'] = t.is(':selected');
row['disabled'] = t.is(':disabled');
if (group){
opts.groupField = opts.groupField || 'group';
row[opts.groupField] = group;
}
data.push(row);
}
};
var COMBOBOX_SERNO = 0;
var defaultView = {
render: function(target, container, data){
var state = $.data(target, 'combobox');
var opts = state.options;
var prefixId = $(target).attr('id')||'';
COMBOBOX_SERNO++;
state.itemIdPrefix = prefixId + '_easyui_combobox_i' + COMBOBOX_SERNO;
state.groupIdPrefix = prefixId + '_easyui_combobox_g' + COMBOBOX_SERNO;
state.groups = [];
var dd = [];
var group = undefined;
for(var i=0; i<data.length; i++){
var row = data[i];
var v = row[opts.valueField]+'';
var s = row[opts.textField];
var g = row[opts.groupField];
if (g){
if (group != g){
group = g;
state.groups.push({
value: g,
startIndex: i,
count: 1
});
dd.push('<div id="' + (state.groupIdPrefix+'_'+(state.groups.length-1)) + '" class="combobox-group">');
dd.push(opts.groupFormatter ? opts.groupFormatter.call(target, g) : g);
dd.push('</div>');
} else {
state.groups[state.groups.length-1].count++;
}
} else {
group = undefined;
}
var cls = 'combobox-item' + (row.disabled ? ' combobox-item-disabled' : '') + (g ? ' combobox-gitem' : '');
dd.push('<div id="' + (state.itemIdPrefix+'_'+i) + '" class="' + cls + '">');
if (opts.showItemIcon && row.iconCls){
dd.push('<span class="combobox-icon ' + row.iconCls + '"></span>');
}
dd.push(opts.formatter ? opts.formatter.call(target, row) : s);
dd.push('</div>');
}
$(container).html(dd.join(''));
}
};
$.fn.combobox.defaults = $.extend({}, $.fn.combo.defaults, {
valueField: 'value',
textField: 'text',
groupPosition: 'static', // or 'sticky'
groupField: null,
groupFormatter: function(group){return group;},
mode: 'local', // or 'remote'
method: 'post',
url: null,
data: null,
queryParams: {},
showItemIcon: false,
limitToList: false, // limit the inputed values to the listed items
unselectedValues: [],
mappingRows: [],
view: defaultView,
keyHandler: {
up: function(e){nav(this,'prev');e.preventDefault()},
down: function(e){nav(this,'next');e.preventDefault()},
left: function(e){},
right: function(e){},
enter: function(e){doEnter(this)},
query: function(q,e){doQuery(this, q)}
},
inputEvents: $.extend({}, $.fn.combo.defaults.inputEvents, {
blur: function(e){
$.fn.combo.defaults.inputEvents.blur(e);
var target = e.data.target;
var opts = $(target).combobox('options');
if (opts.reversed || opts.limitToList){
if (opts.blurTimer){
clearTimeout(opts.blurTimer);
}
opts.blurTimer = setTimeout(function(){
var existing = $(target).parent().length;
if (existing){
if (opts.reversed){
$(target).combobox('setValues', $(target).combobox('getValues'));
} else if (opts.limitToList){
//doEnter(target);
var vv = [];
$.map($(target).combobox('getValues'), function(v){
var index = $.easyui.indexOfArray($(target).combobox('getData'), opts.valueField, v);
if (index >= 0){
vv.push(v);
}
});
$(target).combobox('setValues', vv);
}
opts.blurTimer = null;
}
},50);
}
}
}),
panelEvents: {
mouseover: mouseoverHandler,
mouseout: mouseoutHandler,
mousedown: function(e){
e.preventDefault();
e.stopPropagation();
},
click: clickHandler,
scroll: scrollHandler
},
filter: function(q, row){
var opts = $(this).combobox('options');
return row[opts.textField].toLowerCase().indexOf(q.toLowerCase()) >= 0;
},
formatter: function(row){
var opts = $(this).combobox('options');
return row[opts.textField];
},
loader: function(param, success, error){
var opts = $(this).combobox('options');
if (!opts.url) return false;
$.ajax({
type: opts.method,
url: opts.url,
data: param,
dataType: 'json',
success: function(data){
success(data);
},
error: function(){
error.apply(this, arguments);
}
});
},
loadFilter: function(data){
return data;
},
finder:{
getEl:function(target, value){
var index = getRowIndex(target, value);
var id = $.data(target, 'combobox').itemIdPrefix + '_' + index;
return $('#'+id);
},
getGroupEl:function(target, gvalue){
var state = $.data(target, 'combobox');
var index = $.easyui.indexOfArray(state.groups, 'value', gvalue);
var id = state.groupIdPrefix + '_' + index;
return $('#'+id);
},
getGroup:function(target, p){
var state = $.data(target, 'combobox');
var index = p.attr('id').substr(state.groupIdPrefix.length+1);
return state.groups[parseInt(index)];
},
getRow:function(target, p){
var state = $.data(target, 'combobox');
var index = (p instanceof $) ? p.attr('id').substr(state.itemIdPrefix.length+1) : getRowIndex(target, p);
return state.data[parseInt(index)];
}
},
onBeforeLoad: function(param){},
onLoadSuccess: function(data){},
onLoadError: function(){},
onSelect: function(record){},
onUnselect: function(record){},
onClick: function(record){}
});
})(jQuery);

View File

@@ -0,0 +1,304 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* datebox - EasyUI for jQuery
*
* Dependencies:
* calendar
* combo
*
*/
(function($){
/**
* create date box
*/
function createBox(target){
var state = $.data(target, 'datebox');
var opts = state.options;
$(target).addClass('datebox-f').combo($.extend({}, opts, {
onShowPanel:function(){
bindEvents(this);
setButtons(this);
setCalendar(this);
setValue(this, $(this).datebox('getText'), true);
opts.onShowPanel.call(this);
}
}));
/**
* if the calendar isn't created, create it.
*/
if (!state.calendar){
var panel = $(target).combo('panel').css('overflow','hidden');
panel.panel('options').onBeforeDestroy = function(){
var c = $(this).find('.calendar-shared');
if (c.length){
c.insertBefore(c[0].pholder);
}
};
var cc = $('<div class="datebox-calendar-inner"></div>').prependTo(panel);
if (opts.sharedCalendar){
var c = $(opts.sharedCalendar);
if (!c[0].pholder){
c[0].pholder = $('<div class="calendar-pholder" style="display:none"></div>').insertAfter(c);
}
c.addClass('calendar-shared').appendTo(cc);
if (!c.hasClass('calendar')){
c.calendar();
}
state.calendar = c;
} else {
state.calendar = $('<div></div>').appendTo(cc).calendar();
}
$.extend(state.calendar.calendar('options'), {
fit:true,
border:false,
onSelect:function(date){
var target = this.target;
var opts = $(target).datebox('options');
opts.onSelect.call(target, date);
setValue(target, opts.formatter.call(target, date));
$(target).combo('hidePanel');
}
});
}
$(target).combo('textbox').parent().addClass('datebox');
$(target).datebox('initValue', opts.value);
function bindEvents(target){
var opts = $(target).datebox('options');
var panel = $(target).combo('panel');
panel._unbind('.datebox')._bind('click.datebox', function(e){
if ($(e.target).hasClass('datebox-button-a')){
var index = parseInt($(e.target).attr('datebox-button-index'));
opts.buttons[index].handler.call(e.target, target);
}
});
}
function setButtons(target){
var panel = $(target).combo('panel');
if (panel.children('div.datebox-button').length){return}
var button = $('<div class="datebox-button"><table cellspacing="0" cellpadding="0" style="width:100%"><tr></tr></table></div>').appendTo(panel);
var tr = button.find('tr');
for(var i=0; i<opts.buttons.length; i++){
var td = $('<td></td>').appendTo(tr);
var btn = opts.buttons[i];
var t = $('<a class="datebox-button-a" href="javascript:;"></a>').html($.isFunction(btn.text) ? btn.text(target) : btn.text).appendTo(td);
t.attr('datebox-button-index', i);
}
tr.find('td').css('width', (100/opts.buttons.length)+'%');
}
function setCalendar(target){
var panel = $(target).combo('panel');
var cc = panel.children('div.datebox-calendar-inner');
panel.children()._outerWidth(panel.width());
state.calendar.appendTo(cc);
state.calendar[0].target = target;
if (opts.panelHeight != 'auto'){
var height = panel.height();
panel.children().not(cc).each(function(){
height -= $(this).outerHeight();
});
cc._outerHeight(height);
}
state.calendar.calendar('resize');
}
}
/**
* called when user inputs some value in text box
*/
function doQuery(target, q){
setValue(target, q, true);
}
/**
* called when user press enter key
*/
function doEnter(target){
var state = $.data(target, 'datebox');
var opts = state.options;
var current = state.calendar.calendar('options').current;
if (current){
setValue(target, opts.formatter.call(target, current));
$(target).combo('hidePanel');
}
}
function setValue(target, value, remainText){
var state = $.data(target, 'datebox');
var opts = state.options;
var calendar = state.calendar;
calendar.calendar('moveTo', opts.parser.call(target, value));
if (remainText){
$(target).combo('setValue', value);
} else {
if (value){
value = opts.formatter.call(target, calendar.calendar('options').current);
}
$(target).combo('setText', value).combo('setValue', value);
}
}
$.fn.datebox = function(options, param){
if (typeof options == 'string'){
var method = $.fn.datebox.methods[options];
if (method){
return method(this, param);
} else {
return this.combo(options, param);
}
}
options = options || {};
return this.each(function(){
var state = $.data(this, 'datebox');
if (state){
$.extend(state.options, options);
} else {
$.data(this, 'datebox', {
options: $.extend({}, $.fn.datebox.defaults, $.fn.datebox.parseOptions(this), options)
});
}
createBox(this);
});
};
$.fn.datebox.methods = {
options: function(jq){
var copts = jq.combo('options');
return $.extend($.data(jq[0], 'datebox').options, {
width: copts.width,
height: copts.height,
originalValue: copts.originalValue,
disabled: copts.disabled,
readonly: copts.readonly
});
},
cloneFrom: function(jq, from){
return jq.each(function(){
$(this).combo('cloneFrom', from);
$.data(this, 'datebox', {
options: $.extend(true, {}, $(from).datebox('options')),
calendar: $(from).datebox('calendar')
});
$(this).addClass('datebox-f');
});
},
calendar: function(jq){ // get the calendar object
return $.data(jq[0], 'datebox').calendar;
},
initValue: function(jq, value){
return jq.each(function(){
var opts = $(this).datebox('options');
var value = opts.value;
if (value){
var date = opts.parser.call(this, value);
value = opts.formatter.call(this, date);
$(this).datebox('calendar').calendar('moveTo', date);
}
$(this).combo('initValue', value).combo('setText', value);
});
},
setValue: function(jq, value){
return jq.each(function(){
setValue(this, value);
});
},
reset: function(jq){
return jq.each(function(){
var opts = $(this).datebox('options');
$(this).datebox('setValue', opts.originalValue);
});
},
setDate: function(jq, date){
return jq.each(function(){
var opts = $(this).datebox('options');
$(this).datebox('calendar').calendar('moveTo', date);
setValue(this, date ? opts.formatter.call(this, date) : '');
});
},
getDate: function(jq){
if (jq.datebox('getValue')){
return jq.datebox('calendar').calendar('options').current;
} else {
return null;
}
}
};
$.fn.datebox.parseOptions = function(target){
return $.extend({}, $.fn.combo.parseOptions(target), $.parser.parseOptions(target, ['sharedCalendar']));
};
$.fn.datebox.defaults = $.extend({}, $.fn.combo.defaults, {
panelWidth:250,
panelHeight:'auto',
sharedCalendar:null,
keyHandler: {
up:function(e){},
down:function(e){},
left: function(e){},
right: function(e){},
enter:function(e){doEnter(this)},
query:function(q,e){doQuery(this, q)}
},
currentText:'Today',
closeText:'Close',
okText:'Ok',
buttons:[{
text: function(target){return $(target).datebox('options').currentText;},
handler: function(target){
var opts = $(target).datebox('options');
var now = new Date();
var current = new Date(now.getFullYear(), now.getMonth(), now.getDate());
$(target).datebox('calendar').calendar({
year:current.getFullYear(),
month:current.getMonth()+1,
current:current
});
opts.onSelect.call(target, current);
doEnter(target);
}
},{
text: function(target){return $(target).datebox('options').closeText;},
handler: function(target){
$(this).closest('div.combo-panel').panel('close');
}
}],
formatter:function(date){
var y = date.getFullYear();
var m = date.getMonth()+1;
var d = date.getDate();
return (m<10?('0'+m):m)+'/'+(d<10?('0'+d):d)+'/'+y;
},
parser:function(s){
var copts = $(this).datebox('calendar').calendar('options');
if (!s) return new copts.Date();
var ss = s.split('/');
var m = parseInt(ss[0],10);
var d = parseInt(ss[1],10);
var y = parseInt(ss[2],10);
if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
return new copts.Date(y,m-1,d);
} else {
return new copts.Date();
}
},
onSelect:function(date){}
});
})(jQuery);

View File

@@ -0,0 +1,399 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* draggable - EasyUI for jQuery
*
*/
(function($){
function drag(e){
var state = $.data(e.data.target, 'draggable');
var opts = state.options;
var proxy = state.proxy;
var dragData = e.data;
var left = dragData.startLeft + e.pageX - dragData.startX;
var top = dragData.startTop + e.pageY - dragData.startY;
if (proxy){
if (proxy.parent()[0] == document.body){
if (opts.deltaX != null && opts.deltaX != undefined){
left = e.pageX + opts.deltaX;
} else {
left = e.pageX - e.data.offsetWidth;
}
if (opts.deltaY != null && opts.deltaY != undefined){
top = e.pageY + opts.deltaY;
} else {
top = e.pageY - e.data.offsetHeight;
}
} else {
if (opts.deltaX != null && opts.deltaX != undefined){
left += e.data.offsetWidth + opts.deltaX;
}
if (opts.deltaY != null && opts.deltaY != undefined){
top += e.data.offsetHeight + opts.deltaY;
}
}
}
if (e.data.parent != document.body) {
left += $(e.data.parent).scrollLeft();
top += $(e.data.parent).scrollTop();
}
if (opts.axis == 'h') {
dragData.left = left;
} else if (opts.axis == 'v') {
dragData.top = top;
} else {
dragData.left = left;
dragData.top = top;
}
}
function applyDrag(e){
var state = $.data(e.data.target, 'draggable');
var opts = state.options;
var proxy = state.proxy;
if (!proxy){
proxy = $(e.data.target);
}
proxy.css({
left:e.data.left,
top:e.data.top
});
$('body').css('cursor', opts.cursor);
}
function doDown(e){
if (!$.fn.draggable.isDragging){return false;}
var state = $.data(e.data.target, 'draggable');
var opts = state.options;
var droppables = $('.droppable:visible').filter(function(){
return e.data.target != this;
}).filter(function(){
var accept = $.data(this, 'droppable').options.accept;
if (accept){
return $(accept).filter(function(){
return this == e.data.target;
}).length > 0;
} else {
return true;
}
});
state.droppables = droppables;
var proxy = state.proxy;
if (!proxy){
if (opts.proxy){
if (opts.proxy == 'clone'){
proxy = $(e.data.target).clone().insertAfter(e.data.target);
} else {
proxy = opts.proxy.call(e.data.target, e.data.target);
}
state.proxy = proxy;
} else {
proxy = $(e.data.target);
}
}
proxy.css('position', 'absolute');
drag(e);
applyDrag(e);
opts.onStartDrag.call(e.data.target, e);
return false;
}
function doMove(e){
if (!$.fn.draggable.isDragging){return false;}
var state = $.data(e.data.target, 'draggable');
drag(e);
if (state.options.onDrag.call(e.data.target, e) != false){
applyDrag(e);
}
var source = e.data.target;
state.droppables.each(function(){
var dropObj = $(this);
if (dropObj.droppable('options').disabled){return;}
var p2 = dropObj.offset();
if (e.pageX > p2.left && e.pageX < p2.left + dropObj.outerWidth()
&& e.pageY > p2.top && e.pageY < p2.top + dropObj.outerHeight()){
if (!this.entered){
$(this).trigger('_dragenter', [source]);
this.entered = true;
}
$(this).trigger('_dragover', [source]);
} else {
if (this.entered){
$(this).trigger('_dragleave', [source]);
this.entered = false;
}
}
});
return false;
}
function doUp(e){
if (!$.fn.draggable.isDragging){
clearDragging();
return false;
}
doMove(e);
var state = $.data(e.data.target, 'draggable');
var proxy = state.proxy;
var opts = state.options;
opts.onEndDrag.call(e.data.target, e);
if (opts.revert){
if (checkDrop() == true){
$(e.data.target).css({
position:e.data.startPosition,
left:e.data.startLeft,
top:e.data.startTop
});
} else {
if (proxy){
var left, top;
if (proxy.parent()[0] == document.body){
left = e.data.startX - e.data.offsetWidth;
top = e.data.startY - e.data.offsetHeight;
} else {
left = e.data.startLeft;
top = e.data.startTop;
}
proxy.animate({
left: left,
top: top
}, function(){
removeProxy();
});
} else {
$(e.data.target).animate({
left:e.data.startLeft,
top:e.data.startTop
}, function(){
$(e.data.target).css('position', e.data.startPosition);
});
}
}
} else {
$(e.data.target).css({
position:'absolute',
left:e.data.left,
top:e.data.top
});
checkDrop();
}
opts.onStopDrag.call(e.data.target, e);
clearDragging();
function removeProxy(){
if (proxy){
proxy.remove();
}
state.proxy = null;
}
function checkDrop(){
var dropped = false;
state.droppables.each(function(){
var dropObj = $(this);
if (dropObj.droppable('options').disabled){return;}
var p2 = dropObj.offset();
if (e.pageX > p2.left && e.pageX < p2.left + dropObj.outerWidth()
&& e.pageY > p2.top && e.pageY < p2.top + dropObj.outerHeight()){
if (opts.revert){
$(e.data.target).css({
position:e.data.startPosition,
left:e.data.startLeft,
top:e.data.startTop
});
}
$(this).triggerHandler('_drop', [e.data.target]);
removeProxy();
dropped = true;
this.entered = false;
return false;
}
});
if (!dropped && !opts.revert){
removeProxy();
}
return dropped;
}
return false;
}
function clearDragging(){
if ($.fn.draggable.timer){
clearTimeout($.fn.draggable.timer);
$.fn.draggable.timer = undefined;
}
$(document)._unbind('.draggable');
$.fn.draggable.isDragging = false;
setTimeout(function(){
$('body').css('cursor','');
},100);
}
$.fn.draggable = function(options, param){
if (typeof options == 'string'){
return $.fn.draggable.methods[options](this, param);
}
return this.each(function(){
var opts;
var state = $.data(this, 'draggable');
if (state) {
state.handle._unbind('.draggable');
opts = $.extend(state.options, options);
} else {
opts = $.extend({}, $.fn.draggable.defaults, $.fn.draggable.parseOptions(this), options || {});
}
var handle = opts.handle ? (typeof opts.handle=='string' ? $(opts.handle, this) : opts.handle) : $(this);
$.data(this, 'draggable', {
options: opts,
handle: handle
});
if (opts.disabled) {
$(this).css('cursor', '');
return;
}
handle._unbind('.draggable')._bind('mousemove.draggable', {target:this}, function(e){
if ($.fn.draggable.isDragging){return}
var opts = $.data(e.data.target, 'draggable').options;
if (checkArea(e)){
$(this).css('cursor', opts.cursor);
} else {
$(this).css('cursor', '');
}
})._bind('mouseleave.draggable', {target:this}, function(e){
$(this).css('cursor', '');
})._bind('mousedown.draggable', {target:this}, function(e){
if (checkArea(e) == false) return;
$(this).css('cursor', '');
var position = $(e.data.target).position();
var offset = $(e.data.target).offset();
var data = {
startPosition: $(e.data.target).css('position'),
startLeft: position.left,
startTop: position.top,
left: position.left,
top: position.top,
startX: e.pageX,
startY: e.pageY,
width: $(e.data.target).outerWidth(),
height: $(e.data.target).outerHeight(),
offsetWidth: (e.pageX - offset.left),
offsetHeight: (e.pageY - offset.top),
target: e.data.target,
parent: $(e.data.target).parent()[0]
};
$.extend(e.data, data);
var opts = $.data(e.data.target, 'draggable').options;
if (opts.onBeforeDrag.call(e.data.target, e) == false) return;
$(document)._bind('mousedown.draggable', e.data, doDown);
$(document)._bind('mousemove.draggable', e.data, doMove);
$(document)._bind('mouseup.draggable', e.data, doUp);
$.fn.draggable.timer = setTimeout(function(){
$.fn.draggable.isDragging = true;
doDown(e);
}, opts.delay);
return false;
});
// check if the handle can be dragged
function checkArea(e) {
var state = $.data(e.data.target, 'draggable');
var handle = state.handle;
var offset = $(handle).offset();
var width = $(handle).outerWidth();
var height = $(handle).outerHeight();
var t = e.pageY - offset.top;
var r = offset.left + width - e.pageX;
var b = offset.top + height - e.pageY;
var l = e.pageX - offset.left;
return Math.min(t,r,b,l) > state.options.edge;
}
});
};
$.fn.draggable.methods = {
options: function(jq){
return $.data(jq[0], 'draggable').options;
},
proxy: function(jq){
return $.data(jq[0], 'draggable').proxy;
},
enable: function(jq){
return jq.each(function(){
$(this).draggable({disabled:false});
});
},
disable: function(jq){
return jq.each(function(){
$(this).draggable({disabled:true});
});
}
};
$.fn.draggable.parseOptions = function(target){
var t = $(target);
return $.extend({},
$.parser.parseOptions(target, ['cursor','handle','axis',
{'revert':'boolean','deltaX':'number','deltaY':'number','edge':'number','delay':'number'}]), {
disabled: (t.attr('disabled') ? true : undefined)
});
};
$.fn.draggable.defaults = {
proxy:null, // 'clone' or a function that will create the proxy object,
// the function has the source parameter that indicate the source object dragged.
revert:false,
cursor:'move',
deltaX:null,
deltaY:null,
handle: null,
disabled: false,
edge:0,
axis:null, // v or h
delay:100,
onBeforeDrag: function(e){},
onStartDrag: function(e){},
onDrag: function(e){},
onEndDrag: function(e){},
onStopDrag: function(e){}
};
$.fn.draggable.isDragging = false;
})(jQuery);

View File

@@ -0,0 +1,81 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* droppable - EasyUI for jQuery
*
*/
(function($){
function init(target){
$(target).addClass('droppable');
$(target)._bind('_dragenter', function(e, source){
$.data(target, 'droppable').options.onDragEnter.apply(target, [e, source]);
});
$(target)._bind('_dragleave', function(e, source){
$.data(target, 'droppable').options.onDragLeave.apply(target, [e, source]);
});
$(target)._bind('_dragover', function(e, source){
$.data(target, 'droppable').options.onDragOver.apply(target, [e, source]);
});
$(target)._bind('_drop', function(e, source){
$.data(target, 'droppable').options.onDrop.apply(target, [e, source]);
});
}
$.fn.droppable = function(options, param){
if (typeof options == 'string'){
return $.fn.droppable.methods[options](this, param);
}
options = options || {};
return this.each(function(){
var state = $.data(this, 'droppable');
if (state){
$.extend(state.options, options);
} else {
init(this);
$.data(this, 'droppable', {
options: $.extend({}, $.fn.droppable.defaults, $.fn.droppable.parseOptions(this), options)
});
}
});
};
$.fn.droppable.methods = {
options: function(jq){
return $.data(jq[0], 'droppable').options;
},
enable: function(jq){
return jq.each(function(){
$(this).droppable({disabled:false});
});
},
disable: function(jq){
return jq.each(function(){
$(this).droppable({disabled:true});
});
}
};
$.fn.droppable.parseOptions = function(target){
var t = $(target);
return $.extend({}, $.parser.parseOptions(target, ['accept']), {
disabled: (t.attr('disabled') ? true : undefined)
});
};
$.fn.droppable.defaults = {
accept:null,
disabled:false,
onDragEnter:function(e, source){},
onDragOver:function(e, source){},
onDragLeave:function(e, source){},
onDrop:function(e, source){}
};
})(jQuery);

View File

@@ -0,0 +1,496 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* form - EasyUI for jQuery
*
*/
(function($){
/**
* submit the form
*/
function ajaxSubmit(target, options){
var opts = $.data(target, 'form').options;
$.extend(opts, options||{});
var param = $.extend({}, opts.queryParams);
if (opts.onSubmit.call(target, param) == false){return;}
// $(target).find('.textbox-text:focus').blur();
var input = $(target).find('.textbox-text:focus');
input.triggerHandler('blur');
input.focus();
var disabledFields = null; // the fields to be disabled
if (opts.dirty){
var ff = []; // all the dirty fields
$.map(opts.dirtyFields, function(f){
if ($(f).hasClass('textbox-f')){
$(f).next().find('.textbox-value').each(function(){
ff.push(this);
});
} else {
ff.push(f);
}
});
disabledFields = $(target).find('input[name]:enabled,textarea[name]:enabled,select[name]:enabled').filter(function(){
return $.inArray(this, ff) == -1;
});
// disabledFields.attr('disabled', 'disabled');
disabledFields._propAttr('disabled', true);
}
if (opts.ajax){
if (opts.iframe){
submitIframe(target, param);
} else {
if (window.FormData !== undefined){
submitXhr(target, param);
} else {
submitIframe(target, param);
}
}
} else {
$(target).submit();
}
if (opts.dirty){
// disabledFields.removeAttr('disabled');
disabledFields._propAttr('disabled', false);
}
}
function submitIframe(target, param){
var opts = $.data(target, 'form').options;
var frameId = 'easyui_frame_' + (new Date().getTime());
var frame = $('<iframe id='+frameId+' name='+frameId+'></iframe>').appendTo('body')
frame.attr('src', window.ActiveXObject ? 'javascript:false' : 'about:blank');
frame.css({
position:'absolute',
top:-1000,
left:-1000
});
frame.bind('load', cb);
submit(param);
function submit(param){
var form = $(target);
if (opts.url){
form.attr('action', opts.url);
}
var t = form.attr('target'), a = form.attr('action');
form.attr('target', frameId);
var paramFields = $();
try {
for(var n in param){
var field = $('<input type="hidden" name="' + n + '">').val(param[n]).appendTo(form);
paramFields = paramFields.add(field);
}
checkState();
form[0].submit();
} finally {
form.attr('action', a);
t ? form.attr('target', t) : form.removeAttr('target');
paramFields.remove();
}
}
function checkState(){
var f = $('#'+frameId);
if (!f.length){return}
try{
var s = f.contents()[0].readyState;
if (s && s.toLowerCase() == 'uninitialized'){
setTimeout(checkState, 100);
}
} catch(e){
cb();
}
}
var checkCount = 10;
function cb(){
var f = $('#'+frameId);
if (!f.length){return}
f.unbind();
var data = '';
try{
var body = f.contents().find('body');
data = body.html();
if (data == ''){
if (--checkCount){
setTimeout(cb, 100);
return;
}
}
var ta = body.find('>textarea');
if (ta.length){
data = ta.val();
} else {
var pre = body.find('>pre');
if (pre.length){
data = pre.html();
}
}
} catch(e){
}
opts.success.call(target, data);
setTimeout(function(){
f.unbind();
f.remove();
}, 100);
}
}
function submitXhr(target, param){
var opts = $.data(target, 'form').options;
var formData = new FormData($(target)[0]);
for(var name in param){
formData.append(name, param[name]);
}
$.ajax({
url: opts.url,
type: 'post',
xhr: function(){
var xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.addEventListener('progress', function(e){
if (e.lengthComputable) {
var total = e.total;
var position = e.loaded || e.position;
var percent = Math.ceil(position * 100 / total);
opts.onProgress.call(target, percent);
}
}, false);
}
return xhr;
},
data: formData,
dataType: 'html',
cache: false,
contentType: false,
processData: false,
complete: function(res){
opts.success.call(target, res.responseText);
}
});
}
/**
* load form data
* if data is a URL string type load from remote site,
* otherwise load from local data object.
*/
function load(target, data){
var opts = $.data(target, 'form').options;
if (typeof data == 'string'){
var param = {};
if (opts.onBeforeLoad.call(target, param) == false) return;
$.ajax({
url: data,
data: param,
dataType: 'json',
success: function(data){
_load(data);
},
error: function(){
opts.onLoadError.apply(target, arguments);
}
});
} else {
_load(data);
}
function _load(data){
var form = $(target);
for(var name in data){
var val = data[name];
if (!_checkField(name, val)){
if (!_loadBox(name, val)){
form.find('input[name="'+name+'"]').val(val);
form.find('textarea[name="'+name+'"]').val(val);
form.find('select[name="'+name+'"]').val(val);
}
}
}
opts.onLoadSuccess.call(target, data);
form.form('validate');
}
/**
* check the checkbox and radio fields
*/
function _checkField(name, val){
var plugins = ['switchbutton','radiobutton','checkbox'];
for(var i=0; i<plugins.length; i++){
var plugin = plugins[i];
var cc = $(target).find('['+plugin+'Name="'+name+'"]');
if (cc.length){
cc[plugin]('uncheck');
cc.each(function(){
if (_isChecked($(this)[plugin]('options').value, val)){
$(this)[plugin]('check');
}
});
return true;
}
}
var cc = $(target).find('input[name="'+name+'"][type=radio], input[name="'+name+'"][type=checkbox]');
if (cc.length){
cc._propAttr('checked', false);
cc.each(function(){
if (_isChecked($(this).val(), val)){
$(this)._propAttr('checked', true);
}
});
return true;
}
return false;
}
function _isChecked(v, val){
if (v == String(val) || $.inArray(v, $.isArray(val)?val:[val]) >= 0){
return true;
} else {
return false;
}
}
function _loadBox(name, val){
var field = $(target).find('[textboxName="'+name+'"],[sliderName="'+name+'"]');
if (field.length){
for(var i=0; i<opts.fieldTypes.length; i++){
var type = opts.fieldTypes[i];
var state = field.data(type);
if (state){
if (state.options.multiple || state.options.range){
field[type]('setValues', val);
} else {
field[type]('setValue', val);
}
return true;
}
}
}
return false;
}
}
/**
* clear the form fields
*/
function clear(target){
$('input,select,textarea', target).each(function(){
if ($(this).hasClass('textbox-value')){return;}
var t = this.type, tag = this.tagName.toLowerCase();
if (t == 'text' || t == 'hidden' || t == 'password' || tag == 'textarea'){
this.value = '';
} else if (t == 'file'){
var file = $(this);
if (!file.hasClass('textbox-value')){
var newfile = file.clone().val('');
newfile.insertAfter(file);
if (file.data('validatebox')){
file.validatebox('destroy');
newfile.validatebox();
} else {
file.remove();
}
}
} else if (t == 'checkbox' || t == 'radio'){
this.checked = false;
} else if (tag == 'select'){
this.selectedIndex = -1;
}
});
var tmp = $();
var form = $(target);
var opts = $.data(target, 'form').options;
for(var i=0; i<opts.fieldTypes.length; i++){
var type = opts.fieldTypes[i];
var field = form.find('.'+type+'-f').not(tmp);
if (field.length && field[type]){
field[type]('clear');
tmp = tmp.add(field);
}
}
form.form('validate');
}
function reset(target){
target.reset();
var form = $(target);
var opts = $.data(target, 'form').options;
for(var i=opts.fieldTypes.length-1; i>=0; i--){
var type = opts.fieldTypes[i];
var field = form.find('.'+type+'-f');
if (field.length && field[type]){
field[type]('reset');
}
}
form.form('validate');
}
/**
* set the form to make it can submit with ajax.
*/
function setForm(target){
var options = $.data(target, 'form').options;
$(target).unbind('.form');
if (options.ajax){
$(target).bind('submit.form', function(){
setTimeout(function(){
ajaxSubmit(target, options);
}, 0);
return false;
});
}
$(target).bind('_change.form', function(e, t){
if ($.inArray(t, options.dirtyFields) == -1){
options.dirtyFields.push(t);
}
options.onChange.call(this, t);
}).bind('change.form', function(e){
var t = e.target;
if (!$(t).hasClass('textbox-text')){
if ($.inArray(t, options.dirtyFields) == -1){
options.dirtyFields.push(t);
}
options.onChange.call(this, t);
}
});
setValidation(target, options.novalidate);
}
function initForm(target, options){
options = options || {};
var state = $.data(target, 'form');
if (state){
$.extend(state.options, options);
} else {
$.data(target, 'form', {
options: $.extend({}, $.fn.form.defaults, $.fn.form.parseOptions(target), options)
});
}
}
function validate(target){
if ($.fn.validatebox){
var t = $(target);
t.find('.validatebox-text:not(:disabled)').validatebox('validate');
var invalidbox = t.find('.validatebox-invalid');
invalidbox.filter(':not(:disabled):first').focus();
return invalidbox.length == 0;
}
return true;
}
function setValidation(target, novalidate){
var opts = $.data(target, 'form').options;
opts.novalidate = novalidate;
$(target).find('.validatebox-text:not(:disabled)').validatebox(novalidate ? 'disableValidation' : 'enableValidation');
}
$.fn.form = function(options, param){
if (typeof options == 'string'){
this.each(function(){
initForm(this);
});
return $.fn.form.methods[options](this, param);
}
return this.each(function(){
initForm(this, options);
setForm(this);
});
};
$.fn.form.methods = {
options: function(jq){
return $.data(jq[0], 'form').options;
},
submit: function(jq, options){
return jq.each(function(){
ajaxSubmit(this, options);
});
},
load: function(jq, data){
return jq.each(function(){
load(this, data);
});
},
clear: function(jq){
return jq.each(function(){
clear(this);
});
},
reset: function(jq){
return jq.each(function(){
reset(this);
});
},
validate: function(jq){
return validate(jq[0]);
},
disableValidation: function(jq){
return jq.each(function(){
setValidation(this, true);
});
},
enableValidation: function(jq){
return jq.each(function(){
setValidation(this, false);
});
},
resetValidation: function(jq){
return jq.each(function(){
$(this).find('.validatebox-text:not(:disabled)').validatebox('resetValidation');
});
},
resetDirty: function(jq){
return jq.each(function(){
$(this).form('options').dirtyFields = [];
});
}
};
$.fn.form.parseOptions = function(target){
var t = $(target);
return $.extend({}, $.parser.parseOptions(target, [
{ajax:'boolean',dirty:'boolean'}
]), {
url: (t.attr('action') ? t.attr('action') : undefined)
});
};
$.fn.form.defaults = {
fieldTypes: ['tagbox','combobox','combotree','combogrid','combotreegrid','datetimebox','datebox','timepicker','combo',
'datetimespinner','timespinner','numberspinner','spinner',
'slider','searchbox','numberbox','passwordbox','filebox','textbox','switchbutton','radiobutton','checkbox'],
novalidate: false,
ajax: true,
iframe: true,
dirty: false,
dirtyFields: [],
url: null,
queryParams: {},
onSubmit: function(param){return $(this).form('validate');},
onProgress: function(percent){},
success: function(data){},
onBeforeLoad: function(param){},
onLoadSuccess: function(data){},
onLoadError: function(){},
onChange: function(target){}
};
})(jQuery);

View File

@@ -0,0 +1,235 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* linkbutton - EasyUI for jQuery
*
*/
(function($){
function setSize(target, param){
var opts = $.data(target, 'linkbutton').options;
if (param){
$.extend(opts, param);
}
if (opts.width || opts.height || opts.fit){
var btn = $(target);
var parent = btn.parent();
var isVisible = btn.is(':visible');
if (!isVisible){
var spacer = $('<div style="display:none"></div>').insertBefore(target);
var style = {
position: btn.css('position'),
display: btn.css('display'),
left: btn.css('left')
};
btn.appendTo('body');
btn.css({
position: 'absolute',
display: 'inline-block',
left: -20000
});
}
btn._size(opts, parent);
var left = btn.find('.l-btn-left');
left.css('margin-top', 0);
left.css('margin-top', parseInt((btn.height()-left.height())/2)+'px');
if (!isVisible){
btn.insertAfter(spacer);
btn.css(style);
spacer.remove();
}
}
}
function createButton(target) {
var opts = $.data(target, 'linkbutton').options;
var t = $(target).empty();
t.addClass('l-btn').removeClass('l-btn-plain l-btn-selected l-btn-plain-selected l-btn-outline');
t.removeClass('l-btn-small l-btn-medium l-btn-large').addClass('l-btn-'+opts.size);
if (opts.plain){t.addClass('l-btn-plain')}
if (opts.outline){t.addClass('l-btn-outline')}
if (opts.selected){
t.addClass(opts.plain ? 'l-btn-selected l-btn-plain-selected' : 'l-btn-selected');
}
t.attr('group', opts.group || '');
t.attr('id', opts.id || '');
var inner = $('<span class="l-btn-left"></span>').appendTo(t);
if (opts.text){
$('<span class="l-btn-text"></span>').html(opts.text).appendTo(inner);
} else {
$('<span class="l-btn-text l-btn-empty">&nbsp;</span>').appendTo(inner);
}
if (opts.iconCls){
$('<span class="l-btn-icon">&nbsp;</span>').addClass(opts.iconCls).appendTo(inner);
inner.addClass('l-btn-icon-'+opts.iconAlign);
}
t._unbind('.linkbutton')._bind('focus.linkbutton',function(){
if (!opts.disabled){
$(this).addClass('l-btn-focus');
}
})._bind('blur.linkbutton',function(){
$(this).removeClass('l-btn-focus');
})._bind('click.linkbutton',function(){
if (!opts.disabled){
if (opts.toggle){
if (opts.selected){
$(this).linkbutton('unselect');
} else {
$(this).linkbutton('select');
}
}
opts.onClick.call(this);
}
// return false;
});
setSelected(target, opts.selected)
setDisabled(target, opts.disabled);
}
function setSelected(target, selected){
var opts = $.data(target, 'linkbutton').options;
if (selected){
if (opts.group){
$('a.l-btn[group="'+opts.group+'"]').each(function(){
var o = $(this).linkbutton('options');
if (o.toggle){
$(this).removeClass('l-btn-selected l-btn-plain-selected');
o.selected = false;
}
});
}
$(target).addClass(opts.plain ? 'l-btn-selected l-btn-plain-selected' : 'l-btn-selected');
opts.selected = true;
} else {
if (!opts.group){
$(target).removeClass('l-btn-selected l-btn-plain-selected');
opts.selected = false;
}
}
}
function setDisabled(target, disabled){
var state = $.data(target, 'linkbutton');
var opts = state.options;
$(target).removeClass('l-btn-disabled l-btn-plain-disabled');
if (disabled){
opts.disabled = true;
var href = $(target).attr('href');
if (href){
state.href = href;
$(target).attr('href', 'javascript:;');
}
if (target.onclick){
state.onclick = target.onclick;
target.onclick = null;
}
opts.plain ? $(target).addClass('l-btn-disabled l-btn-plain-disabled') : $(target).addClass('l-btn-disabled');
} else {
opts.disabled = false;
if (state.href) {
$(target).attr('href', state.href);
}
if (state.onclick) {
target.onclick = state.onclick;
}
}
$(target)._propAttr('disabled', disabled);
}
$.fn.linkbutton = function(options, param){
if (typeof options == 'string'){
return $.fn.linkbutton.methods[options](this, param);
}
options = options || {};
return this.each(function(){
var state = $.data(this, 'linkbutton');
if (state){
$.extend(state.options, options);
} else {
$.data(this, 'linkbutton', {
options: $.extend({}, $.fn.linkbutton.defaults, $.fn.linkbutton.parseOptions(this), options)
});
// $(this).removeAttr('disabled');
$(this)._propAttr('disabled', false);
$(this)._bind('_resize', function(e, force){
if ($(this).hasClass('easyui-fluid') || force){
setSize(this);
}
return false;
});
}
createButton(this);
setSize(this);
});
};
$.fn.linkbutton.methods = {
options: function(jq){
return $.data(jq[0], 'linkbutton').options;
},
resize: function(jq, param){
return jq.each(function(){
setSize(this, param);
});
},
enable: function(jq){
return jq.each(function(){
setDisabled(this, false);
});
},
disable: function(jq){
return jq.each(function(){
setDisabled(this, true);
});
},
select: function(jq){
return jq.each(function(){
setSelected(this, true);
});
},
unselect: function(jq){
return jq.each(function(){
setSelected(this, false);
});
}
};
$.fn.linkbutton.parseOptions = function(target){
var t = $(target);
return $.extend({}, $.parser.parseOptions(target,
['id','iconCls','iconAlign','group','size','text',{plain:'boolean',toggle:'boolean',selected:'boolean',outline:'boolean'}]
), {
disabled: (t.attr('disabled') ? true : undefined),
text: ($.trim(t.html()) || undefined),
iconCls: (t.attr('icon') || t.attr('iconCls'))
});
};
$.fn.linkbutton.defaults = {
id: null,
disabled: false,
toggle: false,
selected: false,
outline: false,
group: null,
plain: false,
text: '',
iconCls: null,
iconAlign: 'left',
size: 'small', // small,large
onClick: function(){}
};
})(jQuery);

View File

@@ -0,0 +1,648 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* menu - EasyUI for jQuery
*
*/
(function($){
$(function(){
$(document)._unbind('.menu')._bind('mousedown.menu', function(e){
var m = $(e.target).closest('div.menu,div.combo-p');
if (m.length){return}
$('body>div.menu-top:visible').not('.menu-inline').menu('hide');
hideMenu($('body>div.menu:visible').not('.menu-inline'));
});
});
/**
* initialize the target menu, the function can be invoked only once
*/
function init(target){
var opts = $.data(target, 'menu').options;
$(target).addClass('menu-top'); // the top menu
opts.inline ? $(target).addClass('menu-inline') : $(target).appendTo('body');
$(target)._bind('_resize', function(e, force){
if ($(this).hasClass('easyui-fluid') || force){
$(target).menu('resize', target);
}
return false;
});
var menus = splitMenu($(target));
for(var i=0; i<menus.length; i++){
createMenu(target, menus[i]);
}
function splitMenu(menu){
var menus = [];
menu.addClass('menu');
menus.push(menu);
if (!menu.hasClass('menu-content')){
menu.children('div').each(function(){
var submenu = $(this).children('div');
if (submenu.length){
submenu.appendTo('body');
this.submenu = submenu; // point to the sub menu
var mm = splitMenu(submenu);
menus = menus.concat(mm);
}
});
}
return menus;
}
}
function createMenu(target, div){
var menu = $(div).addClass('menu');
if (!menu.data('menu')){
menu.data('menu', {
options: $.parser.parseOptions(menu[0], ['width','height'])
});
}
if (!menu.hasClass('menu-content')){
menu.children('div').each(function(){
createItem(target, this);
});
$('<div class="menu-line"></div>').prependTo(menu);
}
setMenuSize(target, menu);
if (!menu.hasClass('menu-inline')){
menu.hide();
}
bindMenuEvent(target, menu);
}
/**
* create the menu item
*/
function createItem(target, div, options){
var item = $(div);
var itemOpts = $.extend({}, $.parser.parseOptions(item[0], ['id','name','iconCls','href',{separator:'boolean'}]), {
disabled: (item.attr('disabled') ? true : undefined),
text: $.trim(item.html()),
onclick: item[0].onclick
}, options||{});
itemOpts.onclick = itemOpts.onclick || itemOpts.handler || null;
item.data('menuitem', {
options: itemOpts
});
if (itemOpts.separator){
item.addClass('menu-sep');
}
if (!item.hasClass('menu-sep')){
item.addClass('menu-item');
item.empty().append($('<div class="menu-text"></div>').html(itemOpts.text));
if (itemOpts.iconCls){
$('<div class="menu-icon"></div>').addClass(itemOpts.iconCls).appendTo(item);
}
if (itemOpts.id){
item.attr('id', itemOpts.id);
}
if (itemOpts.onclick){
if (typeof itemOpts.onclick == 'string'){
item.attr('onclick', itemOpts.onclick);
} else {
item[0].onclick = eval(itemOpts.onclick);
}
}
if (itemOpts.disabled){
setDisabled(target, item[0], true);
}
if (item[0].submenu){
$('<div class="menu-rightarrow"></div>').appendTo(item); // has sub menu
}
}
}
function setMenuSize(target, menu){
var opts = $.data(target, 'menu').options;
var style = menu.attr('style') || '';
var isVisible = menu.is(':visible');
menu.css({
display: 'block',
left: -10000,
height: 'auto',
overflow: 'hidden'
});
menu.find('.menu-item').each(function(){
$(this)._outerHeight(opts.itemHeight);
$(this).find('.menu-text').css({
height: (opts.itemHeight-2)+'px',
lineHeight: (opts.itemHeight-2)+'px'
});
});
menu.removeClass('menu-noline').addClass(opts.noline?'menu-noline':'');
var mopts = menu.data('menu').options;
var width = mopts.width;
var height = mopts.height;
if (isNaN(parseInt(width))){
width = 0;
menu.find('div.menu-text').each(function(){
if (width < $(this).outerWidth()){
width = $(this).outerWidth();
}
});
// width += 40;
width = width ? width+40 : '';
}
var autoHeight = menu.outerHeight();
if (isNaN(parseInt(height))){
height = autoHeight;
if (menu.hasClass('menu-top') && opts.alignTo){
var at = $(opts.alignTo);
var h1 = at.offset().top - $(document).scrollTop();
var h2 = $(window)._outerHeight() + $(document).scrollTop() - at.offset().top - at._outerHeight();
height = Math.min(height, Math.max(h1, h2));
} else if (height > $(window)._outerHeight()){
height = $(window).height();
}
}
menu.attr('style', style); // restore the original style
menu.show();
menu._size($.extend({}, mopts, {
width: width,
height: height,
minWidth: mopts.minWidth || opts.minWidth,
maxWidth: mopts.maxWidth || opts.maxWidth
}));
menu.find('.easyui-fluid').triggerHandler('_resize', [true]);
menu.css('overflow', menu.outerHeight() < autoHeight ? 'auto' : 'hidden');
menu.children('div.menu-line')._outerHeight(autoHeight-2);
if (!isVisible){
menu.hide();
}
}
/**
* bind menu event
*/
function bindMenuEvent(target, menu){
var state = $.data(target, 'menu');
var opts = state.options;
menu._unbind('.menu');
for(var event in opts.events){
menu._bind(event+'.menu', {target:target}, opts.events[event]);
}
}
function mouseenterHandler(e){
var target = e.data.target;
var state = $.data(target, 'menu');
if (state.timer){
clearTimeout(state.timer);
state.timer = null;
}
}
function mouseleaveHandler(e){
var target = e.data.target;
var state = $.data(target, 'menu');
if (state.options.hideOnUnhover){
state.timer = setTimeout(function(){
hideAll(target, $(target).hasClass('menu-inline'));
}, state.options.duration);
}
}
function mouseoverHandler(e){
var target = e.data.target;
var item = $(e.target).closest('.menu-item');
if (item.length){
item.siblings().each(function(){
if (this.submenu){
hideMenu(this.submenu);
}
$(this).removeClass('menu-active');
});
// show this menu
item.addClass('menu-active');
if (item.hasClass('menu-item-disabled')){
item.addClass('menu-active-disabled');
return;
}
var submenu = item[0].submenu;
if (submenu){
$(target).menu('show', {
menu: submenu,
parent: item
});
}
}
}
function mouseoutHandler(e){
var item = $(e.target).closest('.menu-item');
if (item.length){
item.removeClass('menu-active menu-active-disabled');
var submenu = item[0].submenu;
if (submenu){
if (e.pageX>=parseInt(submenu.css('left'))){
item.addClass('menu-active');
} else {
hideMenu(submenu);
}
} else {
item.removeClass('menu-active');
}
}
}
function clickHandler(e){
var target = e.data.target;
var item = $(e.target).closest('.menu-item');
if (item.length){
var opts = $(target).data('menu').options;
var itemOpts = item.data('menuitem').options;
if (itemOpts.disabled){return;}
if (!item[0].submenu){
hideAll(target, opts.inline);
if (itemOpts.href){
location.href = itemOpts.href;
}
}
item.trigger('mouseenter');
opts.onClick.call(target, $(target).menu('getItem', item[0]));
}
}
/**
* hide top menu and it's all sub menus
*/
function hideAll(target, inline){
var state = $.data(target, 'menu');
if (state){
if ($(target).is(':visible')){
hideMenu($(target));
if (inline){
$(target).show();
} else {
state.options.onHide.call(target);
}
}
}
return false;
}
/**
* show the menu, the 'param' object has one or more properties:
* left: the left position to display
* top: the top position to display
* menu: the menu to display, if not defined, the 'target menu' is used
* parent: the parent menu item to align to
* alignTo: the element object to align to
*/
function showMenu(target, param){
param = param || {};
var left,top;
var opts = $.data(target, 'menu').options;
var menu = $(param.menu || target);
$(target).menu('resize', menu[0]);
if (menu.hasClass('menu-top')){
$.extend(opts, param);
left = opts.left;
top = opts.top;
if (opts.alignTo){
var at = $(opts.alignTo);
left = at.offset().left;
top = at.offset().top + at._outerHeight();
if (opts.align == 'right'){
left += at.outerWidth() - menu.outerWidth();
}
}
if (left + menu.outerWidth() > $(window)._outerWidth() + $(document)._scrollLeft()){
left = $(window)._outerWidth() + $(document).scrollLeft() - menu.outerWidth() - 5;
}
if (left < 0){left = 0;}
top = _fixTop(top, opts.alignTo);
} else {
var parent = param.parent; // the parent menu item
left = parent.offset().left + parent.outerWidth() - 2;
if (left + menu.outerWidth() + 5 > $(window)._outerWidth() + $(document).scrollLeft()){
left = parent.offset().left - menu.outerWidth() + 2;
}
top = _fixTop(parent.offset().top - 3);
}
function _fixTop(top, alignTo){
if (top + menu.outerHeight() > $(window)._outerHeight() + $(document).scrollTop()){
if (alignTo){
top = $(alignTo).offset().top - menu._outerHeight();
} else {
top = $(window)._outerHeight() + $(document).scrollTop() - menu.outerHeight();
}
}
if (top < 0){top = 0;}
return top;
}
menu.css(opts.position.call(target, menu[0], left, top));
menu.show(0, function(){
if (!menu[0].shadow){
menu[0].shadow = $('<div class="menu-shadow"></div>').insertAfter(menu);
}
menu[0].shadow.css({
display:(menu.hasClass('menu-inline')?'none':'block'),
zIndex:$.fn.menu.defaults.zIndex++,
left:menu.css('left'),
top:menu.css('top'),
width:menu.outerWidth(),
height:menu.outerHeight()
});
menu.css('z-index', $.fn.menu.defaults.zIndex++);
if (menu.hasClass('menu-top')){
opts.onShow.call(target);
}
});
}
function hideMenu(menu){
if (menu && menu.length){
hideit(menu);
menu.find('div.menu-item').each(function(){
if (this.submenu){
hideMenu(this.submenu);
}
$(this).removeClass('menu-active');
});
}
function hideit(m){
m.stop(true,true);
if (m[0].shadow){
m[0].shadow.hide();
}
m.hide();
}
}
function findItem(target, param){
var result = null;
var fn = $.isFunction(param) ? param : function(item){
for(var p in param){
if (item[p] != param[p]){
return false;;
}
}
return true;
}
function find(menu){
menu.children('div.menu-item').each(function(){
var opts = $(this).data('menuitem').options;
if (fn.call(target, opts) == true){
result = $(target).menu('getItem', this);
} else if (this.submenu && !result){
find(this.submenu);
}
});
}
find($(target));
return result;
}
function setDisabled(target, itemEl, disabled){
var t = $(itemEl);
if (t.hasClass('menu-item')){
var opts = t.data('menuitem').options;
opts.disabled = disabled;
if (disabled){
t.addClass('menu-item-disabled');
t[0].onclick = null;
} else {
t.removeClass('menu-item-disabled');
t[0].onclick = opts.onclick;
}
}
}
function appendItem(target, param){
var opts = $.data(target, 'menu').options;
var menu = $(target);
if (param.parent){
if (!param.parent.submenu){
var submenu = $('<div></div>').appendTo('body');
param.parent.submenu = submenu;
$('<div class="menu-rightarrow"></div>').appendTo(param.parent);
createMenu(target, submenu);
}
menu = param.parent.submenu;
}
var div = $('<div></div>').appendTo(menu);
createItem(target, div, param);
}
function removeItem(target, itemEl){
function removeit(el){
if (el.submenu){
el.submenu.children('div.menu-item').each(function(){
removeit(this);
});
var shadow = el.submenu[0].shadow;
if (shadow) shadow.remove();
el.submenu.remove();
}
$(el).remove();
}
removeit(itemEl);
}
function setVisible(target, itemEl, visible){
var menu = $(itemEl).parent();
if (visible){
$(itemEl).show();
} else {
$(itemEl).hide();
}
setMenuSize(target, menu);
}
function destroyMenu(target){
$(target).children('div.menu-item').each(function(){
removeItem(target, this);
});
if (target.shadow) target.shadow.remove();
$(target).remove();
}
$.fn.menu = function(options, param){
if (typeof options == 'string'){
return $.fn.menu.methods[options](this, param);
}
options = options || {};
return this.each(function(){
var state = $.data(this, 'menu');
if (state){
$.extend(state.options, options);
} else {
state = $.data(this, 'menu', {
options: $.extend({}, $.fn.menu.defaults, $.fn.menu.parseOptions(this), options)
});
init(this);
}
$(this).css({
left: state.options.left,
top: state.options.top
});
});
};
$.fn.menu.methods = {
options: function(jq){
return $.data(jq[0], 'menu').options;
},
show: function(jq, pos){
return jq.each(function(){
showMenu(this, pos);
});
},
hide: function(jq){
return jq.each(function(){
hideAll(this);
});
},
destroy: function(jq){
return jq.each(function(){
destroyMenu(this);
});
},
/**
* set the menu item text
* param: {
* target: DOM object, indicate the menu item
* text: string, the new text
* }
*/
setText: function(jq, param){
return jq.each(function(){
var item = $(param.target).data('menuitem').options;
item.text = param.text;
$(param.target).children('div.menu-text').html(param.text);
});
},
/**
* set the menu icon class
* param: {
* target: DOM object, indicate the menu item
* iconCls: the menu item icon class
* }
*/
setIcon: function(jq, param){
return jq.each(function(){
var item = $(param.target).data('menuitem').options;
item.iconCls = param.iconCls;
$(param.target).children('div.menu-icon').remove();
if (param.iconCls){
$('<div class="menu-icon"></div>').addClass(param.iconCls).appendTo(param.target);
}
});
},
/**
* get the menu item data that contains the following property:
* {
* target: DOM object, the menu item
* id: the menu id
* text: the menu item text
* iconCls: the icon class
* href: a remote address to redirect to
* onclick: a function to be called when the item is clicked
* }
*/
getItem: function(jq, itemEl){
var item = $(itemEl).data('menuitem').options;
return $.extend({}, item, {
target: $(itemEl)[0]
});
},
findItem: function(jq, text){
if (typeof text == 'string'){
return findItem(jq[0], function(item){
return $('<div>'+item.text+'</div>').text() == text;
});
} else {
return findItem(jq[0], text);
}
},
/**
* append menu item, the param contains following properties:
* parent,id,text,iconCls,href,onclick
* when parent property is assigned, append menu item to it
*/
appendItem: function(jq, param){
return jq.each(function(){
appendItem(this, param);
});
},
removeItem: function(jq, itemEl){
return jq.each(function(){
removeItem(this, itemEl);
});
},
enableItem: function(jq, itemEl){
return jq.each(function(){
setDisabled(this, itemEl, false);
});
},
disableItem: function(jq, itemEl){
return jq.each(function(){
setDisabled(this, itemEl, true);
});
},
showItem: function(jq, itemEl){
return jq.each(function(){
setVisible(this, itemEl, true);
});
},
hideItem: function(jq, itemEl){
return jq.each(function(){
setVisible(this, itemEl, false);
});
},
resize: function(jq, menuEl){
return jq.each(function(){
setMenuSize(this, menuEl ? $(menuEl) : $(this));
});
}
};
$.fn.menu.parseOptions = function(target){
return $.extend({}, $.parser.parseOptions(target, [
{minWidth:'number',itemHeight:'number',duration:'number',hideOnUnhover:'boolean'},
{fit:'boolean',inline:'boolean',noline:'boolean'}
]));
};
$.fn.menu.defaults = {
zIndex:110000,
left: 0,
top: 0,
alignTo: null,
align: 'left',
minWidth: 150,
// itemHeight: 22,
itemHeight: 32,
duration: 100, // Defines duration time in milliseconds to hide when the mouse leaves the menu.
hideOnUnhover: true, // Automatically hides the menu when mouse exits it
inline: false, // true to stay inside its parent, false to go on top of all elements
fit: false,
noline: false,
events: {
mouseenter: mouseenterHandler,
mouseleave: mouseleaveHandler,
mouseover: mouseoverHandler,
mouseout: mouseoutHandler,
click: clickHandler
},
position: function(target, left, top){
return {left:left,top:top}
},
onShow: function(){},
onHide: function(){},
onClick: function(item){}
};
})(jQuery);

View File

@@ -0,0 +1,438 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* parser - EasyUI for jQuery
*
*/
(function($){
$.easyui = {
/**
* Get the index of array item, return -1 when the item is not found.
*/
indexOfArray: function(a, o, id){
for(var i=0,len=a.length; i<len; i++){
if (id == undefined){
if (a[i] == o){return i;}
} else {
if (a[i][o] == id){return i;}
}
}
return -1;
},
/**
* Remove array item, 'o' parameter can be item object or id field name.
* When 'o' parameter is the id field name, the 'id' parameter is valid.
*/
removeArrayItem: function(a, o, id){
if (typeof o == 'string'){
for(var i=0,len=a.length; i<len; i++){
if (a[i][o] == id){
a.splice(i, 1);
return;
}
}
} else {
var index = this.indexOfArray(a,o);
if (index != -1){
a.splice(index, 1);
}
}
},
/**
* Add un-duplicate array item, 'o' parameter is the id field name, if the 'r' object is exists, deny the action.
*/
addArrayItem: function(a, o, r){
var index = this.indexOfArray(a, o, r ? r[o] : undefined);
if (index == -1){
a.push(r ? r : o);
} else {
a[index] = r ? r : o;
}
},
getArrayItem: function(a, o, id){
var index = this.indexOfArray(a, o, id);
return index==-1 ? null : a[index];
},
forEach: function(data, deep, callback){
var nodes = [];
for(var i=0; i<data.length; i++){
nodes.push(data[i]);
}
while(nodes.length){
var node = nodes.shift();
if (callback(node) == false){return;}
if (deep && node.children){
for(var i=node.children.length-1; i>=0; i--){
nodes.unshift(node.children[i]);
}
}
}
}
};
$.parser = {
auto: true,
emptyFn: function(){},
onComplete: function(context){},
plugins:['draggable','droppable','resizable','pagination','tooltip',
'linkbutton','menu','sidemenu','menubutton','splitbutton','switchbutton','progressbar','radiobutton','checkbox',
'tree','textbox','passwordbox','maskedbox','filebox','combo','combobox','combotree','combogrid','combotreegrid','tagbox','numberbox','validatebox','searchbox',
'spinner','numberspinner','timespinner','datetimespinner','calendar','datebox','datetimebox','timepicker','slider',
'layout','panel','datagrid','propertygrid','treegrid','datalist','tabs','accordion','window','dialog','form'
],
parse: function(context){
var aa = [];
for(var i=0; i<$.parser.plugins.length; i++){
var name = $.parser.plugins[i];
var r = $('.easyui-' + name, context);
if (r.length){
if (r[name]){
r.each(function(){
$(this)[name]($.data(this, 'options')||{});
});
} else {
aa.push({name:name,jq:r});
}
}
}
if (aa.length && window.easyloader){
var names = [];
for(var i=0; i<aa.length; i++){
names.push(aa[i].name);
}
easyloader.load(names, function(){
for(var i=0; i<aa.length; i++){
var name = aa[i].name;
var jq = aa[i].jq;
jq.each(function(){
$(this)[name]($.data(this, 'options')||{});
});
}
$.parser.onComplete.call($.parser, context);
});
} else {
$.parser.onComplete.call($.parser, context);
}
},
parseValue: function(property, value, parent, delta){
delta = delta || 0;
var v = $.trim(String(value||''));
var endchar = v.substr(v.length-1, 1);
if (endchar == '%'){
v = parseFloat(v.substr(0, v.length-1));
if (property.toLowerCase().indexOf('width') >= 0){
delta += parent[0].offsetWidth-parent[0].clientWidth;
v = Math.floor((parent.width()-delta) * v / 100.0);
} else {
delta += parent[0].offsetHeight-parent[0].clientHeight;
v = Math.floor((parent.height()-delta) * v / 100.0);
}
} else {
v = parseInt(v) || undefined;
}
return v;
},
/**
* parse options, including standard 'data-options' attribute.
*
* calling examples:
* $.parser.parseOptions(target);
* $.parser.parseOptions(target, ['id','title','width',{fit:'boolean',border:'boolean'},{min:'number'}]);
*/
parseOptions: function(target, properties){
var t = $(target);
var options = {};
var s = $.trim(t.attr('data-options'));
if (s){
if (s.substring(0, 1) != '{'){
s = '{' + s + '}';
}
options = (new Function('return ' + s))();
}
$.map(['width','height','left','top','minWidth','maxWidth','minHeight','maxHeight'], function(p){
var pv = $.trim(target.style[p] || '');
if (pv){
if (pv.indexOf('%') == -1){
pv = parseInt(pv);
if (isNaN(pv)){
pv = undefined;
}
}
options[p] = pv;
}
});
if (properties){
var opts = {};
for(var i=0; i<properties.length; i++){
var pp = properties[i];
if (typeof pp == 'string'){
opts[pp] = t.attr(pp);
} else {
for(var name in pp){
var type = pp[name];
if (type == 'boolean'){
opts[name] = t.attr(name) ? (t.attr(name) == 'true') : undefined;
} else if (type == 'number'){
opts[name] = t.attr(name)=='0' ? 0 : parseFloat(t.attr(name)) || undefined;
}
}
}
}
$.extend(options, opts);
}
return options;
},
parseVars: function(){
var d = $('<div style="position:absolute;top:-1000px;width:100px;height:100px;padding:5px"></div>').appendTo('body');
$._boxModel = d.outerWidth()!=100;
d.remove();
d = $('<div style="position:fixed"></div>').appendTo('body');
$._positionFixed = (d.css('position') == 'fixed');
d.remove();
}
};
$(function(){
$.parser.parseVars();
if (!window.easyloader && $.parser.auto){
$.parser.parse();
}
});
/**
* extend plugin to set box model width
*/
$.fn._outerWidth = function(width){
if (width == undefined){
if (this[0] == window){
return this.width() || document.body.clientWidth;
}
return this.outerWidth()||0;
}
return this._size('width', width);
};
/**
* extend plugin to set box model height
*/
$.fn._outerHeight = function(height){
if (height == undefined){
if (this[0] == window){
return this.height() || document.body.clientHeight;
}
return this.outerHeight()||0;
}
return this._size('height', height);
};
$.fn._scrollLeft = function(left){
if (left == undefined){
return this.scrollLeft();
} else {
return this.each(function(){$(this).scrollLeft(left)});
}
};
$.fn._propAttr = $.fn.prop || $.fn.attr;
$.fn._bind = $.fn.on;
$.fn._unbind = $.fn.off;
$.fn._size = function(options, parent){
if (typeof options == 'string'){
if (options == 'clear'){
return this.each(function(){
$(this).css({width:'',minWidth:'',maxWidth:'',height:'',minHeight:'',maxHeight:''});
});
} else if (options == 'fit'){
return this.each(function(){
_fit(this, this.tagName=='BODY' ? $('body') : $(this).parent(), true);
});
} else if (options == 'unfit'){
return this.each(function(){
_fit(this, $(this).parent(), false);
});
} else {
if (parent == undefined){
return _css(this[0], options);
} else {
return this.each(function(){
_css(this, options, parent);
});
}
}
} else {
return this.each(function(){
parent = parent || $(this).parent();
$.extend(options, _fit(this, parent, options.fit)||{});
var r1 = _setSize(this, 'width', parent, options);
var r2 = _setSize(this, 'height', parent, options);
if (r1 || r2){
$(this).addClass('easyui-fluid');
} else {
$(this).removeClass('easyui-fluid');
}
});
}
function _fit(target, parent, fit){
if (!parent.length){return false;}
var t = $(target)[0];
var p = parent[0];
var fcount = p.fcount || 0;
if (fit){
if (!t.fitted){
t.fitted = true;
p.fcount = fcount + 1;
$(p).addClass('panel-noscroll');
if (p.tagName == 'BODY'){
$('html').addClass('panel-fit');
}
}
return {
width: ($(p).width()||1),
height: ($(p).height()||1)
};
} else {
if (t.fitted){
t.fitted = false;
p.fcount = fcount - 1;
if (p.fcount == 0){
$(p).removeClass('panel-noscroll');
if (p.tagName == 'BODY'){
$('html').removeClass('panel-fit');
}
}
}
return false;
}
}
function _setSize(target, property, parent, options){
var t = $(target);
var p = property;
var p1 = p.substr(0,1).toUpperCase() + p.substr(1);
var min = $.parser.parseValue('min'+p1, options['min'+p1], parent);// || 0;
var max = $.parser.parseValue('max'+p1, options['max'+p1], parent);// || 99999;
var val = $.parser.parseValue(p, options[p], parent);
var fluid = (String(options[p]||'').indexOf('%') >= 0 ? true : false);
if (!isNaN(val)){
var v = Math.min(Math.max(val, min||0), max||99999);
if (!fluid){
options[p] = v;
}
t._size('min'+p1, '');
t._size('max'+p1, '');
t._size(p, v);
} else {
t._size(p, '');
t._size('min'+p1, min);
t._size('max'+p1, max);
}
return fluid || options.fit;
}
function _css(target, property, value){
var t = $(target);
if (value == undefined){
value = parseInt(target.style[property]);
if (isNaN(value)){return undefined;}
if ($._boxModel){
value += getDeltaSize();
}
return value;
} else if (value === ''){
t.css(property, '');
} else {
if ($._boxModel){
value -= getDeltaSize();
if (value < 0){value = 0;}
}
t.css(property, value+'px');
}
function getDeltaSize(){
if (property.toLowerCase().indexOf('width') >= 0){
return t.outerWidth() - t.width();
} else {
return t.outerHeight() - t.height();
}
}
}
};
})(jQuery);
/**
* support for mobile devices
*/
(function($){
var longTouchTimer = null;
var dblTouchTimer = null;
var isDblClick = false;
function onTouchStart(e){
if (e.touches.length != 1){return}
if (!isDblClick){
isDblClick = true;
dblClickTimer = setTimeout(function(){
isDblClick = false;
}, 500);
} else {
clearTimeout(dblClickTimer);
isDblClick = false;
fire(e, 'dblclick');
// e.preventDefault();
}
longTouchTimer = setTimeout(function(){
fire(e, 'contextmenu', 3);
}, 1000);
fire(e, 'mousedown');
if ($.fn.draggable.isDragging || $.fn.resizable.isResizing){
e.preventDefault();
}
}
function onTouchMove(e){
if (e.touches.length != 1){return}
if (longTouchTimer){
clearTimeout(longTouchTimer);
}
fire(e, 'mousemove');
if ($.fn.draggable.isDragging || $.fn.resizable.isResizing){
e.preventDefault();
}
}
function onTouchEnd(e){
// if (e.touches.length > 0){return}
if (longTouchTimer){
clearTimeout(longTouchTimer);
}
fire(e, 'mouseup');
if ($.fn.draggable.isDragging || $.fn.resizable.isResizing){
e.preventDefault();
}
}
function fire(e, name, which){
var event = new $.Event(name);
event.pageX = e.changedTouches[0].pageX;
event.pageY = e.changedTouches[0].pageY;
event.which = which || 1;
$(e.target).trigger(event);
}
if (document.addEventListener){
document.addEventListener("touchstart", onTouchStart, true);
document.addEventListener("touchmove", onTouchMove, true);
document.addEventListener("touchend", onTouchEnd, true);
}
})(jQuery);

View File

@@ -0,0 +1,107 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* progressbar - EasyUI for jQuery
*
* Dependencies:
* none
*
*/
(function($){
function init(target){
$(target).addClass('progressbar');
$(target).html('<div class="progressbar-text"></div><div class="progressbar-value"><div class="progressbar-text"></div></div>');
$(target)._bind('_resize', function(e,force){
if ($(this).hasClass('easyui-fluid') || force){
setSize(target);
}
return false;
});
return $(target);
}
function setSize(target,width){
var opts = $.data(target, 'progressbar').options;
var bar = $.data(target, 'progressbar').bar;
if (width) opts.width = width;
bar._size(opts);
bar.find('div.progressbar-text').css('width', bar.width());
bar.find('div.progressbar-text,div.progressbar-value').css({
height: bar.height()+'px',
lineHeight: bar.height()+'px'
});
}
$.fn.progressbar = function(options, param){
if (typeof options == 'string'){
var method = $.fn.progressbar.methods[options];
if (method){
return method(this, param);
}
}
options = options || {};
return this.each(function(){
var state = $.data(this, 'progressbar');
if (state){
$.extend(state.options, options);
} else {
state = $.data(this, 'progressbar', {
options: $.extend({}, $.fn.progressbar.defaults, $.fn.progressbar.parseOptions(this), options),
bar: init(this)
});
}
$(this).progressbar('setValue', state.options.value);
setSize(this);
});
};
$.fn.progressbar.methods = {
options: function(jq){
return $.data(jq[0], 'progressbar').options;
},
resize: function(jq, width){
return jq.each(function(){
setSize(this, width);
});
},
getValue: function(jq){
return $.data(jq[0], 'progressbar').options.value;
},
setValue: function(jq, value){
if (value < 0) value = 0;
if (value > 100) value = 100;
return jq.each(function(){
var opts = $.data(this, 'progressbar').options;
var text = opts.text.replace(/{value}/, value);
var oldValue = opts.value;
opts.value = value;
$(this).find('div.progressbar-value').width(value+'%');
$(this).find('div.progressbar-text').html(text);
if (oldValue != value){
opts.onChange.call(this, value, oldValue);
}
});
}
};
$.fn.progressbar.parseOptions = function(target){
return $.extend({}, $.parser.parseOptions(target, ['width','height','text',{value:'number'}]));
};
$.fn.progressbar.defaults = {
width: 'auto',
height: 22,
value: 0, // percentage value
text: '{value}%',
onChange:function(newValue,oldValue){}
};
})(jQuery);

View File

@@ -0,0 +1,526 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* propertygrid - EasyUI for jQuery
*
* Dependencies:
* datagrid
*
*/
(function($){
var currTarget;
$(document)._unbind('.propertygrid')._bind('mousedown.propertygrid', function(e){
var p = $(e.target).closest('div.datagrid-view,div.combo-panel');
if (p.length){return;}
stopEditing(currTarget);
currTarget = undefined;
});
function buildGrid(target){
var state = $.data(target, 'propertygrid');
var opts = $.data(target, 'propertygrid').options;
$(target).datagrid($.extend({}, opts, {
cls:'propertygrid',
view:(opts.showGroup ? opts.groupView : opts.view),
onBeforeEdit:function(index, row){
if (opts.onBeforeEdit.call(target, index, row) == false){return false;}
var dg = $(this);
var row = dg.datagrid('getRows')[index];
var col = dg.datagrid('getColumnOption', 'value');
col.editor = row.editor;
},
onClickCell:function(index, field, value){
if (currTarget != this){
stopEditing(currTarget);
currTarget = this;
}
if (opts.editIndex != index){
stopEditing(currTarget);
$(this).datagrid('beginEdit', index);
var ed = $(this).datagrid('getEditor', {index:index,field:field});
if (!ed){
ed = $(this).datagrid('getEditor', {index:index,field:'value'});
}
if (ed){
var t = $(ed.target);
var input = t.data('textbox') ? t.textbox('textbox') : t;
input.focus();
opts.editIndex = index;
}
}
opts.onClickCell.call(target, index, field, value);
},
loadFilter:function(data){
stopEditing(this);
return opts.loadFilter.call(this, data);
}
}));
}
function stopEditing(target){
var t = $(target);
if (!t.length){return}
var opts = $.data(target, 'propertygrid').options;
opts.finder.getTr(target, null, 'editing').each(function(){
var index = parseInt($(this).attr('datagrid-row-index'));
if (t.datagrid('validateRow', index)){
t.datagrid('endEdit', index);
} else {
t.datagrid('cancelEdit', index);
}
});
opts.editIndex = undefined;
}
$.fn.propertygrid = function(options, param){
if (typeof options == 'string'){
var method = $.fn.propertygrid.methods[options];
if (method){
return method(this, param);
} else {
return this.datagrid(options, param);
}
}
options = options || {};
return this.each(function(){
var state = $.data(this, 'propertygrid');
if (state){
$.extend(state.options, options);
} else {
var opts = $.extend({}, $.fn.propertygrid.defaults, $.fn.propertygrid.parseOptions(this), options);
opts.frozenColumns = $.extend(true, [], opts.frozenColumns);
opts.columns = $.extend(true, [], opts.columns);
$.data(this, 'propertygrid', {
options: opts
});
}
buildGrid(this);
});
}
$.fn.propertygrid.methods = {
options: function(jq){
return $.data(jq[0], 'propertygrid').options;
}
};
$.fn.propertygrid.parseOptions = function(target){
return $.extend({}, $.fn.datagrid.parseOptions(target), $.parser.parseOptions(target,[{showGroup:'boolean'}]));
};
// the group view definition
var groupview = $.extend({}, $.fn.datagrid.defaults.view, {
render: function(target, container, frozen){
var table = [];
var groups = this.groups;
for(var i=0; i<groups.length; i++){
table.push(this.renderGroup.call(this, target, i, groups[i], frozen));
}
$(container).html(table.join(''));
},
renderGroup: function(target, groupIndex, group, frozen){
var state = $.data(target, 'datagrid');
var opts = state.options;
var fields = $(target).datagrid('getColumnFields', frozen);
var hasFrozen = opts.frozenColumns && opts.frozenColumns.length;
if (frozen){
if (!(opts.rownumbers || hasFrozen)){
return '';
}
}
var table = [];
var css = opts.groupStyler.call(target, group.value, group.rows);
var cs = parseCss(css, 'datagrid-group');
table.push('<div group-index=' + groupIndex + ' ' + cs + '>');
if ((frozen && (opts.rownumbers || opts.frozenColumns.length)) ||
(!frozen && !(opts.rownumbers || opts.frozenColumns.length))){
table.push('<span class="datagrid-group-expander">');
table.push('<span class="datagrid-row-expander datagrid-row-collapse">&nbsp;</span>');
table.push('</span>');
}
if ((frozen && hasFrozen) || (!frozen)){
table.push('<span class="datagrid-group-title">');
table.push(opts.groupFormatter.call(target, group.value, group.rows));
table.push('</span>');
}
table.push('</div>');
table.push('<table class="datagrid-btable" cellspacing="0" cellpadding="0" border="0"><tbody>');
var index = group.startIndex;
for(var j=0; j<group.rows.length; j++) {
var css = opts.rowStyler ? opts.rowStyler.call(target, index, group.rows[j]) : '';
var classValue = '';
var styleValue = '';
if (typeof css == 'string'){
styleValue = css;
} else if (css){
classValue = css['class'] || '';
styleValue = css['style'] || '';
}
var cls = 'class="datagrid-row ' + (index % 2 && opts.striped ? 'datagrid-row-alt ' : ' ') + classValue + '"';
var style = styleValue ? 'style="' + styleValue + '"' : '';
var rowId = state.rowIdPrefix + '-' + (frozen?1:2) + '-' + index;
table.push('<tr id="' + rowId + '" datagrid-row-index="' + index + '" ' + cls + ' ' + style + '>');
table.push(this.renderRow.call(this, target, fields, frozen, index, group.rows[j]));
table.push('</tr>');
index++;
}
table.push('</tbody></table>');
return table.join('');
function parseCss(css, cls){
var classValue = '';
var styleValue = '';
if (typeof css == 'string'){
styleValue = css;
} else if (css){
classValue = css['class'] || '';
styleValue = css['style'] || '';
}
return 'class="' + cls + (classValue ? ' '+classValue : '') + '" ' +
'style="' + styleValue + '"';
}
},
bindEvents: function(target){
var state = $.data(target, 'datagrid');
var dc = state.dc;
var body = dc.body1.add(dc.body2);
var clickHandler = ($.data(body[0],'events')||$._data(body[0],'events')).click[0].handler;
body._unbind('click')._bind('click', function(e){
var tt = $(e.target);
var expander = tt.closest('span.datagrid-row-expander');
if (expander.length){
var gindex = expander.closest('div.datagrid-group').attr('group-index');
if (expander.hasClass('datagrid-row-collapse')){
$(target).datagrid('collapseGroup', gindex);
} else {
$(target).datagrid('expandGroup', gindex);
}
} else {
clickHandler(e);
}
e.stopPropagation();
});
},
onBeforeRender: function(target, rows){
var state = $.data(target, 'datagrid');
var opts = state.options;
initCss();
var groups = [];
for(var i=0; i<rows.length; i++){
var row = rows[i];
var group = getGroup(row[opts.groupField]);
if (!group){
group = {
value: row[opts.groupField],
rows: [row]
};
groups.push(group);
} else {
group.rows.push(row);
}
}
var index = 0;
var newRows = [];
for(var i=0; i<groups.length; i++){
var group = groups[i];
group.startIndex = index;
index += group.rows.length;
newRows = newRows.concat(group.rows);
}
state.data.rows = newRows;
this.groups = groups;
var that = this;
setTimeout(function(){
that.bindEvents(target);
},0);
function getGroup(value){
for(var i=0; i<groups.length; i++){
var group = groups[i];
if (group.value == value){
return group;
}
}
return null;
}
function initCss(){
if (!$('#datagrid-group-style').length){
$('head').append(
'<style id="datagrid-group-style">' +
'.datagrid-group{height:'+opts.groupHeight+'px;overflow:hidden;font-weight:bold;border-bottom:1px solid #ccc;white-space:nowrap;word-break:normal;}' +
'.datagrid-group-title,.datagrid-group-expander{display:inline-block;vertical-align:bottom;height:100%;line-height:'+opts.groupHeight+'px;padding:0 4px;}' +
'.datagrid-group-title{position:relative;}' +
'.datagrid-group-expander{width:'+opts.expanderWidth+'px;text-align:center;padding:0}' +
'.datagrid-row-expander{margin:'+Math.floor((opts.groupHeight-16)/2)+'px 0;display:inline-block;width:16px;height:16px;cursor:pointer}' +
'</style>'
);
}
}
},
onAfterRender: function(target){
$.fn.datagrid.defaults.view.onAfterRender.call(this, target);
var view = this;
var state = $.data(target, 'datagrid');
var opts = state.options;
if (!state.onResizeColumn){
state.onResizeColumn = opts.onResizeColumn;
}
if (!state.onResize){
state.onResize = opts.onResize;
}
opts.onResizeColumn = function(field, width){
view.resizeGroup(target);
state.onResizeColumn.call(target, field, width);
}
opts.onResize = function(width, height){
view.resizeGroup(target);
state.onResize.call($(target).datagrid('getPanel')[0], width, height);
}
view.resizeGroup(target);
}
});
$.extend($.fn.datagrid.methods, {
groups:function(jq){
return jq.datagrid('options').view.groups;
},
expandGroup:function(jq, groupIndex){
return jq.each(function(){
var opts = $(this).datagrid('options');
var view = $.data(this, 'datagrid').dc.view;
var group = view.find(groupIndex!=undefined ? 'div.datagrid-group[group-index="'+groupIndex+'"]' : 'div.datagrid-group');
var expander = group.find('span.datagrid-row-expander');
if (expander.hasClass('datagrid-row-expand')){
expander.removeClass('datagrid-row-expand').addClass('datagrid-row-collapse');
group.next('table').show();
}
$(this).datagrid('fixRowHeight');
if (opts.onExpandGroup){
opts.onExpandGroup.call(this, groupIndex);
}
});
},
collapseGroup:function(jq, groupIndex){
return jq.each(function(){
var opts = $(this).datagrid('options');
var view = $.data(this, 'datagrid').dc.view;
var group = view.find(groupIndex!=undefined ? 'div.datagrid-group[group-index="'+groupIndex+'"]' : 'div.datagrid-group');
var expander = group.find('span.datagrid-row-expander');
if (expander.hasClass('datagrid-row-collapse')){
expander.removeClass('datagrid-row-collapse').addClass('datagrid-row-expand');
group.next('table').hide();
}
$(this).datagrid('fixRowHeight');
if (opts.onCollapseGroup){
opts.onCollapseGroup.call(this, groupIndex);
}
});
},
scrollToGroup: function(jq, groupIndex){
return jq.each(function(){
var state = $.data(this, 'datagrid');
var dc = state.dc;
var grow = dc.body2.children('div.datagrid-group[group-index="'+groupIndex+'"]');
if (grow.length){
var groupHeight = grow.outerHeight();
var headerHeight = dc.view2.children('div.datagrid-header')._outerHeight();
var frozenHeight = dc.body2.outerHeight(true) - dc.body2.outerHeight();
var top = grow.position().top - headerHeight - frozenHeight;
if (top < 0){
dc.body2.scrollTop(dc.body2.scrollTop() + top);
} else if (top + groupHeight > dc.body2.height() - 18){
dc.body2.scrollTop(dc.body2.scrollTop() + top + groupHeight - dc.body2.height() + 18);
}
}
});
}
});
$.extend(groupview, {
refreshGroupTitle: function(target, groupIndex){
var state = $.data(target, 'datagrid');
var opts = state.options;
var dc = state.dc;
var group = this.groups[groupIndex];
var span = dc.body1.add(dc.body2).children('div.datagrid-group[group-index=' + groupIndex + ']').find('span.datagrid-group-title');
span.html(opts.groupFormatter.call(target, group.value, group.rows));
},
resizeGroup: function(target, groupIndex){
var state = $.data(target, 'datagrid');
var dc = state.dc;
var ht = dc.header2.find('table');
var fr = ht.find('tr.datagrid-filter-row').hide();
// var ww = ht.width();
var ww = dc.body2.children('table.datagrid-btable:first').width();
if (groupIndex == undefined){
var groupHeader = dc.body2.children('div.datagrid-group');
} else {
var groupHeader = dc.body2.children('div.datagrid-group[group-index=' + groupIndex + ']');
}
groupHeader._outerWidth(ww);
var opts = state.options;
if (opts.frozenColumns && opts.frozenColumns.length){
var width = dc.view1.width() - opts.expanderWidth;
var isRtl = dc.view1.css('direction').toLowerCase()=='rtl';
groupHeader.find('.datagrid-group-title').css(isRtl?'right':'left', -width+'px');
}
if (fr.length){
if (opts.showFilterBar){
fr.show();
}
}
// fr.show();
},
insertRow: function(target, index, row){
var state = $.data(target, 'datagrid');
var opts = state.options;
var dc = state.dc;
var group = null;
var groupIndex;
if (!state.data.rows.length){
$(target).datagrid('loadData', [row]);
return;
}
for(var i=0; i<this.groups.length; i++){
if (this.groups[i].value == row[opts.groupField]){
group = this.groups[i];
groupIndex = i;
break;
}
}
if (group){
if (index == undefined || index == null){
index = state.data.rows.length;
}
if (index < group.startIndex){
index = group.startIndex;
} else if (index > group.startIndex + group.rows.length){
index = group.startIndex + group.rows.length;
}
$.fn.datagrid.defaults.view.insertRow.call(this, target, index, row);
if (index >= group.startIndex + group.rows.length){
_moveTr(index, true);
_moveTr(index, false);
}
group.rows.splice(index - group.startIndex, 0, row);
} else {
group = {
value: row[opts.groupField],
rows: [row],
startIndex: state.data.rows.length
}
groupIndex = this.groups.length;
dc.body1.append(this.renderGroup.call(this, target, groupIndex, group, true));
dc.body2.append(this.renderGroup.call(this, target, groupIndex, group, false));
this.groups.push(group);
state.data.rows.push(row);
}
this.setGroupIndex(target);
this.refreshGroupTitle(target, groupIndex);
this.resizeGroup(target);
function _moveTr(index,frozen){
var serno = frozen?1:2;
var prevTr = opts.finder.getTr(target, index-1, 'body', serno);
var tr = opts.finder.getTr(target, index, 'body', serno);
tr.insertAfter(prevTr);
}
},
updateRow: function(target, index, row){
var opts = $.data(target, 'datagrid').options;
$.fn.datagrid.defaults.view.updateRow.call(this, target, index, row);
var tb = opts.finder.getTr(target, index, 'body', 2).closest('table.datagrid-btable');
var groupIndex = parseInt(tb.prev().attr('group-index'));
this.refreshGroupTitle(target, groupIndex);
},
deleteRow: function(target, index){
var state = $.data(target, 'datagrid');
var opts = state.options;
var dc = state.dc;
var body = dc.body1.add(dc.body2);
var tb = opts.finder.getTr(target, index, 'body', 2).closest('table.datagrid-btable');
var groupIndex = parseInt(tb.prev().attr('group-index'));
$.fn.datagrid.defaults.view.deleteRow.call(this, target, index);
var group = this.groups[groupIndex];
if (group.rows.length > 1){
group.rows.splice(index-group.startIndex, 1);
this.refreshGroupTitle(target, groupIndex);
} else {
body.children('div.datagrid-group[group-index='+groupIndex+']').remove();
for(var i=groupIndex+1; i<this.groups.length; i++){
body.children('div.datagrid-group[group-index='+i+']').attr('group-index', i-1);
}
this.groups.splice(groupIndex, 1);
}
this.setGroupIndex(target);
},
setGroupIndex: function(target){
var index = 0;
for(var i=0; i<this.groups.length; i++){
var group = this.groups[i];
group.startIndex = index;
index += group.rows.length;
}
}
});
// end of group view definition
$.fn.propertygrid.defaults = $.extend({}, $.fn.datagrid.defaults, {
groupHeight:28,
expanderWidth:20,
singleSelect:true,
remoteSort:false,
fitColumns:true,
loadMsg:'',
frozenColumns:[[
{field:'f',width:20,resizable:false}
]],
columns:[[
{field:'name',title:'Name',width:100,sortable:true},
{field:'value',title:'Value',width:100,resizable:false}
]],
showGroup:false,
groupView:groupview,
groupField:'group',
groupStyler: function(value,rows){return ''},
groupFormatter:function(fvalue,rows){return fvalue}
});
})(jQuery);

View File

@@ -0,0 +1,228 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* resizable - EasyUI for jQuery
*
*/
(function($){
function resize(e){
var resizeData = e.data;
var options = $.data(resizeData.target, 'resizable').options;
if (resizeData.dir.indexOf('e') != -1) {
var width = resizeData.startWidth + e.pageX - resizeData.startX;
width = Math.min(
Math.max(width, options.minWidth),
options.maxWidth
);
resizeData.width = width;
}
if (resizeData.dir.indexOf('s') != -1) {
var height = resizeData.startHeight + e.pageY - resizeData.startY;
height = Math.min(
Math.max(height, options.minHeight),
options.maxHeight
);
resizeData.height = height;
}
if (resizeData.dir.indexOf('w') != -1) {
var width = resizeData.startWidth - e.pageX + resizeData.startX;
width = Math.min(
Math.max(width, options.minWidth),
options.maxWidth
);
resizeData.width = width;
resizeData.left = resizeData.startLeft + resizeData.startWidth - resizeData.width;
}
if (resizeData.dir.indexOf('n') != -1) {
var height = resizeData.startHeight - e.pageY + resizeData.startY;
height = Math.min(
Math.max(height, options.minHeight),
options.maxHeight
);
resizeData.height = height;
resizeData.top = resizeData.startTop + resizeData.startHeight - resizeData.height;
}
}
function applySize(e){
var resizeData = e.data;
var t = $(resizeData.target);
t.css({
left: resizeData.left,
top: resizeData.top
});
if (t.outerWidth() != resizeData.width){t._outerWidth(resizeData.width)}
if (t.outerHeight() != resizeData.height){t._outerHeight(resizeData.height)}
}
function doDown(e){
$.fn.resizable.isResizing = true;
$.data(e.data.target, 'resizable').options.onStartResize.call(e.data.target, e);
return false;
}
function doMove(e){
resize(e);
if ($.data(e.data.target, 'resizable').options.onResize.call(e.data.target, e) != false){
applySize(e)
}
return false;
}
function doUp(e){
$.fn.resizable.isResizing = false;
resize(e, true);
applySize(e);
$.data(e.data.target, 'resizable').options.onStopResize.call(e.data.target, e);
$(document)._unbind('.resizable');
$('body').css('cursor','');
return false;
}
// get the resize direction
function getDirection(e) {
var opts = $(e.data.target).resizable('options');
var tt = $(e.data.target);
var dir = '';
var offset = tt.offset();
var width = tt.outerWidth();
var height = tt.outerHeight();
var edge = opts.edge;
if (e.pageY > offset.top && e.pageY < offset.top + edge) {
dir += 'n';
} else if (e.pageY < offset.top + height && e.pageY > offset.top + height - edge) {
dir += 's';
}
if (e.pageX > offset.left && e.pageX < offset.left + edge) {
dir += 'w';
} else if (e.pageX < offset.left + width && e.pageX > offset.left + width - edge) {
dir += 'e';
}
var handles = opts.handles.split(',');
handles = $.map(handles, function(h){return $.trim(h).toLowerCase();});
if ($.inArray('all', handles) >= 0 || $.inArray(dir, handles) >= 0){
return dir;
}
for(var i=0; i<dir.length; i++){
var index = $.inArray(dir.substr(i,1), handles);
if (index >= 0){
return handles[index];
}
}
return '';
}
$.fn.resizable = function(options, param){
if (typeof options == 'string'){
return $.fn.resizable.methods[options](this, param);
}
return this.each(function(){
var opts = null;
var state = $.data(this, 'resizable');
if (state) {
$(this)._unbind('.resizable');
opts = $.extend(state.options, options || {});
} else {
opts = $.extend({}, $.fn.resizable.defaults, $.fn.resizable.parseOptions(this), options || {});
$.data(this, 'resizable', {
options:opts
});
}
if (opts.disabled == true) {
return;
}
$(this)._bind('mousemove.resizable', {target:this}, function(e){
if ($.fn.resizable.isResizing){return}
var dir = getDirection(e);
$(e.data.target).css('cursor', dir ? dir+'-resize' : '');
})._bind('mouseleave.resizable', {target:this}, function(e){
$(e.data.target).css('cursor', '');
})._bind('mousedown.resizable', {target:this}, function(e){
var dir = getDirection(e);
if (dir == ''){return;}
function getCssValue(css) {
var val = parseInt($(e.data.target).css(css));
if (isNaN(val)) {
return 0;
} else {
return val;
}
}
var data = {
target: e.data.target,
dir: dir,
startLeft: getCssValue('left'),
startTop: getCssValue('top'),
left: getCssValue('left'),
top: getCssValue('top'),
startX: e.pageX,
startY: e.pageY,
startWidth: $(e.data.target).outerWidth(),
startHeight: $(e.data.target).outerHeight(),
width: $(e.data.target).outerWidth(),
height: $(e.data.target).outerHeight(),
deltaWidth: $(e.data.target).outerWidth() - $(e.data.target).width(),
deltaHeight: $(e.data.target).outerHeight() - $(e.data.target).height()
};
$(document)._bind('mousedown.resizable', data, doDown);
$(document)._bind('mousemove.resizable', data, doMove);
$(document)._bind('mouseup.resizable', data, doUp);
$('body').css('cursor', dir+'-resize');
});
});
};
$.fn.resizable.methods = {
options: function(jq){
return $.data(jq[0], 'resizable').options;
},
enable: function(jq){
return jq.each(function(){
$(this).resizable({disabled:false});
});
},
disable: function(jq){
return jq.each(function(){
$(this).resizable({disabled:true});
});
}
};
$.fn.resizable.parseOptions = function(target){
var t = $(target);
return $.extend({},
$.parser.parseOptions(target, [
'handles',{minWidth:'number',minHeight:'number',maxWidth:'number',maxHeight:'number',edge:'number'}
]), {
disabled: (t.attr('disabled') ? true : undefined)
})
};
$.fn.resizable.defaults = {
disabled:false,
handles:'n, e, s, w, ne, se, sw, nw, all',
minWidth: 10,
minHeight: 10,
maxWidth: 10000,//$(document).width(),
maxHeight: 10000,//$(document).height(),
edge:5,
onStartResize: function(e){},
onResize: function(e){},
onStopResize: function(e){}
};
$.fn.resizable.isResizing = false;
})(jQuery);

View File

@@ -0,0 +1,455 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* slider - EasyUI for jQuery
*
* Dependencies:
* draggable
*
*/
(function($){
function init(target){
var slider = $('<div class="slider">' +
'<div class="slider-inner">' +
'<a href="javascript:;" class="slider-handle"></a>' +
'<span class="slider-tip"></span>' +
'</div>' +
'<div class="slider-rule"></div>' +
'<div class="slider-rulelabel"></div>' +
'<div style="clear:both"></div>' +
'<input type="hidden" class="slider-value">' +
'</div>').insertAfter(target);
var t = $(target);
t.addClass('slider-f').hide();
var name = t.attr('name');
if (name){
slider.find('input.slider-value').attr('name', name);
t.removeAttr('name').attr('sliderName', name);
}
slider._bind('_resize', function(e,force){
if ($(this).hasClass('easyui-fluid') || force){
setSize(target);
}
return false;
});
return slider;
}
/**
* set the slider size, for vertical slider, the height property is required
*/
function setSize(target, param){
var state = $.data(target, 'slider');
var opts = state.options;
var slider = state.slider;
if (param){
if (param.width) opts.width = param.width;
if (param.height) opts.height = param.height;
}
slider._size(opts);
if (opts.mode == 'h'){
slider.css('height', '');
slider.children('div').css('height', '');
} else {
slider.css('width', '');
slider.children('div').css('width', '');
slider.children('div.slider-rule,div.slider-rulelabel,div.slider-inner')._outerHeight(slider._outerHeight());
}
initValue(target);
}
/**
* show slider rule if needed
*/
function showRule(target){
var state = $.data(target, 'slider');
var opts = state.options;
var slider = state.slider;
var aa = opts.mode == 'h' ? opts.rule : opts.rule.slice(0).reverse();
if (opts.reversed){
aa = aa.slice(0).reverse();
}
_build(aa);
function _build(aa){
var rule = slider.find('div.slider-rule');
var label = slider.find('div.slider-rulelabel');
rule.empty();
label.empty();
for(var i=0; i<aa.length; i++){
var distance = i*100/(aa.length-1)+'%';
var span = $('<span></span>').appendTo(rule);
span.css((opts.mode=='h'?'left':'top'), distance);
// show the labels
if (aa[i] != '|'){
span = $('<span></span>').appendTo(label);
span.html(aa[i]);
if (opts.mode == 'h'){
span.css({
left: distance,
marginLeft: -Math.round(span.outerWidth()/2)
});
} else {
span.css({
top: distance,
marginTop: -Math.round(span.outerHeight()/2)
});
}
}
}
}
}
/**
* build the slider and set some properties
*/
function buildSlider(target){
var state = $.data(target, 'slider');
var opts = state.options;
var slider = state.slider;
slider.removeClass('slider-h slider-v slider-disabled');
slider.addClass(opts.mode == 'h' ? 'slider-h' : 'slider-v');
slider.addClass(opts.disabled ? 'slider-disabled' : '');
var inner = slider.find('.slider-inner');
inner.html(
'<a href="javascript:;" class="slider-handle"></a>' +
'<span class="slider-tip"></span>'
);
if (opts.range){
inner.append(
'<a href="javascript:;" class="slider-handle"></a>' +
'<span class="slider-tip"></span>'
);
}
slider.find('a.slider-handle').draggable({
axis:opts.mode,
cursor:'pointer',
disabled: opts.disabled,
onDrag:function(e){
var left = e.data.left;
var width = slider.width();
if (opts.mode!='h'){
left = e.data.top;
width = slider.height();
}
if (left < 0 || left > width) {
return false;
} else {
setPos(left, this);
return false;
}
},
onStartDrag:function(){
state.isDragging = true;
opts.onSlideStart.call(target, opts.value);
},
onStopDrag:function(e){
setPos(opts.mode=='h'?e.data.left:e.data.top, this);
opts.onSlideEnd.call(target, opts.value);
opts.onComplete.call(target, opts.value);
state.isDragging = false;
}
});
slider.find('div.slider-inner')._unbind('.slider')._bind('mousedown.slider', function(e){
if (state.isDragging || opts.disabled){return}
var pos = $(this).offset();
setPos(opts.mode=='h'?(e.pageX-pos.left):(e.pageY-pos.top));
opts.onComplete.call(target, opts.value);
});
function fixVal(value){
var dd = String(opts.step).split('.');
var dlen = dd.length>1 ? dd[1].length : 0;
return parseFloat(value.toFixed(dlen));
}
function setPos(pos, handle){
var value = pos2value(target, pos);
var s = Math.abs(value % opts.step);
if (s < opts.step/2){
value -= s;
} else {
value = value - s + opts.step;
}
value = fixVal(value);
if (opts.range){
var v1 = opts.value[0];
var v2 = opts.value[1];
var m = parseFloat((v1+v2)/2);
if (handle){
var isLeft = $(handle).nextAll('.slider-handle').length > 0;
if (value <= v2 && isLeft){
v1 = value;
} else if (value >= v1 && (!isLeft)){
v2 = value;
}
} else {
if (value < v1){
v1 = value;
} else if (value > v2){
v2 = value;
} else {
value < m ? v1 = value : v2 = value;
}
}
$(target).slider('setValues', [v1,v2]);
} else {
$(target).slider('setValue', value);
}
}
}
/**
* set a specified value to slider
*/
function setValues(target, values){
var state = $.data(target, 'slider');
var opts = state.options;
var slider = state.slider;
var oldValues = $.isArray(opts.value) ? opts.value : [opts.value];
var newValues = [];
if (!$.isArray(values)){
values = $.map(String(values).split(opts.separator), function(v){
return parseFloat(v);
});
}
slider.find('.slider-value').remove();
var name = $(target).attr('sliderName') || '';
for(var i=0; i<values.length; i++){
var value = values[i];
if (value < opts.min) value = opts.min;
if (value > opts.max) value = opts.max;
var input = $('<input type="hidden" class="slider-value">').appendTo(slider);
input.attr('name', name);
input.val(value);
newValues.push(value);
var handle = slider.find('.slider-handle:eq('+i+')');
var tip = handle.next();
var pos = value2pos(target, value);
if (opts.showTip){
tip.show();
tip.html(opts.tipFormatter.call(target, value));
} else {
tip.hide();
}
if (opts.mode == 'h'){
var style = 'left:'+pos+'px;';
handle.attr('style', style);
tip.attr('style', style + 'margin-left:' + (-Math.round(tip.outerWidth()/2)) + 'px');
} else {
var style = 'top:' + pos + 'px;';
handle.attr('style', style);
tip.attr('style', style + 'margin-left:' + (-Math.round(tip.outerWidth())) + 'px');
}
}
opts.value = opts.range ? newValues : newValues[0];
$(target).val(opts.range ? newValues.join(opts.separator) : newValues[0]);
if (oldValues.join(',') != newValues.join(',')){
opts.onChange.call(target, opts.value, (opts.range?oldValues:oldValues[0]));
}
}
function initValue(target){
var opts = $.data(target, 'slider').options;
var fn = opts.onChange;
opts.onChange = function(){};
setValues(target, opts.value);
opts.onChange = fn;
}
/**
* translate value to slider position
*/
function value2pos(target, value){
var state = $.data(target, 'slider');
var opts = state.options;
var slider = state.slider;
var size = opts.mode == 'h' ? slider.width() : slider.height();
var pos = opts.converter.toPosition.call(target, value, size);
if (opts.mode == 'v'){
pos = slider.height() - pos;
}
if (opts.reversed){
pos = size - pos;
}
return pos;
// return pos.toFixed(0);
}
/**
* translate slider position to value
*/
function pos2value(target, pos){
var state = $.data(target, 'slider');
var opts = state.options;
var slider = state.slider;
var size = opts.mode == 'h' ? slider.width() : slider.height();
var pos = opts.mode=='h' ? (opts.reversed?(size-pos):pos) : (opts.reversed?pos:(size-pos));
var value = opts.converter.toValue.call(target, pos, size);
return value;
// return value.toFixed(0);
}
$.fn.slider = function(options, param){
if (typeof options == 'string'){
return $.fn.slider.methods[options](this, param);
}
options = options || {};
return this.each(function(){
var state = $.data(this, 'slider');
if (state){
$.extend(state.options, options);
} else {
state = $.data(this, 'slider', {
options: $.extend({}, $.fn.slider.defaults, $.fn.slider.parseOptions(this), options),
slider: init(this)
});
// $(this).removeAttr('disabled');
$(this)._propAttr('disabled', false);
}
var opts = state.options;
opts.min = parseFloat(opts.min);
opts.max = parseFloat(opts.max);
if (opts.range){
if (!$.isArray(opts.value)){
opts.value = $.map(String(opts.value).split(opts.separator), function(v){
return parseFloat(v);
});
}
if (opts.value.length < 2){
opts.value.push(opts.max);
}
} else {
opts.value = parseFloat(opts.value);
}
opts.step = parseFloat(opts.step);
opts.originalValue = opts.value;
buildSlider(this);
showRule(this);
setSize(this);
});
};
$.fn.slider.methods = {
options: function(jq){
return $.data(jq[0], 'slider').options;
},
destroy: function(jq){
return jq.each(function(){
$.data(this, 'slider').slider.remove();
$(this).remove();
});
},
resize: function(jq, param){
return jq.each(function(){
setSize(this, param);
});
},
getValue: function(jq){
return jq.slider('options').value;
},
getValues: function(jq){
return jq.slider('options').value;
},
setValue: function(jq, value){
return jq.each(function(){
setValues(this, [value]);
});
},
setValues: function(jq, values){
return jq.each(function(){
setValues(this, values);
});
},
clear: function(jq){
return jq.each(function(){
var opts = $(this).slider('options');
setValues(this, opts.range?[opts.min,opts.max]:[opts.min]);
});
},
reset: function(jq){
return jq.each(function(){
var opts = $(this).slider('options');
$(this).slider(opts.range?'setValues':'setValue', opts.originalValue);
});
},
enable: function(jq){
return jq.each(function(){
$.data(this, 'slider').options.disabled = false;
buildSlider(this);
});
},
disable: function(jq){
return jq.each(function(){
$.data(this, 'slider').options.disabled = true;
buildSlider(this);
});
}
};
$.fn.slider.parseOptions = function(target){
var t = $(target);
return $.extend({}, $.parser.parseOptions(target, [
'width','height','mode',{reversed:'boolean',showTip:'boolean',range:'boolean',min:'number',max:'number',step:'number'}
]), {
value: (t.val() || undefined),
disabled: (t.attr('disabled') ? true : undefined),
rule: (t.attr('rule') ? eval(t.attr('rule')) : undefined)
});
};
$.fn.slider.defaults = {
width: 'auto',
height: 'auto',
mode: 'h', // 'h'(horizontal) or 'v'(vertical)
reversed: false,
showTip: false,
disabled: false,
range: false,
value: 0,
separator: ',',
min: 0,
max: 100,
step: 1,
rule: [], // [0,'|',100]
tipFormatter: function(value){return value},
converter:{
toPosition:function(value, size){
var opts = $(this).slider('options');
var p = (value-opts.min)/(opts.max-opts.min)*size;
return p;
},
toValue:function(pos, size){
var opts = $(this).slider('options');
var v = opts.min + (opts.max-opts.min)*(pos/size);
return v;
}
},
onChange: function(value, oldValue){},
onSlideStart: function(value){},
onSlideEnd: function(value){},
onComplete: function(value){}
};
})(jQuery);

View File

@@ -0,0 +1,932 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* tabs - EasyUI for jQuery
*
* Dependencies:
* panel
* linkbutton
*
*/
(function($){
function getContentWidth(c){
var w = 0;
$(c).children().each(function(){
w += $(this).outerWidth(true);
});
return w;
}
/**
* set the tabs scrollers to show or not,
* dependent on the tabs count and width
*/
function setScrollers(container) {
var opts = $.data(container, 'tabs').options;
if (!opts.showHeader){return}
var header = $(container).children('div.tabs-header');
var tool = header.children('div.tabs-tool:not(.tabs-tool-hidden)');
var sLeft = header.children('div.tabs-scroller-left');
var sRight = header.children('div.tabs-scroller-right');
var wrap = header.children('div.tabs-wrap');
if (opts.tabPosition == 'left' || opts.tabPosition == 'right'){
if (!tool.length){return}
tool._outerWidth(header.width());
var toolCss = {
left: opts.tabPosition == 'left' ? 'auto':0,
right: opts.tabPosition == 'left' ? 0 : 'auto',
top: opts.toolPosition == 'top' ? 0 : 'auto',
bottom: opts.toolPosition == 'top' ? 'auto' : 0
};
var wrapCss = {
marginTop: opts.toolPosition == 'top' ? tool.outerHeight() : 0
};
tool.css(toolCss);
wrap.css(wrapCss);
return;
}
// set the tool height
var tHeight = header.outerHeight();
if (opts.plain){
tHeight -= tHeight - header.height();
}
tool._outerHeight(tHeight);
var tabsWidth = getContentWidth(header.find('ul.tabs'));
var cWidth = header.width() - tool._outerWidth();
if (tabsWidth > cWidth) {
sLeft.add(sRight).show()._outerHeight(tHeight);
if (opts.toolPosition == 'left'){
tool.css({
left: sLeft.outerWidth(),
right: ''
});
wrap.css({
marginLeft: sLeft.outerWidth() + tool._outerWidth(),
marginRight: sRight._outerWidth(),
width: cWidth - sLeft.outerWidth() - sRight.outerWidth()
});
} else {
tool.css({
left: '',
right: sRight.outerWidth()
});
wrap.css({
marginLeft: sLeft.outerWidth(),
marginRight: sRight.outerWidth() + tool._outerWidth(),
width: cWidth - sLeft.outerWidth() - sRight.outerWidth()
});
}
} else {
sLeft.add(sRight).hide();
if (opts.toolPosition == 'left'){
tool.css({
left: 0,
right: ''
});
wrap.css({
marginLeft: tool._outerWidth(),
marginRight: 0,
width: cWidth
});
} else {
tool.css({
left: '',
right: 0
});
wrap.css({
marginLeft: 0,
marginRight: tool._outerWidth(),
width: cWidth
});
}
}
}
function addTools(container){
var opts = $.data(container, 'tabs').options;
var header = $(container).children('div.tabs-header');
if (opts.tools) {
if (typeof opts.tools == 'string'){
$(opts.tools).addClass('tabs-tool').appendTo(header);
$(opts.tools).show();
} else {
header.children('div.tabs-tool').remove();
var tools = $('<div class="tabs-tool"><table cellspacing="0" cellpadding="0" style="height:100%"><tr></tr></table></div>').appendTo(header);
var tr = tools.find('tr');
for(var i=0; i<opts.tools.length; i++){
var td = $('<td></td>').appendTo(tr);
var tool = $('<a href="javascript:;"></a>').appendTo(td);
tool[0].onclick = eval(opts.tools[i].handler || function(){});
tool.linkbutton($.extend({}, opts.tools[i], {
plain: true
}));
}
}
} else {
header.children('div.tabs-tool').remove();
}
}
function setSize(container, param) {
var state = $.data(container, 'tabs');
var opts = state.options;
var cc = $(container);
if (!opts.doSize){return}
if (param){
$.extend(opts, {
width: param.width,
height: param.height
});
}
cc._size(opts);
var header = cc.children('div.tabs-header');
var panels = cc.children('div.tabs-panels');
var wrap = header.find('div.tabs-wrap');
var ul = wrap.find('.tabs');
ul.children('li').removeClass('tabs-first tabs-last');
ul.children('li:first').addClass('tabs-first');
ul.children('li:last').addClass('tabs-last');
if (opts.tabPosition == 'left' || opts.tabPosition == 'right'){
header._outerWidth(opts.showHeader ? opts.headerWidth : 0);
panels._outerWidth(cc.width() - header.outerWidth());
header.add(panels)._size('height', isNaN(parseInt(opts.height)) ? '' : cc.height());
wrap._outerWidth(header.width());
ul._outerWidth(wrap.width()).css('height','');
} else {
header.children('div.tabs-scroller-left,div.tabs-scroller-right,div.tabs-tool:not(.tabs-tool-hidden)').css('display', opts.showHeader?'block':'none');
header._outerWidth(cc.width()).css('height','');
if (opts.showHeader){
header.css('background-color','');
wrap.css('height','');
} else {
header.css('background-color','transparent');
header._outerHeight(0);
wrap._outerHeight(0);
}
ul._outerHeight(opts.tabHeight).css('width','');
ul._outerHeight(ul.outerHeight()-ul.height()-1+opts.tabHeight).css('width','');
panels._size('height', isNaN(parseInt(opts.height)) ? '' : (cc.height()-header.outerHeight()));
panels._size('width', cc.width());
}
if (state.tabs.length){
var d1 = ul.outerWidth(true) - ul.width();
var li = ul.children('li:first');
var d2 = li.outerWidth(true) - li.width();
var hwidth = header.width() - header.children('.tabs-tool:not(.tabs-tool-hidden)')._outerWidth();
var justifiedWidth = Math.floor((hwidth-d1-d2*state.tabs.length)/state.tabs.length);
$.map(state.tabs, function(p){
setTabSize(p, (opts.justified && $.inArray(opts.tabPosition,['top','bottom'])>=0) ? justifiedWidth : undefined);
});
if (opts.justified && $.inArray(opts.tabPosition,['top','bottom'])>=0){
var deltaWidth = hwidth - d1 - getContentWidth(ul);
setTabSize(state.tabs[state.tabs.length-1], justifiedWidth+deltaWidth);
}
}
setScrollers(container);
function setTabSize(p, width){
var p_opts = p.panel('options');
var p_t = p_opts.tab.find('a.tabs-inner');
var width = width ? width : (parseInt(p_opts.tabWidth||opts.tabWidth||undefined));
if (width){
p_t._outerWidth(width);
} else {
p_t.css('width', '');
}
p_t._outerHeight(opts.tabHeight);
p_t.css('lineHeight', p_t.height()+'px');
p_t.find('.easyui-fluid:visible').triggerHandler('_resize');
}
}
/**
* set selected tab panel size
*/
function setSelectedSize(container){
var opts = $.data(container, 'tabs').options;
var tab = getSelectedTab(container);
if (tab){
var panels = $(container).children('div.tabs-panels');
var width = opts.width=='auto' ? 'auto' : panels.width();
var height = opts.height=='auto' ? 'auto' : panels.height();
tab.panel('resize', {
width: width,
height: height
});
}
}
/**
* wrap the tabs header and body
*/
function wrapTabs(container) {
var tabs = $.data(container, 'tabs').tabs;
var cc = $(container).addClass('tabs-container');
var panels = $('<div class="tabs-panels"></div>').insertBefore(cc);
cc.children('div').each(function(){
panels[0].appendChild(this);
});
cc[0].appendChild(panels[0]);
$('<div class="tabs-header">'
+ '<div class="tabs-scroller-left"></div>'
+ '<div class="tabs-scroller-right"></div>'
+ '<div class="tabs-wrap">'
+ '<ul class="tabs"></ul>'
+ '</div>'
+ '</div>').prependTo(container);
cc.children('div.tabs-panels').children('div').each(function(i){
var opts = $.extend({}, $.parser.parseOptions(this), {
disabled: ($(this).attr('disabled') ? true : undefined),
selected: ($(this).attr('selected') ? true : undefined)
});
createTab(container, opts, $(this));
});
// cc.children('div.tabs-header').find('.tabs-scroller-left, .tabs-scroller-right').hover(
// function(){$(this).addClass('tabs-scroller-over');},
// function(){$(this).removeClass('tabs-scroller-over');}
// );
cc.children('div.tabs-header').find('.tabs-scroller-left, .tabs-scroller-right')._bind('mouseenter', function(){
$(this).addClass('tabs-scroller-over');
})._bind('mouseleave', function(){
$(this).removeClass('tabs-scroller-over');
});
cc._bind('_resize', function(e,force){
if ($(this).hasClass('easyui-fluid') || force){
setSize(container);
setSelectedSize(container);
}
return false;
});
}
function bindEvents(container){
var state = $.data(container, 'tabs')
var opts = state.options;
$(container).children('div.tabs-header')._unbind()._bind('click', function(e){
if ($(e.target).hasClass('tabs-scroller-left')){
$(container).tabs('scrollBy', -opts.scrollIncrement);
} else if ($(e.target).hasClass('tabs-scroller-right')){
$(container).tabs('scrollBy', opts.scrollIncrement);
} else {
var li = $(e.target).closest('li');
if (li.hasClass('tabs-disabled')){return false;}
var a = $(e.target).closest('a.tabs-close');
if (a.length){
closeTab(container, getLiIndex(li));
} else if (li.length){
// selectTab(container, getLiIndex(li));
var index = getLiIndex(li);
var popts = state.tabs[index].panel('options');
if (popts.collapsible){
popts.closed ? selectTab(container, index) : unselectTab(container, index);
} else {
selectTab(container, index);
}
}
return false;
}
})._bind('contextmenu', function(e){
var li = $(e.target).closest('li');
if (li.hasClass('tabs-disabled')){return;}
if (li.length){
opts.onContextMenu.call(container, e, li.find('span.tabs-title').html(), getLiIndex(li));
}
});
function getLiIndex(li){
var index = 0;
li.parent().children('li').each(function(i){
if (li[0] == this){
index = i;
return false;
}
});
return index;
}
}
function setProperties(container){
var opts = $.data(container, 'tabs').options;
var header = $(container).children('div.tabs-header');
var panels = $(container).children('div.tabs-panels');
header.removeClass('tabs-header-top tabs-header-bottom tabs-header-left tabs-header-right');
panels.removeClass('tabs-panels-top tabs-panels-bottom tabs-panels-left tabs-panels-right');
if (opts.tabPosition == 'top'){
header.insertBefore(panels);
} else if (opts.tabPosition == 'bottom'){
header.insertAfter(panels);
header.addClass('tabs-header-bottom');
panels.addClass('tabs-panels-top');
} else if (opts.tabPosition == 'left'){
header.addClass('tabs-header-left');
panels.addClass('tabs-panels-right');
} else if (opts.tabPosition == 'right'){
header.addClass('tabs-header-right');
panels.addClass('tabs-panels-left');
}
if (opts.plain == true) {
header.addClass('tabs-header-plain');
} else {
header.removeClass('tabs-header-plain');
}
header.removeClass('tabs-header-narrow').addClass(opts.narrow?'tabs-header-narrow':'');
var tabs = header.find('.tabs');
tabs.removeClass('tabs-pill').addClass(opts.pill?'tabs-pill':'');
tabs.removeClass('tabs-narrow').addClass(opts.narrow?'tabs-narrow':'');
tabs.removeClass('tabs-justified').addClass(opts.justified?'tabs-justified':'');
if (opts.border == true){
header.removeClass('tabs-header-noborder');
panels.removeClass('tabs-panels-noborder');
} else {
header.addClass('tabs-header-noborder');
panels.addClass('tabs-panels-noborder');
}
opts.doSize = true;
}
function createTab(container, options, pp) {
options = options || {};
var state = $.data(container, 'tabs');
var tabs = state.tabs;
if (options.index == undefined || options.index > tabs.length){options.index = tabs.length}
if (options.index < 0){options.index = 0}
var ul = $(container).children('div.tabs-header').find('ul.tabs');
var panels = $(container).children('div.tabs-panels');
var tab = $(
'<li>' +
'<a href="javascript:;" class="tabs-inner">' +
'<span class="tabs-title"></span>' +
'<span class="tabs-icon"></span>' +
'</a>' +
'</li>');
if (!pp){pp = $('<div></div>');}
if (options.index >= tabs.length){
tab.appendTo(ul);
pp.appendTo(panels);
tabs.push(pp);
} else {
tab.insertBefore(ul.children('li:eq('+options.index+')'));
pp.insertBefore(panels.children('div.panel:eq('+options.index+')'));
tabs.splice(options.index, 0, pp);
}
// create panel
pp.panel($.extend({}, options, {
tab: tab,
border: false,
noheader: true,
closed: true,
doSize: false,
iconCls: (options.icon ? options.icon : undefined),
onLoad: function(){
if (options.onLoad){
options.onLoad.apply(this, arguments);
}
state.options.onLoad.call(container, $(this));
},
onBeforeOpen: function(){
if (options.onBeforeOpen){
if (options.onBeforeOpen.call(this) == false){return false;}
}
var p = $(container).tabs('getSelected');
if (p){
if (p[0] != this){
$(container).tabs('unselect', getTabIndex(container, p));
p = $(container).tabs('getSelected');
if (p){
return false;
}
} else {
setSelectedSize(container);
return false;
}
}
var popts = $(this).panel('options');
popts.tab.addClass('tabs-selected');
// scroll the tab to center position if required.
var wrap = $(container).find('>div.tabs-header>div.tabs-wrap');
var left = popts.tab.position().left;
var right = left + popts.tab.outerWidth();
if (left < 0 || right > wrap.width()){
var deltaX = left - (wrap.width()-popts.tab.width()) / 2;
$(container).tabs('scrollBy', deltaX);
} else {
$(container).tabs('scrollBy', 0);
}
var panel = $(this).panel('panel');
panel.css('display','block');
setSelectedSize(container);
panel.css('display','none');
},
onOpen: function(){
if (options.onOpen){
options.onOpen.call(this);
}
var popts = $(this).panel('options');
var index = getTabIndex(container, this);
// state.selectHis.push(popts.title);
state.selectHis.push(index);
state.options.onSelect.call(container, popts.title, index);
},
onBeforeClose: function(){
if (options.onBeforeClose){
if (options.onBeforeClose.call(this) == false){return false;}
}
$(this).panel('options').tab.removeClass('tabs-selected');
},
onClose: function(){
if (options.onClose){
options.onClose.call(this);
}
var popts = $(this).panel('options');
state.options.onUnselect.call(container, popts.title, getTabIndex(container, this));
}
}));
// only update the tab header
$(container).tabs('update', {
tab: pp,
options: pp.panel('options'),
type: 'header'
});
}
function addTab(container, options) {
var state = $.data(container, 'tabs');
var opts = state.options;
if (options.selected == undefined) options.selected = true;
createTab(container, options);
opts.onAdd.call(container, options.title, options.index);
if (options.selected){
selectTab(container, options.index); // select the added tab panel
}
}
/**
* update tab panel, param has following properties:
* tab: the tab panel to be updated
* options: the tab panel options
* type: the update type, possible values are: 'header','body','all'
*/
function updateTab(container, param){
param.type = param.type || 'all';
var selectHis = $.data(container, 'tabs').selectHis;
var pp = param.tab; // the tab panel
var opts = pp.panel('options'); // get the tab panel options
var oldTitle = opts.title;
$.extend(opts, param.options, {
iconCls: (param.options.icon ? param.options.icon : undefined)
});
if (param.type == 'all' || param.type == 'body'){
pp.panel();
}
if (param.type == 'all' || param.type == 'header'){
var tab = opts.tab;
if (opts.header){
tab.find('.tabs-inner').html($(opts.header));
} else {
var s_title = tab.find('span.tabs-title');
var s_icon = tab.find('span.tabs-icon');
s_title.html(opts.title);
s_icon.attr('class', 'tabs-icon');
tab.find('a.tabs-close').remove();
if (opts.closable){
s_title.addClass('tabs-closable');
$('<a href="javascript:;" class="tabs-close"></a>').appendTo(tab);
} else{
s_title.removeClass('tabs-closable');
}
if (opts.iconCls){
s_title.addClass('tabs-with-icon');
s_icon.addClass(opts.iconCls);
} else {
s_title.removeClass('tabs-with-icon');
}
if (opts.tools){
var p_tool = tab.find('span.tabs-p-tool');
if (!p_tool.length){
var p_tool = $('<span class="tabs-p-tool"></span>').insertAfter(tab.find('a.tabs-inner'));
}
if ($.isArray(opts.tools)){
p_tool.empty();
for(var i=0; i<opts.tools.length; i++){
var t = $('<a href="javascript:;"></a>').appendTo(p_tool);
t.addClass(opts.tools[i].iconCls);
if (opts.tools[i].handler){
t._bind('click', {handler:opts.tools[i].handler}, function(e){
if ($(this).parents('li').hasClass('tabs-disabled')){return;}
e.data.handler.call(this);
});
}
}
} else {
$(opts.tools).children().appendTo(p_tool);
}
var pr = p_tool.children().length * 12;
if (opts.closable) {
pr += 8;
p_tool.css('right', '');
} else {
pr -= 3;
p_tool.css('right','5px');
}
s_title.css('padding-right', pr+'px');
} else {
tab.find('span.tabs-p-tool').remove();
s_title.css('padding-right', '');
}
}
// if (oldTitle != opts.title){
// for(var i=0; i<selectHis.length; i++){
// if (selectHis[i] == oldTitle){
// selectHis[i] = opts.title;
// }
// }
// }
}
if (opts.disabled){
opts.tab.addClass('tabs-disabled');
} else {
opts.tab.removeClass('tabs-disabled');
}
setSize(container);
$.data(container, 'tabs').options.onUpdate.call(container, opts.title, getTabIndex(container, pp));
}
/**
* close a tab with specified index or title
*/
function closeTab(container, which) {
var state = $.data(container, 'tabs');
var opts = state.options;
var tabs = state.tabs;
var selectHis = state.selectHis;
if (!exists(container, which)) return;
var tab = getTab(container, which);
var title = tab.panel('options').title;
var index = getTabIndex(container, tab);
if (opts.onBeforeClose.call(container, title, index) == false) return;
var tab = getTab(container, which, true);
tab.panel('options').tab.remove();
tab.panel('destroy');
opts.onClose.call(container, title, index);
// setScrollers(container);
setSize(container);
// remove the select history item
var his = [];
for(var i=0; i<selectHis.length; i++){
var tindex = selectHis[i];
if (tindex != index){
his.push(tindex > index ? tindex-1 : tindex);
}
}
state.selectHis = his;
var selected = $(container).tabs('getSelected');
if (!selected && his.length){
index = state.selectHis.pop();
$(container).tabs('select', index);
}
// for(var i=0; i<selectHis.length; i++){
// if (selectHis[i] == title){
// selectHis.splice(i, 1);
// i --;
// }
// }
// // select the nearest tab panel
// var hisTitle = selectHis.pop();
// if (hisTitle){
// selectTab(container, hisTitle);
// } else if (tabs.length){
// selectTab(container, 0);
// }
}
/**
* get the specified tab panel
*/
function getTab(container, which, removeit){
var tabs = $.data(container, 'tabs').tabs;
var tab = null;
if (typeof which == 'number'){
if (which >=0 && which < tabs.length){
tab = tabs[which];
if (removeit){
tabs.splice(which, 1);
}
}
} else {
var tmp = $('<span></span>');
for(var i=0; i<tabs.length; i++){
var p = tabs[i];
tmp.html(p.panel('options').title);
var title = tmp.text();
tmp.html(which);
which = tmp.text();
if (title == which){
tab = p;
if (removeit){
tabs.splice(i, 1);
}
break;
}
}
tmp.remove();
}
return tab;
}
function getTabIndex(container, tab){
var tabs = $.data(container, 'tabs').tabs;
for(var i=0; i<tabs.length; i++){
if (tabs[i][0] == $(tab)[0]){
return i;
}
}
return -1;
}
function getSelectedTab(container){
var tabs = $.data(container, 'tabs').tabs;
for(var i=0; i<tabs.length; i++){
var tab = tabs[i];
if (tab.panel('options').tab.hasClass('tabs-selected')){
return tab;
}
}
return null;
}
/**
* do first select action, if no tab is setted the first tab will be selected.
*/
function doFirstSelect(container){
var state = $.data(container, 'tabs')
var tabs = state.tabs;
for(var i=0; i<tabs.length; i++){
var opts = tabs[i].panel('options');
if (opts.selected && !opts.disabled){
selectTab(container, i);
return;
}
}
selectTab(container, state.options.selected);
}
function selectTab(container, which){
var p = getTab(container, which);
if (p && !p.is(':visible')){
stopAnimate(container);
if (!p.panel('options').disabled){
p.panel('open');
}
}
}
function unselectTab(container, which){
var p = getTab(container, which);
if (p && p.is(':visible')){
stopAnimate(container);
p.panel('close');
}
}
function stopAnimate(container){
$(container).children('div.tabs-panels').each(function(){
$(this).stop(true, true);
});
}
function exists(container, which){
return getTab(container, which) != null;
}
function showHeader(container, visible){
var opts = $.data(container, 'tabs').options;
opts.showHeader = visible;
$(container).tabs('resize');
}
function showTool(container, visible){
var tool = $(container).find('>.tabs-header>.tabs-tool');
if (visible){
tool.removeClass('tabs-tool-hidden').show();
} else {
tool.addClass('tabs-tool-hidden').hide();
}
$(container).tabs('resize').tabs('scrollBy', 0);
}
$.fn.tabs = function(options, param){
if (typeof options == 'string') {
return $.fn.tabs.methods[options](this, param);
}
options = options || {};
return this.each(function(){
var state = $.data(this, 'tabs');
if (state) {
$.extend(state.options, options);
} else {
$.data(this, 'tabs', {
options: $.extend({},$.fn.tabs.defaults, $.fn.tabs.parseOptions(this), options),
tabs: [],
selectHis: []
});
wrapTabs(this);
}
addTools(this);
setProperties(this);
setSize(this);
bindEvents(this);
doFirstSelect(this);
});
};
$.fn.tabs.methods = {
options: function(jq){
var cc = jq[0];
var opts = $.data(cc, 'tabs').options;
var s = getSelectedTab(cc);
opts.selected = s ? getTabIndex(cc, s) : -1;
return opts;
},
tabs: function(jq){
return $.data(jq[0], 'tabs').tabs;
},
resize: function(jq, param){
return jq.each(function(){
setSize(this, param);
setSelectedSize(this);
});
},
add: function(jq, options){
return jq.each(function(){
addTab(this, options);
});
},
close: function(jq, which){
return jq.each(function(){
closeTab(this, which);
});
},
getTab: function(jq, which){
return getTab(jq[0], which);
},
getTabIndex: function(jq, tab){
return getTabIndex(jq[0], tab);
},
getSelected: function(jq){
return getSelectedTab(jq[0]);
},
select: function(jq, which){
return jq.each(function(){
selectTab(this, which);
});
},
unselect: function(jq, which){
return jq.each(function(){
unselectTab(this, which);
});
},
exists: function(jq, which){
return exists(jq[0], which);
},
update: function(jq, options){
return jq.each(function(){
updateTab(this, options);
});
},
enableTab: function(jq, which){
return jq.each(function(){
var opts = $(this).tabs('getTab', which).panel('options');
opts.tab.removeClass('tabs-disabled');
opts.disabled = false;
});
},
disableTab: function(jq, which){
return jq.each(function(){
var opts = $(this).tabs('getTab', which).panel('options');
opts.tab.addClass('tabs-disabled');
opts.disabled = true;
});
},
showHeader: function(jq){
return jq.each(function(){
showHeader(this, true);
});
},
hideHeader: function(jq){
return jq.each(function(){
showHeader(this, false);
});
},
showTool: function(jq){
return jq.each(function(){
showTool(this, true);
});
},
hideTool: function(jq){
return jq.each(function(){
showTool(this, false);
});
},
scrollBy: function(jq, deltaX){ // scroll the tab header by the specified amount of pixels
return jq.each(function(){
var opts = $(this).tabs('options');
var wrap = $(this).find('>div.tabs-header>div.tabs-wrap');
var pos = Math.min(wrap._scrollLeft() + deltaX, getMaxScrollWidth());
wrap.animate({scrollLeft: pos}, opts.scrollDuration);
function getMaxScrollWidth(){
var w = 0;
var ul = wrap.children('ul');
ul.children('li').each(function(){
w += $(this).outerWidth(true);
});
return w - wrap.width() + (ul.outerWidth() - ul.width());
}
});
}
};
$.fn.tabs.parseOptions = function(target){
return $.extend({}, $.parser.parseOptions(target, [
'tools','toolPosition','tabPosition',
{fit:'boolean',border:'boolean',plain:'boolean'},
{headerWidth:'number',tabWidth:'number',tabHeight:'number',selected:'number'},
{showHeader:'boolean',justified:'boolean',narrow:'boolean',pill:'boolean'}
]));
};
$.fn.tabs.defaults = {
width: 'auto',
height: 'auto',
headerWidth: 150, // the tab header width, it is valid only when tabPosition set to 'left' or 'right'
tabWidth: 'auto', // the tab width
// tabHeight: 27, // the tab height
tabHeight: 32, // the tab height
selected: 0, // the initialized selected tab index
showHeader: true,
plain: false,
fit: false,
border: true,
justified: false,
narrow: false,
pill: false,
tools: null,
toolPosition: 'right', // left,right,top,bottom
tabPosition: 'top', // possible values: top,bottom
scrollIncrement: 100,
scrollDuration: 400,
onLoad: function(panel){},
onSelect: function(title, index){},
onUnselect: function(title, index){},
onBeforeClose: function(title, index){},
onClose: function(title, index){},
onAdd: function(title, index){},
onUpdate: function(title, index){},
onContextMenu: function(e, title, index){}
};
})(jQuery);

View File

@@ -0,0 +1,417 @@
/**
* EasyUI for jQuery 1.9.4
*
* Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
*
* Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
* To use it on other terms please contact us: info@jeasyui.com
*
*/
/**
* window - EasyUI for jQuery
*
* Dependencies:
* panel
* draggable
* resizable
*
*/
(function($){
function moveWindow(target, param){
var state = $.data(target, 'window');
if (param){
if (param.left != null) state.options.left = param.left;
if (param.top != null) state.options.top = param.top;
}
$(target).panel('move', state.options);
if (state.shadow){
state.shadow.css({
left: state.options.left,
top: state.options.top
});
}
}
/**
* center the window only horizontally
*/
function hcenter(target, tomove){
var opts = $.data(target, 'window').options;
var pp = $(target).window('panel');
var width = pp._outerWidth();
if (opts.inline){
var parent = pp.parent();
opts.left = Math.ceil((parent.width() - width) / 2 + parent.scrollLeft());
} else {
opts.left = Math.ceil(($(window)._outerWidth() - width) / 2 + $(document).scrollLeft());
}
if (tomove){moveWindow(target);}
}
/**
* center the window only vertically
*/
function vcenter(target, tomove){
var opts = $.data(target, 'window').options;
var pp = $(target).window('panel');
var height = pp._outerHeight();
if (opts.inline){
var parent = pp.parent();
opts.top = Math.ceil((parent.height() - height) / 2 + parent.scrollTop());
} else {
opts.top = Math.ceil(($(window)._outerHeight() - height) / 2 + $(document).scrollTop());
}
if (tomove){moveWindow(target);}
}
function create(target){
var state = $.data(target, 'window');
var opts = state.options;
var win = $(target).panel($.extend({}, state.options, {
border: false,
doSize: true, // size the panel, the property undefined in window component
closed: true, // close the panel
cls: 'window ' + (!opts.border?'window-thinborder window-noborder ':(opts.border=='thin'?'window-thinborder ':'')) + (opts.cls || ''),
headerCls: 'window-header ' + (opts.headerCls || ''),
bodyCls: 'window-body ' + (opts.noheader ? 'window-body-noheader ' : ' ') + (opts.bodyCls||''),
onBeforeDestroy: function(){
if (opts.onBeforeDestroy.call(target) == false){return false;}
if (state.shadow){state.shadow.remove();}
if (state.mask){state.mask.remove();}
},
onClose: function(){
if (state.shadow){state.shadow.hide();}
if (state.mask){state.mask.hide();}
opts.onClose.call(target);
},
onOpen: function(){
if (state.mask){
state.mask.css($.extend({
display:'block',
zIndex: $.fn.window.defaults.zIndex++
}, $.fn.window.getMaskSize(target)));
}
if (state.shadow){
state.shadow.css({
display:'block',
zIndex: $.fn.window.defaults.zIndex++,
left: opts.left,
top: opts.top,
width: state.window._outerWidth(),
height: state.window._outerHeight()
});
}
state.window.css('z-index', $.fn.window.defaults.zIndex++);
opts.onOpen.call(target);
},
onResize: function(width, height){
var popts = $(this).panel('options');
$.extend(opts, {
width: popts.width,
height: popts.height,
left: popts.left,
top: popts.top
});
if (state.shadow){
state.shadow.css({
left: opts.left,
top: opts.top,
width: state.window._outerWidth(),
height: state.window._outerHeight()
});
}
opts.onResize.call(target, width, height);
},
onMinimize: function(){
if (state.shadow){state.shadow.hide();}
if (state.mask){state.mask.hide();}
state.options.onMinimize.call(target);
},
onBeforeCollapse: function(){
if (opts.onBeforeCollapse.call(target) == false){return false;}
if (state.shadow){state.shadow.hide();}
},
onExpand: function(){
if (state.shadow){state.shadow.show();}
opts.onExpand.call(target);
}
}));
state.window = win.panel('panel');
// create mask
if (state.mask){state.mask.remove();}
if (opts.modal){
state.mask = $('<div class="window-mask" style="display:none"></div>').insertAfter(state.window);
}
// create shadow
if (state.shadow){state.shadow.remove();}
if (opts.shadow){
state.shadow = $('<div class="window-shadow" style="display:none"></div>').insertAfter(state.window);
}
// center and open the window
var closed = opts.closed;
if (opts.left == null){hcenter(target);}
if (opts.top == null){vcenter(target);}
moveWindow(target);
if (!closed){win.window('open');}
}
function constrain(left, top, width, height){
var target = this;
var state = $.data(target, 'window');
var opts = state.options;
if (!opts.constrain){return {};}
if ($.isFunction(opts.constrain)){
return opts.constrain.call(target, left, top, width, height);
}
var win = $(target).window('window');
var parent = opts.inline ? win.parent() : $(window);
if (left < 0){left = 0;}
if (top < parent.scrollTop()){top = parent.scrollTop();}
if (left + width > parent.width()){
if (width == win.outerWidth()){ // moving
left = parent.width() - width;
} else { // resizing
width = parent.width() - left;
}
}
if (top - parent.scrollTop() + height > parent.height()){
if (height == win.outerHeight()){ // moving
top = parent.height() - height + parent.scrollTop();
} else { // resizing
height = parent.height() - top + parent.scrollTop();
}
}
return {
left:left,
top:top,
width:width,
height:height
};
}
/**
* set window drag and resize property
*/
function setProperties(target){
var state = $.data(target, 'window');
state.window.draggable({
handle: '>div.panel-header>div.panel-title',
disabled: state.options.draggable == false,
onBeforeDrag: function(e){
if (state.mask) state.mask.css('z-index', $.fn.window.defaults.zIndex++);
if (state.shadow) state.shadow.css('z-index', $.fn.window.defaults.zIndex++);
state.window.css('z-index', $.fn.window.defaults.zIndex++);
},
onStartDrag: function(e){
start1(e);
},
onDrag: function(e){
proc1(e);
return false;
},
onStopDrag: function(e){
stop1(e, 'move');
}
});
state.window.resizable({
disabled: state.options.resizable == false,
onStartResize:function(e){
start1(e);
},
onResize: function(e){
proc1(e);
return false;
},
onStopResize: function(e){
stop1(e, 'resize');
}
});
function start1(e){
if (state.pmask){state.pmask.remove();}
state.pmask = $('<div class="window-proxy-mask"></div>').insertAfter(state.window);
state.pmask.css({
display: 'none',
zIndex: $.fn.window.defaults.zIndex++,
left: e.data.left,
top: e.data.top,
width: state.window._outerWidth(),
height: state.window._outerHeight()
});
if (state.proxy){state.proxy.remove();}
state.proxy = $('<div class="window-proxy"></div>').insertAfter(state.window);
state.proxy.css({
display: 'none',
zIndex: $.fn.window.defaults.zIndex++,
left: e.data.left,
top: e.data.top
});
state.proxy._outerWidth(e.data.width)._outerHeight(e.data.height);
state.proxy.hide();
setTimeout(function(){
if (state.pmask){state.pmask.show();}
if (state.proxy){state.proxy.show();}
}, 500);
}
function proc1(e){
$.extend(e.data, constrain.call(target, e.data.left, e.data.top, e.data.width, e.data.height));
state.pmask.show();
state.proxy.css({
display: 'block',
left: e.data.left,
top: e.data.top
});
state.proxy._outerWidth(e.data.width);
state.proxy._outerHeight(e.data.height);
}
function stop1(e, method){
$.extend(e.data, constrain.call(target, e.data.left, e.data.top, e.data.width+0.1, e.data.height+0.1));
$(target).window(method, e.data);
state.pmask.remove();
state.pmask = null;
state.proxy.remove();
state.proxy = null;
}
}
// when window resize, reset the width and height of the window's mask
$(function(){
if (!$._positionFixed){
$(window).resize(function(){
$('body>div.window-mask:visible').css({
width: '',
height: ''
});
setTimeout(function(){
$('body>div.window-mask:visible').css($.fn.window.getMaskSize());
}, 50);
});
}
});
$.fn.window = function(options, param){
if (typeof options == 'string'){
var method = $.fn.window.methods[options];
if (method){
return method(this, param);
} else {
return this.panel(options, param);
}
}
options = options || {};
return this.each(function(){
var state = $.data(this, 'window');
if (state){
$.extend(state.options, options);
} else {
state = $.data(this, 'window', {
options: $.extend({}, $.fn.window.defaults, $.fn.window.parseOptions(this), options)
});
if (!state.options.inline){
document.body.appendChild(this);
}
}
create(this);
setProperties(this);
});
};
$.fn.window.methods = {
options: function(jq){
var popts = jq.panel('options');
var wopts = $.data(jq[0], 'window').options;
return $.extend(wopts, {
closed: popts.closed,
collapsed: popts.collapsed,
minimized: popts.minimized,
maximized: popts.maximized
});
},
window: function(jq){
return $.data(jq[0], 'window').window;
},
move: function(jq, param){
return jq.each(function(){
moveWindow(this, param);
});
},
hcenter: function(jq){
return jq.each(function(){
hcenter(this, true);
});
},
vcenter: function(jq){
return jq.each(function(){
vcenter(this, true);
});
},
center: function(jq){
return jq.each(function(){
hcenter(this);
vcenter(this);
moveWindow(this);
});
}
};
$.fn.window.getMaskSize = function(target){
var state = $(target).data('window');
if (state && state.options.inline){
return {};
} else if ($._positionFixed){
return {position: 'fixed'};
} else {
return {
width: $(document).width(),
height: $(document).height()
};
}
};
$.fn.window.parseOptions = function(target){
return $.extend({}, $.fn.panel.parseOptions(target), $.parser.parseOptions(target, [
{draggable:'boolean',resizable:'boolean',shadow:'boolean',modal:'boolean',inline:'boolean'}
]));
};
// Inherited from $.fn.panel.defaults
$.fn.window.defaults = $.extend({}, $.fn.panel.defaults, {
zIndex: 9000,
draggable: true,
resizable: true,
shadow: true,
modal: false,
border: true, // possible values are: true,false,'thin','thick'
inline: false, // true to stay inside its parent, false to go on top of all elements
// window's property which difference from panel
title: 'New Window',
collapsible: true,
minimizable: true,
maximizable: true,
closable: true,
closed: false,
constrain: false
/*
constrain: function(left,top,width,height){
return {
left:left,
top:top,
width:width,
height:height
};
}
*/
});
})(jQuery);