diff --git a/app/assets/javascripts/bootstrap-notify.js b/app/assets/javascripts/bootstrap-notify.js old mode 100755 new mode 100644 diff --git a/app/assets/javascripts/bootstrap-notify.min.js b/app/assets/javascripts/bootstrap-notify.min.js old mode 100755 new mode 100644 diff --git a/app/assets/javascripts/i18n/select2-i18n.zh-CN.js b/app/assets/javascripts/i18n/select2-i18n.zh-CN.js old mode 100755 new mode 100644 diff --git a/app/assets/javascripts/jquery.cxselect.js b/app/assets/javascripts/jquery.cxselect.js old mode 100755 new mode 100644 index 9bd674664..aeb3c17dd --- a/app/assets/javascripts/jquery.cxselect.js +++ b/app/assets/javascripts/jquery.cxselect.js @@ -1,403 +1,403 @@ -/*! - * jQuery cxSelect - * @name jquery.cxselect.js - * @version 1.4.1 - * @date 2016-11-02 - * @author ciaoca - * @email ciaoca@gmail.com - * @site https://github.com/ciaoca/cxSelect - * @license Released under the MIT license - */ -(function(factory) { - if (typeof define === 'function' && define.amd) { - define(['jquery'], factory); - } else { - factory(window.jQuery || window.Zepto || window.$); - }; -}(function($) { - var cxSelect = function() { - var self = this; - var dom, settings, callback; - - // 分配参数 - for (var i = 0, l = arguments.length; i < l; i++) { - if (cxSelect.isJquery(arguments[i]) || cxSelect.isZepto(arguments[i])) { - dom = arguments[i]; - } else if (cxSelect.isElement(arguments[i])) { - dom = $(arguments[i]); - } else if (typeof arguments[i] === 'function') { - callback = arguments[i]; - } else if (typeof arguments[i] === 'object') { - settings = arguments[i]; - }; - }; - - var api = new cxSelect.init(dom, settings); - - if (typeof callback === 'function') { - callback(api); - }; - - return api; - }; - - cxSelect.isElement = function(o){ - if (o && (typeof HTMLElement === 'function' || typeof HTMLElement === 'object') && o instanceof HTMLElement) { - return true; - } else { - return (o && o.nodeType && o.nodeType === 1) ? true : false; - }; - }; - - cxSelect.isJquery = function(o){ - return (o && o.length && (typeof jQuery === 'function' || typeof jQuery === 'object') && o instanceof jQuery) ? true : false; - }; - - cxSelect.isZepto = function(o){ - return (o && o.length && (typeof Zepto === 'function' || typeof Zepto === 'object') && Zepto.zepto.isZ(o)) ? true : false; - }; - - cxSelect.getIndex = function(n, required) { - return required ? n : n - 1; - }; - - cxSelect.getData = function(data, space) { - if (typeof space === 'string' && space.length) { - space = space.split('.'); - for (var i = 0, l = space.length; i < l; i++) { - data = data[space[i]]; - }; - }; - return data; - }; - - cxSelect.init = function(dom, settings) { - var self = this; - - if (!cxSelect.isJquery(dom) && !cxSelect.isZepto(dom)) {return}; - - var theSelect = { - dom: { - box: dom - } - }; - - self.attach = cxSelect.attach.bind(theSelect); - self.detach = cxSelect.detach.bind(theSelect); - self.setOptions = cxSelect.setOptions.bind(theSelect); - self.clear = cxSelect.clear.bind(theSelect); - - theSelect.changeEvent = function() { - cxSelect.selectChange.call(theSelect, this.className); - }; - - theSelect.settings = $.extend({}, $.cxSelect.defaults, settings, { - url: theSelect.dom.box.data('url'), - emptyStyle: theSelect.dom.box.data('emptyStyle'), - required: theSelect.dom.box.data('required'), - firstTitle: theSelect.dom.box.data('firstTitle'), - firstValue: theSelect.dom.box.data('firstValue'), - jsonSpace: theSelect.dom.box.data('jsonSpace'), - jsonName: theSelect.dom.box.data('jsonName'), - jsonValue: theSelect.dom.box.data('jsonValue'), - jsonSub: theSelect.dom.box.data('jsonSub') - }); - - var _dataSelects = theSelect.dom.box.data('selects'); - - if (typeof _dataSelects === 'string' && _dataSelects.length) { - theSelect.settings.selects = _dataSelects.split(','); - }; - - self.setOptions(); - self.attach(); - - // 使用独立接口获取数据 - if (!theSelect.settings.url && !theSelect.settings.data) { - cxSelect.start.apply(theSelect); - - // 设置自定义数据 - } else if ($.isArray(theSelect.settings.data)) { - cxSelect.start.call(theSelect, theSelect.settings.data); - - // 设置 URL,通过 Ajax 获取数据 - } else if (typeof theSelect.settings.url === 'string' && theSelect.settings.url.length) { - $.getJSON(theSelect.settings.url, function(json) { - cxSelect.start.call(theSelect, json); - }); - }; - }; - - // 设置参数 - cxSelect.setOptions = function(opts) { - var self = this; - - if (opts) { - $.extend(self.settings, opts); - }; - - // 初次或重设选择器组 - if (!$.isArray(self.selectArray) || !self.selectArray.length || (opts && opts.selects)) { - self.selectArray = []; - - if ($.isArray(self.settings.selects) && self.settings.selects.length) { - var _tempSelect; - - for (var i = 0, l = self.settings.selects.length; i < l; i++) { - _tempSelect = self.dom.box.find('select.' + self.settings.selects[i]); - - if (!_tempSelect || !_tempSelect.length) {break}; - - self.selectArray.push(_tempSelect); - }; - }; - }; - - if (opts) { - if (!$.isArray(opts.data) && typeof opts.url === 'string' && opts.url.length) { - $.getJSON(self.settings.url, function(json) { - cxSelect.start.call(self, json); - }); - - } else { - cxSelect.start.call(self, opts.data); - }; - }; - }; - - // 绑定 - cxSelect.attach = function() { - var self = this; - - if (!self.attachStatus) { - self.dom.box.on('change', 'select', self.changeEvent); - }; - - if (typeof self.attachStatus === 'boolean') { - cxSelect.start.call(self); - }; - - self.attachStatus = true; - }; - - // 移除绑定 - cxSelect.detach = function() { - var self = this; - self.dom.box.off('change', 'select', self.changeEvent); - self.attachStatus = false; - }; - - // 清空选项 - cxSelect.clear = function(index) { - var self = this; - var _style = { - display: '', - visibility: '' - }; - - index = isNaN(index) ? 0 : index; - - // 清空后面的 select - for (var i = index, l = self.selectArray.length; i < l; i++) { - self.selectArray[i].empty().prop('disabled', true); - - if (self.settings.emptyStyle === 'none') { - _style.display = 'none'; - } else if (self.settings.emptyStyle === 'hidden') { - _style.visibility = 'hidden'; - }; - - self.selectArray[i].css(_style); - }; - }; - - cxSelect.start = function(data) { - var self = this; - - if ($.isArray(data)) { - self.settings.data = cxSelect.getData(data, self.settings.jsonSpace); - }; - - if (!self.selectArray.length) {return}; - - // 保存默认值 - for (var i = 0, l = self.selectArray.length; i < l; i++) { - if (typeof self.selectArray[i].attr('data-value') !== 'string' && self.selectArray[i][0].options.length) { - self.selectArray[i].attr('data-value', self.selectArray[i].val()); - }; - }; - - if (self.settings.data || (typeof self.selectArray[0].data('url') === 'string' && self.selectArray[0].data('url').length)) { - cxSelect.getOptionData.call(self, 0); - } else { - self.selectArray[0].prop('disabled', false).css({ - 'display': '', - 'visibility': '' - }); - }; - }; - - // 获取选项数据 - cxSelect.getOptionData = function(index) { - var self = this; - - if (typeof index !== 'number' || isNaN(index) || index < 0 || index >= self.selectArray.length) {return}; - - var _indexPrev = index - 1; - var _select = self.selectArray[index]; - var _selectData; - var _valueIndex; - var _dataUrl = _select.data('url'); - var _jsonSpace = typeof _select.data('jsonSpace') === 'undefined' ? self.settings.jsonSpace : _select.data('jsonSpace'); - var _query = {}; - var _queryName; - var _selectName; - var _selectValue; - - cxSelect.clear.call(self, index); - - // 使用独立接口 - if (typeof _dataUrl === 'string' && _dataUrl.length) { - if (index > 0) { - for (var i = 0, j = 1; i < index; i++, j++) { - _queryName = self.selectArray[j].data('queryName'); - _selectName = self.selectArray[i].attr('name'); - _selectValue = self.selectArray[i].val(); - - if (typeof _queryName === 'string' && _queryName.length) { - _query[_queryName] = _selectValue; - } else if (typeof _selectName === 'string' && _selectName.length) { - _query[_selectName] = _selectValue; - }; - }; - }; - - $.getJSON(_dataUrl, _query, function(json) { - _selectData = cxSelect.getData(json, _jsonSpace); - - cxSelect.buildOption.call(self, index, _selectData); - }); - - // 使用整合数据 - } else if (self.settings.data && typeof self.settings.data === 'object') { - _selectData = self.settings.data; - - for (var i = 0; i < index; i++) { - _valueIndex = cxSelect.getIndex(self.selectArray[i][0].selectedIndex, typeof self.selectArray[i].data('required') === 'boolean' ? self.selectArray[i].data('required') : self.settings.required); - - if (typeof _selectData[_valueIndex] === 'object' && $.isArray(_selectData[_valueIndex][self.settings.jsonSub]) && _selectData[_valueIndex][self.settings.jsonSub].length) { - _selectData = _selectData[_valueIndex][self.settings.jsonSub]; - } else { - _selectData = null; - break; - }; - }; - - cxSelect.buildOption.call(self, index, _selectData); - }; - }; - - // 构建选项列表 - cxSelect.buildOption = function(index, data) { - var self = this; - - var _select = self.selectArray[index]; - var _required = typeof _select.data('required') === 'boolean' ? _select.data('required') : self.settings.required; - var _firstTitle = typeof _select.data('firstTitle') === 'undefined' ? self.settings.firstTitle : _select.data('firstTitle'); - var _firstValue = typeof _select.data('firstValue') === 'undefined' ? self.settings.firstValue : _select.data('firstValue'); - var _jsonName = typeof _select.data('jsonName') === 'undefined' ? self.settings.jsonName : _select.data('jsonName'); - var _jsonValue = typeof _select.data('jsonValue') === 'undefined' ? self.settings.jsonValue : _select.data('jsonValue'); - - if (!$.isArray(data)) {return}; - - var _html = !_required ? '' : ''; - - // 区分标题、值的数据 - if (typeof _jsonName === 'string' && _jsonName.length) { - // 无值字段时使用标题作为值 - if (typeof _jsonValue !== 'string' || !_jsonValue.length) { - _jsonValue = _jsonName; - }; - - for (var i = 0, l = data.length; i < l; i++) { - _html += ''; - }; - - // 数组即为值的数据 - } else { - for (var i = 0, l = data.length; i < l; i++) { - _html += ''; - }; - }; - - _select.html(_html).prop('disabled', false).css({ - 'display': '', - 'visibility': '' - }); - - // 初次加载设置默认值 - if (typeof _select.attr('data-value') === 'string') { - _select.val(String(_select.attr('data-value'))).removeAttr('data-value'); - - if (_select[0].selectedIndex < 0) { - _select[0].options[0].selected = true; - }; - }; - - if (_required || _select[0].selectedIndex > 0) { - _select.trigger('change'); - }; - - }; - - // 改变选择时的处理 - cxSelect.selectChange = function(name) { - var self = this; - - if (typeof name !== 'string' || !name.length) {return}; - - var index; - - name = name.replace(/\s+/g, ','); - name = ',' + name + ','; - - // 获取当前 select 位置 - for (var i = 0, l = self.selectArray.length; i < l; i++) { - if (name.indexOf(',' + self.settings.selects[i] + ',') > -1) { - index = i; - break; - }; - }; - - if (typeof index === 'number' && index > -1) { - index += 1; - cxSelect.getOptionData.call(self, index); - }; - }; - - $.cxSelect = function() { - return cxSelect.apply(this, arguments); - }; - - // 默认值 - $.cxSelect.defaults = { - selects: [], // 下拉选框组 - url: null, // 列表数据文件路径(URL)或数组数据 - data: null, // 自定义数据 - emptyStyle: null, // 无数据状态显示方式 - required: false, // 是否为必选 - firstTitle: '请选择', // 第一个选项的标题 - firstValue: '', // 第一个选项的值 - jsonSpace: '', // 数据命名空间 - jsonName: 'n', // 数据标题字段名称 - jsonValue: '', // 数据值字段名称 - jsonSub: 's' // 子集数据字段名称 - }; - - $.fn.cxSelect = function(settings, callback) { - this.each(function(i) { - $.cxSelect(this, settings, callback); - }); - return this; - }; -})); +/*! + * jQuery cxSelect + * @name jquery.cxselect.js + * @version 1.4.1 + * @date 2016-11-02 + * @author ciaoca + * @email ciaoca@gmail.com + * @site https://github.com/ciaoca/cxSelect + * @license Released under the MIT license + */ +(function(factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], factory); + } else { + factory(window.jQuery || window.Zepto || window.$); + }; +}(function($) { + var cxSelect = function() { + var self = this; + var dom, settings, callback; + + // 分配参数 + for (var i = 0, l = arguments.length; i < l; i++) { + if (cxSelect.isJquery(arguments[i]) || cxSelect.isZepto(arguments[i])) { + dom = arguments[i]; + } else if (cxSelect.isElement(arguments[i])) { + dom = $(arguments[i]); + } else if (typeof arguments[i] === 'function') { + callback = arguments[i]; + } else if (typeof arguments[i] === 'object') { + settings = arguments[i]; + }; + }; + + var api = new cxSelect.init(dom, settings); + + if (typeof callback === 'function') { + callback(api); + }; + + return api; + }; + + cxSelect.isElement = function(o){ + if (o && (typeof HTMLElement === 'function' || typeof HTMLElement === 'object') && o instanceof HTMLElement) { + return true; + } else { + return (o && o.nodeType && o.nodeType === 1) ? true : false; + }; + }; + + cxSelect.isJquery = function(o){ + return (o && o.length && (typeof jQuery === 'function' || typeof jQuery === 'object') && o instanceof jQuery) ? true : false; + }; + + cxSelect.isZepto = function(o){ + return (o && o.length && (typeof Zepto === 'function' || typeof Zepto === 'object') && Zepto.zepto.isZ(o)) ? true : false; + }; + + cxSelect.getIndex = function(n, required) { + return required ? n : n - 1; + }; + + cxSelect.getData = function(data, space) { + if (typeof space === 'string' && space.length) { + space = space.split('.'); + for (var i = 0, l = space.length; i < l; i++) { + data = data[space[i]]; + }; + }; + return data; + }; + + cxSelect.init = function(dom, settings) { + var self = this; + + if (!cxSelect.isJquery(dom) && !cxSelect.isZepto(dom)) {return}; + + var theSelect = { + dom: { + box: dom + } + }; + + self.attach = cxSelect.attach.bind(theSelect); + self.detach = cxSelect.detach.bind(theSelect); + self.setOptions = cxSelect.setOptions.bind(theSelect); + self.clear = cxSelect.clear.bind(theSelect); + + theSelect.changeEvent = function() { + cxSelect.selectChange.call(theSelect, this.className); + }; + + theSelect.settings = $.extend({}, $.cxSelect.defaults, settings, { + url: theSelect.dom.box.data('url'), + emptyStyle: theSelect.dom.box.data('emptyStyle'), + required: theSelect.dom.box.data('required'), + firstTitle: theSelect.dom.box.data('firstTitle'), + firstValue: theSelect.dom.box.data('firstValue'), + jsonSpace: theSelect.dom.box.data('jsonSpace'), + jsonName: theSelect.dom.box.data('jsonName'), + jsonValue: theSelect.dom.box.data('jsonValue'), + jsonSub: theSelect.dom.box.data('jsonSub') + }); + + var _dataSelects = theSelect.dom.box.data('selects'); + + if (typeof _dataSelects === 'string' && _dataSelects.length) { + theSelect.settings.selects = _dataSelects.split(','); + }; + + self.setOptions(); + self.attach(); + + // 使用独立接口获取数据 + if (!theSelect.settings.url && !theSelect.settings.data) { + cxSelect.start.apply(theSelect); + + // 设置自定义数据 + } else if ($.isArray(theSelect.settings.data)) { + cxSelect.start.call(theSelect, theSelect.settings.data); + + // 设置 URL,通过 Ajax 获取数据 + } else if (typeof theSelect.settings.url === 'string' && theSelect.settings.url.length) { + $.getJSON(theSelect.settings.url, function(json) { + cxSelect.start.call(theSelect, json); + }); + }; + }; + + // 设置参数 + cxSelect.setOptions = function(opts) { + var self = this; + + if (opts) { + $.extend(self.settings, opts); + }; + + // 初次或重设选择器组 + if (!$.isArray(self.selectArray) || !self.selectArray.length || (opts && opts.selects)) { + self.selectArray = []; + + if ($.isArray(self.settings.selects) && self.settings.selects.length) { + var _tempSelect; + + for (var i = 0, l = self.settings.selects.length; i < l; i++) { + _tempSelect = self.dom.box.find('select.' + self.settings.selects[i]); + + if (!_tempSelect || !_tempSelect.length) {break}; + + self.selectArray.push(_tempSelect); + }; + }; + }; + + if (opts) { + if (!$.isArray(opts.data) && typeof opts.url === 'string' && opts.url.length) { + $.getJSON(self.settings.url, function(json) { + cxSelect.start.call(self, json); + }); + + } else { + cxSelect.start.call(self, opts.data); + }; + }; + }; + + // 绑定 + cxSelect.attach = function() { + var self = this; + + if (!self.attachStatus) { + self.dom.box.on('change', 'select', self.changeEvent); + }; + + if (typeof self.attachStatus === 'boolean') { + cxSelect.start.call(self); + }; + + self.attachStatus = true; + }; + + // 移除绑定 + cxSelect.detach = function() { + var self = this; + self.dom.box.off('change', 'select', self.changeEvent); + self.attachStatus = false; + }; + + // 清空选项 + cxSelect.clear = function(index) { + var self = this; + var _style = { + display: '', + visibility: '' + }; + + index = isNaN(index) ? 0 : index; + + // 清空后面的 select + for (var i = index, l = self.selectArray.length; i < l; i++) { + self.selectArray[i].empty().prop('disabled', true); + + if (self.settings.emptyStyle === 'none') { + _style.display = 'none'; + } else if (self.settings.emptyStyle === 'hidden') { + _style.visibility = 'hidden'; + }; + + self.selectArray[i].css(_style); + }; + }; + + cxSelect.start = function(data) { + var self = this; + + if ($.isArray(data)) { + self.settings.data = cxSelect.getData(data, self.settings.jsonSpace); + }; + + if (!self.selectArray.length) {return}; + + // 保存默认值 + for (var i = 0, l = self.selectArray.length; i < l; i++) { + if (typeof self.selectArray[i].attr('data-value') !== 'string' && self.selectArray[i][0].options.length) { + self.selectArray[i].attr('data-value', self.selectArray[i].val()); + }; + }; + + if (self.settings.data || (typeof self.selectArray[0].data('url') === 'string' && self.selectArray[0].data('url').length)) { + cxSelect.getOptionData.call(self, 0); + } else { + self.selectArray[0].prop('disabled', false).css({ + 'display': '', + 'visibility': '' + }); + }; + }; + + // 获取选项数据 + cxSelect.getOptionData = function(index) { + var self = this; + + if (typeof index !== 'number' || isNaN(index) || index < 0 || index >= self.selectArray.length) {return}; + + var _indexPrev = index - 1; + var _select = self.selectArray[index]; + var _selectData; + var _valueIndex; + var _dataUrl = _select.data('url'); + var _jsonSpace = typeof _select.data('jsonSpace') === 'undefined' ? self.settings.jsonSpace : _select.data('jsonSpace'); + var _query = {}; + var _queryName; + var _selectName; + var _selectValue; + + cxSelect.clear.call(self, index); + + // 使用独立接口 + if (typeof _dataUrl === 'string' && _dataUrl.length) { + if (index > 0) { + for (var i = 0, j = 1; i < index; i++, j++) { + _queryName = self.selectArray[j].data('queryName'); + _selectName = self.selectArray[i].attr('name'); + _selectValue = self.selectArray[i].val(); + + if (typeof _queryName === 'string' && _queryName.length) { + _query[_queryName] = _selectValue; + } else if (typeof _selectName === 'string' && _selectName.length) { + _query[_selectName] = _selectValue; + }; + }; + }; + + $.getJSON(_dataUrl, _query, function(json) { + _selectData = cxSelect.getData(json, _jsonSpace); + + cxSelect.buildOption.call(self, index, _selectData); + }); + + // 使用整合数据 + } else if (self.settings.data && typeof self.settings.data === 'object') { + _selectData = self.settings.data; + + for (var i = 0; i < index; i++) { + _valueIndex = cxSelect.getIndex(self.selectArray[i][0].selectedIndex, typeof self.selectArray[i].data('required') === 'boolean' ? self.selectArray[i].data('required') : self.settings.required); + + if (typeof _selectData[_valueIndex] === 'object' && $.isArray(_selectData[_valueIndex][self.settings.jsonSub]) && _selectData[_valueIndex][self.settings.jsonSub].length) { + _selectData = _selectData[_valueIndex][self.settings.jsonSub]; + } else { + _selectData = null; + break; + }; + }; + + cxSelect.buildOption.call(self, index, _selectData); + }; + }; + + // 构建选项列表 + cxSelect.buildOption = function(index, data) { + var self = this; + + var _select = self.selectArray[index]; + var _required = typeof _select.data('required') === 'boolean' ? _select.data('required') : self.settings.required; + var _firstTitle = typeof _select.data('firstTitle') === 'undefined' ? self.settings.firstTitle : _select.data('firstTitle'); + var _firstValue = typeof _select.data('firstValue') === 'undefined' ? self.settings.firstValue : _select.data('firstValue'); + var _jsonName = typeof _select.data('jsonName') === 'undefined' ? self.settings.jsonName : _select.data('jsonName'); + var _jsonValue = typeof _select.data('jsonValue') === 'undefined' ? self.settings.jsonValue : _select.data('jsonValue'); + + if (!$.isArray(data)) {return}; + + var _html = !_required ? '' : ''; + + // 区分标题、值的数据 + if (typeof _jsonName === 'string' && _jsonName.length) { + // 无值字段时使用标题作为值 + if (typeof _jsonValue !== 'string' || !_jsonValue.length) { + _jsonValue = _jsonName; + }; + + for (var i = 0, l = data.length; i < l; i++) { + _html += ''; + }; + + // 数组即为值的数据 + } else { + for (var i = 0, l = data.length; i < l; i++) { + _html += ''; + }; + }; + + _select.html(_html).prop('disabled', false).css({ + 'display': '', + 'visibility': '' + }); + + // 初次加载设置默认值 + if (typeof _select.attr('data-value') === 'string') { + _select.val(String(_select.attr('data-value'))).removeAttr('data-value'); + + if (_select[0].selectedIndex < 0) { + _select[0].options[0].selected = true; + }; + }; + + if (_required || _select[0].selectedIndex > 0) { + _select.trigger('change'); + }; + + }; + + // 改变选择时的处理 + cxSelect.selectChange = function(name) { + var self = this; + + if (typeof name !== 'string' || !name.length) {return}; + + var index; + + name = name.replace(/\s+/g, ','); + name = ',' + name + ','; + + // 获取当前 select 位置 + for (var i = 0, l = self.selectArray.length; i < l; i++) { + if (name.indexOf(',' + self.settings.selects[i] + ',') > -1) { + index = i; + break; + }; + }; + + if (typeof index === 'number' && index > -1) { + index += 1; + cxSelect.getOptionData.call(self, index); + }; + }; + + $.cxSelect = function() { + return cxSelect.apply(this, arguments); + }; + + // 默认值 + $.cxSelect.defaults = { + selects: [], // 下拉选框组 + url: null, // 列表数据文件路径(URL)或数组数据 + data: null, // 自定义数据 + emptyStyle: null, // 无数据状态显示方式 + required: false, // 是否为必选 + firstTitle: '请选择', // 第一个选项的标题 + firstValue: '', // 第一个选项的值 + jsonSpace: '', // 数据命名空间 + jsonName: 'n', // 数据标题字段名称 + jsonValue: '', // 数据值字段名称 + jsonSub: 's' // 子集数据字段名称 + }; + + $.fn.cxSelect = function(settings, callback) { + this.each(function(i) { + $.cxSelect(this, settings, callback); + }); + return this; + }; +})); diff --git a/app/assets/javascripts/jquery.cxselect.min.js b/app/assets/javascripts/jquery.cxselect.min.js old mode 100755 new mode 100644 index 54549a920..9aabba447 --- a/app/assets/javascripts/jquery.cxselect.min.js +++ b/app/assets/javascripts/jquery.cxselect.min.js @@ -1,11 +1,11 @@ -/*! - * jQuery cxSelect - * @name jquery.cxselect.js - * @version 1.4.1 - * @date 2016-11-02 - * @author ciaoca - * @email ciaoca@gmail.com - * @site https://github.com/ciaoca/cxSelect - * @license Released under the MIT license - */ +/*! + * jQuery cxSelect + * @name jquery.cxselect.js + * @version 1.4.1 + * @date 2016-11-02 + * @author ciaoca + * @email ciaoca@gmail.com + * @site https://github.com/ciaoca/cxSelect + * @license Released under the MIT license + */ !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(window.jQuery||window.Zepto||window.$)}(function(a){var b=function(){var d,e,f,g,h,i;for(g=0,h=arguments.length;h>g;g++)b.isJquery(arguments[g])||b.isZepto(arguments[g])?d=arguments[g]:b.isElement(arguments[g])?d=a(arguments[g]):"function"==typeof arguments[g]?f=arguments[g]:"object"==typeof arguments[g]&&(e=arguments[g]);return i=new b.init(d,e),"function"==typeof f&&f(i),i};b.isElement=function(a){return a&&("function"==typeof HTMLElement||"object"==typeof HTMLElement)&&a instanceof HTMLElement?!0:a&&a.nodeType&&1===a.nodeType?!0:!1},b.isJquery=function(a){return a&&a.length&&("function"==typeof jQuery||"object"==typeof jQuery)&&a instanceof jQuery?!0:!1},b.isZepto=function(a){return a&&a.length&&("function"==typeof Zepto||"object"==typeof Zepto)&&Zepto.zepto.isZ(a)?!0:!1},b.getIndex=function(a,b){return b?a:a-1},b.getData=function(a,b){if("string"==typeof b&&b.length){b=b.split(".");for(var c=0,d=b.length;d>c;c++)a=a[b[c]]}return a},b.init=function(c,d){var f,g,e=this;(b.isJquery(c)||b.isZepto(c))&&(f={dom:{box:c}},e.attach=b.attach.bind(f),e.detach=b.detach.bind(f),e.setOptions=b.setOptions.bind(f),e.clear=b.clear.bind(f),f.changeEvent=function(){b.selectChange.call(f,this.className)},f.settings=a.extend({},a.cxSelect.defaults,d,{url:f.dom.box.data("url"),emptyStyle:f.dom.box.data("emptyStyle"),required:f.dom.box.data("required"),firstTitle:f.dom.box.data("firstTitle"),firstValue:f.dom.box.data("firstValue"),jsonSpace:f.dom.box.data("jsonSpace"),jsonName:f.dom.box.data("jsonName"),jsonValue:f.dom.box.data("jsonValue"),jsonSub:f.dom.box.data("jsonSub")}),g=f.dom.box.data("selects"),"string"==typeof g&&g.length&&(f.settings.selects=g.split(",")),e.setOptions(),e.attach(),f.settings.url||f.settings.data?a.isArray(f.settings.data)?b.start.call(f,f.settings.data):"string"==typeof f.settings.url&&f.settings.url.length&&a.getJSON(f.settings.url,function(a){b.start.call(f,a)}):b.start.apply(f))},b.setOptions=function(c){var e,f,g,d=this;if(c&&a.extend(d.settings,c),(!a.isArray(d.selectArray)||!d.selectArray.length||c&&c.selects)&&(d.selectArray=[],a.isArray(d.settings.selects)&&d.settings.selects.length))for(f=0,g=d.settings.selects.length;g>f&&(e=d.dom.box.find("select."+d.settings.selects[f]),e&&e.length);f++)d.selectArray.push(e);c&&(!a.isArray(c.data)&&"string"==typeof c.url&&c.url.length?a.getJSON(d.settings.url,function(a){b.start.call(d,a)}):b.start.call(d,c.data))},b.attach=function(){var a=this;a.attachStatus||a.dom.box.on("change","select",a.changeEvent),"boolean"==typeof a.attachStatus&&b.start.call(a),a.attachStatus=!0},b.detach=function(){var a=this;a.dom.box.off("change","select",a.changeEvent),a.attachStatus=!1},b.clear=function(a){var d,e,b=this,c={display:"",visibility:""};for(a=isNaN(a)?0:a,d=a,e=b.selectArray.length;e>d;d++)b.selectArray[d].empty().prop("disabled",!0),"none"===b.settings.emptyStyle?c.display="none":"hidden"===b.settings.emptyStyle&&(c.visibility="hidden"),b.selectArray[d].css(c)},b.start=function(c){var e,f,d=this;if(a.isArray(c)&&(d.settings.data=b.getData(c,d.settings.jsonSpace)),d.selectArray.length){for(e=0,f=d.selectArray.length;f>e;e++)"string"!=typeof d.selectArray[e].attr("data-value")&&d.selectArray[e][0].options.length&&d.selectArray[e].attr("data-value",d.selectArray[e].val());d.settings.data||"string"==typeof d.selectArray[0].data("url")&&d.selectArray[0].data("url").length?b.getOptionData.call(d,0):d.selectArray[0].prop("disabled",!1).css({display:"",visibility:""})}},b.getOptionData=function(c){var f,g,h,i,j,k,l,m,n,o,p,d=this;if(!("number"!=typeof c||isNaN(c)||0>c||c>=d.selectArray.length))if(f=d.selectArray[c],i=f.data("url"),j="undefined"==typeof f.data("jsonSpace")?d.settings.jsonSpace:f.data("jsonSpace"),k={},b.clear.call(d,c),"string"==typeof i&&i.length){if(c>0)for(o=0,p=1;c>o;o++,p++)l=d.selectArray[p].data("queryName"),m=d.selectArray[o].attr("name"),n=d.selectArray[o].val(),"string"==typeof l&&l.length?k[l]=n:"string"==typeof m&&m.length&&(k[m]=n);a.getJSON(i,k,function(a){g=b.getData(a,j),b.buildOption.call(d,c,g)})}else if(d.settings.data&&"object"==typeof d.settings.data){for(g=d.settings.data,o=0;c>o;o++){if(h=b.getIndex(d.selectArray[o][0].selectedIndex,"boolean"==typeof d.selectArray[o].data("required")?d.selectArray[o].data("required"):d.settings.required),"object"!=typeof g[h]||!a.isArray(g[h][d.settings.jsonSub])||!g[h][d.settings.jsonSub].length){g=null;break}g=g[h][d.settings.jsonSub]}b.buildOption.call(d,c,g)}},b.buildOption=function(b,c){var k,l,m,d=this,e=d.selectArray[b],f="boolean"==typeof e.data("required")?e.data("required"):d.settings.required,g="undefined"==typeof e.data("firstTitle")?d.settings.firstTitle:e.data("firstTitle"),h="undefined"==typeof e.data("firstValue")?d.settings.firstValue:e.data("firstValue"),i="undefined"==typeof e.data("jsonName")?d.settings.jsonName:e.data("jsonName"),j="undefined"==typeof e.data("jsonValue")?d.settings.jsonValue:e.data("jsonValue");if(a.isArray(c)){if(k=f?"":'","string"==typeof i&&i.length)for("string"==typeof j&&j.length||(j=i),l=0,m=c.length;m>l;l++)k+='";else for(l=0,m=c.length;m>l;l++)k+='";e.html(k).prop("disabled",!1).css({display:"",visibility:""}),"string"==typeof e.attr("data-value")&&(e.val(String(e.attr("data-value"))).removeAttr("data-value"),e[0].selectedIndex<0&&(e[0].options[0].selected=!0)),(f||e[0].selectedIndex>0)&&e.trigger("change")}},b.selectChange=function(a){var d,e,f,c=this;if("string"==typeof a&&a.length){for(a=a.replace(/\s+/g,","),a=","+a+",",e=0,f=c.selectArray.length;f>e;e++)if(a.indexOf(","+c.settings.selects[e]+",")>-1){d=e;break}"number"==typeof d&&d>-1&&(d+=1,b.getOptionData.call(c,d))}},a.cxSelect=function(){return b.apply(this,arguments)},a.cxSelect.defaults={selects:[],url:null,data:null,emptyStyle:null,required:!1,firstTitle:"请选择",firstValue:"",jsonSpace:"",jsonName:"n",jsonValue:"",jsonSub:"s"},a.fn.cxSelect=function(b,c){return this.each(function(){a.cxSelect(this,b,c)}),this}}); \ No newline at end of file diff --git a/app/assets/javascripts/jquery.validate.js b/app/assets/javascripts/jquery.validate.js index 70297bd5c..d025319db 100644 --- a/app/assets/javascripts/jquery.validate.js +++ b/app/assets/javascripts/jquery.validate.js @@ -1,21 +1,21 @@ -/*! - * jQuery Validation Plugin v1.19.1 - * - * https://jqueryvalidation.org/ - * - * Copyright (c) 2019 Jörn Zaefferer - * Released under the MIT license - */ -(function( factory ) { - if ( typeof define === "function" && define.amd ) { - define( ["jquery"], factory ); - } else if (typeof module === "object" && module.exports) { - module.exports = factory( require( "jquery" ) ); - } else { - factory( jQuery ); - } -}(function( $ ) { - +/*! + * jQuery Validation Plugin v1.19.1 + * + * https://jqueryvalidation.org/ + * + * Copyright (c) 2019 Jörn Zaefferer + * Released under the MIT license + */ +(function( factory ) { + if ( typeof define === "function" && define.amd ) { + define( ["jquery"], factory ); + } else if (typeof module === "object" && module.exports) { + module.exports = factory( require( "jquery" ) ); + } else { + factory( jQuery ); + } +}(function( $ ) { + $.extend( $.fn, { // https://jqueryvalidation.org/validate/ @@ -1610,7 +1610,7 @@ $.extend( $.validator, { } } ); - + // Ajax mode: abort // usage: $.ajax({ mode: "abort"[, port: "uniqueport"]}); // if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort() @@ -1646,5 +1646,5 @@ if ( $.ajaxPrefilter ) { return ajax.apply( this, arguments ); }; } -return $; +return $; })); \ No newline at end of file diff --git a/app/assets/javascripts/select2.js b/app/assets/javascripts/select2.js old mode 100755 new mode 100644 diff --git a/app/assets/javascripts/select2.min.js b/app/assets/javascripts/select2.min.js old mode 100755 new mode 100644 diff --git a/app/assets/stylesheets/select2-bootstrap4.min.scss b/app/assets/stylesheets/select2-bootstrap4.min.scss old mode 100755 new mode 100644 diff --git a/app/assets/stylesheets/select2.min.scss b/app/assets/stylesheets/select2.min.scss old mode 100755 new mode 100644 diff --git a/public/react/config/webpack.config.dev.js b/public/react/config/webpack.config.dev.js index 510bcaa4f..f126bc363 100644 --- a/public/react/config/webpack.config.dev.js +++ b/public/react/config/webpack.config.dev.js @@ -30,7 +30,8 @@ module.exports = { // You may want 'eval' instead if you prefer to see the compiled output in DevTools. // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s // devtool: "cheap-module-eval-source-map", - // 开启调试 + // 开启调试 + devtool: "source-map", // 开启调试 // These are the "entry points" to our application. // This means they will be the "root" imports that are included in JS bundle. // The first two entry points enable "hot" CSS and auto-refreshes for JS. diff --git a/public/react/scripts/build.js b/public/react/scripts/build.js index 022e8074f..419450dae 100644 --- a/public/react/scripts/build.js +++ b/public/react/scripts/build.js @@ -195,7 +195,30 @@ function generateNewIndexJsp() { let cdnHost = 'https://shixun.educoder.net' cdnHost = 'https://ali-cdn.educoder.net' cdnHost = '' - var result = data.replace('/js/js_min_all.js', `${cdnHost}/react/build/js/js_min_all.js?v=${newVersion}`) + + + var mainRegex = / + ` + var jsMinAllRegex = / + var result = data + .replace(jsMinAllRegex, code) + // .replace('/js/js_min_all.js', `${cdnHost}/react/build/js/js_min_all.js?v=${newVersion}`) // .replace('/js/js_min_all_2.js', `${cdnHost}/react/build/js/js_min_all_2.js?v=${newVersion}`) // ${cdnHost} 加了cdn后,这个文件里的字体文件加载会有跨域的报错 ../fonts/fontawesome-webfont.eot @@ -204,10 +227,11 @@ function generateNewIndexJsp() { .replace('/css/iconfont.css', `${cdnHost}/react/build/css/iconfont.css?v=${newVersion}`) .replace(/\/js\/create_kindeditor.js/g, `${cdnHost}/react/build/js/create_kindeditor.js?v=${newVersion}`) + .replace(mainRegex, '') // .replace('/react/build/./static/css/main', `${cdnHost}/react/build/./static/css/main`) // .replace('/react/build/./static/js/main', `${cdnHost}/react/build/./static/js/main`) - .replace(/https:\/\/testeduplus2.educoder.net/g, ''); + // .replace(/https:\/\/testeduplus2.educoder.net/g, ''); // .replace(/http:\/\/testbdweb.educoder.net/g, ''); // .replace('/css/css_min_all.css', '/react/build/css/css_min_all.css'); diff --git a/public/react/src/App.css b/public/react/src/App.css index a6f1d45e7..2b3d8d08c 100644 --- a/public/react/src/App.css +++ b/public/react/src/App.css @@ -55,6 +55,10 @@ html, body { .markdown-body p { white-space: pre-wrap; } +/* https://www.educoder.net/courses/2346/group_homeworks/34405/question */ +.renderAsHtml.markdown-body p { + white-space: inherit; +} /* resize */ .editormd .CodeMirror { border-right: none !important; diff --git a/public/react/src/App.js b/public/react/src/App.js index e6f55f5d2..b40af3e0b 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -1,4 +1,5 @@ import React, {Component} from 'react'; +import './public-path'; import logo from './logo.svg'; import './App.css'; import {LocaleProvider} from 'antd' diff --git a/public/react/src/common/TextUtil.js b/public/react/src/common/TextUtil.js index 4c83131f1..74cdef3e6 100644 --- a/public/react/src/common/TextUtil.js +++ b/public/react/src/common/TextUtil.js @@ -9,6 +9,7 @@ export function markdownToHTML(oldContent, selector) { window.$('#md_div').html('') // markdown to html if (selector && oldContent && oldContent.startsWith('
{ return(
-
+
{
item.is_pdf && item.is_pdf == true ?
- {item.title}
+
暂时还没有相关数据哦!
暂时还没有相关数据哦!
暂时还没有相关数据哦!
选择的{moduleName}发送到指定课堂
- -
-
选择的{moduleName}发送到指定课堂
+ +
+
-
-
+
暂时还没有相关数据哦!
暂时还没有相关数据哦!
- { + {/* { topicInfo.attachment_list.map((item,key)=>{ return( +
-
-
+
+
-
-
+
+
-
点击或拖拽文件到这里上传
-- 单个文件最大150MB -
-- {errorTip} -
+
+
点击或拖拽文件到这里上传
++ 单个文件最大150MB +
+实训已经更新了,正在为您重置!
-本实训的开启时间:{shixunsmessage}
开启时间之前不能挑战
-
*/} - {/*知道了*/} - {/*
*/} -实训已经更新了,正在为您重置!
+本实训的开启时间:{shixunsmessage}
开启时间之前不能挑战
+
*/} + {/*知道了*/} + {/*
*/} +
- {datas&&datas.category_name===undefined||datas&&datas.category_name===null?datas&&datas.main_category_name:datas&&datas.category_name+" 作业列表"} - {/* 实训作业*/} + {/*{datas&&datas.category_name===undefined||datas&&datas.category_name===null?datas&&datas.main_category_name:datas&&datas.category_name+" 作业列表"}*/} + 实训作业
+
暂时还没有相关数据哦!
暂时还没有相关数据哦!
- 共参与{totalCount}个题库 -
- {item.name} - 发送 - { - item.is_public ==false ? - this.setPublic(1)} className="bank_public color-blue_4C fr mr60">设为公开:"" - } -
-- {item.quotes_count}次引用 - {item.solve_count}次答题 - {moment(item.updated_at).format('YYYY-MM-DD HH:mm')} - this.setPublic(2)}>删除 - {item.course_list_name} -
-+ 共参与{totalCount}个题库 +
+ {item.name} + 发送 + { + item.is_public ==false ? + this.setPublic(1)} className="bank_public color-blue_4C fr mr60">设为公开:"" + } +
++ {item.quotes_count}次引用 + {item.solve_count}次答题 + {moment(item.updated_at).format('YYYY-MM-DD HH:mm')} + this.setPublic(2)}>删除 + {item.course_list_name} +
+- {data && data.name} - { - data && is_current == false && data.identity =="学生" ? "" : - - } -
-
-
+ {data && data.name} + { + data && is_current == false && data.identity =="学生" ? "" : + + } +
+
+
- { - is_edit && is_current ? - - : - is_current ? - {sign || "这家伙很懒,什么都没留下~"} - : - {sign || "这家伙很懒,什么都没留下~"} - } -
- { - is_current ? - - : -+ { + is_edit && is_current ? + + : + is_current ? + {sign || "这家伙很懒,什么都没留下~"} + : + {sign || "这家伙很懒,什么都没留下~"} + } +
+ { + is_current ? + + : +