12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939 |
- +function ($) {
- "use strict";
- $.format = function(o) {
- var newObj = {
- success: 0
- },
- str = o;
- if (typeof str == "undefined") {
- return newObj;
- }
- if (str.indexOf("{") != -1) {
- str = str.substring(str.indexOf("{"), str.lastIndexOf("}") + 1);
- newObj = $.extend({}, newObj, str.toJSON());
- newObj.success = 1;
- }
- return newObj;
- };
- $.fn.Options = function(options) {
- return options == null ? $.format($(this).attr("class")) : (typeof(options) == "object" ? options : $.format($(this).attr(options)));
- };
- }($);
- (function(){
- String.prototype.trim = function() {
- return this.replace(/^\s+/, "").replace(/\s+$/, "");
- };
- String.prototype.isEmpty = function() {
- var s = this.trim();
- return s.length == 0;
- };
- String.prototype.toText = function() {
- var str = this;
- str = str.replace(/</g, "<");
- str = str.replace(/>/g, ">");
- str = str.replace(/\n\r/g, "<br />");
- str = str.replace(/\n/g, "<br />");
- str = str.replace(/\r/g, "<br />");
- return str;
- };
- String.prototype.toHtml = function() {
- var str = this;
- str = str.replace(/</g, "<");
- str = str.replace(/>/g, ">");
- str = str.replace(/\n\r/g, "<br />");
- str = str.replace(/\n/g, "<br />");
- str = str.replace(/\r/g, "<br />");
- return str;
- };
- String.prototype.format = function(args) {
- var result = this;
- if (arguments.length > 0) {
- if (arguments.length == 1 && typeof(args) == "object") {
- for (var key in args) {
- if (args[key] != undefined) {
- var reg = new RegExp("({" + key + "})", "g");
- result = result.replace(reg, args[key]);
- }
- }
- } else {
- for (var i = 0; i < arguments.length; i++) {
- if (arguments[i] != undefined) {
- var regStr = "",
- num = i.toString();
- for (j = 0; j < num.length; j++) {
- regStr += "[" + num.substr(j, 1) + "]{1}";
- }
- var reg = new RegExp("{" + regStr + "}", "g");
- result = result.replace(reg, arguments[i]);
- }
- }
- }
- }
- return result;
- };
- String.prototype.formatMoney = function(s) {
- var num = this.toString().replace(/[^\d.]/g, "").split("."),
- s = s || "";
- num.length = 2;
- num = num.join(".");
- if (isNaN(num)) {
- num = "0";
- }
- var sign = (num == (num = Math.abs(num)));
- num = Math.floor(num * 100 + 0.50000000001);
- var cents = num % 100;
- num = Math.floor(num / 100).toString();
- if (cents < 10) {
- cents = "0" + cents;
- }
- for (var i = 0, j = Math.floor((num.length - (1 + i)) / 3); i < j; i++) {
- num = num.substring(0, num.length - (4 * i + 3)) + s + num.substring(num.length - (4 * i + 3));
- }
- return (((sign) ? '' : '-') + num + '.' + cents);
- };
- String.prototype.toMoney = function(s) {
- var str = this.toString().replace(/[^\d.]/g, "").split(".");
- str.length = 2, s = s || "", num = ((str[0] || 0) * 1000 / 1000).toString();
- str[1] = str[1] || 0;
- str[1] = Number("0." + str[1]).toString().substring(2, str[1].length + 2);
- var nums = this.toString().substr(0, 1) == '-' ? true : false;
- if (str[1].length < 2) {
- for (var i = str[1].length; i < 2; i++) {
- str[1] += "0";
- }
- }
- for (var i = 0, j = Math.floor((num.length - (1 + i)) / 3); i < j; i++) {
- num = num.substring(0, num.length - (4 * i + 3)) + s + num.substring(num.length - (4 * i + 3));
- }
- str[0] = num;
- return (nums ? "-" : "") + str.join(".");
- };
- Number.prototype.toMoney = String.prototype.toMoney;
- Number.prototype.formatMoney = String.prototype.formatMoney;
- Date.prototype.Format = function(format) {
- var format = format || "yyyy-MM-dd hh:mm:ss",
- o = {
- "M+": this.getMonth() + 1,
- "d+": this.getDate(),
- "h+": this.getHours(),
- "m+": this.getMinutes(),
- "s+": this.getSeconds(),
- "q+": Math.floor((this.getMonth() + 3) / 3),
- "S": this.getMilliseconds()
- };
- if (/(y+)/.test(format)) {
- format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length))
- }
- for (var k in o) {
- if (new RegExp("(" + k + ")").test(format)) {
- format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length))
- }
- }
- return format;
- };
- String.prototype.toDate = function(f) {
- return new Date(parseInt(this) * 1000).Format(f || "yyyy-MM-dd hh:mm:ss");
- };
- Date.prototype.add = function(milliseconds){
- var m = this.getTime() + milliseconds;
- return new Date(m);
- };
- Date.prototype.addSeconds = function(second){
- return this.add(second * 1000);
- };
- Date.prototype.addHours = function(hour){
- return this.addMinutes(hour*60);
- };
- Date.prototype.addMinutes = function(minute){
- return this.addSeconds(minute*60);
- };
- Date.prototype.addDate = function(format) {
- var format = parseInt(format, 10) || 0,
- time = 0;
- time = this.getTime() + (format * 60 * 60 * 24 * 1000);
- return new Date(time);
- };
- String.prototype.dateDiff = function(date, interval) {
- var objInterval = {
- 'D': 1000 * 60 * 60 * 24,
- 'H': 1000 * 60 * 60,
- 'M': 1000 * 60,
- 'S': 1000,
- 'T': 1
- },
- Time = (interval || "D").toUpperCase(),
- start = new Date(this.replace(/-/g, "/")),
- end = new Date(date.replace(/-/g, "/"));
- try {
- return Math.round((end.getTime() - start.getTime()) / parseInt(eval("objInterval." + Time), 10));
- } catch (e) {
- return e.message;
- }
- };
- String.prototype.decode = function(args) {
- var result = this;
- if (arguments.length > 0) {
- if (arguments.length == 1) {
- result = args;
- } else {
- for (var i = 0; i < arguments.length; i = i + 2) {
- if (arguments[i] != undefined) {
- if (arguments[i + 1] != undefined) {
- if (result == arguments[i]) {
- result = arguments[i + 1];
- break;
- }
- } else {
- result = arguments[i];
- }
- }
- }
- }
- }
- return result;
- }
- String.prototype.toJSON = function() {
- return new Function("return " + this.toText())();
- };
- String.prototype.unhtml = function(reg) {
- return this ? this.replace(reg || /[&<">'](?:(amp|lt|quot|gt|#39|nbsp|#\d+);)?/g, function (a, b) {
- if (b) {
- return a;
- } else {
- return {
- '<':'<',
- '&':'&',
- '"':'"',
- '>':'>',
- "'":'''
- }[a]
- }
- }) : '';
- };
- String.prototype.html = function() {
- return this ? this.replace(/&((g|l|quo)t|amp|#39|nbsp);/g, function (m) {
- return {
- '<':'<',
- '&':'&',
- '"':'"',
- '>':'>',
- ''':"'",
- ' ':' '
- }[m]
- }) : '';
- };
- $.showIndicator = function () {
- $(document.body).append('<div class="preloader-indicator-overlay"></div><div class="preloader-indicator-modal"><span class="preloader preloader-white"></span></div>');
- };
- $.hideIndicator = function () {
- $('.preloader-indicator-overlay, .preloader-indicator-modal').remove();
- };
- })(jQuery);
- +function ($) {
- "use strict";
- $.cookie = {
- set:function(name, value, iDay){
- iDay = iDay || 1;
- var oDate=new Date();
- oDate.setDate(oDate.getDate()+iDay);
- document.cookie=name+'='+encodeURIComponent(value)+';expires='+oDate;
- },
- get:function(name){
- var arr=document.cookie.split('; ');
- var i=0;
- for(i=0;i<arr.length;i++){
- var arr2=arr[i].split('=');
- if(arr2[0]==name){
- var getC = decodeURIComponent(arr2[1]);
- return getC;
- }
- }
- return '';
- },
- remove:function(name){
- this.set(name, '1', -1);
- }
- }
- }($);
- +function ($) {
- "use strict";
- $.fn.tabs=function(options){
- var defaults={tabMenu:".tab-menu",tabContent:".tab-content-box",tabDisplay:"div.tab-content",currentTab:0,defaultClass:"active",isAutoPlay:false,stepTime:2000,switchingMode:"c"},
- o = $.extend({},defaults, options),
- _tabList=$(this).find(o.tabMenu),
- _tabTxt=$(this).find(o.tabContent),
- tabListLi=_tabList.find("li:not('.disabled')");
- _tabList.find("li:eq("+o.currentTab+")").addClass(o.defaultClass);
- _tabTxt.children(o.tabDisplay).each(function(i){
- $(this).attr("id","wp_div"+i);
- }).eq(o.currentTab).show();
- tabListLi.each(function(ix){
- $(this).mouseover(function(){
- if(o.switchingMode == "o"){
- $(this).click();
- }
- });
- $(this).click(function(){
- if($(this).className != o.defaultClass){
- $(this).addClass(o.defaultClass).siblings().removeClass(o.defaultClass);
- }
- if($.browser.msie){
- _tabTxt.children(o.tabDisplay).eq(ix).siblings().hide();
- _tabTxt.children(o.tabDisplay).eq(ix).show();
- }else{
- _tabTxt.children(o.tabDisplay).eq(ix).show().siblings().hide();
- }
- });
- });
- };
- }($);
- /**/
- +function ($) {
- "use strict";
- $.fn.Tags = function(){
- var _this = this;
- _this.find("li>a").live("click",function(){
- var $this = $(this),
- childNode = $this.parent().children("ul");
- if(childNode.length > 0){
- $("ul",_this).addClass("contentTxt");
- $(_this).find(">li>a").removeClass("active");
- childNode.removeClass("contentTxt");
- $($this).addClass("active");
- }
- });
- }
- }($);
- +function ($) {
- "use strict";
- $.fn.serializeJSON = function(options){
- var $this = $(this),
- opts = $.fn.Options.call(this, options),
- data = opts.data || $this.serializeArray(),
- list = [];
- $.each(data, function(i, filed){
- list.push('"'+filed.name+'":"'+filed.value.trim().unhtml()+'"');
- });
- var newdata = "{" + list.join(',') + "}";
- return newdata.toJSON();
- }
- }($);
- /*input tip检测下拉*/
- +function ($) {
- "use strict";
- $.fn.autocomplete = function(urlOrData, options) {
- var isUrl = typeof urlOrData == "string";
- options = jQuery.extend({}, jQuery.Autocompleter.defaults, {
- url: isUrl ? urlOrData : null,
- data: isUrl ? null : urlOrData,
- delay: isUrl ? jQuery.Autocompleter.defaults.delay : 10,
- max: options && !options.scroll ? 10 : 150
- }, options);
- // if highlight is set to false, replace it with a do-nothing function
- options.highlight = options.highlight ||
- function(value) {
- return value;
- };
- // if the formatMatch option is not specified, then use formatItem for backwards compatibility
- options.formatMatch = options.formatMatch || options.formatItem;
- return this.each(function() {
- new jQuery.Autocompleter(this, options);
- });
- }
- $.fn.result = function(handler) {
- return this.bind("result", handler);
- }
- $.fn.search = function(handler) {
- return this.trigger("search", [handler]);
- }
- $.fn.flushCache = function() {
- return this.trigger("flushCache");
- }
- $.fn.setOptions = function(options) {
- return this.trigger("setOptions", [options]);
- },
- $.fn.unautocomplete = function() {
- return this.trigger("unautocomplete");
- }
- }($);
- /*
- url -- ajax查询数据地址
- length -- 输入的字符长度搜索
- returnId -- 接收返回数据ID
- width -- 下拉列表的宽度
- fun -- 回调方法
- 是否展示可输的下拉菜单
- */
- +function ($) {
- "use strict";
- $.fn.inputTips = function(url, len, back, width, fun, clickStatus) {
- var url = url || "",
- back = back || "",
- len = len || 2,
- width = width || 166,
- clickStatus = clickStatus == null ? false : clickStatus;
- if (url == "") {
- return false;
- }
- $(this).unbind();
- $(this).autocomplete(url, {
- "max": 30,
- "minChars": len,
- "clickStatus":clickStatus,
- "width": width,
- "dataType": "json",
- parse: function(data) {
- return $.map(data.d.list, function(item, row) {
- return {
- data: item,
- value: item.value,
- result: item.text
- }
- });
- },
- formatItem: function(item, i, max) {
- return item.text;
- }
- }).result(function(e, data, formatted) {
- if (back != "") {
- $(back).val(data.id);
- }
- if (fun != null) {
- fun.call(this, data);
- }
- }).focusout(function() {
- var val = $(this).val().trim();
- if (back != "" && val == "") {
- $(back).val("");
- }
- if (fun != null && val == "") {
- fun.call(this, {});
- }
- }).keyup(function() {
- var val = $(this).val().trim();
- if (back != "" && val == "") {
- $(back).val("");
- }
- });
- }
- }($);
- /*输入强制转换数字类型*/
- +function ($) {
- "use strict";
- $.fn.number = function(options) {
- if (typeof options === 'function') {
- var opts = {
- fun: options
- };
- } else {
- var opts = $.fn.Options.call(this, options);
- opts = $.extend({}, {
- fun: null
- }, opts);
- };
- $(this).bind('keyup afterpaste focusout', function(e) {
- var oldVal = this.value,
- val = oldVal.replace(/[^\d.]/g, '').replace(/^\./g, "").replace(/\.{2,}/g, ".").replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
- opts.place && val > opts.place ? this.value = "":"";
- if (e.type == 'focusout') {
- if (typeof opts.fun === 'function') {
- var val = this.value * 1;
- opts.fun.call(this, val);
- };
- };
- if (oldVal != val) {
- this.value = val;
- };
- });
- }
- }($);
- +function ($) {
- "use strict";
- $.fn.hoverTable = function(tr) {
- var $Class = $(this),
- tr = tr || false;
- $Class.find("tbody").find("tr").removeClass("trSplit").off("click mouseenter mouseleave");
- if (tr) {
- $Class.each(function(index, element) {
- $(this).find("thead").find("th").last().addClass("lastTh");
- $Class.eq(index).find("tbody").find("tr").each(function(i, element) {
- if (i % 2 == 1) {
- $(this).addClass("trSplit");
- }
- });
- });
- }
- $Class.find("tbody").find("tr").bind({
- mouseenter: function() {
- $(this).addClass("trHover");
- },
- mouseleave: function() {
- $(this).removeClass("trHover");
- }
- });
- }
- }($);
- /*没有数据时显示提示*/
- +function ($) {
- "use strict";
- $.fn.info = function(msg, type) {
- var $this = $(this), msg = msg || '', $thead = $this.closest("table").find("thead");
- if(type == 1){
- $this.addClass("noInfo").html("<i class=\"icon info\"></i>"+msg);
- }else{
- if($thead.length > 0)
- $this.html("<tr><td class=\"noInfo\" colspan=\""+$thead.find("th").length+"\"><i class=\"icon info\"></i><span class=\"middle\">"+msg+"</span></td></tr>");
- else
- $this.html("<tr><td class=\"noInfo\"><i class=\"icon info\"></i><span class=\"middle\">"+msg+"</span></td></tr>");
- }
- }
- }($);
- /*获取地址栏参数值*/
- +function ($) {
- "use strict";
- $.getParam = function(name){
- var url = window.location.href,
- urlArr = url.split("?");
- var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
- if(urlArr.length > 1){
- var r = urlArr[1].match(reg);
- if (r != null) return unescape(encodeURIComponent(r[2])); return null;
- }else
- return null;
- }
- }($);
- +function ($) {
- "use strict";
- uiAlert.MyAlert = function(json, flag, fun) {
- var fun = fun || null,
- flag = flag || (json != undefined && json.flag || 0);
- uiAlert.first(new uiAlert.Tostring(typeof(json) != "object" ? "" + json + "" : json), flag, fun);
- };
- window.alert = uiAlert.MyAlert;
- $.fn.alert = function(options) {
- return this.each(function(e) {
- var name = new uiAlert.Tostring(options);
- uiAlert.first(name, e);
- });
- }
- }($);
- function uiAlert(data, flag) {
- this.data = data;
- this.flag = flag || data.flag;
- if (typeof uiAlert._initialized == "undefined") {
- uiAlert.prototype.Append = function() {
- // 创建弹出
- // $(".Uialert_Bbox").length > 0 ? $(".Uialert_Bbox").remove() : "";
- uiAlert.Close();
- $("body").append("<div class=\"Uialert_Bbox \" style=\"height:" + ($(window).height() - 22) + "px;display:none;\"><div class=\"Uialert_bj\" style=\"height:" + ($(window).height() - 22) + "px;\"></div><div class=\"Uialert_box\" style=\"display:none;\"></div></div>");
- // 创建盒子
- var $Box = $(".Uialert_box");
- //$Box.append("<div class=\"Uialert_title\"><span class=\"Uialert_Tspan\">" + this.data.title + "</span><a href=\"#\" class=\"uiAlert_close\" onclick=\"uiAlert.GoNext();return false;\">关闭</a></div>");
- // 创建title
- $Box.append("<div class=\"Uialert_nav\"><div class=\"Uialert_Nleft\"><span class='icon" + (this.flag ? ' iOk' : ' iError') + "'></span></div><div class=\"Uialert_Nright\">"+(this.data.title != "" ? "<div class=\"Uialert_Tspan\">" + this.data.title + "</div>":"") + this.data.nav + "</div></div>");
- // 创建正文
- $Box.append("<div class=\"Uialert_button\"><input type=\"button\" value=\"确定\" onclick=\"uiAlert.GoNext();return false;\" class=\"one\" /></div>");
- // 创建底部按钮
- $(".Uialert_bj").fadeTo(0, this.data.opacity);
- // 更改遮挡层透明度
- $(".Uialert_Bbox").show();
- $Box.fadeIn(300);
- uiAlert.ChangeCss();
- // 更改css
- this.B_Click();
- // 绑定点击事件
- this.Auto();
- // 绑定自动关闭事件
- uiAlert.next = this.data.next;
- // 光标焦点处于按钮上
- $(".Uialert_button>input").focus();
- };
- uiAlert.prototype.Auto = function() {
- // 自动
- if (this.data.close) {
- var AutoT = null;
- AutoT = setTimeout(function() {
- clearTimeout(AutoT);
- uiAlert.GoNext();
- },
- this.data.time);
- }
- };
- uiAlert.prototype.B_Click = function() {
- // 点击遮挡层
- var z = $(".Uialert_title").css("background-color");
- $(".Uialert_Bbox,#TB_HideSelect body").bind({
- click: function() {
- $(".Uialert_Binput").focus();
- }
- });
- };
- uiAlert._initialized = true;
- }
- }
- uiAlert._object = function(){
- var obj = {box:document.body};
- obj.type = false;
- obj.height = $(obj.box).outerHeight();
- obj.width = $(obj.box).outerWidth();
- obj.top = $(obj.box).offset().top;
- obj.left = $(obj.box).offset().left;
- uiAlert.object = obj;
- }
- uiAlert.Tostring = function(o) {
- this.nav = typeof o == "object" ? o.nav.replace(/\n\r/g, "<br />").replace(/\n/g, "<br />").replace(/\r/g, "<br />") : o.replace(/\n\r/g, "<br />").replace(/\n/g, "<br />").replace(/\r/g, "<br />");
- // 替换\n为<br />
- this.close = o.close || false;
- this.time = o.time || 3000;
- this.title = o.title || "提示";
- this.opacity = o.opacity || 0.3;
- this.next = o.next || function() {};
- this.flag = o.flag || false;
- return {
- "nav": this.nav,
- "close": this.close,
- "time": this.time,
- "title": this.title,
- "opacity": this.opacity,
- "next": this.next,
- "flag": this.flag
- };
- };
- uiAlert.first = function(data, n, fun) {
- // 添加和执行处理
- if (typeof fun == "function") {
- data.next = fun;
- }
- var Alert = new uiAlert(data, n);
- Alert.Append();
- };
- uiAlert.GoNext = function() {
- uiAlert.Close();
- uiAlert.next();
- };
- uiAlert.ChangeCss = function() {
- // 更改css
- $(window).resize(uiAlert.ChangeCss);
- // 当window窗口变化时
- if (typeof uiAlert.object == "undefined" || uiAlert.object.type) {
- var $Box = $(".Uialert_box");
- $(".Uialert_Bbox,.Uialert_bj").css({
- "height": $(window).height()
- });
- $Box.css({
- // 重置提示框位置
- "top": ((window.screen.availHeight - $Box.height()) / 2),
- "left": (($(window).width() - $Box.width()) / 2)
- });
-
- } else {
- $(".Uialert_Bbox").css({
- position: "absolute",
- top: uiAlert.object.top,
- left: uiAlert.object.left,
- height: uiAlert.object.height,
- width: uiAlert.object.width
- });
- }
- };
- uiAlert.ie = function() {
- var userAgent = navigator.userAgent.toLowerCase();
- $.browser = {
- version: (userAgent.match( /.+(?:rv|it|ra|ie)[/: ]([d.]+)/ ) || [])[1],
- safari: /webkit/.test( userAgent ),
- opera: /opera/.test( userAgent ),
- msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
- mozilla: /mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)
- };
- !$.browser.msie ? "" : ($.browser.version == 6.0 ? uiAlert.scroll() : "");
- // 当ie6时绑定
- };
- uiAlert.B_Click_ = function(x, y, z) {
- // 更改背景色触发
- var x = x,
- y = y,
- T = null,
- z = z;
- clearInterval(T);
- T = setInterval(function() {
- if (x <= y) {
- uiAlert.Change_b();
- x++;
- } else {
- $(".Uialert_title").css({
- "background-color": z
- });
- clearInterval(T);
- }
- },
- 100);
- };
- uiAlert.Change_b = function() {
- // 更改背景颜色
- $(".Uialert_title").css({
- "background-color": "rgb(" + uiAlert.B_Click_B() + "," + uiAlert.B_Click_B() + "," + uiAlert.B_Click_B() + ")"
- });
- };
- uiAlert.B_Click_B = function() {
- // 随机数字_背景色
- return Math.round(Math.random() * 255);
- };
- uiAlert.Close = function() {
- // 关闭
- $(".Uialert_Bbox").remove();
- if (typeof uiAlert.scroll._init != "undefined") {
- $("html").css("overflow", "");
- delete uiAlert.scroll._init;
- }
- $(window).unbind("resize scroll");
- typeof uiAlert.object != "undefined" ? delete uiAlert.object : "";
- if (typeof CollectGarbage != "undefined") {
- CollectGarbage();
- }
- };
- uiAlert.scroll = function() {
- // 绑定滚动条滚动事件
- if (typeof uiAlert.scroll._init == "undefined") {
- // iframe to hide select elements in ie6
- // $("html").css("overflow","hidden");
- $(".Uialert_Bbox").append("<iframe id=\"TB_HideSelect\" style=\"position: absolute;z-index:99;background-color: #fff;border: none;filter: alpha(opacity=0);height:" + $(".Uialert_Bbox").height() + "px;width: 100%;\"></iframe>");
- uiAlert.scroll._init = true;
- }
- uiAlert.scroll.css();
- $(window).bind({
- scroll: function() {
- uiAlert.scroll.css();
- }
- });
- };
- uiAlert.scroll.css = function() {
- $(".Uialert_Bbox").css({
- "top": $(window).scrollTop()
- });
- };
- +function ($) {
- "use strict";
- uiConfirm.MyConfirm = function(n, fun, o) {
- var o = o || true;
- if (typeof fun == "undefined") {
- top.uiConfirm.type = false;
- } else if (typeof fun == "function") {
- uiConfirm.type = true;
- uiConfirm.fun = fun;
- }
- o == true ? uiConfirm.call(this, uiConfirm.toJson(n, name)) : _confirm(n);
- };
- window.confirm = uiConfirm.MyConfirm;
- $.fn.uiConfirm = function(options) {
- return this.each(function(e) {
- var name = uiConfirm.toJson(options);
- uiConfirm(name, e);
- });
- }
- $.fn.uiConfirm.defaults = {
- title: "温馨提示", // 标题
- content: "", // 确认提示内容
- width: 350,
- data: null, // 开放自定义接口,为方法之间数据传输
- opacity: 0.1,
- button: 0, // 确认回调方法 0/1,0表示取消,1表示确认
- flag:1,
- fontcolor:"#434343",
- alertsubmit:'确认',
- alertcancle:'取消',
- fun: false // 用户选择后回调方法
- };
- }($);
- function uiConfirm(n) {
- var data = n || $.fn.uiConfirm.defaults;
- uiConfirm.data = data;
- this._init = function() {
- uiAlert.Close();
- var $Uialert_Bbox = $("<div class=\"Uialert_Bbox\" style=\"height:" + ($(window).height() - 22) + "px;display:none;\"><div class=\"Uialert_bj\" style=\"height:" + ($(window).height() - 22) + "px;\"></div><div class=\"Uialert_box\" style=\"width:" + parseInt(data.width, 10) + "px; display:none;\"></div></div>");
- // 创建盒子
- var $Box = $Uialert_Bbox.find(".Uialert_box");
- // 创建title
- $Box.append("<div class=\"Uialert_nav\"><div class=\"Uialert_Nleft\"><div class='icon" + (data.flag ? ' iInfo' : ' iError') + "'></div></div><div class=\"Uialert_Nright\">"+(data.title != "" ? "<div class=\"Uialert_Tspan\">" + data.title + "</div>":"") + data.content + "</div></div>");
- // 创建正文
- $Box.append("<div class=\"Uialert_button\"><input type=\"button\" value="+data.alertsubmit+" onclick=\"uiConfirm.close(1);return false;\" class=\"two line\" /><input type=\"button\" value="+data.alertcancle+" onclick=\"uiConfirm.close(0);return false;\" style=\"right:0;\" class=\"two disabled\" /></div>");
- // 创建底部按钮
- $("body").append($Uialert_Bbox);
- $(".Uialert_bj").fadeTo(0, data.opacity);
- // 更改遮挡层透明度
- $(".Uialert_Bbox").show();
- $Box.fadeIn(300);
- this.ChangeCss();
- // 光标焦点处于取消按钮上
- $(".Uialert_button>input").eq(0).focus();
- };
- this.ChangeCss = function() {
- // 更改css
- $(window).resize(this.ChangeCss);
- // 当window窗口变化时
- var $Box = $(".Uialert_box");
- $(".Uialert_Bbox,.Uialert_bj").css({
- "height": $(window).height()
- });
- $Box.css({
- // 重置提示框位置
- "top": ((window.screen.availHeight - $Box.height()) / 2),
- "left": (($(window).width() - $Box.width()) / 2)
- });
- uiAlert.ie();
- };
- this._init();
- }
- uiConfirm.data = {};
- uiConfirm.close = function(type) {
- this.data.button = type || 0;
- uiAlert.Close();
- if (uiConfirm.type && this.data.button) {
- uiConfirm.fun();
- return false;
- } else if (uiConfirm.data.fun) {
- uiConfirm.data.fun.call(this.data, this.data.button);
- }
- };
- uiConfirm.toJson = function(n, name) {
- if (typeof n == "object") {
- $.fn.uiConfirm.defaults = $.extend({}, $.fn.uiConfirm.defaults, n);
- } else {
- $.fn.uiConfirm.defaults.content = n;
- }
- $.fn.uiConfirm.defaults.content = $.fn.uiConfirm.defaults.content.toHtml();
- return $.fn.uiConfirm.defaults;
- };
- /*
- 错误提示
- */
- +function ($) {
- "use strict";
- $.fn.tips = function(msg, callback){
- var $this = $(this),
- text = "<div class=\"errorTips\">\n\
- <a href=\"javascript:void(0);\" class=\"owClose\"></a>\n\
- <i class=\"icon iError\"></i>"+msg+"\n\
- </div>";
- $this.html(text);
- $(".errorTips").fadeIn("last");
- typeof callback == "function" ? callback.call(this) : "";
- $(".errorTips .owClose").live("click",$.closeTips);
- }
- $.closeTips = function(){
- $(this).closest(".errorTips").fadeOut('fast',function(){
- $(this).remove();
- });
- };
- }($);
- /*
- 设置input提示语
- */
- +function ($) {
- "use strict";
- $.fn.input = function(options) {
- return this.each(function(e) {
- var opts = $.fn.Options.call(this, options);
- opts = $.extend({}, {text: "", color: "#c5c5c5"}, opts);
- new fInput(this, opts);
- });
- }
- function fInput(o, opts) {
- var $this = $(o),
- padding = parseInt(getCss(o, "paddingLeft")),
- width = $this.outerWidth() - padding,
- height = $this.outerHeight(),
- top = $this.position().top,
- left = $this.position().left + parseInt(getCss(o, "marginLeft")),
- vid = $this.attr("id") || "";
- if (typeof fInput._init == "undefined") {
- fInput.num = 0;
- fInput._init = true;
- } else {
- fInput.num++;
- }
- if (vid == "") {
- vid = "input" + fInput.num;
- $this.attr("id", vid);
- }
- $this.attr("data-input", "lInput" + fInput.num).after("<label id=\"lInput" + fInput.num + "\" class=\"lInput\" style=\"width:" + width + "px;height:" + height + "px;color:" + opts.color + ";top:" + top + "px; left:" + left + "px; padding-left:" + padding + "px; line-height:" + height + "px;position:absolute;\" for=\"" + vid + "\">" + opts.text + "</label>");
- if ($this.val() != "") {
- $("#lInput" + fInput.num).hide().text("");
- }
- $this.bind({
- keyup: function() {
- var length = o.value.length,
- id = "#" + $this.attr("data-input");
- if (length > 0) {
- $(id).hide().text("");
- } else {
- $(id).show().text(opts.text);
- }
- },
- click: function() {
- var id = "#" + $this.attr("data-input"),
- length = o.value.length;
- if (length <= 0) $(id).hide().text("");
- },
- blur: function() {
- var id = "#" + $this.attr("data-input"),
- length = o.value.length;
- if (length <= 0) $(id).show().text(opts.text);
- }
- });
- }
- function getCss(o, key) {
- return o.currentStyle ? o.currentStyle[key] : document.defaultView.getComputedStyle(o, false)[key];
- };
- }($);
- /*
- 初始化所有input textarea文件框
- */
- +function ($) {
- "use strict";
- var resetText = function(o){
- var o = o || ".text,.textarea";
- $(o).each(function(i, item) {
- var $this = $(this),
- attr = $this.attr("icon") ? $this.attr("icon") : "",
- Class = attr != "" ? " " + attr + "Lable" : "",
- type = $this.attr("type") || "",
- clone = $this.attr("copy") || false,
- name = parseInt(Math.random() * 100000);
- Class += type == "button" || type == "submit" ? " labelButton" : "";
- if ($this.hasClass("textarea")) {
- Class = " textareaRadius";
- }
- if (typeof $this.data("cache") == "undefined") {
- $this.data("cache", "true");
- if(clone){
- var $obj = $this.parent().find("input[icon=" + clone + "]"),
- $search = $("<input type=\"button\" class=\"inSearch\" value=\"\" id=\"" + name + "\" />");
- $obj.hide();
- $this.wrap($("<label type=\"" + (attr || "label") + "\" class=\"borderRadius" + Class + "\"></label>")).after($search).attr("autocomplete", "off");
- $search.click(function() {
- $obj.click();
- });
- new resetText.inputEnter({
- input: this,
- func: function() {
- $obj.click();
- }
- });
- }else{
- $this.wrap(function() {
- return "<label type=\"" + (attr || "label") + "\" class=\"borderRadius" + Class + "\" />";
- }).attr("tautocomplete", "off");
- if($this.attr("arrow") == "true") $this.before("<span class=\"inputimg\"></span>");
- }
- }
- });
- resetText.inputHover();
- }
- resetText.inputHover = function(){
- $("input,.borderRadius").bind("mouseenter mouseleave", function(e) {
- var Class = ($(this).attr("icon") || $(this).attr("type")) + "Hover";
- if (e.type == "mouseenter") {
- $(this).addClass(Class);
- } else {
- $(this).removeClass(Class);
- }
- });
- }
- resetText.inputEnter = function(obj) {
- if (typeof obj != "object") {
- return false;
- }
- var obj = $.extend({}, {input: false,func: false}, obj);
- if (!obj.input) {
- return false;
- }
- $(obj.input).bind({
- keyup: function(event) {
- var event = event || window.event;
- if (event.keyCode == 13) {
- obj.func.call(this);
- }
- }
- });
- };
- $.resetText = resetText;
- }($);
- /*
- 重置系统复选框样式
- */
- +function ($) {
- "use strict";
- $.fn.checkbox = function(options) {
- return this.each(function() {
- var opt = $.fn.Options.call(this, options);
- opt = $.extend({}, {skin: "checkboxs", check: "check", disabled: "disabled", text: false, click: false, readonly: false}, opt);
- var $this = this,
- e = $(this),
- next = e.next("label"),
- text = opt.text === false ? e.val() : opt.text,
- disabled = e.is(":disabled");
- e.hide();
- if (next.attr("data-d")) {
- next.removeClass(opt.skin + "-" + opt.check);
- next.unbind("click mouseover mouseout");
- } else {
- if (next.length <= 0) {
- e.after("<label class=\"" + opt.skin + "\" "+(text == ""?"style='padding-left:15px;'":"")+" data-d=\"true\">" + text + "</label>");
- } else {
- next.addClass(opt.skin).attr({
- tabindex: 0,
- unselectable: "on",
- "data-d": "true"
- });
- }
- }
- // 重置label
- next = e.next("label");
- // 初始化
- if (disabled == false) {
- if (e.is(":checked")) {
- next.addClass(opt.skin + "-" + opt.check);
- }
- } else {
- next.addClass(opt.skin + "-" + opt.disabled);
- }
- // 移除只读复选框
- if (opt.readonly && opt.remove) {
- e.remove();
- }
- // 绑定事件
- next.bind({
- click: function(event) {
- if (opt.readonly) {
- return false;
- }
- if (e.is(":disabled")) {
- alert(opt.alert);
- return false;
- }
- if (!next.prev().is(':checked')) {
- next.addClass(opt.skin + "-" + opt.check);
- next.prev()[0].checked = true;
- } else {
- next.removeClass(opt.skin + "-" + opt.check);
- next.prev()[0].checked = false;
- }
- if (opt.click == false) {
- } else {
- opt.click.call(this, $this);
- }
- }
- });
- });
- }
- $.checkbox = function(){
- $("input[type='checkbox']").checkbox();
- };
- }($);
- /*
- 重置系统单选按钮样式
- */
- +function ($) {
- "use strict";
- $.fn.radio = function(options) { // 鍗曢€夋
- return this.each(function(e) {
- var opt = $.fn.Options.call(this, options);
- opt = $.extend({}, {skin: "radiobox", check: "check", disabled: "disabled", text: false, alert: "已禁用", click: false, readonly: false, remove: true}, opt);
- var $this = this,
- e = $(this),
- next = e.next("label"),
- text = opt.text === false ? e.val() : opt.text,
- disabled = e.is(":disabled");
- e.hide();
- if (next.attr("data-d")) {
- next.removeClass(opt.skin + "-" + opt.check);
- next.unbind("click mouseover mouseout");
- } else {
- if (next.length <= 0) {
- e.after("<label data-d=\"true\" class=\"" + opt.skin + "\">" + text + "</label>");
- } else {
- next.attr("data-d", "true").addClass(opt.skin);
- }
- }
- // 重置label
- next = e.next("label");
- // 初始化
- if (disabled == false) {
- if (e.is(":checked")) {
- next.addClass(opt.skin + "-" + opt.check);
- }
- } else {
- next.addClass(opt.skin + "-" + opt.disabled);
- }
- // 移除只读复选框
- // if(opt.readonly){
- // e.remove();
- // }
- // 绑定事件
- next.bind({
- click: function(event) {
- if (opt.readonly) {
- return false;
- }
- if (e.is(":disabled")) {
- // alert(opt.alert);
- return false;
- }
- next.addClass(opt.skin + "-" + opt.check).siblings().removeClass(opt.skin + "-" + opt.check);
- if (!next.prev().is(':checked')) {
- next.prev()[0].checked = true;
- }
- if (opt.click === false) {
- } else {
- opt.click.call(this, $this);
- }
- }
- });
- });
- }
- $.radio = function(){
- $("input[type='radio']").radio();
- };
- }($);
- +function ($) {
- "use strict";
- $.fn.outClick = function(options) {
- var name = $.extend({}, {idcache: "UiOutSide",remove: true,click: function() {}}, options),
- $this = $(this);
- name.obj = this;
- if (typeof $this.data("idcache") == "undefined") {
- setTimeout(function() {
- name.clickNum = 0;
- $this.data("idcache", name.idcache);
- $this.find("*").data("idcache", name.idcache);
- $(document).delegate("*", "mousedown", function(e) {
- e = e || window.event;
- var target = e.target || e.srcElement;
- if ($(target).data("idcache") != name.idcache && $(name.obj).find(target).length <= 0 && name.clickNum == 0) {
- name.click.call(this);
- $this.removeClick();
- name.clickNum++;
- }
- });
- }, 50);
- }
- }
- }($);
- +function ($) {
- "use strict";
- $.fn.removeClick = function() {
- $(this).removeData("idcache");
- $(this).find("*").removeData("idcache");
- $(document).undelegate("*", "mousedown");
- }
- }($);
- /*
- 重置系统下拉菜单
- */
- +function ($) {
- "use strict";
- $.fn.uiSelect = function(options) {
- return this.each(function(e) {
- typeof Select.Num == "undefined" ? Select.Num = 0 : Select.Num++;
- var name = $.fn.Options.call(this, options),
- index = Select.Num,
- $this = $(this);
- name = $.extend({}, {width: "100",height: "200",type: "click",change: true,onchange: false,ajax: false,box: null,input: false,text: ""}, name);
- if ($this.data("ListNum") == undefined) {
- $this.addClass("uiSelect" + index);
- $this.data("ListNum", index);
- } else {
- index = $this.data("ListNum");
- Select.Num--;
- $this.find(".selectbox").remove();
- }
- name.box = ".uiSelect" + index;
- if (name.change) {
- Select(name, this, index);
- }
- });
- }
-
- function Select(data, obj, num) {
- var Selected = null,
- Option = [],
- val = [],
- box = data.box + " ",
- $boxSelect = $(box + "select"),
- boxHeight = new Array(),
- text = "";
- boxHeight[0] = parseInt(data.height, 10);
- if ($boxSelect.length > 0) {
- $boxSelect.hide();
- Selected = $(data.box + " select option:selected").text();
- text = data.input ? "<input type=\"text\" class=\"selecttext\" id=\"selecttext" + num + "\" value=\"" + Selected + "\" />" : "<span class=\"selecttext\">" + data.text + Selected + "</span>";
- $(obj).append("<div class=\"selectbox\"><div class=\"selecttbox\">" + text + "<span class=\"selectimg\"></span></div><div class=\"selectubox\" style=\"width:" + parseInt(data.width, 10) + "px; max-height:" + boxHeight[0] + "px;top:-9999px;left:-9999px;\"><ul class=\"selectul\"></ul></div></div>");
- if (data.input) {
- $("#selecttext" + num).bind({
- keydown: function(e) {
- var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
- if (keyCode == 13) {
- return false;
- }
- },
- focusout: function() {
- var value = this.value;
- if (!val.equal(value)) {
- val.push(value);
- $(box + ".selectul").find("li").removeClass("selected");
- $(box + ".selectul li:eq(0)").after("<li class=\"selected\" value=" + value + ">" + value + "</li>");
- $(box + "select").append("<option selected=\"selected\" value=\"" + value + "\">" + value + "</option>");
- Select.SelectLi(data, true);
- }
- }
- });
- }
- // 创建select盒子
- // 获取select项
- $(box + "select option").each(function() {
- var $this = $(this),
- Class = $this.attr("selected") ? " class=\"optGroupLi selected\"" : " class=\"optGroupLi\"",
- SelectVal = $this.text() || "",
- icon = $this.attr("icon") ? "<span class=\"selectIcon " + $this.attr("icon") + "\"></span>" : "";
- if (SelectVal != "") {
- // Option.push("<li" + Class + (data.onchange ? "
- // onclick=\"javascript:" + data.onchange + ";\"" : "") + "
- // value=" + $(this).val() + ">" + SelectVal + "</li>");
- val.push(SelectVal);
- Option.push("<li" + Class + " value=" + $this.val() + ">" + icon + SelectVal + "</li>");
- }
- });
- $(box + ".selectul").append(Option.join(""));
- // 在指定class内添加select项
- // 验证option高度
- // boxHeight[1] = $(box + ".selectubox").height();
- // boxHeight[2] = data.height = boxHeight[1] < boxHeight[0] &&
- // boxHeight[1] != 0 ? boxHeight[1] : boxHeight[0];
- // $(box + ".selectubox").height(boxHeight[2]);
- // 执行绑定
- Select.SelectOption(data, obj);
- // 获取select分组
- $(box + "select optgroup").each(function(i) {
- var $this = $(this),
- SelectVal = $this.attr("label") || "",
- option = $this.find("option").eq(0).index(box + "select option");
- $(box + ".selectul").find("li").eq(i + option).before($("<li class=\"optgroup\">" + SelectVal + "</li>"));
- });
- }
- }
- $.uiSelect = function(){
- $("select").uiSelect();
- }
- // 获取分组添加位置
- Select.optgroup = function(a, c) {
- for (var a = 0; a < c.length; a++) {
- if (b == c[a]) {
- return a;
- break
- }
- }
- };
- // 绑定下拉
- Select.SelectLi = function(data, type) {
- var SelectTime = null,
- $box = $(data.box + " .selecttbox"),
- $option = $(data.box + " .selectubox"),
- $ouclick = $(data.box + " .selectbox"),
- _init = false,
- hoverClass = "selecthover",
- type = type || false,
- Change = data.onchange ? data.onchange : ($(data.box + " select").attr("onChange") || false);
- if (type) {
- $(data.box + " .selectul li").unbind("mouseenter").unbind("mouseleave").unbind("click");
- }
- $(data.box + " .selectul li").bind({
- // 选择项动作,以及点击项后触发动作
- mouseenter: function() {
- // 鼠标移入
- $(this).addClass("Optionselect");
- },
- mouseleave: function() {
- // 鼠标移出
- $(this).removeClass("Optionselect");
- },
- click: function() {
- // 鼠标点击
- var $this = $(this),
- Index = $this.index(data.box + " .optGroupLi");
- $(data.box + " option").eq(Index).attr("selected", "selected"); // .siblings().removeAttr("selected");
- // 控制select
- if (data.input) {
- $(data.box + " .selecttext").val($this.text());
- } else {
- $(data.box + " .selecttext").text(data.text + $this.text());
- }
- // 显示当前选择内容
- $this.addClass("selected").siblings().removeClass("selected");
- // 为当前选择添加指定class,并移除同辈元素的指定class
- Selectremove();
- if (typeof Change == "function") {
- Change.call($(data.box + " select"));
- }
- }
- });
- function Selectremove() {
- // 移出选择项盒子
- $box.removeClass(hoverClass);
- $option.css({
- "top": "-9999px",
- "left": "-9999px"
- });
- _init = false;
- // 恢复初始默认状态
- };
- };
- // select绑定
- /**
- * 2013-09-05 修正下拉项高度问题
- */
- Select.SelectOption = function(data, obj) {
- var SelectTime = null,
- $box = $(data.box + " .selecttbox"),
- $option = $(data.box + " .selectubox"),
- $ouclick = $(data.box + " .selectubox"),
- _init = false,
- hoverClass = "selecthover";
- if (data.type == "mouseover") {
- // 根据用户自定义绑定动作
- SelectBindM();
- } else {
- SelectBindC();
- }
- Select.SelectLi(data);
- function SelectBindM() {
- // 绑定鼠标移入显示选择项
- $box.bind({
- mouseenter: function() {
- // 鼠标移入
- var $this = this;
- $(this).addClass(hoverClass);
- SelectTime = setTimeout(function() {
- SelectOver($this);
- }, 300);
- },
- mouseleave: function() {
- // 鼠标移出
- _init ? "" : $box.removeClass(hoverClass);
- clearTimeout(SelectTime);
- }
- });
- };
- function SelectBindC() {
- // 绑定鼠标点击显示选择项
- $box.bind({
- mouseleave: function() {
- // 鼠标移出
- _init ? "" : $box.removeClass(hoverClass);
- },
- click: function() {
- // 鼠标点击
- _init ? "" : SelectOver(this);
- },
- mouseenter: function() {
- // 鼠标移入
- $(this).addClass(hoverClass);
- }
- });
- };
- function SelectOver(o) {
- // 移入选择项盒子
- _init = false;
- SelectTop(o);
- $ouclick.outClick({
- click: function() {
- Selectremove();
- _init = false;
- }
- });
- };
- function Selectremove() {
- // 移出选择项盒子
- $box.removeClass(hoverClass);
- $option.css({
- "top": "-9999px",
- "left": "-9999px"
- });
- _init = false;
- // 恢复初始默认状态
- };
- function SelectTop(o) {
- var $obj = $(o),
- $window = $(window),
- DHeight = $window.height() + $window.scrollTop(),
- oTop = $obj.offset().top,
- height = $(o).height(),
- opHeight = $option.height(),
- top = oTop + opHeight + height;
- top = top > DHeight ? -opHeight : height;
- $option.css({
- "top": top,
- "left": 0
- });
- return;
- };
- };
- $.select = function(){
- $(".select").uiSelect();
- }
- }($);
- // 分页
- /*
- * count = 总数 page = 当前页码 pagesize = 每页条数 splitsize = 分页前后显示 使用示例: var newpage =
- * new createPage(100,1,15,3); 输出: newpage.minHtml;//第n页/共n页
- * newpage.pageHtml;//共技n条 当前第n/n页 每页n条 页码 重置分页 newpage.resetPage(页码); 输出: 同上
- */
- var createPage = function(count, page, pagesize, splitsize, pageFun) {
- this.pageFun = pageFun || "pageGo";
- this.count = parseInt((count || 0), 10);
- this.page = page || 1;
- this.pagesize = pagesize || 15;
- this.splitsize = splitsize || 3;
- this.minTemplet = "第{0}页/共{1}页";
- this.pageTemplet = "{4}";
- //this.pageTemplet = "共计{0}条 当前第{1}/{2}页 每页{3}条 {4}";
- this.minHtml = this.minTemplet;
- this.pageHtml = this.pageTemplet.format(this.count, "{0}", "{1}", this.pagesize, "{2}");
- this.init();
- };
- createPage.prototype = {
- Size: function() { // 分页大小
- this.pagelen = parseInt(this.count % this.pagesize > 0 ? this.count / this.pagesize + 1 : this.count / this.pagesize);
- this.validatePage();
- this.initPage();
- },
- initPage: function() { // 重置分页模板
- this.minHtml = this.minTemplet.format(this.page, this.pagelen);
- this.pageHtml = this.pageHtml.format(this.page, this.pagelen, "{0}");
- },
- concat: function() { // 装载分页链接
- var s = this.page - this.splitsize < 1 ? 1 : this.page - this.splitsize,
- e = this.page + this.splitsize > this.pagelen ? this.pagelen : this.page + this.splitsize,
- html = "";
- if(e > 0) html += "<ul class=\"pagination\">";
- if(this.page == 1 && e > 0)
- html += '<li><span>«</span></li>';
- else if(e > 0)
- html += '<li><a href="javascript:void(0);" onclick="'+this.pageFun+'(1, this);">«</a></li>';
-
- for (var i = s; i < e + 1; i++) {
- //var et = (i == this.page ? " class=\"active\"" : "");
- if(i == this.page)
- html += '<li class=\"active\"><a href="javascript:void(0);">' + i + '</a></li>';
- else
- html += '<li><a href="javascript:void(0);" onclick="'+this.pageFun+'(' + i + ', this);">' + i + '</a></li>';
- }
- if(this.page == e && e > 0)
- html += '<li><span>»</span></li>';
- else if(e > 0)
- html += '<li><a href="javascript:void(0);" onclick="'+this.pageFun+'(' + e + ', this);">»</a></li>';
- if(e > 0) html+='</ul>';
- this.pageHtml = this.pageHtml.format(html);
- },
- validatePage: function() { // 验证有效分页
- if (this.page > this.pagelen) {
- this.page = this.pagelen;
- }
- },
- resetPage: function(page) { // 切换分页
- this.pageHtml = this.pageTemplet.format(this.count, "{0}", "{1}", this.pagesize, "{2}");
- this.page = page || this.page;
- this.initPage();
- return this.concat();
- },
- init: function() { // 装载分页
- this.Size();
- return this.concat();
- }
- };
- ajax = function(o, data, callBack) {
- new ajax.ajax(o, data, callBack);
- };
- +function ($) {
- "use strict";
- ajax.ajax = function(o, data, callBack){
- this.url = o.url || o;
- this.type = o.type || "POST";
- this.data = o.data || (data || "");
- this.dataType = o.dataType || "json";
- this.async = o.async || true;
- this.loading = o.load == null ? true : o.load;
- // this.contentType = o.contentType || "application/x-www-form-urlencoded";
- this.callBack = o.callBack || callBack;
- this.jsonp = o.jsonp || "";
- typeof this.callBack == "undefined" ? this.callBack = ajax.ajaxback : "";
- this.url = !this.url.isEmpty() ? (this.url.indexOf("?") != -1 ? this.url+"&t="+Math.random() : this.url+"?t="+Math.random()) : "";
- var $this = this;
- if (this.loading) $.showIndicator();
- $.ajax({
- url: $this.url,
- type: $this.type,
- data: $this.data,
- //contentType: $this.contentType,
- dataType: this.dataType,
- jsonp : this.jsonp,
- cache: false,
- async:$this.async,
- success: function(data) {
- if(data.code == 100){
- top.window.location.href = "/login.html";
- return false;
- }
- setTimeout(function() {
- $this.callBack.call(this, data);
- }, 200);
- },
- error: function(xml, status) {
- if (status == "error") {
- try {
- var json = eval("(" + xml.responseText + ")");
- alert(json.Message + "\n" + json.StackTrace);
- } catch (e) {
- }
- }
- },
- complete: function() {
- if ($this.loading) {
- $.hideIndicator();
- }
- }
- });
- }
- ajax.ajaxback = function(o) {};
- }($);
- var windowIndex = 0,Windows = [null];
- +function ($) {
- "use strict";
- $.openWindow = function(title,html,width,height,isUrl,fun,scrolling,flag){
- var title = title || "",
- html = html || "",
- width = parseInt(width || 300) + "px",
- height = parseInt(height || 100) + "px",
- m_left = (top.$(document).width() - parseInt(width))/2 + "px",
- m_top = ((document.documentElement.clientHeight || document.body.clientHeight) - parseInt(height))/2 + "px",
- isUrl = isUrl || false,
- flag = flag || 0,
- scrolling = scrolling ? "yes" : "no";
- windowIndex++;
- if(isUrl){
- html = '<iframe width="100%" style="margin:-10px 0;" name="minWindow" id="minWindow" height="' + height + '" src="' + html + '" frameborder="0" scrolling="'+scrolling+'"></iframe>';
- }
- Windows[windowIndex] = new OpenWindow(title ,html,{
- "width":width,
- "height":height,
- "top":m_top,
- "left":m_left
- },
- (fun || null),flag);
- }
- $.closeWindow = function(){
- Windows[windowIndex].close();
- }
- }($);
- var OpenWindow = function(f, e, d, c, a) {
- this.title = f || "";
- this.name = parseInt(Math.random() * 100000);
- this.defaults = {
- left: "300px",
- top: "100px",
- width: "400px",
- height: "400px"
- };
- this.flag = parseInt((a || 0), 10);
- this.style = $.extend(this.defaults, (d || {}));
- this.content = e;
- this.type = typeof type == "undefined" ? "common": type;
- this.height = $(document).height();
- this.width = $(document).width();
- this.fun = c || null;
- this.init = function() {
- var h = $(".owBj").length > 0 ? "none": "block";
- var g = '<div class="owBj" style="display:' + h + ";width:" + this.width + "px;height:" + this.height + 'px; top:0; left:0;"></div>\n\
- <div class="owBox" id="' + this.name + '" style="display:none;"><div class="owTitle">';
- if(this.title != "") g+='<span class="owtName">' + this.title + '</span>';
- g+='<span></span><a href="javascript:void(0);" class="owClose"></a></div>\n\
- <div class="owContent">' + this.content + "</div>\n\
- </div>";
- var i = '<div class="OpenWindow" id="box' + this.name + '">' + g + '</div>';
- $("body").append(i);
- OpenWindow.ArrayW.push(document.getElementById(this.name));
- this.setCss();
- this.startDrag();
- this.setTop();
- this.setCommond()
- };
- this.init();
- return this
- };
- OpenWindow.ArrayW = new Array();
- OpenWindow.Drag = function(d, c) {
- var a = this;
- this.obj = (typeof c != "undefined") ? c: d;
- this.relLeft = 0;
- this.relTop = 0;
- a._move = false;
- a.moveId = "moveWindow";
- d.onselectstart = function() {
- return false
- };
- d.onmousedown = function(g) {
- var f = $(c).offset(),
- h = $('<div class="' + a.moveId + '" style="border:1px dotted #ddd; cursor: move; position: absolute; background:#fff; z-index: 999998;"></div><div id="' + a.moveId + '" class="' + a.moveId + '" style="border:1px dotted #ddd; cursor: move; position: absolute; background:#000; z-index: 999999;"></div>');
- $("body").append(h);
- $("." + a.moveId).css({
- left: f.left,
- top: f.top,
- width: $(c).outerWidth(),
- height: $(c).outerHeight(),
- opacity: 0.5
- });
- g = a.fixE(g);
- a.relLeft = g.clientX - a.fixU(a.obj.style.left);
- a.relTop = g.clientY - a.fixU(a.obj.style.top);
- a._move = true;
- document.onmousemove = function(i) {
- a.drag(i)
- };
- document.onmouseup = function() {
- a.end()
- }
- };
- this.drag = function(h) {
- h = this.fixE(h);
- var f = h.clientX - this.relLeft;
- var g = h.clientY - this.relTop;
- if (g < 0) {
- g = 0
- }
- $("#" + a.moveId).css({
- left: f + "px",
- top: g + "px"
- })
- };
- this.end = function() {
- a._move = false;
- document.onmousemove = null;
- document.onmouseup = null;
- var e = $("#" + a.moveId).offset();
- $(a.obj).css({
- left: e.left + "px",
- top: e.top + "px"
- });
- $("." + a.moveId).remove();
- return false
- };
- this.fixE = function(f) {
- if (typeof f == "undefined") {
- f = window.event
- }
- return f
- };
- this.fixU = function(e) {
- return parseInt(e.split("p")[0])
- }
- };
- OpenWindow.prototype.setCss = function() {
- var a = document.getElementById(this.name);
- switch (this.flag) {
- case 0:
- if (typeof this.style.top != "undefined") {
- a.style.top = parseInt(this.style.top, 10) < 0 ? "0": this.style.top
- }
- if (typeof this.style.width != "undefined") {
- a.style.width = this.style.width
- }
- if (typeof this.style.left != "undefined") {
- a.style.left = this.style.left
- }
- break;
- case 1:
- a.style.top = "91px";
- a.style.height = ($(window).height() - 96) + "px";
- a.style.width = "100%";
- a.style.left = "0px";
- $("#" + this.name).find("#minWindow").height((parseInt(a.style.height, 10) - 31) + "px");
- break;
- case 2:
- a.style.top = 0;
- a.style.height = ($(window).height() - 6) + "px";
- a.style.width = "100%";
- a.style.left = "0px";
- $("#" + this.name).find("#minWindow").height((parseInt(a.style.height, 10) - 31) + "px");
- break;
- default:
- break
- }
- this.height = a.style.height;
- this.width = a.style.width;
- $("#" + this.name).fadeIn(500)
- };
- OpenWindow.prototype.startDrag = function() {
- var a = document.getElementById(this.name);
- new OpenWindow.Drag(a.childNodes[0].childNodes[0], a)
- };
- OpenWindow.prototype.setTop = function() {
- for (var a = 0; a < OpenWindow.ArrayW.length; a++) {
- OpenWindow.ArrayW[a].style.zIndex = 10004;
- }
- this.style.zIndex = 100;
- document.getElementById(this.name).onclick = document.getElementById(this.name).onmousedown = function() {
- for (var c = 0; c < OpenWindow.ArrayW.length; c++) {
- OpenWindow.ArrayW[c].style.zIndex = 10004;
- }
- this.style.zIndex = 10005;
- }
- };
- OpenWindow.prototype.close = function(a) {
- var a = a || this.name;
- $("#box" + a).remove();
- top.windowIndex = top.windowIndex - 1 < 0 ? 0 : top.windowIndex - 1;
- if (typeof(this.fun) == "function") {
- this.fun.call(this, {})
- }
- };
- OpenWindow.prototype.setCommond = function() {
- var a = this,
- c = document.getElementById(this.name);
- c.childNodes[0].getElementsByTagName("a")[0].onclick = function() {
- a.close();
- return false
- }
- };
- OpenWindow.prototype.getValue = function() {
- return this.content
- };
- OpenWindow.prototype.setValue = function(a) {
- this.content = Vlaue;
- this.setContent()
- };
- /*===========================
- Template7 Template engine
- ===========================*/
- /* global $:true */
- /* jshint unused:false */
- /* jshint forin:false */
- +function ($) {
- "use strict";
- $.Template7 = $.t7 = (function () {
- function isArray(arr) {
- return Object.prototype.toString.apply(arr) === '[object Array]';
- }
- function isObject(obj) {
- return obj instanceof Object;
- }
- function isFunction(func) {
- return typeof func === 'function';
- }
- var cache = {};
- function helperToSlices(string) {
- var helperParts = string.replace(/[{}#}]/g, '').split(' ');
- var slices = [];
- var shiftIndex, i, j;
- for (i = 0; i < helperParts.length; i++) {
- var part = helperParts[i];
- if (i === 0) slices.push(part);
- else {
- if (part.indexOf('"') === 0) {
- // Plain String
- if (part.match(/"/g).length === 2) {
- // One word string
- slices.push(part);
- }
- else {
- // Find closed Index
- shiftIndex = 0;
- for (j = i + 1; j < helperParts.length; j++) {
- part += ' ' + helperParts[j];
- if (helperParts[j].indexOf('"') >= 0) {
- shiftIndex = j;
- slices.push(part);
- break;
- }
- }
- if (shiftIndex) i = shiftIndex;
- }
- }
- else {
- if (part.indexOf('=') > 0) {
- // Hash
- var hashParts = part.split('=');
- var hashName = hashParts[0];
- var hashContent = hashParts[1];
- if (hashContent.match(/"/g).length !== 2) {
- shiftIndex = 0;
- for (j = i + 1; j < helperParts.length; j++) {
- hashContent += ' ' + helperParts[j];
- if (helperParts[j].indexOf('"') >= 0) {
- shiftIndex = j;
- break;
- }
- }
- if (shiftIndex) i = shiftIndex;
- }
- var hash = [hashName, hashContent.replace(/"/g,'')];
- slices.push(hash);
- }
- else {
- // Plain variable
- slices.push(part);
- }
- }
- }
- }
- return slices;
- }
- function stringToBlocks(string) {
- var blocks = [], i, j, k;
- if (!string) return [];
- var _blocks = string.split(/({{[^{^}]*}})/);
- for (i = 0; i < _blocks.length; i++) {
- var block = _blocks[i];
- if (block === '') continue;
- if (block.indexOf('{{') < 0) {
- blocks.push({
- type: 'plain',
- content: block
- });
- }
- else {
- if (block.indexOf('{/') >= 0) {
- continue;
- }
- if (block.indexOf('{#') < 0 && block.indexOf(' ') < 0 && block.indexOf('else') < 0) {
- // Simple variable
- blocks.push({
- type: 'variable',
- contextName: block.replace(/[{}]/g, '')
- });
- continue;
- }
- // Helpers
- var helperSlices = helperToSlices(block);
- var helperName = helperSlices[0];
- var helperContext = [];
- var helperHash = {};
- for (j = 1; j < helperSlices.length; j++) {
- var slice = helperSlices[j];
- if (isArray(slice)) {
- // Hash
- helperHash[slice[0]] = slice[1] === 'false' ? false : slice[1];
- }
- else {
- helperContext.push(slice);
- }
- }
- if (block.indexOf('{#') >= 0) {
- // Condition/Helper
- var helperStartIndex = i;
- var helperContent = '';
- var elseContent = '';
- var toSkip = 0;
- var shiftIndex;
- var foundClosed = false, foundElse = false, foundClosedElse = false, depth = 0;
- for (j = i + 1; j < _blocks.length; j++) {
- if (_blocks[j].indexOf('{{#') >= 0) {
- depth ++;
- }
- if (_blocks[j].indexOf('{{/') >= 0) {
- depth --;
- }
- if (_blocks[j].indexOf('{{#' + helperName) >= 0) {
- helperContent += _blocks[j];
- if (foundElse) elseContent += _blocks[j];
- toSkip ++;
- }
- else if (_blocks[j].indexOf('{{/' + helperName) >= 0) {
- if (toSkip > 0) {
- toSkip--;
- helperContent += _blocks[j];
- if (foundElse) elseContent += _blocks[j];
- }
- else {
- shiftIndex = j;
- foundClosed = true;
- break;
- }
- }
- else if (_blocks[j].indexOf('else') >= 0 && depth === 0) {
- foundElse = true;
- }
- else {
- if (!foundElse) helperContent += _blocks[j];
- if (foundElse) elseContent += _blocks[j];
- }
- }
- if (foundClosed) {
- if (shiftIndex) i = shiftIndex;
- blocks.push({
- type: 'helper',
- helperName: helperName,
- contextName: helperContext,
- content: helperContent,
- inverseContent: elseContent,
- hash: helperHash
- });
- }
- }
- else if (block.indexOf(' ') > 0) {
- blocks.push({
- type: 'helper',
- helperName: helperName,
- contextName: helperContext,
- hash: helperHash
- });
- }
- }
- }
- return blocks;
- }
- var Template7 = function (template) {
- var t = this;
- t.template = template;
- function getCompileFn(block, depth) {
- if (block.content) return compile(block.content, depth);
- else return function () {return ''; };
- }
- function getCompileInverse(block, depth) {
- if (block.inverseContent) return compile(block.inverseContent, depth);
- else return function () {return ''; };
- }
- function getCompileVar(name, ctx) {
- var variable, parts, levelsUp = 0, initialCtx = ctx;
- if (name.indexOf('../') === 0) {
- levelsUp = name.split('../').length - 1;
- var newDepth = ctx.split('_')[1] - levelsUp;
- ctx = 'ctx_' + (newDepth >= 1 ? newDepth : 1);
- parts = name.split('../')[levelsUp].split('.');
- }
- else if (name.indexOf('@global') === 0) {
- ctx = '$.Template7.global';
- parts = name.split('@global.')[1].split('.');
- }
- else if (name.indexOf('@root') === 0) {
- ctx = 'ctx_1';
- parts = name.split('@root.')[1].split('.');
- }
- else {
- parts = name.split('.');
- }
- variable = ctx;
- for (var i = 0; i < parts.length; i++) {
- var part = parts[i];
- if (part.indexOf('@') === 0) {
- if (i > 0) {
- variable += '[(data && data.' + part.replace('@', '') + ')]';
- }
- else {
- variable = '(data && data.' + name.replace('@', '') + ')';
- }
- }
- else {
- if (isFinite(part)) {
- variable += '[' + part + ']';
- }
- else {
- if (part.indexOf('this') === 0) {
- variable = part.replace('this', ctx);
- }
- else {
- variable += '.' + part;
- }
- }
- }
- }
- return variable;
- }
- function getCompiledArguments(contextArray, ctx) {
- var arr = [];
- for (var i = 0; i < contextArray.length; i++) {
- if (contextArray[i].indexOf('"') === 0) arr.push(contextArray[i]);
- else {
- arr.push(getCompileVar(contextArray[i], ctx));
- }
- }
- return arr.join(', ');
- }
- function compile(template, depth) {
- depth = depth || 1;
- template = template || t.template;
- if (typeof template !== 'string') {
- throw new Error('Template7: Template must be a string');
- }
- var blocks = stringToBlocks(template);
- if (blocks.length === 0) {
- return function () { return ''; };
- }
- var ctx = 'ctx_' + depth;
- var resultString = '(function (' + ctx + ', data) {\n';
- if (depth === 1) {
- resultString += 'function isArray(arr){return Object.prototype.toString.apply(arr) === \'[object Array]\';}\n';
- resultString += 'function isFunction(func){return (typeof func === \'function\');}\n';
- resultString += 'function c(val, ctx) {if (typeof val !== "undefined") {if (isFunction(val)) {return val.call(ctx);} else return val;} else return "";}\n';
- }
- resultString += 'var r = \'\';\n';
- var i, j, context;
- for (i = 0; i < blocks.length; i++) {
- var block = blocks[i];
- // Plain block
- if (block.type === 'plain') {
- resultString += 'r +=\'' + (block.content).replace(/\r/g, '\\r').replace(/\n/g, '\\n').replace(/'/g, '\\' + '\'') + '\';';
- continue;
- }
- var variable, compiledArguments;
- // Variable block
- if (block.type === 'variable') {
- variable = getCompileVar(block.contextName, ctx);
- resultString += 'r += c(' + variable + ', ' + ctx + ');';
- }
- // Helpers block
- if (block.type === 'helper') {
- if (block.helperName in t.helpers) {
- compiledArguments = getCompiledArguments(block.contextName, ctx);
- resultString += 'r += ($.Template7.helpers.' + block.helperName + ').call(' + ctx + ', ' + (compiledArguments && (compiledArguments + ', ')) +'{hash:' + JSON.stringify(block.hash) + ', data: data || {}, fn: ' + getCompileFn(block, depth+1) + ', inverse: ' + getCompileInverse(block, depth+1) + ', root: ctx_1});';
- }
- else {
- if (block.contextName.length > 0) {
- throw new Error('Template7: Missing helper: "' + block.helperName + '"');
- }
- else {
- variable = getCompileVar(block.helperName, ctx);
- resultString += 'if (' + variable + ') {';
- resultString += 'if (isArray(' + variable + ')) {';
- resultString += 'r += ($.Template7.helpers.each).call(' + ctx + ', ' + variable + ', {hash:' + JSON.stringify(block.hash) + ', data: data || {}, fn: ' + getCompileFn(block, depth+1) + ', inverse: ' + getCompileInverse(block, depth+1) + ', root: ctx_1});';
- resultString += '}else {';
- resultString += 'r += ($.Template7.helpers.with).call(' + ctx + ', ' + variable + ', {hash:' + JSON.stringify(block.hash) + ', data: data || {}, fn: ' + getCompileFn(block, depth+1) + ', inverse: ' + getCompileInverse(block, depth+1) + ', root: ctx_1});';
- resultString += '}}';
- }
- }
- }
- }
- resultString += '\nreturn r;})';
- return eval.call(window, resultString);
- }
- t.compile = function (template) {
- if (!t.compiled) {
- t.compiled = compile(template);
- }
- return t.compiled;
- };
- };
- Template7.prototype = {
- options: {},
- helpers: {
- 'if': function (context, options) {
- if (isFunction(context)) { context = context.call(this); }
- if (context) {
- return options.fn(this, options.data);
- }
- else {
- return options.inverse(this, options.data);
- }
- },
- 'unless': function (context, options) {
- if (isFunction(context)) { context = context.call(this); }
- if (!context) {
- return options.fn(this, options.data);
- }
- else {
- return options.inverse(this, options.data);
- }
- },
- 'each': function (context, options) {
- var ret = '', i = 0;
- if (isFunction(context)) { context = context.call(this); }
- if (isArray(context)) {
- if (options.hash.reverse) {
- context = context.reverse();
- }
- for (i = 0; i < context.length; i++) {
- ret += options.fn(context[i], {first: i === 0, last: i === context.length - 1, index: i});
- }
- if (options.hash.reverse) {
- context = context.reverse();
- }
- }
- else {
- for (var key in context) {
- i++;
- ret += options.fn(context[key], {key: key});
- }
- }
- if (i > 0) return ret;
- else return options.inverse(this);
- },
- 'with': function (context, options) {
- if (isFunction(context)) { context = context.call(this); }
- return options.fn(context);
- },
- 'join': function (context, options) {
- if (isFunction(context)) { context = context.call(this); }
- return context.join(options.hash.delimiter || options.hash.delimeter);
- },
- 'urlcode': function (context, options) {
- if (isFunction(context)) { context = context.call(this); }
- return options.hash.val == "encodeURIComponent" ? encodeURIComponent(context) : decodeURIComponent(context);
- },
- 'date': function (context, options) {
- if(!context) return "";
- context = isFunction(context) ? context.call(this) : new Date(context);
- options.hash.format = options.hash.format || "yyyy-MM-dd hh:mm:ss";
- var o = {
- "M+": context.getMonth() + 1,
- "d+": context.getDate(),
- "h+": context.getHours(),
- "m+": context.getMinutes(),
- "s+": context.getSeconds(),
- "q+": Math.floor((context.getMonth() + 3) / 3),
- "S": context.getMilliseconds()
- };
- if (/(y+)/.test(options.hash.format)) {
- options.hash.format = options.hash.format.replace(RegExp.$1, (context.getFullYear() + "").substr(4 - RegExp.$1.length));
- }
- for (var k in o) {
- if (new RegExp("(" + k + ")").test(options.hash.format)) {
- options.hash.format = options.hash.format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
- }
- }
- return options.hash.format;
- },
- 'js': function (expression, options) {
- var func;
- if (expression.indexOf('return')>=0) {
- func = '(function(){'+expression+'})';
- }
- else {
- func = '(function(){return ('+expression+')})';
- }
- return eval.call(this, func).call(this);
- },
- 'js_compare': function (expression, options) {
- var func;
- if (expression.indexOf('return')>=0) {
- func = '(function(){'+expression+'})';
- }
- else {
- func = '(function(){return ('+expression+')})';
- }
- var condition = eval.call(this, func).call(this);
- if (condition) {
- return options.fn(this, options.data);
- }
- else {
- return options.inverse(this, options.data);
- }
- },
- 'if_compare': function (str, expression, options) {
- var func;
- if (expression.indexOf('return')>=0) {
- str = "'"+str+"'";
- console.log(str);
- func = '(function(){'+str+expression+'})';
- }
- else {
- func = '(function(){return ('+str+expression+')})';
- }
- var condition = eval.call(this, func).call(this);
- if (condition) {
- return options.fn(this, options.data);
- }
- else {
- return options.inverse(this, options.data);
- }
- }
- }
- };
- var t7 = function (template, data) {
- if (arguments.length === 2) {
- var instance = new Template7(template);
- var rendered = instance.compile()(data);
- instance = null;
- return (rendered);
- }
- else return new Template7(template);
- };
- t7.registerHelper = function (name, fn) {
- Template7.prototype.helpers[name] = fn;
- };
- t7.unregisterHelper = function (name) {
- Template7.prototype.helpers[name] = undefined;
- delete Template7.prototype.helpers[name];
- };
- t7.compile = function (template, options) {
- var instance = new Template7(template, options);
- return instance.compile();
- };
- t7.templateData = {};
- t7.getTemplate = function(){
- var templateDoc = $('script[type="text/html"]');
- templateDoc.each(function(index, item){
- t7.templateData[$(this).attr("id")] = $(item).html();
- $(this).remove();
- });
- }
- t7.renderTpl = function(markup,renderData){
- this.getTemplate();
- if(!t7.templateData.hasOwnProperty(markup)) return false;
- var compiledTemplate = t7.compile(t7.templateData[markup]);
- return compiledTemplate(renderData);
- };
- t7.removeTpl = function(id){
- if(t7.templateData.hasOwnProperty(id))
- delete t7.templateData[id];
- }
-
- t7.options = Template7.prototype.options;
- t7.helpers = Template7.prototype.helpers;
- return t7;
- })();
- }($);
- //input用户输入提示
- jQuery.Autocompleter = function(input, options) {
- var KEY = {
- UP: 38,
- DOWN: 40,
- DEL: 46,
- TAB: 9,
- RETURN: 13,
- ESC: 27,
- COMMA: 188,
- PAGEUP: 33,
- PAGEDOWN: 34,
- BACKSPACE: 8
- };
- // Create $ object for input element
- var jQueryinput = jQuery(input).attr("autocomplete", "off").addClass(options.inputClass);
- var timeout;
- var previousValue = "";
- var cache = jQuery.Autocompleter.Cache(options);
- var hasFocus = 0;
- var lastKeyPressCode;
- var config = {
- mouseDownOnSelect: false
- };
- var select = jQuery.Autocompleter.Select(options, input, selectCurrent, config);
- var blockSubmit;
- // prevent form submit in opera when selecting with return key
- jQuery.browser.opera && jQuery(input.form).bind("submit.autocomplete", function() {
- if (blockSubmit) {
- blockSubmit = false;
- return false;
- }
- });
- // only opera doesn't trigger keydown multiple times while pressed, others don't work with keypress at all
- jQueryinput.bind((jQuery.browser.opera ? "keypress" : "keydown") + ".autocomplete", function(event) {
- // track last key pressed
- lastKeyPressCode = event.keyCode;
- switch (event.keyCode) {
- case KEY.UP:
- event.preventDefault();
- if (select.visible()) {
- select.prev();
- } else {
- onChange(0, true);
- }
- break;
- case KEY.DOWN:
- event.preventDefault();
- if (select.visible()) {
- select.next();
- } else {
- onChange(0, true);
- }
- break;
- case KEY.PAGEUP:
- event.preventDefault();
- if (select.visible()) {
- select.pageUp();
- } else {
- onChange(0, true);
- }
- break;
- case KEY.PAGEDOWN:
- event.preventDefault();
- if (select.visible()) {
- select.pageDown();
- } else {
- onChange(0, true);
- }
- break;
- // matches also semicolon
- case options.multiple && jQuery.trim(options.multipleSeparator) == "," && KEY.COMMA:
- case KEY.TAB:
- case KEY.RETURN:
- if (selectCurrent()) {
- // stop default to prevent a form submit, Opera needs special handling
- event.preventDefault();
- blockSubmit = true;
- return false;
- }
- break;
- case KEY.ESC:
- select.hide();
- break;
- default:
- clearTimeout(timeout);
- timeout = setTimeout(onChange, options.delay);
- break;
- }
- }).focus(function() {
- // track whether the field has focus, we shouldn't process any
- // results if the field no longer has focus
- hasFocus++;
- }).blur(function() {
- hasFocus = 0;
- if (!config.mouseDownOnSelect) {
- hideResults();
- }
- }).bind("search", function() {
- // TODO why not just specifying both arguments?
- var fn = (arguments.length > 1) ? arguments[1] : null;
- function findValueCallback(q, data) {
- var result;
- if (data && data.length) {
- for (var i = 0; i < data.length; i++) {
- if (data[i].result.toLowerCase() == q.toLowerCase()) {
- result = data[i];
- break;
- }
- }
- }
- if (typeof fn == "function") fn(result);
- else jQueryinput.trigger("result", result && [result.data, result.value]);
- }
- jQuery.each(trimWords(jQueryinput.val()), function(i, value) {
- request(value, findValueCallback, findValueCallback);
- });
- }).bind("flushCache", function() {
- cache.flush();
- }).bind("setOptions", function() {
- jQuery.extend(options, arguments[1]);
- // if we've updated the data, repopulate
- if ("data" in arguments[1]) cache.populate();
- }).bind("unautocomplete", function() {
- select.unbind();
- jQueryinput.unbind();
- jQuery(input.form).unbind(".autocomplete");
- }).bind("input", function() {
- onChange(0, true);
- });
- if(options.clickStatus){
- jQuery(jQueryinput.prev()).bind("click",function(){
- clearTimeout(timeout);
- timeout = setTimeout(function(){
- onChange(0, true);
- }, options.delay);
- });
- }
- function selectCurrent() {
- var selected = select.selected();
- if (!selected) return false;
- var v = selected.result;
- previousValue = v;
- if (options.multiple) {
- var words = trimWords(jQueryinput.val());
- if (words.length > 1) {
- v = words.slice(0, words.length - 1).join(options.multipleSeparator) + options.multipleSeparator + v;
- }
- v += options.multipleSeparator;
- }
- jQueryinput.val(v);
- hideResultsNow();
- jQueryinput.trigger("result", [selected.data, selected.value]);
- return true;
- }
- function onChange(crap, skipPrevCheck) {
- if (lastKeyPressCode == KEY.DEL) {
- select.hide();
- return;
- }
- var currentValue = jQueryinput.val();
- if (!skipPrevCheck && currentValue == previousValue) return;
- previousValue = currentValue;
- currentValue = lastWord(currentValue);
- if (currentValue.length >= options.minChars || options.clickStatus) {
- jQueryinput.addClass(options.loadingClass);
- if (!options.matchCase) currentValue = currentValue.toLowerCase();
- request(currentValue, receiveData, hideResultsNow);
- } else {
- stopLoading();
- select.hide();
- }
- };
- function trimWords(value) {
- if (!value) {
- return [""];
- }
- var words = value.split(options.multipleSeparator);
- var result = [];
- jQuery.each(words, function(i, value) {
- if (jQuery.trim(value)) result[i] = jQuery.trim(value);
- });
- return result;
- }
- function lastWord(value) {
- if (!options.multiple) return value;
- var words = trimWords(value);
- return words[words.length - 1];
- }
- // fills in the input box w/the first match (assumed to be the best match)
- // q: the term entered
- // sValue: the first matching result
- function autoFill(q, sValue) {
- // autofill in the complete box w/the first match as long as the user hasn't entered in more data
- // if the last user key pressed was backspace, don't autofill
- if (options.autoFill && (lastWord(jQueryinput.val()).toLowerCase() == q.toLowerCase()) && lastKeyPressCode != KEY.BACKSPACE) {
- // fill in the value (keep the case the user has typed)
- jQueryinput.val(jQueryinput.val() + sValue.substring(lastWord(previousValue).length));
- // select the portion of the value not typed by the user (so the next character will erase)
- jQuery.Autocompleter.Selection(input, previousValue.length, previousValue.length + sValue.length);
- }
- };
- function hideResults() {
- clearTimeout(timeout);
- timeout = setTimeout(hideResultsNow, 200);
- };
- function hideResultsNow() {
- var wasVisible = select.visible();
- select.hide();
- clearTimeout(timeout);
- stopLoading();
- if (options.mustMatch) {
- // call search and run callback
- jQueryinput.search(
- function(result) {
- // if no value found, clear the input box
- if (!result) {
- if (options.multiple) {
- var words = trimWords(jQueryinput.val()).slice(0, -1);
- jQueryinput.val(words.join(options.multipleSeparator) + (words.length ? options.multipleSeparator : ""));
- } else jQueryinput.val("");
- }
- });
- }
- if (wasVisible)
- // position cursor at end of input field
- jQuery.Autocompleter.Selection(input, input.value.length, input.value.length);
- };
- function receiveData(q, data) {
- if (data && data.length && hasFocus) {
- stopLoading();
- select.display(data, q);
- autoFill(q, data[0].value);
- select.show();
- } else {
- hideResultsNow();
- }
- };
- function request(term, success, failure) {
- if (!options.matchCase) term = term.toLowerCase();
- var data = cache.load(term);
- // recieve the cached data
- /*if (data && data.length) {
- success(term, data);
- cache.add(term, parsed);
- // if an AJAX url has been supplied, try loading the data now
- } else */if ((typeof options.url == "string") && (options.url.length > 0)) {
- var extraParams = {
- timestamp: +new Date()
- };
- jQuery.each(options.extraParams, function(key, param) {
- extraParams[key] = typeof param == "function" ? param() : param;
- });
- jQuery.ajax({
- // try to leverage ajaxQueue plugin to abort previous requests
- mode: "abort",
- // limit abortion to this input
- port: "autocomplete" + input.name,
- dataType: options.dataType,
- url: options.url,
- data: jQuery.extend({
- q: encodeURIComponent($.trim(term)),
- limit: options.max
- }, extraParams),
- success: function(data) {
- var parsed = options.parse && options.parse(data) || parse(data);
- cache.add(term, parsed);
- success(term, parsed);
- }
- });
- } else {
- // if we have a failure, we need to empty the list -- this prevents the the [TAB] key from selecting the last successful match
- select.emptyList();
- failure(term);
- }
- };
- function parse(data) {
- var parsed = [];
- var rows = eval('(' + data + ')');
- for (var i = 0; i < rows.length; i++) {
- var row = jQuery.trim(rows[i]);
- if (row) {
- row = row.split("|");
- parsed[parsed.length] = {
- data: row,
- value: row[0],
- result: options.formatResult && options.formatResult(row, row[0]) || row[0]
- };
- }
- }
- return parsed;
- };
- function stopLoading() {
- jQueryinput.removeClass(options.loadingClass);
- };
- };
- jQuery.Autocompleter.defaults = {
- inputClass: "ac_input",
- resultsClass: "ac_results",
- loadingClass: "ac_loading",
- minChars: 1,
- delay: 400,
- matchCase: false,
- matchSubset: true,
- matchContains: false,
- cacheLength: 10,
- max: 100,
- mustMatch: false,
- extraParams: {},
- selectFirst: true,
- formatItem: function(row) {
- return row[0];
- },
- formatMatch: null,
- autoFill: false,
- width: 0,
- multiple: false,
- multipleSeparator: ", ",
- highlight: function(value, term) {
- return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
- },
- scroll: true,
- scrollHeight: 180
- };
- jQuery.Autocompleter.Cache = function(options) {
- var data = {};
- var length = 0;
- function matchSubset(s, sub) {
- if (!options.matchCase) s = (s || "").toString().toLowerCase();
- var i = s.indexOf(sub);
- if (i == -1) return false;
- return i == 0 || options.matchContains;
- };
- function add(q, value) {
- if (length > options.cacheLength) {
- flush();
- }
- if (!data[q]) {
- length++;
- }
- data[q] = value;
- }
- function populate() {
- if (!options.data) return false;
- // track the matches
- var stMatchSets = {},
- nullData = 0;
- // no url was specified, we need to adjust the cache length to make sure it fits the local data store
- if (!options.url) options.cacheLength = 1;
- // track all options for minChars = 0
- stMatchSets[""] = [];
- // loop through the array and create a lookup structure
- for (var i = 0, ol = options.data.length; i < ol; i++) {
- var rawValue = options.data[i];
- // if rawValue is a string, make an array otherwise just reference the array
- rawValue = (typeof rawValue == "string") ? [rawValue] : rawValue;
- var value = options.formatMatch(rawValue, i + 1, options.data.length);
- if (value === false) continue;
- var firstChar = value.charAt(0).toLowerCase();
- // if no lookup array for this character exists, look it up now
- if (!stMatchSets[firstChar]) stMatchSets[firstChar] = [];
- // if the match is a string
- var row = {
- value: value,
- data: rawValue,
- result: options.formatResult && options.formatResult(rawValue) || value
- };
- // push the current match into the set list
- stMatchSets[firstChar].push(row);
- // keep track of minChars zero items
- if (nullData++ < options.max) {
- stMatchSets[""].push(row);
- }
- };
- // add the data items to the cache
- jQuery.each(stMatchSets, function(i, value) {
- // increase the cache size
- options.cacheLength++;
- // add to the cache
- add(i, value);
- });
- }
- // populate any existing data
- setTimeout(populate, 25);
- function flush() {
- data = {};
- length = 0;
- }
- return {
- flush: flush,
- add: add,
- populate: populate,
- load: function(q) {
- if (!options.cacheLength || !length) return null;
- /*
- * if dealing w/local data and matchContains than we must make sure
- * to loop through all the data collections looking for matches
- */
- if (!options.url && options.matchContains) {
- // track all matches
- var csub = [];
- // loop through all the data grids for matches
- for (var k in data) {
- // don't search through the stMatchSets[""] (minChars: 0) cache
- // this prevents duplicates
- if (k.length > 0) {
- var c = data[k];
- jQuery.each(c, function(i, x) {
- // if we've got a match, add it to the array
- if (matchSubset(x.value, q)) {
- csub.push(x);
- }
- });
- }
- }
- return csub;
- } else
- // if the exact item exists, use it
- if (data[q]) {
- return data[q];
- } else if (options.matchSubset) {
- for (var i = q.length - 1; i >= options.minChars; i--) {
- var c = data[q.substr(0, i)];
- if (c) {
- var csub = [];
- jQuery.each(c, function(i, x) {
- if (matchSubset(x.value, q)) {
- csub[csub.length] = x;
- }
- });
- return csub;
- }
- }
- }
- return null;
- }
- };
- };
- jQuery.Autocompleter.Select = function(options, input, select, config) {
- var CLASSES = {
- ACTIVE: "ac_over"
- };
- var listItems, active = -1,
- data, term = "",
- needsInit = true,
- element, list;
- // Create results
- function init() {
- if (!needsInit) return;
- element = jQuery("<div/>").hide().addClass(options.resultsClass).css("position", "absolute").appendTo(document.body);
- list = jQuery("<ul/>").appendTo(element).mouseover(function(event) {
- if (target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') {
- active = jQuery("li", list).removeClass(CLASSES.ACTIVE).index(target(event));
- jQuery(target(event)).addClass(CLASSES.ACTIVE);
- }
- }).click(function(event) {
- jQuery(target(event)).addClass(CLASSES.ACTIVE);
- select();
- // TODO provide option to avoid setting focus again after selection? useful for cleanup-on-focus
- input.focus();
- return false;
- }).mousedown(function() {
- config.mouseDownOnSelect = true;
- }).mouseup(function() {
- config.mouseDownOnSelect = false;
- });
- if (options.width > 0) element.css("width", options.width);
- needsInit = false;
- }
- function target(event) {
- var element = event.target;
- while (element && element.tagName != "LI")
- element = element.parentNode;
- // more fun with IE, sometimes event.target is empty, just ignore it then
- if (!element) return [];
- return element;
- }
- function moveSelect(step) {
- listItems.slice(active, active + 1).removeClass(CLASSES.ACTIVE);
- movePosition(step);
- var activeItem = listItems.slice(active, active + 1).addClass(CLASSES.ACTIVE);
- if (options.scroll) {
- var offset = 0;
- listItems.slice(0, active).each(function() {
- offset += this.offsetHeight;
- });
- if ((offset + activeItem[0].offsetHeight - list.scrollTop()) > list[0].clientHeight) {
- list.scrollTop(offset + activeItem[0].offsetHeight - list.innerHeight());
- } else if (offset < list.scrollTop()) {
- list.scrollTop(offset);
- }
- }
- };
- function movePosition(step) {
- active += step;
- if (active < 0) {
- active = listItems.size() - 1;
- } else if (active >= listItems.size()) {
- active = 0;
- }
- }
- function limitNumberOfItems(available) {
- return options.max && options.max < available ? options.max : available;
- }
- function fillList() {
- list.empty();
- var max = limitNumberOfItems(data.length);
- for (var i = 0; i < max; i++) {
- if (!data[i]) continue;
- var formatted = options.formatItem(data[i].data, i + 1, max, data[i].value, term);
- if (formatted === false) continue;
- var li = jQuery("<li/>").html(options.highlight(formatted, term)).addClass(i % 2 == 0 ? "ac_even" : "ac_odd").appendTo(list)[0];
- jQuery.data(li, "ac_data", data[i]);
- }
- listItems = list.find("li");
- if (options.selectFirst) {
- listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
- active = 0;
- }
- // apply bgiframe if available
- if (jQuery.fn.bgiframe) list.bgiframe();
- }
- return {
- display: function(d, q) {
- init();
- data = d;
- term = q;
- fillList();
- },
- next: function() {
- moveSelect(1);
- },
- prev: function() {
- moveSelect(-1);
- },
- pageUp: function() {
- if (active != 0 && active - 8 < 0) {
- moveSelect(-active);
- } else {
- moveSelect(-8);
- }
- },
- pageDown: function() {
- if (active != listItems.size() - 1 && active + 8 > listItems.size()) {
- moveSelect(listItems.size() - 1 - active);
- } else {
- moveSelect(8);
- }
- },
- hide: function() {
- element && element.hide();
- listItems && listItems.removeClass(CLASSES.ACTIVE);
- active = -1;
- },
- visible: function() {
- return element && element.is(":visible");
- },
- current: function() {
- return this.visible() && (listItems.filter("." + CLASSES.ACTIVE)[0] || options.selectFirst && listItems[0]);
- },
- show: function() {
- var offset = jQuery(input).offset();
- element.css({
- width: typeof options.width == "string" || options.width > 0 ? options.width : jQuery(input).width(),
- top: offset.top + input.offsetHeight,
- left: offset.left
- }).show();
- if (options.scroll) {
- list.scrollTop(0);
- list.css({
- maxHeight: options.scrollHeight,
- overflow: 'auto'
- });
- if (jQuery.browser.msie && typeof document.body.style.maxHeight === "undefined") {
- var listHeight = 0;
- listItems.each(function() {
- listHeight += this.offsetHeight;
- });
- var scrollbarsVisible = listHeight > options.scrollHeight;
- list.css('height', scrollbarsVisible ? options.scrollHeight : listHeight);
- if (!scrollbarsVisible) {
- // IE doesn't recalculate width when scrollbar disappears
- listItems.width(list.width() - parseInt(listItems.css("padding-left")) - parseInt(listItems.css("padding-right")));
- }
- }
- }
- },
- selected: function() {
- var selected = listItems && listItems.filter("." + CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);
- return selected && selected.length && jQuery.data(selected[0], "ac_data");
- },
- emptyList: function() {
- list && list.empty();
- },
- unbind: function() {
- element && element.remove();
- }
- };
- };
- jQuery.Autocompleter.Selection = function(field, start, end) {
- if (field.createTextRange) {
- var selRange = field.createTextRange();
- selRange.collapse(true);
- selRange.moveStart("character", start);
- selRange.moveEnd("character", end);
- selRange.select();
- } else if (field.setSelectionRange) {
- field.setSelectionRange(start, end);
- } else {
- if (field.selectionStart) {
- field.selectionStart = start;
- field.selectionEnd = end;
- }
- }
- field.focus();
- };
|