| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238 |
- if (typeof jQuery === "undefined") {
- throw new Error("jQuery plugins need to be before this file");
- }
- var log = true, abp = abp || {};
- /*JQuery扩展*/
- $.extend({
- //表单赋值
- formDeserialize: function ($form, data) {
- //isSelect2 = isSelect2 === undefined;
- if (!data) {
- return;
- }
- var $input = $form.find("input");
- var $textarea = $form.find("textarea");
- var $select = $form.find("select");
- var $checkbox = $form.find("input[type='checkbox']");
- var $radio = $form.find("input[type='radio']");
- $.merge($input, $textarea);
- $input.each(function () {
- var $input = $form.find($(this));
- var name = $input.attr("name");
- if (data[name] && data[name] !== "") {
- $input.val(data[name]);
- }
- });
- $select.each(function () {
- var $select = $form.find($(this));
- var name = $select.attr("name");
- if (typeof data[name] === "boolean") {
- data[name] = data[name] + "";
- }
- if (data[name] !== "") {
- var val = data[name];
- $select.val(val);
- if ($select.hasClass('ajax-select')) {
- window.ChangAjaxSelectValue($select, val);
- }
- }
- });
- $checkbox.each(function () {
- var input = $form.find($(this));
- var name = input.attr("name");
- if (data[name] !== "") {
- //console.log(array[name]);
- input.val(data[name] === "True" ||
- input.val(data[name]) === "1" ||
- input.val(data[name]) === "true");
- }
- });
- $radio.each(function () {
- var input = $form.find($(this));
- var name = input.attr("name");
- if (data[name] !== "") {
- //console.log(array[name]);
- $("input[name='" + name + "'][value='" + data[name] + "']").prop("checked", true);
- $("input[name='" + name + "'][value!='" + data[name] + "']").prop("checked", false);
- }
- });
- },
- //将form表单元素的值序列化成对象
- formSerialize: function ($form) {
- var disableEle = $form.find("[disabled]");
- disableEle.each(function (i, e) {
- $(e).prop("disabled", false);
- });
- var data = {};
- $.each($form.serializeArray(),
- function () {
- if (data[this['name']]) {
- data[this['name']] = data[this['name']] + "," + this['value'];
- } else {
- data[this['name']] = this['value'];
- }
- });
- disableEle.each(function (i, e) {
- $(e).prop("disabled", true);
- });
- return data;
- },
- //表单验证
- formValidate: function ($form, opt) {
- var defaults = {
- noValid: false,
- form: "form",
- modal: "modal",
- errorPlacement: function (error, element) {
- if (element.parent().parent().find('label.error').length === 0) {
- element.parent().after(error);
- }
- var $tab = element.closest('.form-auto-tab');
- if ($tab && $tab.length) {
- $("#" + $tab.data("tabid")).tab("show");
- }
- element.focus();
- },
- rules: {}
- };
- opt = opt || {};
- var options = $.extend({}, defaults, opt);
- var $modal = options.modal
- ? typeof (options.modal) === 'string'
- ? $('#' + options.modal)
- : $(options.modal)
- : null;
- $form = $form ? $form : options.form ? $(options.form) : $modal.find('form');
- $form.validate({
- errorPlacement: options.errorPlacement,
- rules: options.rules,
- ignore: ".ignore .iwb-wang-editor"
- });
- //.settings.ignore = ":disabled";
- if (!options.noValid) {
- var valid = $form.valid();
- console.log("FormValidate", $form.attr('id'), valid);
- return valid;
- }
- return options.noValid;
- },
- formatterDate: function (fmt, date, isFix) {
- date = date || new Date();
- isFix = isFix === undefined ? true : isFix;
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- fmt = fmt.replace("yyyy", year);
- fmt = fmt.replace("yy", year % 100);
- fmt = fmt.replace("MM", fix(month));
- fmt = fmt.replace("dd", fix(date.getDate()));
- fmt = fmt.replace("HH", fix(date.getHours()));
- fmt = fmt.replace("mm", fix(date.getMinutes()));
- fmt = fmt.replace("ss", fix(date.getSeconds()));
- return fmt;
- function fix(n) {
- return isFix ? (n < 10 ? "0" + n : n) : n;
- }
- },
- blinkTitle: {
- start: function (msg) {
- msg = msg || abp.localization.iwbZero('NewNotificationRemind');
- this.title = document.title;
- this.messages = [msg];
- if (!this.action) {
- try {
- this.element = document.getElementsByTagName('title')[0];
- this.element.innerHTML = this.title;
- this.action = function (ttl) {
- this.element.innerHTML = ttl;
- };
- } catch (e) {
- this.action = function (ttl) {
- document.title = ttl;
- };
- delete this.element;
- }
- this.toggleTitle = function () {
- this.index = this.index === 0 ? 1 : 0;
- this.action('【' + this.messages[this.index] + '】' + this.title);
- };
- }
- var n = msg.length;
- var s = '';
- if (this.element) {
- var num = msg.match(/\w/g);
- if (num) {
- var n2 = num.length;
- n -= n2;
- while (n2 > 0) {
- s += " ";
- n2--;
- }
- }
- }
- while (n > 0) {
- s += ' ';
- n--;
- }
- this.messages.push(s);
- this.index = 0;
- //this.title = this.title.replace("【" + msg + "】", "").replace("【" + s + "】", "");
- var that = this;
- this.timer = setInterval(function () {
- that.toggleTitle();
- }, 500);
- },
- stop: function () {
- if (this.timer) {
- clearInterval(this.timer);
- var t = this.title ? this.title : document.title;
- this.action(t);
- delete this.timer;
- delete this.messages;
- }
- }
- },
- metPageCss: function (url, id) {
- id = id || 'dy-css';
- if ($('#' + id).length > 0) {
- return;
- }
- var link = document.createElement('link');
- link.type = 'text/css';
- link.rel = 'stylesheet';
- link.id = id;
- link.href = url + '?v=' + Math.floor(Math.random() * 100000);
- var flag = document.getElementById('flag');
- var head = document.getElementsByTagName('head')[0];
- if (flag) {
- head.insertBefore(link, flag.nextSibling);
- } else {
- head.appendChild(link);
- }
- },
- metPageJs: function (src, id) {
- id = id || 'dy-js';
- if ($('#' + id).length > 0) {
- return;
- }
- var script = document.createElement('script');
- script.id = id;
- script.type = 'text/javascript';
- script.charset = 'UTF-8';
- script.src = src + '?v=' + Math.floor(Math.random() * 100000);
- $('head').append(script);
- },
- loadScript: function (url, loadCallback, failCallback) {
- /* UrlStates enum */
- var urlStates = {
- LOADING: 'LOADING',
- LOADED: 'LOADED',
- FAILED: 'FAILED'
- };
- /* UrlInfo class */
- function UrlInfo() {
- this.state = urlStates.LOADING;
- this.loadCallbacks = [];
- this.failCallbacks = [];
- }
- UrlInfo.prototype.succeed = function () {
- this.state = urlStates.LOADED;
- for (var i = 0; i < this.loadCallbacks.length; i++) {
- this.loadCallbacks[i]();
- }
- };
- UrlInfo.prototype.failed = function () {
- this.state = urlStates.FAILED;
- for (var i = 0; i < this.failCallbacks.length; i++) {
- this.failCallbacks[i]();
- }
- };
- UrlInfo.prototype.handleCallbacks = function (loadCallback, failCallback) {
- switch (this.state) {
- case urlStates.LOADED:
- loadCallback && loadCallback();
- break;
- case urlStates.FAILED:
- failCallback && failCallback();
- break;
- case urlStates.LOADING:
- this.addCallbacks(loadCallback, failCallback);
- break;
- }
- };
- UrlInfo.prototype.addCallbacks = function (loadCallback, failCallback) {
- loadCallback && this.loadCallbacks.push(loadCallback);
- failCallback && this.failCallbacks.push(failCallback);
- };
- var urlInfos = {};
- var loadScript = function (url, loadCallback, failCallback) {
- var urlInfo = urlInfos[url];
- if (urlInfo) {
- urlInfo.handleCallbacks(loadCallback, failCallback);
- return;
- }
- urlInfos[url] = urlInfo = new UrlInfo();
- urlInfo.addCallbacks(loadCallback, failCallback);
- $.getScript(url).done(function (script, textStatus) {
- urlInfo.succeed();
- }).fail(function (jqxhr, settings, exception) {
- urlInfo.failed();
- });
- };
- loadScript(url, loadCallback, failCallback);
- },
- //jsonTree 转成 array
- Json2Array: function (data, opts) {
- var defaults = {
- id: 'id',
- parentId: 'parentId',
- children: 'children'
- };
- var opt = $.extend({}, defaults, opts || {});
- var Json2ArrayChild = function (data, dataArray) {
- var newData = $.extend([], data);
- var children = data[opt.children];
- delete newData[opt.children];
- dataArray.push(newData);
- if (children && children.length > 0) {
- children.forEach(function (v) {
- Json2ArrayChild(v, dataArray);
- });
- }
- }
- var dataArray = [];
- var children = data[opt.children];
- var newData = $.extend([], data);
- delete newData[opt.children];
- dataArray.push(newData);
- if (children && children.length > 0) {
- children.forEach(function (v) {
- Json2ArrayChild(v, dataArray);
- });
- }
- return dataArray;
- },
- //array 转成 JsonTree
- Array2Json: function (dataArray, opts) {
- var defaults = {
- root: '',
- id: 'id',
- parentId: 'parentId',
- children: 'children'
- };
- var opt = $.extend({}, defaults, opts || {});
- var Json2DataChild = function (parentId, dataArray) {
- var children = dataArray.filter(function (v) {
- return v[opt.parentId] === parentId;
- });
- if (children && children.length > 0) {
- children.forEach(function (v) {
- v[opt.children] = Json2DataChild(v[opt.id], dataArray);
- });
- }
- return children;
- }
- var index = dataArray.findIndex(function (v) {
- return v[opt.parentId] === opt.root;
- });
- var dataJson = dataArray[index];
- dataJson[opt.children] = Json2DataChild(dataJson.id, dataArray);
- return dataJson;
- }
- });
- /*AJAX*/
- $.extend({
- //ajax
- iwbAjax: function (url, opt) {
- this.defaults = {
- async: true,
- type: "Post",
- contentType: 'application/json; charset=UTF-8',
- //contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
- data: null,
- dataFun: null,
- log: window.log,
- dataType: "json",
- isAlert: true,
- successAlert: false,
- isValidate: true,
- isRefresh: true,//默认刷新表格
- success: null,
- error: null,
- table: undefined,
- modal: undefined,
- form: undefined,
- errorPlacement: function (error, element) {
- element.parent().before(error);
- element.focus();
- },
- rules: {},
- blockUI: true
- };
- if (!opt) {
- opt = url;
- url = opt.url;
- }
- var options = $.extend({}, this.defaults, opt);
- var $table = !options.table ? undefined : typeof options.table === 'string' ? $('#' + options.table) : $(options.table);
- var $modal = !options.modal ? undefined : typeof options.modal === 'string' ? $('#' + options.modal) : $(options.modal);
- var $form = !options.form ? ($modal ? $modal.find("form") : undefined) : typeof options.form === 'string' ? $('#' + options.form) : $(options.form);
- var isValidated = true;
- if (options.isValidate && $form) {
- isValidated = $.formValidate($form);
- }
- if (isValidated) {
- if (options.dataFun !== null && typeof options.dataFun === 'function') {
- options.data = options.dataFun();
- } else {
- options.data = options.data ? (typeof options.data === 'function' ? options.data() : options.data) : $form ? $.formSerialize($form) : undefined;
- }
- var guid = Math.floor(Math.random() * 10000);
- var log = options.log;
- if (log) {
- console.log('[' + guid + ']url:' + url, 'data:', options.data);
- }
- var success = options.success && typeof options.success === 'function'
- ? function (res) {
- if (log) { console.log('[' + guid + ']', res); }
- options.success(res);
- if (options.isRefresh && $table) {
- $table.iwbTable('refresh', true);
- }
- if ($modal) {
- $modal.iwbModal('hide');
- }
- }
- : function (res) {
- if (log) { console.log('[' + guid + ']', res); }
- if (options.isRefresh && $table) {
- $table.iwbTable('refresh', true);
- }
- if ($modal) {
- $modal.iwbModal('hide');
- }
- };
- var ajaxSuccess = options.isAlert || options.successAlert ? function (res) { abp.message.success(abp.localization.iwbZero('OpSuccess')).done(success(res)); } : success;
- var data = typeof (options.data) === 'string' ? options.data : JSON.stringify(options.data);
- var ajaxOption = {
- url: url,
- async: options.async,
- type: options.type,
- contentType: options.contentType,
- data: data,
- dataType: options.dataType,
- success: ajaxSuccess,
- error: options.error,
- abpHandleError: options.isAlert,
- blockUI: options.blockUI
- };
- abp.ajax(ajaxOption);
- }
- }
- });
- $.extend({
- iwbAjax1: function (opt) {
- opt = $.extend({}, { isValidate: false }, opt);
- $.iwbAjax(opt);
- },
- iwbAjax2: function (opt) {
- opt = $.extend({}, { isAlert: false }, opt);
- $.iwbAjax(opt);
- },
- iwbAjax3: function (opt) {
- opt = $.extend({}, { isValidate: false, isAlert: false, blockUI: true }, opt);
- $.iwbAjax(opt);
- },
- iwbAjax4: function (opt) {
- opt = $.extend({}, { isValidate: false, isAlert: false, isRefresh: false, blockUI: true }, opt);
- $.iwbAjax(opt);
- },
- iwbAjax41: function (opt) {
- opt = $.extend({}, { isValidate: false, isAlert: false, isRefresh: false, blockUI: false }, opt);
- $.iwbAjax(opt);
- },
- iwbAjax5: function (opt) {
- opt = $.extend({}, { isValidate: false, isAlert: false, successAlert: true, isRefresh: false, blockUI: true }, opt);
- $.iwbAjax(opt);
- },
- iwbGet: function (opt) {
- opt = $.extend({}, { type: 'get', modal: null, form: null }, opt);
- $.iwbAjax4(opt);
- }
- });
- /*Table*/
- (function ($, window, document, undefined) {
- //构造函数
- 'use strict';
- var abp = window.abp || {},
- selectionRows = [],
- searchList = [],
- isSearching,
- modalDefaults = {
- modal: 'modal',
- modaltitle: '',
- data: null,
- form: null,
- errorPlacement: function (error, element) {
- if (element.is('select')) {
- if (!element.next().next().hasClass('error')) {
- element.next().after(error);
- element.focus();
- }
- } else {
- element.after(error);
- element.focus();
- }
- },
- rules: {},
- readonly: '',
- disabled: '',
- select2: true,
- select2tree: false,
- url: '',
- savebtn: null,
- save: null,
- success: null,
- shownBefore: null,
- shownAfter: null,
- draggable: false,
- searchValidate: true
- };
- //modalOptions = {};
- var getSearchList = function ($that) {
- var o = $that.options;
- var $searchForm = (typeof (o.searchForm) === 'string' ? $('#' + o.searchForm) : $(o.searchForm));
- searchList = [];
- if (o.searchFun && typeof o.searchFun === "function") {
- o.searchFun(searchList);
- }
- if (o.searchList && o.searchList.length > 0) {
- o.searchList.forEach(function (v) {
- if (v.KeyWords) {
- searchList.push(v);
- }
- });
- }
- if (!o.onlySearchList) {
- $searchForm.find('.KeyWords').each(function () {
- var $this = $(this), keyWords = $this.val();
- if (keyWords) {
- if ($this.hasClass('dataRange')) {
- try {
- var dates = keyWords.split(' - ');
- searchList.push({
- KeyWords: dates[0],
- KeyField: $this.data('field'),
- FieldType: $this.data('ftype'),
- ExpType: 4
- });
- if (dates.length === 2) {
- var dateArr = dates[1].split(' ')[0].split('-');
- var date = new Date(dateArr[0], dateArr[1] - 1, dateArr[2], 0, 0, 0);
- var newDate = new Date(date.getTime() + 24 * 60 * 60 * 1000 - 1);
- keyWords = $.formatterDate('yyyy-MM-dd HH:mm:ss', newDate);
- searchList.push({
- KeyWords: keyWords,
- KeyField: $this.data('field'),
- FieldType: $this.data('ftype'),
- ExpType: 5
- });
- }
- } catch (e) {
- console.log(e);
- }
- } else {
- searchList.push({
- KeyWords: keyWords,
- KeyField: $this.data('field'),
- FieldType: $this.data('ftype'),
- ExpType: $this.data('etype')
- });
- }
- }
- });
- }
- };
- var queryParams = function (params, $that) {
- var o = $that.options;
- getSearchList($that);
- var $searchForm = (typeof (o.searchForm) === 'string' ? $('#' + o.searchForm) : $(o.searchForm));
- var $keyWord = $searchForm.find('#keyWords');
- if (o.onlySearchList) {
- return {
- MaxResultCount: params.limit,
- SkipCount: params.offset,
- //sort: params.sort, //排序列名
- //sortOrder: params.order, //排位命令(desc,asc)
- sorting: params.sort ? params.sort + ' ' + params.order : '',
- SearchList: searchList
- };
- }
- return {
- MaxResultCount: params.limit,
- SkipCount: params.offset,
- sorting: params.sort ? params.sort + ' ' + params.order : '',
- keyField: $keyWord.data('field'),
- fieldType: $keyWord.data('ftype'),
- expType: $keyWord.data('etype'),
- keyWords: $keyWord.val(),
- SearchList: searchList
- };
- };
- var responseHandler = function (res) {
- if (res.success) {
- var data = JSON.parse('{"total":' +
- res.result.totalCount +
- ',"rows":' +
- JSON.stringify(res.result.items) +
- '}');
- if (selectionRows.length > 0) {
- data.rows.forEach(function (row) {
- row.state = selectionRows.findIndex(function (v) {
- return v.id === row.id;
- }) !== -1;
- });
- }
- console.log(data);
- return data;
- } else {
- console.log('Table load failed');
- if (res.error) {
- if (res.error.details) {
- return abp.message.error(res.error.details, res.error.message);
- } else {
- if (res.error.message && res.error.message.indexOf('登陆超时') >= 0) {
- return abp.message.error(res.error.message).done(function () {
- window.top.location.reload();
- });
- } else {
- return abp.message.error(res.error.message || abp.ajax.defaultError.message);
- }
- }
- }
- }
- return JSON.parse('{"total":0,"rows":[]}');
- };
- var responseHandlerNoPage = function (res) {
- if (res.success) {
- var data = res.result;
- console.log(data);
- return data;
- } else {
- console.log('Table load failed');
- if (res.error) {
- if (res.error.details) {
- return abp.message.error(res.error.details, res.error.message);
- } else {
- if (res.error.message && res.error.message.indexOf('登陆超时') >= 0) {
- return abp.message.error(res.error.message).done(function () {
- window.top.location.reload();
- });
- } else {
- return abp.message.error(res.error.message || abp.ajax.defaultError.message);
- }
- }
- }
- }
- return JSON.parse('[]');
- };
- var onAll = function (eName, eData, $that) {
- isSearching = false;
- var o = $that.options;
- var $table = (typeof (o.table) === 'string' ? $('#' + o.table) : $(o.table));
- $table.closest('.table-box').find('.tableTool .menu-btn[data-type^=\'btn\']')
- .prop('disabled', $table.bootstrapTable('getSelections').length !== 1);
- };
- var onLoadSuccess = function (data, $that) {
- //var o = $that.options;
- //var $table = (typeof (o.table) === 'string' ? $('#' + o.table) : $(o.table));
- // $table.find('.bs-checkbox').find('input').addClass('filled-in').after('<label></label');
- };
- //var isResetView = true;
- var onPostBody = function (data, $that) {
- var o = $that.options;
- $(document);
- var $table = (typeof (o.table) === 'string' ? $('#' + o.table) : $(o.table));
- $table.find("td.bs-checkbox").each(function () {
- var input = $(this).find('input');
- var $label = $('<span class="iwb-checkbox"></span>');
- $label.append(input);
- $label.append('<span></span>');
- $(this).html($label);
- });
- isSearching = false;
- var $tableTool = o.tableTool
- ? typeof (o.tableTool) === 'string'
- ? $table.closest('.table-box').find('#' + o.tableTool)
- : $table.closest('.table-box').find(o.tableTool)
- : $table.closest('.table-box').find('.btn-toolbar');
- $tableTool.find('.menu-btn').off('click.menubtn').on('click.menubtn',
- function () {
- var funs = $that.getFuns();
- var type = $(this).data('type');
- var index = type.lastIndexOf('_');
- type = index > -1 ? type.substr(index + 1) : type;
- var url = $(this).data('url') || "";
- funs[type] ? funs[type].call(this, url) : funs["none"].call(this);
- });
- abp.ui.clearBusy();
- $table.find('tr th').each(function () { $(this).css('text-align', 'center') });
- $table.find('tr td.iwb-tips').each(function () {
- var text = $(this).text();
- $(this).tooltip({ 'title': text, 'placement': 'bottom', 'container': 'body', 'delay': 800 });
- });
- //if (isResetView) {
- // isResetView = false;
- // $table.bootstrapTable('resetView');
- //}
- };
- var getModal = function (url, opt, title, type, $that) {
- var o = $that.options;
- var modalOptions = $.extend({}, modalDefaults, opt);
- var $table = typeof o.table === 'string' ? $('#' + o.table) : $(o.table);
- var $tableTool = o.tableTool
- ? typeof o.tableTool === 'string'
- ? $table.closest('.table-box').find('#' + o.tableTool)
- : $table.closest('.table-box').find(o.tableTool)
- : $table.closest('.table-box').find('.btn-toolbar');
- modalOptions.modaltitle = title;
- modalOptions.draggable = $that.options.modalDrag;
- if (!opt) {
- opt = !url || typeof url === "string" ? {} : url;
- }
- if (opt.hasOwnProperty("url")) {
- modalOptions.url = opt.url;
- } else if (typeof url === "string") {
- modalOptions.url = url;
- } else {
- modalOptions.url = $tableTool.find('.menu-btn[data-type=' + type + ']').data('url');
- modalOptions.url = modalOptions.url
- ? modalOptions.url
- : $tableTool.find('.menu-btn[data-type=_' + type + ']').data('url');
- }
- modalOptions.modal =
- typeof $that.options.modal === 'string' ? $("#" + $that.options.modal) : $($that.options.modal);
- modalOptions.table = $table;
- //modalOptions.type = type.toLowerCase().indexOf('btnupdate') === 0 ? 'put' : 'post';
- modalOptions.type = 'post';
- modalOptions = $.extend({}, modalOptions, opt);
- return modalOptions;
- };
- //选中事件操作数组
- var union = function (array, rows) {
- rows.forEach(function (row) {
- var index = selectionRows.findIndex(function (v) {
- return v.id === row.id;
- });
- if (index === -1) {
- array[array.length] = row;
- }
- });
- return array;
- };
- //取消选中事件操作数组
- var difference = function (array, rows) {
- rows.forEach(function (row) {
- var index = selectionRows.findIndex(function (v) {
- return v.id === row.id;
- });
- if (index !== -1) {
- array.splice(index, 1);
- }
- });
- return array;
- };
- var Table = function (ele, opt) {
- var $that = this;
- this.defaults = {
- url: undefined,
- table: undefined,
- tableTool: '',
- resetView: true,
- height: undefined,
- searchForm: 'search-form',
- searchList: [],
- searchFun: null,
- onlySearchList: false,
- searchValidate: true,
- queryParams: function (p) { return queryParams(p, $that); },
- onAll: function (e, d) { onAll(e, d, $that); },
- onLoadSuccess: function (d) { onLoadSuccess(d, $that); },
- onPostBody: function (d) { onPostBody(d, $that); },
- isPage: true,
- lang: 'zh-CN',
- funs: undefined,
- modal: 'modal',
- form: 'form',
- modalDrag: true,
- multipleSelect: false//多选保存分页数据
- };
- $that.options = $.extend({}, this.defaults, opt || {});
- if (!$that.options.onAll) {
- $that.options.onAll = function (e, d) {
- onAll(e, d, $that);
- };
- }
- this.$ele = ele,
- this.loadTable();
- return this;
- };
- Table.prototype.loadTable = function () {
- var $that = this;
- $that.options.maintainMetaData = $that.options.multipleSelect;
- $that.options.responseHandler = $that.options.responseHandler
- ? $that.options.responseHandler
- : $that.options.isPage
- ? responseHandler
- : responseHandlerNoPage;
- $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales[$that.options.lang]);
- var o = $that.options;
- //searchList = o.searchList;
- getSearchList($that);
- var $table = (typeof (o.table) === 'string' ? $('#' + o.table) : $(o.table));
- $table.bootstrapTable($that.options);
- if (o.resetView) {
- var h = o.height ? o.height : $(window).height() - 150;
- $that.resetView(h);
- $(window).resize(function () {
- $that.resetView();
- });
- }
- if (o.multipleSelect) {
- selectionRows = [];
- var _ = { "union": union, "difference": difference };
- //绑定选中事件、取消事件、全部选中、全部取消
- $table.on('check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table', function (e, rows) {
- rows = $.map(!$.isArray(rows) ? [rows] : rows, function (row) {
- return row;
- });
- var func = $.inArray(e.type, ['check', 'check-all']) > -1 ? 'union' : 'difference';
- selectionRows = _[func](selectionRows, rows);
- });
- }
- return this;
- };
- Table.prototype.refresh = function (isForce) {
- var $that = this;
- abp.ui.setBusy();
- setTimeout(function () { abp.ui.clearBusy(); isSearching = false; }, 5 * 1000);
- if (isSearching) {
- return;
- }
- isSearching = true;
- //getSearchList($that);
- //if (!isForce && searchList.length <= 0) {
- // console.log("Search-Multi-None");
- // return;
- //}
- var o = $that.options;
- var $searchForm = (typeof (o.searchForm) === 'string' ? $('#' + o.searchForm) : $(o.searchForm));
- var isValidated = true;
- if (o.searchValidate && $searchForm && $searchForm.length > 0) {
- isValidated = $.formValidate($searchForm);
- }
- if (isValidated) {
- var $table = (typeof (o.table) === 'string' ? $('#' + o.table) : $(o.table));
- selectionRows = [];
- $table.bootstrapTable('refresh', { silent: true });
- console.log("Search");
- } else {
- console.log("Search_Validate_Faild");
- }
- };
- Table.prototype.resetView = function (height) {
- var $that = this;
- var o = $that.options;
- var $table = (typeof (o.table) === 'string' ? $('#' + o.table) : $(o.table));
- $table.bootstrapTable('resetView', { height: height });
- };
- Table.prototype.destroy = function () {
- var $that = this;
- var o = $that.options;
- var $table = (typeof (o.table) === 'string' ? $('#' + o.table) : $(o.table));
- $table.bootstrapTable('destroy', { silent: true });
- };
- Table.prototype.getFuns = function () {
- var $that = this;
- $that.options.funs = $that.options.funs ||
- {
- btnCreate: function (url) { $that.defaultCreate(url); },
- btnUpdate: function (url) { $that.defaultUpdate(url); },
- btnDelete: function (url) { $that.defaultDelete(url); },
- btnSearch: function () { $that.refresh(true); },
- none: function () { console.log("No type"); }
- };
- return $that.options.funs;
- };
- Table.prototype.addFuns = function (key, fun) {
- var $that = this;
- var funs = $that.getFuns();
- funs[key] = fun;
- $that.options.funs = funs;
- };
- Table.prototype.defaultCreate = function (url, opt) {
- var $that = this;
- console.log("Add");
- opt = opt || {};
- var modalOptions = getModal(url, opt, abp.localization.iwbZero('OpCreate'), 'btnCreate', $that);
- var $modal = typeof modalOptions.modal === 'string' ? $('#' + modalOptions.modal) : $(modalOptions.modal);
- $modal.iwbModal(modalOptions);
- };
- Table.prototype.defaultUpdate = function (url, opt, row) {
- var $that = this;
- console.log("Update");
- var o = $that.options;
- var $table = (typeof (o.table) === 'string' ? $('#' + o.table) : $(o.table));
- opt = opt || {};
- row = row || opt.row || $table.bootstrapTable("getSelections")[0];
- if (row) {
- var modalOptions = getModal(url, opt, abp.localization.iwbZero('OpUpdate'), 'btnUpdate', $that);
- if (!modalOptions.data) {
- modalOptions.data = row;
- }
- var $modal = typeof (modalOptions.modal) === 'string' ? $('#' + modalOptions.modal) : $(modalOptions.modal);
- $modal.iwbModal(modalOptions);
- } else
- abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
- };
- Table.prototype.defaultDelete = function (url, opt, row) {
- console.log("Delete");
- var $that = this;
- var o = $that.options;
- var $table = (typeof (o.table) === 'string' ? $('#' + o.table) : $(o.table));
- opt = opt || {};
- row = row || opt.row || $table.bootstrapTable("getSelections")[0];
- if (row) {
- var data = opt.data || { id: row.id };
- abp.message.confirm(abp.localization.iwbZero('DeleteConfirmContent'),
- abp.localization.iwbZero('DeleteConfirm'),
- function (isConfirmed) {
- if (isConfirmed) {
- $.iwbAjax({ table: $table, url: url + '?id=' + data.id, data: data, type: 'post', isValidate: false });
- }
- });
- } else
- abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
- };
- Table.prototype.setSearchList = function (obj) {
- var $that = this;
- var o = $that.options;
- o.searchList = obj;
- };
- Table.prototype.getSelections = function () {
- var $that = this;
- var o = $that.options;
- if (o.multipleSelect) {
- return selectionRows;
- }
- var $table = (typeof (o.table) === 'string' ? $('#' + o.table) : $(o.table));
- return $table.bootstrapTable("getSelections");
- }
- Table.prototype.getAllSelections = function () {
- var $that = this;
- var o = $that.options;
- if (o.multipleSelect) {
- return selectionRows;
- }
- var $table = (typeof (o.table) === 'string' ? $('#' + o.table) : $(o.table));
- return $table.bootstrapTable("getAllSelections");
- }
- var allowedMethods = [
- 'loadTable',
- 'refresh',
- 'getFuns',
- 'defaultCreate',
- 'defaultUpdate',
- 'defaultDelete',
- 'resetView',
- 'destroy',
- 'setSearchList',
- 'getSelections',
- 'getAllSelections',
- ];
- $.fn.iwbTable = function (option) {
- var value,
- args = Array.prototype.slice.call(arguments, 1);
- this.each(function () {
- var $this = $(this);
- var data = $this.data('iwb.table'),
- options = $.extend({}, $this.data(),
- typeof option === 'object' && option);
- if (typeof option === 'string') {
- if ($.inArray(option, allowedMethods) < 0) {
- throw new Error("Unknown method: " + option);
- }
- if (!data) {
- return;
- }
- value = data[option].apply(data, args);
- if (option === 'destroy') {
- $this.removeData('iwb.table');
- $this.removeData('iwbtable.init');
- return;
- }
- }
- if ($this.data('iwbtable.init')) {
- return;
- }
- $this.data('iwbtable.init', true);
- if (!data) {
- data = new Table(this, options);
- $this.data('iwb.table', data);
- }
- });
- return typeof value === 'undefined' ? this : value;
- };
- })(jQuery, window, document);
- /*Modal*/
- (function ($, window, document, undefined) {
- 'use strict';
- var Modal = function (ele, opt) {
- this.$ele = ele,
- this.defaults = {
- modal: ele,
- modaltitle: '',
- data: null,
- dataFun: undefined,
- form: null,
- table: undefined,
- errorPlacement: function (error, element) {
- element.parent().before(error);
- //if (element.is('select')) {
- // if (!element.next().next().hasClass('error')) {
- // element.next().after(error);
- // element.focus();
- // }
- //} else {
- // element.parent().before(error);
- // element.focus();
- //}
- },
- rules: {},
- readonly: '',
- disabled: '',
- notClear: '',
- select2: true,
- select2tree: false,
- url: '',
- type: 'post',
- savebtn: null,
- save: null,
- success: null,
- shownBefore: null,
- shownAfter: null,
- isRefresh: true,
- draggable: true,
- backdrop: 'static',
- keyboard: true,
- kindeditorOption: {},
- content: undefined,
- ajaxSelect: true,
- abp: window.abp
- },
- this.options = $.extend({}, this.defaults, opt);
- this.draggable();
- };
- var select2Opt = window.select2DefaultOption || {};
- //var abp = window.abp || {};
- Modal.prototype.getModal = function () {
- var $that = this;
- var $modal = $that.options.modalId
- ? $('#' + $that.options.modalId)
- : typeof ($that.options.modal) === 'string'
- ? $('#' + $that.options.modal)
- : $($that.options.modal);
- return $modal;
- };
- Modal.prototype.open = function () {
- var $that = this;
- var $modal = $that.getModal();
- $modal.off('show.bs.modal.open').on('show.bs.modal.open',
- function () {
- $that.showBefore();
- $that.init();
- $that.initWangEditor();
- $that.setData();
- $that.setSelect2();
- $that.initKindeditor();
- $that.setWangEditorData();
- $that.verticalCenter();
- $that.bindSave();
- $.formValidate($modal.find('form'), { noValid: true });
- $that.showAfter();
- });
- $that.show2();
- };
- Modal.prototype.show = function () {
- var $that = this;
- var $modal = $that.getModal();
- $modal.off('show.bs.modal.open').on('show.bs.modal.open',
- function () {
- $that.showBefore();
- $that.initWangEditor();
- $that.setData();
- $that.setSelect2();
- $that.initKindeditor();
- $that.setWangEditorData();
- $that.verticalCenter();
- $.formValidate($modal.find('form'), { noValid: true });
- $that.showAfter();
- });
- $that.show2();
- };
- Modal.prototype.show2 = function ($modal) {
- var $that = this, o = $that.options;
- $modal = $modal || $that.getModal();
- $modal.modal({ backdrop: o.backdrop, keyboard: o.keyboard });
- $modal.modal('show');
- //$that.verticalCenter();
- };
- Modal.prototype.create = function (opts) {
- var $that = this, o = $that.options = $.extend({}, $that.options, opts);
- if (!o.modalId) {
- if (o.modal) {
- o.modalId = typeof (o.modal) === 'string' ? o.modal : $(o.modal).attr('id');
- } else {
- o.modalId = 'Modal_' + (Math.floor((Math.random() * 1000000))) + new Date().getTime();
- }
- }
- if (o.modalSize === null) {
- o.modalSize = "";
- }
- else if (!o.modalSize) {
- o.modalSize = 'modal-lg';
- }
- if (o.width) {
- o.widthStr = 'max-width:' + o.width + 'px';
- }
- var createContainer = function (modalId, modalSize, width) {
- abp.ui.setBusy($("body"));
- $that.removeContainer(modalId);
- var containerId = modalId + 'Container';
- return $('<div id="' + containerId + '" tabindex="-1"></div>')
- .append(
- '<div id="' + modalId + '" class="modal fade">' +
- ' <div class="modal-dialog modal-dialog-centered ' + modalSize + '" style="' + width + '">' +
- ' <div class="modal-content"></div>' +
- ' </div>' +
- '</div>'
- ).appendTo('body');
- };
- var show = function () {
- $('#' + o.modalId).off('show.bs.modal').on('show.bs.modal', function () {
- $that.showBefore();
- if (o.data) {
- $that.setData();
- }
- $that.setSelect2();
- $that.bindSave();
- $.formValidate($('#' + o.modalId).find('form'), { noValid: true });
- $that.showAfter();
- });
- $that.show2();
- //$('#' + o.modalId).modal({ backdrop: o.backdrop, keyboard: o.keyboard }).modal('show');
- abp.ui.clearBusy($("body"));
- };
- var $modalContent = createContainer(o.modalId, o.modalSize, o.widthStr).find('.modal-content');
- if (o.viewUrl) {
- $modalContent.load(o.viewUrl, o.args, function (response, status, xhr) {
- if (status === "error") {
- abp.message.warn(abp.localization.abpWeb('InternalServerError'));
- return;
- }
- if (o.scriptUrl) {
- $.loadScript(o.scriptUrl, function () {
- show();
- });
- } else {
- show();
- }
- });
- } else if (o.content) {
- $modalContent.append(o.content);
- show();
- } else if (o.modalBody) {
- var modalHeader = o.modalHeader
- ? modalHeader
- : '<div class="modal-header"><h4 class="modal-title"><span class="modal-title-span">' +
- (o.modaltitle ? o.modaltitle : "") +
- '</span></h4><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div>';
- var modalFooter = o.modalFooter
- ? modalFooter
- : '<div class="modal-footer" style="text-align: center;"><button type="button" class="btn btn-sm btn-outline-iwb waves-effect" data-dismiss="modal" style="min-width:100px;">取消</button><button type="button" class="btn btn-iwb btn-sm save-btn waves-effect" style="min-width:100px;">保存</button></div>';
- $modalContent.append(modalHeader);
- $modalContent.append(o.modalBody);
- $modalContent.append(modalFooter);
- show();
- } else {
- abp.ui.clearBusy($("body"));
- return;
- }
- };
- Modal.prototype.hide = function () {
- var $that = this, o = $that.options;
- var $modal = $that.getModal();
- if (o.modalId) {
- $that.removeContainer(o.modalId);
- }
- return $modal.modal('hide');
- };
- Modal.prototype.removeContainer = function (modalId) {
- var containerId = modalId + 'Container';
- var containerSelector = '#' + containerId;
- var $container = $(containerSelector);
- if ($container.length) {
- $container.remove();
- }
- };
- Modal.prototype.showBefore = function () {
- var $that = this;
- if ($that.options.shownBefore && typeof ($that.options.shownBefore) === 'function') {
- $that.options.shownBefore($that);
- }
- };
- Modal.prototype.showAfter = function () {
- var $that = this;
- if ($that.options.shownAfter && typeof ($that.options.shownAfter) === 'function') {
- $that.options.shownAfter($that);
- }
- };
- Modal.prototype.init = function () {
- var $that = this;
- var $modal = $that.getModal();
- $that.clearOldVal();
- $modal.find('input,select,textarea').removeClass('error valid not-clear');
- $modal.find('input:not(.disabled),select:not(.disabled),textarea:not(.disabled)').prop('disabled', false);
- $modal.find('input:not(.readonly),select:not(.readonly),textarea:not(.readonly)').prop('readonly', false);
- $modal.find('label.error').remove();
- $modal.find('.modal-title-span').html($that.options.modaltitle);
- $that.setReadonly();
- $that.setDisabled();
- $that.cleanFile();
- $modal.find('input:not(:disabled,[type=\'hidden\'],[readonly=\'readonly\']):first').focus();
- };
- Modal.prototype.clearOldVal = function () {
- var $that = this;
- var $modal = $that.getModal();
- if ($that.options.notClear) {
- var notClear = $that.options.notClear.split(',');
- for (var i = 0; i < notClear.length; i++) {
- if (notClear[i]) {
- $modal.find('#' + notClear[i]).addClass('not-clear');
- }
- }
- }
- $modal.find('input:not(.not-clear),select:not(.not-clear),textarea:not(.not-clear)').val('');
- };
- Modal.prototype.setReadonly = function () {
- var $that = this;
- var $modal = $that.getModal();
- if (!$that.options.readonly)
- return;
- var readonly = $that.options.readonly.split(',');
- for (var i = 0; i < readonly.length; i++) {
- if (readonly[i]) {
- $modal.find('#' + readonly[i]).prop('readonly', true);
- }
- }
- };
- Modal.prototype.setDisabled = function () {
- var $that = this;
- var $modal = $that.getModal();
- if (!$that.options.disabled)
- return;
- var disabled = $that.options.disabled.split(',');
- for (var i = 0; i < disabled.length; i++) {
- if (disabled[i]) {
- $modal.find('#' + disabled[i]).prop('disabled', true);
- }
- }
- };
- Modal.prototype.setData = function () {
- var $that = this;
- var $modal = $that.getModal();
- var $form = $that.options.form ? $($that.options.form) : $modal.find('form');
- $('.ajax-select').addClass("set-value");
- $.formDeserialize($form, $that.options.data);
- };
- Modal.prototype.setSelect2 = function () {
- var $that = this;
- var $modal = $that.getModal();
- if ($that.options.select2) {
- $modal.find("select").trigger('change');
- $modal.find('select').off("change.ff").on("change.ff",
- function () {
- $(this).focus();
- $(this).next(".error").remove();
- $(this).blur();
- });
- }
- if ($that.options.select2tree) {
- var tree = $that.options.select2tree.split(',');
- for (var i = 0; i < tree.length; i++) {
- $modal.find('#' + tree[i]).select2tree();
- }
- }
- };
- Modal.prototype.initKindeditor = function () {
- var $that = this;
- var $modal = $that.getModal();
- $modal.find('textarea.kindeditor').each(function (i, v) {
- if ($(v).length && $.fn.iwbKindeditor) {
- var val = $(v).val();
- if ($(v).data("iwb.kindEditor")) {
- $(v).iwbKindeditor('remove');
- }
- var option = $that.options.kindeditorOption || {};
- $(v).iwbKindeditor(option);
- window.editor_K[$(v).attr('id')].html(val);
- }
- });
- };
- Modal.prototype.initWangEditor = function () {
- var $that = this;
- var $modal = $that.getModal();
- $modal.find('div.iwb-wang-editor').each(function (i, v) {
- if ($(v).length && $.fn.iwbWangEditor) {
- if (!$(v).data("iwb.WangEditor")) {
- var option = $that.options.wangEditorOption || {};
- $(v).iwbWangEditor(option);
- }
- }
- });
- };
- Modal.prototype.setWangEditorData = function () {
- var $that = this;
- var $modal = $that.getModal();
- $modal.find('div.iwb-wang-editor').each(function (i, v) {
- if ($(v).length && $.fn.iwbWangEditor) {
- if ($(v).data("iwb.WangEditor")) {
- var val = $('#' + $(v).data('id')).val();
- $(v).iwbWangEditor('setContent', val);
- }
- }
- });
- };
- Modal.prototype.cleanFile = function () {
- var $that = this;
- var $modal = $that.getModal();
- $modal.find('input[type="file"]').each(function (i, v) {
- $(v).iwbFileUpload('cleanFile');
- });
- };
- Modal.prototype.bindSave = function () {
- var $that = this;
- var $modal = $that.getModal();
- var $saveBtn = $that.options.savebtn
- ? $($that.options.savebtn)
- : $modal.find('.save-btn').length > 0
- ? $modal.find('.save-btn')
- : $modal.find('.save').length > 0
- ? $modal.find('.save')
- : $modal.find('#save');
- var opt = $that.getSaveOptions(), ajaxSelectFun;
- if ($that.options.ajaxSelect) {
- ajaxSelectFun = function () {
- $modal.find('select.ajax-select').each(function () {
- var $this = $(this);
- var tKey = $this.data('table-key'),
- cKey = $this.data('column-key'),
- val = $this.val(),
- name = $this.find("option[value='" + val + "']").text(), ran = Math.floor(Math.random() * 9999);
- console.log('AjaxSelect[{4}]:{0}-{1}-{2}-{3}'.format(tKey, cKey, val, name, ran));
- $.iwbAjax41({
- url: abp.appUrl + "Query/AddAcInfo",
- data: {
- TableKey: tKey,
- ColumnKey: cKey,
- ValueKey: val,
- NameKey: name
- },
- success: function (r) {
- console.log('AjaxSelect[{0}]:Success'.format(ran));
- }
- });
- });
- }
- }
- var save = null;
- if ($that.options.save && typeof ($that.options.save) === "function") {
- save = function () { $that.options.save(opt); };
- } else if ($that.options.url) {
- save = function () { $.iwbAjax($that.options.url, opt); };
- }
- var saveFun =
- function () {
- if (save && $.isFunction(save)) {
- save();
- }
- if (ajaxSelectFun && $.isFunction(ajaxSelectFun)) {
- ajaxSelectFun();
- }
- }
- $saveBtn.off('click.save').on('click.save', saveFun);
- $modal.find('.modal-body input').keydown(function (e) {
- if (e.which === 13) {
- if (e.target.tagName.toLocaleLowerCase() === "textarea") {
- e.stopPropagation();
- } else {
- e.preventDefault();
- saveFun.call(this);
- }
- }
- });
- //var opt = $that.getSaveOptions();
- //if ($that.options.save && typeof $that.options.save === "function") {
- // $that.options.save(opt);
- //} else {
- // $.iwbAjax($that.options.url, opt);
- //}
- };
- Modal.prototype.getSaveOptions = function () {
- var $that = this;
- var $modal = $that.getModal();
- var $form = $that.options.form ? $($that.options.form) : $modal.find('form');
- return {
- url: $that.options.url,
- type: $that.options.type,
- success: $that.options.success,
- form: $form,
- data: null,
- dataFun: $that.options.dataFun,
- table: $that.options.table,
- modal: $that.options.modal,
- blockUI: $modal.find('.modal-content'),
- isRefresh: $that.options.isRefresh
- };
- };
- Modal.prototype.verticalCenter = function () {
- var $that = this;
- var $modal = $that.getModal();
- $modal.css('display', 'block');
- var topHeight = $(window).height() - $modal.find('.modal-dialog').height() - 150;
- if (topHeight < 30) {
- topHeight = 30;
- }
- $modal.find('.modal-dialog').animate({ 'marginTop': topHeight / 2 + "px" });
- };
- Modal.prototype.draggable = function () {
- var $that = this;
- var $modal = $that.getModal();
- if ($that.options.draggable) {
- //console.log('draggable');
- $('.modal-header').css('cursor', 'move');
- /** 拖拽模态框*/
- var dragModal = {
- mouseStartPoint: { 'left': 0, 'top': 0 },
- mouseEndPoint: { 'left': 0, 'top': 0 },
- mouseDragDown: false,
- basePoint: { 'left': 0, 'top': 0 },
- moveTarget: null,
- topleng: 0
- };
- $modal.off('mousedown.drag').on('mousedown.drag',
- '.modal-header',
- function (e) {
- //webkit内核和火狐禁止文字被选中
- $('body').addClass('drag-select');
- //ie浏览器禁止文字选中
- document.body.onselectstart = document.body.ondrag = function () {
- return false;
- };
- if ($(e.target).hasClass('close')) //点关闭按钮不能移动对话框
- return;
- dragModal.mouseDragDown = true;
- dragModal.moveTargetHeader = $(this);
- dragModal.moveTarget = $(this).closest('.modal-content');
- dragModal.mouseStartPoint = { 'left': e.clientX, 'top': e.pageY };
- dragModal.basePoint = dragModal.moveTarget.offset();
- dragModal.topLeng = e.pageY - e.clientY;
- });
- $modal.off('mouseup.drag').on('mouseup.drag',
- function () {
- dragModal.mouseDragDown = false;
- dragModal.moveTarget = undefined;
- dragModal.mouseStartPoint = { 'left': 0, 'top': 0 };
- dragModal.basePoint = { 'left': 0, 'top': 0 };
- });
- $modal.off('mousemove.drag').on('mousemove.drag',
- function (e) {
- if (!dragModal.mouseDragDown || dragModal.moveTarget === undefined) return;
- var mousX = e.clientX;
- var mousY = e.pageY;
- if (mousX < 0) mousX = 0;
- if (mousY < 0) mousY = 25;
- dragModal.mouseEndPoint = { 'left': mousX, 'top': mousY };
- var width = dragModal.moveTarget.width();
- var height = dragModal.moveTargetHeader.height();
- var clientWidth = document.body.clientWidth;
- var clientHeight = document.body.clientHeight;
- if (dragModal.mouseEndPoint.left < dragModal.mouseStartPoint.left - dragModal.basePoint.left) {
- dragModal.mouseEndPoint.left = 0;
- } else if (dragModal.mouseEndPoint.left >=
- clientWidth - width + dragModal.mouseStartPoint.left - dragModal.basePoint.left) {
- dragModal.mouseEndPoint.left = clientWidth - width - 38;
- } else {
- dragModal.mouseEndPoint.left =
- dragModal.mouseEndPoint.left -
- (dragModal.mouseStartPoint.left - dragModal.basePoint.left); //移动修正,更平滑
- }
- if (dragModal.mouseEndPoint.top - (dragModal.mouseStartPoint.top - dragModal.basePoint.top) <
- dragModal.topLeng) {
- dragModal.mouseEndPoint.top = dragModal.topLeng;
- } else if (dragModal.mouseEndPoint.top - dragModal.topLeng >
- clientHeight - height + dragModal.mouseStartPoint.top - dragModal.basePoint.top) {
- dragModal.mouseEndPoint.top = clientHeight - height - 38 + dragModal.topLeng;
- } else {
- dragModal.mouseEndPoint.top = dragModal.mouseEndPoint.top -
- (dragModal.mouseStartPoint.top - dragModal.basePoint.top);
- }
- dragModal.moveTarget.offset(dragModal.mouseEndPoint);
- });
- $(document).on('hidden.bs.modal',
- '.modal',
- function () {
- $('.modal-content').css({ 'top': 0, 'left': 0 });
- $('body').removeClass('drag-select');
- document.body.onselectstart = document.body.ondrag = null;
- });
- } else {
- $('.modal-header').css('cursor', 'default');
- }
- };
- var allowedMethods = [
- 'open',
- 'show',
- 'show2',
- 'hide',
- 'create'
- ];
- $.fn.iwbModal = function (option) {
- var value,
- args = Array.prototype.slice.call(arguments, 1);
- this.each(function () {
- var modal = new Modal(this, option);
- if (typeof option === 'string') {
- if ($.inArray(option, allowedMethods) < 0) {
- throw new Error("Unknown method: " + option);
- }
- value = modal[option].apply(modal, args);
- } else {
- modal.open();
- }
- });
- return typeof value === 'undefined' ? this : value;
- };
- })(jQuery, window, document);
- /*FileUpload*/
- (function ($, window, document, undefined) {
- 'use strict';
- var abp = window.abp || {};
- var File = function (ele, opt) {
- this.$ele = ele,
- this.defaults = {
- file: ele,
- maxSize: 2,
- isImage: true,
- targetInfo: undefined,
- targetName: "fileName",
- targetExt: "fileExt",
- callback: undefined,
- abp: window.abp
- },
- this.options = $.extend({}, this.defaults, opt || {});
- //var $that = this;
- //$that.show();
- };
- File.prototype.getFile = function () {
- var $that = this;
- var $file = typeof ($that.options.file) === 'string' ? $('#' + $that.options.file) : $($that.options.file);
- return $file;
- };
- File.prototype.show = function () {
- var $that = this;
- var $file = $that.getFile();
- $file.off('change.file.check').on('change.file.check', function () {
- $that.fileCheck($that);
- });
- $file.closest('.iwb-file ').removeClass("file-success").removeClass("file-error");
- //return $file[0].click();
- };
- File.prototype.fileCheck = function ($that) {
- var $file = $that.getFile();
- if ($that.checkSize()) {
- var fileName = $file.val().split("\\").pop();
- $file.closest('.iwb-file ').addClass("file-success").find("label").text(fileName);
- var file = document.getElementById($file.attr("id")).files[0];
- $that.readFile(file);
- if ($that.options.targetName && $that.options.targetName !== undefined) {
- var name = fileName.substring(0, fileName.lastIndexOf("."));
- if (!$that.options.targetName)
- return;
- var targetName = $that.options.targetName.split(',');
- for (var i = 0; i < targetName.length; i++) {
- $('#' + targetName[i]).val(name);
- }
- }
- if ($that.options.targetExt && $that.options.targetExt !== undefined) {
- var ext = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length);
- if (!$that.options.targetExt)
- return;
- var targetExt = $that.options.targetExt.split(',');
- for (var j = 0; j < targetExt.length; j++) {
- $('#' + targetExt[j]).val(ext);
- }
- }
- var callback = $that.options.callback;
- if (callback && typeof (callback) === "function") {
- callback(fileName, file);
- }
- } else {
- var target = $that.options.targetInfo ? $that.options.targetInfo : $file.attr('id').replace('_file', '');
- $('#' + target).closest('.iwb-file ').addClass("file-error").find("label").text(abp.localization.iwbZero('SelectFile'));
- }
- };
- File.prototype.checkSize = function () {
- var $that = this;
- var $file = $that.getFile();
- var maxsize = $that.options.maxSize * 1024 * 1024;
- //var errMsg = "上传的附件文件不能超过" + $that.options.maxSize + "M。";
- //var tipMsg = "您的浏览器暂不支持计算上传文件的大小,确保上传文件不要超过" + $that.options.maxSize + "M,建议使用IE、FireFox、Chrome浏览器。";
- var errMsg = abp.localization.iwbZero('FileUploadErrorMsg', $that.options.maxSize);
- var tipMsg = abp.localization.iwbZero('FileUploadTipMsg', $that.options.maxSize);
- var browserCfg = {};
- var ua = window.navigator.userAgent;
- if (ua.indexOf("MSIE") >= 1) {
- browserCfg.ie = true;
- } else if (ua.indexOf("Firefox") >= 1) {
- browserCfg.firefox = true;
- } else if (ua.indexOf("Chrome") >= 1) {
- browserCfg.chrome = true;
- }
- try {
- var objFile = document.getElementById($file.attr("id"));
- if (objFile.value === "") {
- //layer.alert("请先选择上传文件", { icon: 7, title: "提示信息" });
- return false;
- }
- var filesize;
- if (browserCfg.firefox || browserCfg.chrome) {
- filesize = objFile.files[0].size;
- } else if (browserCfg.ie) {
- var objImg = document.createElement("img");
- objImg.id = "tempImg";
- objImg.style.display = "none";
- document.body.appendChild(objImg);
- objImg.dynsrc = objFile.value;
- filesize = objImg.fileSize;
- } else {
- $that.cleanFile();
- abp.message.warn(tipMsg);
- return false;
- }
- if (filesize === -1) {
- $that.cleanFile();
- abp.message.warn(tipMsg);
- return false;
- } else if (filesize > maxsize) {
- $that.cleanFile();
- abp.message.warn(errMsg);
- return false;
- } else {
- return true;
- }
- } catch (e) {
- $that.cleanFile();
- abp.message.error(e);
- return false;
- }
- };
- File.prototype.readFile = function (file) {
- //判断是否是图片类型
- //console.log(file.type);
- if (!file) {
- return;
- }
- var $that = this;
- var $file = $that.getFile();
- if ($that.options.isImage && !/image\/\w+/.test(file.type)) {
- abp.message.warn(abp.localization.iwbZero('FileUploadOnlyImage'));
- return;
- }
- var reader = new FileReader();
- reader.readAsDataURL(file);
- reader.onload = function () {
- var fileinfo = this.result.substring(this.result.indexOf(',') + 1);
- console.log(fileinfo);
- var target = $that.options.targetInfo ? $that.options.targetInfo : $file.attr('id').replace('_file', '');
- $('#' + target).val(fileinfo);
- };
- };
- File.prototype.cleanFile = function () {
- var $that = this;
- var $file = $that.getFile();
- $file.closest('.iwb-file ').removeClass("file-success").removeClass("file-error").find("label").text(abp.localization.iwbZero('SelectFile'));
- $file.closest('.iwb-file ').find('input').val('');
- $file.after($file.clone().val(""));
- $file.remove();
- };
- var allowedMethods = [
- 'show',
- 'readFile',
- 'cleanFile',
- 'fileCheck',
- 'checkSize'
- ];
- $.fn.iwbFileUpload = function (option) {
- var value,
- args = Array.prototype.slice.call(arguments, 1);
- this.each(function () {
- var $this = $(this);
- var data = $this.data('iwb.FileUpload');
- if (!data) {
- data = new File(this, option);
- $this.data('iwb.FileUpload', data);
- }
- if (typeof option === 'string') {
- if ($.inArray(option, allowedMethods) < 0) {
- throw new Error("Unknown method: " + option);
- }
- value = data[option].apply(data, args);
- } else {
- data.show();
- }
- });
- return typeof value === 'undefined' ? this : value;
- };
- })(jQuery, window, document);
- /*FileOpenShow*/
- (function ($, window, document, undefined) {
- 'use strict';
- var File = function (ele, opt) {
- this.$ele = ele,
- this.defaults = {
- url: undefined,
- type: 'img'
- },
- this.options = $.extend({}, this.defaults, opt);
- if ($(this.$ele).data('type')) {
- this.options.type = $(this.$ele).data('type');
- }
- if (!this.options.url) {
- this.options.url = $(this.$ele).data('url');
- }
- if (this.options.url && this.options.url.indexOf("/") !== 0) {
- this.options.url = "/" + this.options.url;
- }
- };
- //var abp = window.abp || {};
- File.prototype.show = function () {
- var $that = this;
- switch ($that.options.type) {
- case 'img':
- case 'image':
- this.showImage();
- break;
- case 'office':
- this.showOffice();
- break;
- default:
- this.showFile();
- return;
- }
- };
- File.prototype.showImage = function () {
- var $that = this;
- $.metPageCss('/Content/Libs/viewer/viewer.min.css', "dy-css-viewer");
- $.metPageJs('/Content/Libs/viewer/viewer.min.js', "dy-js-viewer");
- if ($("#Img-Modal").length > 0) {
- $("#Img-Modal").remove();
- }
- $("body").append(' <ul id="Img-Modal" style="display:none"><li><img src="' +
- $that.options.url +
- '" data-original="' +
- $that.options.url +
- '" alt="Picture" /></li></ul>');
- var $image = $('#Img-Modal');
- var options = {
- // inline: true,
- url: 'data-original',
- button: true,
- navbar: false,
- title: false,
- toolbar: false,
- ready: function (e) {
- console.log(e.type);
- }
- };
- $image.on({
- show: function (e) {
- console.log(e.type);
- },
- hidden: function (e) {
- $image.viewer('destroy');
- $image.remove();
- }
- }).viewer(options);
- $image.viewer("show");
- $image.css("display", "none");
- };
- File.prototype.showOffice = function () {
- var $that = this;
- var url = 'http://ow365.cn/?i=17314&furl=http://' + window.location.host + $that.options.url;
- $that.showFile(url);
- };
- File.prototype.showFile = function (url) {
- var $that = this;
- url = url || $that.options.url;
- if ($('#File-Modal').length <= 0) {
- $('body').append(
- '<section><div class="modal fade" id="File-Modal" role="dialog" tabindex="-1" aria-hidden="true"><div class="modal-dialog modal-dialog-centered" role="document" style="min-width: calc(100% - 600px);"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span aria-hidden="true">×</span></button><h4 class="modal-title">文件预览</h4></div><div class="modal-body" style=" overflow: hide"></div><div class="modal-footer" style="text-align: center;"><button type="button" class="btn btn-success waves-effect" data-dismiss="modal" style="min-width: 100px;background: #F0985D;border: 1px solid #DDDDDD;">关闭窗口</button><button id="download" type="button" class="btn btn-success waves-effect" style="min-width: 100px;background-color: #678ceb;border: 1px solid #678ceb;border: 1px solid #DDDDDD;">下载文件</button></div></div></div></div></section>');
- }
- $('#File-Modal').find('.modal-body')
- .html('<iframe src="' + url + '" width="100%"; style="min-height: calc(100vh - 200px);" frameborder="0"></iframe>');
- $(document).off('click.download', '#File-Modal #download').on('click.download', '#File-Modal #download',
- function () { $that.download(url) });
- $('#File-Modal').iwbModal('show2');
- };
- File.prototype.download = function (url) {
- var $that = this;
- url = url || $that.options.url;
- if ($('#tempLink-fd').length > 0) {
- $('#tempLink-fd').remove();
- }
- $('body').append('<a id="tempLink-fd" href="' + url + '" style="display:none"></a>');
- $('#tempLink-fd')[0].click();
- $('#tempLink-fd').remove();
- };
- var allowedMethods = [
- 'show',
- 'download'
- ];
- $.fn.iwbFileShow = function (option) {
- var value,
- args = Array.prototype.slice.call(arguments, 1);
- this.each(function () {
- var $this = $(this);
- var data = $this.data('iwb.FileShow');
- if (!data || typeof option !== 'string') {
- data = new File(this, option);
- $this.data('iwb.FileShow', data);
- }
- if (typeof option === 'string') {
- if ($.inArray(option, allowedMethods) < 0) {
- throw new Error("Unknown method: " + option);
- }
- value = data[option].apply(data, args);
- } else {
- data.show();
- }
- });
- return typeof value === 'undefined' ? this : value;
- };
- })(jQuery, window, document);
- /*TreeView*/
- (function ($, window, document, undefined) {
- 'use strict';
- var TreeView = function (ele, opt) {
- var that = this;
- var tempId = '';
- var onNodeSelected = function (e, data, that) {
- var o = that.options;
- if (!data || !data[o.selectFiledName]) {
- return;
- }
- var $input = (typeof (o.selectFiledInput) === 'string' ? $('#' + o.selectFiledInput) : $(o.selectFiledInput));
- tempId = data[o.selectFiledName];
- $input.val(tempId);
- var $table = (typeof (o.table) === 'string' ? $('#' + o.table) : $(o.table));
- $table.iwbTable('refresh', true);
- };
- var onNodeUnselected = function (e, data, that) {
- var o = that.options;
- var $input = (typeof (o.selectFiledInput) === 'string' ? $('#' + o.selectFiledInput) : $(o.selectFiledInput));
- $input.val('');
- var $table = (typeof (o.table) === 'string' ? $('#' + o.table) : $(o.table));
- $table.iwbTable('refresh', true);
- };
- this.$ele = ele,
- this.defaults = {
- url: undefined,
- data: undefined,
- levels: 2,
- emptyIcon: "iconfont icon-delete",
- collapseIcon: 'iconfont icon-delete ',
- expandIcon: 'iconfont icon-add',
- selectedBackColor: '#563d7c',
- onNodeSelected: function (e, d) {
- onNodeSelected(e, d, that);
- },
- onNodeUnselected: function (e, d) {
- onNodeUnselected(e, d, that);
- },
- table: 'table',
- selectFiledName: 'id',
- selectFiledInput: 'keyWords'
- },
- this.options = $.extend({}, this.defaults, opt);
- };
- //var abp = window.abp || {};
- TreeView.prototype.init = function () {
- var that = this, o = that.options;
- $.metPageCss('/Content/Libs/bootstrap-treeview/bootstrap-treeview.min.css', "dy-css-treeview");
- $.metPageJs('/Content/Libs/bootstrap-treeview/bootstrap-treeview.min.js', "dy-js-treeview");
- if (o.data) {
- that.loadTree();
- } else if (o.url) {
- that.postData();
- }
- };
- TreeView.prototype.loadTree = function (data) {
- var that = this, o = that.options;
- var option = $.extend({}, o);
- if (data) {
- option.data = data;
- }
- $(that.$ele).treeview(option);
- };
- TreeView.prototype.postData = function (url) {
- var that = this, o = that.options;
- url = url || o.url;
- $.iwbAjax({
- url: window.appUrl + url,
- isAlert: false,
- isValidate: false,
- isRefresh: false,
- success: function (res) {
- if (res) {
- that.loadTree(res);
- }
- }
- });
- };
- var allowedMethods = [
- 'init'
- ];
- $.fn.iwbTreeView = function (option) {
- var value,
- args = Array.prototype.slice.call(arguments, 1);
- this.each(function () {
- var $this = $(this);
- var data = $this.data('iwb.TreeView');
- if (!data) {
- data = new TreeView(this, option);
- $this.data('iwb.TreeView', data);
- data.init();
- }
- if (typeof option === 'string') {
- if ($.inArray(option, allowedMethods) < 0) {
- throw new Error("Unknown method: " + option);
- }
- value = data[option].apply(data, args);
- }
- });
- return typeof value === 'undefined' ? this : value;
- };
- })(jQuery, window, document);
- /*DateTime*/
- (function ($, window, document, undefined) {
- 'use strict';
- var DateTime = function (ele, opt) {
- this.$ele = ele,
- this.defaults = {
- language: 'zh-CN',
- singleDatePicker: true,
- dayStep: false,
- opens: "center",
- drops: "down",
- format: "YYYY-MM-DD", //YYYY-MM-DD HH:MM:SS
- showEvent: undefined,
- showCalendarEvent: undefined,
- hideEvent: undefined,
- hideCalendarEvent: undefined,
- applyEvent: undefined,
- cancelEvent: undefined,
- minDate: '2015-01-01',
- maxDate: false,
- showWeekNumbers: false,
- showISOWeekNumbers: false,
- timePicker: false,
- timePicker24Hour: true,
- timePickerIncrement: 5,
- timePickerSeconds: false,
- linkedCalendars: true,
- showCustomRangeLabel: false,
- alwaysShowCalendars: true,
- autoApply: true,
- autoUpdateInput: true,
- buttonClasses: "btn btn-sm",
- applyButtonClasses: "btn-success",
- cancelClass: "btn-default",
- startDate: undefined, //开始时间
- endDate: undefined, //结束时间,
- maxSpan: undefined,
- locale: undefined,
- ranges: undefined,
- hasRange: false
- },
- this.options = $.extend({}, this.defaults, opt);
- };
- var dateOpt = {};
- //var timeSelect2 = function () {
- // $('.daterangepicker .calendar-time > select').select2();
- //}
- //var abp = window.abp || {};
- DateTime.prototype.init = function () {
- var that = this; var o = that.options;
- $.metPageCss('/Content/Libs/bootstrap-daterangepicker/daterangepicker.css', "dy-css-daterangepicker");
- $.metPageJs('/Content/Libs/bootstrap-daterangepicker/daterangepicker.js', "dy-js-daterangepicker");
- var lang = o.language.toLowerCase();
- if (lang === 'zh-hans') {
- lang = 'zh-cn';
- }
- moment.locale(lang);
- var localeName = {
- applyLabel: 'Apply',
- cancelLabel: 'Cancel',
- fromLabel: "",
- toLabel: "",
- customRangeLabel: 'Custom Range',
- daysOfWeek: moment.weekdaysMin(),
- monthNames: moment.monthsShort()
- },
- ranges = {
- 'Today': [moment(), moment()],
- 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
- 'Last 7 Days': [moment().subtract(6, 'days'), moment()],
- 'Last 30 Days': [moment().subtract(29, 'days'), moment()],
- 'This Month': [moment().startOf('month'), moment().endOf('month')],
- 'Last Month': [
- moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')
- ]
- };
- dateOpt = {
- format: o.format, //YYYY-MM-DD HH:MM:SS
- opens: o.opens,
- startDate: o.startDate ? o.startDate : false,
- endDate: o.endDate ? o.endDate : false,
- singleDatePicker: o.singleDatePicker,
- drops: o.drops,
- minDate: o.minDate,
- maxDate: o.maxDate,
- showCustomRangeLabel: o.showCustomRangeLabel ? o.hasRange : o.showCustomRangeLabel,
- linkedCalendars: o.linkedCalendars,
- showWeekNumbers: o.showWeekNumbers,
- showISOWeekNumbers: o.showISOWeekNumbers,
- timePicker: o.timePicker,
- timePicker24Hour: o.timePicker24Hour,
- timePickerIncrement: o.timePickerIncrement,
- timePickerSeconds: o.timePickerSeconds,
- buttonClasses: o.buttonClasses,
- applyButtonClasses: o.applyButtonClasses,
- cancelClass: o.cancelClass,
- autoApply: o.autoApply,
- autoUpdateInput: o.autoUpdateInput,
- alwaysShowCalendars: o.alwaysShowCalendars,
- maxSpan: o.maxSpan ? o.maxSpan : o.dayStep ? {
- days: o.dayStep
- } : false,
- locale: o.locale ? o.locale : {
- direction: 'ltr',
- format: o.format,
- separator: " - ", //
- applyLabel: localeName.applyLabel,
- cancelLabel: localeName.cancelLabel,
- fromLabel: localeName.fromLabel,
- toLabel: localeName.toLabel,
- customRangeLabel: localeName.customRangeLabel,
- weekLabel: localeName.weekLabel,
- daysOfWeek: localeName.daysOfWeek,
- monthNames: localeName.monthNames,
- firstDay: 1
- },
- ranges: !o.hasRange ? false : o.ranges ? o.ranges : ranges
- };
- };
- DateTime.prototype.date = function () {
- var that = this, o = that.options;
- var opt = { locale: {} };
- opt.locale.format = "YYYY-MM-DD";
- that.load(opt);
- };
- DateTime.prototype.dateTime = function () {
- var that = this//, o = that.options;
- var opt = { locale: {} };
- opt.locale.format = "YYYY-MM-DD HH:mm";
- opt.timePicker = true;
- that.load(opt);
- };
- DateTime.prototype.dateSecond = function () {
- var that = this//, o = that.options;
- var opt = { locale: {} };
- opt.locale.format = "YYYY-MM-DD HH:mm:SS";
- opt.timePicker = true;
- opt.timePickerSeconds = true;
- that.load(opt);
- };
- DateTime.prototype.dataRange = function () {
- var that = this, o = that.options;
- var opt = { locale: {} };
- opt.singleDatePicker = false;
- that.load(opt);
- };
- DateTime.prototype.dataRangeTime = function () {
- var that = this, o = that.options;
- var opt = { locale: {} };
- opt.locale.format = "YYYY-MM-DD HH:mm";
- opt.timePicker = true;
- opt.singleDatePicker = false;
- that.load(opt);
- };
- DateTime.prototype.dataRangeSecond = function () {
- var that = this, o = that.options;
- var opt = { locale: {} };
- opt.locale.format = "YYYY-MM-DD HH:mm:SS";
- opt.singleDatePicker = false;
- opt.timePicker = true;
- opt.timePickerSeconds = true;
- that.load(opt);
- };
- DateTime.prototype.load = function (opt) {
- var that = this, o = that.options;
- var option = $.extend({}, dateOpt, opt || {});
- $(that.$ele).daterangepicker(option, function (start, end, label) {
- console.log('Data-Change: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' ( Range: ' + label + ')');
- });
- var cancelEvent = o.cancelEvent && o.cancelEvent.isFunction() ? o.cancelEvent : function () { $(that.$ele).val('') }
- $(that.$ele).on('cancel.daterangepicker', cancelEvent);
- if (o.applyEvent && o.applyEvent.isFunction()) {
- $(that.$ele).on('apply.daterangepicker', o.applyEvent);
- }
- $(that.$ele).on('show.daterangepicker', function () {
- //timeSelect2();
- if (o.showEvent && o.showEvent.isFunction()) {
- o.showEvent();
- }
- });
- if (o.hideEvent && o.hideEvent.isFunction()) {
- $(that.$ele).on('hide.daterangepicker', o.hideEvent);
- }
- if (o.showCalendarEvent && o.showCalendarEvent.isFunction()) {
- $(that.$ele).on('showCalendar.daterangepicker', o.showCalendarEvent);
- }
- if (o.hideCalendarEvent && o.hideCalendarEvent.isFunction()) {
- $(that.$ele).on('hideCalendar.daterangepicker', o.hideCalendarEvent);
- }
- $(that.$ele).val('');
- };
- DateTime.prototype.setStartDate = function (data) {
- var that = this, o = that.options;
- $(that.$ele).data('daterangepicker').setStartDate(data);
- };
- DateTime.prototype.setEndDate = function (data) {
- var that = this, o = that.options;
- $(that.$ele).data('daterangepicker').setEndDate(data);
- };
- var allowedMethods = [
- 'date',
- 'dateTime',
- 'dateSecond',
- 'dataRange',
- 'dataRangeTime',
- 'dataRangeSecond',
- 'setStartDate',
- 'setEndDate'
- ];
- $.fn.iwbDate = function (option) {
- var value,
- args = Array.prototype.slice.call(arguments, 1);
- this.each(function () {
- var $this = $(this);
- var data = $this.data('iwb.date');
- if (!data) {
- data = new DateTime(this, option ? option : {});
- $this.data('iwb.date', data);
- data.init();
- }
- if (typeof option === 'string') {
- if ($.inArray(option, allowedMethods) < 0) {
- throw new Error("Unknown method: " + option);
- }
- value = data[option].apply(data, args);
- } else if (option && option.method && typeof option.method === 'string') {
- if ($.inArray(option.method, allowedMethods) < 0) {
- throw new Error("Unknown method: " + option.method);
- }
- value = data[option.method].apply(data, args);
- }
- else {
- if (!option && $this.hasClass('iwb-date')) {
- data.date();
- } else if ((!option || !option.method) && ($this.hasClass('iwb-date-time') || $this.hasClass('iwb-dateTime'))) {
- data.dateTime();
- } else if ((!option || !option.method) && ($this.hasClass('iwb-date-second') || $this.hasClass('iwb-dateSecond'))) {
- data.dateSecond();
- } else if ((!option || !option.method) && ($this.hasClass('iwb-date-range') || $this.hasClass('iwb-range-date'))) {
- data.dataRange();
- } else if ((!option || !option.method) && ($this.hasClass('iwb-date-range-time') || $this.hasClass('iwb-range-dateTime'))) {
- data.dataRangeTime();
- } else if ((!option || !option.method) && ($this.hasClass('iwb-date-range-second') || $this.hasClass('iwb-range-dateSecond'))) {
- data.dataRangeSecond();
- } else {
- data.load();
- }
- }
- });
- return typeof value === 'undefined' ? this : value;
- };
- $.fn.iwbDateRange = function (option) {
- var value,
- args = Array.prototype.slice.call(arguments, 1);
- this.each(function () {
- var $this = $(this);
- var data = $this.data('iwb.rangeDate');
- if (!data) {
- data = new DateTime(this, option);
- $this.data('iwb.rangeDate', data);
- data.init();
- data.dataRange();
- }
- if (typeof option === 'string') {
- if ($.inArray(option, allowedMethods) < 0) {
- throw new Error("Unknown method: " + option);
- }
- value = data[option].apply(data, args);
- }
- });
- return typeof value === 'undefined' ? this : value;
- };
- $('.iwb-date-time').iwbDate();
- $('.iwb-date').iwbDate();
- })(jQuery, window, document);
- /*Kindeditor*/
- (function ($, window, document, undefined) {
- 'use strict';
- window.editor_K = {};
- var Kindeditor = function (ele, opt) {
- this.$ele = ele,
- this.defaults = {
- isModal: true,
- tools: 'simpleTools',
- resizeMode: 1,
- width: '100%',
- height: '300px',
- bodyClass: 'article-content',
- urlType: '',
- uploadJson: '/system/KindEditorUploadFile',
- filterMode: false,
- allowFileManager: false,
- langType: 'zh-CN',
- cssData: 'html,body {background: none}.article-content, .article-content table td, .article-content table th {line-height: 1.3846153846; font-size: 13px;}.article-content .table-auto {width: auto!important; max-width: 100%;}',
- placeholder: '请输入...',
- placeholderStyle: { fontSize: '13px', color: '#888' },
- pasteImage: { postUrl: '/system/KindEditorUploadFile', placeholder: "\u53ef\u4ee5\u5728\u7f16\u8f91\u5668\u76f4\u63a5\u8d34\u56fe\u3002" },
- syncAfterBlur: true,
- afterChange: function () { this.sync(); },
- afterBlur: function () { this.sync(); },
- spellcheck: false
- },
- this.options = $.extend({}, this.defaults, opt);
- };
- var bugTools =
- ['formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', '|',
- 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|',
- 'emoticons', 'image', 'code', 'link', '|', 'removeformat', 'undo', 'redo', 'fullscreen', 'source', 'about'];
- var simpleTools =
- ['formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', '|',
- 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|',
- 'emoticons', 'image', 'code', 'link', 'table', '|', 'removeformat', 'undo', 'redo', 'fullscreen', 'source', 'about'];
- var fullTools =
- ['formatblock', 'fontname', 'fontsize', 'lineheight', '|', 'forecolor', 'hilitecolor', '|', 'bold', 'italic', 'underline', 'strikethrough', '|',
- 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', '|',
- 'insertorderedlist', 'insertunorderedlist', '|',
- 'emoticons', 'image', 'insertfile', 'hr', '|', 'link', 'unlink', '/',
- 'undo', 'redo', '|', 'selectall', 'cut', 'copy', 'paste', '|', 'plainpaste', 'wordpaste', '|', 'removeformat', 'clearhtml', 'quickformat', '|',
- 'indent', 'outdent', 'subscript', 'superscript', '|',
- 'table', 'code', '|', 'pagebreak', 'anchor', '|',
- 'fullscreen', 'source', 'preview', 'about'];
- var editorToolsMap = { fullTools: fullTools, simpleTools: simpleTools, bugTools: bugTools };
- //var abp = window.abp || {};
- Kindeditor.prototype.init = function (options) {
- var that = this, o = that.options;
- options = options || {};
- $.metPageCss('/Content/Libs/kindeditor/themes/default/default.css', "dy-css-kindeditor");
- $.metPageJs('/Content/Libs/kindeditor/kindeditor-all-min.js', "dy-js-kindeditor");
- $.metPageJs('/Content/Libs/kindeditor/lang/zh-CN.js', "dy-js-kindeditor-zh-CN");
- that.setKindeditor(options);
- };
- Kindeditor.prototype.setKindeditor = function (options) {
- var that = this, o = that.options;
- var $editor = $(that.$ele);
- var editorId = $editor.attr('id');
- options = options || {};
- options = $.extend({}, o, $editor.data(), options);
- if (editorId === undefined) {
- editorId = 'kindeditor-' + Math.floor(Math.random() * 10000000);
- $editor.attr('id', editorId);
- }
- var editorTool = editorToolsMap[o.tools] || simpleTools;
- /* Remove fullscreen in modal. */
- if (o.isModal) {
- var newEditorTool = new Array();
- var i;
- for (i in editorTool) {
- if (editorTool.hasOwnProperty(i)) {
- if (editorTool[i] !== 'fullscreen') newEditorTool.push(editorTool[i]);
- }
- }
- editorTool = newEditorTool;
- }
- $.extend(options,
- {
- items: editorTool,
- placeholder: $editor.attr('placeholder') || options.placeholder || ''
- });
- try {
- $editor.length && window.KindEditor && window.KindEditor.remove(editorId);
- var editor = window.KindEditor.create('#' + editorId, options);
- window.editor_K['#'] = window.editor_K[editorId] = editor;
- return editor;
- } catch (e) {
- console.log('kindEditor', e);
- return false;
- }
- };
- Kindeditor.prototype.remove = function () {
- var that = this, o = that.options;
- var $editor = $(that.$ele);
- var editorId = $editor.attr('id');
- if (editorId && window.KindEditor) {
- window.KindEditor.remove(editorId);
- $editor.data('iwb.kindEditor', undefined);
- }
- };
- var allowedMethods = [
- 'init',
- 'remove',
- 'setKindeditor'
- ];
- $.fn.iwbKindeditor = function (option) {
- var value,
- args = Array.prototype.slice.call(arguments, 1);
- this.each(function () {
- var $this = $(this);
- var data = $this.data('iwb.kindEditor');
- if (!data) {
- data = new Kindeditor(this, option);
- $this.data('iwb.kindEditor', data);
- data.init();
- }
- if (typeof option === 'string') {
- if ($.inArray(option, allowedMethods) < 0) {
- throw new Error("Unknown method: " + option);
- }
- value = data[option].apply(data, args);
- }
- });
- return typeof value === 'undefined' ? this : value;
- };
- })(jQuery, window, document);
- /*wangEditor*/
- (function ($, window, document, undefined) {
- 'use strict';
- window.editor_W = {};
- var E, editor = undefined;
- var WangEditor = function (ele, opt) {
- this.$ele = ele,
- this.defaults = {
- dataId: undefined,
- dataName: undefined,
- showFullScreen: true,
- menus: undefined,
- //[
- // 'head',
- // 'bold',
- // 'fontSize',
- // 'fontName',
- // 'italic',
- // 'underline',
- // 'strikeThrough',
- // 'indent',
- // 'lineHeight',
- // 'foreColor',
- // 'backColor',
- // 'link',
- // 'list',
- // //'todo',
- // 'justify',
- // //'quote',
- // //'emoticon',
- // 'image',
- // //'video',
- // //'table',
- // //'code',
- // 'splitLine',
- // 'undo',
- // 'redo'
- // ],
- excludeMenus: undefined,
- colors: undefined,
- /*[
- '#000000',
- '#eeece0',
- '#1c487f',
- '#4d80bf'
- ],*/
- fontNames: undefined,
- /*[
- '黑体',
- '仿宋',
- '楷体',
- '标楷体',
- '华文仿宋',
- '华文楷体',
- '宋体',
- '微软雅黑',
- 'Arial',
- 'Tahoma',
- 'Verdana',
- 'Times New Roman',
- 'Courier New',
- ],*/
- lineHeights: undefined,
- //['1', '1.15', '1.6', '2', '2.5', '3'],
- pasteFilterStyle: false, //粘贴样式的过滤
- pasteIgnoreImg: true, //来忽略粘贴的图片
- pasteTextHandle: undefined, // 对粘贴的文本进行处理,然后返回处理后的结果
- onchange: undefined,
- onblur: function (ss) {
- },
- onfocus: function (ss) {
- //console.log(ss);
- },
- linkImgCallback: undefined, // 插入网络图片的回调
- onlineVideoCallback: undefined, // 自定义检查插入视频的回调
- uploadImgServer: "", // 配置 server 接口地址
- uploadImgMaxSize: 2 * 1024 * 1024, //限制大小 2M
- uploadImgAccept: ['jpg', 'jpeg', 'png', 'gif', 'bmp'], //限制类型
- uploadFileName: undefined, //自定义 fileName
- uploadImgHeaders: undefined, //自定义 header
- withCredentials: false, //跨域传递 cookie
- customUploadImg: undefined, //自己实现上传图片
- /*
- function (resultFiles, insertImgFn) {
- // resultFiles 是 input 中选中的文件列表
- // insertImgFn 是获取图片 url 后,插入到编辑器的方法
- // 上传图片,返回结果,将图片插入到编辑器中
- insertImgFn(imgUrl)
- }
- */
- uploadImgTimeout: 5 * 1000, //自定义 timeout 时间
- uploadImgParams: undefined, //自定义上传参数
- uploadImgHooks: undefined, //回调函数
- /*
- {
- // 上传图片之前
- before: function(xhr) {
- console.log(xhr)
- // 可阻止图片上传
- return {
- prevent: true,
- msg: '需要提示给用户的错误信息'
- }
- },
- // 图片上传并返回了结果,图片插入已成功
- success: function(xhr) {
- console.log('success', xhr)
- },
- // 图片上传并返回了结果,但图片插入时出错了
- fail: function(xhr, editor, resData) {
- console.log('fail', resData)
- },
- // 上传图片出错,一般为 http 请求的错误
- error: function(xhr, editor, resData) {
- console.log('error', xhr, resData)
- },
- // 上传图片超时
- timeout: function(xhr) {
- console.log('timeout')
- },
- // 图片上传并返回了结果,想要自己把图片插入到编辑器中
- // 例如服务器端返回的不是 { errno: 0, data: [...] } 这种格式,可使用 customInsert
- customInsert: function(insertImgFn, result) {
- // result 即服务端返回的接口
- console.log('customInsert', result)
- // insertImgFn 可把图片插入到编辑器,传入图片 src ,执行函数即可
- insertImgFn(result.data[0])
- }
- }
- */
- uploadImgMaxLength: 5, // 一次最多上传 5 个图片,
- uploadImgShowBase64: true, // 可使用 base64 格式保存图片
- showLinkImg: false, // 隐藏插入网络图片
- },
- this.options = $.extend({}, this.defaults, opt);
- $.metPageJs('/Content/Libs/wangEditor/wangEditor.min.js', "dy-js-wangEditor");
- E = window.wangEditor;
- //this.init();
- };
- //var abp = window.abp || {};
- WangEditor.prototype.init = function (options) {
- var that = this, o = that.options;
- options = options || {};
- editor = new E(that.$ele);
- that.$ele.form = $(that.$ele).closest('form');
- that.createEditor(options);
- };
- WangEditor.prototype.createEditor = function (options) {
- var that = this;
- options = options || {};
- var o = $.extend(true, {}, that.options, options);
- var dataId = o.dataId || $(that.$ele).data('id');
- if (dataId) {
- var dataName = o.dataName || $(that.$ele).data('name') || dataId;
- var $t = $('<input id="' + dataId + '" name="' + dataName + '" type="hidden" />');
- $(that.$ele).before($t);
- $t.on('change.editor', function () {
- that.setContent($t.val());
- });
- o.onchange = function (html) {
- // 监控变化,同步更新到 input
- $t.val(html);
- }
- if (!o.excludeMenus) {
- var menuStr = $(that.$ele).data('menu');
- var menu = menuStr.split(',');
- if (menu) {
- editor.config.menus = menu;
- }
- }
- }
- var opt = $(that.$ele).data('opt');
- if (!(typeof (opt) === "object" && Object.prototype.toString.call(opt).toLowerCase() === "[object object]")) {
- try {
- opt = opt ? JSON.parse(opt) : {};
- } catch (e) {
- console.log(e);
- }
- }
- editor.config = $.extend({}, editor.config, o, opt || {});
- if (editor.config.excludeMenus) {
- editor.config.excludeMenus = o.excludeMenus;
- }
- if (!editor.config.excludeMenus && o.menus && $.isArray(o.menus)) {
- editor.config.menus = o.menus;
- }
- if (o.colors && $.isArray(o.colors)) {
- editor.config.colors = o.colors;
- }
- if (o.fontNames && $.isArray(o.fontNames)) {
- editor.config.fontNames = o.fontNames;
- }
- if (o.lineHeights && $.isArray(o.lineHeights)) {
- editor.config.lineHeights = o.lineHeights;
- }
- //var $editor = $(that.$ele);
- //var editorId = $editor.attr('id');
- //if (editorId === undefined) {
- // editorId = 'wangEditor-' + Math.floor(Math.random() * 10000000);
- // $editor.attr('id', editorId);
- //}
- editor.create();
- //window.editor_W['#'] = window.editor_W[editorId] = editor;
- }
- WangEditor.prototype.setContent = function (txt) {
- editor.txt.html(txt);
- }
- var allowedMethods = [
- 'setContent'
- ];
- $.fn.iwbWangEditor = function (option) {
- var value,
- args = Array.prototype.slice.call(arguments, 1);
- this.each(function () {
- var $this = $(this);
- var data = $this.data('iwb.WangEditor');
- if (!data) {
- data = new WangEditor(this, option);
- $this.data('iwb.WangEditor', data);
- data.init();
- }
- if (typeof option === 'string') {
- if ($.inArray(option, allowedMethods) < 0) {
- throw new Error("Unknown method: " + option);
- }
- value = data[option].apply(data, args);
- }
- });
- return typeof value === 'undefined' ? this : value;
- };
- })(jQuery, window, document);
- ; (function (window, document, $) {
- //开启严格模式,规范代码,提高浏览器运行效率
- "use strict"
- var _global;
- var progressTool = function (opt) {
- var defaultOption = {
- OutDom: undefined,
- InnerDom: undefined,
- OutDomCss: null,
- InnerDomCss: null,
- ScaleCss: null,
- initValue: 0,
- curValue: 0,
- isShowValue: true,
- ShowValueCss: {},
- moveCallback: function (curScalePer, innerDom) { },
- changeEndCall: function (curScalePer, innerDom, that) { }
- }
- $.extend(defaultOption, opt);
- this.defaultOption = defaultOption;
- $.metPageCss('/Content/Css/z_Progress.css', "dy-css-z_Progress"); //初始加载外部样式CSS
- this.outDom = typeof defaultOption.OutDom === "string"
- ? $("#" + defaultOption.OutDom)
- : defaultOption.OutDom;
- this.outDom.toggleClass('z_progress');
- if (defaultOption.OutDomCss != null) {
- this.outDom.css(defaultOption.OutDomCss);
- }
- this.outDom.html('');
- var innerDomStr = '<div class="z_progress-bar"><div class="Scale"></div></div>';
- this.outDom.append(innerDomStr);
- if (defaultOption.isShowValue) {
- this.outDom.append('<span class="showValue"></span>');
- this.outDom.find('.showValue').css(defaultOption.ShowValueCss);
- }
- this.innerDom = this.outDom.find(".z_progress-bar");
- if (defaultOption.InnerDomCss != null) {
- this.innerDom.css(defaultOption.InnerDomCss);
- }
- this.scaleDom = this.innerDom.find('.Scale');
- if (defaultOption.ScaleCss != null) {
- this.scaleDom.css(defaultOption.ScaleCss);
- }
- this.scaleWidth = this.scaleDom.width();
- this.curValue = defaultOption.initValue;
- this.moveBeforeVal = this.curValue;
- this.setValue(this.curValue);
- this.bindEvent();
- }
- progressTool.prototype.bindEvent = function () {
- var that = this;
- var outDom = that.outDom;
- var innerDom = that.innerDom;
- var scaleDom = that.scaleDom;
- var flag = false;
- scaleDom.on({
- mousedown: function () {
- flag = true;
- that.moveBeforeVal = that.curValue;
- scaleDom.css('cursor', 'w-resize');
- },
- mouseup: function () {
- flag = false;
- scaleDom.css('cursor', 'default');
- that.defaultOption.changeEndCall(that.curValue, innerDom, that);
- }
- });
- outDom.on({
- mousemove: function (e) {
- if (!flag) {
- return;
- }
- var innerLeftDis = innerDom.offset().left;
- var maxLength = outDom.width() + innerLeftDis;
- if (e.clientX <= maxLength && e.clientX >= innerLeftDis) {
- var inWidth = (e.clientX - innerLeftDis);
- that.change(inWidth);
- }
- },
- mouseup: function () {
- flag = false;
- that.defaultOption.changeEndCall(that.curValue, innerDom, that);
- }
- });
- }
- progressTool.prototype.change = function (inWidth) {
- var that = this;
- var outDom = that.outDom;
- var innerDom = that.innerDom;
- var scaleDom = that.scaleDom;
- var scaleWidth = that.scaleWidth;
- var v = Math.round(inWidth / outDom.width() * 100);
- if (v === 0) {
- scaleDom.css('right', '-' + scaleWidth + 'px');
- } else {
- scaleDom.css('right', '0px');
- }
- innerDom.css("width", v + "%");
- //$("#showValue").html(v + "%");
- if (that.defaultOption.isShowValue) {
- var showValue = that.outDom.find('.showValue');
- showValue.html(v + "%");
- }
- that.curValue = v;
- that.defaultOption.moveCallback(v, innerDom);
- }
- progressTool.prototype.setValue = function (v) {
- var that = this;
- if (v === 0) {
- that.scaleDom.css('right', '-' + that.scaleWidth + 'px');
- } else {
- that.scaleDom.css('right', '0px');
- }
- if (that.defaultOption.isShowValue) {
- var showValue = that.outDom.find('.showValue');
- showValue.html(v + "%");
- }
- that.innerDom.css("width", v + "%");
- that.curValue = v;
- //that.defaultOption.moveCallback(v);
- }
- progressTool.prototype.getValue = function () {
- var that = this;
- return that.curValue;
- }
- progressTool.prototype.invokeCallBack = function () {
- var that = this;
- that.defaultOption.moveCallback(that.curValue, that.innerDom);
- }
- _global = (function () {
- return this || (0, eval)('this');
- }());
- if (typeof module !== "undefined" && module.exports) {
- module.exports = progressTool;
- } else if (typeof define === "function" && define.amd) {
- define(function () {
- return progressTool;
- });
- } else {
- !('progressTool' in _global) && (_global.progressTool = progressTool);
- }
- })(window, document, $);
- $.AdminBSB = {};
- $.AdminBSB.options = {
- colors: {
- red: '#F44336',
- pink: '#E91E63',
- purple: '#9C27B0',
- deepPurple: '#673AB7',
- indigo: '#3F51B5',
- blue: '#2196F3',
- lightBlue: '#03A9F4',
- cyan: '#00BCD4',
- teal: '#009688',
- green: '#4CAF50',
- lightGreen: '#8BC34A',
- lime: '#CDDC39',
- yellow: '#ffe821',
- amber: '#FFC107',
- orange: '#FF9800',
- deepOrange: '#FF5722',
- brown: '#795548',
- grey: '#9E9E9E',
- blueGrey: '#607D8B',
- black: '#000000',
- white: '#ffffff'
- },
- leftSideBar: {
- scrollColor: 'rgba(0,0,0,0.5)',
- scrollWidth: '4px',
- scrollAlwaysVisible: false,
- scrollBorderRadius: '0',
- scrollRailBorderRadius: '0',
- scrollActiveItemWhenPageLoad: true,
- breakpointWidth: 1170
- },
- dropdownMenu: {
- effectIn: 'fadeIn',
- effectOut: 'fadeOut'
- }
- };
- /* Left Sidebar - Function =================================================================================================
- * You can manage the left sidebar menu options
- *
- */
- $.AdminBSB.leftSideBar = {
- activate: function () {
- var that = this;
- var $body = $('body');
- var $overlay = $('.overlay');
- //Close sidebar
- $(window).click(function (e) {
- var $target = $(e.target);
- if (e.target.nodeName.toLowerCase() === 'i') {
- $target = $(e.target).parent();
- }
- if (!$target.hasClass('bars') && that.isOpen() && $target.parents('#left-sidebar').length === 0) {
- //if (!$target.hasClass('js-right-sidebar'))
- // $overlay.fadeOut();
- $body.removeClass('overlay-open');
- }
- });
- $.each($('.menu-toggle.toggled'), function (i, val) {
- $(val).next().slideToggle(0);
- });
- //When page load
- $.each($('.menu .list li.active'), function (i, val) {
- var $activeAnchors = $(val).find('a:eq(0)');
- var $parentAnchors = $(val).parentsUntil('.menu .list', 'li').children('a:first-child');
- $activeAnchors = $activeAnchors.add($parentAnchors);
- $activeAnchors.addClass('toggled');
- $activeAnchors.next().show();
- });
- //Collapse or Expand Menu
- $('.menu-toggle').on('click', function (e) {
- var $this = $(this);
- var $content = $this.next();
- if ($($this.parents('ul')[0]).hasClass('list')) {
- var $not = $(e.target).hasClass('menu-toggle') ? e.target : $(e.target).parents('.menu-toggle');
- $.each($('.menu-toggle.toggled').not($not).next(), function (i, val) {
- if ($(val).is(':visible')) {
- $(val).prev().toggleClass('toggled');
- $(val).slideUp();
- }
- });
- }
- $this.toggleClass('toggled');
- $content.slideToggle(320);
- });
- //Set menu height
- that.setMenuHeight();
- that.checkStatuForResize(true);
- $(window).resize(function () {
- that.setMenuHeight();
- that.checkStatuForResize(false);
- });
- //Set Waves
- var theme = "block";
- var bodyClassName = $body.prop('className');
- if (bodyClassName) {
- var classArray = bodyClassName.split(' ');
- for (var j = 0; j < classArray.length; j++) {
- if (classArray[j].indexOf('theme') === 0) {
- theme = classArray[j].split('-')[1];
- break;
- }
- }
- }
- Waves.attach('.menu .list a', ['waves-' + theme]);
- Waves.init();
- },
- setMenuHeight: function (isFirstTime) {
- if (typeof $.fn.slimScroll != 'undefined') {
- var configs = $.AdminBSB.options.leftSideBar;
- var height = ($(window).height() - ($('.legal').outerHeight() + $('.user-info').outerHeight() + $('.navbar').innerHeight()));
- var $el = $('.list');
- $el.slimscroll({
- height: height + "px",
- color: configs.scrollColor,
- size: configs.scrollWidth,
- alwaysVisible: configs.scrollAlwaysVisible,
- borderRadius: configs.scrollBorderRadius,
- railBorderRadius: configs.scrollRailBorderRadius
- });
- //Scroll active menu item when page load, if option set = true
- if ($.AdminBSB.options.leftSideBar.scrollActiveItemWhenPageLoad) {
- var $activeItem = $('.menu .list li.active');
- if ($activeItem.length) {
- var activeItemOffsetTop = $activeItem[0].offsetTop;
- if (activeItemOffsetTop > 150) $el.slimscroll({ scrollTo: activeItemOffsetTop + 'px' });
- }
- }
- }
- },
- checkStatuForResize: function (firstTime) {
- var $body = $('body');
- // var $openCloseBar = $('.navbar .navbar-header .bars');
- var width = $body.width();
- if (firstTime) {
- $body.find('.content, .sidebar').addClass('no-animate').delay(1000).queue(function () {
- $(this).removeClass('no-animate').dequeue();
- });
- }
- if (width < $.AdminBSB.options.leftSideBar.breakpointWidth) {
- $body.addClass('ls-closed');
- //$openCloseBar.fadeIn();
- }
- else {
- $body.removeClass('ls-closed');
- //$openCloseBar.fadeOut();
- }
- },
- isOpen: function () {
- return $('body').hasClass('overlay-open');
- }
- };
- //==========================================================================================================================
- /* Right Sidebar - Function ================================================================================================
- * You can manage the right sidebar menu options
- *
- */
- $.AdminBSB.rightSideBar = {
- activate: function () {
- var _this = this;
- var $sidebar = $('#rightsidebar');
- var $overlay = $('.overlay');
- //Close sidebar
- $(window).click(function (e) {
- var $target = $(e.target);
- if (e.target.nodeName.toLowerCase() === 'i') { $target = $(e.target).parent(); }
- if (!$target.hasClass('js-right-sidebar') && _this.isOpen() && $target.parents('#rightsidebar').length === 0) {
- if (!$target.hasClass('bars')) $overlay.fadeOut();
- $sidebar.removeClass('open');
- }
- });
- $('.js-right-sidebar').on('click', function () {
- $sidebar.toggleClass('open');
- if (_this.isOpen()) { $overlay.fadeIn(); } else { $overlay.fadeOut(); }
- });
- },
- isOpen: function () {
- return $('.right-sidebar').hasClass('open');
- }
- }
- //==========================================================================================================================
- /* Searchbar - Function ================================================================================================
- * You can manage the search bar
- *
- */
- var $searchBar = $('.search-bar');
- $.AdminBSB.search = {
- activate: function () {
- var _this = this;
- //Search button click event
- $('.js-search').on('click', function () {
- _this.showSearchBar();
- });
- //Close search click event
- $searchBar.find('.close-search').on('click', function () {
- _this.hideSearchBar();
- });
- //ESC key on pressed
- $searchBar.find('input[type="text"]').on('keyup', function (e) {
- if (e.keyCode == 27) {
- _this.hideSearchBar();
- }
- });
- },
- showSearchBar: function () {
- $searchBar.addClass('open');
- $searchBar.find('input[type="text"]').focus();
- },
- hideSearchBar: function () {
- $searchBar.removeClass('open');
- $searchBar.find('input[type="text"]').val('');
- }
- }
- //==========================================================================================================================
- /* Navbar - Function =======================================================================================================
- * You can manage the navbar
- *
- */
- $.AdminBSB.navbar = {
- activate: function () {
- var $body = $('body');
- var $overlay = $('.overlay');
- //Open left sidebar panel
- $('.bars').on('click', function () {
- $body.toggleClass('ls-closed');
- //if ($body.hasClass('ls-closed')) $body.toggleClass('overlay-open');
- if ($body.hasClass('overlay-open')) { $overlay.fadeIn(); } else { $overlay.fadeOut(); }
- });
- //Close collapse bar on click event
- $('.nav [data-close="true"]').on('click', function () {
- var isVisible = $('.navbar-toggle').is(':visible');
- var $navbarCollapse = $('.navbar-collapse');
- if (isVisible) {
- $navbarCollapse.slideUp(function () {
- $navbarCollapse.removeClass('in').removeAttr('style');
- });
- }
- });
- }
- }
- //==========================================================================================================================
- /* Input - Function ========================================================================================================
- * You can manage the inputs(also textareas) with name of class 'form-control'
- *
- */
- $.AdminBSB.input = {
- activate: function ($parentSelector) {
- $parentSelector = $parentSelector || $('body');
- //On focus event
- $parentSelector.find('.form-control').focus(function () {
- $(this).parent().addClass('focused');
- });
- //On focusout event
- $parentSelector.find('.form-control').focusout(function () {
- var $this = $(this);
- if ($this.parents('.form-group').hasClass('form-float')) {
- if ($this.val() == '') { $this.parents('.form-line').removeClass('focused'); }
- }
- else {
- $this.parents('.form-line').removeClass('focused');
- }
- });
- //On label click
- $parentSelector.on('click', '.form-float .form-line .form-label', function () {
- $(this).parent().find('input').focus();
- });
- //Not blank form
- $parentSelector.find('.form-control').each(function () {
- if ($(this).val() !== '') {
- $(this).parents('.form-line').addClass('focused');
- }
- });
- }
- }
- //==========================================================================================================================
- /* Form - Select - Function ================================================================================================
- * You can manage the 'select' of form elements
- *
- */
- $.AdminBSB.select = {
- activate: function () {
- if ($.fn.selectpicker) { $('select:not(.ms)').selectpicker(); }
- }
- }
- //==========================================================================================================================
- /* DropdownMenu - Function =================================================================================================
- * You can manage the dropdown menu
- *
- */
- //$.AdminBSB.dropdownMenu = {
- // activate: function () {
- // var _this = this;
- // $('.dropdown, .dropup, .btn-group').on({
- // "show.bs.dropdown": function () {
- // var dropdown = _this.dropdownEffect(this);
- // _this.dropdownEffectStart(dropdown, dropdown.effectIn);
- // },
- // "shown.bs.dropdown": function () {
- // var dropdown = _this.dropdownEffect(this);
- // if (dropdown.effectIn && dropdown.effectOut) {
- // _this.dropdownEffectEnd(dropdown, function () { });
- // }
- // },
- // "hide.bs.dropdown": function (e) {
- // var dropdown = _this.dropdownEffect(this);
- // if (dropdown.effectOut) {
- // e.preventDefault();
- // _this.dropdownEffectStart(dropdown, dropdown.effectOut);
- // _this.dropdownEffectEnd(dropdown, function () {
- // dropdown.dropdown.removeClass('open');
- // });
- // }
- // }
- // });
- // //Set Waves
- // Waves.attach('.dropdown-menu li a', ['waves-block']);
- // Waves.init();
- // },
- // dropdownEffect: function (target) {
- // var effectIn = $.AdminBSB.options.dropdownMenu.effectIn, effectOut = $.AdminBSB.options.dropdownMenu.effectOut;
- // var dropdown = $(target), dropdownMenu = $('.dropdown-menu', target);
- // if (dropdown.length > 0) {
- // var udEffectIn = dropdown.data('effect-in');
- // var udEffectOut = dropdown.data('effect-out');
- // if (udEffectIn !== undefined) { effectIn = udEffectIn; }
- // if (udEffectOut !== undefined) { effectOut = udEffectOut; }
- // }
- // return {
- // target: target,
- // dropdown: dropdown,
- // dropdownMenu: dropdownMenu,
- // effectIn: effectIn,
- // effectOut: effectOut
- // };
- // },
- // dropdownEffectStart: function (data, effectToStart) {
- // if (effectToStart) {
- // data.dropdown.addClass('dropdown-animating');
- // data.dropdownMenu.addClass('animated dropdown-animated');
- // data.dropdownMenu.addClass(effectToStart);
- // }
- // },
- // dropdownEffectEnd: function (data, callback) {
- // var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
- // data.dropdown.one(animationEnd, function () {
- // data.dropdown.removeClass('dropdown-animating');
- // data.dropdownMenu.removeClass('animated dropdown-animated');
- // data.dropdownMenu.removeClass(data.effectIn);
- // data.dropdownMenu.removeClass(data.effectOut);
- // if (typeof callback == 'function') {
- // callback();
- // }
- // });
- // }
- //}
- //==========================================================================================================================
- /* Browser - Function ======================================================================================================
- * You can manage browser
- *
- */
- var edge = 'Microsoft Edge';
- var ie10 = 'Internet Explorer 10';
- var ie11 = 'Internet Explorer 11';
- var opera = 'Opera';
- var firefox = 'Mozilla Firefox';
- var chrome = 'Google Chrome';
- var safari = 'Safari';
- $.AdminBSB.browser = {
- activate: function () {
- var _this = this;
- var className = _this.getClassName();
- if (className !== '') $('html').addClass(_this.getClassName());
- },
- getBrowser: function () {
- var userAgent = navigator.userAgent.toLowerCase();
- if (/edge/i.test(userAgent)) {
- return edge;
- } else if (/rv:11/i.test(userAgent)) {
- return ie11;
- } else if (/msie 10/i.test(userAgent)) {
- return ie10;
- } else if (/opr/i.test(userAgent)) {
- return opera;
- } else if (/chrome/i.test(userAgent)) {
- return chrome;
- } else if (/firefox/i.test(userAgent)) {
- return firefox;
- } else if (!!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/)) {
- return safari;
- }
- return undefined;
- },
- getClassName: function () {
- var browser = this.getBrowser();
- if (browser === edge) {
- return 'edge';
- } else if (browser === ie11) {
- return 'ie11';
- } else if (browser === ie10) {
- return 'ie10';
- } else if (browser === opera) {
- return 'opera';
- } else if (browser === chrome) {
- return 'chrome';
- } else if (browser === firefox) {
- return 'firefox';
- } else if (browser === safari) {
- return 'safari';
- } else {
- return '';
- }
- }
- }
- //==========================================================================================================================
|