@ -0,0 +1,4 @@ |
|||
SUU MIS |
|||
SBT : ver ${spring-boot.version} |
|||
MIS : ver 2.01 |
|||
*************************************** |
|||
@ -0,0 +1,198 @@ |
|||
{ |
|||
"evy": "application/envoy", |
|||
"fif": "application/fractals", |
|||
"spl": "application/futuresplash", |
|||
"hta": "application/hta", |
|||
"acx": "application/internet-property-stream", |
|||
"hqx": "application/mac-binhex40", |
|||
"doc": "application/msword", |
|||
"dot": "application/msword", |
|||
"*": "application/octet-stream", |
|||
"bin": "application/octet-stream", |
|||
"class": "application/octet-stream", |
|||
"dms": "application/octet-stream", |
|||
"exe": "application/octet-stream", |
|||
"lha": "application/octet-stream", |
|||
"lzh": "application/octet-stream", |
|||
"oda": "application/oda", |
|||
"axs": "application/olescript", |
|||
"pdf": "application/pdf", |
|||
"prf": "application/pics-rules", |
|||
"p10": "application/pkcs10", |
|||
"crl": "application/pkix-crl", |
|||
"ai": "application/postscript", |
|||
"eps": "application/postscript", |
|||
"ps": "application/postscript", |
|||
"rtf": "application/rtf", |
|||
"setpay": "application/set-payment-initiation", |
|||
"setreg": "application/set-registration-initiation", |
|||
"xla": "application/vnd.ms-excel", |
|||
"xlc": "application/vnd.ms-excel", |
|||
"xlm": "application/vnd.ms-excel", |
|||
"xls": "application/vnd.ms-excel", |
|||
"xlt": "application/vnd.ms-excel", |
|||
"xlw": "application/vnd.ms-excel", |
|||
"msg": "application/vnd.ms-outlook", |
|||
"sst": "application/vnd.ms-pkicertstore", |
|||
"cat": "application/vnd.ms-pkiseccat", |
|||
"stl": "application/vnd.ms-pkistl", |
|||
"pot": "application/vnd.ms-powerpoint", |
|||
"pps": "application/vnd.ms-powerpoint", |
|||
"ppt": "application/vnd.ms-powerpoint", |
|||
"mpp": "application/vnd.ms-project", |
|||
"wcm": "application/vnd.ms-works", |
|||
"wdb": "application/vnd.ms-works", |
|||
"wks": "application/vnd.ms-works", |
|||
"wps": "application/vnd.ms-works", |
|||
"hlp": "application/winhlp", |
|||
"bcpio": "application/x-bcpio", |
|||
"cdf": "application/x-netcdf", |
|||
"z": "application/x-compress", |
|||
"tgz": "application/x-compressed", |
|||
"cpio": "application/x-cpio", |
|||
"csh": "application/x-csh", |
|||
"dcr": "application/x-director", |
|||
"dir": "application/x-director", |
|||
"dxr": "application/x-director", |
|||
"dvi": "application/x-dvi", |
|||
"gtar": "application/x-gtar", |
|||
"gz": "application/x-gzip", |
|||
"hdf": "application/x-hdf", |
|||
"ins": "application/x-internet-signup", |
|||
"isp": "application/x-internet-signup", |
|||
"iii": "application/x-iphone", |
|||
"js": "application/x-javascript", |
|||
"latex": "application/x-latex", |
|||
"mdb": "application/x-msaccess", |
|||
"crd": "application/x-mscardfile", |
|||
"clp": "application/x-msclip", |
|||
"dll": "application/x-msdownload", |
|||
"m13": "application/x-msmediaview", |
|||
"m14": "application/x-msmediaview", |
|||
"mvb": "application/x-msmediaview", |
|||
"wmf": "application/x-msmetafile", |
|||
"mny": "application/x-msmoney", |
|||
"pub": "application/x-mspublisher", |
|||
"scd": "application/x-msschedule", |
|||
"trm": "application/x-msterminal", |
|||
"wri": "application/x-mswrite", |
|||
"nc": "application/x-netcdf", |
|||
"pma": "application/x-perfmon", |
|||
"pmc": "application/x-perfmon", |
|||
"pml": "application/x-perfmon", |
|||
"pmr": "application/x-perfmon", |
|||
"pmw": "application/x-perfmon", |
|||
"p12": "application/x-pkcs12", |
|||
"pfx": "application/x-pkcs12", |
|||
"p7b": "application/x-pkcs7-certificates", |
|||
"spc": "application/x-pkcs7-certificates", |
|||
"p7r": "application/x-pkcs7-certreqresp", |
|||
"p7c": "application/x-pkcs7-mime", |
|||
"p7m": "application/x-pkcs7-mime", |
|||
"p7s": "application/x-pkcs7-signature", |
|||
"sh": "application/x-sh", |
|||
"shar": "application/x-shar", |
|||
"swf": "application/x-shockwave-flash", |
|||
"sit": "application/x-stuffit", |
|||
"sv4cpio": "application/x-sv4cpio", |
|||
"sv4crc": "application/x-sv4crc", |
|||
"tar": "application/x-tar", |
|||
"tcl": "application/x-tcl", |
|||
"tex": "application/x-tex", |
|||
"texi": "application/x-texinfo", |
|||
"texinfo": "application/x-texinfo", |
|||
"roff": "application/x-troff", |
|||
"t": "application/x-troff", |
|||
"tr": "application/x-troff", |
|||
"man": "application/x-troff-man", |
|||
"me": "application/x-troff-me", |
|||
"ms": "application/x-troff-ms", |
|||
"ustar": "application/x-ustar", |
|||
"src": "application/x-wais-source", |
|||
"cer": "application/x-x509-ca-cert", |
|||
"crt": "application/x-x509-ca-cert", |
|||
"der": "application/x-x509-ca-cert", |
|||
"pko": "application/ynd.ms-pkipko", |
|||
"zip": "application/zip", |
|||
"au": "audio/basic", |
|||
"snd": "audio/basic", |
|||
"mid": "audio/mid", |
|||
"rmi": "audio/mid", |
|||
"mp3": "audio/mpeg", |
|||
"aif": "audio/x-aiff", |
|||
"aifc": "audio/x-aiff", |
|||
"aiff": "audio/x-aiff", |
|||
"m3u": "audio/x-mpegurl", |
|||
"ra": "audio/x-pn-realaudio", |
|||
"ram": "audio/x-pn-realaudio", |
|||
"wav": "audio/x-wav", |
|||
"bmp": "image/bmp", |
|||
"cod": "image/cis-cod", |
|||
"gif": "image/gif", |
|||
"ief": "image/ief", |
|||
"png": "image/png", |
|||
"jpeg": "image/jpeg", |
|||
"jpg": "image/jpeg", |
|||
"jfif": "image/pipeg", |
|||
"svg": "image/svg+xml", |
|||
"tif": "image/tiff", |
|||
"tiff": "image/tiff", |
|||
"ras": "image/x-cmu-raster", |
|||
"cmx": "image/x-cmx", |
|||
"ico": "image/x-icon", |
|||
"pnm": "image/x-portable-anymap", |
|||
"pbm": "image/x-portable-bitmap", |
|||
"pgm": "image/x-portable-graymap", |
|||
"ppm": "image/x-portable-pixmap", |
|||
"rgb": "image/x-rgb", |
|||
"xbm": "image/x-xbitmap", |
|||
"xpm": "image/x-xpixmap", |
|||
"xwd": "image/x-xwindowdump", |
|||
"mht": "message/rfc822", |
|||
"mhtml": "message/rfc822", |
|||
"nws": "message/rfc822", |
|||
"css": "text/css", |
|||
"323": "text/h323", |
|||
"htm": "text/html", |
|||
"html": "text/html", |
|||
"stm": "text/html", |
|||
"uls": "text/iuls", |
|||
"bas": "text/plain", |
|||
"c": "text/plain", |
|||
"h": "text/plain", |
|||
"txt": "text/plain", |
|||
"rtx": "text/richtext", |
|||
"sct": "text/scriptlet", |
|||
"tsv": "text/tab-separated-values", |
|||
"htt": "text/webviewhtml", |
|||
"htc": "text/x-component", |
|||
"etx": "text/x-setext", |
|||
"vcf": "text/x-vcard", |
|||
"mp2": "video/mpeg", |
|||
"mpa": "video/mpeg", |
|||
"mpe": "video/mpeg", |
|||
"mpeg": "video/mpeg", |
|||
"mpg": "video/mpeg", |
|||
"mpv2": "video/mpeg", |
|||
"mp4": "video/mp4", |
|||
"mov": "video/quicktime", |
|||
"qt": "video/quicktime", |
|||
"lsf": "video/x-la-asf", |
|||
"lsx": "video/x-la-asf", |
|||
"asf": "video/x-ms-asf", |
|||
"asr": "video/x-ms-asf", |
|||
"asx": "video/x-ms-asf", |
|||
"avi": "video/x-msvideo", |
|||
"movie": "video/x-sgi-movie", |
|||
"flr": "x-world/x-vrml", |
|||
"vrml": "x-world/x-vrml", |
|||
"wrl": "x-world/x-vrml", |
|||
"wrz": "x-world/x-vrml", |
|||
"xaf": "x-world/x-vrml", |
|||
"xof": "x-world/x-vrml", |
|||
"mp4a": "audio/mp4", |
|||
"wma": "audio/x-ms-wma", |
|||
"psd": "image/vnd.adobe.photoshop", |
|||
"php": "text/x-php", |
|||
"ogg": "audio/ogg" |
|||
} |
|||
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 912 B |
@ -0,0 +1,690 @@ |
|||
define('form', ['jquery','layer','validator','validatorLang'], function ($, undefined) { |
|||
var Form = { |
|||
config: { |
|||
frmOperate: '.frm-operate', // 表单标签class
|
|||
btnSubmit: '.btn-submit', // 表单提交按钮class
|
|||
isValidate: true, // 是否开启验证
|
|||
}, |
|||
api: { |
|||
init: function (config) { |
|||
config = config ? config : {}; |
|||
config = $.extend(Form.config, config); |
|||
var form = typeof config.frmOperate == 'object' ? config.frmOperate : $(config.frmOperate); |
|||
|
|||
if (config.isValidate) { |
|||
Form.event.validator(form, config.validator, config.before, config.success, config.error); |
|||
} else { |
|||
form.submit(function (e) { |
|||
e.preventDefault(); |
|||
Form.api.submit(form, config.before, config.success, config.error); |
|||
}); |
|||
} |
|||
Form.event.selectpage(form); |
|||
Form.event.laydate(form); |
|||
Form.event.fileSelect(form); |
|||
Form.event.fileUpload(form); |
|||
Form.event.filePreview(form); |
|||
Form.event.tips(form); |
|||
Form.event.keyvalue(form); |
|||
Form.event.selectpicker(form); |
|||
Form.event.more(form); |
|||
}, |
|||
submit: function(form, before, success, error) { |
|||
var btnSumit = $('[type=submit]', form); |
|||
if (btnSumit.hasClass('disabled')) { |
|||
return false; |
|||
} |
|||
btnSumit.addClass('disabled'); |
|||
|
|||
// 数据提交
|
|||
var url = form.attr('action'); |
|||
url = url ? url : location.href; |
|||
var method = form.attr('method'); |
|||
method = method ? method : 'post'; |
|||
|
|||
var obj = hkcms.api.ajax({ |
|||
url: url, |
|||
type: method, |
|||
data: form.serializeArray(), |
|||
enableToken: true |
|||
}, before,function (data,response) { |
|||
btnSumit.removeClass('disabled'); |
|||
|
|||
// 是否有设置响应成功后的回调
|
|||
if (typeof success === "function") { |
|||
if (false===success(data,response)) { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
if (self != top) { // iframe
|
|||
if ($('.operatePage').length) { |
|||
layer.msg(response.msg, {time:2000, icon:1}, function () { |
|||
var index = parent.layer.getFrameIndex(window.name); |
|||
|
|||
// 获取页面关闭后的处理
|
|||
var page_callback = parent.$("#layui-layer" + index).data("page"); |
|||
parent.layer.close(index); |
|||
if (page_callback) { |
|||
page_callback(); |
|||
} |
|||
}); |
|||
} else { |
|||
// 返回上一页
|
|||
layer.msg(response.msg, {time:2000, icon:1}, function () { |
|||
self.location = document.referrer; |
|||
}); |
|||
} |
|||
} else { |
|||
// 刷新当前页
|
|||
layer.msg(response.msg, {time:2000, icon:1}, function () { |
|||
window.location.reload(); |
|||
}); |
|||
} |
|||
}, function (data) { |
|||
// 错误回调
|
|||
btnSumit.removeClass('disabled'); |
|||
|
|||
// 是否有设置回调
|
|||
if (typeof error === "function") { |
|||
if (false===error(data)) { |
|||
return false; |
|||
} |
|||
} |
|||
layer.msg(data.msg,{time:4000, icon:2}); |
|||
}, btnSumit); |
|||
}, |
|||
}, |
|||
event: { |
|||
validator: function (form, option, before, success, error) { |
|||
option = option || {}; |
|||
var options = { |
|||
formClass: "n-default n-bootstrap", |
|||
msgClass: "n-bottom", |
|||
theme: 'bootstrap', |
|||
invalidClass: 'is-invalid', |
|||
target: function(elem){ // 自定义消息位置
|
|||
var formitem = $(elem).closest('.form-group>div'), |
|||
msgbox = formitem.find('span.msg-box'); |
|||
if (!msgbox.length) { |
|||
msgbox = $('<span class="msg-box"></span>').appendTo(formitem); |
|||
} |
|||
return msgbox; |
|||
}, |
|||
valid: function(result) { |
|||
Form.api.submit(form, before, success, error); |
|||
}, |
|||
invalid: function (result) { |
|||
if ($(result).find('.card.card-tabs').length==1) { |
|||
// is-invalid
|
|||
var href = $('.nav-tabs').find('.nav-link.active').attr('href'); |
|||
if ($(href).find('.is-invalid').length<=0) { |
|||
$('.nav-tabs').find('.nav-link:not(.active)').each(function (e) { |
|||
href = $(this).attr('href'); |
|||
if ($(href).find('.is-invalid').length) { |
|||
$(this).trigger('click'); |
|||
return false; |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
}; |
|||
form.validator($.extend(options, option)); |
|||
}, |
|||
selectpage: function (form) { |
|||
if (form.find('.selectpage').length>0) { |
|||
// 加载selectpage插件
|
|||
require(['selectpage'], function (undefined) { |
|||
var option = { |
|||
showField: 'name', |
|||
keyField: 'id', |
|||
// searchField: 'name', // ajax查询时,需要提交的查询字段,多个英文逗号分隔(废弃默认,默认与showField一致,可外面指定)
|
|||
data: [], // 格式:[{id:1,name:'张三',sex:'男'},{id:2,name:'李四',sex:'男'}]
|
|||
selectOnly: false, |
|||
pagination: true, |
|||
listSize: 10, // 列表显示的项目个数,其它的项目以滚动条滚动方式展现
|
|||
multiple: false, |
|||
lang: 'cn', |
|||
maxSelectLimit: 10, |
|||
eAjaxSuccess: function (data) { |
|||
if (data.code && data.code!=200) { |
|||
layer.alert(data.msg); |
|||
return {list:[],totalRow:[]}; |
|||
} |
|||
// 动态下拉返回值的格式化
|
|||
data.list = typeof data.rows !== 'undefined' ? data.rows : []; |
|||
data.totalRow = typeof data.total !== 'undefined' ? data.total : data.list.length; |
|||
return data; |
|||
} |
|||
}; |
|||
form.find('.selectpage').each(function (key,item) { |
|||
var id = $(this).attr('id'),data = $(this).data(); |
|||
data = $.extend(false, option, data); // 通过input data属性覆盖默认属性,更多属性查看文档
|
|||
|
|||
// 自动加上域名
|
|||
if (data.data.indexOf(Config.root_file)<0) { |
|||
data.data = Config.root_domain+(data.data.substr(0,1)=='/'?data.data:'/'+data.data); |
|||
} |
|||
|
|||
// 判断是否自定义条件json类型
|
|||
var jsonStr = data.params; |
|||
if (typeof jsonStr!=='function' && typeof jsonStr!=='undefined') { |
|||
data.params = function(){return jsonStr;} |
|||
} |
|||
$('#'+id).selectPage(data); |
|||
}) |
|||
}) |
|||
} |
|||
}, |
|||
selectpicker: function (form) { |
|||
if (form.find('.selectpicker').length>0) { |
|||
// 加载selectpicker下拉插件
|
|||
require(['selectpicker'], function (undefined) { |
|||
var option = { |
|||
style: "form-control", |
|||
noneSelectedText: lang('Please choose'), // 多重选择没有选定选项时显示的文本。
|
|||
} |
|||
|
|||
$.fn.selectpicker.defaults = { |
|||
noneSelectedText: '没有选中任何项', |
|||
noneResultsText: '没有找到匹配项', |
|||
countSelectedText: '选中{1}中的{0}项', |
|||
maxOptionsText: ['超出限制 (最多选择{n}项)', '组选择超出限制(最多选择{n}组)'], |
|||
multipleSeparator: ', ', |
|||
selectAllText: '全选', |
|||
deselectAllText: '取消全选' |
|||
}; |
|||
|
|||
form.find('.selectpicker').each(function (key,item) { |
|||
var id = $(this).attr('id'),data = $(this).data(); |
|||
data = $.extend(false, option, data); |
|||
|
|||
$('#'+id).selectpicker(data); |
|||
}) |
|||
}); |
|||
} |
|||
}, |
|||
laydate: function (form) { |
|||
if (form.find('.laydate').length>0) { |
|||
// 加载laydate插件
|
|||
require(['laydate'], function (Laydate) { |
|||
form.find('.laydate').each(function (idx,vo) { |
|||
var obj = { |
|||
elem: vo, |
|||
type: 'datetime', |
|||
trigger: 'click', |
|||
value: $(this).val() |
|||
}; |
|||
obj = $.extend(obj, $(this).data()); |
|||
Laydate.render(obj); |
|||
}); |
|||
}) |
|||
} |
|||
}, |
|||
fileSelect: function (form) { // 文件选择
|
|||
form.on('click', '.btn-imgSelect', function (e) { |
|||
var option = { |
|||
field: 'image', |
|||
mimetype: '', |
|||
multiple: false, |
|||
fileNum: 10 |
|||
}; |
|||
option = $.extend(option, $(this).data()); |
|||
option.mimetype = option.mimetype.replace("*", ""); |
|||
var url = hkcms.api.setUrlParams({url:Config.root_domain+'/routine.attachment/select', query:option}); |
|||
|
|||
var _this = this; |
|||
hkcms.api.open(url,lang('Select image'),{},function (arr) { |
|||
var field = $(_this).data('field'); |
|||
if (field) { |
|||
var multiple = $(_this).data('multiple'); |
|||
if (multiple == 'multiple' || multiple == 1) { |
|||
var oldfiles = $('#' + field).val(); |
|||
if ($('#' + field).parent().parent().hasClass('file-json')) { // json
|
|||
oldfiles = oldfiles.length == 0 ? [] : JSON.parse(oldfiles); |
|||
for (const idx in arr) { |
|||
oldfiles.push({file: arr[idx], info: ""}) |
|||
} |
|||
} else { // 逗号分隔模式
|
|||
oldfiles = oldfiles.length == 0 ? [] : oldfiles.split(','); |
|||
for (const idx in arr) { |
|||
oldfiles.push(arr[idx]) |
|||
} |
|||
} |
|||
// 判断是否超过最大可上传图片数
|
|||
if (oldfiles.length > option.fileNum) { |
|||
layer.msg(lang('Only %s file can be uploaded at a time!', [option.fileNum]), { |
|||
time: 4000, |
|||
icon: 2 |
|||
}) |
|||
return false; |
|||
} |
|||
$('#' + field).val($('#' + field).parent().parent().hasClass('file-json') ? JSON.stringify(oldfiles) : oldfiles.join(',')); |
|||
} else { |
|||
$('#' + field).val(arr.join(',')) |
|||
} |
|||
|
|||
// 触发change事件
|
|||
$('#' + field).trigger('change'); |
|||
} |
|||
}); |
|||
}) |
|||
}, |
|||
fileUpload: function (form) { // 文件上传插件
|
|||
if (form.find('.btn-imgUpload').length>0) { |
|||
require(['jquery-fileupload'], function (undefined) { // 加载文件上传插件
|
|||
form.find('.btn-imgUpload').each(function (index) { |
|||
if ($(this).parent().find('input[type=file]').length!=0) { |
|||
return true; |
|||
} |
|||
var option = { |
|||
url: Config.upload_url, |
|||
field: 'image', |
|||
mimetype: '*', |
|||
multiple: false |
|||
}; |
|||
option = $.extend(option, $(this).data()); |
|||
$(this).after('<input type="file" class="input-file'+index+'" style="display: none" name="files[]" '+(option.multiple==true?'multiple':'')+' accept="'+option.mimetype+'">'); |
|||
$(this).bind('click', {}, function (e) { |
|||
if (!$(this).is('.disabled')) { |
|||
$(this).next().click(); |
|||
} |
|||
}); |
|||
|
|||
var chunkSize = 0; // 每次上次的分块字节
|
|||
var error = 0; // 1-错误,0-继续上传分块
|
|||
var count = 1; |
|||
option = { |
|||
url: Config.upload_url, |
|||
type: 'POST', |
|||
dataType: 'json', // 服务器返回的数据类型
|
|||
autoUpload: true, // 选择文件后自动上传
|
|||
mimetype: '*', // 文件类型
|
|||
size: Config.file_size || (2*1024*1024), |
|||
singleFileUploads: false, |
|||
fileNum: 10, |
|||
filesguid: Util.guid(), |
|||
maxChunkSize: Config && Config.chunk && Config.chunk==1 ? Config.chunk_size:0, // 2MB
|
|||
formData: function (form) { // 额外表单
|
|||
var allow = []; |
|||
if (option && option.fields) { |
|||
var arr = option.fields.split(','); |
|||
if (arr.length>0) { |
|||
$.each(form.serializeArray(), function (idx, item) { |
|||
if ($.inArray(item.name,arr)!=-1) { |
|||
allow.push(item); |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
return allow; |
|||
}, |
|||
add: function (e, data) { // 文件添加验证
|
|||
var arr = option.mimetype.split(','); |
|||
if (data.originalFiles.length > option.fileNum) { |
|||
layer.msg(lang('Only %s file can be uploaded at a time!',[option.fileNum]),{time: 4000,icon:2}); |
|||
return false; |
|||
} |
|||
for (var idx in data.originalFiles) { |
|||
// 文件格式限制
|
|||
if (option.mimetype.indexOf("/")===-1) { // .jpg,.png格式
|
|||
var index1 = data.originalFiles[idx]['name'].lastIndexOf("."); |
|||
var index2 = data.originalFiles[idx]['name'].length; |
|||
var ext = data.originalFiles[idx]['name'].substring(index1,index2); |
|||
if (option.mimetype!='*' && 0>$.inArray(ext, arr)) { |
|||
layer.msg(lang('Unsupported file suffix'), {time: 4000,icon:2}); |
|||
return false; |
|||
} |
|||
} else { |
|||
// image/png 格式判断
|
|||
var type = data.originalFiles[idx]['type']; |
|||
if (option.mimetype.indexOf("/*") !== -1) { |
|||
type = type.split('/'); |
|||
type[1] = '*'; |
|||
type = type.join('/'); |
|||
} |
|||
|
|||
if (option.mimetype!='*' && 0>$.inArray(type, arr)) { |
|||
layer.msg(lang('Unsupported file suffix'), {time: 4000,icon:2}); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
//文件大小判断
|
|||
if(data.originalFiles[idx].size > option.size) { |
|||
layer.msg(lang('Please upload a leaflet that does not exceed %s',[(option.size/1024).toFixed(2)+'KB']),{time: 4000,icon:2}); |
|||
return false; |
|||
} |
|||
} |
|||
count = 1; |
|||
chunkSize = 0; |
|||
data.submit(); |
|||
}, |
|||
progressall: function (e, data) { // 进度
|
|||
var progress = parseInt(data.loaded / data.total * 100, 10); |
|||
var obj = $(e.target).parent().find('.btn-imgUpload'); |
|||
|
|||
obj.addClass('disabled'); |
|||
|
|||
var value = ''; |
|||
if (obj.is('input')) { |
|||
value = obj.val(); |
|||
obj.val(progress+'%'); |
|||
} else { |
|||
value = obj.html(); |
|||
obj.html(progress+'%'); |
|||
} |
|||
if (!obj.data('value')) { |
|||
obj.attr('data-value', value); |
|||
} |
|||
}, |
|||
done: function (e, data) { // 成功回调
|
|||
count = 1; |
|||
var obj = $(e.target).parent().find('.btn-imgUpload'); |
|||
|
|||
if (obj.is('input')) { |
|||
obj.val(obj.data('value')); |
|||
} else { |
|||
obj.html(obj.data('value')); |
|||
} |
|||
|
|||
obj.removeClass('disabled'); |
|||
if (data.result.code==200) { |
|||
if (!data.result.data || data.result.data.length==0) { |
|||
layer.msg(lang('Not uploaded successfully'),{time: 4000,icon:2}); |
|||
return false; |
|||
} |
|||
var paths = []; |
|||
$.each(data.result.data, function (idx, item) { |
|||
paths.push(item.path); |
|||
}) |
|||
var newfilesnum = paths.length; |
|||
|
|||
// 多文件模式
|
|||
var multiple = $(e.target).attr('multiple'); |
|||
if (multiple=='multiple' || multiple==1) { |
|||
|
|||
var oldfiles = $('#'+option.field).val(); |
|||
if ($('#'+option.field).parent().parent().hasClass('file-json')) { // json
|
|||
oldfiles = oldfiles.length == 0 ? [] : JSON.parse(oldfiles); |
|||
for (const idx in paths) { |
|||
oldfiles.push({file: paths[idx], info: ""}) |
|||
} |
|||
} else { // 逗号分隔模式
|
|||
oldfiles = oldfiles.length == 0 ? [] : oldfiles.split(','); |
|||
for (const idx in paths) { |
|||
oldfiles.push(paths[idx]) |
|||
} |
|||
} |
|||
// 判断是否超过最大可上传图片数
|
|||
if (oldfiles.length > option.fileNum) { |
|||
layer.msg(lang('Only %s file can be uploaded at a time!', [option.fileNum]), { |
|||
time: 4000, |
|||
icon: 2 |
|||
}) |
|||
return false; |
|||
} |
|||
$('#'+option.field).val($('#'+option.field).parent().parent().hasClass('file-json') ? JSON.stringify(oldfiles) : oldfiles.join(',')); |
|||
} else { |
|||
$('#'+option.field).val(paths.join(',')); |
|||
} |
|||
$('#'+option.field).trigger('change'); |
|||
} else { |
|||
layer.alert(data.result.msg); |
|||
} |
|||
}, |
|||
chunksend: function (e, data) { // 分块上传前的回调,返回false,结束上传
|
|||
if (error) { |
|||
return false; |
|||
} |
|||
data.data.append('chunksize', chunkSize += data.chunkSize); |
|||
data.data.append('filesize', data.files[0].size); |
|||
data.data.append('fileid', data.filesguid); |
|||
data.data.append('fileindex', count); |
|||
|
|||
count++; |
|||
}, |
|||
chunkdone: function (e, data) { // 每个分块上传完成的回调
|
|||
if (data.result.code!=200) { |
|||
layer.alert(data.result.msg); |
|||
error = 1; |
|||
return false; |
|||
} |
|||
}, |
|||
fail: function (e, data) { |
|||
if (data.maxChunkSize>0) { |
|||
// 切片上传处理
|
|||
var url = Util.setUrlParams({url:data.url, query:{action:'clear',fileid:data.filesguid}}) |
|||
$.get({url: url}); |
|||
} |
|||
count = 1; |
|||
|
|||
layer.alert(data._response.jqXHR.responseJSON.message); |
|||
} |
|||
}; |
|||
|
|||
option = $.extend(option, $(this).data()); |
|||
$('.input-file'+index).fileupload(option); |
|||
}) |
|||
}) |
|||
} |
|||
}, |
|||
filePreview: function (form) { // 文件input框更改事件,预览
|
|||
form.on('change','.txt-files', function (e) { |
|||
if (!$(this).parent().parent().find('.file-preview')) { |
|||
return false; |
|||
} |
|||
var imgStr = $(this).val(); |
|||
if (imgStr.length==0) { |
|||
return false; |
|||
} |
|||
|
|||
// 判断是否是:base图片
|
|||
var html = ''; |
|||
if (/^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i.test(imgStr)) { |
|||
html += '<div class="col-md-3">\n' + |
|||
'<a href="'+imgStr+'" target="_blank"><img src="'+imgStr+'" class="img-thumbnail"></a>\n' + |
|||
'<a href="#" class="btn btn-danger btn-xs preview-del mt-2" data-index="0"><i class="fas fa-trash-alt"></i></a>\n' + |
|||
'</div>'; |
|||
$(this).parent().parent().find('.file-preview').html(html); |
|||
return true; |
|||
} |
|||
|
|||
// json格式。多图、多文件组件
|
|||
if ($(this).parent().parent().hasClass('file-json')) { |
|||
var arr = JSON.parse(imgStr); |
|||
} else { |
|||
var arr = imgStr.split(','); |
|||
var jsonObj = [] |
|||
for (var idx in arr) { |
|||
jsonObj.push({ |
|||
file: arr[idx], |
|||
info: "" |
|||
}) |
|||
} |
|||
arr = jsonObj |
|||
} |
|||
|
|||
var reg = /^(http|https):\/\//; |
|||
var file = ''; |
|||
var ext = ''; |
|||
|
|||
for (var idx in arr) { |
|||
file = reg.test(arr[idx].file) ? arr[idx].file : Config.cdn_url+arr[idx].file; |
|||
if (file.length==0) { |
|||
continue; |
|||
} |
|||
file = file.split('?'); |
|||
file = file[0]; |
|||
ext = file.split('.').pop().toLowerCase(); |
|||
html += '<div class="col-md-3 file-item">\n'; |
|||
if (ext=='mp4') { |
|||
html += '<a href="'+arr[idx].file+'" target="_blank"><img src="'+Config.static_path+'/img/video.png" class="img-thumbnail"></a>\n'; |
|||
} else if ($.inArray(ext, ['png','jpg','jpeg','gif','bmp','ico','webp'])!=-1) { |
|||
html += '<a href="'+arr[idx].file+'" target="_blank"><img src="'+(file)+'" class="img-thumbnail"></a>\n'; |
|||
} else { |
|||
html +='<a href="'+arr[idx].file+'" target="_blank"><img src="'+Config.static_path+'/img/zip.png" class="img-thumbnail"></a>\n'; |
|||
} |
|||
html += '<a href="#" class="preview-del" data-index="'+idx+'"><i class="fas fa-times"></i></a>\n'; |
|||
// '<textarea cols="1" rows="5" data-path="'+arr[idx]+'" class="form-control form-control-sm edit-image-remark" style="height: 28px;" placeholder="'+lang('Remark')+'"></textarea>\n' +
|
|||
// 是否json对象
|
|||
if ($(this).parent().parent().hasClass('file-json')) { |
|||
html += '<textarea cols="1" rows="5" data-index="'+idx+'" class="form-control form-control-sm edit-image-remark" style="height: 28px;" placeholder="'+lang('Remark')+'">'+arr[idx].info+'</textarea>\n'; |
|||
} |
|||
// 是否开启移动排序
|
|||
if ($(this).parent().parent().hasClass('file-sortable')) { |
|||
html += '<a href="#" class="preview-arrows-alt" data-index="'+idx+'"><i class="fas fa-arrows-alt"></i></a>\n' |
|||
} |
|||
html += '</div>'; |
|||
} |
|||
$(this).parent().parent().find('.file-preview').html(html); |
|||
}); |
|||
|
|||
// 格式化多文件、多图片组件
|
|||
form.find('.file-json').each(function (idx, vo) { |
|||
var txtVal = $(this).find('.txt-files').val(); |
|||
if (txtVal.length==0) { |
|||
return false; |
|||
} |
|||
try { |
|||
JSON.parse(txtVal); |
|||
} catch (error) { |
|||
var arr = txtVal.split(','); |
|||
var jsonObj = [] |
|||
for (idx in arr) { |
|||
jsonObj.push({ |
|||
file: arr[idx], |
|||
info: "" |
|||
}) |
|||
} |
|||
$(this).find('.txt-files').val(JSON.stringify(jsonObj)) |
|||
} |
|||
}) |
|||
|
|||
form.find('.txt-files').trigger('change'); |
|||
// 删除事件
|
|||
form.on('click', '.preview-del', function (e) { |
|||
var obj = $(this).parents('.fileGroup').find('.txt-files'); |
|||
// json格式。多图、多文件组件
|
|||
var arr = obj.val(); |
|||
if ($(this).parents('.fileGroup').hasClass('file-json')) { |
|||
arr = JSON.parse(arr); |
|||
} else { |
|||
arr = arr.split(','); |
|||
} |
|||
var index = $(this).parents('.fileGroup').find('.preview-del').index(this) |
|||
arr.splice(index,1); |
|||
obj.val($(this).parents('.fileGroup').hasClass('file-json') ? (arr.length==0 ? "" : JSON.stringify(arr)) : arr.join(',')); |
|||
$(this).parent().remove(); |
|||
}); |
|||
// 开启拖动排序
|
|||
if (form.find('.file-sortable').length>0) { |
|||
require(['jquery-ui'], function (undefined) { |
|||
form.find('.file-sortable').each(function (idx, vo) { |
|||
$(this).sortable({cursor:"move",items:".file-item",opacity:0.6,stop:function (e, ui) { |
|||
var curVal = $(e.target).find('.txt-files').val(); |
|||
if ($(e.target).hasClass('file-json')) { |
|||
curVal = JSON.parse(curVal); |
|||
} else { |
|||
curVal = curVal.split(','); |
|||
} |
|||
var newVal = [] |
|||
$(e.target).find(".preview-del").each(function (idx, vo){ |
|||
newVal.push(curVal[$(this).data('index')]) |
|||
}) |
|||
$(e.target).find('.txt-files').val($(e.target).hasClass('file-json') ? JSON.stringify(newVal) : newVal.join(',')) |
|||
$(e.target).find('.txt-files').trigger('change'); |
|||
}}); |
|||
}) |
|||
}) |
|||
} |
|||
// 备注更新事件
|
|||
form.on('change', '.edit-image-remark', function (e) { |
|||
var obj = $(this).parent().parent().parent().find('.txt-files'); |
|||
var curVal = JSON.parse(obj.val()); |
|||
curVal[$(this).data('index')].info = $(this).val() |
|||
obj.val(JSON.stringify(curVal)) |
|||
}) |
|||
}, |
|||
tips: function (form) { |
|||
var tips_index = 0; |
|||
form.on('mouseover', '.form-tips span', function (e) { |
|||
if ($(this).data('tips')) { |
|||
tips_index = layer.tips($(this).data('tips'), this, { |
|||
tips: 2, |
|||
time: 0 |
|||
}); |
|||
} else if (typeof($(this).attr('title'))!= "undefined") { |
|||
tips_index = layer.tips($(this).attr('title'), this, { |
|||
tips: 2, |
|||
time: 0 |
|||
}); |
|||
} |
|||
}).on('mouseleave', '.form-tips span', function(){ |
|||
layer.close(tips_index); |
|||
}); |
|||
}, |
|||
keyvalue: function (form) { |
|||
if (form.find('.keyvalue').length>0) { |
|||
require(['jquery-ui'], function (undefined) { |
|||
// 更新
|
|||
var updateJson = function (e) { |
|||
var arr = {}; |
|||
e.children('.row').each(function (idx, item) { |
|||
var tmp = $(this).find('[data-name="keyvalue-key"]').val(); |
|||
if (tmp) { |
|||
arr[tmp] = $(this).find('[data-name="keyvalue-value"]').val(); |
|||
} |
|||
}) |
|||
e.parent().find('.key-value-textarea').val($.isEmptyObject(arr)?'':JSON.stringify(arr)); |
|||
}; |
|||
|
|||
form.find('.keyvalue').each(function (idx, item) { |
|||
updateJson($(this).find('.keyvalue-item')); |
|||
$(this).find('.keyvalue-item').sortable({update: function (e) { |
|||
updateJson($(this)); |
|||
}}); |
|||
}); |
|||
|
|||
// 删除行
|
|||
$(document).on('click', '.btn-keyvalue-row-del', function (e) { |
|||
var obj = $(this).closest('.keyvalue-item'); |
|||
$(this).parent().parent().remove(); |
|||
updateJson(obj); |
|||
e.preventDefault(); |
|||
}) |
|||
// 添加行
|
|||
$(document).on('click', '.btn-keyvalue-row-add', function (e) { |
|||
var obj = $(this).closest('.keyvalue'); |
|||
var html = obj.find('.keyvalue-template').html(); |
|||
obj.find('.keyvalue-item').append(html); |
|||
e.preventDefault(); |
|||
}) |
|||
|
|||
// 值更改
|
|||
$(document).on('change keyup', ".keyvalue .keyvalue-item input", function () { |
|||
updateJson($(this).closest('.keyvalue-item')) |
|||
}); |
|||
|
|||
// 参数配置
|
|||
$(document).on('click','.btn-key-config',function () { |
|||
var obj = $(this).closest('.keyvalue'); |
|||
var val = obj.find('.key-value-textarea').val(); |
|||
if (val) { |
|||
$.post($(this).data('url'),{val:val,field:obj.find('.key-value-textarea').data('field'),model_id:$('#model_id').val()},function (e) { |
|||
layer.msg(e.msg); |
|||
}); |
|||
} else { |
|||
layer.msg("请点追加按钮追加数据后再试~"); |
|||
} |
|||
}) |
|||
}); |
|||
} |
|||
}, |
|||
more: function (form) { |
|||
} |
|||
} |
|||
} |
|||
return Form; |
|||
}); |
|||
@ -0,0 +1,214 @@ |
|||
define('hkcms', ['jquery','bootstrap','layer'], function ($, undefined,Layer) { |
|||
var hkcms = { |
|||
init: function () { // 初始化
|
|||
// 增加弹出框
|
|||
$(document).on('click', '[data-toggle="open"]', function (e) { |
|||
e.preventDefault(); |
|||
e.stopPropagation(); |
|||
|
|||
var url = $(this).data('url'); |
|||
var title = $(this).data('title'); |
|||
title = title ? title : '信息'; |
|||
if (url) { |
|||
hkcms.api.open(url, title); |
|||
} |
|||
}); |
|||
}, |
|||
api: { |
|||
// JS内使用语言包,PHP需要提前将语言包赋值给JS Lang 变量
|
|||
lang: function (name, arr) { |
|||
var langKey = name.toLowerCase(); |
|||
name = Lang[langKey] ? Lang[langKey] : name; |
|||
if (arr) { |
|||
for(var key in arr) { |
|||
name = name.replace('%s', arr[key]); |
|||
} |
|||
} |
|||
return name; |
|||
}, |
|||
// 获取唯一值
|
|||
guid: function () { |
|||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { |
|||
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); |
|||
return v.toString(16); |
|||
}); |
|||
}, |
|||
// 通用ajax请求,options 选项,before 提交前的处理,success 状态码200的回调,error 状态码非200的回调,btnSumit 提交按钮jq对象用于实现提交中不可在点击
|
|||
ajax: function (options, before, success, error, btnSumit) { |
|||
options = typeof options === 'string' ? {url: options} : options; |
|||
if (options.type==='post') { |
|||
var token = $('meta[name="csrf-token"]').attr('content'); |
|||
if (token) { |
|||
if (Object.prototype.toString.call(options.data) === '[object Array]') { |
|||
options.data.push({name:'__token__',value:token}); |
|||
} else if(typeof options.data == "object") { |
|||
options.data['__token__'] = token; |
|||
} |
|||
} |
|||
} |
|||
|
|||
var index = 0; |
|||
var defaultConfig = { |
|||
type: 'get', |
|||
dataType:'json', |
|||
beforeSend:function(XMLHttpRequest,self) { |
|||
if (typeof before === "function") { |
|||
var data = before(options.data); |
|||
if (false===data) { |
|||
if (btnSumit){btnSumit.removeClass('disabled')} |
|||
return false; |
|||
} |
|||
self.data = $.param(data); |
|||
} |
|||
index = layer.load(1); |
|||
}, |
|||
cache: false, |
|||
complete: function (xhr) { |
|||
var token = xhr.getResponseHeader('__token__'); |
|||
if (token) { |
|||
$('meta[name="csrf-token"]').attr('content',token); |
|||
} |
|||
}, |
|||
success: function(response) { |
|||
layer.close(index); |
|||
|
|||
if (response.code === 200) { |
|||
if (typeof success === "function") { |
|||
if (false===success(response.data,response)) { |
|||
return false; |
|||
} |
|||
} |
|||
} else { |
|||
if (typeof error === "function") { |
|||
if (false===error(response)) { |
|||
return false; |
|||
} |
|||
} |
|||
layer.msg(response.msg, {time:4000,icon:2}); |
|||
} |
|||
}, |
|||
error: function(e) { |
|||
layer.close(index); |
|||
|
|||
if (btnSumit){ |
|||
btnSumit.removeClass('disabled') |
|||
} |
|||
|
|||
if (e.status>0) { |
|||
var txt = e.statusText; |
|||
if (e.responseJSON && e.responseJSON.message) { |
|||
txt = e.responseJSON.message; |
|||
} else if (e.responseJSON && e.responseJSON.msg) { |
|||
txt = e.responseJSON.msg; |
|||
} |
|||
layer.alert('['+e.status+'] '+txt); |
|||
} else { |
|||
layer.alert(lang('Request exception')); |
|||
} |
|||
} |
|||
}; |
|||
return $.ajax($.extend(defaultConfig,options)); |
|||
}, |
|||
// 获取地址栏参数
|
|||
getUrlParams: function (url) { |
|||
url = url || window.location.search; //获取url中"?"符后的字串
|
|||
var params = {}; |
|||
var urlidx = url.indexOf("?"); |
|||
if (urlidx != -1) { |
|||
var str = url.substr(urlidx+1); |
|||
str = str.split("&"); |
|||
for(var i = 0; i < str.length; i ++) { |
|||
params[str[i].split("=")[0]]=decodeURI(str[i].split("=")[1]); |
|||
} |
|||
} |
|||
return params; |
|||
}, |
|||
// 追加url参数,options object {url:'', query:[]}
|
|||
setUrlParams: function (options) { |
|||
var {url,query} = options; |
|||
if(query) { |
|||
var queryArr = []; |
|||
for (const key in query) { |
|||
if (query.hasOwnProperty(key)) { |
|||
queryArr.push(`${key}=${query[key]}`) |
|||
} |
|||
} |
|||
if(url.indexOf('?') !== -1) { |
|||
url =`${url}&${queryArr.join('&')}` |
|||
} else { |
|||
url = url ? `${url}?${queryArr.join('&')}` : queryArr.join('&'); |
|||
} |
|||
} |
|||
return url; |
|||
}, |
|||
open: function (url, title, options,callback) { |
|||
options = options ? options : {}; |
|||
// 弹出框统一增加popup参数
|
|||
var urlPar = hkcms.api.getUrlParams(url); |
|||
if (!(urlPar && urlPar.popup)) { |
|||
url = hkcms.api.setUrlParams({url:url,query:{popup:1}}); |
|||
} |
|||
|
|||
// 是否默认全屏,2=全屏
|
|||
var area = Tpl.popup==1 ? [$(top.window).width() > 800 ? '800px' : '90%', $(top.window).height() > 600 ? '600px' : '90%'] : ['100%', '100%']; |
|||
|
|||
var defaultOptions = { |
|||
type: 2, |
|||
title: title, |
|||
shadeClose: false, |
|||
shade: false, |
|||
area: area, |
|||
maxmin: true, |
|||
resize: true, |
|||
moveOut: true, |
|||
content: url, |
|||
zIndex: top.layer.zIndex, //重点1
|
|||
success: (layero) => { |
|||
top.layer.setTop(layero); |
|||
|
|||
// 解决全屏下无法正常缩小问题
|
|||
if (typeof options.area =="object" && options.area[0]=='100%' && options.area[1]=='100%') { |
|||
var width = $(top.window).width(); |
|||
var height = $(top.window).height(); |
|||
var area = [ |
|||
width > 800 ? 800 : width*0.9, |
|||
height > 600 ? 600 : height*0.9, |
|||
(height - (height > 600 ? 600 : height*0.9))/2, |
|||
(width - (width > 800 ? 800 : width*0.9))/2 |
|||
]; |
|||
layero.find('.layui-layer-max').addClass('layui-layer-maxmin'); |
|||
layero.attr({area: area}); |
|||
} |
|||
|
|||
// 页面关闭后的处理
|
|||
top.$(layero).data('page', function () { |
|||
if ($('button[name="refresh"]').length>0) { |
|||
$('button[name="refresh"]').trigger('click'); |
|||
} else if ($('.btn-refresh').length>0) { |
|||
$('.btn-refresh').trigger('click'); |
|||
} else { |
|||
window.location.reload(); |
|||
} |
|||
}); |
|||
top.$(layero).data('callback', callback); |
|||
} |
|||
}; |
|||
|
|||
options = $.extend(defaultOptions, options); |
|||
return top.layer.open(options); |
|||
} |
|||
} |
|||
}; |
|||
|
|||
// 暴露到全局
|
|||
window.lang = hkcms.api.lang; |
|||
window.hkcms = hkcms; |
|||
// 兼容旧版
|
|||
window.Util = hkcms.api; |
|||
window.cmsOpen = hkcms.api.open; |
|||
|
|||
// 初始化
|
|||
hkcms.init(); |
|||
|
|||
return hkcms; |
|||
}) |
|||
@ -0,0 +1,737 @@ |
|||
define('table', ['jquery','bootstrap-table','bootstrap-table-lang','moment'], function ($, undefined, undefined, Moment) { |
|||
var Table = { |
|||
defaults: { // 对应bootstraptable属性,表格选项,(doc: https://www.bootstrap-table.com.cn/doc/api/table-options/)
|
|||
classes: 'table table-bordered table-hover table-striped', |
|||
theadClasses: '', |
|||
sortName: 'weigh', // 排序字段
|
|||
sortOrder: 'asc', |
|||
url:'', |
|||
method: 'get', |
|||
pagination: true, //为在表格底部显示分页工具栏
|
|||
sidePagination: 'server', // 服务端分页
|
|||
pageSize: Tpl && Tpl.page && Tpl.page>10 ? parseInt(Tpl.page) : 10, // 初始分页大小
|
|||
pageList: [10, 15, 25, 50, 100, 'all'], // all 显示所有
|
|||
paginationLoop: true, // 分页连续循环模式。
|
|||
search: false, // 快速搜索,formatSearch:function(){return"Search"},更改提示
|
|||
toolbar:'#toolbar', //工具栏
|
|||
showColumns: true, // 显示行下拉选项
|
|||
showRefresh: true, // 显示表格刷新
|
|||
showToggle: true, // 卡片/表格切换
|
|||
showFullscreen: false, // 全屏按钮
|
|||
escape: true, // 转义用于插入HTML的字符串,并替换 &, <, >, “, `, and ‘ 字符
|
|||
clickToSelect: true, // 行点击选中
|
|||
singleSelect: false, // 是否开启单选
|
|||
multipleSelectRow: false, // 设置true以启用多选行。可以使用ctrl键单击以选择一行,或使用shift键单击以选择一系列行
|
|||
pk: 'id', |
|||
onDblClickRow: function(row,obj,name) { |
|||
$(obj).find('.btn-row-edit').trigger('click'); |
|||
}, |
|||
responseHandler: function(res) { |
|||
if (res && res.code && res.code===-1000) { |
|||
layer.msg(res.msg, {time: 4000,icon:2}); |
|||
return []; |
|||
} |
|||
if (res.rows.length<=0 && res.total) { |
|||
return []; |
|||
} |
|||
return res; |
|||
}, |
|||
queryParams: function(params) { |
|||
var exp = {}; |
|||
$('.filter-panel').find('[data-op]').each(function (id, vo) { |
|||
var name = $(this).attr('name'); |
|||
if (typeof name == 'undefined'){ |
|||
return true; |
|||
} |
|||
if ($.inArray($(this).data('op').toUpperCase(), ['BETWEEN','NOT BETWEEN','BETWEEN TIME','NOT BETWEEN TIME'])>=0 && !$(this).hasClass('laydate')) { |
|||
var start = $('#'+$(this).attr('name')+'_start').val() ? $('#'+$(this).attr('name')+'_start').val() : ''; |
|||
var end = $('#'+$(this).attr('name')+'_end').val() ? $('#'+$(this).attr('name')+'_end').val() : ''; |
|||
if (!start && !end) { |
|||
$(this).val(''); |
|||
} else { |
|||
$(this).val(start+' - '+end); |
|||
} |
|||
} |
|||
if (($(this).data('op').toUpperCase()=='IN' || $(this).data('op').toUpperCase()=='NOT IN') && $(this).hasClass('selectpage')) { |
|||
var str = $(this).attr('id'); |
|||
if (str.indexOf('_text')>=0) { |
|||
str = str.substr(0, str.length-5); |
|||
} |
|||
name = $('#'+str).attr('name'); |
|||
} |
|||
exp[name] = $(this).data('op'); |
|||
}); |
|||
|
|||
params.filter = $('.frm-filter').serialize(); |
|||
params.op = JSON.stringify(exp); |
|||
|
|||
var lan = $('.J-hk-contentLang').val(); |
|||
if (!lan) { |
|||
lan = Config.content_lang_mode |
|||
} |
|||
params.clang = lan; |
|||
return params; |
|||
} |
|||
}, |
|||
columnDefaults: { // 列表选项
|
|||
align: 'center', |
|||
valign: 'middle' |
|||
}, |
|||
config: { |
|||
table: '#table', |
|||
disabledbtn: '.btn-disabled', // 禁用按钮
|
|||
btnAdd: '.btn-add', // 添加按钮标识
|
|||
btnEdit: '.btn-edit', // 添加按钮标识
|
|||
btnDel: '.btn-del', // 删除按钮
|
|||
btnRecycle: '.btn-recycle', // 回收站按钮
|
|||
btnRestoreAll: '.btn-restoreAll', // 还原全部
|
|||
btnRestore: '.btn-restore', // 还原
|
|||
btnDestroyAll: '.btn-destroyAll', // 销毁全部
|
|||
btnDestroy: '.btn-destroy', // 销毁全部
|
|||
}, |
|||
init: function(customDefault,customColumnDefaults,config){ |
|||
|
|||
customDefault = customDefault ? customDefault : {}; |
|||
customColumnDefaults = customColumnDefaults ? customColumnDefaults : {}; |
|||
config = config ? config : {}; |
|||
|
|||
// 合并覆盖
|
|||
$.extend($.fn.bootstrapTable.defaults, this.defaults, customDefault); |
|||
$.extend(true, $.fn.bootstrapTable.columnDefaults, this.columnDefaults, customColumnDefaults); |
|||
$.extend(this.config, config); |
|||
var table = $(this.config.table); |
|||
$.extend(true,$.fn.bootstrapTable.columnDefaults, {table:table}); |
|||
table.bootstrapTable(); |
|||
return this.run(table); |
|||
}, |
|||
api: { |
|||
getSelectionsId: function(table, isStr) { |
|||
var ids = table.bootstrapTable('getSelections'); |
|||
if (ids.length===0) { |
|||
layer.msg(lang('Please select a record line'),{time: 4000,icon:2}); |
|||
return false; |
|||
} |
|||
var idsArr = []; |
|||
$.each(ids, function (key, value) { |
|||
idsArr.push(value.id); |
|||
}); |
|||
if (isStr) { |
|||
ids = idsArr.join(','); |
|||
} else { |
|||
ids = idsArr; |
|||
} |
|||
return ids; |
|||
} |
|||
}, |
|||
run: function (table) { |
|||
var that = this; |
|||
// 获取选项
|
|||
var options = table.bootstrapTable('getOptions'); |
|||
// 内容多语言切换.
|
|||
if (Config.content_lang_on==1 && options.contentLangSw) { |
|||
var html = ''; |
|||
$.each(Config.content_lang_list, function (idx, vo) { |
|||
html += '<option value="'+vo['mark']+'" '+(Config.content_lang_mode==vo['mark']?'selected':'')+'>'+(Config.content_lang_mode==vo['mark']?"("+lang('Current')+")"+vo['title']:vo['title'])+'</option>'; |
|||
}) |
|||
$('.J-hk-contentLang').html(html); |
|||
$('.J-hk-contentLang').attr('data-toggle','tooltip'); |
|||
$('.J-hk-contentLang').attr('data-original-title',lang('Only for query, will not affect edit mode')); |
|||
$('.J-hk-contentLang').removeClass('d-none'); |
|||
$(document).on('change', '.J-hk-contentLang', function (e) { |
|||
table.bootstrapTable('refresh'); |
|||
}); |
|||
} |
|||
|
|||
// checkbox 选中事件、取消、全选事件
|
|||
table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table', function (e) { |
|||
var ids = table.bootstrapTable('getSelections'); |
|||
$(that.config.disabledbtn, options.toolbar).toggleClass('disabled', !ids.length); |
|||
}); |
|||
//当刷新表格时
|
|||
table.on('refresh.bs.table', function (e, settings, data) { |
|||
$(that.config.disabledbtn, options.toolbar).addClass("disabled"); |
|||
}); |
|||
// 重载页面
|
|||
$(options.toolbar).on('click','.btn-refresh',function (e) { |
|||
//window.location.reload();
|
|||
table.bootstrapTable('refresh'); |
|||
}); |
|||
|
|||
// 渲染完成后
|
|||
table.on('post-body.bs.table', function (e, settings, json, xhr) { |
|||
$('[data-toggle="tooltip"]').tooltip(); |
|||
$(that.config.disabledbtn, options.toolbar).addClass("disabled"); |
|||
}); |
|||
|
|||
// 工具栏【增、改、删、导入、导出、状态更改、回收站】
|
|||
$(options.toolbar).on('click',this.config.btnAdd,function (e) { |
|||
var data = $(this).data(); |
|||
|
|||
if (options && options.addCallback && typeof options.addCallback === "function") { // 回调
|
|||
var res = options.addCallback.call(e, data); |
|||
if (res===false) { |
|||
return false; |
|||
} |
|||
} |
|||
if (data.popup===false) { |
|||
// 新页面
|
|||
window.location.href = Util.setUrlParams({url:data.url, query:{popup:0}}); |
|||
} else { |
|||
cmsOpen(Util.setUrlParams({url:data.url, query:{popup:1}}),lang('Add')) |
|||
} |
|||
}); |
|||
|
|||
// 修改
|
|||
$(options.toolbar).on('click',this.config.btnEdit,function (e) { |
|||
if ($(this).hasClass('disabled')) { |
|||
return false; |
|||
} |
|||
|
|||
var ids = Table.api.getSelectionsId(table); |
|||
var data = $(this).data(); |
|||
|
|||
if (options && options.editCallback && typeof options.editCallback === "function") { // 回调
|
|||
var res = options.editCallback.call(e, data, ids); |
|||
if (res===false) { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
if (data.popup===false) { |
|||
// 新页面
|
|||
if (ids.length>1) { |
|||
layer.msg(lang('Only one line of record can be operated~'),{time: 4000,icon:2}); |
|||
return false; |
|||
} |
|||
window.location.href = Util.setUrlParams({url:data.url, query:{popup:0,id:ids[0]}}); |
|||
} else { |
|||
$.each(ids, function (key, value) { |
|||
cmsOpen(Util.setUrlParams({url:data.url, query:{popup:1,id:value}}), lang('Edit')); |
|||
}); |
|||
} |
|||
}); |
|||
|
|||
// 删除
|
|||
$(options.toolbar).on('click',this.config.btnDel,function (e) { |
|||
if ($(this).hasClass('disabled')) { |
|||
return false; |
|||
} |
|||
|
|||
var ids = Table.api.getSelectionsId(table,true); |
|||
var url = Util.setUrlParams({url:$(this).data('url'), query:{ids:ids}}); |
|||
|
|||
//询问框
|
|||
layer.confirm(lang('Confirm operation?'), { |
|||
title: lang('Delete'), |
|||
btn: [lang('Confirm'),lang('Cancel')] //按钮
|
|||
}, function(){ |
|||
Util.ajax({url:url,type:"post"},'',function (data,res) { |
|||
layer.msg(res.msg,{time:1000, icon:1},function (e) { |
|||
table.bootstrapTable('refresh'); |
|||
}); |
|||
}); |
|||
}); |
|||
}); |
|||
|
|||
// 回收站
|
|||
$(options.toolbar).on('click', this.config.btnRecycle, function (e) { |
|||
var data = $(this).data(); |
|||
|
|||
if (options && options.recycleCallback && typeof options.recycleCallback === "function") { // 回调
|
|||
var res = options.recycleCallback.call(e, data); |
|||
if (res===false) { |
|||
return false; |
|||
} |
|||
} |
|||
if (data.popup===false) { |
|||
// 新页面
|
|||
window.location.href = Util.setUrlParams({url:data.url, query:{popup:0}}); |
|||
} else { |
|||
cmsOpen(Util.setUrlParams({url:data.url, query:{popup:1}}),lang('Recycle')) |
|||
} |
|||
}); |
|||
|
|||
// 还原全部
|
|||
$(options.toolbar).on('click', this.config.btnRestoreAll, function (e) { |
|||
var that = this; |
|||
//询问框
|
|||
layer.confirm(lang('Are you sure to restore everything?'), { |
|||
btn: [lang('Confirm'),lang('Cancel')] //按钮
|
|||
}, function(){ |
|||
Util.ajax({url:$(that).data('url')},'',function (data,res) { |
|||
layer.msg(res.msg,{time:1000,icon:1},function (e) { |
|||
table.bootstrapTable('refresh'); |
|||
}); |
|||
}); |
|||
}); |
|||
}); |
|||
// 还原选中项
|
|||
$(options.toolbar).on('click', this.config.btnRestore, function (e) { |
|||
if ($(this).hasClass('disabled')) { |
|||
return false; |
|||
} |
|||
var ids = Table.api.getSelectionsId(table,true); |
|||
var url = Util.setUrlParams({url:$(this).data('url'), query:{ids:ids}}); |
|||
layer.confirm(lang('Are you sure to restore the selected items?'), { |
|||
btn: [lang('Confirm'),lang('Cancel')] //按钮
|
|||
}, function(){ |
|||
Util.ajax({url:url},'',function (data,res) { |
|||
layer.msg(res.msg,{time:1000,icon:1},function (e) { |
|||
table.bootstrapTable('refresh'); |
|||
}); |
|||
}); |
|||
}); |
|||
}); |
|||
|
|||
// 销毁全部
|
|||
$(options.toolbar).on('click', this.config.btnDestroyAll, function (e) { |
|||
var that = this; |
|||
layer.confirm(lang('Are you sure to destroy the selected item? Document data will be included'), { |
|||
btn: [lang('Confirm'),lang('Cancel')] //按钮
|
|||
}, function(){ |
|||
Util.ajax({url:$(that).data('url')},'',function (data,res) { |
|||
layer.msg(res.msg,{time:1000,icon:1},function (e) { |
|||
table.bootstrapTable('refresh'); |
|||
}); |
|||
}); |
|||
}); |
|||
}); |
|||
// 销毁选中项
|
|||
$(options.toolbar).on('click', this.config.btnDestroy, function (e) { |
|||
if ($(this).hasClass('disabled')) { |
|||
return false; |
|||
} |
|||
var ids = Table.api.getSelectionsId(table,true); |
|||
var url = Util.setUrlParams({url:$(this).data('url'), query:{ids:ids}}); |
|||
layer.confirm(lang('Are you sure to destroy the selected item? Document data will be included'), { |
|||
btn: [lang('Confirm'),lang('Cancel')] //按钮
|
|||
}, function(){ |
|||
Util.ajax({url:url},'',function (data,res) { |
|||
layer.msg(res.msg,{time:1000,icon:1},function (e) { |
|||
table.bootstrapTable('refresh'); |
|||
}); |
|||
}); |
|||
}); |
|||
}); |
|||
|
|||
// 状态更改
|
|||
$(options.toolbar).find('.btn-toggle').on('click','.dropdown-item.status',function (e) { |
|||
var ids = Table.api.getSelectionsId(table,true); |
|||
if (table.data('batches')) { |
|||
Util.ajax({url: table.data('batches'),data:{ids: ids,params:$(this).data('params')}},'',function (data,res) { |
|||
layer.msg(res.msg,{time:1000,icon:1},function (e) { |
|||
table.bootstrapTable('refresh'); |
|||
}); |
|||
}) |
|||
} else { |
|||
layer.msg(lang('Request address is empty'),{time:4000,icon:2}); |
|||
} |
|||
}) |
|||
|
|||
// 数据筛选
|
|||
if (options.customFilter) { |
|||
$('.filter-panel .frm-filter').submit(function (e) { |
|||
table.bootstrapTable('refresh', {pageNumber: 1}); |
|||
return false; |
|||
}); |
|||
$(document).on('click','.btn-filter',function (e) { |
|||
$('.filter-panel').toggleClass('d-none'); |
|||
}); |
|||
if ($('.frm-filter .selectpage').length>0) { |
|||
require(['Form'], function (Form) { |
|||
Form.event.selectpage($('.frm-filter')); |
|||
}) |
|||
} |
|||
if ($('.frm-filter .laydate').length>0) { |
|||
require(['Form'], function (Form) { |
|||
Form.event.laydate($('.frm-filter')); |
|||
}) |
|||
} |
|||
// 重置表单
|
|||
$('.frm-filter').find("input[type=reset]").click(function (e) { |
|||
setTimeout(function () { |
|||
table.bootstrapTable('refresh'); |
|||
}, 600); |
|||
}) |
|||
} |
|||
|
|||
// 绑定文件上传事件
|
|||
if ($(options.toolbar).find('.btn-uploads').length>0) { |
|||
require(['jquery-fileupload'], function (undefined) { |
|||
$(options.toolbar).on('click', '.btn-uploads', function (e) { |
|||
if ($(this).is('.disabled')) { |
|||
return false; |
|||
} |
|||
|
|||
var chunkSize = 0; // 每次上次的分块字节
|
|||
var error = 0; // 1-错误,0-继续上传分块
|
|||
var count = 1; |
|||
var op = { |
|||
url: Config.upload_url, |
|||
type: 'POST', |
|||
dataType: 'json', // 服务器返回的数据类型
|
|||
autoUpload: true, // 选择文件后自动上传
|
|||
mimetype: '*', // 文件类型
|
|||
size: Config.file_size || (2*1024*1024), |
|||
singleFileUploads: false, |
|||
multiple: false, |
|||
fileNum: 10, |
|||
filesguid: Util.guid(), |
|||
maxChunkSize: Config && Config.chunk && Config.chunk==1 ? Config.chunk_size:0, // 2MB
|
|||
add: function (e, data) { |
|||
count = 1; |
|||
var arr = op.mimetype.split(','); |
|||
if (data.originalFiles.length > op.fileNum) { |
|||
layer.msg(lang('Only %s file can be uploaded at a time!',[op.fileNum]),{time:4000,icon:2}); |
|||
return false; |
|||
} |
|||
for (var idx in data.originalFiles) { |
|||
// 文件格式限制
|
|||
if (op.mimetype.indexOf("/")===-1) { // .jpg,.png格式
|
|||
var index1 = data.originalFiles[idx]['name'].lastIndexOf("."); |
|||
var index2 = data.originalFiles[idx]['name'].length; |
|||
var ext = data.originalFiles[idx]['name'].substring(index1,index2); |
|||
if (op.mimetype!='*' && 0>$.inArray(ext, arr)) { |
|||
layer.msg(lang('Unsupported file suffix'), {time: 4000,icon:2}); |
|||
return false; |
|||
} |
|||
} else { |
|||
// image/png 格式判断
|
|||
var type = data.originalFiles[idx]['type']; |
|||
if (op.mimetype.indexOf("/*") !== -1) { |
|||
type = type.split('/'); |
|||
type[1] = '*'; |
|||
type = type.join('/'); |
|||
} |
|||
|
|||
if (op.mimetype!='*' && 0>$.inArray(type, arr)) { |
|||
layer.msg(lang('Unsupported file suffix'), {time: 4000,icon:2}); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
//文件大小判断
|
|||
if(data.originalFiles[idx].size > op.size) { |
|||
layer.msg(lang('Please upload a leaflet that does not exceed %s',[(op.size/1024).toFixed(2)+'kb']),{time:4000,icon:2}); |
|||
return false; |
|||
} |
|||
} |
|||
data.submit(); |
|||
}, |
|||
progressall: function (e, data) { |
|||
var progress = parseInt(data.loaded / data.total * 100, 10); |
|||
var obj = $(e.target).parent().find('.btn-uploads'); |
|||
|
|||
obj.addClass('disabled'); |
|||
|
|||
var value = ''; |
|||
if (obj.is('input')) { |
|||
value = obj.val(); |
|||
obj.val(progress+'%'); |
|||
} else { |
|||
value = obj.html(); |
|||
obj.html(progress+'%'); |
|||
} |
|||
if (!obj.data('value')) { |
|||
obj.attr('data-value', value); |
|||
} |
|||
}, |
|||
done: function (e, data) { |
|||
count = 1; |
|||
var obj = $(e.target).parent().find('.btn-uploads'); |
|||
if (obj.is('input')) { |
|||
obj.val(obj.data('value')); |
|||
} else { |
|||
obj.html(obj.data('value')); |
|||
} |
|||
obj.removeClass('disabled'); |
|||
if (data.result.code==200) { |
|||
if (!data.result.data || data.result.data.length==0) { |
|||
layer.msg(lang('Not uploaded successfully'),{time:4000,icon:2}); |
|||
return false; |
|||
} |
|||
layer.msg(data.result.msg,{time:1000,icon:1},function (e) { |
|||
table.bootstrapTable('refresh'); |
|||
}); |
|||
} else { |
|||
layer.alert(data.result.msg); |
|||
} |
|||
}, |
|||
chunksend: function (e, data) { // 分块上传前的回调,返回false,结束上传
|
|||
if (error) { |
|||
return false; |
|||
} |
|||
data.data.append('chunksize', chunkSize += data.chunkSize); |
|||
data.data.append('filesize', data.files[0].size); |
|||
data.data.append('fileid', data.filesguid); |
|||
data.data.append('fileindex', count); |
|||
|
|||
count++; |
|||
}, |
|||
chunkdone: function (e, data) { // 每个分块上传完成的回调
|
|||
if (data.result.code!=200) { |
|||
layer.alert(data.result.msg); |
|||
error = 1; |
|||
return false; |
|||
} |
|||
}, |
|||
fail: function (e, data) { |
|||
if (data.maxChunkSize>0) { |
|||
// 切片上传处理
|
|||
var url = Util.setUrlParams({url:data.url, query:{action:'clear',fileid:data.filesguid}}) |
|||
$.get({url: url}); |
|||
} |
|||
count = 1; |
|||
} |
|||
}; |
|||
op = $.extend(op, $(this).data()); |
|||
$(this).after('<input type="file" class="toolbar-input-file" style="display: none" name="files[]" '+(op.multiple==true?'multiple':'')+' accept="'+op.mimetype+'">'); |
|||
$(this).next().click(); |
|||
|
|||
$('.toolbar-input-file').fileupload(op); |
|||
}); |
|||
}); |
|||
} |
|||
return table; |
|||
}, |
|||
|
|||
// 通用格式 输出
|
|||
formatter: { |
|||
SN: function(value, row, index) { |
|||
return index+1; |
|||
}, |
|||
operate: function (value,row,index) { |
|||
var table = this.table; |
|||
var html = ''; |
|||
if (table.data('edit')) { |
|||
html += '<button type="button" class="btn btn-primary btn-xs btn-row-edit mr-2" title="'+lang('Edit')+'" data-popup="'+(typeof(this.popup) !== "undefined"?this.popup:'true')+'"><i class="fas fa-pen"></i></button>'; |
|||
} |
|||
if (table.data('del')) { |
|||
html += '<button type="button" class="btn btn-danger btn-xs btn-row-del mr-2" title="'+lang('Delete')+'" data-tips="'+(this.delTips || '')+'"><i class="fas fa-trash-alt"></i></button>'; |
|||
} |
|||
return html; |
|||
}, |
|||
switchBtn: function (value, row, index, field) { // 切换按钮。1-打开 0-关闭
|
|||
var table = this.table; |
|||
var checked = 1; |
|||
if (!value || value===0 || value === '0' || value=='hidden') { |
|||
checked = 0; |
|||
} |
|||
|
|||
if (table.data('batches')) { |
|||
return '<div class="custom-control custom-switch custom-control-sm">\n' + |
|||
'<input type="checkbox" class="custom-control-input" id="switch'+field+'_'+index+'" data-field="'+field+'" '+(checked===1?'checked':'')+' >\n' + |
|||
'<label class="custom-control-label" for="switch'+field+'_'+index+'"><div class="custom-control-label-dot"></div></label>\n' + |
|||
'</div>' |
|||
} else { |
|||
return '<div class="custom-control custom-switch custom-control-sm">\n' + |
|||
'<input type="checkbox" class="custom-control-input" disabled id="switch'+field+'_'+index+'" data-field="'+field+'" '+(checked===1?'checked':'')+' >\n' + |
|||
'<label class="custom-control-label" for="switch'+field+'_'+index+'"><div class="custom-control-label-dot"></div></label>\n' + |
|||
'</div>' |
|||
} |
|||
}, |
|||
txtEditBtn: function (value, row, index, field) { |
|||
var table = this.table; |
|||
if (table.data('batches')) { |
|||
value = '<input value="'+value+'" data-field="'+field+'" data-id="'+row['id']+'" class="form-control form-control-sm btn-txtEditBtn" style="width: 50px;text-align: center;margin: 0 auto;padding: 2px 8px;" />'; |
|||
return value; |
|||
} else { |
|||
return value; |
|||
} |
|||
}, |
|||
textBox: function (value, row, index, field) { // 设置超过多少隐藏文本
|
|||
var textLength = typeof this.textLength === 'undefined' || this.textLength=='' ? 0 : this.textLength; |
|||
var html = ''; |
|||
if (value.length>textLength) { |
|||
html += '<a class="btn btn-xs btn-default text-box-btn" data-field="'+this.field+'"><i class="fas fa-eye"></i></a>'; |
|||
} else { |
|||
html += value; |
|||
} |
|||
return html; |
|||
}, |
|||
editor: function (value, row, index, field) { // 编辑器效果
|
|||
return '<a class="btn btn-xs btn-default editor-box-btn" data-field="'+this.field+'"><i class="fas fa-eye"></i></a>'; |
|||
}, |
|||
image: function (value, row, index, field) { |
|||
if (!value) { |
|||
return ''; |
|||
} |
|||
var html = ''; |
|||
var checkValue = value.toLowerCase() |
|||
if(!/\.(gif|jpg|jpeg|png|ico|webp)$/.test(checkValue)) { |
|||
if (/\.mp4$/.test(checkValue)) { |
|||
html += '<a href="'+value+'" target="_blank"><img src="'+Config.static_path+'/img/video.png" data-toggle="tooltip" title="'+lang('Click to open')+'" data-url="'+value+'" style="width: auto;height:60px;object-fit: cover;cursor: pointer" class="img-thumbnail"></a>'; |
|||
} else if (/^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i.test(value)) { |
|||
html += '<img src="'+value+'" style="width: 100px;height:60px;object-fit: cover;cursor: pointer" data-toggle="tooltip" title="'+lang('Click to open')+'" class="img-thumbnail">'; |
|||
} else { |
|||
html += '<a href="'+value+'" target="_blank"><img src="'+Config.static_path+'/img/zip.png" data-toggle="tooltip" title="'+lang('Click to open')+'" data-url="'+value+'" style="width: auto;height:60px;object-fit: cover;cursor: pointer" class="img-thumbnail"></a>'; |
|||
} |
|||
} else { |
|||
html += '<a href="'+value+'" target="_blank"><img src="'+value+'" style="width: 100px;height:60px;object-fit: cover;cursor: pointer" data-toggle="tooltip" title="'+lang('Click to open')+'" data-url="'+value+'" class="img-thumbnail" style=""></a>'; |
|||
} |
|||
return html; |
|||
}, |
|||
radio: function (value, row, index, field) { |
|||
if (typeof this.radioOption === 'undefined' || this.radioOption=='') { |
|||
return value |
|||
} |
|||
return this.radioOption[value]; |
|||
}, |
|||
datetime: function (value, row, index, field) { // 日期处理
|
|||
var format = typeof this.datetimeFormat==='undefined' ? 'YYYY-MM-DD HH:mm:ss' : this.datetimeFormat; |
|||
if (isNaN(value)) { |
|||
return value ? Moment(value).format(format) : ''; |
|||
} else { |
|||
return value ? Moment(parseInt(value)* 1000).format(format) : ''; |
|||
} |
|||
}, |
|||
images: function (value, row, index, field) { |
|||
if (!value) { |
|||
return ''; |
|||
} |
|||
var html = ''; |
|||
var tmpArr = []; |
|||
try { |
|||
var JsonObj = JSON.parse(row[field]); |
|||
for (const key in JsonObj) { |
|||
tmpArr.push(JsonObj[key].file); |
|||
} |
|||
} catch (error) { |
|||
console.log(error) |
|||
tmpArr = value.split(','); |
|||
} |
|||
for (var itemKey in tmpArr) { |
|||
html = html + Table.formatter.image(tmpArr[itemKey]) |
|||
} |
|||
return html; |
|||
}, |
|||
}, |
|||
//单元格元素事件
|
|||
events: { |
|||
operate: { |
|||
'click .btn-row-edit': function (e, value, row, index) { |
|||
e.stopPropagation(); |
|||
var table = $(e.currentTarget).closest('table'); |
|||
var options = table.bootstrapTable('getOptions'); |
|||
var id = row[options.pk]; |
|||
var data = $(e.currentTarget).data(); |
|||
var url = table.data('edit'); |
|||
if (!url) { |
|||
layer.msg(lang('Request address is empty'),{time:4000,icon:2}); |
|||
return false; |
|||
} |
|||
|
|||
if (options && options.editCallback && typeof options.editCallback === "function") { // 回调
|
|||
var res = options.editCallback.call(e, {url:url}, id, row); |
|||
if (res===false) { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
if (data.popup===false) { |
|||
// 新页面
|
|||
window.location.href = Util.setUrlParams({url:url, query:{popup:0,id:id}}); |
|||
} else { |
|||
cmsOpen(Util.setUrlParams({url:url,query:{popup:1,id:id}}), lang('Edit')); |
|||
} |
|||
}, |
|||
'click .btn-row-del': function (e, value, row, index) { |
|||
e.stopPropagation(); |
|||
|
|||
var table = $(e.currentTarget).closest('table'); |
|||
var options = table.bootstrapTable('getOptions'); |
|||
var id = row[options.pk]; |
|||
var url = table.data('del'); |
|||
if (!url) { |
|||
layer.msg(lang('Request address is empty'),{time:4000,icon:2}); |
|||
return false; |
|||
} |
|||
|
|||
var data = $(e.currentTarget).data(); |
|||
layer.confirm(data && data.tips || lang('Confirm operation?'), { |
|||
btn: [lang('Confirm'),lang('Cancel')] //按钮
|
|||
}, function(){ |
|||
Util.ajax({url:Util.setUrlParams({url:url, query:{ids:id}}),type:"post"},'',function (data,res) { |
|||
layer.msg(res.msg,{time:1000,icon:1},function (e) { |
|||
table.bootstrapTable('refresh'); |
|||
}); |
|||
}); |
|||
}); |
|||
} |
|||
}, |
|||
switchBtn: { |
|||
'change .custom-control-input': function (e, value, row, index) { |
|||
var table = $(e.currentTarget).closest('table'); |
|||
var options = table.bootstrapTable('getOptions'); |
|||
var r=/^\d+$/; |
|||
var val; |
|||
if (r.test(value)) { |
|||
val = value===1?0:1; |
|||
} else { |
|||
val = value==='normal'?'hidden':'normal'; |
|||
} |
|||
if (table.data('batches')) { |
|||
Util.ajax({url: table.data('batches'),data:{ids: row[options.pk],params:$(e.currentTarget).data('field')+'='+val}},'',function (data,res) { |
|||
layer.msg(res.msg,{time:1000,icon:1},function (e) { |
|||
table.bootstrapTable('refresh'); |
|||
}); |
|||
}) |
|||
} else { |
|||
layer.msg(lang('Permission denied'),{time:4000,icon:2}); |
|||
} |
|||
} |
|||
}, |
|||
txtEditBtn: { // 快速修改字段值
|
|||
'change .btn-txtEditBtn': function (e, value, row, index) { |
|||
e.stopPropagation(); |
|||
|
|||
var table = $(e.currentTarget).closest('table'); |
|||
var data = $(e.currentTarget).data(); |
|||
if (data) { |
|||
hkcms.api.ajax({url: table.data('batches'),data:{ids:data.id,params:data.field+'='+$(e.currentTarget).val()},type: 'post'},'',function (data, res) { |
|||
layer.msg(res.msg,{time:1000, icon:1},function (e) { |
|||
table.bootstrapTable('refresh'); |
|||
}); |
|||
}) |
|||
} |
|||
}, |
|||
'dblclick .btn-txtEditBtn': function (e) { |
|||
e.stopPropagation() |
|||
} |
|||
}, |
|||
textBoxBtn: { // 弹出式显示文本内容
|
|||
'click .text-box-btn': function (e, value, row, index) { |
|||
e.stopPropagation(); |
|||
hkcms.api.open('',lang('Info'),{ |
|||
type: 1, |
|||
area: [$(top.window).width() > 800 ? '400px' : '90%', $(top.window).height() > 600 ? '300px' : '90%'], |
|||
id:'frm-'+$(e.currentTarget).data('field')+index, |
|||
content:`<div style="word-wrap:break-word;padding: 10px;"><textarea class="form-control" rows="8">`+value+'</textarea></div>' |
|||
}) |
|||
} |
|||
}, |
|||
image: { |
|||
'click .img-thumbnail': function (e, value, row, index) { |
|||
e.stopPropagation(); |
|||
e.preventDefault(); |
|||
var img = $(e.currentTarget).data('url'); |
|||
window.open(img) |
|||
} |
|||
}, |
|||
// 编辑器
|
|||
editor: { |
|||
'click .editor-box-btn': function (e, value, row, index) { |
|||
e.stopPropagation(); |
|||
console.log($(top.window).width()) |
|||
hkcms.api.open('',lang('Info'),{ |
|||
type: 1, |
|||
area: [$(top.window).width() > 800 ? '800px' : '90%', $(top.window).height() > 600 ? '600px' : '90%'], |
|||
id:'frm-'+$(e.currentTarget).data('field')+index, |
|||
content:`<div style="padding: 20px 25px 25px 25px">`+value+'</div>' |
|||
}) |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
return Table; |
|||
}); |
|||
@ -0,0 +1,619 @@ |
|||
/** |
|||
* 语言包 |
|||
* @param name |
|||
* @param arr |
|||
* @returns {*} |
|||
*/ |
|||
function lang(name, arr) { |
|||
name = Lang[name] ? Lang[name] : name; |
|||
if (arr) { |
|||
for(var key in arr) { |
|||
name = name.replace('%s', arr[key]); |
|||
} |
|||
} |
|||
return name; |
|||
} |
|||
|
|||
require.config({ |
|||
baseUrl: Config.cdn+'/static/', |
|||
urlArgs: "v="+Config.version+parseInt(new Date().getTime()/1000), |
|||
map: { |
|||
'*': { |
|||
'css': 'libs/require/css.min' |
|||
} |
|||
}, |
|||
paths: { |
|||
"jquery": "libs/jquery/jquery.min", |
|||
"bootstrap": "libs/bootstrap/js/bootstrap.bundle.min", |
|||
// "bootstrap-table": 'libs/bootstrap-table-master/bootstrap-table.min',
|
|||
// "bootstrap-table-lang": 'libs/bootstrap-table-master/locale/bootstrap-table-'+Config.admin_lang+'.min',
|
|||
"validator": 'libs/nice-validator/jquery.validator.min', |
|||
"validatorLang": 'libs/nice-validator/local/zh-cn', // 语言包
|
|||
"jquery-ui-widget": 'libs/jquery-fileupload/jquery.ui.widget', |
|||
"jquery-fileupload": 'libs/jquery-fileupload/jquery.fileupload', |
|||
// "jquery-ui": 'libs/jquery-ui/jquery-ui.min',
|
|||
"layerJs": 'libs/layer/layer', |
|||
// "laydate": 'libs/laydate/laydate',
|
|||
// "selectpage": 'libs/selectpage/selectpage.min',
|
|||
// "jstree": 'libs/jstree/jstree.min'
|
|||
}, |
|||
shim: { |
|||
'bootstrap': ['jquery'], |
|||
// 'bootstrap-table': ['bootstrap'],
|
|||
// 'bootstrap-table-lang': ['bootstrap-table'],
|
|||
'validator': ['css!libs/nice-validator/jquery.validator.css'], |
|||
'validatorLang': ['validator'], |
|||
'jquery-fileupload': ['jquery-ui-widget'], |
|||
// 'jquery-ui': ['css!libs/jquery-ui/jquery-ui.min.css'],
|
|||
// 'selectpage': ['css!libs/selectpage/selectpage.css'],
|
|||
// 'jstree': ['jquery','css!libs/jstree/themes/default/style.min.css']
|
|||
}, |
|||
waitSeconds: 30 |
|||
}); |
|||
|
|||
/** |
|||
* Util常用函数库 |
|||
* @returns {UtilHelpApp20190708} |
|||
* @constructor |
|||
*/ |
|||
function UtilHelpApp20190708() { |
|||
if (this.constructor != UtilHelpApp20190708) { |
|||
return new UtilHelpApp20190708(); |
|||
} |
|||
|
|||
/** |
|||
* 设置URL常用参数 |
|||
* @param options object {url:'', query:[]} |
|||
* @returns {string|*} |
|||
*/ |
|||
this.setUrlParams = function (options) { |
|||
let {url,query} = options; |
|||
if(query) { |
|||
let queryArr = []; |
|||
for (const key in query) { |
|||
if (query.hasOwnProperty(key)) { |
|||
queryArr.push(`${key}=${query[key]}`) |
|||
} |
|||
} |
|||
if(url.indexOf('?') !== -1) { |
|||
url =`${url}&${queryArr.join('&')}` |
|||
} else { |
|||
url = url ? `${url}?${queryArr.join('&')}` : queryArr.join('&'); |
|||
} |
|||
} |
|||
return url; |
|||
}; |
|||
|
|||
/** |
|||
* 获取URL地址参数 |
|||
* @param url |
|||
* @returns {{}} |
|||
*/ |
|||
this.getUrlParams = function getRequest(url) { |
|||
url = url || window.location.search; //获取url中"?"符后的字串
|
|||
var params = {}; |
|||
if (url.indexOf("?") != -1) { |
|||
var str = url.substr(1); |
|||
str = str.split("&"); |
|||
for(var i = 0; i < str.length; i ++) { |
|||
params[str[i].split("=")[0]]=decodeURI(str[i].split("=")[1]); |
|||
} |
|||
} |
|||
return params; |
|||
} |
|||
|
|||
/** |
|||
* ajax请求 |
|||
* @param options ajax选项,覆盖ajax |
|||
* @param before 请求前的回调 |
|||
* @param success 请求后的回调 |
|||
* @param error 响应成功,但状态码错误的回调 |
|||
* @param btnSumit 提交按钮对象 |
|||
* @returns {*} |
|||
*/ |
|||
this.ajax = function (options, before, success, error, btnSumit) { |
|||
options = typeof options === 'string' ? {url: options} : options; |
|||
|
|||
if (options.type==='post') { |
|||
var token = $('meta[name="csrf-token"]').attr('content'); |
|||
if (token) { |
|||
if (Object.prototype.toString.call(options.data) === '[object Array]') { |
|||
options.data.push({name:'__token__',value:token}); |
|||
} else if(typeof options.data == "object") { |
|||
options.data['__token__'] = token; |
|||
} |
|||
} |
|||
} |
|||
|
|||
var index = 0; |
|||
var defaultConfig = { |
|||
type: 'get', |
|||
dataType:'json', |
|||
beforeSend:function(XMLHttpRequest,self) { |
|||
if (typeof before === "function") { |
|||
var data = before(options.data); |
|||
if (false===data) { |
|||
if (btnSumit){btnSumit.removeClass('disabled')} |
|||
return false; |
|||
} |
|||
self.data = $.param(data); |
|||
} |
|||
index = layer.load(1); |
|||
}, |
|||
cache: false, |
|||
complete: function (xhr) { |
|||
var token = xhr.getResponseHeader('__token__'); |
|||
if (token) { |
|||
$('meta[name="csrf-token"]').attr('content',token); |
|||
} |
|||
}, |
|||
success: function(response) { |
|||
layer.close(index); |
|||
|
|||
if (response.code === 200) { |
|||
if (typeof success === "function") { |
|||
if (false===success(response.data,response)) { |
|||
return false; |
|||
} |
|||
} |
|||
} else { |
|||
if (typeof error === "function") { |
|||
if (false===error(response)) { |
|||
return false; |
|||
} |
|||
} |
|||
layer.msg(response.msg, {time:4000,icon:2}); |
|||
} |
|||
}, |
|||
error: function(e) { |
|||
layer.close(index); |
|||
|
|||
if (btnSumit){ |
|||
btnSumit.removeClass('disabled') |
|||
} |
|||
|
|||
if (e.status>0) { |
|||
let txt = e.statusText; |
|||
if (e.responseJSON && e.responseJSON.message) { |
|||
txt = e.responseJSON.message; |
|||
} else if (e.responseJSON && e.responseJSON.msg) { |
|||
txt = e.responseJSON.msg; |
|||
} |
|||
layer.alert('['+e.status+'] '+txt); |
|||
} else { |
|||
layer.alert(lang('Request exception')); |
|||
} |
|||
} |
|||
}; |
|||
return $.ajax($.extend(defaultConfig,options)); |
|||
} |
|||
|
|||
/** |
|||
* 获取唯一值 |
|||
* @returns {string} |
|||
*/ |
|||
this.guid = function () { |
|||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { |
|||
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); |
|||
return v.toString(16); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
var UtilHelpApp = UtilHelpApp20190708; |
|||
window.Util = new UtilHelpApp(); |
|||
|
|||
define('layer', ['jquery', 'layerJs'], function ($, layer) { |
|||
layer.config({ |
|||
extend: 'default/layer.css', //加载新皮肤
|
|||
}); |
|||
|
|||
// 全局
|
|||
window.Layer = layer; |
|||
return layer; |
|||
}) |
|||
|
|||
define('Form', ['jquery','layer','validator','validatorLang'], function ($, layer) { |
|||
var Form = { |
|||
config: { |
|||
frmOperate: '.frm-operate', // 表单标签class
|
|||
isValidate: true, // 是否开启验证
|
|||
}, |
|||
api: { |
|||
init: function (config) { |
|||
config = config ? config : {}; |
|||
config = $.extend(Form.config, config); |
|||
let form = typeof config.frmOperate == 'object' ? config.frmOperate : $(config.frmOperate); |
|||
|
|||
if (config.isValidate) { |
|||
Form.event.validator(form, config.validator, config.before, config.success, config.error); |
|||
} else { |
|||
form.submit(function (e) { |
|||
e.preventDefault(); |
|||
Form.api.submit(form, config.before, config.success, config.error); |
|||
}); |
|||
} |
|||
Form.event.selectpage(form); |
|||
Form.event.laydate(form); |
|||
Form.event.fileSelect(form); |
|||
Form.event.fileUpload(form); |
|||
Form.event.filePreview(form); |
|||
Form.event.tips(form); |
|||
Form.event.more(form); |
|||
}, |
|||
submit: function(form, before, success, error) { |
|||
let btnSumit = $('[type=submit]', form); |
|||
if (btnSumit.hasClass('disabled')) { |
|||
return false; |
|||
} |
|||
btnSumit.addClass('disabled'); |
|||
|
|||
// 数据提交
|
|||
let url = form.attr('action'); |
|||
url = url ? url : location.href; |
|||
let method = form.attr('method'); |
|||
method = method ? method : 'post'; |
|||
|
|||
let obj = Util.ajax({ |
|||
url: url, |
|||
type: method, |
|||
data: form.serializeArray(), |
|||
enableToken: true |
|||
}, before,function (data,response) { |
|||
btnSumit.removeClass('disabled'); |
|||
|
|||
// 是否有设置响应成功后的回调
|
|||
if (typeof success === "function") { |
|||
if (false===success(data,response)) { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
if ($('.operatePage').length) { |
|||
layer.msg(response.msg || lang('Successful operation'), {time:2000, icon:1}, function () { |
|||
parent.layer.close(parent.layer.getFrameIndex(window.name)); |
|||
parent.$('button[name="refresh"]').trigger('click'); |
|||
}); |
|||
} else { |
|||
layer.msg(response.msg || lang('Successful operation'), {time:2000, icon:1}, function () { |
|||
self.location=document.referrer; |
|||
}); |
|||
} |
|||
}, function (data) { |
|||
// 错误回调
|
|||
btnSumit.removeClass('disabled'); |
|||
|
|||
// 是否有设置回调
|
|||
if (typeof error === "function") { |
|||
if (false===error(data)) { |
|||
return false; |
|||
} |
|||
} |
|||
layer.msg(data.msg,{time:4000, icon:2}); |
|||
}, btnSumit); |
|||
}, |
|||
}, |
|||
event: { |
|||
validator: function (form, option, before, success, error) { |
|||
option = option || {}; |
|||
let options = { |
|||
formClass: "n-default n-bootstrap", |
|||
msgClass: "n-bottom", |
|||
theme: 'bootstrap', |
|||
invalidClass: 'is-invalid', |
|||
target: function(elem){ // 自定义消息位置
|
|||
let formitem = $(elem).closest('.form-group>div'), |
|||
msgbox = formitem.find('span.msg-box'); |
|||
if (!msgbox.length) { |
|||
msgbox = $('<span class="msg-box"></span>').appendTo(formitem); |
|||
} |
|||
return msgbox; |
|||
}, |
|||
valid: function(result) { |
|||
Form.api.submit(form, before, success, error); |
|||
}, |
|||
invalid: function (result) { |
|||
if ($(result).find('.card.card-tabs').length==1) { |
|||
// is-invalid
|
|||
var href = $('.nav-tabs').find('.nav-link.active').attr('href'); |
|||
if ($(href).find('.is-invalid').length<=0) { |
|||
$('.nav-tabs').find('.nav-link:not(.active)').each(function (e) { |
|||
href = $(this).attr('href'); |
|||
if ($(href).find('.is-invalid').length) { |
|||
$(this).trigger('click'); |
|||
return false; |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
}; |
|||
form.validator($.extend(options, option)); |
|||
}, |
|||
selectpage: function (form) { |
|||
if (form.find('.selectpage').length>0) { |
|||
// 加载selectpage插件
|
|||
require(['selectpage'], function (undefined) { |
|||
let option = { |
|||
showField: 'name', |
|||
keyField: 'id', |
|||
searchField: 'name', // ajax查询时,需要提交的查询字段,多个英文逗号分隔
|
|||
data: [], // 格式:[{id:1,name:'张三',sex:'男'},{id:2,name:'李四',sex:'男'}]
|
|||
selectOnly: false, |
|||
pagination: true, |
|||
listSize: 10, // 列表显示的项目个数,其它的项目以滚动条滚动方式展现
|
|||
multiple: false, |
|||
lang: 'cn', |
|||
maxSelectLimit: 10, |
|||
eAjaxSuccess: function (data) { |
|||
if (data.code && data.code!=200) { |
|||
layer.alert(data.msg); |
|||
return {list:[],totalRow:[]}; |
|||
} |
|||
// 动态下拉返回值的格式化
|
|||
data.list = typeof data.rows !== 'undefined' ? data.rows : []; |
|||
data.totalRow = typeof data.total !== 'undefined' ? data.total : data.list.length; |
|||
return data; |
|||
} |
|||
}; |
|||
form.find('.selectpage').each(function (key,item) { |
|||
let id = $(this).attr('id'),data = $(this).data(); |
|||
data = $.extend(false, option, data); // 通过input data属性覆盖默认属性,更多属性查看文档
|
|||
|
|||
// 自动加上域名
|
|||
if (data.data.indexOf(Config.root_file)<0) { |
|||
data.data = Config.root_domain+(data.data.substr(0,1)=='/'?data.data:'/'+data.data); |
|||
} |
|||
|
|||
// 判断是否自定义条件json类型
|
|||
let jsonStr = data.params; |
|||
if (typeof jsonStr!=='function' && typeof jsonStr!=='undefined') { |
|||
data.params = function(){return jsonStr;} |
|||
} |
|||
$('#'+id).selectPage(data); |
|||
}) |
|||
}) |
|||
} |
|||
}, |
|||
laydate: function (form) { |
|||
if (form.find('.laydate').length>0) { |
|||
// 加载laydate插件
|
|||
require(['laydate'], function (Laydate) { |
|||
form.find('.laydate').each(function (idx,vo) { |
|||
let obj = { |
|||
elem: vo, |
|||
type: 'datetime', |
|||
trigger: 'click', |
|||
value: $(this).val() |
|||
}; |
|||
obj = $.extend(obj, $(this).data()); |
|||
Laydate.render(obj); |
|||
}); |
|||
}) |
|||
} |
|||
}, |
|||
fileSelect: function (form) { // 文件选择
|
|||
form.on('click', '.btn-imgSelect', function (e) { |
|||
let option = { |
|||
field: 'image', |
|||
mimetype: '*', |
|||
multiple: false, |
|||
fileNum: 10 |
|||
}; |
|||
option = $.extend(option, $(this).data()); |
|||
let url = Util.setUrlParams({url:Config.root_domain+'/routine.attachment/select', query:option}); |
|||
cmsOpen(url,lang('Select image')); |
|||
}) |
|||
}, |
|||
fileUpload: function (form) { // 文件上传插件
|
|||
if (form.find('.btn-imgUpload').length>0) { |
|||
require(['jquery-fileupload'], function (undefined) { // 加载文件上传插件
|
|||
form.find('.btn-imgUpload').each(function (index) { |
|||
if ($(this).parent().find('input[type=file]').length!=0) { |
|||
return true; |
|||
} |
|||
let option = { |
|||
url: Config.upload_url, |
|||
field: 'image', |
|||
mimetype: '*', |
|||
multiple: false |
|||
}; |
|||
option = $.extend(option, $(this).data()); |
|||
$(this).after('<input type="file" class="input-file'+index+'" style="display: none" name="files[]" '+(option.multiple==true?'multiple':'')+' accept="'+option.mimetype+'">'); |
|||
$(this).bind('click', {}, function (e) { |
|||
if (!$(this).is('.disabled')) { |
|||
$(this).next().click(); |
|||
} |
|||
}); |
|||
|
|||
var chunkSize = 0; // 每次上次的分块字节
|
|||
var error = 0; // 1-错误,0-继续上传分块
|
|||
var count = 1; |
|||
option = { |
|||
url: Config.upload_url, |
|||
type: 'POST', |
|||
dataType: 'json', // 服务器返回的数据类型
|
|||
autoUpload: true, // 选择文件后自动上传
|
|||
mimetype: '*', // 文件类型
|
|||
size: Config.file_size || (2*1024*1024), |
|||
singleFileUploads: false, |
|||
fileNum: 10, |
|||
filesguid: Util.guid(), |
|||
maxChunkSize: Config && Config.chunk && Config.chunk==1 ? Config.chunk_size:0, // 2MB
|
|||
formData: function (form) { // 额外表单
|
|||
var allow = []; |
|||
if (option && option.fields) { |
|||
var arr = option.fields.split(','); |
|||
if (arr.length>0) { |
|||
$.each(form.serializeArray(), function (idx, item) { |
|||
if ($.inArray(item.name,arr)!=-1) { |
|||
allow.push(item); |
|||
} |
|||
}) |
|||
} |
|||
} |
|||
return allow; |
|||
}, |
|||
add: function (e, data) { // 文件添加验证
|
|||
let arr = option.mimetype.split(','); |
|||
if (data.originalFiles.length > option.fileNum) { |
|||
layer.msg(lang('Only %s file can be uploaded at a time!',[option.fileNum]),{time: 4000,icon:2}); |
|||
return false; |
|||
} |
|||
for (let idx in data.originalFiles) { |
|||
var type = data.originalFiles[idx]['type']; |
|||
if (option.mimetype.indexOf("/*") !== -1) { |
|||
type = type.split('/'); |
|||
type[1] = '*'; |
|||
type = type.join('/'); |
|||
} |
|||
if (option.mimetype!='*' && 0>$.inArray(type, arr)) { |
|||
layer.msg(lang('Unsupported file suffix'), {time: 4000,icon:2}); |
|||
return false; |
|||
} |
|||
|
|||
//文件大小判断
|
|||
if(data.originalFiles[idx].size > option.size) { |
|||
layer.msg(lang('Please upload a leaflet that does not exceed %s',[(option.size/1024/1024).toFixed(2)+'M']),{time: 4000,icon:2}); |
|||
return false; |
|||
} |
|||
} |
|||
count = 1; |
|||
chunkSize = 0; |
|||
data.submit(); |
|||
}, |
|||
progressall: function (e, data) { // 进度
|
|||
var progress = parseInt(data.loaded / data.total * 100, 10); |
|||
var obj = $(e.target).parent().find('.btn-imgUpload'); |
|||
|
|||
obj.addClass('disabled'); |
|||
|
|||
var value = ''; |
|||
if (obj.is('input')) { |
|||
value = obj.val(); |
|||
obj.val(progress+'%'); |
|||
} else { |
|||
value = obj.html(); |
|||
obj.html(progress+'%'); |
|||
} |
|||
if (!obj.data('value')) { |
|||
obj.attr('data-value', value); |
|||
} |
|||
}, |
|||
done: function (e, data) { // 成功回调
|
|||
count = 1; |
|||
var obj = $(e.target).parent().find('.btn-imgUpload'); |
|||
obj.val(obj.data('value')); |
|||
obj.removeClass('disabled'); |
|||
if (data.result.code==200) { |
|||
if (!data.result.data || data.result.data.length==0) { |
|||
layer.msg(lang('Not uploaded successfully'),{time: 4000,icon:2}); |
|||
return false; |
|||
} |
|||
var paths = []; |
|||
$.each(data.result.data, function (idx, item) { |
|||
paths.push(item.path); |
|||
}) |
|||
paths = paths.join(','); |
|||
$('#'+option.field).val(paths); |
|||
$('#'+option.field).trigger('change'); |
|||
} else { |
|||
layer.alert(data.result.msg); |
|||
} |
|||
}, |
|||
chunksend: function (e, data) { // 分块上传前的回调,返回false,结束上传
|
|||
if (error) { |
|||
return false; |
|||
} |
|||
data.data.append('chunksize', chunkSize += data.chunkSize); |
|||
data.data.append('filesize', data.files[0].size); |
|||
data.data.append('fileid', data.filesguid); |
|||
data.data.append('fileindex', count); |
|||
|
|||
count++; |
|||
}, |
|||
chunkdone: function (e, data) { // 每个分块上传完成的回调
|
|||
if (data.result.code!=200) { |
|||
layer.alert(data.result.msg); |
|||
error = 1; |
|||
return false; |
|||
} |
|||
}, |
|||
fail: function (e, data) { |
|||
if (data.maxChunkSize>0) { |
|||
// 切片上传处理
|
|||
var url = Util.setUrlParams({url:data.url, query:{action:'clear',fileid:data.filesguid}}) |
|||
$.get({url: url}); |
|||
} |
|||
count = 1; |
|||
} |
|||
}; |
|||
|
|||
option = $.extend(option, $(this).data()); |
|||
$('.input-file'+index).fileupload(option); |
|||
}) |
|||
}) |
|||
} |
|||
}, |
|||
filePreview: function (form) { // 文件input框更改事件,预览
|
|||
form.on('change','.txt-files', function (e) { |
|||
if (!$(this).parent().parent().find('.file-preview')) { |
|||
return false; |
|||
} |
|||
let imgStr = $(this).val(); |
|||
if (imgStr.length==0) { |
|||
return false; |
|||
} |
|||
let arr = imgStr.split(','); |
|||
let html = ''; |
|||
for (var idx in arr) { |
|||
html += '<div class="col-md-3">\n' + |
|||
'<a href="'+arr[idx]+'" target="_blank"><img src="'+Config.cdn_url+arr[idx]+'" class="img-thumbnail"></a>\n' + |
|||
'<a href="#" class="btn btn-danger btn-xs preview-del mt-2" data-index="'+idx+'"><i class="fas fa-trash-alt"></i></a>\n' + |
|||
'</div>'; |
|||
} |
|||
$(this).parent().parent().find('.file-preview').html(html); |
|||
}); |
|||
form.find('.txt-files').trigger('change'); |
|||
form.on('click', '.preview-del', function (e) { |
|||
let obj = $(this).parents('.fileGroup').find('.txt-files'); |
|||
let arr = obj.val().split(','); |
|||
let index = $(this).parents('.fileGroup').find('.preview-del').index(this) |
|||
arr.splice(index,1); |
|||
obj.val(arr.join(',')); |
|||
$(this).parent().remove(); |
|||
}); |
|||
}, |
|||
tips: function (form) { |
|||
var tips_index = 0; |
|||
form.on('mouseover', '.form-tips span', function (e) { |
|||
tips_index = layer.tips($(this).attr('title'), this, { |
|||
tips: 2, |
|||
time: 0 |
|||
}); |
|||
}).on('mouseleave', '.form-tips span', function(){ |
|||
layer.close(tips_index); |
|||
}); |
|||
}, |
|||
more: function (form) { |
|||
} |
|||
} |
|||
} |
|||
return Form; |
|||
}); |
|||
|
|||
require(['jquery','bootstrap'], function ($) { |
|||
// 初始化
|
|||
if ($(window).width()>767) { |
|||
$('#navbarSupportedContent').find('.dropdown>.nav-link').removeAttr('data-toggle'); |
|||
} |
|||
$('.userMenuBtn').click(function (e) { |
|||
if ($(this).find('.fas').is('.fa-bars')) { |
|||
$('#userMenu').addClass('show'); |
|||
$(this).find('.fas').removeClass('fa-bars').addClass('fa-times'); |
|||
} else { |
|||
$('#userMenu').removeClass('show'); |
|||
$(this).find('.fas').removeClass('fa-times').addClass('fa-bars'); |
|||
} |
|||
}); |
|||
}) |
|||
@ -0,0 +1 @@ |
|||
|
|||
@ -0,0 +1,10 @@ |
|||
/** |
|||
* bootstrap-table - An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation) |
|||
* |
|||
* @version v1.16.0 |
|||
* @homepage https://bootstrap-table.com |
|||
* @author wenzhixin <wenzhixin2010@gmail.com> (http://wenzhixin.net.cn/) |
|||
* @license MIT |
|||
*/ |
|||
|
|||
.table-cell-input{display:block!important;padding:5px!important;margin:0!important;border:0!important;width:100%!important;box-sizing:border-box!important;-moz-box-sizing:border-box!important;border-radius:0!important;line-height:1!important;white-space:nowrap} |
|||
@ -0,0 +1,10 @@ |
|||
/** |
|||
* bootstrap-table - An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation) |
|||
* |
|||
* @version v1.16.0 |
|||
* @homepage https://bootstrap-table.com |
|||
* @author wenzhixin <wenzhixin2010@gmail.com> (http://wenzhixin.net.cn/) |
|||
* @license MIT |
|||
*/ |
|||
|
|||
@charset "UTF-8";.no-filter-control{height:34px}.filter-control{margin:0 2px 2px 2px} |
|||
@ -0,0 +1,10 @@ |
|||
/** |
|||
* bootstrap-table - An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation) |
|||
* |
|||
* @version v1.16.0 |
|||
* @homepage https://bootstrap-table.com |
|||
* @author wenzhixin <wenzhixin2010@gmail.com> (http://wenzhixin.net.cn/) |
|||
* @license MIT |
|||
*/ |
|||
|
|||
.fixed-columns,.fixed-columns-right{position:absolute;top:0;height:100%;background-color:#fff;box-sizing:border-box;z-index:1}.fixed-columns{left:0}.fixed-columns .fixed-table-body{overflow:hidden!important}.fixed-columns-right{right:0}.fixed-columns-right .fixed-table-body{overflow-x:hidden!important} |
|||
@ -0,0 +1,10 @@ |
|||
/** |
|||
* bootstrap-table - An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation) |
|||
* |
|||
* @version v1.16.0 |
|||
* @homepage https://bootstrap-table.com |
|||
* @author wenzhixin <wenzhixin2010@gmail.com> (http://wenzhixin.net.cn/) |
|||
* @license MIT |
|||
*/ |
|||
|
|||
.bootstrap-table .table>tbody>tr.groupBy{cursor:pointer}.bootstrap-table .table>tbody>tr.hidden+tr.detail-view{display:none} |
|||
@ -0,0 +1,10 @@ |
|||
/** |
|||
* bootstrap-table - An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation) |
|||
* |
|||
* @version v1.16.0 |
|||
* @homepage https://bootstrap-table.com
|
|||
* @author wenzhixin <wenzhixin2010@gmail.com> (http://wenzhixin.net.cn/)
|
|||
* @license MIT |
|||
*/ |
|||
|
|||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],e):e((t=t||self).jQuery)}(this,(function(t){"use strict";function e(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function n(t){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}(t=t&&t.hasOwnProperty("default")?t.default:t).fn.bootstrapTable.methods.push("changeTitle"),t.fn.bootstrapTable.methods.push("changeLocale"),t.BootstrapTable=function(r){function u(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,u),i(this,n(u).apply(this,arguments))}var a,c,f;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}(u,r),a=u,(c=[{key:"changeTitle",value:function(e){t.each(this.options.columns,(function(n,o){t.each(o,(function(t,n){n.field&&(n.title=e[n.field])}))})),this.initHeader(),this.initBody(),this.initToolbar()}},{key:"changeLocale",value:function(t){this.options.locale=t,this.initLocale(),this.initPagination(),this.initBody(),this.initToolbar()}}])&&e(a.prototype,c),f&&e(a,f),u}(t.BootstrapTable)})); |
|||
@ -0,0 +1,10 @@ |
|||
/** |
|||
* bootstrap-table - An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation) |
|||
* |
|||
* @version v1.16.0 |
|||
* @homepage https://bootstrap-table.com |
|||
* @author wenzhixin <wenzhixin2010@gmail.com> (http://wenzhixin.net.cn/) |
|||
* @license MIT |
|||
*/ |
|||
|
|||
.bootstrap-table.bootstrap3 .fixed-table-pagination>.pagination .page-jump-to,.bootstrap-table.bootstrap3 .fixed-table-pagination>.pagination ul.pagination{display:inline}.bootstrap-table .fixed-table-pagination>.pagination .page-jump-to input{width:70px;margin-left:5px;text-align:center;float:left} |
|||
@ -0,0 +1,10 @@ |
|||
/** |
|||
* bootstrap-table - An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation) |
|||
* |
|||
* @version v1.16.0 |
|||
* @homepage https://bootstrap-table.com |
|||
* @author wenzhixin <wenzhixin2010@gmail.com> (http://wenzhixin.net.cn/) |
|||
* @license MIT |
|||
*/ |
|||
|
|||
.reorder_rows_onDragClass td{background-color:#eee;-webkit-box-shadow:11px 5px 12px 2px #333,0 1px 0 #ccc inset,0 -1px 0 #ccc inset;-webkit-box-shadow:6px 3px 5px #555,0 1px 0 #ccc inset,0 -1px 0 #ccc inset;-moz-box-shadow:6px 4px 5px 1px #555,0 1px 0 #ccc inset,0 -1px 0 #ccc inset;-box-shadow:6px 4px 5px 1px #555,0 1px 0 #ccc inset,0 -1px 0 #ccc inset}.reorder_rows_onDragClass td:last-child{-webkit-box-shadow:8px 7px 12px 0 #333,0 1px 0 #ccc inset,0 -1px 0 #ccc inset;-webkit-box-shadow:1px 8px 6px -4px #555,0 1px 0 #ccc inset,0 -1px 0 #ccc inset;-moz-box-shadow:0 9px 4px -4px #555,0 1px 0 #ccc inset,0 -1px 0 #ccc inset,-1px 0 0 #ccc inset;-box-shadow:0 9px 4px -4px #555,0 1px 0 #ccc inset,0 -1px 0 #ccc inset,-1px 0 0 #ccc inset} |
|||
@ -0,0 +1,10 @@ |
|||
/** |
|||
* bootstrap-table - An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation) |
|||
* |
|||
* @version v1.16.0 |
|||
* @homepage https://bootstrap-table.com |
|||
* @author wenzhixin <wenzhixin2010@gmail.com> (http://wenzhixin.net.cn/) |
|||
* @license MIT |
|||
*/ |
|||
|
|||
.fix-sticky{position:fixed!important;overflow:hidden;z-index:100}.fix-sticky table thead{background:#fff}.fix-sticky table thead.thead-light{background:#e9ecef}.fix-sticky table thead.thead-dark{background:#212529} |
|||
@ -0,0 +1,344 @@ |
|||
/* BASICS */ |
|||
|
|||
.CodeMirror { |
|||
/* Set height, width, borders, and global font properties here */ |
|||
font-family: monospace; |
|||
height: 300px; |
|||
color: black; |
|||
direction: ltr; |
|||
} |
|||
|
|||
/* PADDING */ |
|||
|
|||
.CodeMirror-lines { |
|||
padding: 4px 0; /* Vertical padding around content */ |
|||
} |
|||
.CodeMirror pre.CodeMirror-line, |
|||
.CodeMirror pre.CodeMirror-line-like { |
|||
padding: 0 4px; /* Horizontal padding of content */ |
|||
} |
|||
|
|||
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { |
|||
background-color: white; /* The little square between H and V scrollbars */ |
|||
} |
|||
|
|||
/* GUTTER */ |
|||
|
|||
.CodeMirror-gutters { |
|||
border-right: 1px solid #ddd; |
|||
background-color: #f7f7f7; |
|||
white-space: nowrap; |
|||
} |
|||
.CodeMirror-linenumbers {} |
|||
.CodeMirror-linenumber { |
|||
padding: 0 3px 0 5px; |
|||
min-width: 20px; |
|||
text-align: right; |
|||
color: #999; |
|||
white-space: nowrap; |
|||
} |
|||
|
|||
.CodeMirror-guttermarker { color: black; } |
|||
.CodeMirror-guttermarker-subtle { color: #999; } |
|||
|
|||
/* CURSOR */ |
|||
|
|||
.CodeMirror-cursor { |
|||
border-left: 1px solid black; |
|||
border-right: none; |
|||
width: 0; |
|||
} |
|||
/* Shown when moving in bi-directional text */ |
|||
.CodeMirror div.CodeMirror-secondarycursor { |
|||
border-left: 1px solid silver; |
|||
} |
|||
.cm-fat-cursor .CodeMirror-cursor { |
|||
width: auto; |
|||
border: 0 !important; |
|||
background: #7e7; |
|||
} |
|||
.cm-fat-cursor div.CodeMirror-cursors { |
|||
z-index: 1; |
|||
} |
|||
.cm-fat-cursor .CodeMirror-line::selection, |
|||
.cm-fat-cursor .CodeMirror-line > span::selection, |
|||
.cm-fat-cursor .CodeMirror-line > span > span::selection { background: transparent; } |
|||
.cm-fat-cursor .CodeMirror-line::-moz-selection, |
|||
.cm-fat-cursor .CodeMirror-line > span::-moz-selection, |
|||
.cm-fat-cursor .CodeMirror-line > span > span::-moz-selection { background: transparent; } |
|||
.cm-fat-cursor { caret-color: transparent; } |
|||
@-moz-keyframes blink { |
|||
0% {} |
|||
50% { background-color: transparent; } |
|||
100% {} |
|||
} |
|||
@-webkit-keyframes blink { |
|||
0% {} |
|||
50% { background-color: transparent; } |
|||
100% {} |
|||
} |
|||
@keyframes blink { |
|||
0% {} |
|||
50% { background-color: transparent; } |
|||
100% {} |
|||
} |
|||
|
|||
/* Can style cursor different in overwrite (non-insert) mode */ |
|||
.CodeMirror-overwrite .CodeMirror-cursor {} |
|||
|
|||
.cm-tab { display: inline-block; text-decoration: inherit; } |
|||
|
|||
.CodeMirror-rulers { |
|||
position: absolute; |
|||
left: 0; right: 0; top: -50px; bottom: 0; |
|||
overflow: hidden; |
|||
} |
|||
.CodeMirror-ruler { |
|||
border-left: 1px solid #ccc; |
|||
top: 0; bottom: 0; |
|||
position: absolute; |
|||
} |
|||
|
|||
/* DEFAULT THEME */ |
|||
|
|||
.cm-s-default .cm-header {color: blue;} |
|||
.cm-s-default .cm-quote {color: #090;} |
|||
.cm-negative {color: #d44;} |
|||
.cm-positive {color: #292;} |
|||
.cm-header, .cm-strong {font-weight: bold;} |
|||
.cm-em {font-style: italic;} |
|||
.cm-link {text-decoration: underline;} |
|||
.cm-strikethrough {text-decoration: line-through;} |
|||
|
|||
.cm-s-default .cm-keyword {color: #708;} |
|||
.cm-s-default .cm-atom {color: #219;} |
|||
.cm-s-default .cm-number {color: #164;} |
|||
.cm-s-default .cm-def {color: #00f;} |
|||
.cm-s-default .cm-variable, |
|||
.cm-s-default .cm-punctuation, |
|||
.cm-s-default .cm-property, |
|||
.cm-s-default .cm-operator {} |
|||
.cm-s-default .cm-variable-2 {color: #05a;} |
|||
.cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;} |
|||
.cm-s-default .cm-comment {color: #a50;} |
|||
.cm-s-default .cm-string {color: #a11;} |
|||
.cm-s-default .cm-string-2 {color: #f50;} |
|||
.cm-s-default .cm-meta {color: #555;} |
|||
.cm-s-default .cm-qualifier {color: #555;} |
|||
.cm-s-default .cm-builtin {color: #30a;} |
|||
.cm-s-default .cm-bracket {color: #997;} |
|||
.cm-s-default .cm-tag {color: #170;} |
|||
.cm-s-default .cm-attribute {color: #00c;} |
|||
.cm-s-default .cm-hr {color: #999;} |
|||
.cm-s-default .cm-link {color: #00c;} |
|||
|
|||
.cm-s-default .cm-error {color: #f00;} |
|||
.cm-invalidchar {color: #f00;} |
|||
|
|||
.CodeMirror-composing { border-bottom: 2px solid; } |
|||
|
|||
/* Default styles for common addons */ |
|||
|
|||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;} |
|||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;} |
|||
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); } |
|||
.CodeMirror-activeline-background {background: #e8f2ff;} |
|||
|
|||
/* STOP */ |
|||
|
|||
/* The rest of this file contains styles related to the mechanics of |
|||
the editor. You probably shouldn't touch them. */ |
|||
|
|||
.CodeMirror { |
|||
position: relative; |
|||
overflow: hidden; |
|||
background: white; |
|||
} |
|||
|
|||
.CodeMirror-scroll { |
|||
overflow: scroll !important; /* Things will break if this is overridden */ |
|||
/* 50px is the magic margin used to hide the element's real scrollbars */ |
|||
/* See overflow: hidden in .CodeMirror */ |
|||
margin-bottom: -50px; margin-right: -50px; |
|||
padding-bottom: 50px; |
|||
height: 100%; |
|||
outline: none; /* Prevent dragging from highlighting the element */ |
|||
position: relative; |
|||
z-index: 0; |
|||
} |
|||
.CodeMirror-sizer { |
|||
position: relative; |
|||
border-right: 50px solid transparent; |
|||
} |
|||
|
|||
/* The fake, visible scrollbars. Used to force redraw during scrolling |
|||
before actual scrolling happens, thus preventing shaking and |
|||
flickering artifacts. */ |
|||
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { |
|||
position: absolute; |
|||
z-index: 6; |
|||
display: none; |
|||
outline: none; |
|||
} |
|||
.CodeMirror-vscrollbar { |
|||
right: 0; top: 0; |
|||
overflow-x: hidden; |
|||
overflow-y: scroll; |
|||
} |
|||
.CodeMirror-hscrollbar { |
|||
bottom: 0; left: 0; |
|||
overflow-y: hidden; |
|||
overflow-x: scroll; |
|||
} |
|||
.CodeMirror-scrollbar-filler { |
|||
right: 0; bottom: 0; |
|||
} |
|||
.CodeMirror-gutter-filler { |
|||
left: 0; bottom: 0; |
|||
} |
|||
|
|||
.CodeMirror-gutters { |
|||
position: absolute; left: 0; top: 0; |
|||
min-height: 100%; |
|||
z-index: 3; |
|||
} |
|||
.CodeMirror-gutter { |
|||
white-space: normal; |
|||
height: 100%; |
|||
display: inline-block; |
|||
vertical-align: top; |
|||
margin-bottom: -50px; |
|||
} |
|||
.CodeMirror-gutter-wrapper { |
|||
position: absolute; |
|||
z-index: 4; |
|||
background: none !important; |
|||
border: none !important; |
|||
} |
|||
.CodeMirror-gutter-background { |
|||
position: absolute; |
|||
top: 0; bottom: 0; |
|||
z-index: 4; |
|||
} |
|||
.CodeMirror-gutter-elt { |
|||
position: absolute; |
|||
cursor: default; |
|||
z-index: 4; |
|||
} |
|||
.CodeMirror-gutter-wrapper ::selection { background-color: transparent } |
|||
.CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent } |
|||
|
|||
.CodeMirror-lines { |
|||
cursor: text; |
|||
min-height: 1px; /* prevents collapsing before first draw */ |
|||
} |
|||
.CodeMirror pre.CodeMirror-line, |
|||
.CodeMirror pre.CodeMirror-line-like { |
|||
/* Reset some styles that the rest of the page might have set */ |
|||
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; |
|||
border-width: 0; |
|||
background: transparent; |
|||
font-family: inherit; |
|||
font-size: inherit; |
|||
margin: 0; |
|||
white-space: pre; |
|||
word-wrap: normal; |
|||
line-height: inherit; |
|||
color: inherit; |
|||
z-index: 2; |
|||
position: relative; |
|||
overflow: visible; |
|||
-webkit-tap-highlight-color: transparent; |
|||
-webkit-font-variant-ligatures: contextual; |
|||
font-variant-ligatures: contextual; |
|||
} |
|||
.CodeMirror-wrap pre.CodeMirror-line, |
|||
.CodeMirror-wrap pre.CodeMirror-line-like { |
|||
word-wrap: break-word; |
|||
white-space: pre-wrap; |
|||
word-break: normal; |
|||
} |
|||
|
|||
.CodeMirror-linebackground { |
|||
position: absolute; |
|||
left: 0; right: 0; top: 0; bottom: 0; |
|||
z-index: 0; |
|||
} |
|||
|
|||
.CodeMirror-linewidget { |
|||
position: relative; |
|||
z-index: 2; |
|||
padding: 0.1px; /* Force widget margins to stay inside of the container */ |
|||
} |
|||
|
|||
.CodeMirror-widget {} |
|||
|
|||
.CodeMirror-rtl pre { direction: rtl; } |
|||
|
|||
.CodeMirror-code { |
|||
outline: none; |
|||
} |
|||
|
|||
/* Force content-box sizing for the elements where we expect it */ |
|||
.CodeMirror-scroll, |
|||
.CodeMirror-sizer, |
|||
.CodeMirror-gutter, |
|||
.CodeMirror-gutters, |
|||
.CodeMirror-linenumber { |
|||
-moz-box-sizing: content-box; |
|||
box-sizing: content-box; |
|||
} |
|||
|
|||
.CodeMirror-measure { |
|||
position: absolute; |
|||
width: 100%; |
|||
height: 0; |
|||
overflow: hidden; |
|||
visibility: hidden; |
|||
} |
|||
|
|||
.CodeMirror-cursor { |
|||
position: absolute; |
|||
pointer-events: none; |
|||
} |
|||
.CodeMirror-measure pre { position: static; } |
|||
|
|||
div.CodeMirror-cursors { |
|||
visibility: hidden; |
|||
position: relative; |
|||
z-index: 3; |
|||
} |
|||
div.CodeMirror-dragcursors { |
|||
visibility: visible; |
|||
} |
|||
|
|||
.CodeMirror-focused div.CodeMirror-cursors { |
|||
visibility: visible; |
|||
} |
|||
|
|||
.CodeMirror-selected { background: #d9d9d9; } |
|||
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; } |
|||
.CodeMirror-crosshair { cursor: crosshair; } |
|||
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; } |
|||
.CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; } |
|||
|
|||
.cm-searching { |
|||
background-color: #ffa; |
|||
background-color: rgba(255, 255, 0, .4); |
|||
} |
|||
|
|||
/* Used to force a border model for a node */ |
|||
.cm-force-border { padding-right: .1px; } |
|||
|
|||
@media print { |
|||
/* Hide the cursor when printing */ |
|||
.CodeMirror div.CodeMirror-cursors { |
|||
visibility: hidden; |
|||
} |
|||
} |
|||
|
|||
/* See issue #2901 */ |
|||
.cm-tab-wrap-hack:after { content: ''; } |
|||
|
|||
/* Help users use markselection to safely style text background */ |
|||
span.CodeMirror-selectedtext { background: none; } |
|||
@ -0,0 +1,862 @@ |
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|||
|
|||
(function(mod) { |
|||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|||
mod(require("../../lib/codemirror")); |
|||
else if (typeof define == "function" && define.amd) // AMD
|
|||
define(["../../lib/codemirror.js"], mod); |
|||
else // Plain browser env
|
|||
mod(CodeMirror); |
|||
})(function(CodeMirror) { |
|||
"use strict"; |
|||
|
|||
CodeMirror.defineMode("css", function(config, parserConfig) { |
|||
var inline = parserConfig.inline |
|||
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css"); |
|||
|
|||
var indentUnit = config.indentUnit, |
|||
tokenHooks = parserConfig.tokenHooks, |
|||
documentTypes = parserConfig.documentTypes || {}, |
|||
mediaTypes = parserConfig.mediaTypes || {}, |
|||
mediaFeatures = parserConfig.mediaFeatures || {}, |
|||
mediaValueKeywords = parserConfig.mediaValueKeywords || {}, |
|||
propertyKeywords = parserConfig.propertyKeywords || {}, |
|||
nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {}, |
|||
fontProperties = parserConfig.fontProperties || {}, |
|||
counterDescriptors = parserConfig.counterDescriptors || {}, |
|||
colorKeywords = parserConfig.colorKeywords || {}, |
|||
valueKeywords = parserConfig.valueKeywords || {}, |
|||
allowNested = parserConfig.allowNested, |
|||
lineComment = parserConfig.lineComment, |
|||
supportsAtComponent = parserConfig.supportsAtComponent === true, |
|||
highlightNonStandardPropertyKeywords = config.highlightNonStandardPropertyKeywords !== false; |
|||
|
|||
var type, override; |
|||
function ret(style, tp) { type = tp; return style; } |
|||
|
|||
// Tokenizers
|
|||
|
|||
function tokenBase(stream, state) { |
|||
var ch = stream.next(); |
|||
if (tokenHooks[ch]) { |
|||
var result = tokenHooks[ch](stream, state); |
|||
if (result !== false) return result; |
|||
} |
|||
if (ch == "@") { |
|||
stream.eatWhile(/[\w\\\-]/); |
|||
return ret("def", stream.current()); |
|||
} else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) { |
|||
return ret(null, "compare"); |
|||
} else if (ch == "\"" || ch == "'") { |
|||
state.tokenize = tokenString(ch); |
|||
return state.tokenize(stream, state); |
|||
} else if (ch == "#") { |
|||
stream.eatWhile(/[\w\\\-]/); |
|||
return ret("atom", "hash"); |
|||
} else if (ch == "!") { |
|||
stream.match(/^\s*\w*/); |
|||
return ret("keyword", "important"); |
|||
} else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) { |
|||
stream.eatWhile(/[\w.%]/); |
|||
return ret("number", "unit"); |
|||
} else if (ch === "-") { |
|||
if (/[\d.]/.test(stream.peek())) { |
|||
stream.eatWhile(/[\w.%]/); |
|||
return ret("number", "unit"); |
|||
} else if (stream.match(/^-[\w\\\-]*/)) { |
|||
stream.eatWhile(/[\w\\\-]/); |
|||
if (stream.match(/^\s*:/, false)) |
|||
return ret("variable-2", "variable-definition"); |
|||
return ret("variable-2", "variable"); |
|||
} else if (stream.match(/^\w+-/)) { |
|||
return ret("meta", "meta"); |
|||
} |
|||
} else if (/[,+>*\/]/.test(ch)) { |
|||
return ret(null, "select-op"); |
|||
} else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) { |
|||
return ret("qualifier", "qualifier"); |
|||
} else if (/[:;{}\[\]\(\)]/.test(ch)) { |
|||
return ret(null, ch); |
|||
} else if (stream.match(/^[\w-.]+(?=\()/)) { |
|||
if (/^(url(-prefix)?|domain|regexp)$/i.test(stream.current())) { |
|||
state.tokenize = tokenParenthesized; |
|||
} |
|||
return ret("variable callee", "variable"); |
|||
} else if (/[\w\\\-]/.test(ch)) { |
|||
stream.eatWhile(/[\w\\\-]/); |
|||
return ret("property", "word"); |
|||
} else { |
|||
return ret(null, null); |
|||
} |
|||
} |
|||
|
|||
function tokenString(quote) { |
|||
return function(stream, state) { |
|||
var escaped = false, ch; |
|||
while ((ch = stream.next()) != null) { |
|||
if (ch == quote && !escaped) { |
|||
if (quote == ")") stream.backUp(1); |
|||
break; |
|||
} |
|||
escaped = !escaped && ch == "\\"; |
|||
} |
|||
if (ch == quote || !escaped && quote != ")") state.tokenize = null; |
|||
return ret("string", "string"); |
|||
}; |
|||
} |
|||
|
|||
function tokenParenthesized(stream, state) { |
|||
stream.next(); // Must be '('
|
|||
if (!stream.match(/^\s*[\"\')]/, false)) |
|||
state.tokenize = tokenString(")"); |
|||
else |
|||
state.tokenize = null; |
|||
return ret(null, "("); |
|||
} |
|||
|
|||
// Context management
|
|||
|
|||
function Context(type, indent, prev) { |
|||
this.type = type; |
|||
this.indent = indent; |
|||
this.prev = prev; |
|||
} |
|||
|
|||
function pushContext(state, stream, type, indent) { |
|||
state.context = new Context(type, stream.indentation() + (indent === false ? 0 : indentUnit), state.context); |
|||
return type; |
|||
} |
|||
|
|||
function popContext(state) { |
|||
if (state.context.prev) |
|||
state.context = state.context.prev; |
|||
return state.context.type; |
|||
} |
|||
|
|||
function pass(type, stream, state) { |
|||
return states[state.context.type](type, stream, state); |
|||
} |
|||
function popAndPass(type, stream, state, n) { |
|||
for (var i = n || 1; i > 0; i--) |
|||
state.context = state.context.prev; |
|||
return pass(type, stream, state); |
|||
} |
|||
|
|||
// Parser
|
|||
|
|||
function wordAsValue(stream) { |
|||
var word = stream.current().toLowerCase(); |
|||
if (valueKeywords.hasOwnProperty(word)) |
|||
override = "atom"; |
|||
else if (colorKeywords.hasOwnProperty(word)) |
|||
override = "keyword"; |
|||
else |
|||
override = "variable"; |
|||
} |
|||
|
|||
var states = {}; |
|||
|
|||
states.top = function(type, stream, state) { |
|||
if (type == "{") { |
|||
return pushContext(state, stream, "block"); |
|||
} else if (type == "}" && state.context.prev) { |
|||
return popContext(state); |
|||
} else if (supportsAtComponent && /@component/i.test(type)) { |
|||
return pushContext(state, stream, "atComponentBlock"); |
|||
} else if (/^@(-moz-)?document$/i.test(type)) { |
|||
return pushContext(state, stream, "documentTypes"); |
|||
} else if (/^@(media|supports|(-moz-)?document|import)$/i.test(type)) { |
|||
return pushContext(state, stream, "atBlock"); |
|||
} else if (/^@(font-face|counter-style)/i.test(type)) { |
|||
state.stateArg = type; |
|||
return "restricted_atBlock_before"; |
|||
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/i.test(type)) { |
|||
return "keyframes"; |
|||
} else if (type && type.charAt(0) == "@") { |
|||
return pushContext(state, stream, "at"); |
|||
} else if (type == "hash") { |
|||
override = "builtin"; |
|||
} else if (type == "word") { |
|||
override = "tag"; |
|||
} else if (type == "variable-definition") { |
|||
return "maybeprop"; |
|||
} else if (type == "interpolation") { |
|||
return pushContext(state, stream, "interpolation"); |
|||
} else if (type == ":") { |
|||
return "pseudo"; |
|||
} else if (allowNested && type == "(") { |
|||
return pushContext(state, stream, "parens"); |
|||
} |
|||
return state.context.type; |
|||
}; |
|||
|
|||
states.block = function(type, stream, state) { |
|||
if (type == "word") { |
|||
var word = stream.current().toLowerCase(); |
|||
if (propertyKeywords.hasOwnProperty(word)) { |
|||
override = "property"; |
|||
return "maybeprop"; |
|||
} else if (nonStandardPropertyKeywords.hasOwnProperty(word)) { |
|||
override = highlightNonStandardPropertyKeywords ? "string-2" : "property"; |
|||
return "maybeprop"; |
|||
} else if (allowNested) { |
|||
override = stream.match(/^\s*:(?:\s|$)/, false) ? "property" : "tag"; |
|||
return "block"; |
|||
} else { |
|||
override += " error"; |
|||
return "maybeprop"; |
|||
} |
|||
} else if (type == "meta") { |
|||
return "block"; |
|||
} else if (!allowNested && (type == "hash" || type == "qualifier")) { |
|||
override = "error"; |
|||
return "block"; |
|||
} else { |
|||
return states.top(type, stream, state); |
|||
} |
|||
}; |
|||
|
|||
states.maybeprop = function(type, stream, state) { |
|||
if (type == ":") return pushContext(state, stream, "prop"); |
|||
return pass(type, stream, state); |
|||
}; |
|||
|
|||
states.prop = function(type, stream, state) { |
|||
if (type == ";") return popContext(state); |
|||
if (type == "{" && allowNested) return pushContext(state, stream, "propBlock"); |
|||
if (type == "}" || type == "{") return popAndPass(type, stream, state); |
|||
if (type == "(") return pushContext(state, stream, "parens"); |
|||
|
|||
if (type == "hash" && !/^#([0-9a-fA-f]{3,4}|[0-9a-fA-f]{6}|[0-9a-fA-f]{8})$/.test(stream.current())) { |
|||
override += " error"; |
|||
} else if (type == "word") { |
|||
wordAsValue(stream); |
|||
} else if (type == "interpolation") { |
|||
return pushContext(state, stream, "interpolation"); |
|||
} |
|||
return "prop"; |
|||
}; |
|||
|
|||
states.propBlock = function(type, _stream, state) { |
|||
if (type == "}") return popContext(state); |
|||
if (type == "word") { override = "property"; return "maybeprop"; } |
|||
return state.context.type; |
|||
}; |
|||
|
|||
states.parens = function(type, stream, state) { |
|||
if (type == "{" || type == "}") return popAndPass(type, stream, state); |
|||
if (type == ")") return popContext(state); |
|||
if (type == "(") return pushContext(state, stream, "parens"); |
|||
if (type == "interpolation") return pushContext(state, stream, "interpolation"); |
|||
if (type == "word") wordAsValue(stream); |
|||
return "parens"; |
|||
}; |
|||
|
|||
states.pseudo = function(type, stream, state) { |
|||
if (type == "meta") return "pseudo"; |
|||
|
|||
if (type == "word") { |
|||
override = "variable-3"; |
|||
return state.context.type; |
|||
} |
|||
return pass(type, stream, state); |
|||
}; |
|||
|
|||
states.documentTypes = function(type, stream, state) { |
|||
if (type == "word" && documentTypes.hasOwnProperty(stream.current())) { |
|||
override = "tag"; |
|||
return state.context.type; |
|||
} else { |
|||
return states.atBlock(type, stream, state); |
|||
} |
|||
}; |
|||
|
|||
states.atBlock = function(type, stream, state) { |
|||
if (type == "(") return pushContext(state, stream, "atBlock_parens"); |
|||
if (type == "}" || type == ";") return popAndPass(type, stream, state); |
|||
if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top"); |
|||
|
|||
if (type == "interpolation") return pushContext(state, stream, "interpolation"); |
|||
|
|||
if (type == "word") { |
|||
var word = stream.current().toLowerCase(); |
|||
if (word == "only" || word == "not" || word == "and" || word == "or") |
|||
override = "keyword"; |
|||
else if (mediaTypes.hasOwnProperty(word)) |
|||
override = "attribute"; |
|||
else if (mediaFeatures.hasOwnProperty(word)) |
|||
override = "property"; |
|||
else if (mediaValueKeywords.hasOwnProperty(word)) |
|||
override = "keyword"; |
|||
else if (propertyKeywords.hasOwnProperty(word)) |
|||
override = "property"; |
|||
else if (nonStandardPropertyKeywords.hasOwnProperty(word)) |
|||
override = highlightNonStandardPropertyKeywords ? "string-2" : "property"; |
|||
else if (valueKeywords.hasOwnProperty(word)) |
|||
override = "atom"; |
|||
else if (colorKeywords.hasOwnProperty(word)) |
|||
override = "keyword"; |
|||
else |
|||
override = "error"; |
|||
} |
|||
return state.context.type; |
|||
}; |
|||
|
|||
states.atComponentBlock = function(type, stream, state) { |
|||
if (type == "}") |
|||
return popAndPass(type, stream, state); |
|||
if (type == "{") |
|||
return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top", false); |
|||
if (type == "word") |
|||
override = "error"; |
|||
return state.context.type; |
|||
}; |
|||
|
|||
states.atBlock_parens = function(type, stream, state) { |
|||
if (type == ")") return popContext(state); |
|||
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2); |
|||
return states.atBlock(type, stream, state); |
|||
}; |
|||
|
|||
states.restricted_atBlock_before = function(type, stream, state) { |
|||
if (type == "{") |
|||
return pushContext(state, stream, "restricted_atBlock"); |
|||
if (type == "word" && state.stateArg == "@counter-style") { |
|||
override = "variable"; |
|||
return "restricted_atBlock_before"; |
|||
} |
|||
return pass(type, stream, state); |
|||
}; |
|||
|
|||
states.restricted_atBlock = function(type, stream, state) { |
|||
if (type == "}") { |
|||
state.stateArg = null; |
|||
return popContext(state); |
|||
} |
|||
if (type == "word") { |
|||
if ((state.stateArg == "@font-face" && !fontProperties.hasOwnProperty(stream.current().toLowerCase())) || |
|||
(state.stateArg == "@counter-style" && !counterDescriptors.hasOwnProperty(stream.current().toLowerCase()))) |
|||
override = "error"; |
|||
else |
|||
override = "property"; |
|||
return "maybeprop"; |
|||
} |
|||
return "restricted_atBlock"; |
|||
}; |
|||
|
|||
states.keyframes = function(type, stream, state) { |
|||
if (type == "word") { override = "variable"; return "keyframes"; } |
|||
if (type == "{") return pushContext(state, stream, "top"); |
|||
return pass(type, stream, state); |
|||
}; |
|||
|
|||
states.at = function(type, stream, state) { |
|||
if (type == ";") return popContext(state); |
|||
if (type == "{" || type == "}") return popAndPass(type, stream, state); |
|||
if (type == "word") override = "tag"; |
|||
else if (type == "hash") override = "builtin"; |
|||
return "at"; |
|||
}; |
|||
|
|||
states.interpolation = function(type, stream, state) { |
|||
if (type == "}") return popContext(state); |
|||
if (type == "{" || type == ";") return popAndPass(type, stream, state); |
|||
if (type == "word") override = "variable"; |
|||
else if (type != "variable" && type != "(" && type != ")") override = "error"; |
|||
return "interpolation"; |
|||
}; |
|||
|
|||
return { |
|||
startState: function(base) { |
|||
return {tokenize: null, |
|||
state: inline ? "block" : "top", |
|||
stateArg: null, |
|||
context: new Context(inline ? "block" : "top", base || 0, null)}; |
|||
}, |
|||
|
|||
token: function(stream, state) { |
|||
if (!state.tokenize && stream.eatSpace()) return null; |
|||
var style = (state.tokenize || tokenBase)(stream, state); |
|||
if (style && typeof style == "object") { |
|||
type = style[1]; |
|||
style = style[0]; |
|||
} |
|||
override = style; |
|||
if (type != "comment") |
|||
state.state = states[state.state](type, stream, state); |
|||
return override; |
|||
}, |
|||
|
|||
indent: function(state, textAfter) { |
|||
var cx = state.context, ch = textAfter && textAfter.charAt(0); |
|||
var indent = cx.indent; |
|||
if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev; |
|||
if (cx.prev) { |
|||
if (ch == "}" && (cx.type == "block" || cx.type == "top" || |
|||
cx.type == "interpolation" || cx.type == "restricted_atBlock")) { |
|||
// Resume indentation from parent context.
|
|||
cx = cx.prev; |
|||
indent = cx.indent; |
|||
} else if (ch == ")" && (cx.type == "parens" || cx.type == "atBlock_parens") || |
|||
ch == "{" && (cx.type == "at" || cx.type == "atBlock")) { |
|||
// Dedent relative to current context.
|
|||
indent = Math.max(0, cx.indent - indentUnit); |
|||
} |
|||
} |
|||
return indent; |
|||
}, |
|||
|
|||
electricChars: "}", |
|||
blockCommentStart: "/*", |
|||
blockCommentEnd: "*/", |
|||
blockCommentContinue: " * ", |
|||
lineComment: lineComment, |
|||
fold: "brace" |
|||
}; |
|||
}); |
|||
|
|||
function keySet(array) { |
|||
var keys = {}; |
|||
for (var i = 0; i < array.length; ++i) { |
|||
keys[array[i].toLowerCase()] = true; |
|||
} |
|||
return keys; |
|||
} |
|||
|
|||
var documentTypes_ = [ |
|||
"domain", "regexp", "url", "url-prefix" |
|||
], documentTypes = keySet(documentTypes_); |
|||
|
|||
var mediaTypes_ = [ |
|||
"all", "aural", "braille", "handheld", "print", "projection", "screen", |
|||
"tty", "tv", "embossed" |
|||
], mediaTypes = keySet(mediaTypes_); |
|||
|
|||
var mediaFeatures_ = [ |
|||
"width", "min-width", "max-width", "height", "min-height", "max-height", |
|||
"device-width", "min-device-width", "max-device-width", "device-height", |
|||
"min-device-height", "max-device-height", "aspect-ratio", |
|||
"min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio", |
|||
"min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color", |
|||
"max-color", "color-index", "min-color-index", "max-color-index", |
|||
"monochrome", "min-monochrome", "max-monochrome", "resolution", |
|||
"min-resolution", "max-resolution", "scan", "grid", "orientation", |
|||
"device-pixel-ratio", "min-device-pixel-ratio", "max-device-pixel-ratio", |
|||
"pointer", "any-pointer", "hover", "any-hover", "prefers-color-scheme", |
|||
"dynamic-range", "video-dynamic-range" |
|||
], mediaFeatures = keySet(mediaFeatures_); |
|||
|
|||
var mediaValueKeywords_ = [ |
|||
"landscape", "portrait", "none", "coarse", "fine", "on-demand", "hover", |
|||
"interlace", "progressive", |
|||
"dark", "light", |
|||
"standard", "high" |
|||
], mediaValueKeywords = keySet(mediaValueKeywords_); |
|||
|
|||
var propertyKeywords_ = [ |
|||
"align-content", "align-items", "align-self", "alignment-adjust", |
|||
"alignment-baseline", "all", "anchor-point", "animation", "animation-delay", |
|||
"animation-direction", "animation-duration", "animation-fill-mode", |
|||
"animation-iteration-count", "animation-name", "animation-play-state", |
|||
"animation-timing-function", "appearance", "azimuth", "backdrop-filter", |
|||
"backface-visibility", "background", "background-attachment", |
|||
"background-blend-mode", "background-clip", "background-color", |
|||
"background-image", "background-origin", "background-position", |
|||
"background-position-x", "background-position-y", "background-repeat", |
|||
"background-size", "baseline-shift", "binding", "bleed", "block-size", |
|||
"bookmark-label", "bookmark-level", "bookmark-state", "bookmark-target", |
|||
"border", "border-bottom", "border-bottom-color", "border-bottom-left-radius", |
|||
"border-bottom-right-radius", "border-bottom-style", "border-bottom-width", |
|||
"border-collapse", "border-color", "border-image", "border-image-outset", |
|||
"border-image-repeat", "border-image-slice", "border-image-source", |
|||
"border-image-width", "border-left", "border-left-color", "border-left-style", |
|||
"border-left-width", "border-radius", "border-right", "border-right-color", |
|||
"border-right-style", "border-right-width", "border-spacing", "border-style", |
|||
"border-top", "border-top-color", "border-top-left-radius", |
|||
"border-top-right-radius", "border-top-style", "border-top-width", |
|||
"border-width", "bottom", "box-decoration-break", "box-shadow", "box-sizing", |
|||
"break-after", "break-before", "break-inside", "caption-side", "caret-color", |
|||
"clear", "clip", "color", "color-profile", "column-count", "column-fill", |
|||
"column-gap", "column-rule", "column-rule-color", "column-rule-style", |
|||
"column-rule-width", "column-span", "column-width", "columns", "contain", |
|||
"content", "counter-increment", "counter-reset", "crop", "cue", "cue-after", |
|||
"cue-before", "cursor", "direction", "display", "dominant-baseline", |
|||
"drop-initial-after-adjust", "drop-initial-after-align", |
|||
"drop-initial-before-adjust", "drop-initial-before-align", "drop-initial-size", |
|||
"drop-initial-value", "elevation", "empty-cells", "fit", "fit-content", "fit-position", |
|||
"flex", "flex-basis", "flex-direction", "flex-flow", "flex-grow", |
|||
"flex-shrink", "flex-wrap", "float", "float-offset", "flow-from", "flow-into", |
|||
"font", "font-family", "font-feature-settings", "font-kerning", |
|||
"font-language-override", "font-optical-sizing", "font-size", |
|||
"font-size-adjust", "font-stretch", "font-style", "font-synthesis", |
|||
"font-variant", "font-variant-alternates", "font-variant-caps", |
|||
"font-variant-east-asian", "font-variant-ligatures", "font-variant-numeric", |
|||
"font-variant-position", "font-variation-settings", "font-weight", "gap", |
|||
"grid", "grid-area", "grid-auto-columns", "grid-auto-flow", "grid-auto-rows", |
|||
"grid-column", "grid-column-end", "grid-column-gap", "grid-column-start", |
|||
"grid-gap", "grid-row", "grid-row-end", "grid-row-gap", "grid-row-start", |
|||
"grid-template", "grid-template-areas", "grid-template-columns", |
|||
"grid-template-rows", "hanging-punctuation", "height", "hyphens", "icon", |
|||
"image-orientation", "image-rendering", "image-resolution", "inline-box-align", |
|||
"inset", "inset-block", "inset-block-end", "inset-block-start", "inset-inline", |
|||
"inset-inline-end", "inset-inline-start", "isolation", "justify-content", |
|||
"justify-items", "justify-self", "left", "letter-spacing", "line-break", |
|||
"line-height", "line-height-step", "line-stacking", "line-stacking-ruby", |
|||
"line-stacking-shift", "line-stacking-strategy", "list-style", |
|||
"list-style-image", "list-style-position", "list-style-type", "margin", |
|||
"margin-bottom", "margin-left", "margin-right", "margin-top", "marks", |
|||
"marquee-direction", "marquee-loop", "marquee-play-count", "marquee-speed", |
|||
"marquee-style", "mask-clip", "mask-composite", "mask-image", "mask-mode", |
|||
"mask-origin", "mask-position", "mask-repeat", "mask-size","mask-type", |
|||
"max-block-size", "max-height", "max-inline-size", |
|||
"max-width", "min-block-size", "min-height", "min-inline-size", "min-width", |
|||
"mix-blend-mode", "move-to", "nav-down", "nav-index", "nav-left", "nav-right", |
|||
"nav-up", "object-fit", "object-position", "offset", "offset-anchor", |
|||
"offset-distance", "offset-path", "offset-position", "offset-rotate", |
|||
"opacity", "order", "orphans", "outline", "outline-color", "outline-offset", |
|||
"outline-style", "outline-width", "overflow", "overflow-style", |
|||
"overflow-wrap", "overflow-x", "overflow-y", "padding", "padding-bottom", |
|||
"padding-left", "padding-right", "padding-top", "page", "page-break-after", |
|||
"page-break-before", "page-break-inside", "page-policy", "pause", |
|||
"pause-after", "pause-before", "perspective", "perspective-origin", "pitch", |
|||
"pitch-range", "place-content", "place-items", "place-self", "play-during", |
|||
"position", "presentation-level", "punctuation-trim", "quotes", |
|||
"region-break-after", "region-break-before", "region-break-inside", |
|||
"region-fragment", "rendering-intent", "resize", "rest", "rest-after", |
|||
"rest-before", "richness", "right", "rotate", "rotation", "rotation-point", |
|||
"row-gap", "ruby-align", "ruby-overhang", "ruby-position", "ruby-span", |
|||
"scale", "scroll-behavior", "scroll-margin", "scroll-margin-block", |
|||
"scroll-margin-block-end", "scroll-margin-block-start", "scroll-margin-bottom", |
|||
"scroll-margin-inline", "scroll-margin-inline-end", |
|||
"scroll-margin-inline-start", "scroll-margin-left", "scroll-margin-right", |
|||
"scroll-margin-top", "scroll-padding", "scroll-padding-block", |
|||
"scroll-padding-block-end", "scroll-padding-block-start", |
|||
"scroll-padding-bottom", "scroll-padding-inline", "scroll-padding-inline-end", |
|||
"scroll-padding-inline-start", "scroll-padding-left", "scroll-padding-right", |
|||
"scroll-padding-top", "scroll-snap-align", "scroll-snap-type", |
|||
"shape-image-threshold", "shape-inside", "shape-margin", "shape-outside", |
|||
"size", "speak", "speak-as", "speak-header", "speak-numeral", |
|||
"speak-punctuation", "speech-rate", "stress", "string-set", "tab-size", |
|||
"table-layout", "target", "target-name", "target-new", "target-position", |
|||
"text-align", "text-align-last", "text-combine-upright", "text-decoration", |
|||
"text-decoration-color", "text-decoration-line", "text-decoration-skip", |
|||
"text-decoration-skip-ink", "text-decoration-style", "text-emphasis", |
|||
"text-emphasis-color", "text-emphasis-position", "text-emphasis-style", |
|||
"text-height", "text-indent", "text-justify", "text-orientation", |
|||
"text-outline", "text-overflow", "text-rendering", "text-shadow", |
|||
"text-size-adjust", "text-space-collapse", "text-transform", |
|||
"text-underline-position", "text-wrap", "top", "touch-action", "transform", "transform-origin", |
|||
"transform-style", "transition", "transition-delay", "transition-duration", |
|||
"transition-property", "transition-timing-function", "translate", |
|||
"unicode-bidi", "user-select", "vertical-align", "visibility", "voice-balance", |
|||
"voice-duration", "voice-family", "voice-pitch", "voice-range", "voice-rate", |
|||
"voice-stress", "voice-volume", "volume", "white-space", "widows", "width", |
|||
"will-change", "word-break", "word-spacing", "word-wrap", "writing-mode", "z-index", |
|||
// SVG-specific
|
|||
"clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color", |
|||
"flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events", |
|||
"color-interpolation", "color-interpolation-filters", |
|||
"color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering", |
|||
"marker", "marker-end", "marker-mid", "marker-start", "paint-order", "shape-rendering", "stroke", |
|||
"stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", |
|||
"stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering", |
|||
"baseline-shift", "dominant-baseline", "glyph-orientation-horizontal", |
|||
"glyph-orientation-vertical", "text-anchor", "writing-mode", |
|||
], propertyKeywords = keySet(propertyKeywords_); |
|||
|
|||
var nonStandardPropertyKeywords_ = [ |
|||
"accent-color", "aspect-ratio", "border-block", "border-block-color", "border-block-end", |
|||
"border-block-end-color", "border-block-end-style", "border-block-end-width", |
|||
"border-block-start", "border-block-start-color", "border-block-start-style", |
|||
"border-block-start-width", "border-block-style", "border-block-width", |
|||
"border-inline", "border-inline-color", "border-inline-end", |
|||
"border-inline-end-color", "border-inline-end-style", |
|||
"border-inline-end-width", "border-inline-start", "border-inline-start-color", |
|||
"border-inline-start-style", "border-inline-start-width", |
|||
"border-inline-style", "border-inline-width", "content-visibility", "margin-block", |
|||
"margin-block-end", "margin-block-start", "margin-inline", "margin-inline-end", |
|||
"margin-inline-start", "overflow-anchor", "overscroll-behavior", "padding-block", "padding-block-end", |
|||
"padding-block-start", "padding-inline", "padding-inline-end", |
|||
"padding-inline-start", "scroll-snap-stop", "scrollbar-3d-light-color", |
|||
"scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color", |
|||
"scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color", |
|||
"scrollbar-track-color", "searchfield-cancel-button", "searchfield-decoration", |
|||
"searchfield-results-button", "searchfield-results-decoration", "shape-inside", "zoom" |
|||
], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_); |
|||
|
|||
var fontProperties_ = [ |
|||
"font-display", "font-family", "src", "unicode-range", "font-variant", |
|||
"font-feature-settings", "font-stretch", "font-weight", "font-style" |
|||
], fontProperties = keySet(fontProperties_); |
|||
|
|||
var counterDescriptors_ = [ |
|||
"additive-symbols", "fallback", "negative", "pad", "prefix", "range", |
|||
"speak-as", "suffix", "symbols", "system" |
|||
], counterDescriptors = keySet(counterDescriptors_); |
|||
|
|||
var colorKeywords_ = [ |
|||
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", |
|||
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", |
|||
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue", |
|||
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", |
|||
"darkgray", "darkgreen", "darkgrey", "darkkhaki", "darkmagenta", "darkolivegreen", |
|||
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", |
|||
"darkslateblue", "darkslategray", "darkslategrey", "darkturquoise", "darkviolet", |
|||
"deeppink", "deepskyblue", "dimgray", "dimgrey", "dodgerblue", "firebrick", |
|||
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", |
|||
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", |
|||
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", |
|||
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", |
|||
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink", |
|||
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey", |
|||
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", |
|||
"maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", |
|||
"mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", |
|||
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", |
|||
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered", |
|||
"orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", |
|||
"papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", |
|||
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", |
|||
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", |
|||
"slateblue", "slategray", "slategrey", "snow", "springgreen", "steelblue", "tan", |
|||
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", |
|||
"whitesmoke", "yellow", "yellowgreen" |
|||
], colorKeywords = keySet(colorKeywords_); |
|||
|
|||
var valueKeywords_ = [ |
|||
"above", "absolute", "activeborder", "additive", "activecaption", "afar", |
|||
"after-white-space", "ahead", "alias", "all", "all-scroll", "alphabetic", "alternate", |
|||
"always", "amharic", "amharic-abegede", "antialiased", "appworkspace", |
|||
"arabic-indic", "armenian", "asterisks", "attr", "auto", "auto-flow", "avoid", "avoid-column", "avoid-page", |
|||
"avoid-region", "axis-pan", "background", "backwards", "baseline", "below", "bidi-override", "binary", |
|||
"bengali", "blink", "block", "block-axis", "blur", "bold", "bolder", "border", "border-box", |
|||
"both", "bottom", "break", "break-all", "break-word", "brightness", "bullets", "button", |
|||
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "calc", "cambodian", |
|||
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret", |
|||
"cell", "center", "checkbox", "circle", "cjk-decimal", "cjk-earthly-branch", |
|||
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote", |
|||
"col-resize", "collapse", "color", "color-burn", "color-dodge", "column", "column-reverse", |
|||
"compact", "condensed", "conic-gradient", "contain", "content", "contents", |
|||
"content-box", "context-menu", "continuous", "contrast", "copy", "counter", "counters", "cover", "crop", |
|||
"cross", "crosshair", "cubic-bezier", "currentcolor", "cursive", "cyclic", "darken", "dashed", "decimal", |
|||
"decimal-leading-zero", "default", "default-button", "dense", "destination-atop", |
|||
"destination-in", "destination-out", "destination-over", "devanagari", "difference", |
|||
"disc", "discard", "disclosure-closed", "disclosure-open", "document", |
|||
"dot-dash", "dot-dot-dash", |
|||
"dotted", "double", "down", "drop-shadow", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out", |
|||
"element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede", |
|||
"ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er", |
|||
"ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er", |
|||
"ethiopic-halehame-aa-et", "ethiopic-halehame-am-et", |
|||
"ethiopic-halehame-gez", "ethiopic-halehame-om-et", |
|||
"ethiopic-halehame-sid-et", "ethiopic-halehame-so-et", |
|||
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et", "ethiopic-halehame-tig", |
|||
"ethiopic-numeric", "ew-resize", "exclusion", "expanded", "extends", "extra-condensed", |
|||
"extra-expanded", "fantasy", "fast", "fill", "fill-box", "fixed", "flat", "flex", "flex-end", "flex-start", "footnotes", |
|||
"forwards", "from", "geometricPrecision", "georgian", "grayscale", "graytext", "grid", "groove", |
|||
"gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hard-light", "hebrew", |
|||
"help", "hidden", "hide", "higher", "highlight", "highlighttext", |
|||
"hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "hue", "hue-rotate", "icon", "ignore", |
|||
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite", |
|||
"infobackground", "infotext", "inherit", "initial", "inline", "inline-axis", |
|||
"inline-block", "inline-flex", "inline-grid", "inline-table", "inset", "inside", "intrinsic", "invert", |
|||
"italic", "japanese-formal", "japanese-informal", "justify", "kannada", |
|||
"katakana", "katakana-iroha", "keep-all", "khmer", |
|||
"korean-hangul-formal", "korean-hanja-formal", "korean-hanja-informal", |
|||
"landscape", "lao", "large", "larger", "left", "level", "lighter", "lighten", |
|||
"line-through", "linear", "linear-gradient", "lines", "list-item", "listbox", "listitem", |
|||
"local", "logical", "loud", "lower", "lower-alpha", "lower-armenian", |
|||
"lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian", |
|||
"lower-roman", "lowercase", "ltr", "luminosity", "malayalam", "manipulation", "match", "matrix", "matrix3d", |
|||
"media-play-button", "media-slider", "media-sliderthumb", |
|||
"media-volume-slider", "media-volume-sliderthumb", "medium", |
|||
"menu", "menulist", "menulist-button", |
|||
"menutext", "message-box", "middle", "min-intrinsic", |
|||
"mix", "mongolian", "monospace", "move", "multiple", "multiple_mask_images", "multiply", "myanmar", "n-resize", |
|||
"narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop", |
|||
"no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap", |
|||
"ns-resize", "numbers", "numeric", "nw-resize", "nwse-resize", "oblique", "octal", "opacity", "open-quote", |
|||
"optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset", |
|||
"outside", "outside-shape", "overlay", "overline", "padding", "padding-box", |
|||
"painted", "page", "paused", "persian", "perspective", "pinch-zoom", "plus-darker", "plus-lighter", |
|||
"pointer", "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", |
|||
"progress", "push-button", "radial-gradient", "radio", "read-only", |
|||
"read-write", "read-write-plaintext-only", "rectangle", "region", |
|||
"relative", "repeat", "repeating-linear-gradient", "repeating-radial-gradient", |
|||
"repeating-conic-gradient", "repeat-x", "repeat-y", "reset", "reverse", |
|||
"rgb", "rgba", "ridge", "right", "rotate", "rotate3d", "rotateX", "rotateY", |
|||
"rotateZ", "round", "row", "row-resize", "row-reverse", "rtl", "run-in", "running", |
|||
"s-resize", "sans-serif", "saturate", "saturation", "scale", "scale3d", "scaleX", "scaleY", "scaleZ", "screen", |
|||
"scroll", "scrollbar", "scroll-position", "se-resize", "searchfield", |
|||
"searchfield-cancel-button", "searchfield-decoration", |
|||
"searchfield-results-button", "searchfield-results-decoration", "self-start", "self-end", |
|||
"semi-condensed", "semi-expanded", "separate", "sepia", "serif", "show", "sidama", |
|||
"simp-chinese-formal", "simp-chinese-informal", "single", |
|||
"skew", "skewX", "skewY", "skip-white-space", "slide", "slider-horizontal", |
|||
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow", |
|||
"small", "small-caps", "small-caption", "smaller", "soft-light", "solid", "somali", |
|||
"source-atop", "source-in", "source-out", "source-over", "space", "space-around", "space-between", "space-evenly", "spell-out", "square", |
|||
"square-button", "start", "static", "status-bar", "stretch", "stroke", "stroke-box", "sub", |
|||
"subpixel-antialiased", "svg_masks", "super", "sw-resize", "symbolic", "symbols", "system-ui", "table", |
|||
"table-caption", "table-cell", "table-column", "table-column-group", |
|||
"table-footer-group", "table-header-group", "table-row", "table-row-group", |
|||
"tamil", |
|||
"telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai", |
|||
"thick", "thin", "threeddarkshadow", "threedface", "threedhighlight", |
|||
"threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er", |
|||
"tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top", |
|||
"trad-chinese-formal", "trad-chinese-informal", "transform", |
|||
"translate", "translate3d", "translateX", "translateY", "translateZ", |
|||
"transparent", "ultra-condensed", "ultra-expanded", "underline", "unidirectional-pan", "unset", "up", |
|||
"upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal", |
|||
"upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url", |
|||
"var", "vertical", "vertical-text", "view-box", "visible", "visibleFill", "visiblePainted", |
|||
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider", |
|||
"window", "windowframe", "windowtext", "words", "wrap", "wrap-reverse", "x-large", "x-small", "xor", |
|||
"xx-large", "xx-small" |
|||
], valueKeywords = keySet(valueKeywords_); |
|||
|
|||
var allWords = documentTypes_.concat(mediaTypes_).concat(mediaFeatures_).concat(mediaValueKeywords_) |
|||
.concat(propertyKeywords_).concat(nonStandardPropertyKeywords_).concat(colorKeywords_) |
|||
.concat(valueKeywords_); |
|||
CodeMirror.registerHelper("hintWords", "css", allWords); |
|||
|
|||
function tokenCComment(stream, state) { |
|||
var maybeEnd = false, ch; |
|||
while ((ch = stream.next()) != null) { |
|||
if (maybeEnd && ch == "/") { |
|||
state.tokenize = null; |
|||
break; |
|||
} |
|||
maybeEnd = (ch == "*"); |
|||
} |
|||
return ["comment", "comment"]; |
|||
} |
|||
|
|||
CodeMirror.defineMIME("text/css", { |
|||
documentTypes: documentTypes, |
|||
mediaTypes: mediaTypes, |
|||
mediaFeatures: mediaFeatures, |
|||
mediaValueKeywords: mediaValueKeywords, |
|||
propertyKeywords: propertyKeywords, |
|||
nonStandardPropertyKeywords: nonStandardPropertyKeywords, |
|||
fontProperties: fontProperties, |
|||
counterDescriptors: counterDescriptors, |
|||
colorKeywords: colorKeywords, |
|||
valueKeywords: valueKeywords, |
|||
tokenHooks: { |
|||
"/": function(stream, state) { |
|||
if (!stream.eat("*")) return false; |
|||
state.tokenize = tokenCComment; |
|||
return tokenCComment(stream, state); |
|||
} |
|||
}, |
|||
name: "css" |
|||
}); |
|||
|
|||
CodeMirror.defineMIME("text/x-scss", { |
|||
mediaTypes: mediaTypes, |
|||
mediaFeatures: mediaFeatures, |
|||
mediaValueKeywords: mediaValueKeywords, |
|||
propertyKeywords: propertyKeywords, |
|||
nonStandardPropertyKeywords: nonStandardPropertyKeywords, |
|||
colorKeywords: colorKeywords, |
|||
valueKeywords: valueKeywords, |
|||
fontProperties: fontProperties, |
|||
allowNested: true, |
|||
lineComment: "//", |
|||
tokenHooks: { |
|||
"/": function(stream, state) { |
|||
if (stream.eat("/")) { |
|||
stream.skipToEnd(); |
|||
return ["comment", "comment"]; |
|||
} else if (stream.eat("*")) { |
|||
state.tokenize = tokenCComment; |
|||
return tokenCComment(stream, state); |
|||
} else { |
|||
return ["operator", "operator"]; |
|||
} |
|||
}, |
|||
":": function(stream) { |
|||
if (stream.match(/^\s*\{/, false)) |
|||
return [null, null] |
|||
return false; |
|||
}, |
|||
"$": function(stream) { |
|||
stream.match(/^[\w-]+/); |
|||
if (stream.match(/^\s*:/, false)) |
|||
return ["variable-2", "variable-definition"]; |
|||
return ["variable-2", "variable"]; |
|||
}, |
|||
"#": function(stream) { |
|||
if (!stream.eat("{")) return false; |
|||
return [null, "interpolation"]; |
|||
} |
|||
}, |
|||
name: "css", |
|||
helperType: "scss" |
|||
}); |
|||
|
|||
CodeMirror.defineMIME("text/x-less", { |
|||
mediaTypes: mediaTypes, |
|||
mediaFeatures: mediaFeatures, |
|||
mediaValueKeywords: mediaValueKeywords, |
|||
propertyKeywords: propertyKeywords, |
|||
nonStandardPropertyKeywords: nonStandardPropertyKeywords, |
|||
colorKeywords: colorKeywords, |
|||
valueKeywords: valueKeywords, |
|||
fontProperties: fontProperties, |
|||
allowNested: true, |
|||
lineComment: "//", |
|||
tokenHooks: { |
|||
"/": function(stream, state) { |
|||
if (stream.eat("/")) { |
|||
stream.skipToEnd(); |
|||
return ["comment", "comment"]; |
|||
} else if (stream.eat("*")) { |
|||
state.tokenize = tokenCComment; |
|||
return tokenCComment(stream, state); |
|||
} else { |
|||
return ["operator", "operator"]; |
|||
} |
|||
}, |
|||
"@": function(stream) { |
|||
if (stream.eat("{")) return [null, "interpolation"]; |
|||
if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/i, false)) return false; |
|||
stream.eatWhile(/[\w\\\-]/); |
|||
if (stream.match(/^\s*:/, false)) |
|||
return ["variable-2", "variable-definition"]; |
|||
return ["variable-2", "variable"]; |
|||
}, |
|||
"&": function() { |
|||
return ["atom", "atom"]; |
|||
} |
|||
}, |
|||
name: "css", |
|||
helperType: "less" |
|||
}); |
|||
|
|||
CodeMirror.defineMIME("text/x-gss", { |
|||
documentTypes: documentTypes, |
|||
mediaTypes: mediaTypes, |
|||
mediaFeatures: mediaFeatures, |
|||
propertyKeywords: propertyKeywords, |
|||
nonStandardPropertyKeywords: nonStandardPropertyKeywords, |
|||
fontProperties: fontProperties, |
|||
counterDescriptors: counterDescriptors, |
|||
colorKeywords: colorKeywords, |
|||
valueKeywords: valueKeywords, |
|||
supportsAtComponent: true, |
|||
tokenHooks: { |
|||
"/": function(stream, state) { |
|||
if (!stream.eat("*")) return false; |
|||
state.tokenize = tokenCComment; |
|||
return tokenCComment(stream, state); |
|||
} |
|||
}, |
|||
name: "css", |
|||
helperType: "gss" |
|||
}); |
|||
|
|||
}); |
|||
@ -0,0 +1,153 @@ |
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|||
|
|||
(function(mod) { |
|||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|||
mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css")); |
|||
else if (typeof define == "function" && define.amd) // AMD
|
|||
define(["../../lib/codemirror.js", "../xml/xml.js", "../javascript/javascript.js", "../css/css.js"], mod); |
|||
else // Plain browser env
|
|||
mod(CodeMirror); |
|||
})(function(CodeMirror) { |
|||
"use strict"; |
|||
|
|||
var defaultTags = { |
|||
script: [ |
|||
["lang", /(javascript|babel)/i, "javascript"], |
|||
["type", /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i, "javascript"], |
|||
["type", /./, "text/plain"], |
|||
[null, null, "javascript"] |
|||
], |
|||
style: [ |
|||
["lang", /^css$/i, "css"], |
|||
["type", /^(text\/)?(x-)?(stylesheet|css)$/i, "css"], |
|||
["type", /./, "text/plain"], |
|||
[null, null, "css"] |
|||
] |
|||
}; |
|||
|
|||
function maybeBackup(stream, pat, style) { |
|||
var cur = stream.current(), close = cur.search(pat); |
|||
if (close > -1) { |
|||
stream.backUp(cur.length - close); |
|||
} else if (cur.match(/<\/?$/)) { |
|||
stream.backUp(cur.length); |
|||
if (!stream.match(pat, false)) stream.match(cur); |
|||
} |
|||
return style; |
|||
} |
|||
|
|||
var attrRegexpCache = {}; |
|||
function getAttrRegexp(attr) { |
|||
var regexp = attrRegexpCache[attr]; |
|||
if (regexp) return regexp; |
|||
return attrRegexpCache[attr] = new RegExp("\\s+" + attr + "\\s*=\\s*('|\")?([^'\"]+)('|\")?\\s*"); |
|||
} |
|||
|
|||
function getAttrValue(text, attr) { |
|||
var match = text.match(getAttrRegexp(attr)) |
|||
return match ? /^\s*(.*?)\s*$/.exec(match[2])[1] : "" |
|||
} |
|||
|
|||
function getTagRegexp(tagName, anchored) { |
|||
return new RegExp((anchored ? "^" : "") + "<\/\\s*" + tagName + "\\s*>", "i"); |
|||
} |
|||
|
|||
function addTags(from, to) { |
|||
for (var tag in from) { |
|||
var dest = to[tag] || (to[tag] = []); |
|||
var source = from[tag]; |
|||
for (var i = source.length - 1; i >= 0; i--) |
|||
dest.unshift(source[i]) |
|||
} |
|||
} |
|||
|
|||
function findMatchingMode(tagInfo, tagText) { |
|||
for (var i = 0; i < tagInfo.length; i++) { |
|||
var spec = tagInfo[i]; |
|||
if (!spec[0] || spec[1].test(getAttrValue(tagText, spec[0]))) return spec[2]; |
|||
} |
|||
} |
|||
|
|||
CodeMirror.defineMode("htmlmixed", function (config, parserConfig) { |
|||
var htmlMode = CodeMirror.getMode(config, { |
|||
name: "xml", |
|||
htmlMode: true, |
|||
multilineTagIndentFactor: parserConfig.multilineTagIndentFactor, |
|||
multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag, |
|||
allowMissingTagName: parserConfig.allowMissingTagName, |
|||
}); |
|||
|
|||
var tags = {}; |
|||
var configTags = parserConfig && parserConfig.tags, configScript = parserConfig && parserConfig.scriptTypes; |
|||
addTags(defaultTags, tags); |
|||
if (configTags) addTags(configTags, tags); |
|||
if (configScript) for (var i = configScript.length - 1; i >= 0; i--) |
|||
tags.script.unshift(["type", configScript[i].matches, configScript[i].mode]) |
|||
|
|||
function html(stream, state) { |
|||
var style = htmlMode.token(stream, state.htmlState), tag = /\btag\b/.test(style), tagName |
|||
if (tag && !/[<>\s\/]/.test(stream.current()) && |
|||
(tagName = state.htmlState.tagName && state.htmlState.tagName.toLowerCase()) && |
|||
tags.hasOwnProperty(tagName)) { |
|||
state.inTag = tagName + " " |
|||
} else if (state.inTag && tag && />$/.test(stream.current())) { |
|||
var inTag = /^([\S]+) (.*)/.exec(state.inTag) |
|||
state.inTag = null |
|||
var modeSpec = stream.current() == ">" && findMatchingMode(tags[inTag[1]], inTag[2]) |
|||
var mode = CodeMirror.getMode(config, modeSpec) |
|||
var endTagA = getTagRegexp(inTag[1], true), endTag = getTagRegexp(inTag[1], false); |
|||
state.token = function (stream, state) { |
|||
if (stream.match(endTagA, false)) { |
|||
state.token = html; |
|||
state.localState = state.localMode = null; |
|||
return null; |
|||
} |
|||
return maybeBackup(stream, endTag, state.localMode.token(stream, state.localState)); |
|||
}; |
|||
state.localMode = mode; |
|||
state.localState = CodeMirror.startState(mode, htmlMode.indent(state.htmlState, "", "")); |
|||
} else if (state.inTag) { |
|||
state.inTag += stream.current() |
|||
if (stream.eol()) state.inTag += " " |
|||
} |
|||
return style; |
|||
}; |
|||
|
|||
return { |
|||
startState: function () { |
|||
var state = CodeMirror.startState(htmlMode); |
|||
return {token: html, inTag: null, localMode: null, localState: null, htmlState: state}; |
|||
}, |
|||
|
|||
copyState: function (state) { |
|||
var local; |
|||
if (state.localState) { |
|||
local = CodeMirror.copyState(state.localMode, state.localState); |
|||
} |
|||
return {token: state.token, inTag: state.inTag, |
|||
localMode: state.localMode, localState: local, |
|||
htmlState: CodeMirror.copyState(htmlMode, state.htmlState)}; |
|||
}, |
|||
|
|||
token: function (stream, state) { |
|||
return state.token(stream, state); |
|||
}, |
|||
|
|||
indent: function (state, textAfter, line) { |
|||
if (!state.localMode || /^\s*<\//.test(textAfter)) |
|||
return htmlMode.indent(state.htmlState, textAfter, line); |
|||
else if (state.localMode.indent) |
|||
return state.localMode.indent(state.localState, textAfter, line); |
|||
else |
|||
return CodeMirror.Pass; |
|||
}, |
|||
|
|||
innerMode: function (state) { |
|||
return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode}; |
|||
} |
|||
}; |
|||
}, "xml", "javascript", "css"); |
|||
|
|||
CodeMirror.defineMIME("text/html", "htmlmixed"); |
|||
}); |
|||
@ -0,0 +1,960 @@ |
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|||
|
|||
(function(mod) { |
|||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|||
mod(require("../../lib/codemirror")); |
|||
else if (typeof define == "function" && define.amd) // AMD
|
|||
define(["../../lib/codemirror.js"], mod); |
|||
else // Plain browser env
|
|||
mod(CodeMirror); |
|||
})(function(CodeMirror) { |
|||
"use strict"; |
|||
|
|||
CodeMirror.defineMode("javascript", function(config, parserConfig) { |
|||
var indentUnit = config.indentUnit; |
|||
var statementIndent = parserConfig.statementIndent; |
|||
var jsonldMode = parserConfig.jsonld; |
|||
var jsonMode = parserConfig.json || jsonldMode; |
|||
var trackScope = parserConfig.trackScope !== false |
|||
var isTS = parserConfig.typescript; |
|||
var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/; |
|||
|
|||
// Tokenizer
|
|||
|
|||
var keywords = function(){ |
|||
function kw(type) {return {type: type, style: "keyword"};} |
|||
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c"), D = kw("keyword d"); |
|||
var operator = kw("operator"), atom = {type: "atom", style: "atom"}; |
|||
|
|||
return { |
|||
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B, |
|||
"return": D, "break": D, "continue": D, "new": kw("new"), "delete": C, "void": C, "throw": C, |
|||
"debugger": kw("debugger"), "var": kw("var"), "const": kw("var"), "let": kw("var"), |
|||
"function": kw("function"), "catch": kw("catch"), |
|||
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"), |
|||
"in": operator, "typeof": operator, "instanceof": operator, |
|||
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom, |
|||
"this": kw("this"), "class": kw("class"), "super": kw("atom"), |
|||
"yield": C, "export": kw("export"), "import": kw("import"), "extends": C, |
|||
"await": C |
|||
}; |
|||
}(); |
|||
|
|||
var isOperatorChar = /[+\-*&%=<>!?|~^@]/; |
|||
var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/; |
|||
|
|||
function readRegexp(stream) { |
|||
var escaped = false, next, inSet = false; |
|||
while ((next = stream.next()) != null) { |
|||
if (!escaped) { |
|||
if (next == "/" && !inSet) return; |
|||
if (next == "[") inSet = true; |
|||
else if (inSet && next == "]") inSet = false; |
|||
} |
|||
escaped = !escaped && next == "\\"; |
|||
} |
|||
} |
|||
|
|||
// Used as scratch variables to communicate multiple values without
|
|||
// consing up tons of objects.
|
|||
var type, content; |
|||
function ret(tp, style, cont) { |
|||
type = tp; content = cont; |
|||
return style; |
|||
} |
|||
function tokenBase(stream, state) { |
|||
var ch = stream.next(); |
|||
if (ch == '"' || ch == "'") { |
|||
state.tokenize = tokenString(ch); |
|||
return state.tokenize(stream, state); |
|||
} else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) { |
|||
return ret("number", "number"); |
|||
} else if (ch == "." && stream.match("..")) { |
|||
return ret("spread", "meta"); |
|||
} else if (/[\[\]{}\(\),;\:\.]/.test(ch)) { |
|||
return ret(ch); |
|||
} else if (ch == "=" && stream.eat(">")) { |
|||
return ret("=>", "operator"); |
|||
} else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) { |
|||
return ret("number", "number"); |
|||
} else if (/\d/.test(ch)) { |
|||
stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/); |
|||
return ret("number", "number"); |
|||
} else if (ch == "/") { |
|||
if (stream.eat("*")) { |
|||
state.tokenize = tokenComment; |
|||
return tokenComment(stream, state); |
|||
} else if (stream.eat("/")) { |
|||
stream.skipToEnd(); |
|||
return ret("comment", "comment"); |
|||
} else if (expressionAllowed(stream, state, 1)) { |
|||
readRegexp(stream); |
|||
stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/); |
|||
return ret("regexp", "string-2"); |
|||
} else { |
|||
stream.eat("="); |
|||
return ret("operator", "operator", stream.current()); |
|||
} |
|||
} else if (ch == "`") { |
|||
state.tokenize = tokenQuasi; |
|||
return tokenQuasi(stream, state); |
|||
} else if (ch == "#" && stream.peek() == "!") { |
|||
stream.skipToEnd(); |
|||
return ret("meta", "meta"); |
|||
} else if (ch == "#" && stream.eatWhile(wordRE)) { |
|||
return ret("variable", "property") |
|||
} else if (ch == "<" && stream.match("!--") || |
|||
(ch == "-" && stream.match("->") && !/\S/.test(stream.string.slice(0, stream.start)))) { |
|||
stream.skipToEnd() |
|||
return ret("comment", "comment") |
|||
} else if (isOperatorChar.test(ch)) { |
|||
if (ch != ">" || !state.lexical || state.lexical.type != ">") { |
|||
if (stream.eat("=")) { |
|||
if (ch == "!" || ch == "=") stream.eat("=") |
|||
} else if (/[<>*+\-|&?]/.test(ch)) { |
|||
stream.eat(ch) |
|||
if (ch == ">") stream.eat(ch) |
|||
} |
|||
} |
|||
if (ch == "?" && stream.eat(".")) return ret(".") |
|||
return ret("operator", "operator", stream.current()); |
|||
} else if (wordRE.test(ch)) { |
|||
stream.eatWhile(wordRE); |
|||
var word = stream.current() |
|||
if (state.lastType != ".") { |
|||
if (keywords.propertyIsEnumerable(word)) { |
|||
var kw = keywords[word] |
|||
return ret(kw.type, kw.style, word) |
|||
} |
|||
if (word == "async" && stream.match(/^(\s|\/\*([^*]|\*(?!\/))*?\*\/)*[\[\(\w]/, false)) |
|||
return ret("async", "keyword", word) |
|||
} |
|||
return ret("variable", "variable", word) |
|||
} |
|||
} |
|||
|
|||
function tokenString(quote) { |
|||
return function(stream, state) { |
|||
var escaped = false, next; |
|||
if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){ |
|||
state.tokenize = tokenBase; |
|||
return ret("jsonld-keyword", "meta"); |
|||
} |
|||
while ((next = stream.next()) != null) { |
|||
if (next == quote && !escaped) break; |
|||
escaped = !escaped && next == "\\"; |
|||
} |
|||
if (!escaped) state.tokenize = tokenBase; |
|||
return ret("string", "string"); |
|||
}; |
|||
} |
|||
|
|||
function tokenComment(stream, state) { |
|||
var maybeEnd = false, ch; |
|||
while (ch = stream.next()) { |
|||
if (ch == "/" && maybeEnd) { |
|||
state.tokenize = tokenBase; |
|||
break; |
|||
} |
|||
maybeEnd = (ch == "*"); |
|||
} |
|||
return ret("comment", "comment"); |
|||
} |
|||
|
|||
function tokenQuasi(stream, state) { |
|||
var escaped = false, next; |
|||
while ((next = stream.next()) != null) { |
|||
if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) { |
|||
state.tokenize = tokenBase; |
|||
break; |
|||
} |
|||
escaped = !escaped && next == "\\"; |
|||
} |
|||
return ret("quasi", "string-2", stream.current()); |
|||
} |
|||
|
|||
var brackets = "([{}])"; |
|||
// This is a crude lookahead trick to try and notice that we're
|
|||
// parsing the argument patterns for a fat-arrow function before we
|
|||
// actually hit the arrow token. It only works if the arrow is on
|
|||
// the same line as the arguments and there's no strange noise
|
|||
// (comments) in between. Fallback is to only notice when we hit the
|
|||
// arrow, and not declare the arguments as locals for the arrow
|
|||
// body.
|
|||
function findFatArrow(stream, state) { |
|||
if (state.fatArrowAt) state.fatArrowAt = null; |
|||
var arrow = stream.string.indexOf("=>", stream.start); |
|||
if (arrow < 0) return; |
|||
|
|||
if (isTS) { // Try to skip TypeScript return type declarations after the arguments
|
|||
var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow)) |
|||
if (m) arrow = m.index |
|||
} |
|||
|
|||
var depth = 0, sawSomething = false; |
|||
for (var pos = arrow - 1; pos >= 0; --pos) { |
|||
var ch = stream.string.charAt(pos); |
|||
var bracket = brackets.indexOf(ch); |
|||
if (bracket >= 0 && bracket < 3) { |
|||
if (!depth) { ++pos; break; } |
|||
if (--depth == 0) { if (ch == "(") sawSomething = true; break; } |
|||
} else if (bracket >= 3 && bracket < 6) { |
|||
++depth; |
|||
} else if (wordRE.test(ch)) { |
|||
sawSomething = true; |
|||
} else if (/["'\/`]/.test(ch)) { |
|||
for (;; --pos) { |
|||
if (pos == 0) return |
|||
var next = stream.string.charAt(pos - 1) |
|||
if (next == ch && stream.string.charAt(pos - 2) != "\\") { pos--; break } |
|||
} |
|||
} else if (sawSomething && !depth) { |
|||
++pos; |
|||
break; |
|||
} |
|||
} |
|||
if (sawSomething && !depth) state.fatArrowAt = pos; |
|||
} |
|||
|
|||
// Parser
|
|||
|
|||
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, |
|||
"regexp": true, "this": true, "import": true, "jsonld-keyword": true}; |
|||
|
|||
function JSLexical(indented, column, type, align, prev, info) { |
|||
this.indented = indented; |
|||
this.column = column; |
|||
this.type = type; |
|||
this.prev = prev; |
|||
this.info = info; |
|||
if (align != null) this.align = align; |
|||
} |
|||
|
|||
function inScope(state, varname) { |
|||
if (!trackScope) return false |
|||
for (var v = state.localVars; v; v = v.next) |
|||
if (v.name == varname) return true; |
|||
for (var cx = state.context; cx; cx = cx.prev) { |
|||
for (var v = cx.vars; v; v = v.next) |
|||
if (v.name == varname) return true; |
|||
} |
|||
} |
|||
|
|||
function parseJS(state, style, type, content, stream) { |
|||
var cc = state.cc; |
|||
// Communicate our context to the combinators.
|
|||
// (Less wasteful than consing up a hundred closures on every call.)
|
|||
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style; |
|||
|
|||
if (!state.lexical.hasOwnProperty("align")) |
|||
state.lexical.align = true; |
|||
|
|||
while(true) { |
|||
var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement; |
|||
if (combinator(type, content)) { |
|||
while(cc.length && cc[cc.length - 1].lex) |
|||
cc.pop()(); |
|||
if (cx.marked) return cx.marked; |
|||
if (type == "variable" && inScope(state, content)) return "variable-2"; |
|||
return style; |
|||
} |
|||
} |
|||
} |
|||
|
|||
// Combinator utils
|
|||
|
|||
var cx = {state: null, column: null, marked: null, cc: null}; |
|||
function pass() { |
|||
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]); |
|||
} |
|||
function cont() { |
|||
pass.apply(null, arguments); |
|||
return true; |
|||
} |
|||
function inList(name, list) { |
|||
for (var v = list; v; v = v.next) if (v.name == name) return true |
|||
return false; |
|||
} |
|||
function register(varname) { |
|||
var state = cx.state; |
|||
cx.marked = "def"; |
|||
if (!trackScope) return |
|||
if (state.context) { |
|||
if (state.lexical.info == "var" && state.context && state.context.block) { |
|||
// FIXME function decls are also not block scoped
|
|||
var newContext = registerVarScoped(varname, state.context) |
|||
if (newContext != null) { |
|||
state.context = newContext |
|||
return |
|||
} |
|||
} else if (!inList(varname, state.localVars)) { |
|||
state.localVars = new Var(varname, state.localVars) |
|||
return |
|||
} |
|||
} |
|||
// Fall through means this is global
|
|||
if (parserConfig.globalVars && !inList(varname, state.globalVars)) |
|||
state.globalVars = new Var(varname, state.globalVars) |
|||
} |
|||
function registerVarScoped(varname, context) { |
|||
if (!context) { |
|||
return null |
|||
} else if (context.block) { |
|||
var inner = registerVarScoped(varname, context.prev) |
|||
if (!inner) return null |
|||
if (inner == context.prev) return context |
|||
return new Context(inner, context.vars, true) |
|||
} else if (inList(varname, context.vars)) { |
|||
return context |
|||
} else { |
|||
return new Context(context.prev, new Var(varname, context.vars), false) |
|||
} |
|||
} |
|||
|
|||
function isModifier(name) { |
|||
return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly" |
|||
} |
|||
|
|||
// Combinators
|
|||
|
|||
function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block } |
|||
function Var(name, next) { this.name = name; this.next = next } |
|||
|
|||
var defaultVars = new Var("this", new Var("arguments", null)) |
|||
function pushcontext() { |
|||
cx.state.context = new Context(cx.state.context, cx.state.localVars, false) |
|||
cx.state.localVars = defaultVars |
|||
} |
|||
function pushblockcontext() { |
|||
cx.state.context = new Context(cx.state.context, cx.state.localVars, true) |
|||
cx.state.localVars = null |
|||
} |
|||
pushcontext.lex = pushblockcontext.lex = true |
|||
function popcontext() { |
|||
cx.state.localVars = cx.state.context.vars |
|||
cx.state.context = cx.state.context.prev |
|||
} |
|||
popcontext.lex = true |
|||
function pushlex(type, info) { |
|||
var result = function() { |
|||
var state = cx.state, indent = state.indented; |
|||
if (state.lexical.type == "stat") indent = state.lexical.indented; |
|||
else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev) |
|||
indent = outer.indented; |
|||
state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info); |
|||
}; |
|||
result.lex = true; |
|||
return result; |
|||
} |
|||
function poplex() { |
|||
var state = cx.state; |
|||
if (state.lexical.prev) { |
|||
if (state.lexical.type == ")") |
|||
state.indented = state.lexical.indented; |
|||
state.lexical = state.lexical.prev; |
|||
} |
|||
} |
|||
poplex.lex = true; |
|||
|
|||
function expect(wanted) { |
|||
function exp(type) { |
|||
if (type == wanted) return cont(); |
|||
else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass(); |
|||
else return cont(exp); |
|||
}; |
|||
return exp; |
|||
} |
|||
|
|||
function statement(type, value) { |
|||
if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex); |
|||
if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex); |
|||
if (type == "keyword b") return cont(pushlex("form"), statement, poplex); |
|||
if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex); |
|||
if (type == "debugger") return cont(expect(";")); |
|||
if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext); |
|||
if (type == ";") return cont(); |
|||
if (type == "if") { |
|||
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex) |
|||
cx.state.cc.pop()(); |
|||
return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse); |
|||
} |
|||
if (type == "function") return cont(functiondef); |
|||
if (type == "for") return cont(pushlex("form"), pushblockcontext, forspec, statement, popcontext, poplex); |
|||
if (type == "class" || (isTS && value == "interface")) { |
|||
cx.marked = "keyword" |
|||
return cont(pushlex("form", type == "class" ? type : value), className, poplex) |
|||
} |
|||
if (type == "variable") { |
|||
if (isTS && value == "declare") { |
|||
cx.marked = "keyword" |
|||
return cont(statement) |
|||
} else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) { |
|||
cx.marked = "keyword" |
|||
if (value == "enum") return cont(enumdef); |
|||
else if (value == "type") return cont(typename, expect("operator"), typeexpr, expect(";")); |
|||
else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex) |
|||
} else if (isTS && value == "namespace") { |
|||
cx.marked = "keyword" |
|||
return cont(pushlex("form"), expression, statement, poplex) |
|||
} else if (isTS && value == "abstract") { |
|||
cx.marked = "keyword" |
|||
return cont(statement) |
|||
} else { |
|||
return cont(pushlex("stat"), maybelabel); |
|||
} |
|||
} |
|||
if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext, |
|||
block, poplex, poplex, popcontext); |
|||
if (type == "case") return cont(expression, expect(":")); |
|||
if (type == "default") return cont(expect(":")); |
|||
if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext); |
|||
if (type == "export") return cont(pushlex("stat"), afterExport, poplex); |
|||
if (type == "import") return cont(pushlex("stat"), afterImport, poplex); |
|||
if (type == "async") return cont(statement) |
|||
if (value == "@") return cont(expression, statement) |
|||
return pass(pushlex("stat"), expression, expect(";"), poplex); |
|||
} |
|||
function maybeCatchBinding(type) { |
|||
if (type == "(") return cont(funarg, expect(")")) |
|||
} |
|||
function expression(type, value) { |
|||
return expressionInner(type, value, false); |
|||
} |
|||
function expressionNoComma(type, value) { |
|||
return expressionInner(type, value, true); |
|||
} |
|||
function parenExpr(type) { |
|||
if (type != "(") return pass() |
|||
return cont(pushlex(")"), maybeexpression, expect(")"), poplex) |
|||
} |
|||
function expressionInner(type, value, noComma) { |
|||
if (cx.state.fatArrowAt == cx.stream.start) { |
|||
var body = noComma ? arrowBodyNoComma : arrowBody; |
|||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext); |
|||
else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext); |
|||
} |
|||
|
|||
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma; |
|||
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop); |
|||
if (type == "function") return cont(functiondef, maybeop); |
|||
if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); } |
|||
if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression); |
|||
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop); |
|||
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression); |
|||
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop); |
|||
if (type == "{") return contCommasep(objprop, "}", null, maybeop); |
|||
if (type == "quasi") return pass(quasi, maybeop); |
|||
if (type == "new") return cont(maybeTarget(noComma)); |
|||
return cont(); |
|||
} |
|||
function maybeexpression(type) { |
|||
if (type.match(/[;\}\)\],]/)) return pass(); |
|||
return pass(expression); |
|||
} |
|||
|
|||
function maybeoperatorComma(type, value) { |
|||
if (type == ",") return cont(maybeexpression); |
|||
return maybeoperatorNoComma(type, value, false); |
|||
} |
|||
function maybeoperatorNoComma(type, value, noComma) { |
|||
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma; |
|||
var expr = noComma == false ? expression : expressionNoComma; |
|||
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext); |
|||
if (type == "operator") { |
|||
if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me); |
|||
if (isTS && value == "<" && cx.stream.match(/^([^<>]|<[^<>]*>)*>\s*\(/, false)) |
|||
return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me); |
|||
if (value == "?") return cont(expression, expect(":"), expr); |
|||
return cont(expr); |
|||
} |
|||
if (type == "quasi") { return pass(quasi, me); } |
|||
if (type == ";") return; |
|||
if (type == "(") return contCommasep(expressionNoComma, ")", "call", me); |
|||
if (type == ".") return cont(property, me); |
|||
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me); |
|||
if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) } |
|||
if (type == "regexp") { |
|||
cx.state.lastType = cx.marked = "operator" |
|||
cx.stream.backUp(cx.stream.pos - cx.stream.start - 1) |
|||
return cont(expr) |
|||
} |
|||
} |
|||
function quasi(type, value) { |
|||
if (type != "quasi") return pass(); |
|||
if (value.slice(value.length - 2) != "${") return cont(quasi); |
|||
return cont(maybeexpression, continueQuasi); |
|||
} |
|||
function continueQuasi(type) { |
|||
if (type == "}") { |
|||
cx.marked = "string-2"; |
|||
cx.state.tokenize = tokenQuasi; |
|||
return cont(quasi); |
|||
} |
|||
} |
|||
function arrowBody(type) { |
|||
findFatArrow(cx.stream, cx.state); |
|||
return pass(type == "{" ? statement : expression); |
|||
} |
|||
function arrowBodyNoComma(type) { |
|||
findFatArrow(cx.stream, cx.state); |
|||
return pass(type == "{" ? statement : expressionNoComma); |
|||
} |
|||
function maybeTarget(noComma) { |
|||
return function(type) { |
|||
if (type == ".") return cont(noComma ? targetNoComma : target); |
|||
else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma) |
|||
else return pass(noComma ? expressionNoComma : expression); |
|||
}; |
|||
} |
|||
function target(_, value) { |
|||
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); } |
|||
} |
|||
function targetNoComma(_, value) { |
|||
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); } |
|||
} |
|||
function maybelabel(type) { |
|||
if (type == ":") return cont(poplex, statement); |
|||
return pass(maybeoperatorComma, expect(";"), poplex); |
|||
} |
|||
function property(type) { |
|||
if (type == "variable") {cx.marked = "property"; return cont();} |
|||
} |
|||
function objprop(type, value) { |
|||
if (type == "async") { |
|||
cx.marked = "property"; |
|||
return cont(objprop); |
|||
} else if (type == "variable" || cx.style == "keyword") { |
|||
cx.marked = "property"; |
|||
if (value == "get" || value == "set") return cont(getterSetter); |
|||
var m // Work around fat-arrow-detection complication for detecting typescript typed arrow params
|
|||
if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false))) |
|||
cx.state.fatArrowAt = cx.stream.pos + m[0].length |
|||
return cont(afterprop); |
|||
} else if (type == "number" || type == "string") { |
|||
cx.marked = jsonldMode ? "property" : (cx.style + " property"); |
|||
return cont(afterprop); |
|||
} else if (type == "jsonld-keyword") { |
|||
return cont(afterprop); |
|||
} else if (isTS && isModifier(value)) { |
|||
cx.marked = "keyword" |
|||
return cont(objprop) |
|||
} else if (type == "[") { |
|||
return cont(expression, maybetype, expect("]"), afterprop); |
|||
} else if (type == "spread") { |
|||
return cont(expressionNoComma, afterprop); |
|||
} else if (value == "*") { |
|||
cx.marked = "keyword"; |
|||
return cont(objprop); |
|||
} else if (type == ":") { |
|||
return pass(afterprop) |
|||
} |
|||
} |
|||
function getterSetter(type) { |
|||
if (type != "variable") return pass(afterprop); |
|||
cx.marked = "property"; |
|||
return cont(functiondef); |
|||
} |
|||
function afterprop(type) { |
|||
if (type == ":") return cont(expressionNoComma); |
|||
if (type == "(") return pass(functiondef); |
|||
} |
|||
function commasep(what, end, sep) { |
|||
function proceed(type, value) { |
|||
if (sep ? sep.indexOf(type) > -1 : type == ",") { |
|||
var lex = cx.state.lexical; |
|||
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1; |
|||
return cont(function(type, value) { |
|||
if (type == end || value == end) return pass() |
|||
return pass(what) |
|||
}, proceed); |
|||
} |
|||
if (type == end || value == end) return cont(); |
|||
if (sep && sep.indexOf(";") > -1) return pass(what) |
|||
return cont(expect(end)); |
|||
} |
|||
return function(type, value) { |
|||
if (type == end || value == end) return cont(); |
|||
return pass(what, proceed); |
|||
}; |
|||
} |
|||
function contCommasep(what, end, info) { |
|||
for (var i = 3; i < arguments.length; i++) |
|||
cx.cc.push(arguments[i]); |
|||
return cont(pushlex(end, info), commasep(what, end), poplex); |
|||
} |
|||
function block(type) { |
|||
if (type == "}") return cont(); |
|||
return pass(statement, block); |
|||
} |
|||
function maybetype(type, value) { |
|||
if (isTS) { |
|||
if (type == ":") return cont(typeexpr); |
|||
if (value == "?") return cont(maybetype); |
|||
} |
|||
} |
|||
function maybetypeOrIn(type, value) { |
|||
if (isTS && (type == ":" || value == "in")) return cont(typeexpr) |
|||
} |
|||
function mayberettype(type) { |
|||
if (isTS && type == ":") { |
|||
if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr) |
|||
else return cont(typeexpr) |
|||
} |
|||
} |
|||
function isKW(_, value) { |
|||
if (value == "is") { |
|||
cx.marked = "keyword" |
|||
return cont() |
|||
} |
|||
} |
|||
function typeexpr(type, value) { |
|||
if (value == "keyof" || value == "typeof" || value == "infer" || value == "readonly") { |
|||
cx.marked = "keyword" |
|||
return cont(value == "typeof" ? expressionNoComma : typeexpr) |
|||
} |
|||
if (type == "variable" || value == "void") { |
|||
cx.marked = "type" |
|||
return cont(afterType) |
|||
} |
|||
if (value == "|" || value == "&") return cont(typeexpr) |
|||
if (type == "string" || type == "number" || type == "atom") return cont(afterType); |
|||
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType) |
|||
if (type == "{") return cont(pushlex("}"), typeprops, poplex, afterType) |
|||
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType) |
|||
if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr) |
|||
if (type == "quasi") { return pass(quasiType, afterType); } |
|||
} |
|||
function maybeReturnType(type) { |
|||
if (type == "=>") return cont(typeexpr) |
|||
} |
|||
function typeprops(type) { |
|||
if (type.match(/[\}\)\]]/)) return cont() |
|||
if (type == "," || type == ";") return cont(typeprops) |
|||
return pass(typeprop, typeprops) |
|||
} |
|||
function typeprop(type, value) { |
|||
if (type == "variable" || cx.style == "keyword") { |
|||
cx.marked = "property" |
|||
return cont(typeprop) |
|||
} else if (value == "?" || type == "number" || type == "string") { |
|||
return cont(typeprop) |
|||
} else if (type == ":") { |
|||
return cont(typeexpr) |
|||
} else if (type == "[") { |
|||
return cont(expect("variable"), maybetypeOrIn, expect("]"), typeprop) |
|||
} else if (type == "(") { |
|||
return pass(functiondecl, typeprop) |
|||
} else if (!type.match(/[;\}\)\],]/)) { |
|||
return cont() |
|||
} |
|||
} |
|||
function quasiType(type, value) { |
|||
if (type != "quasi") return pass(); |
|||
if (value.slice(value.length - 2) != "${") return cont(quasiType); |
|||
return cont(typeexpr, continueQuasiType); |
|||
} |
|||
function continueQuasiType(type) { |
|||
if (type == "}") { |
|||
cx.marked = "string-2"; |
|||
cx.state.tokenize = tokenQuasi; |
|||
return cont(quasiType); |
|||
} |
|||
} |
|||
function typearg(type, value) { |
|||
if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg) |
|||
if (type == ":") return cont(typeexpr) |
|||
if (type == "spread") return cont(typearg) |
|||
return pass(typeexpr) |
|||
} |
|||
function afterType(type, value) { |
|||
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) |
|||
if (value == "|" || type == "." || value == "&") return cont(typeexpr) |
|||
if (type == "[") return cont(typeexpr, expect("]"), afterType) |
|||
if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) } |
|||
if (value == "?") return cont(typeexpr, expect(":"), typeexpr) |
|||
} |
|||
function maybeTypeArgs(_, value) { |
|||
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType) |
|||
} |
|||
function typeparam() { |
|||
return pass(typeexpr, maybeTypeDefault) |
|||
} |
|||
function maybeTypeDefault(_, value) { |
|||
if (value == "=") return cont(typeexpr) |
|||
} |
|||
function vardef(_, value) { |
|||
if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)} |
|||
return pass(pattern, maybetype, maybeAssign, vardefCont); |
|||
} |
|||
function pattern(type, value) { |
|||
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) } |
|||
if (type == "variable") { register(value); return cont(); } |
|||
if (type == "spread") return cont(pattern); |
|||
if (type == "[") return contCommasep(eltpattern, "]"); |
|||
if (type == "{") return contCommasep(proppattern, "}"); |
|||
} |
|||
function proppattern(type, value) { |
|||
if (type == "variable" && !cx.stream.match(/^\s*:/, false)) { |
|||
register(value); |
|||
return cont(maybeAssign); |
|||
} |
|||
if (type == "variable") cx.marked = "property"; |
|||
if (type == "spread") return cont(pattern); |
|||
if (type == "}") return pass(); |
|||
if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern); |
|||
return cont(expect(":"), pattern, maybeAssign); |
|||
} |
|||
function eltpattern() { |
|||
return pass(pattern, maybeAssign) |
|||
} |
|||
function maybeAssign(_type, value) { |
|||
if (value == "=") return cont(expressionNoComma); |
|||
} |
|||
function vardefCont(type) { |
|||
if (type == ",") return cont(vardef); |
|||
} |
|||
function maybeelse(type, value) { |
|||
if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex); |
|||
} |
|||
function forspec(type, value) { |
|||
if (value == "await") return cont(forspec); |
|||
if (type == "(") return cont(pushlex(")"), forspec1, poplex); |
|||
} |
|||
function forspec1(type) { |
|||
if (type == "var") return cont(vardef, forspec2); |
|||
if (type == "variable") return cont(forspec2); |
|||
return pass(forspec2) |
|||
} |
|||
function forspec2(type, value) { |
|||
if (type == ")") return cont() |
|||
if (type == ";") return cont(forspec2) |
|||
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression, forspec2) } |
|||
return pass(expression, forspec2) |
|||
} |
|||
function functiondef(type, value) { |
|||
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);} |
|||
if (type == "variable") {register(value); return cont(functiondef);} |
|||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext); |
|||
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef) |
|||
} |
|||
function functiondecl(type, value) { |
|||
if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);} |
|||
if (type == "variable") {register(value); return cont(functiondecl);} |
|||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext); |
|||
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl) |
|||
} |
|||
function typename(type, value) { |
|||
if (type == "keyword" || type == "variable") { |
|||
cx.marked = "type" |
|||
return cont(typename) |
|||
} else if (value == "<") { |
|||
return cont(pushlex(">"), commasep(typeparam, ">"), poplex) |
|||
} |
|||
} |
|||
function funarg(type, value) { |
|||
if (value == "@") cont(expression, funarg) |
|||
if (type == "spread") return cont(funarg); |
|||
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); } |
|||
if (isTS && type == "this") return cont(maybetype, maybeAssign) |
|||
return pass(pattern, maybetype, maybeAssign); |
|||
} |
|||
function classExpression(type, value) { |
|||
// Class expressions may have an optional name.
|
|||
if (type == "variable") return className(type, value); |
|||
return classNameAfter(type, value); |
|||
} |
|||
function className(type, value) { |
|||
if (type == "variable") {register(value); return cont(classNameAfter);} |
|||
} |
|||
function classNameAfter(type, value) { |
|||
if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter) |
|||
if (value == "extends" || value == "implements" || (isTS && type == ",")) { |
|||
if (value == "implements") cx.marked = "keyword"; |
|||
return cont(isTS ? typeexpr : expression, classNameAfter); |
|||
} |
|||
if (type == "{") return cont(pushlex("}"), classBody, poplex); |
|||
} |
|||
function classBody(type, value) { |
|||
if (type == "async" || |
|||
(type == "variable" && |
|||
(value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) && |
|||
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) { |
|||
cx.marked = "keyword"; |
|||
return cont(classBody); |
|||
} |
|||
if (type == "variable" || cx.style == "keyword") { |
|||
cx.marked = "property"; |
|||
return cont(classfield, classBody); |
|||
} |
|||
if (type == "number" || type == "string") return cont(classfield, classBody); |
|||
if (type == "[") |
|||
return cont(expression, maybetype, expect("]"), classfield, classBody) |
|||
if (value == "*") { |
|||
cx.marked = "keyword"; |
|||
return cont(classBody); |
|||
} |
|||
if (isTS && type == "(") return pass(functiondecl, classBody) |
|||
if (type == ";" || type == ",") return cont(classBody); |
|||
if (type == "}") return cont(); |
|||
if (value == "@") return cont(expression, classBody) |
|||
} |
|||
function classfield(type, value) { |
|||
if (value == "!") return cont(classfield) |
|||
if (value == "?") return cont(classfield) |
|||
if (type == ":") return cont(typeexpr, maybeAssign) |
|||
if (value == "=") return cont(expressionNoComma) |
|||
var context = cx.state.lexical.prev, isInterface = context && context.info == "interface" |
|||
return pass(isInterface ? functiondecl : functiondef) |
|||
} |
|||
function afterExport(type, value) { |
|||
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); } |
|||
if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); } |
|||
if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";")); |
|||
return pass(statement); |
|||
} |
|||
function exportField(type, value) { |
|||
if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); } |
|||
if (type == "variable") return pass(expressionNoComma, exportField); |
|||
} |
|||
function afterImport(type) { |
|||
if (type == "string") return cont(); |
|||
if (type == "(") return pass(expression); |
|||
if (type == ".") return pass(maybeoperatorComma); |
|||
return pass(importSpec, maybeMoreImports, maybeFrom); |
|||
} |
|||
function importSpec(type, value) { |
|||
if (type == "{") return contCommasep(importSpec, "}"); |
|||
if (type == "variable") register(value); |
|||
if (value == "*") cx.marked = "keyword"; |
|||
return cont(maybeAs); |
|||
} |
|||
function maybeMoreImports(type) { |
|||
if (type == ",") return cont(importSpec, maybeMoreImports) |
|||
} |
|||
function maybeAs(_type, value) { |
|||
if (value == "as") { cx.marked = "keyword"; return cont(importSpec); } |
|||
} |
|||
function maybeFrom(_type, value) { |
|||
if (value == "from") { cx.marked = "keyword"; return cont(expression); } |
|||
} |
|||
function arrayLiteral(type) { |
|||
if (type == "]") return cont(); |
|||
return pass(commasep(expressionNoComma, "]")); |
|||
} |
|||
function enumdef() { |
|||
return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex) |
|||
} |
|||
function enummember() { |
|||
return pass(pattern, maybeAssign); |
|||
} |
|||
|
|||
function isContinuedStatement(state, textAfter) { |
|||
return state.lastType == "operator" || state.lastType == "," || |
|||
isOperatorChar.test(textAfter.charAt(0)) || |
|||
/[,.]/.test(textAfter.charAt(0)); |
|||
} |
|||
|
|||
function expressionAllowed(stream, state, backUp) { |
|||
return state.tokenize == tokenBase && |
|||
/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) || |
|||
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0)))) |
|||
} |
|||
|
|||
// Interface
|
|||
|
|||
return { |
|||
startState: function(basecolumn) { |
|||
var state = { |
|||
tokenize: tokenBase, |
|||
lastType: "sof", |
|||
cc: [], |
|||
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false), |
|||
localVars: parserConfig.localVars, |
|||
context: parserConfig.localVars && new Context(null, null, false), |
|||
indented: basecolumn || 0 |
|||
}; |
|||
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object") |
|||
state.globalVars = parserConfig.globalVars; |
|||
return state; |
|||
}, |
|||
|
|||
token: function(stream, state) { |
|||
if (stream.sol()) { |
|||
if (!state.lexical.hasOwnProperty("align")) |
|||
state.lexical.align = false; |
|||
state.indented = stream.indentation(); |
|||
findFatArrow(stream, state); |
|||
} |
|||
if (state.tokenize != tokenComment && stream.eatSpace()) return null; |
|||
var style = state.tokenize(stream, state); |
|||
if (type == "comment") return style; |
|||
state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type; |
|||
return parseJS(state, style, type, content, stream); |
|||
}, |
|||
|
|||
indent: function(state, textAfter) { |
|||
if (state.tokenize == tokenComment || state.tokenize == tokenQuasi) return CodeMirror.Pass; |
|||
if (state.tokenize != tokenBase) return 0; |
|||
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top |
|||
// Kludge to prevent 'maybelse' from blocking lexical scope pops
|
|||
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) { |
|||
var c = state.cc[i]; |
|||
if (c == poplex) lexical = lexical.prev; |
|||
else if (c != maybeelse && c != popcontext) break; |
|||
} |
|||
while ((lexical.type == "stat" || lexical.type == "form") && |
|||
(firstChar == "}" || ((top = state.cc[state.cc.length - 1]) && |
|||
(top == maybeoperatorComma || top == maybeoperatorNoComma) && |
|||
!/^[,\.=+\-*:?[\(]/.test(textAfter)))) |
|||
lexical = lexical.prev; |
|||
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat") |
|||
lexical = lexical.prev; |
|||
var type = lexical.type, closing = firstChar == type; |
|||
|
|||
if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0); |
|||
else if (type == "form" && firstChar == "{") return lexical.indented; |
|||
else if (type == "form") return lexical.indented + indentUnit; |
|||
else if (type == "stat") |
|||
return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0); |
|||
else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false) |
|||
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit); |
|||
else if (lexical.align) return lexical.column + (closing ? 0 : 1); |
|||
else return lexical.indented + (closing ? 0 : indentUnit); |
|||
}, |
|||
|
|||
electricInput: /^\s*(?:case .*?:|default:|\{|\})$/, |
|||
blockCommentStart: jsonMode ? null : "/*", |
|||
blockCommentEnd: jsonMode ? null : "*/", |
|||
blockCommentContinue: jsonMode ? null : " * ", |
|||
lineComment: jsonMode ? null : "//", |
|||
fold: "brace", |
|||
closeBrackets: "()[]{}''\"\"``", |
|||
|
|||
helperType: jsonMode ? "json" : "javascript", |
|||
jsonldMode: jsonldMode, |
|||
jsonMode: jsonMode, |
|||
|
|||
expressionAllowed: expressionAllowed, |
|||
|
|||
skipExpression: function(state) { |
|||
parseJS(state, "atom", "atom", "true", new CodeMirror.StringStream("", 2, null)) |
|||
} |
|||
}; |
|||
}); |
|||
|
|||
CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/); |
|||
|
|||
CodeMirror.defineMIME("text/javascript", "javascript"); |
|||
CodeMirror.defineMIME("text/ecmascript", "javascript"); |
|||
CodeMirror.defineMIME("application/javascript", "javascript"); |
|||
CodeMirror.defineMIME("application/x-javascript", "javascript"); |
|||
CodeMirror.defineMIME("application/ecmascript", "javascript"); |
|||
CodeMirror.defineMIME("application/json", { name: "javascript", json: true }); |
|||
CodeMirror.defineMIME("application/x-json", { name: "javascript", json: true }); |
|||
CodeMirror.defineMIME("application/manifest+json", { name: "javascript", json: true }) |
|||
CodeMirror.defineMIME("application/ld+json", { name: "javascript", jsonld: true }); |
|||
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true }); |
|||
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true }); |
|||
|
|||
}); |
|||
@ -0,0 +1,417 @@ |
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|||
|
|||
(function(mod) { |
|||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|||
mod(require("../../lib/codemirror")); |
|||
else if (typeof define == "function" && define.amd) // AMD
|
|||
define(["../../lib/codemirror.js"], mod); |
|||
else // Plain browser env
|
|||
mod(CodeMirror); |
|||
})(function(CodeMirror) { |
|||
"use strict"; |
|||
|
|||
var htmlConfig = { |
|||
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true, |
|||
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true, |
|||
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true, |
|||
'track': true, 'wbr': true, 'menuitem': true}, |
|||
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true, |
|||
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true, |
|||
'th': true, 'tr': true}, |
|||
contextGrabbers: { |
|||
'dd': {'dd': true, 'dt': true}, |
|||
'dt': {'dd': true, 'dt': true}, |
|||
'li': {'li': true}, |
|||
'option': {'option': true, 'optgroup': true}, |
|||
'optgroup': {'optgroup': true}, |
|||
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true, |
|||
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true, |
|||
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true, |
|||
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true, |
|||
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true}, |
|||
'rp': {'rp': true, 'rt': true}, |
|||
'rt': {'rp': true, 'rt': true}, |
|||
'tbody': {'tbody': true, 'tfoot': true}, |
|||
'td': {'td': true, 'th': true}, |
|||
'tfoot': {'tbody': true}, |
|||
'th': {'td': true, 'th': true}, |
|||
'thead': {'tbody': true, 'tfoot': true}, |
|||
'tr': {'tr': true} |
|||
}, |
|||
doNotIndent: {"pre": true}, |
|||
allowUnquoted: true, |
|||
allowMissing: true, |
|||
caseFold: true |
|||
} |
|||
|
|||
var xmlConfig = { |
|||
autoSelfClosers: {}, |
|||
implicitlyClosed: {}, |
|||
contextGrabbers: {}, |
|||
doNotIndent: {}, |
|||
allowUnquoted: false, |
|||
allowMissing: false, |
|||
allowMissingTagName: false, |
|||
caseFold: false |
|||
} |
|||
|
|||
CodeMirror.defineMode("xml", function(editorConf, config_) { |
|||
var indentUnit = editorConf.indentUnit |
|||
var config = {} |
|||
var defaults = config_.htmlMode ? htmlConfig : xmlConfig |
|||
for (var prop in defaults) config[prop] = defaults[prop] |
|||
for (var prop in config_) config[prop] = config_[prop] |
|||
|
|||
// Return variables for tokenizers
|
|||
var type, setStyle; |
|||
|
|||
function inText(stream, state) { |
|||
function chain(parser) { |
|||
state.tokenize = parser; |
|||
return parser(stream, state); |
|||
} |
|||
|
|||
var ch = stream.next(); |
|||
if (ch == "<") { |
|||
if (stream.eat("!")) { |
|||
if (stream.eat("[")) { |
|||
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>")); |
|||
else return null; |
|||
} else if (stream.match("--")) { |
|||
return chain(inBlock("comment", "-->")); |
|||
} else if (stream.match("DOCTYPE", true, true)) { |
|||
stream.eatWhile(/[\w\._\-]/); |
|||
return chain(doctype(1)); |
|||
} else { |
|||
return null; |
|||
} |
|||
} else if (stream.eat("?")) { |
|||
stream.eatWhile(/[\w\._\-]/); |
|||
state.tokenize = inBlock("meta", "?>"); |
|||
return "meta"; |
|||
} else { |
|||
type = stream.eat("/") ? "closeTag" : "openTag"; |
|||
state.tokenize = inTag; |
|||
return "tag bracket"; |
|||
} |
|||
} else if (ch == "&") { |
|||
var ok; |
|||
if (stream.eat("#")) { |
|||
if (stream.eat("x")) { |
|||
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";"); |
|||
} else { |
|||
ok = stream.eatWhile(/[\d]/) && stream.eat(";"); |
|||
} |
|||
} else { |
|||
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";"); |
|||
} |
|||
return ok ? "atom" : "error"; |
|||
} else { |
|||
stream.eatWhile(/[^&<]/); |
|||
return null; |
|||
} |
|||
} |
|||
inText.isInText = true; |
|||
|
|||
function inTag(stream, state) { |
|||
var ch = stream.next(); |
|||
if (ch == ">" || (ch == "/" && stream.eat(">"))) { |
|||
state.tokenize = inText; |
|||
type = ch == ">" ? "endTag" : "selfcloseTag"; |
|||
return "tag bracket"; |
|||
} else if (ch == "=") { |
|||
type = "equals"; |
|||
return null; |
|||
} else if (ch == "<") { |
|||
state.tokenize = inText; |
|||
state.state = baseState; |
|||
state.tagName = state.tagStart = null; |
|||
var next = state.tokenize(stream, state); |
|||
return next ? next + " tag error" : "tag error"; |
|||
} else if (/[\'\"]/.test(ch)) { |
|||
state.tokenize = inAttribute(ch); |
|||
state.stringStartCol = stream.column(); |
|||
return state.tokenize(stream, state); |
|||
} else { |
|||
stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/); |
|||
return "word"; |
|||
} |
|||
} |
|||
|
|||
function inAttribute(quote) { |
|||
var closure = function(stream, state) { |
|||
while (!stream.eol()) { |
|||
if (stream.next() == quote) { |
|||
state.tokenize = inTag; |
|||
break; |
|||
} |
|||
} |
|||
return "string"; |
|||
}; |
|||
closure.isInAttribute = true; |
|||
return closure; |
|||
} |
|||
|
|||
function inBlock(style, terminator) { |
|||
return function(stream, state) { |
|||
while (!stream.eol()) { |
|||
if (stream.match(terminator)) { |
|||
state.tokenize = inText; |
|||
break; |
|||
} |
|||
stream.next(); |
|||
} |
|||
return style; |
|||
} |
|||
} |
|||
|
|||
function doctype(depth) { |
|||
return function(stream, state) { |
|||
var ch; |
|||
while ((ch = stream.next()) != null) { |
|||
if (ch == "<") { |
|||
state.tokenize = doctype(depth + 1); |
|||
return state.tokenize(stream, state); |
|||
} else if (ch == ">") { |
|||
if (depth == 1) { |
|||
state.tokenize = inText; |
|||
break; |
|||
} else { |
|||
state.tokenize = doctype(depth - 1); |
|||
return state.tokenize(stream, state); |
|||
} |
|||
} |
|||
} |
|||
return "meta"; |
|||
}; |
|||
} |
|||
|
|||
function lower(tagName) { |
|||
return tagName && tagName.toLowerCase(); |
|||
} |
|||
|
|||
function Context(state, tagName, startOfLine) { |
|||
this.prev = state.context; |
|||
this.tagName = tagName || ""; |
|||
this.indent = state.indented; |
|||
this.startOfLine = startOfLine; |
|||
if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent)) |
|||
this.noIndent = true; |
|||
} |
|||
function popContext(state) { |
|||
if (state.context) state.context = state.context.prev; |
|||
} |
|||
function maybePopContext(state, nextTagName) { |
|||
var parentTagName; |
|||
while (true) { |
|||
if (!state.context) { |
|||
return; |
|||
} |
|||
parentTagName = state.context.tagName; |
|||
if (!config.contextGrabbers.hasOwnProperty(lower(parentTagName)) || |
|||
!config.contextGrabbers[lower(parentTagName)].hasOwnProperty(lower(nextTagName))) { |
|||
return; |
|||
} |
|||
popContext(state); |
|||
} |
|||
} |
|||
|
|||
function baseState(type, stream, state) { |
|||
if (type == "openTag") { |
|||
state.tagStart = stream.column(); |
|||
return tagNameState; |
|||
} else if (type == "closeTag") { |
|||
return closeTagNameState; |
|||
} else { |
|||
return baseState; |
|||
} |
|||
} |
|||
function tagNameState(type, stream, state) { |
|||
if (type == "word") { |
|||
state.tagName = stream.current(); |
|||
setStyle = "tag"; |
|||
return attrState; |
|||
} else if (config.allowMissingTagName && type == "endTag") { |
|||
setStyle = "tag bracket"; |
|||
return attrState(type, stream, state); |
|||
} else { |
|||
setStyle = "error"; |
|||
return tagNameState; |
|||
} |
|||
} |
|||
function closeTagNameState(type, stream, state) { |
|||
if (type == "word") { |
|||
var tagName = stream.current(); |
|||
if (state.context && state.context.tagName != tagName && |
|||
config.implicitlyClosed.hasOwnProperty(lower(state.context.tagName))) |
|||
popContext(state); |
|||
if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) { |
|||
setStyle = "tag"; |
|||
return closeState; |
|||
} else { |
|||
setStyle = "tag error"; |
|||
return closeStateErr; |
|||
} |
|||
} else if (config.allowMissingTagName && type == "endTag") { |
|||
setStyle = "tag bracket"; |
|||
return closeState(type, stream, state); |
|||
} else { |
|||
setStyle = "error"; |
|||
return closeStateErr; |
|||
} |
|||
} |
|||
|
|||
function closeState(type, _stream, state) { |
|||
if (type != "endTag") { |
|||
setStyle = "error"; |
|||
return closeState; |
|||
} |
|||
popContext(state); |
|||
return baseState; |
|||
} |
|||
function closeStateErr(type, stream, state) { |
|||
setStyle = "error"; |
|||
return closeState(type, stream, state); |
|||
} |
|||
|
|||
function attrState(type, _stream, state) { |
|||
if (type == "word") { |
|||
setStyle = "attribute"; |
|||
return attrEqState; |
|||
} else if (type == "endTag" || type == "selfcloseTag") { |
|||
var tagName = state.tagName, tagStart = state.tagStart; |
|||
state.tagName = state.tagStart = null; |
|||
if (type == "selfcloseTag" || |
|||
config.autoSelfClosers.hasOwnProperty(lower(tagName))) { |
|||
maybePopContext(state, tagName); |
|||
} else { |
|||
maybePopContext(state, tagName); |
|||
state.context = new Context(state, tagName, tagStart == state.indented); |
|||
} |
|||
return baseState; |
|||
} |
|||
setStyle = "error"; |
|||
return attrState; |
|||
} |
|||
function attrEqState(type, stream, state) { |
|||
if (type == "equals") return attrValueState; |
|||
if (!config.allowMissing) setStyle = "error"; |
|||
return attrState(type, stream, state); |
|||
} |
|||
function attrValueState(type, stream, state) { |
|||
if (type == "string") return attrContinuedState; |
|||
if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;} |
|||
setStyle = "error"; |
|||
return attrState(type, stream, state); |
|||
} |
|||
function attrContinuedState(type, stream, state) { |
|||
if (type == "string") return attrContinuedState; |
|||
return attrState(type, stream, state); |
|||
} |
|||
|
|||
return { |
|||
startState: function(baseIndent) { |
|||
var state = {tokenize: inText, |
|||
state: baseState, |
|||
indented: baseIndent || 0, |
|||
tagName: null, tagStart: null, |
|||
context: null} |
|||
if (baseIndent != null) state.baseIndent = baseIndent |
|||
return state |
|||
}, |
|||
|
|||
token: function(stream, state) { |
|||
if (!state.tagName && stream.sol()) |
|||
state.indented = stream.indentation(); |
|||
|
|||
if (stream.eatSpace()) return null; |
|||
type = null; |
|||
var style = state.tokenize(stream, state); |
|||
if ((style || type) && style != "comment") { |
|||
setStyle = null; |
|||
state.state = state.state(type || style, stream, state); |
|||
if (setStyle) |
|||
style = setStyle == "error" ? style + " error" : setStyle; |
|||
} |
|||
return style; |
|||
}, |
|||
|
|||
indent: function(state, textAfter, fullLine) { |
|||
var context = state.context; |
|||
// Indent multi-line strings (e.g. css).
|
|||
if (state.tokenize.isInAttribute) { |
|||
if (state.tagStart == state.indented) |
|||
return state.stringStartCol + 1; |
|||
else |
|||
return state.indented + indentUnit; |
|||
} |
|||
if (context && context.noIndent) return CodeMirror.Pass; |
|||
if (state.tokenize != inTag && state.tokenize != inText) |
|||
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0; |
|||
// Indent the starts of attribute names.
|
|||
if (state.tagName) { |
|||
if (config.multilineTagIndentPastTag !== false) |
|||
return state.tagStart + state.tagName.length + 2; |
|||
else |
|||
return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1); |
|||
} |
|||
if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0; |
|||
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter); |
|||
if (tagAfter && tagAfter[1]) { // Closing tag spotted
|
|||
while (context) { |
|||
if (context.tagName == tagAfter[2]) { |
|||
context = context.prev; |
|||
break; |
|||
} else if (config.implicitlyClosed.hasOwnProperty(lower(context.tagName))) { |
|||
context = context.prev; |
|||
} else { |
|||
break; |
|||
} |
|||
} |
|||
} else if (tagAfter) { // Opening tag spotted
|
|||
while (context) { |
|||
var grabbers = config.contextGrabbers[lower(context.tagName)]; |
|||
if (grabbers && grabbers.hasOwnProperty(lower(tagAfter[2]))) |
|||
context = context.prev; |
|||
else |
|||
break; |
|||
} |
|||
} |
|||
while (context && context.prev && !context.startOfLine) |
|||
context = context.prev; |
|||
if (context) return context.indent + indentUnit; |
|||
else return state.baseIndent || 0; |
|||
}, |
|||
|
|||
electricInput: /<\/[\s\w:]+>$/, |
|||
blockCommentStart: "<!--", |
|||
blockCommentEnd: "-->", |
|||
|
|||
configuration: config.htmlMode ? "html" : "xml", |
|||
helperType: config.htmlMode ? "html" : "xml", |
|||
|
|||
skipAttribute: function(state) { |
|||
if (state.state == attrValueState) |
|||
state.state = attrState |
|||
}, |
|||
|
|||
xmlCurrentTag: function(state) { |
|||
return state.tagName ? {name: state.tagName, close: state.type == "closeTag"} : null |
|||
}, |
|||
|
|||
xmlCurrentContext: function(state) { |
|||
var context = [] |
|||
for (var cx = state.context; cx; cx = cx.prev) |
|||
context.push(cx.tagName) |
|||
return context.reverse() |
|||
} |
|||
}; |
|||
}); |
|||
|
|||
CodeMirror.defineMIME("text/xml", "xml"); |
|||
CodeMirror.defineMIME("application/xml", "xml"); |
|||
if (!CodeMirror.mimeModes.hasOwnProperty("text/html")) |
|||
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true}); |
|||
|
|||
}); |
|||
|
After Width: | Height: | Size: 699 KiB |
|
After Width: | Height: | Size: 141 KiB |
|
After Width: | Height: | Size: 876 KiB |
@ -0,0 +1,808 @@ |
|||
/*! jQuery UI - v1.12.1+0b7246b6eeadfa9e2696e22f3230f6452f8129dc - 2020-02-20 |
|||
* http://jqueryui.com
|
|||
* Includes: widget.js |
|||
* Copyright jQuery Foundation and other contributors; Licensed MIT */ |
|||
|
|||
/* global define, require */ |
|||
/* eslint-disable no-param-reassign, new-cap, jsdoc/require-jsdoc */ |
|||
|
|||
(function (factory) { |
|||
'use strict'; |
|||
if (typeof define === 'function' && define.amd) { |
|||
// AMD. Register as an anonymous module.
|
|||
define(['jquery'], factory); |
|||
} else if (typeof exports === 'object') { |
|||
// Node/CommonJS
|
|||
factory(require('jquery')); |
|||
} else { |
|||
// Browser globals
|
|||
factory(window.jQuery); |
|||
} |
|||
})(function ($) { |
|||
('use strict'); |
|||
|
|||
$.ui = $.ui || {}; |
|||
|
|||
$.ui.version = '1.12.1'; |
|||
|
|||
/*! |
|||
* jQuery UI Widget 1.12.1 |
|||
* http://jqueryui.com
|
|||
* |
|||
* Copyright jQuery Foundation and other contributors |
|||
* Released under the MIT license. |
|||
* http://jquery.org/license
|
|||
*/ |
|||
|
|||
//>>label: Widget
|
|||
//>>group: Core
|
|||
//>>description: Provides a factory for creating stateful widgets with a common API.
|
|||
//>>docs: http://api.jqueryui.com/jQuery.widget/
|
|||
//>>demos: http://jqueryui.com/widget/
|
|||
|
|||
// Support: jQuery 1.9.x or older
|
|||
// $.expr[ ":" ] is deprecated.
|
|||
if (!$.expr.pseudos) { |
|||
$.expr.pseudos = $.expr[':']; |
|||
} |
|||
|
|||
// Support: jQuery 1.11.x or older
|
|||
// $.unique has been renamed to $.uniqueSort
|
|||
if (!$.uniqueSort) { |
|||
$.uniqueSort = $.unique; |
|||
} |
|||
|
|||
var widgetUuid = 0; |
|||
var widgetHasOwnProperty = Array.prototype.hasOwnProperty; |
|||
var widgetSlice = Array.prototype.slice; |
|||
|
|||
$.cleanData = (function (orig) { |
|||
return function (elems) { |
|||
var events, elem, i; |
|||
// eslint-disable-next-line eqeqeq
|
|||
for (i = 0; (elem = elems[i]) != null; i++) { |
|||
// Only trigger remove when necessary to save time
|
|||
events = $._data(elem, 'events'); |
|||
if (events && events.remove) { |
|||
$(elem).triggerHandler('remove'); |
|||
} |
|||
} |
|||
orig(elems); |
|||
}; |
|||
})($.cleanData); |
|||
|
|||
$.widget = function (name, base, prototype) { |
|||
var existingConstructor, constructor, basePrototype; |
|||
|
|||
// ProxiedPrototype allows the provided prototype to remain unmodified
|
|||
// so that it can be used as a mixin for multiple widgets (#8876)
|
|||
var proxiedPrototype = {}; |
|||
|
|||
var namespace = name.split('.')[0]; |
|||
name = name.split('.')[1]; |
|||
var fullName = namespace + '-' + name; |
|||
|
|||
if (!prototype) { |
|||
prototype = base; |
|||
base = $.Widget; |
|||
} |
|||
|
|||
if ($.isArray(prototype)) { |
|||
prototype = $.extend.apply(null, [{}].concat(prototype)); |
|||
} |
|||
|
|||
// Create selector for plugin
|
|||
$.expr.pseudos[fullName.toLowerCase()] = function (elem) { |
|||
return !!$.data(elem, fullName); |
|||
}; |
|||
|
|||
$[namespace] = $[namespace] || {}; |
|||
existingConstructor = $[namespace][name]; |
|||
constructor = $[namespace][name] = function (options, element) { |
|||
// Allow instantiation without "new" keyword
|
|||
if (!this._createWidget) { |
|||
return new constructor(options, element); |
|||
} |
|||
|
|||
// Allow instantiation without initializing for simple inheritance
|
|||
// must use "new" keyword (the code above always passes args)
|
|||
if (arguments.length) { |
|||
this._createWidget(options, element); |
|||
} |
|||
}; |
|||
|
|||
// Extend with the existing constructor to carry over any static properties
|
|||
$.extend(constructor, existingConstructor, { |
|||
version: prototype.version, |
|||
|
|||
// Copy the object used to create the prototype in case we need to
|
|||
// redefine the widget later
|
|||
_proto: $.extend({}, prototype), |
|||
|
|||
// Track widgets that inherit from this widget in case this widget is
|
|||
// redefined after a widget inherits from it
|
|||
_childConstructors: [] |
|||
}); |
|||
|
|||
basePrototype = new base(); |
|||
|
|||
// We need to make the options hash a property directly on the new instance
|
|||
// otherwise we'll modify the options hash on the prototype that we're
|
|||
// inheriting from
|
|||
basePrototype.options = $.widget.extend({}, basePrototype.options); |
|||
$.each(prototype, function (prop, value) { |
|||
if (!$.isFunction(value)) { |
|||
proxiedPrototype[prop] = value; |
|||
return; |
|||
} |
|||
proxiedPrototype[prop] = (function () { |
|||
function _super() { |
|||
return base.prototype[prop].apply(this, arguments); |
|||
} |
|||
|
|||
function _superApply(args) { |
|||
return base.prototype[prop].apply(this, args); |
|||
} |
|||
|
|||
return function () { |
|||
var __super = this._super; |
|||
var __superApply = this._superApply; |
|||
var returnValue; |
|||
|
|||
this._super = _super; |
|||
this._superApply = _superApply; |
|||
|
|||
returnValue = value.apply(this, arguments); |
|||
|
|||
this._super = __super; |
|||
this._superApply = __superApply; |
|||
|
|||
return returnValue; |
|||
}; |
|||
})(); |
|||
}); |
|||
constructor.prototype = $.widget.extend( |
|||
basePrototype, |
|||
{ |
|||
// TODO: remove support for widgetEventPrefix
|
|||
// always use the name + a colon as the prefix, e.g., draggable:start
|
|||
// don't prefix for widgets that aren't DOM-based
|
|||
widgetEventPrefix: existingConstructor |
|||
? basePrototype.widgetEventPrefix || name |
|||
: name |
|||
}, |
|||
proxiedPrototype, |
|||
{ |
|||
constructor: constructor, |
|||
namespace: namespace, |
|||
widgetName: name, |
|||
widgetFullName: fullName |
|||
} |
|||
); |
|||
|
|||
// If this widget is being redefined then we need to find all widgets that
|
|||
// are inheriting from it and redefine all of them so that they inherit from
|
|||
// the new version of this widget. We're essentially trying to replace one
|
|||
// level in the prototype chain.
|
|||
if (existingConstructor) { |
|||
$.each(existingConstructor._childConstructors, function (i, child) { |
|||
var childPrototype = child.prototype; |
|||
|
|||
// Redefine the child widget using the same prototype that was
|
|||
// originally used, but inherit from the new version of the base
|
|||
$.widget( |
|||
childPrototype.namespace + '.' + childPrototype.widgetName, |
|||
constructor, |
|||
child._proto |
|||
); |
|||
}); |
|||
|
|||
// Remove the list of existing child constructors from the old constructor
|
|||
// so the old child constructors can be garbage collected
|
|||
delete existingConstructor._childConstructors; |
|||
} else { |
|||
base._childConstructors.push(constructor); |
|||
} |
|||
|
|||
$.widget.bridge(name, constructor); |
|||
|
|||
return constructor; |
|||
}; |
|||
|
|||
$.widget.extend = function (target) { |
|||
var input = widgetSlice.call(arguments, 1); |
|||
var inputIndex = 0; |
|||
var inputLength = input.length; |
|||
var key; |
|||
var value; |
|||
|
|||
for (; inputIndex < inputLength; inputIndex++) { |
|||
for (key in input[inputIndex]) { |
|||
value = input[inputIndex][key]; |
|||
if ( |
|||
widgetHasOwnProperty.call(input[inputIndex], key) && |
|||
value !== undefined |
|||
) { |
|||
// Clone objects
|
|||
if ($.isPlainObject(value)) { |
|||
target[key] = $.isPlainObject(target[key]) |
|||
? $.widget.extend({}, target[key], value) |
|||
: // Don't extend strings, arrays, etc. with objects
|
|||
$.widget.extend({}, value); |
|||
|
|||
// Copy everything else by reference
|
|||
} else { |
|||
target[key] = value; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
return target; |
|||
}; |
|||
|
|||
$.widget.bridge = function (name, object) { |
|||
var fullName = object.prototype.widgetFullName || name; |
|||
$.fn[name] = function (options) { |
|||
var isMethodCall = typeof options === 'string'; |
|||
var args = widgetSlice.call(arguments, 1); |
|||
var returnValue = this; |
|||
|
|||
if (isMethodCall) { |
|||
// If this is an empty collection, we need to have the instance method
|
|||
// return undefined instead of the jQuery instance
|
|||
if (!this.length && options === 'instance') { |
|||
returnValue = undefined; |
|||
} else { |
|||
this.each(function () { |
|||
var methodValue; |
|||
var instance = $.data(this, fullName); |
|||
|
|||
if (options === 'instance') { |
|||
returnValue = instance; |
|||
return false; |
|||
} |
|||
|
|||
if (!instance) { |
|||
return $.error( |
|||
'cannot call methods on ' + |
|||
name + |
|||
' prior to initialization; ' + |
|||
"attempted to call method '" + |
|||
options + |
|||
"'" |
|||
); |
|||
} |
|||
|
|||
if (!$.isFunction(instance[options]) || options.charAt(0) === '_') { |
|||
return $.error( |
|||
"no such method '" + |
|||
options + |
|||
"' for " + |
|||
name + |
|||
' widget instance' |
|||
); |
|||
} |
|||
|
|||
methodValue = instance[options].apply(instance, args); |
|||
|
|||
if (methodValue !== instance && methodValue !== undefined) { |
|||
returnValue = |
|||
methodValue && methodValue.jquery |
|||
? returnValue.pushStack(methodValue.get()) |
|||
: methodValue; |
|||
return false; |
|||
} |
|||
}); |
|||
} |
|||
} else { |
|||
// Allow multiple hashes to be passed on init
|
|||
if (args.length) { |
|||
options = $.widget.extend.apply(null, [options].concat(args)); |
|||
} |
|||
|
|||
this.each(function () { |
|||
var instance = $.data(this, fullName); |
|||
if (instance) { |
|||
instance.option(options || {}); |
|||
if (instance._init) { |
|||
instance._init(); |
|||
} |
|||
} else { |
|||
$.data(this, fullName, new object(options, this)); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
return returnValue; |
|||
}; |
|||
}; |
|||
|
|||
$.Widget = function (/* options, element */) {}; |
|||
$.Widget._childConstructors = []; |
|||
|
|||
$.Widget.prototype = { |
|||
widgetName: 'widget', |
|||
widgetEventPrefix: '', |
|||
defaultElement: '<div>', |
|||
|
|||
options: { |
|||
classes: {}, |
|||
disabled: false, |
|||
|
|||
// Callbacks
|
|||
create: null |
|||
}, |
|||
|
|||
_createWidget: function (options, element) { |
|||
element = $(element || this.defaultElement || this)[0]; |
|||
this.element = $(element); |
|||
this.uuid = widgetUuid++; |
|||
this.eventNamespace = '.' + this.widgetName + this.uuid; |
|||
|
|||
this.bindings = $(); |
|||
this.hoverable = $(); |
|||
this.focusable = $(); |
|||
this.classesElementLookup = {}; |
|||
|
|||
if (element !== this) { |
|||
$.data(element, this.widgetFullName, this); |
|||
this._on(true, this.element, { |
|||
remove: function (event) { |
|||
if (event.target === element) { |
|||
this.destroy(); |
|||
} |
|||
} |
|||
}); |
|||
this.document = $( |
|||
element.style |
|||
? // Element within the document
|
|||
element.ownerDocument |
|||
: // Element is window or document
|
|||
element.document || element |
|||
); |
|||
this.window = $( |
|||
this.document[0].defaultView || this.document[0].parentWindow |
|||
); |
|||
} |
|||
|
|||
this.options = $.widget.extend( |
|||
{}, |
|||
this.options, |
|||
this._getCreateOptions(), |
|||
options |
|||
); |
|||
|
|||
this._create(); |
|||
|
|||
if (this.options.disabled) { |
|||
this._setOptionDisabled(this.options.disabled); |
|||
} |
|||
|
|||
this._trigger('create', null, this._getCreateEventData()); |
|||
this._init(); |
|||
}, |
|||
|
|||
_getCreateOptions: function () { |
|||
return {}; |
|||
}, |
|||
|
|||
_getCreateEventData: $.noop, |
|||
|
|||
_create: $.noop, |
|||
|
|||
_init: $.noop, |
|||
|
|||
destroy: function () { |
|||
var that = this; |
|||
|
|||
this._destroy(); |
|||
$.each(this.classesElementLookup, function (key, value) { |
|||
that._removeClass(value, key); |
|||
}); |
|||
|
|||
// We can probably remove the unbind calls in 2.0
|
|||
// all event bindings should go through this._on()
|
|||
this.element.off(this.eventNamespace).removeData(this.widgetFullName); |
|||
this.widget().off(this.eventNamespace).removeAttr('aria-disabled'); |
|||
|
|||
// Clean up events and states
|
|||
this.bindings.off(this.eventNamespace); |
|||
}, |
|||
|
|||
_destroy: $.noop, |
|||
|
|||
widget: function () { |
|||
return this.element; |
|||
}, |
|||
|
|||
option: function (key, value) { |
|||
var options = key; |
|||
var parts; |
|||
var curOption; |
|||
var i; |
|||
|
|||
if (arguments.length === 0) { |
|||
// Don't return a reference to the internal hash
|
|||
return $.widget.extend({}, this.options); |
|||
} |
|||
|
|||
if (typeof key === 'string') { |
|||
// Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
|
|||
options = {}; |
|||
parts = key.split('.'); |
|||
key = parts.shift(); |
|||
if (parts.length) { |
|||
curOption = options[key] = $.widget.extend({}, this.options[key]); |
|||
for (i = 0; i < parts.length - 1; i++) { |
|||
curOption[parts[i]] = curOption[parts[i]] || {}; |
|||
curOption = curOption[parts[i]]; |
|||
} |
|||
key = parts.pop(); |
|||
if (arguments.length === 1) { |
|||
return curOption[key] === undefined ? null : curOption[key]; |
|||
} |
|||
curOption[key] = value; |
|||
} else { |
|||
if (arguments.length === 1) { |
|||
return this.options[key] === undefined ? null : this.options[key]; |
|||
} |
|||
options[key] = value; |
|||
} |
|||
} |
|||
|
|||
this._setOptions(options); |
|||
|
|||
return this; |
|||
}, |
|||
|
|||
_setOptions: function (options) { |
|||
var key; |
|||
|
|||
for (key in options) { |
|||
this._setOption(key, options[key]); |
|||
} |
|||
|
|||
return this; |
|||
}, |
|||
|
|||
_setOption: function (key, value) { |
|||
if (key === 'classes') { |
|||
this._setOptionClasses(value); |
|||
} |
|||
|
|||
this.options[key] = value; |
|||
|
|||
if (key === 'disabled') { |
|||
this._setOptionDisabled(value); |
|||
} |
|||
|
|||
return this; |
|||
}, |
|||
|
|||
_setOptionClasses: function (value) { |
|||
var classKey, elements, currentElements; |
|||
|
|||
for (classKey in value) { |
|||
currentElements = this.classesElementLookup[classKey]; |
|||
if ( |
|||
value[classKey] === this.options.classes[classKey] || |
|||
!currentElements || |
|||
!currentElements.length |
|||
) { |
|||
continue; |
|||
} |
|||
|
|||
// We are doing this to create a new jQuery object because the _removeClass() call
|
|||
// on the next line is going to destroy the reference to the current elements being
|
|||
// tracked. We need to save a copy of this collection so that we can add the new classes
|
|||
// below.
|
|||
elements = $(currentElements.get()); |
|||
this._removeClass(currentElements, classKey); |
|||
|
|||
// We don't use _addClass() here, because that uses this.options.classes
|
|||
// for generating the string of classes. We want to use the value passed in from
|
|||
// _setOption(), this is the new value of the classes option which was passed to
|
|||
// _setOption(). We pass this value directly to _classes().
|
|||
elements.addClass( |
|||
this._classes({ |
|||
element: elements, |
|||
keys: classKey, |
|||
classes: value, |
|||
add: true |
|||
}) |
|||
); |
|||
} |
|||
}, |
|||
|
|||
_setOptionDisabled: function (value) { |
|||
this._toggleClass( |
|||
this.widget(), |
|||
this.widgetFullName + '-disabled', |
|||
null, |
|||
!!value |
|||
); |
|||
|
|||
// If the widget is becoming disabled, then nothing is interactive
|
|||
if (value) { |
|||
this._removeClass(this.hoverable, null, 'ui-state-hover'); |
|||
this._removeClass(this.focusable, null, 'ui-state-focus'); |
|||
} |
|||
}, |
|||
|
|||
enable: function () { |
|||
return this._setOptions({ disabled: false }); |
|||
}, |
|||
|
|||
disable: function () { |
|||
return this._setOptions({ disabled: true }); |
|||
}, |
|||
|
|||
_classes: function (options) { |
|||
var full = []; |
|||
var that = this; |
|||
|
|||
options = $.extend( |
|||
{ |
|||
element: this.element, |
|||
classes: this.options.classes || {} |
|||
}, |
|||
options |
|||
); |
|||
|
|||
function bindRemoveEvent() { |
|||
options.element.each(function (_, element) { |
|||
var isTracked = $.map(that.classesElementLookup, function (elements) { |
|||
return elements; |
|||
}).some(function (elements) { |
|||
return elements.is(element); |
|||
}); |
|||
|
|||
if (!isTracked) { |
|||
that._on($(element), { |
|||
remove: '_untrackClassesElement' |
|||
}); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
function processClassString(classes, checkOption) { |
|||
var current, i; |
|||
for (i = 0; i < classes.length; i++) { |
|||
current = that.classesElementLookup[classes[i]] || $(); |
|||
if (options.add) { |
|||
bindRemoveEvent(); |
|||
current = $( |
|||
$.uniqueSort(current.get().concat(options.element.get())) |
|||
); |
|||
} else { |
|||
current = $(current.not(options.element).get()); |
|||
} |
|||
that.classesElementLookup[classes[i]] = current; |
|||
full.push(classes[i]); |
|||
if (checkOption && options.classes[classes[i]]) { |
|||
full.push(options.classes[classes[i]]); |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (options.keys) { |
|||
processClassString(options.keys.match(/\S+/g) || [], true); |
|||
} |
|||
if (options.extra) { |
|||
processClassString(options.extra.match(/\S+/g) || []); |
|||
} |
|||
|
|||
return full.join(' '); |
|||
}, |
|||
|
|||
_untrackClassesElement: function (event) { |
|||
var that = this; |
|||
$.each(that.classesElementLookup, function (key, value) { |
|||
if ($.inArray(event.target, value) !== -1) { |
|||
that.classesElementLookup[key] = $(value.not(event.target).get()); |
|||
} |
|||
}); |
|||
|
|||
this._off($(event.target)); |
|||
}, |
|||
|
|||
_removeClass: function (element, keys, extra) { |
|||
return this._toggleClass(element, keys, extra, false); |
|||
}, |
|||
|
|||
_addClass: function (element, keys, extra) { |
|||
return this._toggleClass(element, keys, extra, true); |
|||
}, |
|||
|
|||
_toggleClass: function (element, keys, extra, add) { |
|||
add = typeof add === 'boolean' ? add : extra; |
|||
var shift = typeof element === 'string' || element === null, |
|||
options = { |
|||
extra: shift ? keys : extra, |
|||
keys: shift ? element : keys, |
|||
element: shift ? this.element : element, |
|||
add: add |
|||
}; |
|||
options.element.toggleClass(this._classes(options), add); |
|||
return this; |
|||
}, |
|||
|
|||
_on: function (suppressDisabledCheck, element, handlers) { |
|||
var delegateElement; |
|||
var instance = this; |
|||
|
|||
// No suppressDisabledCheck flag, shuffle arguments
|
|||
if (typeof suppressDisabledCheck !== 'boolean') { |
|||
handlers = element; |
|||
element = suppressDisabledCheck; |
|||
suppressDisabledCheck = false; |
|||
} |
|||
|
|||
// No element argument, shuffle and use this.element
|
|||
if (!handlers) { |
|||
handlers = element; |
|||
element = this.element; |
|||
delegateElement = this.widget(); |
|||
} else { |
|||
element = delegateElement = $(element); |
|||
this.bindings = this.bindings.add(element); |
|||
} |
|||
|
|||
$.each(handlers, function (event, handler) { |
|||
function handlerProxy() { |
|||
// Allow widgets to customize the disabled handling
|
|||
// - disabled as an array instead of boolean
|
|||
// - disabled class as method for disabling individual parts
|
|||
if ( |
|||
!suppressDisabledCheck && |
|||
(instance.options.disabled === true || |
|||
$(this).hasClass('ui-state-disabled')) |
|||
) { |
|||
return; |
|||
} |
|||
return (typeof handler === 'string' |
|||
? instance[handler] |
|||
: handler |
|||
).apply(instance, arguments); |
|||
} |
|||
|
|||
// Copy the guid so direct unbinding works
|
|||
if (typeof handler !== 'string') { |
|||
handlerProxy.guid = handler.guid = |
|||
handler.guid || handlerProxy.guid || $.guid++; |
|||
} |
|||
|
|||
var match = event.match(/^([\w:-]*)\s*(.*)$/); |
|||
var eventName = match[1] + instance.eventNamespace; |
|||
var selector = match[2]; |
|||
|
|||
if (selector) { |
|||
delegateElement.on(eventName, selector, handlerProxy); |
|||
} else { |
|||
element.on(eventName, handlerProxy); |
|||
} |
|||
}); |
|||
}, |
|||
|
|||
_off: function (element, eventName) { |
|||
eventName = |
|||
(eventName || '').split(' ').join(this.eventNamespace + ' ') + |
|||
this.eventNamespace; |
|||
element.off(eventName); |
|||
|
|||
// Clear the stack to avoid memory leaks (#10056)
|
|||
this.bindings = $(this.bindings.not(element).get()); |
|||
this.focusable = $(this.focusable.not(element).get()); |
|||
this.hoverable = $(this.hoverable.not(element).get()); |
|||
}, |
|||
|
|||
_delay: function (handler, delay) { |
|||
var instance = this; |
|||
function handlerProxy() { |
|||
return (typeof handler === 'string' |
|||
? instance[handler] |
|||
: handler |
|||
).apply(instance, arguments); |
|||
} |
|||
return setTimeout(handlerProxy, delay || 0); |
|||
}, |
|||
|
|||
_hoverable: function (element) { |
|||
this.hoverable = this.hoverable.add(element); |
|||
this._on(element, { |
|||
mouseenter: function (event) { |
|||
this._addClass($(event.currentTarget), null, 'ui-state-hover'); |
|||
}, |
|||
mouseleave: function (event) { |
|||
this._removeClass($(event.currentTarget), null, 'ui-state-hover'); |
|||
} |
|||
}); |
|||
}, |
|||
|
|||
_focusable: function (element) { |
|||
this.focusable = this.focusable.add(element); |
|||
this._on(element, { |
|||
focusin: function (event) { |
|||
this._addClass($(event.currentTarget), null, 'ui-state-focus'); |
|||
}, |
|||
focusout: function (event) { |
|||
this._removeClass($(event.currentTarget), null, 'ui-state-focus'); |
|||
} |
|||
}); |
|||
}, |
|||
|
|||
_trigger: function (type, event, data) { |
|||
var prop, orig; |
|||
var callback = this.options[type]; |
|||
|
|||
data = data || {}; |
|||
event = $.Event(event); |
|||
event.type = (type === this.widgetEventPrefix |
|||
? type |
|||
: this.widgetEventPrefix + type |
|||
).toLowerCase(); |
|||
|
|||
// The original event may come from any element
|
|||
// so we need to reset the target on the new event
|
|||
event.target = this.element[0]; |
|||
|
|||
// Copy original event properties over to the new event
|
|||
orig = event.originalEvent; |
|||
if (orig) { |
|||
for (prop in orig) { |
|||
if (!(prop in event)) { |
|||
event[prop] = orig[prop]; |
|||
} |
|||
} |
|||
} |
|||
|
|||
this.element.trigger(event, data); |
|||
return !( |
|||
($.isFunction(callback) && |
|||
callback.apply(this.element[0], [event].concat(data)) === false) || |
|||
event.isDefaultPrevented() |
|||
); |
|||
} |
|||
}; |
|||
|
|||
$.each({ show: 'fadeIn', hide: 'fadeOut' }, function (method, defaultEffect) { |
|||
$.Widget.prototype['_' + method] = function (element, options, callback) { |
|||
if (typeof options === 'string') { |
|||
options = { effect: options }; |
|||
} |
|||
|
|||
var hasOptions; |
|||
var effectName = !options |
|||
? method |
|||
: options === true || typeof options === 'number' |
|||
? defaultEffect |
|||
: options.effect || defaultEffect; |
|||
|
|||
options = options || {}; |
|||
if (typeof options === 'number') { |
|||
options = { duration: options }; |
|||
} |
|||
|
|||
hasOptions = !$.isEmptyObject(options); |
|||
options.complete = callback; |
|||
|
|||
if (options.delay) { |
|||
element.delay(options.delay); |
|||
} |
|||
|
|||
if (hasOptions && $.effects && $.effects.effect[effectName]) { |
|||
element[method](options); |
|||
} else if (effectName !== method && element[effectName]) { |
|||
element[effectName](options.duration, options.easing, callback); |
|||
} else { |
|||
element.queue(function (next) { |
|||
$(this)[method](); |
|||
if (callback) { |
|||
callback.call(element[0]); |
|||
} |
|||
next(); |
|||
}); |
|||
} |
|||
}; |
|||
}); |
|||
}); |
|||
@ -0,0 +1,6 @@ |
|||
/*! jQuery UI - v1.13.2 - 2022-08-31 |
|||
* http://jqueryui.com |
|||
* Includes: sortable.css |
|||
* Copyright jQuery Foundation and other contributors; Licensed MIT */ |
|||
|
|||
.ui-sortable-handle{-ms-touch-action:none;touch-action:none} |
|||
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 3.0 KiB |