12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113 |
- 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] !== "") {
- $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] !== "") {
- $select.val(data[name]);
- //if (isSelect2) {
- // $select.val(data[name]).select2();
- //} else {
- //}
- }
- });
- $checkbox.each(function () {
- var input = $form.find($(this));
- //var name = input.attr("name").replace(/(\w)/, function (v) { return v.toUpperCase() });
- var name = input.attr("name");
- if (data[name] !== "") {
- //console.log(array[name]);
- //console.log("---");
- 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").replace(/(\w)/, function (v) { return v.toUpperCase() });
- 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);
- }
- 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"
- });
- //.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,
- 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 ? 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: false }, opt);
- $.iwbAjax(opt);
- },
- iwbAjax4: function (opt) {
- opt = $.extend({}, { isValidate: false, isAlert: false, isRefresh: false }, opt);
- $.iwbAjax(opt);
- },
- iwbAjax5: function (opt) {
- opt = $.extend({}, { isValidate: false, isAlert: false, isRefresh: false, blockUI: false }, 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 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 });
- });
- };
- 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.getSearchList = function () {
- return searchList;
- };
- 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',
- 'getSearchList',
- '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: '',
- 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,
- abp: window.abp
- },
- this.options = $.extend({}, this.defaults, opt);
- this.draggable();
- };
- //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.setData();
- $that.setSelect2();
- $that.initKindeditor();
- $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.setData();
- $that.setSelect2();
- $that.initKindeditor();
- $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 ' + 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
- ? o.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();
- $modal.find('input,select,textarea').val('').removeClass('error valid');
- $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.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');
- $.formDeserialize($form, $that.options.data);
- };
- Modal.prototype.setSelect2 = function () {
- var $that = this;
- var $modal = $that.getModal();
- if ($that.options.select2) {
- $modal.find("select").select2();
- $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[$(v).attr('id')].html(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();
- 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); };
- }
- if (save !== null) {
- $saveBtn.off('click.save').on('click.save', save);
- $modal.find('.modal-body').keydown(function (e) {
- if (e.which === 13) {
- if (e.target.tagName.toLocaleLowerCase() === "textarea") {
- e.stopPropagation();
- } else {
- e.preventDefault();
- save.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-dialog'),
- 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',
- format: "yyyy-mm-dd", //yyyy-mm-ddThh:ii:ssZ
- autoclose: true, //当选择一个日期之后是否立即关闭此日期时间选择器。
- startView: 2, //日期时间选择器打开之后首先显示的视图。 可接受的值:0 or 'hour' \ 1 or 'day' \2 or 'month' (the default )\3 or 'year' \4 or 'decade' for the 10-year overview.
- minView: 2, //日期时间选择器所能够提供的最精确的时间选择视图。
- maxView: 4, //日期时间选择器最高能展示的选择范围视图。
- todayBtn: true,
- weekStart: 0, //一周从哪一天开始。0(星期日)到6(星期六)
- startDate: '2015-01-01', //开始时间
- endDate: null, //结束时间,
- forceParse: true, //强制解析
- minuteStep: 10, //分钟视图中分钟间隔
- twoDateId: undefined,//双日期外部Id(默认找里面的 .startTime和.endTime)
- startId: undefined,//开始日期Id,不填就是本身
- endId: undefined,//结束日期Id
- isAutoSetDate: true,//双日期自动填写另一个日期
- startEndInterval: 30,//双日期自动填写间隔(天)
- defaultDate: undefined//默认日期时间
- },
- this.options = $.extend({}, this.defaults, opt);
- };
- //var abp = window.abp || {};
- DateTime.prototype.init = function () {
- var that = this;//, o = that.options;
- $.metPageCss('/Content/Libs/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css', "dy-css-dateTime");
- //$.metPageCss('/Content/Plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker-wr.css', "dy-css-dateTime-self");
- $.metPageJs('/Content/Libs/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js', "dy-js-dateTime");
- $.metPageJs('/Content/Libs/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js', "dy-js-dateTime-zhCN");
- };
- DateTime.prototype.date = function () {
- var that = this, o = that.options;
- o.format = "yyyy-mm-dd";
- o.startView = 2;
- o.minView = 2;
- that.load();
- };
- DateTime.prototype.dateTime = function () {
- var that = this, o = that.options;
- o.format = "yyyy-mm-dd hh:ii";
- o.startView = 2;
- o.minView = 1;
- that.load();
- };
- DateTime.prototype.dateSecond = function () {
- var that = this, o = that.options;
- o.format = "yyyy-mm-dd hh:ii:ss";
- o.startView = 2;
- o.minView = 0;
- that.load();
- };
- DateTime.prototype.twoDate = function () {
- var that = this, o = that.options;
- var $start, $end;
- if (o.twoDateId) {
- $start = $('#' + o.twoDateId).find('.startTime');
- $end = $('#' + o.twoDateId).find('.endTime');
- } else {
- $start = $('#' + o.startId);
- $end = $('#' + o.endId);
- }
- $start = $start.length > 0 ? $start : $(that.$ele);
- if ($end.length <= 0) {
- $end = $start.parent().find('.endTime');
- if ($end.length <= 0) {
- throw new Error("Unknown EndDate Selector");
- }
- }
- $start.datetimepicker('remove');
- $start.datetimepicker(o).on('show',
- function (event) {
- event.preventDefault();
- event.stopPropagation();
- }).on('hide',
- function (event) {
- event.preventDefault();
- event.stopPropagation();
- }).on("changeDate",
- function (e) {
- //console.log(e);
- //console.log(e.date.valueOf());
- $end.datetimepicker('setStartDate', e.date);
- if (o.isAutoSetDate && o.startEndInterval && o.startEndInterval > 0) {
- $end.datetimepicker('setDate',
- new Date(e.date.valueOf() + 1000 * 60 * 60 * 24 * o.startEndInterval));
- }
- });
- $end.datetimepicker('remove');
- $end.datetimepicker(o).on('show',
- function (event) {
- event.preventDefault();
- event.stopPropagation();
- }).on('hide',
- function (event) {
- event.preventDefault();
- event.stopPropagation();
- }).on("changeDate",
- function (e) {
- //console.log(e);
- //console.log(e.date.valueOf());
- $start.datetimepicker('setEndDate', e.date);
- if (o.isAutoSetDate && o.startEndInterval && o.startEndInterval > 0) {
- $start.datetimepicker('setDate', new Date(e.date.valueOf() - 1000 * 60 * 60 * 24 * o.startEndInterval));
- }
- });
- if (o.isAutoSetDate) {
- var eDate = o.defaultDate ? o.defaultDate : new Date();
- $end.datetimepicker("setDate", eDate);
- $start.datetimepicker("setDate",
- new Date(eDate.valueOf() - 1000 * 60 * 60 * 24 * (o.startEndInterval ? o.startEndInterval : 30)));
- }
- };
- DateTime.prototype.load = function () {
- var that = this, o = that.options;
- $(that.$ele).datetimepicker('remove');
- $(that.$ele).datetimepicker(o).on('show', function (event) {
- event.preventDefault();
- event.stopPropagation();
- }).on('hide', function (event) {
- event.preventDefault();
- event.stopPropagation();
- });
- };
- //var allowedMethods = [
- // 'date',
- // 'dateTime',
- // 'dateSecond',
- // 'twoDate'
- //];
- //$.fn.iwbDate2 = function (option) {
- // var value,
- // args = Array.prototype.slice.call(arguments, 1);
- // this.each(function () {
- // var $this = $(this);
- // var data = $this.data('iwb.dateTime');
- // if (!data) {
- // data = new DateTime(this, option ? option : {});
- // $this.data('iwb.dateTime', 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 && ($this.hasClass('iwb-date-time') || $this.hasClass('iwb-dateTime'))) {
- // data.dateTime();
- // } else if (!option && ($this.hasClass('iwb-date-second') || $this.hasClass('iwb-dateSecond'))) {
- // data.dateSecond();
- // } else if (!option && ($this.hasClass('startTime') || $this.hasClass('iwb-date-two') || $this.hasClass('iwb-twoDate'))) {
- // data.twoDate();
- // } else {
- // data.load();
- // }
- // }
- // });
- // return typeof value === 'undefined' ? this : value;
- //};
- //$.fn.iwbTwoDate2 = function (option) {
- // this.each(function () {
- // var $this = $(this);
- // var data = $this.data('iwb.dateTime');
- // if (!data) {
- // data = new DateTime(this, option);
- // $this.data('iwb.dateTime', data);
- // data.init();
- // data.twoDate();
- // }
- // });
- // return this;
- //};
- //$('.iwb-date-time').iwbDate();
- //$('.iwb-date').iwbDate();
- })(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/moment.min.js', "dy-js-daterangepicker.moment");
- $.metPageJs('/Content/Libs/bootstrap-daterangepicker/daterangepicker.js', "dy-js-daterangepicker");
- 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')
- ]
- };
- if (o.language.toLowerCase() === 'zh-cn' || o.language.toLowerCase() === 'zh-hans') {
- localeName = {
- applyLabel: "确定",
- cancelLabel: "清空",
- fromLabel: "起始时间",
- toLabel: "结束时间'",
- customRangeLabel: "自定义",
- weekLabel: "W",
- daysOfWeek: ["日", "一", "二", "三", "四", "五", "六"],
- monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
- };
- ranges = {
- '今日': [moment(), moment()],
- '昨日': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
- '最近 7 日': [moment().subtract(6, 'days'), moment()],
- '最近 30 最近': [moment().subtract(29, 'days'), moment()],
- '上个月': [moment().startOf('month'), moment().endOf('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
- };
- console.log(dateOpt.ranges);
- };
- DateTime.prototype.date = function () {
- var that = this, o = that.options;
- that.load();
- };
- DateTime.prototype.dateTime = function () {
- var that = this//, o = that.options;
- dateOpt.locale.format = "YYYY-MM-DD HH:MM";
- dateOpt.timePicker = true;
- that.load();
- };
- DateTime.prototype.dateSecond = function () {
- var that = this//, o = that.options;
- dateOpt.locale.format = "YYYY-MM-DD HH:MM:SS";
- dateOpt.timePicker = true;
- dateOpt.timePickerSeconds = true;
- that.load();
- };
- DateTime.prototype.dataRange = function () {
- var that = this, o = that.options;
- dateOpt.singleDatePicker = false;
- that.load();
- };
- DateTime.prototype.dataRangeTime = function () {
- var that = this, o = that.options;
- dateOpt.locale.format = "YYYY-MM-DD HH:MM";
- dateOpt.timePicker = true;
- dateOpt.singleDatePicker = false;
- that.load();
- };
- DateTime.prototype.dataRangeSecond = function () {
- var that = this, o = that.options;
- dateOpt.locale.format = "YYYY-MM-DD HH:MM:SS";
- dateOpt.singleDatePicker = false;
- dateOpt.timePicker = true;
- dateOpt.timePickerSeconds = true;
- that.load();
- };
- DateTime.prototype.load = function () {
- var that = this, o = that.options;
- $(that.$ele).daterangepicker(dateOpt, 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 && $.isFunction(o.cancelEvent) ? o.cancelEvent : function () { $(that.$ele).val('') }
- $(that.$ele).on('cancel.daterangepicker', cancelEvent);
- if (o.applyEvent && $.isFunction(o.applyEvent)) {
- $(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 && $.isFunction(o.hideEvent)) {
- $(that.$ele).on('hide.daterangepicker', o.hideEvent);
- }
- if (o.showCalendarEvent && $.isFunction(o.showCalendarEvent)) {
- $(that.$ele).on('showCalendar.daterangepicker', o.showCalendarEvent);
- }
- if (o.hideCalendarEvent && $.isFunction(o.hideCalendarEvent )) {
- $(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 = {};
- 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['#'] = window.editor[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);
- ; (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 '';
- }
- }
- }
- //==========================================================================================================================
|