|
@@ -0,0 +1,7200 @@
|
|
|
+window.pinyin_dict_notone = {
|
|
|
+ a: "阿啊呵腌嗄吖锕",
|
|
|
+ e: "额阿俄恶鹅遏鄂厄饿峨扼娥鳄哦蛾噩愕讹锷垩婀鹗萼谔莪腭锇颚呃阏屙苊轭",
|
|
|
+ ai: "爱埃艾碍癌哀挨矮隘蔼唉皑哎霭捱暧嫒嗳瑷嗌锿砹",
|
|
|
+ ei: "诶",
|
|
|
+ xi: "系西席息希习吸喜细析戏洗悉锡溪惜稀袭夕洒晰昔牺腊烯熙媳栖膝隙犀蹊硒兮熄曦禧嬉玺奚汐徙羲铣淅嘻歙熹矽蟋郗唏皙隰樨浠忾蜥檄郄翕阋鳃舾屣葸螅咭粞觋欷僖醯鼷裼穸饩舄禊诶菥蓰",
|
|
|
+ yi: "一以已意议义益亿易医艺食依移衣异伊仪宜射遗疑毅谊亦疫役忆抑尾乙译翼蛇溢椅沂泄逸蚁夷邑怡绎彝裔姨熠贻矣屹颐倚诣胰奕翌疙弈轶蛾驿壹猗臆弋铱旖漪迤佚翊诒怿痍懿饴峄揖眙镒仡黟肄咿翳挹缢呓刈咦嶷羿钇殪荑薏蜴镱噫癔苡悒嗌瘗衤佾埸圯舣酏劓",
|
|
|
+ an: "安案按岸暗鞍氨俺胺铵谙庵黯鹌桉埯犴揞厂广",
|
|
|
+ han: "厂汉韩含旱寒汗涵函喊憾罕焊翰邯撼瀚憨捍酣悍鼾邗颔蚶晗菡旰顸犴焓撖",
|
|
|
+ ang: "昂仰盎肮",
|
|
|
+ ao: "奥澳傲熬凹鳌敖遨鏖袄坳翱嗷拗懊岙螯骜獒鏊艹媪廒聱",
|
|
|
+ wa: "瓦挖娃洼袜蛙凹哇佤娲呙腽",
|
|
|
+ yu: "于与育余预域予遇奥语誉玉鱼雨渔裕愈娱欲吁舆宇羽逾豫郁寓吾狱喻御浴愉禹俞邪榆愚渝尉淤虞屿峪粥驭瑜禺毓钰隅芋熨瘀迂煜昱汩於臾盂聿竽萸妪腴圄谕觎揄龉谀俣馀庾妤瘐鬻欤鹬阈嵛雩鹆圉蜮伛纡窬窳饫蓣狳肀舁蝓燠",
|
|
|
+ niu: "牛纽扭钮拗妞忸狃",
|
|
|
+ o: "哦噢喔",
|
|
|
+ ba: "把八巴拔伯吧坝爸霸罢芭跋扒叭靶疤笆耙鲅粑岜灞钯捌菝魃茇",
|
|
|
+ pa: "怕帕爬扒趴琶啪葩耙杷钯筢",
|
|
|
+ pi: "被批副否皮坏辟啤匹披疲罢僻毗坯脾譬劈媲屁琵邳裨痞癖陂丕枇噼霹吡纰砒铍淠郫埤濞睥芘蚍圮鼙罴蜱疋貔仳庀擗甓陴",
|
|
|
+ bi: "比必币笔毕秘避闭佛辟壁弊彼逼碧鼻臂蔽拂泌璧庇痹毙弼匕鄙陛裨贲敝蓖吡篦纰俾铋毖筚荸薜婢哔跸濞秕荜愎睥妣芘箅髀畀滗狴萆嬖襞舭",
|
|
|
+ bai: "百白败摆伯拜柏佰掰呗擘捭稗",
|
|
|
+ bo: "波博播勃拨薄佛伯玻搏柏泊舶剥渤卜驳簿脖膊簸菠礴箔铂亳钵帛擘饽跛钹趵檗啵鹁擗踣",
|
|
|
+ bei: "北被备倍背杯勃贝辈悲碑臂卑悖惫蓓陂钡狈呗焙碚褙庳鞴孛鹎邶鐾",
|
|
|
+ ban: "办版半班般板颁伴搬斑扮拌扳瓣坂阪绊钣瘢舨癍",
|
|
|
+ pan: "判盘番潘攀盼拚畔胖叛拌蹒磐爿蟠泮袢襻丬",
|
|
|
+ bin: "份宾频滨斌彬濒殡缤鬓槟摈膑玢镔豳髌傧",
|
|
|
+ bang: "帮邦彭旁榜棒膀镑绑傍磅蚌谤梆浜蒡",
|
|
|
+ pang: "旁庞乓磅螃彷滂逄耪",
|
|
|
+ beng: "泵崩蚌蹦迸绷甭嘣甏堋",
|
|
|
+ bao: "报保包宝暴胞薄爆炮饱抱堡剥鲍曝葆瀑豹刨褒雹孢苞煲褓趵鸨龅勹",
|
|
|
+ bu: "不部步布补捕堡埔卜埠簿哺怖钚卟瓿逋晡醭钸",
|
|
|
+ pu: "普暴铺浦朴堡葡谱埔扑仆蒲曝瀑溥莆圃璞濮菩蹼匍噗氆攵镨攴镤",
|
|
|
+ mian: "面棉免绵缅勉眠冕娩腼渑湎沔黾宀眄",
|
|
|
+ po: "破繁坡迫颇朴泊婆泼魄粕鄱珀陂叵笸泺皤钋钷",
|
|
|
+ fan: "反范犯繁饭泛翻凡返番贩烦拚帆樊藩矾梵蕃钒幡畈蘩蹯燔",
|
|
|
+ fu: "府服副负富复福夫妇幅付扶父符附腐赴佛浮覆辅傅伏抚赋辐腹弗肤阜袱缚甫氟斧孚敷俯拂俘咐腑孵芙涪釜脯茯馥宓绂讣呋罘麸蝠匐芾蜉跗凫滏蝮驸绋蚨砩桴赙菔呒趺苻拊阝鲋怫稃郛莩幞祓艴黻黼鳆",
|
|
|
+ ben: "本体奔苯笨夯贲锛畚坌",
|
|
|
+ feng: "风丰封峰奉凤锋冯逢缝蜂枫疯讽烽俸沣酆砜葑唪",
|
|
|
+ bian: "变便边编遍辩鞭辨贬匾扁卞汴辫砭苄蝙鳊弁窆笾煸褊碥忭缏",
|
|
|
+ pian: "便片篇偏骗翩扁骈胼蹁谝犏缏",
|
|
|
+ zhen: "镇真针圳振震珍阵诊填侦臻贞枕桢赈祯帧甄斟缜箴疹砧榛鸩轸稹溱蓁胗椹朕畛浈",
|
|
|
+ biao: "表标彪镖裱飚膘飙镳婊骠飑杓髟鳔灬瘭",
|
|
|
+ piao: "票朴漂飘嫖瓢剽缥殍瞟骠嘌莩螵",
|
|
|
+ huo: "和活或货获火伙惑霍祸豁嚯藿锪蠖钬耠镬夥灬劐攉",
|
|
|
+ bie: "别鳖憋瘪蹩",
|
|
|
+ min: "民敏闽闵皿泯岷悯珉抿黾缗玟愍苠鳘",
|
|
|
+ fen: "分份纷奋粉氛芬愤粪坟汾焚酚吩忿棼玢鼢瀵偾鲼",
|
|
|
+ bing: "并病兵冰屏饼炳秉丙摒柄槟禀枋邴冫",
|
|
|
+ geng: "更耕颈庚耿梗埂羹哽赓绠鲠",
|
|
|
+ fang: "方放房防访纺芳仿坊妨肪邡舫彷枋鲂匚钫",
|
|
|
+ xian: "现先县见线限显险献鲜洗宪纤陷闲贤仙衔掀咸嫌掺羡弦腺痫娴舷馅酰铣冼涎暹籼锨苋蚬跹岘藓燹鹇氙莶霰跣猃彡祆筅",
|
|
|
+ fou: "不否缶",
|
|
|
+ ca: "拆擦嚓礤",
|
|
|
+ cha: "查察差茶插叉刹茬楂岔诧碴嚓喳姹杈汊衩搽槎镲苴檫馇锸猹",
|
|
|
+ cai: "才采财材菜彩裁蔡猜踩睬",
|
|
|
+ can: "参残餐灿惨蚕掺璨惭粲孱骖黪",
|
|
|
+ shen: "信深参身神什审申甚沈伸慎渗肾绅莘呻婶娠砷蜃哂椹葚吲糁渖诜谂矧胂",
|
|
|
+ cen: "参岑涔",
|
|
|
+ san: "三参散伞叁糁馓毵",
|
|
|
+ cang: "藏仓苍沧舱臧伧",
|
|
|
+ zang: "藏脏葬赃臧奘驵",
|
|
|
+ chen: "称陈沈沉晨琛臣尘辰衬趁忱郴宸谌碜嗔抻榇伧谶龀肜",
|
|
|
+ cao: "草操曹槽糙嘈漕螬艚屮",
|
|
|
+ ce: "策测册侧厕栅恻",
|
|
|
+ ze: "责则泽择侧咋啧仄箦赜笮舴昃迮帻",
|
|
|
+ zhai: "债择齐宅寨侧摘窄斋祭翟砦瘵哜",
|
|
|
+ dao: "到道导岛倒刀盗稻蹈悼捣叨祷焘氘纛刂帱忉",
|
|
|
+ ceng: "层曾蹭噌",
|
|
|
+ zha: "查扎炸诈闸渣咋乍榨楂札栅眨咤柞喳喋铡蚱吒怍砟揸痄哳齄",
|
|
|
+ chai: "差拆柴钗豺侪虿瘥",
|
|
|
+ ci: "次此差词辞刺瓷磁兹慈茨赐祠伺雌疵鹚糍呲粢",
|
|
|
+ zi: "资自子字齐咨滋仔姿紫兹孜淄籽梓鲻渍姊吱秭恣甾孳訾滓锱辎趑龇赀眦缁呲笫谘嵫髭茈粢觜耔",
|
|
|
+ cuo: "措错磋挫搓撮蹉锉厝嵯痤矬瘥脞鹾",
|
|
|
+ chan: "产单阐崭缠掺禅颤铲蝉搀潺蟾馋忏婵孱觇廛谄谗澶骣羼躔蒇冁",
|
|
|
+ shan: "山单善陕闪衫擅汕扇掺珊禅删膳缮赡鄯栅煽姗跚鳝嬗潸讪舢苫疝掸膻钐剡蟮芟埏彡骟",
|
|
|
+ zhan: "展战占站崭粘湛沾瞻颤詹斩盏辗绽毡栈蘸旃谵搌",
|
|
|
+ xin: "新心信辛欣薪馨鑫芯锌忻莘昕衅歆囟忄镡",
|
|
|
+ lian: "联连练廉炼脸莲恋链帘怜涟敛琏镰濂楝鲢殓潋裢裣臁奁莶蠊蔹",
|
|
|
+ chang: "场长厂常偿昌唱畅倡尝肠敞倘猖娼淌裳徜昶怅嫦菖鲳阊伥苌氅惝鬯",
|
|
|
+ zhang: "长张章障涨掌帐胀彰丈仗漳樟账杖璋嶂仉瘴蟑獐幛鄣嫜",
|
|
|
+ chao: "超朝潮炒钞抄巢吵剿绰嘲晁焯耖怊",
|
|
|
+ zhao: "着照招找召朝赵兆昭肇罩钊沼嘲爪诏濯啁棹笊",
|
|
|
+ zhou: "调州周洲舟骤轴昼宙粥皱肘咒帚胄绉纣妯啁诌繇碡籀酎荮",
|
|
|
+ che: "车彻撤尺扯澈掣坼砗屮",
|
|
|
+ ju: "车局据具举且居剧巨聚渠距句拒俱柜菊拘炬桔惧矩鞠驹锯踞咀瞿枸掬沮莒橘飓疽钜趄踽遽琚龃椐苣裾榘狙倨榉苴讵雎锔窭鞫犋屦醵",
|
|
|
+ cheng: "成程城承称盛抢乘诚呈净惩撑澄秤橙骋逞瞠丞晟铛埕塍蛏柽铖酲裎枨",
|
|
|
+ rong: "容荣融绒溶蓉熔戎榕茸冗嵘肜狨蝾",
|
|
|
+ sheng: "生声升胜盛乘圣剩牲甸省绳笙甥嵊晟渑眚",
|
|
|
+ deng: "等登邓灯澄凳瞪蹬噔磴嶝镫簦戥",
|
|
|
+ zhi: "制之治质职只志至指织支值知识直致执置止植纸拓智殖秩旨址滞氏枝芝脂帜汁肢挚稚酯掷峙炙栉侄芷窒咫吱趾痔蜘郅桎雉祉郦陟痣蛭帙枳踯徵胝栀贽祗豸鸷摭轵卮轾彘觯絷跖埴夂黹忮骘膣踬",
|
|
|
+ zheng: "政正证争整征郑丁症挣蒸睁铮筝拯峥怔诤狰徵钲",
|
|
|
+ tang: "堂唐糖汤塘躺趟倘棠烫淌膛搪镗傥螳溏帑羰樘醣螗耥铴瑭",
|
|
|
+ chi: "持吃池迟赤驰尺斥齿翅匙痴耻炽侈弛叱啻坻眙嗤墀哧茌豉敕笞饬踟蚩柢媸魑篪褫彳鸱螭瘛眵傺",
|
|
|
+ shi: "是时实事市十使世施式势视识师史示石食始士失适试什泽室似诗饰殖释驶氏硕逝湿蚀狮誓拾尸匙仕柿矢峙侍噬嗜栅拭嘘屎恃轼虱耆舐莳铈谥炻豕鲥饣螫酾筮埘弑礻蓍鲺贳",
|
|
|
+ qi: "企其起期气七器汽奇齐启旗棋妻弃揭枝歧欺骑契迄亟漆戚岂稽岐琦栖缉琪泣乞砌祁崎绮祺祈凄淇杞脐麒圻憩芪伎俟畦耆葺沏萋骐鳍綦讫蕲屺颀亓碛柒啐汔綮萁嘁蛴槭欹芑桤丌蜞",
|
|
|
+ chuai: "揣踹啜搋膪",
|
|
|
+ tuo: "托脱拓拖妥驼陀沱鸵驮唾椭坨佗砣跎庹柁橐乇铊沲酡鼍箨柝",
|
|
|
+ duo: "多度夺朵躲铎隋咄堕舵垛惰哆踱跺掇剁柁缍沲裰哚隳",
|
|
|
+ xue: "学血雪削薛穴靴谑噱鳕踅泶彐",
|
|
|
+ chong: "重种充冲涌崇虫宠忡憧舂茺铳艟",
|
|
|
+ chou: "筹抽绸酬愁丑臭仇畴稠瞅踌惆俦瘳雠帱",
|
|
|
+ qiu: "求球秋丘邱仇酋裘龟囚遒鳅虬蚯泅楸湫犰逑巯艽俅蝤赇鼽糗",
|
|
|
+ xiu: "修秀休宿袖绣臭朽锈羞嗅岫溴庥馐咻髹鸺貅",
|
|
|
+ chu: "出处础初助除储畜触楚厨雏矗橱锄滁躇怵绌搐刍蜍黜杵蹰亍樗憷楮",
|
|
|
+ tuan: "团揣湍疃抟彖",
|
|
|
+ zhui: "追坠缀揣椎锥赘惴隹骓缒",
|
|
|
+ chuan: "传川船穿串喘椽舛钏遄氚巛舡",
|
|
|
+ zhuan: "专转传赚砖撰篆馔啭颛",
|
|
|
+ yuan: "元员院原源远愿园援圆缘袁怨渊苑宛冤媛猿垣沅塬垸鸳辕鸢瑗圜爰芫鼋橼螈眢箢掾",
|
|
|
+ cuan: "窜攒篡蹿撺爨汆镩",
|
|
|
+ chuang: "创床窗闯幢疮怆",
|
|
|
+ zhuang: "装状庄壮撞妆幢桩奘僮戆",
|
|
|
+ chui: "吹垂锤炊椎陲槌捶棰",
|
|
|
+ chun: "春纯醇淳唇椿蠢鹑朐莼肫蝽",
|
|
|
+ zhun: "准屯淳谆肫窀",
|
|
|
+ cu: "促趋趣粗簇醋卒蹴猝蹙蔟殂徂",
|
|
|
+ dun: "吨顿盾敦蹲墩囤沌钝炖盹遁趸砘礅",
|
|
|
+ qu: "区去取曲趋渠趣驱屈躯衢娶祛瞿岖龋觑朐蛐癯蛆苣阒诎劬蕖蘧氍黢蠼璩麴鸲磲",
|
|
|
+ xu: "需许续须序徐休蓄畜虚吁绪叙旭邪恤墟栩絮圩婿戌胥嘘浒煦酗诩朐盱蓿溆洫顼勖糈砉醑",
|
|
|
+ chuo: "辍绰戳淖啜龊踔辶",
|
|
|
+ zu: "组族足祖租阻卒俎诅镞菹",
|
|
|
+ ji: "济机其技基记计系期际及集级几给积极己纪即继击既激绩急奇吉季齐疾迹鸡剂辑籍寄挤圾冀亟寂暨脊跻肌稽忌饥祭缉棘矶汲畸姬藉瘠骥羁妓讥稷蓟悸嫉岌叽伎鲫诘楫荠戟箕霁嵇觊麂畿玑笈犄芨唧屐髻戢佶偈笄跽蒺乩咭赍嵴虮掎齑殛鲚剞洎丌墼蕺彐芰哜",
|
|
|
+ cong: "从丛匆聪葱囱琮淙枞骢苁璁",
|
|
|
+ zong: "总从综宗纵踪棕粽鬃偬枞腙",
|
|
|
+ cou: "凑辏腠楱",
|
|
|
+ cui: "衰催崔脆翠萃粹摧璀瘁悴淬啐隹毳榱",
|
|
|
+ wei: "为位委未维卫围违威伟危味微唯谓伪慰尾魏韦胃畏帷喂巍萎蔚纬潍尉渭惟薇苇炜圩娓诿玮崴桅偎逶倭猥囗葳隗痿猬涠嵬韪煨艉隹帏闱洧沩隈鲔軎",
|
|
|
+ cun: "村存寸忖皴",
|
|
|
+ zuo: "作做座左坐昨佐琢撮祚柞唑嘬酢怍笮阼胙",
|
|
|
+ zuan: "钻纂攥缵躜",
|
|
|
+ da: "大达打答搭沓瘩惮嗒哒耷鞑靼褡笪怛妲",
|
|
|
+ dai: "大代带待贷毒戴袋歹呆隶逮岱傣棣怠殆黛甙埭诒绐玳呔迨",
|
|
|
+ tai: "大台太态泰抬胎汰钛苔薹肽跆邰鲐酞骀炱",
|
|
|
+ ta: "他它她拓塔踏塌榻沓漯獭嗒挞蹋趿遢铊鳎溻闼",
|
|
|
+ dan: "但单石担丹胆旦弹蛋淡诞氮郸耽殚惮儋眈疸澹掸膻啖箪聃萏瘅赕",
|
|
|
+ lu: "路六陆录绿露鲁卢炉鹿禄赂芦庐碌麓颅泸卤潞鹭辘虏璐漉噜戮鲈掳橹轳逯渌蓼撸鸬栌氇胪镥簏舻辂垆",
|
|
|
+ tan: "谈探坦摊弹炭坛滩贪叹谭潭碳毯瘫檀痰袒坍覃忐昙郯澹钽锬",
|
|
|
+ ren: "人任认仁忍韧刃纫饪妊荏稔壬仞轫亻衽",
|
|
|
+ jie: "家结解价界接节她届介阶街借杰洁截姐揭捷劫戒皆竭桔诫楷秸睫藉拮芥诘碣嗟颉蚧孑婕疖桀讦疥偈羯袷哜喈卩鲒骱",
|
|
|
+ yan: "研严验演言眼烟沿延盐炎燕岩宴艳颜殷彦掩淹阎衍铅雁咽厌焰堰砚唁焉晏檐蜒奄俨腌妍谚兖筵焱偃闫嫣鄢湮赝胭琰滟阉魇酽郾恹崦芫剡鼹菸餍埏谳讠厣罨",
|
|
|
+ dang: "当党档荡挡宕砀铛裆凼菪谠",
|
|
|
+ tao: "套讨跳陶涛逃桃萄淘掏滔韬叨洮啕绦饕鼗",
|
|
|
+ tiao: "条调挑跳迢眺苕窕笤佻啁粜髫铫祧龆蜩鲦",
|
|
|
+ te: "特忑忒铽慝",
|
|
|
+ de: "的地得德底锝",
|
|
|
+ dei: "得",
|
|
|
+ di: "的地第提低底抵弟迪递帝敌堤蒂缔滴涤翟娣笛棣荻谛狄邸嘀砥坻诋嫡镝碲骶氐柢籴羝睇觌",
|
|
|
+ ti: "体提题弟替梯踢惕剔蹄棣啼屉剃涕锑倜悌逖嚏荑醍绨鹈缇裼",
|
|
|
+ tui: "推退弟腿褪颓蜕忒煺",
|
|
|
+ you: "有由又优游油友右邮尤忧幼犹诱悠幽佑釉柚铀鱿囿酉攸黝莠猷蝣疣呦蚴莸莜铕宥繇卣牖鼬尢蚰侑",
|
|
|
+ dian: "电点店典奠甸碘淀殿垫颠滇癫巅惦掂癜玷佃踮靛钿簟坫阽",
|
|
|
+ tian: "天田添填甜甸恬腆佃舔钿阗忝殄畋栝掭",
|
|
|
+ zhu: "主术住注助属逐宁著筑驻朱珠祝猪诸柱竹铸株瞩嘱贮煮烛苎褚蛛拄铢洙竺蛀渚伫杼侏澍诛茱箸炷躅翥潴邾槠舳橥丶瘃麈疰",
|
|
|
+ nian: "年念酿辗碾廿捻撵拈蔫鲶埝鲇辇黏",
|
|
|
+ diao: "调掉雕吊钓刁貂凋碉鲷叼铫铞",
|
|
|
+ yao: "要么约药邀摇耀腰遥姚窑瑶咬尧钥谣肴夭侥吆疟妖幺杳舀窕窈曜鹞爻繇徭轺铫鳐崾珧",
|
|
|
+ die: "跌叠蝶迭碟爹谍牒耋佚喋堞瓞鲽垤揲蹀",
|
|
|
+ she: "设社摄涉射折舍蛇拾舌奢慑赦赊佘麝歙畲厍猞揲滠",
|
|
|
+ ye: "业也夜叶射野液冶喝页爷耶邪咽椰烨掖拽曳晔谒腋噎揶靥邺铘揲",
|
|
|
+ xie: "些解协写血叶谢械鞋胁斜携懈契卸谐泄蟹邪歇泻屑挟燮榭蝎撷偕亵楔颉缬邂鲑瀣勰榍薤绁渫廨獬躞",
|
|
|
+ zhe: "这者着著浙折哲蔗遮辙辄柘锗褶蜇蛰鹧谪赭摺乇磔螫",
|
|
|
+ ding: "定订顶丁鼎盯钉锭叮仃铤町酊啶碇腚疔玎耵",
|
|
|
+ diu: "丢铥",
|
|
|
+ ting: "听庭停厅廷挺亭艇婷汀铤烃霆町蜓葶梃莛",
|
|
|
+ dong: "动东董冬洞懂冻栋侗咚峒氡恫胴硐垌鸫岽胨",
|
|
|
+ tong: "同通统童痛铜桶桐筒彤侗佟潼捅酮砼瞳恸峒仝嗵僮垌茼",
|
|
|
+ zhong: "中重种众终钟忠仲衷肿踵冢盅蚣忪锺舯螽夂",
|
|
|
+ dou: "都斗读豆抖兜陡逗窦渎蚪痘蔸钭篼",
|
|
|
+ du: "度都独督读毒渡杜堵赌睹肚镀渎笃竺嘟犊妒牍蠹椟黩芏髑",
|
|
|
+ duan: "断段短端锻缎煅椴簖",
|
|
|
+ dui: "对队追敦兑堆碓镦怼憝",
|
|
|
+ rui: "瑞兑锐睿芮蕊蕤蚋枘",
|
|
|
+ yue: "月说约越乐跃兑阅岳粤悦曰钥栎钺樾瀹龠哕刖",
|
|
|
+ tun: "吞屯囤褪豚臀饨暾氽",
|
|
|
+ hui: "会回挥汇惠辉恢徽绘毁慧灰贿卉悔秽溃荟晖彗讳诲珲堕诙蕙晦睢麾烩茴喙桧蛔洄浍虺恚蟪咴隳缋哕",
|
|
|
+ wu: "务物无五武午吴舞伍污乌误亡恶屋晤悟吾雾芜梧勿巫侮坞毋诬呜钨邬捂鹜兀婺妩於戊鹉浯蜈唔骛仵焐芴鋈庑鼯牾怃圬忤痦迕杌寤阢",
|
|
|
+ ya: "亚压雅牙押鸭呀轧涯崖邪芽哑讶鸦娅衙丫蚜碣垭伢氩桠琊揠吖睚痖疋迓岈砑",
|
|
|
+ he: "和合河何核盖贺喝赫荷盒鹤吓呵苛禾菏壑褐涸阂阖劾诃颌嗬貉曷翮纥盍",
|
|
|
+ wo: "我握窝沃卧挝涡斡渥幄蜗喔倭莴龌肟硪",
|
|
|
+ en: "恩摁蒽",
|
|
|
+ n: "嗯唔",
|
|
|
+ er: "而二尔儿耳迩饵洱贰铒珥佴鸸鲕",
|
|
|
+ fa: "发法罚乏伐阀筏砝垡珐",
|
|
|
+ quan: "全权券泉圈拳劝犬铨痊诠荃醛蜷颧绻犭筌鬈悛辁畎",
|
|
|
+ fei: "费非飞肥废菲肺啡沸匪斐蜚妃诽扉翡霏吠绯腓痱芾淝悱狒榧砩鲱篚镄",
|
|
|
+ pei: "配培坏赔佩陪沛裴胚妃霈淠旆帔呸醅辔锫",
|
|
|
+ ping: "平评凭瓶冯屏萍苹乒坪枰娉俜鲆",
|
|
|
+ fo: "佛",
|
|
|
+ hu: "和护许户核湖互乎呼胡戏忽虎沪糊壶葫狐蝴弧瑚浒鹄琥扈唬滹惚祜囫斛笏芴醐猢怙唿戽槲觳煳鹕冱瓠虍岵鹱烀轷",
|
|
|
+ ga: "夹咖嘎尬噶旮伽尕钆尜",
|
|
|
+ ge: "个合各革格歌哥盖隔割阁戈葛鸽搁胳舸疙铬骼蛤咯圪镉颌仡硌嗝鬲膈纥袼搿塥哿虼",
|
|
|
+ ha: "哈蛤铪",
|
|
|
+ xia: "下夏峡厦辖霞夹虾狭吓侠暇遐瞎匣瑕唬呷黠硖罅狎瘕柙",
|
|
|
+ gai: "改该盖概溉钙丐芥赅垓陔戤",
|
|
|
+ hai: "海还害孩亥咳骸骇氦嗨胲醢",
|
|
|
+ gan: "干感赶敢甘肝杆赣乾柑尴竿秆橄矸淦苷擀酐绀泔坩旰疳澉",
|
|
|
+ gang: "港钢刚岗纲冈杠缸扛肛罡戆筻",
|
|
|
+ jiang: "将江港奖讲降疆蒋姜浆匠酱僵桨绛缰犟豇礓洚茳糨耩",
|
|
|
+ hang: "行航杭巷夯吭桁沆绗颃",
|
|
|
+ gong: "工公共供功红贡攻宫巩龚恭拱躬弓汞蚣珙觥肱廾",
|
|
|
+ hong: "红宏洪轰虹鸿弘哄烘泓訇蕻闳讧荭黉薨",
|
|
|
+ guang: "广光逛潢犷胱咣桄",
|
|
|
+ qiong: "穷琼穹邛茕筇跫蛩銎",
|
|
|
+ gao: "高告搞稿膏糕镐皋羔锆杲郜睾诰藁篙缟槁槔",
|
|
|
+ hao: "好号毫豪耗浩郝皓昊皋蒿壕灏嚎濠蚝貉颢嗥薅嚆",
|
|
|
+ li: "理力利立里李历例离励礼丽黎璃厉厘粒莉梨隶栗荔沥犁漓哩狸藜罹篱鲤砺吏澧俐骊溧砾莅锂笠蠡蛎痢雳俪傈醴栎郦俚枥喱逦娌鹂戾砬唳坜疠蜊黧猁鬲粝蓠呖跞疬缡鲡鳢嫠詈悝苈篥轹",
|
|
|
+ jia: "家加价假佳架甲嘉贾驾嫁夹稼钾挟拮迦伽颊浃枷戛荚痂颉镓笳珈岬胛袈郏葭袷瘕铗跏蛱恝哿",
|
|
|
+ luo: "落罗络洛逻螺锣骆萝裸漯烙摞骡咯箩珞捋荦硌雒椤镙跞瘰泺脶猡倮蠃",
|
|
|
+ ke: "可科克客刻课颗渴壳柯棵呵坷恪苛咳磕珂稞瞌溘轲窠嗑疴蝌岢铪颏髁蚵缂氪骒钶锞",
|
|
|
+ qia: "卡恰洽掐髂袷咭葜",
|
|
|
+ gei: "给",
|
|
|
+ gen: "根跟亘艮哏茛",
|
|
|
+ hen: "很狠恨痕哏",
|
|
|
+ gou: "构购够句沟狗钩拘勾苟垢枸篝佝媾诟岣彀缑笱鞲觏遘",
|
|
|
+ kou: "口扣寇叩抠佝蔻芤眍筘",
|
|
|
+ gu: "股古顾故固鼓骨估谷贾姑孤雇辜菇沽咕呱锢钴箍汩梏痼崮轱鸪牯蛊诂毂鹘菰罟嘏臌觚瞽蛄酤牿鲴",
|
|
|
+ pai: "牌排派拍迫徘湃俳哌蒎",
|
|
|
+ gua: "括挂瓜刮寡卦呱褂剐胍诖鸹栝呙",
|
|
|
+ tou: "投头透偷愉骰亠",
|
|
|
+ guai: "怪拐乖",
|
|
|
+ kuai: "会快块筷脍蒯侩浍郐蒉狯哙",
|
|
|
+ guan: "关管观馆官贯冠惯灌罐莞纶棺斡矜倌鹳鳏盥掼涫",
|
|
|
+ wan: "万完晚湾玩碗顽挽弯蔓丸莞皖宛婉腕蜿惋烷琬畹豌剜纨绾脘菀芄箢",
|
|
|
+ ne: "呢哪呐讷疒",
|
|
|
+ gui: "规贵归轨桂柜圭鬼硅瑰跪龟匮闺诡癸鳜桧皈鲑刽晷傀眭妫炅庋簋刿宄匦",
|
|
|
+ jun: "军均俊君峻菌竣钧骏龟浚隽郡筠皲麇捃",
|
|
|
+ jiong: "窘炯迥炅冂扃",
|
|
|
+ jue: "决绝角觉掘崛诀獗抉爵嚼倔厥蕨攫珏矍蹶谲镢鳜噱桷噘撅橛孓觖劂爝",
|
|
|
+ gun: "滚棍辊衮磙鲧绲丨",
|
|
|
+ hun: "婚混魂浑昏棍珲荤馄诨溷阍",
|
|
|
+ guo: "国过果郭锅裹帼涡椁囗蝈虢聒埚掴猓崞蜾呙馘",
|
|
|
+ hei: "黑嘿嗨",
|
|
|
+ kan: "看刊勘堪坎砍侃嵌槛瞰阚龛戡凵莰",
|
|
|
+ heng: "衡横恒亨哼珩桁蘅",
|
|
|
+ mo: "万没么模末冒莫摩墨默磨摸漠脉膜魔沫陌抹寞蘑摹蓦馍茉嘿谟秣蟆貉嫫镆殁耱嬷麽瘼貊貘",
|
|
|
+ peng: "鹏朋彭膨蓬碰苹棚捧亨烹篷澎抨硼怦砰嘭蟛堋",
|
|
|
+ hou: "后候厚侯猴喉吼逅篌糇骺後鲎瘊堠",
|
|
|
+ hua: "化华划话花画滑哗豁骅桦猾铧砉",
|
|
|
+ huai: "怀坏淮徊槐踝",
|
|
|
+ huan: "还环换欢患缓唤焕幻痪桓寰涣宦垸洹浣豢奂郇圜獾鲩鬟萑逭漶锾缳擐",
|
|
|
+ xun: "讯训迅孙寻询循旬巡汛勋逊熏徇浚殉驯鲟薰荀浔洵峋埙巽郇醺恂荨窨蕈曛獯",
|
|
|
+ huang: "黄荒煌皇凰慌晃潢谎惶簧璜恍幌湟蝗磺隍徨遑肓篁鳇蟥癀",
|
|
|
+ nai: "能乃奶耐奈鼐萘氖柰佴艿",
|
|
|
+ luan: "乱卵滦峦鸾栾銮挛孪脔娈",
|
|
|
+ qie: "切且契窃茄砌锲怯伽惬妾趄挈郄箧慊",
|
|
|
+ jian: "建间件见坚检健监减简艰践兼鉴键渐柬剑尖肩舰荐箭浅剪俭碱茧奸歼拣捡煎贱溅槛涧堑笺谏饯锏缄睑謇蹇腱菅翦戬毽笕犍硷鞯牮枧湔鲣囝裥踺搛缣鹣蒹谫僭戋趼楗",
|
|
|
+ nan: "南难男楠喃囡赧腩囝蝻",
|
|
|
+ qian: "前千钱签潜迁欠纤牵浅遣谦乾铅歉黔谴嵌倩钳茜虔堑钎骞阡掮钤扦芊犍荨仟芡悭缱佥愆褰凵肷岍搴箝慊椠",
|
|
|
+ qiang: "强抢疆墙枪腔锵呛羌蔷襁羟跄樯戕嫱戗炝镪锖蜣",
|
|
|
+ xiang: "向项相想乡象响香降像享箱羊祥湘详橡巷翔襄厢镶飨饷缃骧芗庠鲞葙蟓",
|
|
|
+ jiao: "教交较校角觉叫脚缴胶轿郊焦骄浇椒礁佼蕉娇矫搅绞酵剿嚼饺窖跤蛟侥狡姣皎茭峤铰醮鲛湫徼鹪僬噍艽挢敫",
|
|
|
+ zhuo: "着著缴桌卓捉琢灼浊酌拙茁涿镯淖啄濯焯倬擢斫棹诼浞禚",
|
|
|
+ qiao: "桥乔侨巧悄敲俏壳雀瞧翘窍峭锹撬荞跷樵憔鞘橇峤诮谯愀鞒硗劁缲",
|
|
|
+ xiao: "小效销消校晓笑肖削孝萧俏潇硝宵啸嚣霄淆哮筱逍姣箫骁枭哓绡蛸崤枵魈",
|
|
|
+ si: "司四思斯食私死似丝饲寺肆撕泗伺嗣祀厮驷嘶锶俟巳蛳咝耜笥纟糸鸶缌澌姒汜厶兕",
|
|
|
+ kai: "开凯慨岂楷恺揩锴铠忾垲剀锎蒈",
|
|
|
+ jin: "进金今近仅紧尽津斤禁锦劲晋谨筋巾浸襟靳瑾烬缙钅矜觐堇馑荩噤廑妗槿赆衿卺",
|
|
|
+ qin: "亲勤侵秦钦琴禽芹沁寝擒覃噙矜嗪揿溱芩衾廑锓吣檎螓",
|
|
|
+ jing: "经京精境竞景警竟井惊径静劲敬净镜睛晶颈荆兢靖泾憬鲸茎腈菁胫阱旌粳靓痉箐儆迳婧肼刭弪獍",
|
|
|
+ ying: "应营影英景迎映硬盈赢颖婴鹰荧莹樱瑛蝇萦莺颍膺缨瀛楹罂荥萤鹦滢蓥郢茔嘤璎嬴瘿媵撄潆",
|
|
|
+ jiu: "就究九酒久救旧纠舅灸疚揪咎韭玖臼柩赳鸠鹫厩啾阄桕僦鬏",
|
|
|
+ zui: "最罪嘴醉咀蕞觜",
|
|
|
+ juan: "卷捐圈眷娟倦绢隽镌涓鹃鄄蠲狷锩桊",
|
|
|
+ suan: "算酸蒜狻",
|
|
|
+ yun: "员运云允孕蕴韵酝耘晕匀芸陨纭郧筠恽韫郓氲殒愠昀菀狁",
|
|
|
+ qun: "群裙逡麇",
|
|
|
+ ka: "卡喀咖咔咯佧胩",
|
|
|
+ kang: "康抗扛慷炕亢糠伉钪闶",
|
|
|
+ keng: "坑铿吭",
|
|
|
+ kao: "考靠烤拷铐栲尻犒",
|
|
|
+ ken: "肯垦恳啃龈裉",
|
|
|
+ yin: "因引银印音饮阴隐姻殷淫尹荫吟瘾寅茵圻垠鄞湮蚓氤胤龈窨喑铟洇狺夤廴吲霪茚堙",
|
|
|
+ kong: "空控孔恐倥崆箜",
|
|
|
+ ku: "苦库哭酷裤枯窟挎骷堀绔刳喾",
|
|
|
+ kua: "跨夸垮挎胯侉",
|
|
|
+ kui: "亏奎愧魁馈溃匮葵窥盔逵睽馗聩喟夔篑岿喹揆隗傀暌跬蒉愦悝蝰",
|
|
|
+ kuan: "款宽髋",
|
|
|
+ kuang: "况矿框狂旷眶匡筐邝圹哐贶夼诳诓纩",
|
|
|
+ que: "确却缺雀鹊阙瘸榷炔阕悫",
|
|
|
+ kun: "困昆坤捆琨锟鲲醌髡悃阃",
|
|
|
+ kuo: "扩括阔廓蛞",
|
|
|
+ la: "拉落垃腊啦辣蜡喇剌旯砬邋瘌",
|
|
|
+ lai: "来莱赖睐徕籁涞赉濑癞崃疠铼",
|
|
|
+ lan: "兰览蓝篮栏岚烂滥缆揽澜拦懒榄斓婪阑褴罱啉谰镧漤",
|
|
|
+ lin: "林临邻赁琳磷淋麟霖鳞凛拎遴蔺吝粼嶙躏廪檩啉辚膦瞵懔",
|
|
|
+ lang: "浪朗郎廊狼琅榔螂阆锒莨啷蒗稂",
|
|
|
+ liang: "量两粮良辆亮梁凉谅粱晾靓踉莨椋魉墚",
|
|
|
+ lao: "老劳落络牢捞涝烙姥佬崂唠酪潦痨醪铑铹栳耢",
|
|
|
+ mu: "目模木亩幕母牧莫穆姆墓慕牟牡募睦缪沐暮拇姥钼苜仫毪坶",
|
|
|
+ le: "了乐勒肋叻鳓嘞仂泐",
|
|
|
+ lei: "类累雷勒泪蕾垒磊擂镭肋羸耒儡嫘缧酹嘞诔檑",
|
|
|
+ sui: "随岁虽碎尿隧遂髓穗绥隋邃睢祟濉燧谇眭荽",
|
|
|
+ lie: "列烈劣裂猎冽咧趔洌鬣埒捩躐",
|
|
|
+ leng: "冷愣棱楞塄",
|
|
|
+ ling: "领令另零灵龄陵岭凌玲铃菱棱伶羚苓聆翎泠瓴囹绫呤棂蛉酃鲮柃",
|
|
|
+ lia: "俩",
|
|
|
+ liao: "了料疗辽廖聊寥缪僚燎缭撂撩嘹潦镣寮蓼獠钌尥鹩",
|
|
|
+ liu: "流刘六留柳瘤硫溜碌浏榴琉馏遛鎏骝绺镏旒熘鹨锍",
|
|
|
+ lun: "论轮伦仑纶沦抡囵",
|
|
|
+ lv: "率律旅绿虑履吕铝屡氯缕滤侣驴榈闾偻褛捋膂稆",
|
|
|
+ lou: "楼露漏陋娄搂篓喽镂偻瘘髅耧蝼嵝蒌",
|
|
|
+ mao: "贸毛矛冒貌茂茅帽猫髦锚懋袤牦卯铆耄峁瑁蟊茆蝥旄泖昴瞀",
|
|
|
+ long: "龙隆弄垄笼拢聋陇胧珑窿茏咙砻垅泷栊癃",
|
|
|
+ nong: "农浓弄脓侬哝",
|
|
|
+ shuang: "双爽霜孀泷",
|
|
|
+ shu: "术书数属树输束述署朱熟殊蔬舒疏鼠淑叔暑枢墅俞曙抒竖蜀薯梳戍恕孰沭赎庶漱塾倏澍纾姝菽黍腧秫毹殳疋摅",
|
|
|
+ shuai: "率衰帅摔甩蟀",
|
|
|
+ lve: "略掠锊",
|
|
|
+ ma: "么马吗摩麻码妈玛嘛骂抹蚂唛蟆犸杩",
|
|
|
+ me: "么麽",
|
|
|
+ mai: "买卖麦迈脉埋霾荬劢",
|
|
|
+ man: "满慢曼漫埋蔓瞒蛮鳗馒幔谩螨熳缦镘颟墁鞔",
|
|
|
+ mi: "米密秘迷弥蜜谜觅靡泌眯麋猕谧咪糜宓汨醚嘧弭脒冖幂祢縻蘼芈糸敉",
|
|
|
+ men: "们门闷瞒汶扪焖懑鞔钔",
|
|
|
+ mang: "忙盲茫芒氓莽蟒邙硭漭",
|
|
|
+ meng: "蒙盟梦猛孟萌氓朦锰檬勐懵蟒蜢虻黾蠓艨甍艋瞢礞",
|
|
|
+ miao: "苗秒妙描庙瞄缪渺淼藐缈邈鹋杪眇喵",
|
|
|
+ mou: "某谋牟缪眸哞鍪蛑侔厶",
|
|
|
+ miu: "缪谬",
|
|
|
+ mei: "美没每煤梅媒枚妹眉魅霉昧媚玫酶镁湄寐莓袂楣糜嵋镅浼猸鹛",
|
|
|
+ wen: "文问闻稳温纹吻蚊雯紊瘟汶韫刎璺玟阌",
|
|
|
+ mie: "灭蔑篾乜咩蠛",
|
|
|
+ ming: "明名命鸣铭冥茗溟酩瞑螟暝",
|
|
|
+ na: "内南那纳拿哪娜钠呐捺衲镎肭",
|
|
|
+ nei: "内那哪馁",
|
|
|
+ nuo: "难诺挪娜糯懦傩喏搦锘",
|
|
|
+ ruo: "若弱偌箬",
|
|
|
+ nang: "囊馕囔曩攮",
|
|
|
+ nao: "脑闹恼挠瑙淖孬垴铙桡呶硇猱蛲",
|
|
|
+ ni: "你尼呢泥疑拟逆倪妮腻匿霓溺旎昵坭铌鲵伲怩睨猊",
|
|
|
+ nen: "嫩恁",
|
|
|
+ neng: "能",
|
|
|
+ nin: "您恁",
|
|
|
+ niao: "鸟尿溺袅脲茑嬲",
|
|
|
+ nie: "摄聂捏涅镍孽捻蘖啮蹑嗫臬镊颞乜陧",
|
|
|
+ niang: "娘酿",
|
|
|
+ ning: "宁凝拧泞柠咛狞佞聍甯",
|
|
|
+ nu: "努怒奴弩驽帑孥胬",
|
|
|
+ nv: "女钕衄恧",
|
|
|
+ ru: "入如女乳儒辱汝茹褥孺濡蠕嚅缛溽铷洳薷襦颥蓐",
|
|
|
+ nuan: "暖",
|
|
|
+ nve: "虐疟",
|
|
|
+ re: "热若惹喏",
|
|
|
+ ou: "区欧偶殴呕禺藕讴鸥瓯沤耦怄",
|
|
|
+ pao: "跑炮泡抛刨袍咆疱庖狍匏脬",
|
|
|
+ pou: "剖掊裒",
|
|
|
+ pen: "喷盆湓",
|
|
|
+ pie: "瞥撇苤氕丿",
|
|
|
+ pin: "品贫聘频拼拚颦姘嫔榀牝",
|
|
|
+ se: "色塞瑟涩啬穑铯槭",
|
|
|
+ qing: "情青清请亲轻庆倾顷卿晴氢擎氰罄磬蜻箐鲭綮苘黥圊檠謦",
|
|
|
+ zan: "赞暂攒堑昝簪糌瓒錾趱拶",
|
|
|
+ shao: "少绍召烧稍邵哨韶捎勺梢鞘芍苕劭艄筲杓潲",
|
|
|
+ sao: "扫骚嫂梢缫搔瘙臊埽缲鳋",
|
|
|
+ sha: "沙厦杀纱砂啥莎刹杉傻煞鲨霎嗄痧裟挲铩唼歃",
|
|
|
+ xuan: "县选宣券旋悬轩喧玄绚渲璇炫萱癣漩眩暄煊铉楦泫谖痃碹揎镟儇",
|
|
|
+ ran: "然染燃冉苒髯蚺",
|
|
|
+ rang: "让壤攘嚷瓤穰禳",
|
|
|
+ rao: "绕扰饶娆桡荛",
|
|
|
+ reng: "仍扔",
|
|
|
+ ri: "日",
|
|
|
+ rou: "肉柔揉糅鞣蹂",
|
|
|
+ ruan: "软阮朊",
|
|
|
+ run: "润闰",
|
|
|
+ sa: "萨洒撒飒卅仨脎",
|
|
|
+ suo: "所些索缩锁莎梭琐嗦唆唢娑蓑羧挲桫嗍睃",
|
|
|
+ sai: "思赛塞腮噻鳃",
|
|
|
+ shui: "说水税谁睡氵",
|
|
|
+ sang: "桑丧嗓搡颡磉",
|
|
|
+ sen: "森",
|
|
|
+ seng: "僧",
|
|
|
+ shai: "筛晒",
|
|
|
+ shang: "上商尚伤赏汤裳墒晌垧觞殇熵绱",
|
|
|
+ xing: "行省星腥猩惺兴刑型形邢饧醒幸杏性姓陉荇荥擤悻硎",
|
|
|
+ shou: "收手受首售授守寿瘦兽狩绶艏扌",
|
|
|
+ shuo: "说数硕烁朔铄妁槊蒴搠",
|
|
|
+ su: "速素苏诉缩塑肃俗宿粟溯酥夙愫簌稣僳谡涑蔌嗉觫",
|
|
|
+ shua: "刷耍唰",
|
|
|
+ shuan: "栓拴涮闩",
|
|
|
+ shun: "顺瞬舜吮",
|
|
|
+ song: "送松宋讼颂耸诵嵩淞怂悚崧凇忪竦菘",
|
|
|
+ sou: "艘搜擞嗽嗖叟馊薮飕嗾溲锼螋瞍",
|
|
|
+ sun: "损孙笋荪榫隼狲飧",
|
|
|
+ teng: "腾疼藤滕誊",
|
|
|
+ tie: "铁贴帖餮萜",
|
|
|
+ tu: "土突图途徒涂吐屠兔秃凸荼钍菟堍酴",
|
|
|
+ wai: "外歪崴",
|
|
|
+ wang: "王望往网忘亡旺汪枉妄惘罔辋魍",
|
|
|
+ weng: "翁嗡瓮蓊蕹",
|
|
|
+ zhua: "抓挝爪",
|
|
|
+ yang: "样养央阳洋扬杨羊详氧仰秧痒漾疡泱殃恙鸯徉佯怏炀烊鞅蛘",
|
|
|
+ xiong: "雄兄熊胸凶匈汹芎",
|
|
|
+ yo: "哟唷",
|
|
|
+ yong: "用永拥勇涌泳庸俑踊佣咏雍甬镛臃邕蛹恿慵壅痈鳙墉饔喁",
|
|
|
+ za: "杂扎咱砸咋匝咂拶",
|
|
|
+ zai: "在再灾载栽仔宰哉崽甾",
|
|
|
+ zao: "造早遭枣噪灶燥糟凿躁藻皂澡蚤唣",
|
|
|
+ zei: "贼",
|
|
|
+ zen: "怎谮",
|
|
|
+ zeng: "增曾综赠憎锃甑罾缯",
|
|
|
+ zhei: "这",
|
|
|
+ zou: "走邹奏揍诹驺陬楱鄹鲰",
|
|
|
+ zhuai: "转拽",
|
|
|
+ zun: "尊遵鳟樽撙",
|
|
|
+ dia: "嗲",
|
|
|
+ nou: "耨"
|
|
|
+};
|
|
|
+(function() {
|
|
|
+ if (!Array.prototype.indexOf) {
|
|
|
+ Array.prototype.indexOf = function(elt) {
|
|
|
+ var len = this.length >>> 0;
|
|
|
+ var from = Number(arguments[1]) || 0;
|
|
|
+ from = from < 0 ? Math.ceil(from) : Math.floor(from);
|
|
|
+ if (from < 0)
|
|
|
+ from += len;
|
|
|
+ for (; from < len; from++) {
|
|
|
+ if (from in this && this[from] === elt)
|
|
|
+ return from
|
|
|
+ }
|
|
|
+ return -1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Date.prototype.format = function(format) {
|
|
|
+ var 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
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ window.z = window.z || {};
|
|
|
+ z.ui = z.ui || {};
|
|
|
+ var comm = {
|
|
|
+ isIE: function() {
|
|
|
+ return !!window.ActiveXObject || "ActiveXObject"in window
|
|
|
+ },
|
|
|
+ isIE8: function() {
|
|
|
+ return navigator.userAgent.indexOf("MSIE 8.0") > 0
|
|
|
+ },
|
|
|
+ isMobile: function() {
|
|
|
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
|
|
|
+ },
|
|
|
+ isIOS: function() {
|
|
|
+ var u = navigator.userAgent;
|
|
|
+ return !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
|
|
|
+ },
|
|
|
+ isDingTalk: function() {
|
|
|
+ return /AliApp\(DingTalk/gi.test(navigator.userAgent) || /DingTalk/gi.test(navigator.userAgent)
|
|
|
+ },
|
|
|
+ isHbuildApp: function() {
|
|
|
+ return typeof plus != "undefined"
|
|
|
+ },
|
|
|
+ isTaurusApp: function() {
|
|
|
+ return navigator.userAgent.match(/TaurusApp/i) == "taurusapp"
|
|
|
+ },
|
|
|
+ compareObj: function(objA, objB) {
|
|
|
+ if (!$.isPlainObject(objA) || !$.isPlainObject(objB))
|
|
|
+ return false;
|
|
|
+ if (z.ui.comm.getObjLength(objA) != z.ui.comm.getObjLength(objB))
|
|
|
+ return false;
|
|
|
+ return compareObj(objA, objB, true);
|
|
|
+ function compareObj(objA, objB, flag) {
|
|
|
+ for (var key in objA) {
|
|
|
+ if (!flag)
|
|
|
+ break;
|
|
|
+ if (!objB.hasOwnProperty(key)) {
|
|
|
+ flag = false;
|
|
|
+ break
|
|
|
+ }
|
|
|
+ if (!$.isArray(objA[key])) {
|
|
|
+ if (objB[key] != objA[key]) {
|
|
|
+ flag = false;
|
|
|
+ break
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!$.isArray(objB[key])) {
|
|
|
+ flag = false;
|
|
|
+ break
|
|
|
+ }
|
|
|
+ var oA = objA[key]
|
|
|
+ , oB = objB[key];
|
|
|
+ if (oA.length != oB.length) {
|
|
|
+ flag = false;
|
|
|
+ break
|
|
|
+ }
|
|
|
+ for (var k in oA) {
|
|
|
+ if (!flag)
|
|
|
+ break;
|
|
|
+ flag = compareObj(oA[k], oB[k], flag)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return flag
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getObjLength: function(object) {
|
|
|
+ var count = 0;
|
|
|
+ for (var i in object)
|
|
|
+ count++;
|
|
|
+ return count
|
|
|
+ },
|
|
|
+ getUrlParam: function(field, uncode) {
|
|
|
+ var pReg = new RegExp("(^|&)" + field + "=([^&]*)(&|$)","i");
|
|
|
+ var pR = window.location.search.substr(1).match(pReg);
|
|
|
+ if (pR != null) {
|
|
|
+ if (!uncode)
|
|
|
+ return unescape(pR[2]);
|
|
|
+ else
|
|
|
+ return eval(uncode + "('" + pR[2] + "')")
|
|
|
+ }
|
|
|
+ return null
|
|
|
+ },
|
|
|
+ getStrUrlParam: function(url, field, uncode) {
|
|
|
+ var pReg = new RegExp("(^|&)" + field + "=([^&]*)(&|$)","i");
|
|
|
+ var pR = url.split("?")[1].match(pReg);
|
|
|
+ if (pR != null) {
|
|
|
+ if (!uncode)
|
|
|
+ return unescape(pR[2]);
|
|
|
+ else
|
|
|
+ return eval(uncode + "('" + pR[2] + "')")
|
|
|
+ }
|
|
|
+ return null
|
|
|
+ },
|
|
|
+ getEntranceUrl: function(url) {
|
|
|
+ url = $.trim(url);
|
|
|
+ if (!url)
|
|
|
+ return url;
|
|
|
+ if (!/^(https|http|ftp)/.test(url)) {
|
|
|
+ if (z.ui.posix.isAbsolute(url)) {
|
|
|
+ z.current_sys_url = z.current_sys_url || window.location.origin;
|
|
|
+ var _c = z.current_sys_url.split("//")
|
|
|
+ } else {
|
|
|
+ var _c = window.location.href.split("?")[0].split("//")
|
|
|
+ }
|
|
|
+ url = _c[0] + "//" + z.ui.posix.join(_c[1], url)
|
|
|
+ }
|
|
|
+ if (z.entrance_ip && z.current_sys_url) {
|
|
|
+ var cip = z.current_sys_url.split("//")[1].split("/")[0].split(":");
|
|
|
+ var urli = url.indexOf("//");
|
|
|
+ var urlarr0 = url.substring(0, urli);
|
|
|
+ var urlarr1 = url.substring(urli + 2);
|
|
|
+ var start = urlarr1.indexOf("/");
|
|
|
+ var uid = urlarr1.substring(0, start).split(":");
|
|
|
+ if (cip[0] === uid[0]) {
|
|
|
+ var relUrl = urlarr1.substring(start);
|
|
|
+ url = urlarr0 + "//" + z.entrance_ip + relUrl
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return url
|
|
|
+ },
|
|
|
+ addUrlParam: function(url, key, value) {
|
|
|
+ if (!value) {
|
|
|
+ return url
|
|
|
+ }
|
|
|
+ url = url || "";
|
|
|
+ var re = new RegExp("([?&])" + key + "=.*?(&|$)","i");
|
|
|
+ var separator = url.indexOf("?") !== -1 ? "&" : "?";
|
|
|
+ if (url.match(re)) {
|
|
|
+ return url.replace(re, "$1" + key + "=" + value + "$2")
|
|
|
+ } else {
|
|
|
+ return url + separator + key + "=" + value
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getTextByValue: function(value, data) {
|
|
|
+ var text = "";
|
|
|
+ for (var i = 0, len = data.length; i < len; i++) {
|
|
|
+ if (data[i].value == value) {
|
|
|
+ return data[i].text
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setPosition: function(selector) {
|
|
|
+ if ($.inArray(selector.css("position"), ["relative", "position", "fixed"])) {
|
|
|
+ selector.css({
|
|
|
+ position: "relative",
|
|
|
+ overflow: "visible"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ dragBox: function(option) {
|
|
|
+ var dragel = option.dragel
|
|
|
+ , targel = option.targel.get(0);
|
|
|
+ var x, y;
|
|
|
+ var isDrop = false;
|
|
|
+ dragel.addClass("z-dragbox").mousedown(function(e) {
|
|
|
+ var e = e || window.event;
|
|
|
+ x = e.clientX - targel.offsetLeft;
|
|
|
+ y = e.clientY - targel.offsetTop;
|
|
|
+ isDrop = true
|
|
|
+ });
|
|
|
+ $(document).mouseup(function(e) {
|
|
|
+ isDrop = false
|
|
|
+ });
|
|
|
+ $(document).mousemove(function(e) {
|
|
|
+ if (isDrop) {
|
|
|
+ var e = e || window.event;
|
|
|
+ var moveX = e.clientX - x;
|
|
|
+ var moveY = e.clientY - y;
|
|
|
+ var maxX = document.documentElement.clientWidth - targel.offsetWidth;
|
|
|
+ var maxY = document.documentElement.clientHeight - targel.offsetHeight;
|
|
|
+ if (moveX < 0) {
|
|
|
+ moveX = 0
|
|
|
+ } else if (moveX > maxX) {
|
|
|
+ moveX = maxX
|
|
|
+ }
|
|
|
+ if (moveY < 0) {
|
|
|
+ moveY = 0
|
|
|
+ } else if (moveY > maxY) {
|
|
|
+ moveY = maxY
|
|
|
+ }
|
|
|
+ targel.style.left = moveX + "px";
|
|
|
+ targel.style.top = moveY + "px"
|
|
|
+ } else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ createCompId: function(compname) {
|
|
|
+ return compname + "_" + parseInt(Math.random() * 1e6)
|
|
|
+ },
|
|
|
+ inheritClass: function(child, parent) {
|
|
|
+ var Super = function() {};
|
|
|
+ Super.prototype = parent.prototype;
|
|
|
+ child.prototype = new Super;
|
|
|
+ child.prototype.constructor = child
|
|
|
+ },
|
|
|
+ checkType: function(obj, type, iswarn) {
|
|
|
+ var res = Object.prototype.toString.call(obj) === "[object " + type + "]";
|
|
|
+ if (!res && iswarn) {
|
|
|
+ throw "Type error: argument is no " + type
|
|
|
+ }
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ each: function(obj, fn) {
|
|
|
+ if (!comm.checkType(obj, "Object") || !comm.checkType(fn, "Function"))
|
|
|
+ return;
|
|
|
+ for (var k in obj) {
|
|
|
+ if (obj.hasOwnProperty(k)) {
|
|
|
+ fn(k, obj[k])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ recursArr: function(arr, childField, parentObj, fn) {
|
|
|
+ for (var i = 0, len = arr.length; i < len; i++) {
|
|
|
+ var carr = arr[i][childField];
|
|
|
+ if (carr && carr.length > 0) {
|
|
|
+ arguments.callee(carr, childField, arr[i], fn)
|
|
|
+ }
|
|
|
+ fn(i, arr[i], parentObj)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ toRecursTree: function(arr, rootid, quitefield, quiteparentfield) {
|
|
|
+ var tree = [];
|
|
|
+ for (var i = 0; i < arr.length; i++) {
|
|
|
+ var item = arr[i];
|
|
|
+ if (!item[quiteparentfield] || rootid && item[quiteparentfield] == rootid) {
|
|
|
+ tree.push(item);
|
|
|
+ setchild(arr, item, item[quitefield])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function setchild(arr, pitem, pid) {
|
|
|
+ for (var i = 0; i < arr.length; i++) {
|
|
|
+ var item = arr[i];
|
|
|
+ if (item[quiteparentfield] == pid) {
|
|
|
+ if (!pitem.children) {
|
|
|
+ pitem.children = []
|
|
|
+ }
|
|
|
+ pitem.children.push(item);
|
|
|
+ setchild(arr, item, item[quitefield])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return tree
|
|
|
+ },
|
|
|
+ getCompAccomBottom: function(selector) {
|
|
|
+ var cH = 0
|
|
|
+ , scl = selector.parents(".z-tab-scroll");
|
|
|
+ if (scl.length) {
|
|
|
+ cH = scl.outerHeight() + scl.offset().top - selector.offset().top
|
|
|
+ } else {
|
|
|
+ var pmod = selector.parents(".z-modal-body");
|
|
|
+ if (pmod.length) {
|
|
|
+ cH = pmod.outerHeight() + pmod.offset().top - selector.offset().top
|
|
|
+ } else {
|
|
|
+ cH = $(window).outerHeight() - selector.offset().top
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return cH
|
|
|
+ },
|
|
|
+ getCompAccomTop: function(selector) {
|
|
|
+ var cH = 0
|
|
|
+ , scl = selector.parents(".z-tab-content");
|
|
|
+ if (scl.length) {
|
|
|
+ cH = selector.offset().top - scl.offset().top
|
|
|
+ } else {
|
|
|
+ var pmod = selector.parents(".z-modal-body");
|
|
|
+ if (pmod.length) {
|
|
|
+ cH = selector.offset().top - pmod.offset().top
|
|
|
+ } else {
|
|
|
+ cH = selector.offset().top
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return cH
|
|
|
+ }
|
|
|
+ };
|
|
|
+ z.ui.comm = comm
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ z.ui.comm.downLoadFile = function(url, fileName) {
|
|
|
+ z.ui.loading(true, true, false, "等待下载中...");
|
|
|
+ url = z.ui.comm.getEntranceUrl(url);
|
|
|
+ var uarr = url.split("/")
|
|
|
+ , fileName = fileName || uarr[uarr.length - 1];
|
|
|
+ fileExt = fileName.substr(fileName.indexOf(".") + 1);
|
|
|
+ var xmlhttp = null;
|
|
|
+ if (window.XMLHttpRequest) {
|
|
|
+ xmlhttp = new XMLHttpRequest
|
|
|
+ } else if (window.ActiveXObject) {
|
|
|
+ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
|
|
|
+ }
|
|
|
+ var xmlhttp = new XMLHttpRequest;
|
|
|
+ xmlhttp.open("GET", url, true);
|
|
|
+ xmlhttp.responseType = "blob";
|
|
|
+ xmlhttp.onload = function(e) {
|
|
|
+ download(xmlhttp.response, fileName, MimeList[fileExt]);
|
|
|
+ z.ui.loading(false)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ xmlhttp.send()
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ var MimeList = {
|
|
|
+ "*": "application/octet-stream",
|
|
|
+ 323: "text/h323",
|
|
|
+ acx: "application/internet-property-stream",
|
|
|
+ ai: "application/postscript",
|
|
|
+ aif: "audio/x-aiff",
|
|
|
+ aifc: "audio/x-aiff",
|
|
|
+ aiff: "audio/x-aiff",
|
|
|
+ asf: "video/x-ms-asf",
|
|
|
+ asr: "video/x-ms-asf",
|
|
|
+ asx: "video/x-ms-asf",
|
|
|
+ au: "audio/basic",
|
|
|
+ avi: "video/x-msvideo",
|
|
|
+ axs: "application/olescript",
|
|
|
+ bas: "text/plain",
|
|
|
+ bcpio: "application/x-bcpio",
|
|
|
+ bin: "application/octet-stream",
|
|
|
+ bmp: "image/bmp",
|
|
|
+ c: "text/plain",
|
|
|
+ cat: "application/vnd.ms-pkiseccat",
|
|
|
+ cdf: "application/x-cdf",
|
|
|
+ cer: "application/x-x509-ca-cert",
|
|
|
+ class: "application/octet-stream",
|
|
|
+ clp: "application/x-msclip",
|
|
|
+ cmx: "image/x-cmx",
|
|
|
+ cod: "image/cis-cod",
|
|
|
+ cpio: "application/x-cpio",
|
|
|
+ crd: "application/x-mscardfile",
|
|
|
+ crl: "application/pkix-crl",
|
|
|
+ crt: "application/x-x509-ca-cert",
|
|
|
+ csh: "application/x-csh",
|
|
|
+ css: "text/css",
|
|
|
+ dcr: "application/x-director",
|
|
|
+ der: "application/x-x509-ca-cert",
|
|
|
+ dir: "application/x-director",
|
|
|
+ dll: "application/x-msdownload",
|
|
|
+ dms: "application/octet-stream",
|
|
|
+ doc: "application/msword",
|
|
|
+ dot: "application/msword",
|
|
|
+ dvi: "application/x-dvi",
|
|
|
+ dxr: "application/x-director",
|
|
|
+ eps: "application/postscript",
|
|
|
+ etx: "text/x-setext",
|
|
|
+ evy: "application/envoy",
|
|
|
+ exe: "application/octet-stream",
|
|
|
+ fif: "application/fractals",
|
|
|
+ flr: "x-world/x-vrml",
|
|
|
+ gif: "image/gif",
|
|
|
+ gtar: "application/x-gtar",
|
|
|
+ gz: "application/x-gzip",
|
|
|
+ h: "text/plain",
|
|
|
+ hdf: "application/x-hdf",
|
|
|
+ hlp: "application/winhlp",
|
|
|
+ hqx: "application/mac-binhex40",
|
|
|
+ hta: "application/hta",
|
|
|
+ htc: "text/x-component",
|
|
|
+ htm: "text/html",
|
|
|
+ html: "text/html",
|
|
|
+ htt: "text/webviewhtml",
|
|
|
+ ico: "image/x-icon",
|
|
|
+ ief: "image/ief",
|
|
|
+ iii: "application/x-iphone",
|
|
|
+ ins: "application/x-internet-signup",
|
|
|
+ isp: "application/x-internet-signup",
|
|
|
+ jfif: "image/pipeg",
|
|
|
+ jpe: "image/jpeg",
|
|
|
+ jpeg: "image/jpeg",
|
|
|
+ jpg: "image/jpeg",
|
|
|
+ js: "application/x-javascript",
|
|
|
+ latex: "application/x-latex",
|
|
|
+ lha: "application/octet-stream",
|
|
|
+ lsf: "video/x-la-asf",
|
|
|
+ lsx: "video/x-la-asf",
|
|
|
+ lzh: "application/octet-stream",
|
|
|
+ m13: "application/x-msmediaview",
|
|
|
+ m14: "application/x-msmediaview",
|
|
|
+ m3u: "audio/x-mpegurl",
|
|
|
+ man: "application/x-troff-man",
|
|
|
+ mdb: "application/x-msaccess",
|
|
|
+ me: "application/x-troff-me",
|
|
|
+ mht: "message/rfc822",
|
|
|
+ mhtml: "message/rfc822",
|
|
|
+ mid: "audio/mid",
|
|
|
+ mny: "application/x-msmoney",
|
|
|
+ mov: "video/quicktime",
|
|
|
+ movie: "video/x-sgi-movie",
|
|
|
+ mp2: "video/mpeg",
|
|
|
+ mp3: "audio/mpeg",
|
|
|
+ mpa: "video/mpeg",
|
|
|
+ mpe: "video/mpeg",
|
|
|
+ mpeg: "video/mpeg",
|
|
|
+ mpg: "video/mpeg",
|
|
|
+ mpp: "application/vnd.ms-project",
|
|
|
+ mpv2: "video/mpeg",
|
|
|
+ ms: "application/x-troff-ms",
|
|
|
+ mvb: "application/x-msmediaview",
|
|
|
+ nws: "message/rfc822",
|
|
|
+ oda: "application/oda",
|
|
|
+ p10: "application/pkcs10",
|
|
|
+ p12: "application/x-pkcs12",
|
|
|
+ p7b: "application/x-pkcs7-certificates",
|
|
|
+ p7c: "application/x-pkcs7-mime",
|
|
|
+ p7m: "application/x-pkcs7-mime",
|
|
|
+ p7r: "application/x-pkcs7-certreqresp",
|
|
|
+ p7s: "application/x-pkcs7-signature",
|
|
|
+ pbm: "image/x-portable-bitmap",
|
|
|
+ pdf: "application/pdf",
|
|
|
+ pfx: "application/x-pkcs12",
|
|
|
+ pgm: "image/x-portable-graymap",
|
|
|
+ pko: "application/ynd.ms-pkipko",
|
|
|
+ pma: "application/x-perfmon",
|
|
|
+ pmc: "application/x-perfmon",
|
|
|
+ pml: "application/x-perfmon",
|
|
|
+ pmr: "application/x-perfmon",
|
|
|
+ pmw: "application/x-perfmon",
|
|
|
+ pnm: "image/x-portable-anymap",
|
|
|
+ "pot,": "application/vnd.ms-powerpoint",
|
|
|
+ ppm: "image/x-portable-pixmap",
|
|
|
+ pps: "application/vnd.ms-powerpoint",
|
|
|
+ ppt: "application/vnd.ms-powerpoint",
|
|
|
+ prf: "application/pics-rules",
|
|
|
+ ps: "application/postscript",
|
|
|
+ pub: "application/x-mspublisher",
|
|
|
+ qt: "video/quicktime",
|
|
|
+ ra: "audio/x-pn-realaudio",
|
|
|
+ ram: "audio/x-pn-realaudio",
|
|
|
+ ras: "image/x-cmu-raster",
|
|
|
+ rgb: "image/x-rgb",
|
|
|
+ rmi: "audio/mid",
|
|
|
+ roff: "application/x-troff",
|
|
|
+ rtf: "application/rtf",
|
|
|
+ rtx: "text/richtext",
|
|
|
+ scd: "application/x-msschedule",
|
|
|
+ sct: "text/scriptlet",
|
|
|
+ setpay: "application/set-payment-initiation",
|
|
|
+ setreg: "application/set-registration-initiation",
|
|
|
+ sh: "application/x-sh",
|
|
|
+ shar: "application/x-shar",
|
|
|
+ sit: "application/x-stuffit",
|
|
|
+ snd: "audio/basic",
|
|
|
+ spc: "application/x-pkcs7-certificates",
|
|
|
+ spl: "application/futuresplash",
|
|
|
+ src: "application/x-wais-source",
|
|
|
+ sst: "application/vnd.ms-pkicertstore",
|
|
|
+ stl: "application/vnd.ms-pkistl",
|
|
|
+ stm: "text/html",
|
|
|
+ svg: "image/svg+xml",
|
|
|
+ sv4cpio: "application/x-sv4cpio",
|
|
|
+ sv4crc: "application/x-sv4crc",
|
|
|
+ swf: "application/x-shockwave-flash",
|
|
|
+ t: "application/x-troff",
|
|
|
+ tar: "application/x-tar",
|
|
|
+ tcl: "application/x-tcl",
|
|
|
+ tex: "application/x-tex",
|
|
|
+ texi: "application/x-texinfo",
|
|
|
+ texinfo: "application/x-texinfo",
|
|
|
+ tgz: "application/x-compressed",
|
|
|
+ tif: "image/tiff",
|
|
|
+ tiff: "image/tiff",
|
|
|
+ tr: "application/x-troff",
|
|
|
+ trm: "application/x-msterminal",
|
|
|
+ tsv: "text/tab-separated-values",
|
|
|
+ txt: "text/plain",
|
|
|
+ uls: "text/iuls",
|
|
|
+ ustar: "application/x-ustar",
|
|
|
+ vcf: "text/x-vcard",
|
|
|
+ vrml: "x-world/x-vrml",
|
|
|
+ wav: "audio/x-wav",
|
|
|
+ wcm: "application/vnd.ms-works",
|
|
|
+ wdb: "application/vnd.ms-works",
|
|
|
+ wks: "application/vnd.ms-works",
|
|
|
+ wmf: "application/x-msmetafile",
|
|
|
+ wps: "application/vnd.ms-works",
|
|
|
+ wri: "application/x-mswrite",
|
|
|
+ wrl: "x-world/x-vrml",
|
|
|
+ wrz: "x-world/x-vrml",
|
|
|
+ xaf: "x-world/x-vrml",
|
|
|
+ xbm: "image/x-xbitmap",
|
|
|
+ xla: "application/vnd.ms-excel",
|
|
|
+ xlc: "application/vnd.ms-excel",
|
|
|
+ xlm: "application/vnd.ms-excel",
|
|
|
+ xls: "application/vnd.ms-excel",
|
|
|
+ xlt: "application/vnd.ms-excel",
|
|
|
+ xlw: "application/vnd.ms-excel",
|
|
|
+ xof: "x-world/x-vrml",
|
|
|
+ xpm: "image/x-xpixmap",
|
|
|
+ xwd: "image/x-xwindowdump",
|
|
|
+ z: "application/x-compress",
|
|
|
+ zip: "application/zip"
|
|
|
+ };
|
|
|
+ function download(data, strFileName, strMimeType) {
|
|
|
+ var self = window, u = "application/octet-stream", m = strMimeType || u, x = data, D = document, a = D.createElement("a"), z = function(a) {
|
|
|
+ return String(a)
|
|
|
+ }, B = self.Blob || self.MozBlob || self.WebKitBlob || z, BB = self.MSBlobBuilder || self.WebKitBlobBuilder || self.BlobBuilder, fn = strFileName || "download", blob, b, ua, fr;
|
|
|
+ if (String(this) === "true") {
|
|
|
+ x = [x, m];
|
|
|
+ m = x[0];
|
|
|
+ x = x[1]
|
|
|
+ }
|
|
|
+ if (String(x).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/)) {
|
|
|
+ return navigator.msSaveBlob ? navigator.msSaveBlob(d2b(x), fn) : saver(x)
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ blob = x instanceof B ? x : new B([x],{
|
|
|
+ type: m
|
|
|
+ })
|
|
|
+ } catch (y) {
|
|
|
+ if (BB) {
|
|
|
+ b = new BB;
|
|
|
+ b.append([x]);
|
|
|
+ blob = b.getBlob(m)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function d2b(u) {
|
|
|
+ var p = u.split(/[:;,]/)
|
|
|
+ , t = p[1]
|
|
|
+ , dec = p[2] == "base64" ? atob : decodeURIComponent
|
|
|
+ , bin = dec(p.pop())
|
|
|
+ , mx = bin.length
|
|
|
+ , i = 0
|
|
|
+ , uia = new Uint8Array(mx);
|
|
|
+ for (i; i < mx; ++i)
|
|
|
+ uia[i] = bin.charCodeAt(i);
|
|
|
+ return new B([uia],{
|
|
|
+ type: t
|
|
|
+ })
|
|
|
+ }
|
|
|
+ function saver(url, winMode) {
|
|
|
+ if ("download"in a) {
|
|
|
+ a.href = url;
|
|
|
+ a.setAttribute("download", fn);
|
|
|
+ D.body.appendChild(a);
|
|
|
+ setTimeout(function() {
|
|
|
+ a.click();
|
|
|
+ D.body.removeChild(a);
|
|
|
+ if (winMode === true) {
|
|
|
+ setTimeout(function() {
|
|
|
+ self.URL.revokeObjectURL(a.href)
|
|
|
+ }, 250)
|
|
|
+ }
|
|
|
+ }, 66);
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ var f = D.createElement("iframe");
|
|
|
+ D.body.appendChild(f);
|
|
|
+ if (!winMode) {
|
|
|
+ url = "data:" + url.replace(/^data:([\w\/\-\+]+)/, u)
|
|
|
+ }
|
|
|
+ f.src = url;
|
|
|
+ setTimeout(function() {
|
|
|
+ D.body.removeChild(f)
|
|
|
+ }, 333)
|
|
|
+ }
|
|
|
+ if (navigator.msSaveBlob) {
|
|
|
+ return navigator.msSaveBlob(blob, fn)
|
|
|
+ }
|
|
|
+ if (self.URL) {
|
|
|
+ saver(self.URL.createObjectURL(blob), true)
|
|
|
+ } else {
|
|
|
+ if (typeof blob === "string" || blob.constructor === z) {
|
|
|
+ try {
|
|
|
+ return saver("data:" + m + ";base64," + self.btoa(blob))
|
|
|
+ } catch (y) {
|
|
|
+ return saver("data:" + m + "," + encodeURIComponent(blob))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fr = new FileReader;
|
|
|
+ fr.onload = function(e) {
|
|
|
+ saver(this.result)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ fr.readAsDataURL(blob)
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
|
|
|
+ var splitTailRe = /^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/;
|
|
|
+ var posix = z.ui.posix = {};
|
|
|
+ posix.isAbsolute = function(path) {
|
|
|
+ return path.charAt(0) === "/"
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ posix.normalize = function(path) {
|
|
|
+ var isAbsolute = posix.isAbsolute(path)
|
|
|
+ , trailingSlash = path && path[path.length - 1] === "/";
|
|
|
+ path = normalizeArray(path.split("/"), !isAbsolute).join("/");
|
|
|
+ if (!path && !isAbsolute) {
|
|
|
+ path = "."
|
|
|
+ }
|
|
|
+ if (path && trailingSlash) {
|
|
|
+ path += "/"
|
|
|
+ }
|
|
|
+ return (isAbsolute ? "/" : "") + path
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ posix.join = function() {
|
|
|
+ var path = "";
|
|
|
+ for (var i = 0; i < arguments.length; i++) {
|
|
|
+ var segment = arguments[i];
|
|
|
+ if (segment) {
|
|
|
+ if (!path) {
|
|
|
+ path += segment
|
|
|
+ } else {
|
|
|
+ path += "/" + segment
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return posix.normalize(path)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function normalizeArray(parts, allowAboveRoot) {
|
|
|
+ var res = [];
|
|
|
+ for (var i = 0; i < parts.length; i++) {
|
|
|
+ var p = parts[i];
|
|
|
+ if (!p || p === ".")
|
|
|
+ continue;
|
|
|
+ if (p === "..") {
|
|
|
+ if (res.length && res[res.length - 1] !== "..") {
|
|
|
+ res.pop()
|
|
|
+ } else if (allowAboveRoot) {
|
|
|
+ res.push("..")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ res.push(p)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ var _prevNum = 0;
|
|
|
+ var i_height = 0;
|
|
|
+ var line_num = 0;
|
|
|
+ function _computed(that) {
|
|
|
+ var _cnum = $(that).val().length;
|
|
|
+ var _w = parseInt($(that).css("width"));
|
|
|
+ var _h = parseInt($(that).css("height")) - 12;
|
|
|
+ if (i_height === 0) {
|
|
|
+ i_height = _h
|
|
|
+ }
|
|
|
+ if (_cnum === 0) {
|
|
|
+ $(that).height(i_height);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (_prevNum < _cnum) {
|
|
|
+ $(that).height(_h + $(that).scrollTop());
|
|
|
+ _prevNum = _cnum
|
|
|
+ } else if (_prevNum > _cnum) {
|
|
|
+ var _fontSize = parseInt($(that).css("font-size"));
|
|
|
+ var num = _w / _fontSize;
|
|
|
+ var _computedNum = _prevNum - _cnum;
|
|
|
+ line_num = line_num + _computedNum;
|
|
|
+ if (line_num >= num) {
|
|
|
+ if (i_height >= _h)
|
|
|
+ return;
|
|
|
+ $(that).height(_h - _fontSize);
|
|
|
+ line_num = 0
|
|
|
+ }
|
|
|
+ _prevNum = _cnum
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $("textarea[autoheight=true]").on("keyup keydown", function() {
|
|
|
+ _computed(this)
|
|
|
+ });
|
|
|
+ var timer = null;
|
|
|
+ $("textarea[autoheight=true]").on("paste", function() {
|
|
|
+ var _that = $(this);
|
|
|
+ if (timer != null) {
|
|
|
+ clearTimeout(timer)
|
|
|
+ }
|
|
|
+ timer = setTimeout(function() {
|
|
|
+ _that.trigger("keyup keydown")
|
|
|
+ }, 500)
|
|
|
+ })
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ var pluses = /\+/g;
|
|
|
+ function encode(s) {
|
|
|
+ return config.raw ? s : encodeURIComponent(s)
|
|
|
+ }
|
|
|
+ function decode(s) {
|
|
|
+ return config.raw ? s : decodeURIComponent(s)
|
|
|
+ }
|
|
|
+ function stringifyCookieValue(value) {
|
|
|
+ return encode(config.json ? JSON.stringify(value) : String(value))
|
|
|
+ }
|
|
|
+ function parseCookieValue(s) {
|
|
|
+ if (s.indexOf('"') === 0) {
|
|
|
+ s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, "\\")
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ s = decodeURIComponent(s.replace(pluses, " "));
|
|
|
+ return config.json ? JSON.parse(s) : s
|
|
|
+ } catch (e) {}
|
|
|
+ }
|
|
|
+ function read(s, converter) {
|
|
|
+ var value = config.raw ? s : parseCookieValue(s);
|
|
|
+ return $.isFunction(converter) ? converter(value) : value
|
|
|
+ }
|
|
|
+ var config = {};
|
|
|
+ config.defaults = {};
|
|
|
+ z.ui.cookie = function(key, value, options) {
|
|
|
+ if (value !== undefined && !$.isFunction(value)) {
|
|
|
+ options = $.extend({}, config.defaults, options);
|
|
|
+ if (typeof options.expires === "number") {
|
|
|
+ var days = options.expires
|
|
|
+ , t = options.expires = new Date;
|
|
|
+ t.setTime(+t + days * 864e5)
|
|
|
+ }
|
|
|
+ return document.cookie = [encode(key), "=", stringifyCookieValue(value), options.expires ? "; expires=" + options.expires.toUTCString() : "", options.path ? "; path=" + options.path : "", options.domain ? "; domain=" + options.domain : "", options.secure ? "; secure" : ""].join("")
|
|
|
+ }
|
|
|
+ var result = key ? undefined : {};
|
|
|
+ var cookies = document.cookie ? document.cookie.split("; ") : [];
|
|
|
+ for (var i = 0, l = cookies.length; i < l; i++) {
|
|
|
+ var parts = cookies[i].split("=");
|
|
|
+ var name = decode(parts.shift());
|
|
|
+ var cookie = parts.join("=");
|
|
|
+ if (key && key === name) {
|
|
|
+ result = read(cookie, value);
|
|
|
+ break
|
|
|
+ }
|
|
|
+ if (!key && (cookie = read(cookie)) !== undefined) {
|
|
|
+ result[name] = cookie
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.removeCookie = function(key, options) {
|
|
|
+ if (z.ui.cookie(key) === undefined) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ z.ui.cookie(key, "", $.extend({}, options, {
|
|
|
+ expires: -1
|
|
|
+ }));
|
|
|
+ return !z.ui.cookie(key)
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ var dict = {};
|
|
|
+ var pinyinUtil = {
|
|
|
+ parseDict: function() {
|
|
|
+ if (window.pinyin_dict_firstletter) {
|
|
|
+ dict.firstletter = pinyin_dict_firstletter
|
|
|
+ }
|
|
|
+ if (window.pinyin_dict_notone) {
|
|
|
+ dict.notone = {};
|
|
|
+ dict.py2hz = pinyin_dict_notone;
|
|
|
+ for (var i in pinyin_dict_notone) {
|
|
|
+ var temp = pinyin_dict_notone[i];
|
|
|
+ for (var j = 0, len = temp.length; j < len; j++) {
|
|
|
+ if (dict.notone[temp[j]]) {
|
|
|
+ dict.notone[temp[j]] += " " + i
|
|
|
+ } else {
|
|
|
+ dict.notone[temp[j]] = i
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (window.pinyin_dict_withtone) {
|
|
|
+ dict.withtone = {};
|
|
|
+ var temp = pinyin_dict_withtone.split(",");
|
|
|
+ for (var i = 0, len = temp.length; i < len; i++) {
|
|
|
+ dict.withtone[String.fromCharCode(i + 19968)] = temp[i]
|
|
|
+ }
|
|
|
+ if (window.pinyin_dict_notone) {
|
|
|
+ dict.py2hz = pinyin_dict_notone
|
|
|
+ } else {
|
|
|
+ var notone = pinyinUtil.removeTone(pinyin_dict_withtone).split(",");
|
|
|
+ var py2hz = {}, py, hz;
|
|
|
+ for (var i = 0, len = notone.length; i < len; i++) {
|
|
|
+ hz = String.fromCharCode(i + 19968);
|
|
|
+ py = notone[i].split(" ");
|
|
|
+ for (var j = 0; j < py.length; j++) {
|
|
|
+ py2hz[py[j]] = (py2hz[py[j]] || "") + hz
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dict.py2hz = py2hz
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getPinyin: function(chinese, splitter, withtone, polyphone) {
|
|
|
+ if (!chinese || /^ +$/g.test(chinese))
|
|
|
+ return "";
|
|
|
+ splitter = splitter == undefined ? " " : splitter;
|
|
|
+ withtone = withtone == undefined ? true : withtone;
|
|
|
+ polyphone = polyphone == undefined ? false : polyphone;
|
|
|
+ var result = [];
|
|
|
+ if (dict.withtone) {
|
|
|
+ for (var i = 0, len = chinese.length; i < len; i++) {
|
|
|
+ var pinyin = dict.withtone[chinese[i]];
|
|
|
+ if (pinyin) {
|
|
|
+ if (!polyphone)
|
|
|
+ pinyin = pinyin.replace(/ .*$/g, "");
|
|
|
+ if (!withtone)
|
|
|
+ pinyin = this.removeTone(pinyin)
|
|
|
+ }
|
|
|
+ result.push(pinyin || chinese[i])
|
|
|
+ }
|
|
|
+ } else if (dict.notone) {
|
|
|
+ if (withtone)
|
|
|
+ console.warn("pinyin_dict_notone 字典文件不支持声调!");
|
|
|
+ for (var i = 0, len = chinese.length; i < len; i++) {
|
|
|
+ var pinyin = dict.notone[chinese[i]];
|
|
|
+ if (pinyin) {
|
|
|
+ if (!polyphone)
|
|
|
+ pinyin = pinyin.replace(/ .*$/g, "")
|
|
|
+ }
|
|
|
+ result.push(pinyin || chinese[i])
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw "抱歉,未找到合适的拼音字典文件!"
|
|
|
+ }
|
|
|
+ if (!polyphone)
|
|
|
+ return result.join(splitter);
|
|
|
+ else {
|
|
|
+ if (window.pinyin_dict_polyphone)
|
|
|
+ return parsePolyphone(chinese, result, splitter, withtone);
|
|
|
+ else
|
|
|
+ return handlePolyphone(result, " ", splitter)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getFirstLetter: function(str, polyphone) {
|
|
|
+ polyphone = polyphone == undefined ? false : polyphone;
|
|
|
+ if (!str || /^ +$/g.test(str))
|
|
|
+ return "";
|
|
|
+ if (dict.firstletter) {
|
|
|
+ var result = [];
|
|
|
+ for (var i = 0; i < str.length; i++) {
|
|
|
+ var unicode = str.charCodeAt(i);
|
|
|
+ var ch = str.charAt(i);
|
|
|
+ if (unicode >= 19968 && unicode <= 40869) {
|
|
|
+ ch = dict.firstletter.all.charAt(unicode - 19968);
|
|
|
+ if (polyphone)
|
|
|
+ ch = dict.firstletter.polyphone[unicode] || ch
|
|
|
+ }
|
|
|
+ result.push(ch)
|
|
|
+ }
|
|
|
+ if (!polyphone)
|
|
|
+ return result.join("");
|
|
|
+ else
|
|
|
+ return handlePolyphone(result, "", "")
|
|
|
+ } else {
|
|
|
+ var py = this.getPinyin(str, " ", false, polyphone);
|
|
|
+ py = py instanceof Array ? py : [py];
|
|
|
+ var result = [];
|
|
|
+ for (var i = 0; i < py.length; i++) {
|
|
|
+ result.push(py[i].replace(/(^| )(\w)\w*/g, function(m, $1, $2) {
|
|
|
+ return $2.toUpperCase()
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ if (!polyphone)
|
|
|
+ return result[0];
|
|
|
+ else
|
|
|
+ return simpleUnique(result)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getHanzi: function(pinyin) {
|
|
|
+ if (!dict.py2hz) {
|
|
|
+ throw "抱歉,未找到合适的拼音字典文件!"
|
|
|
+ }
|
|
|
+ return dict.py2hz[pinyin] || ""
|
|
|
+ },
|
|
|
+ removeTone: function(pinyin) {
|
|
|
+ var toneMap = {
|
|
|
+ "ā": "a1",
|
|
|
+ "á": "a2",
|
|
|
+ "ǎ": "a3",
|
|
|
+ "à": "a4",
|
|
|
+ "ō": "o1",
|
|
|
+ "ó": "o2",
|
|
|
+ "ǒ": "o3",
|
|
|
+ "ò": "o4",
|
|
|
+ "ē": "e1",
|
|
|
+ "é": "e2",
|
|
|
+ "ě": "e3",
|
|
|
+ "è": "e4",
|
|
|
+ "ī": "i1",
|
|
|
+ "í": "i2",
|
|
|
+ "ǐ": "i3",
|
|
|
+ "ì": "i4",
|
|
|
+ "ū": "u1",
|
|
|
+ "ú": "u2",
|
|
|
+ "ǔ": "u3",
|
|
|
+ "ù": "u4",
|
|
|
+ "ü": "v0",
|
|
|
+ "ǖ": "v1",
|
|
|
+ "ǘ": "v2",
|
|
|
+ "ǚ": "v3",
|
|
|
+ "ǜ": "v4",
|
|
|
+ "ń": "n2",
|
|
|
+ "ň": "n3",
|
|
|
+ "": "m2"
|
|
|
+ };
|
|
|
+ return pinyin.replace(/[āáǎàōóǒòēéěèīíǐìūúǔùüǖǘǚǜńň]/g, function(m) {
|
|
|
+ return toneMap[m][0]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ };
|
|
|
+ function handlePolyphone(array, splitter, joinChar) {
|
|
|
+ splitter = splitter || "";
|
|
|
+ var result = [""]
|
|
|
+ , temp = [];
|
|
|
+ for (var i = 0; i < array.length; i++) {
|
|
|
+ temp = [];
|
|
|
+ var t = array[i].split(splitter);
|
|
|
+ for (var j = 0; j < t.length; j++) {
|
|
|
+ for (var k = 0; k < result.length; k++)
|
|
|
+ temp.push(result[k] + (result[k] ? joinChar : "") + t[j])
|
|
|
+ }
|
|
|
+ result = temp
|
|
|
+ }
|
|
|
+ return simpleUnique(result)
|
|
|
+ }
|
|
|
+ function parsePolyphone(chinese, result, splitter, withtone) {
|
|
|
+ var poly = window.pinyin_dict_polyphone;
|
|
|
+ var max = 7;
|
|
|
+ var temp = poly[chinese];
|
|
|
+ if (temp) {
|
|
|
+ temp = temp.split(" ");
|
|
|
+ for (var i = 0; i < temp.length; i++) {
|
|
|
+ result[i] = temp[i] || result[i];
|
|
|
+ if (!withtone)
|
|
|
+ result[i] = pinyinUtil.removeTone(result[i])
|
|
|
+ }
|
|
|
+ return result.join(splitter)
|
|
|
+ }
|
|
|
+ for (var i = 0; i < chinese.length; i++) {
|
|
|
+ temp = "";
|
|
|
+ for (var j = 0; j < max && i + j < chinese.length; j++) {
|
|
|
+ if (!/^[\u2E80-\u9FFF]+$/.test(chinese[i + j]))
|
|
|
+ break;
|
|
|
+ temp += chinese[i + j];
|
|
|
+ var res = poly[temp];
|
|
|
+ if (res) {
|
|
|
+ res = res.split(" ");
|
|
|
+ for (var k = 0; k <= j; k++) {
|
|
|
+ if (res[k])
|
|
|
+ result[i + k] = withtone ? res[k] : pinyinUtil.removeTone(res[k])
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (var i = 0; i < result.length; i++) {
|
|
|
+ result[i] = result[i].replace(/ .*$/g, "")
|
|
|
+ }
|
|
|
+ return result.join(splitter)
|
|
|
+ }
|
|
|
+ function simpleUnique(array) {
|
|
|
+ var result = [];
|
|
|
+ var hash = {};
|
|
|
+ for (var i = 0; i < array.length; i++) {
|
|
|
+ var key = typeof array[i] + array[i];
|
|
|
+ if (!hash[key]) {
|
|
|
+ result.push(array[i]);
|
|
|
+ hash[key] = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result
|
|
|
+ }
|
|
|
+ pinyinUtil.parseDict();
|
|
|
+ pinyinUtil.dict = dict;
|
|
|
+ z.ui.pinyinUtil = pinyinUtil
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ var znavigationbar, isDD = z.ui.comm.isDingTalk(), isZZD = z.ui.comm.isTaurusApp(), isHbuildApp = z.ui.comm.isHbuildApp(), isMobile = z.ui.comm.isMobile();
|
|
|
+ var znavigationcontainer = $(".z-navigation-container");
|
|
|
+ if (!isDD && isMobile && znavigationcontainer.length) {
|
|
|
+ var str = '<div class="z-navigation-bar">' + '<div class="z-navigation-bar-left"><i class="fa fa-angle-left"></i> <span class="text">返回</span></div>' + '<div class="z-navigation-bar-title"></div>' + '<div class="z-navigation-bar-right"></div>' + "</div>";
|
|
|
+ znavigationcontainer.css("top", "2rem");
|
|
|
+ $("body").prepend(str);
|
|
|
+ if (isMobile) {
|
|
|
+ znavigationbar = $(".z-navigation-bar");
|
|
|
+ znavigationbar.find(".z-navigation-bar-left").on("click", function(e) {
|
|
|
+ if (z.ui.navigation.leftclick) {
|
|
|
+ z.ui.navigation.leftclick()
|
|
|
+ } else {
|
|
|
+ z.ui.navigation.goBack()
|
|
|
+ }
|
|
|
+ });
|
|
|
+ znavigationbar.find(".z-navigation-bar-right").on("click", "#znavigationrightbtn", function(e) {
|
|
|
+ znavigationbar.find(".z-inputselect-dropdown").toggle();
|
|
|
+ return false
|
|
|
+ });
|
|
|
+ znavigationbar.find(".z-navigation-bar-right").on("click", ".z-navigation-right-item", function(e) {
|
|
|
+ var id = $(this).attr("id");
|
|
|
+ for (var i = 0, len = z.ui.navigation.menus.length; i < len; i++) {
|
|
|
+ var item = z.ui.navigation.menus[i];
|
|
|
+ if (item.id == id) {
|
|
|
+ item.onClick && item.onClick(item);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ z.ui.navigation = {
|
|
|
+ leftclick: null,
|
|
|
+ items: [],
|
|
|
+ reload: function() {
|
|
|
+ window.location.reload()
|
|
|
+ },
|
|
|
+ openLink: function(option) {
|
|
|
+ if (isDD) {
|
|
|
+ dd.biz.util.openLink({
|
|
|
+ url: option.url,
|
|
|
+ onSuccess: option.onSuccess,
|
|
|
+ onFail: option.onFail
|
|
|
+ })
|
|
|
+ } else if (isHbuildApp) {
|
|
|
+ mui.openWindow({
|
|
|
+ url: url,
|
|
|
+ id: url,
|
|
|
+ styles: {
|
|
|
+ top: "0px",
|
|
|
+ bottom: "0px",
|
|
|
+ width: "100%",
|
|
|
+ height: "100%",
|
|
|
+ scalable: true
|
|
|
+ },
|
|
|
+ extras: {},
|
|
|
+ show: {
|
|
|
+ autoShow: true
|
|
|
+ },
|
|
|
+ waiting: {
|
|
|
+ autoShow: false,
|
|
|
+ options: {
|
|
|
+ width: "120px",
|
|
|
+ height: "120px",
|
|
|
+ background: "rgba(255,255,255,0.0)",
|
|
|
+ modal: true,
|
|
|
+ style: "black"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (isMobile) {
|
|
|
+ window.location.href = option.url
|
|
|
+ }
|
|
|
+ },
|
|
|
+ goBack: function() {
|
|
|
+ if (isDD || isZZD) {
|
|
|
+ dd.biz.navigation.goBack({
|
|
|
+ onSuccess: function(result) {},
|
|
|
+ onFail: function(err) {}
|
|
|
+ })
|
|
|
+ } else if (isHbuildApp) {
|
|
|
+ mui.back()
|
|
|
+ } else if (isMobile) {
|
|
|
+ window.history.back()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ close: function() {
|
|
|
+ if (isDD) {
|
|
|
+ dd.biz.navigation.close({
|
|
|
+ onSuccess: function(result) {},
|
|
|
+ onFail: function(err) {}
|
|
|
+ })
|
|
|
+ } else if (isHbuildApp) {
|
|
|
+ mui.back()
|
|
|
+ } else if (isMobile) {
|
|
|
+ window.close()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setLeft: function(option) {
|
|
|
+ if (isDD) {
|
|
|
+ dd.biz.navigation.setLeft({
|
|
|
+ control: !!option.onClick,
|
|
|
+ text: option.text,
|
|
|
+ onSuccess: function(result) {
|
|
|
+ option.onClick(result)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else if (isMobile) {
|
|
|
+ z.ui.navigation.leftclick = option.onClick;
|
|
|
+ znavigationbar.find(".z-navigation-bar-left").find(".text").html(option.text)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setTitle: function(option) {
|
|
|
+ var title = option.show !== false ? option.title : " ";
|
|
|
+ if (isDD) {
|
|
|
+ dd.biz.navigation.setTitle({
|
|
|
+ title: title
|
|
|
+ })
|
|
|
+ } else if (isMobile) {
|
|
|
+ znavigationbar.find(".z-navigation-bar-title").html(title)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setRight: function(option) {
|
|
|
+ var isshow = option.show !== false;
|
|
|
+ if (isshow) {
|
|
|
+ z.ui.navigation.menus = option.items;
|
|
|
+ var items = [];
|
|
|
+ for (var i = 0, len = option.items.length; i < len; i++) {
|
|
|
+ var item = option.items[i];
|
|
|
+ if (item.show && item.show(item) === false)
|
|
|
+ continue;
|
|
|
+ items.push(item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isDD) {
|
|
|
+ if (isshow) {
|
|
|
+ dd.biz.navigation.setMenu({
|
|
|
+ backgroundColor: option.backgroundColor,
|
|
|
+ textColor: option.textColor,
|
|
|
+ items: items,
|
|
|
+ onSuccess: function(data) {
|
|
|
+ for (var i = 0, len = items.length; i < len; i++) {
|
|
|
+ var item = items[i];
|
|
|
+ if (item.id == data.id) {
|
|
|
+ item.onClick && item.onClick(item);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ dd.biz.navigation.setRight({
|
|
|
+ show: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else if (isMobile && isshow) {
|
|
|
+ if (items.length === 1) {
|
|
|
+ var str = '<span class="z-navigation-right-item" id="' + items[0].id + '">' + items[0].text + "</span>"
|
|
|
+ } else {
|
|
|
+ var str = '<div id="znavigationrightbtn"><i class="fa fa-ellipsis-h"></i></div><div class="z-inputselect-dropdown" style="background-color:' + option.backgroundColor + ";color:" + option.textColor + '"><ul>';
|
|
|
+ for (var i = 0, len = items.length; i < len; i++) {
|
|
|
+ var item = items[i];
|
|
|
+ str += '<li class="z-navigation-right-item" id="' + item.id + '">' + item.text + "</li>"
|
|
|
+ }
|
|
|
+ str += "</ul></div>"
|
|
|
+ }
|
|
|
+ znavigationbar.find(".z-navigation-bar-right").html(str)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ z.ui.mtree = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var treeid = selector;
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = new mtree(selector,treeid)
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function mtree(selector, treeid) {
|
|
|
+ this.treeid = treeid;
|
|
|
+ this.iscomprender = false;
|
|
|
+ this.selector = $(selector);
|
|
|
+ this.setting = {};
|
|
|
+ this.curcatid = null
|
|
|
+ }
|
|
|
+ mtree.prototype.init = function(option) {
|
|
|
+ if (this.iscomprender)
|
|
|
+ return;
|
|
|
+ var _this = this;
|
|
|
+ var setting = $.extend(true, {
|
|
|
+ checkclsarr: ["", "halfchecked", "checked"],
|
|
|
+ ajax: {
|
|
|
+ url: "",
|
|
|
+ data: {}
|
|
|
+ },
|
|
|
+ treedata: [],
|
|
|
+ callback: {
|
|
|
+ onBeforeLoad: function() {},
|
|
|
+ onLoadSuccess: function() {},
|
|
|
+ onLoadError: function() {},
|
|
|
+ onClick: function(node, treeid) {},
|
|
|
+ beforeCheck: function(node, treeid) {},
|
|
|
+ onCheck: function(node, treeid) {}
|
|
|
+ },
|
|
|
+ search: {
|
|
|
+ enable: false,
|
|
|
+ field: "name"
|
|
|
+ },
|
|
|
+ check: {
|
|
|
+ enable: false
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ checkbychild: true,
|
|
|
+ key: {
|
|
|
+ name: "name"
|
|
|
+ },
|
|
|
+ simpleData: {
|
|
|
+ enable: true,
|
|
|
+ idKey: "id",
|
|
|
+ pIdKey: "pid",
|
|
|
+ childKey: "children",
|
|
|
+ rootPId: ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, option);
|
|
|
+ this.setting = setting;
|
|
|
+ var str = '<div class="z-mtree">' + (setting.search.enable ? '<div class="z-mtree-head">' + '<div class="z-mtree-search">' + '<i class="fa fa-search"></i>' + '<input type="text">' + "</div>" + "</div>" : "") + '<div class="z-mtree-catalog">' + '<span class="catalog-item">顶部</span>' + "</div>" + '<div class="z-mtree-content" style="height:calc(100% - 2px - ' + (setting.search.enable ? "4rem" : "2rem") + ')">' + (setting.check.enable ? '<div class="z-mtree-allcheck"><i class="z-mtree-checkbox"></i><span class="z-mtree-text">全部</span></div>' : "") + '<div class="z-mtree-list"></div>' + "</div>" + "</div>";
|
|
|
+ this.selector.html(str);
|
|
|
+ this.itemlist = this.selector.find(".z-mtree-list");
|
|
|
+ this.selector.find(".z-mtree-catalog").on("click", ".catalog-item", function(e) {
|
|
|
+ var nodeid = $(this).attr("nodeid");
|
|
|
+ createContent.call(_this, nodeid)
|
|
|
+ });
|
|
|
+ this.itemlist.on("click", ".z-mtree-item-r", function(e) {
|
|
|
+ var nodeid = $(this).parent().attr("nodeid");
|
|
|
+ createContent.call(_this, nodeid);
|
|
|
+ return false
|
|
|
+ });
|
|
|
+ this.selector.find(".z-mtree-allcheck").on("click", function(e) {
|
|
|
+ var flag;
|
|
|
+ if ($(this).hasClass("checked")) {
|
|
|
+ flag = false
|
|
|
+ } else {
|
|
|
+ flag = true
|
|
|
+ }
|
|
|
+ var items = _this.selector.find(".z-mtree-list .z-mtree-item");
|
|
|
+ items.each(function(i, item) {
|
|
|
+ _this.checkNode.call(_this, $(this).attr("nodeid"), flag, true, true)
|
|
|
+ })
|
|
|
+ });
|
|
|
+ this.itemlist.on("click", ".z-mtree-item", function(e) {
|
|
|
+ var nodeid = $(this).attr("nodeid")
|
|
|
+ , node = _this.getNode(nodeid);
|
|
|
+ if (_this.setting.check.enable) {
|
|
|
+ var checked = node.checkstate === 0 ? true : false;
|
|
|
+ checkNode.call(_this, nodeid, node, checked, true, true)
|
|
|
+ }
|
|
|
+ _this.setting.callback.onClick(node, _this.treeid)
|
|
|
+ });
|
|
|
+ getTreeData.call(this, this.treeid, this.selector, setting)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ mtree.prototype.checkNode = function(nodeid, checked, checkTypeFlag, callbackFlag) {
|
|
|
+ if (this.setting.check.enable === false)
|
|
|
+ return;
|
|
|
+ var node = this.getNode(nodeid);
|
|
|
+ checkNode.call(this, nodeid, node, checked, checkTypeFlag, callbackFlag)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ mtree.prototype.checkAllNodes = function(checked) {
|
|
|
+ if (this.setting.check.enable === false)
|
|
|
+ return;
|
|
|
+ var sd = this.setting.data.simpleData;
|
|
|
+ var nodes = this.setting.treedata;
|
|
|
+ for (var i = 0, len = nodes.length; i < len; i++) {
|
|
|
+ var node = nodes[i];
|
|
|
+ checkNode.call(this, node[sd.idKey], node, checked, true, false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ mtree.prototype.getCheckedNodes = function(checked, catalog, halfchecked) {
|
|
|
+ if (this.setting.check.enable === false)
|
|
|
+ return [];
|
|
|
+ var sd = this.setting.data.simpleData
|
|
|
+ , nodes = this.defaulttreedata
|
|
|
+ , slist = [];
|
|
|
+ for (var i = 0, len = nodes.length; i < len; i++) {
|
|
|
+ var node = nodes[i];
|
|
|
+ if (checked && (halfchecked && node.checkstate === 1 || node.checkstate === 2)) {
|
|
|
+ if (node[sd.childKey] && node[sd.childKey].length > 0) {
|
|
|
+ if (catalog === true) {
|
|
|
+ slist.push(node)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ slist.push(node)
|
|
|
+ }
|
|
|
+ } else if (!checked && (halfchecked && node.checkstate === 1 || node.checkstate === 0)) {
|
|
|
+ if (node[sd.childKey] && node[sd.childKey].length > 0) {
|
|
|
+ if (catalog === true) {
|
|
|
+ slist.push(node)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ slist.push(node)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return slist
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ mtree.prototype.getNode = function(nodeid) {
|
|
|
+ var sd = this.setting.data.simpleData;
|
|
|
+ for (var i = 0, len = this.defaulttreedata.length; i < len; i++) {
|
|
|
+ var node = this.defaulttreedata[i];
|
|
|
+ if (node[sd.idKey] == nodeid) {
|
|
|
+ return node
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ mtree.prototype.getTreeNodes = function() {
|
|
|
+ return this.setting.treedata
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ mtree.prototype.getListNodes = function() {
|
|
|
+ return this.defaulttreedata
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function checkCountAll() {
|
|
|
+ var _this = this
|
|
|
+ , items = this.selector.find(".z-mtree-list .z-mtree-item")
|
|
|
+ , ci = 0;
|
|
|
+ items.each(function(i, item) {
|
|
|
+ if (_this.getNode($(this).attr("nodeid")).checkstate === 2) {
|
|
|
+ ci++
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (items.length !== 0 && ci === items.length) {
|
|
|
+ this.selector.find(".z-mtree-allcheck").addClass("checked")
|
|
|
+ } else {
|
|
|
+ this.selector.find(".z-mtree-allcheck").removeClass("checked")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function checkNode(nodeid, node, checked, checkTypeFlag, callbackFlag) {
|
|
|
+ if (!node)
|
|
|
+ return;
|
|
|
+ if (callbackFlag !== false) {
|
|
|
+ if (this.setting.callback.beforeCheck(node, this.treeid) === false)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ node.checkstate = checked ? 2 : 0;
|
|
|
+ if (checkTypeFlag !== false) {
|
|
|
+ checkNodeRelation.call(this, node)
|
|
|
+ }
|
|
|
+ var el = this.itemlist.find("[nodeid=" + nodeid + "]");
|
|
|
+ if (el.length) {
|
|
|
+ el.removeClass("halfchecked").removeClass("checked").addClass(this.setting.checkclsarr[node.checkstate])
|
|
|
+ }
|
|
|
+ checkCountAll.call(this);
|
|
|
+ if (callbackFlag !== false) {
|
|
|
+ this.setting.callback.onCheck(node, this.treeid)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function createContent(nodeid) {
|
|
|
+ var sd = this.setting.data.simpleData
|
|
|
+ , childlist = [];
|
|
|
+ if (!nodeid) {
|
|
|
+ childlist = this.setting.treedata
|
|
|
+ } else {
|
|
|
+ for (var i = 0, len = this.defaulttreedata.length; i < len; i++) {
|
|
|
+ if (this.defaulttreedata[i][sd.idKey] == nodeid) {
|
|
|
+ childlist = this.defaulttreedata[i][sd.childKey];
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ createCatalog.call(this, nodeid);
|
|
|
+ createItems.call(this, childlist)
|
|
|
+ }
|
|
|
+ function createItems(childlist) {
|
|
|
+ var val = this.selector.find(".z-mtree-search input").val() || ""
|
|
|
+ , childlist = getlist.call(this, val);
|
|
|
+ var sd = this.setting.data.simpleData
|
|
|
+ , name = this.setting.data.key.name
|
|
|
+ , hasck = this.setting.check.enable;
|
|
|
+ var str = "";
|
|
|
+ for (var i = 0, len = childlist.length; i < len; i++) {
|
|
|
+ var node = childlist[i];
|
|
|
+ str += '<div class="z-mtree-item ' + this.setting.checkclsarr[node.checkstate] + " " + (hasck ? "hascheckbox" : "") + '" nodeid="' + node[sd.idKey] + '">' + '<i class="z-mtree-checkbox"></i>' + '<span class="z-mtree-text">' + node[name] + "</span>" + (node[sd.childKey] && node[sd.childKey].length > 0 ? '<div class="z-mtree-item-r fa fa-angle-right"></div>' : "") + "</div>"
|
|
|
+ }
|
|
|
+ this.itemlist.html(str);
|
|
|
+ checkCountAll.call(this);
|
|
|
+ function getlist(val) {
|
|
|
+ var matcher = val.replace(/,/g, "|")
|
|
|
+ , field = this.setting.search.field
|
|
|
+ , sd = this.setting.data.simpleData;
|
|
|
+ var slist = [];
|
|
|
+ if (val !== "") {
|
|
|
+ var nodes = [];
|
|
|
+ if (!this.curcatid) {
|
|
|
+ nodes = this.setting.treedata
|
|
|
+ } else {
|
|
|
+ nodes = this.getNode(this.curcatid)[sd.childKey]
|
|
|
+ }
|
|
|
+ _list(nodes)
|
|
|
+ } else {
|
|
|
+ if (!this.curcatid) {
|
|
|
+ slist = this.setting.treedata
|
|
|
+ } else {
|
|
|
+ slist = this.getNode(this.curcatid)[sd.childKey]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return slist;
|
|
|
+ function _list(nodes) {
|
|
|
+ for (var i = 0, len = nodes.length; i < len; i++) {
|
|
|
+ var node = nodes[i]
|
|
|
+ , children = node[sd.childKey];
|
|
|
+ if (children && children.length > 0) {
|
|
|
+ _list(children)
|
|
|
+ } else {
|
|
|
+ var value = node[field]
|
|
|
+ , pinyin = z.ui.pinyinUtil.getPinyin(value, "", false).toLowerCase().replace(/\s+/g, "")
|
|
|
+ , fl = z.ui.pinyinUtil.getFirstLetter(value).toLowerCase();
|
|
|
+ if (pinyin.indexOf(matcher) > -1 || fl.indexOf(matcher) > -1 || value.indexOf(matcher) > -1) {
|
|
|
+ slist.push(node)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function createCatalog(nodeid) {
|
|
|
+ this.curcatid = nodeid;
|
|
|
+ var sd = this.setting.data.simpleData
|
|
|
+ , name = this.setting.data.key.name
|
|
|
+ , str = "";
|
|
|
+ create.call(this, nodeid);
|
|
|
+ this.selector.find(".z-mtree-catalog").html('<span class="catalog-item">顶部</span>' + str);
|
|
|
+ function create(nodeid) {
|
|
|
+ for (var i = 0, len = this.defaulttreedata.length; i < len; i++) {
|
|
|
+ if (this.defaulttreedata[i][sd.idKey] == nodeid) {
|
|
|
+ var node = this.defaulttreedata[i];
|
|
|
+ str = '><span class="catalog-item" nodeid="' + node[sd.idKey] + '">' + node[name] + "</span>" + str;
|
|
|
+ var pid = node[sd.pIdKey];
|
|
|
+ if (pid) {
|
|
|
+ create.call(this, pid)
|
|
|
+ }
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function bindSearch() {
|
|
|
+ var _this = this
|
|
|
+ , timer = null;
|
|
|
+ this.selector.find(".z-mtree-search input").on("input propertychange", function() {
|
|
|
+ clearTimeout(timer);
|
|
|
+ timer = window.setTimeout(function() {
|
|
|
+ createItems.call(_this)
|
|
|
+ }, 200)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ function getTreeData(treeid, selector, setting) {
|
|
|
+ if (setting.callback.onBeforeLoad(treeid) === false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var _this = this;
|
|
|
+ if (setting.ajax.url) {
|
|
|
+ var ajaxobj = $.extend(true, {}, setting.ajax);
|
|
|
+ ajaxobj.success = function(res) {
|
|
|
+ setting.treedata = res || [];
|
|
|
+ _this.defaulttreedata = setting.treedata;
|
|
|
+ dealTreeData(setting);
|
|
|
+ bindSearch.call(_this);
|
|
|
+ createContent.call(_this);
|
|
|
+ setting.callback.onLoadSuccess(treeid, setting.treedata)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ ajaxobj.error = function(xhr, ts, err) {
|
|
|
+ setting.callback.onLoadError(treeid, xhr, ts, err)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.ajax(ajaxobj)
|
|
|
+ } else if (setting.treedata) {
|
|
|
+ _this.defaulttreedata = setting.treedata;
|
|
|
+ dealTreeData(setting);
|
|
|
+ bindSearch.call(_this);
|
|
|
+ createContent.call(_this);
|
|
|
+ setting.callback.onLoadSuccess(treeid, setting.treedata)
|
|
|
+ }
|
|
|
+ function dealTreeData(setting) {
|
|
|
+ var sd = setting.data.simpleData
|
|
|
+ , checkbychild = setting.data.checkbychild;
|
|
|
+ setting.treedata = z.ui.comm.toRecursTree(setting.treedata || [], sd.rootPId, sd.idKey, sd.pIdKey);
|
|
|
+ if (sd.enable === false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ z.ui.comm.recursArr(setting.treedata, sd.childKey, null, function(i, val, parentObj) {
|
|
|
+ if (typeof val.checkstate === "undefined") {
|
|
|
+ if (val.checked) {
|
|
|
+ val.checkstate = 2
|
|
|
+ } else {
|
|
|
+ val.checkstate = 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (checkbychild && parentObj) {
|
|
|
+ if (i === 0) {
|
|
|
+ parentObj.childcheckedcount = 0;
|
|
|
+ parentObj.checkstate = 0
|
|
|
+ }
|
|
|
+ parentObj.childcheckedcount += val.checkstate;
|
|
|
+ if (i === parentObj.children.length - 1) {
|
|
|
+ if (parentObj.childcheckedcount === 0) {
|
|
|
+ parentObj.checkstate = 0
|
|
|
+ } else if (parentObj.childcheckedcount === 2 * parentObj.children.length) {
|
|
|
+ parentObj.checkstate = 2
|
|
|
+ } else {
|
|
|
+ parentObj.checkstate = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function checkNodeRelation(node) {
|
|
|
+ var sd = this.setting.data.simpleData;
|
|
|
+ setSonNodeCheckBox.call(this, node, node.checkstate === 2, sd.childKey, sd.idKey);
|
|
|
+ setParentNodeCheckBox.call(this, node, sd.pIdKey, sd.childKey, sd.idKey)
|
|
|
+ }
|
|
|
+ function setSonNodeCheckBox(node, checked, childKey, idKey) {
|
|
|
+ var children = node[childKey];
|
|
|
+ if (children) {
|
|
|
+ for (var i = 0, l = children.length; i < l; i++) {
|
|
|
+ var snode = children[i];
|
|
|
+ snode.checkstate = checked ? 2 : 0;
|
|
|
+ var el = this.itemlist.find("[nodeid=" + snode[idKey] + "]");
|
|
|
+ if (el.length) {
|
|
|
+ el.removeClass("halfchecked").removeClass("checked").addClass(this.setting.checkclsarr[snode.checkstate])
|
|
|
+ }
|
|
|
+ setSonNodeCheckBox.call(this, snode, checked, childKey, idKey)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function setParentNodeCheckBox(node, pidkey, childKey, idKey) {
|
|
|
+ var pid = node[pidkey];
|
|
|
+ if (pid) {
|
|
|
+ pnode = this.getNode(pid);
|
|
|
+ if (pnode) {
|
|
|
+ var children = pnode[childKey];
|
|
|
+ if (children) {
|
|
|
+ var allstate = 0;
|
|
|
+ for (var i = 0, l = children.length; i < l; i++) {
|
|
|
+ var sNode = children[i];
|
|
|
+ allstate += sNode.checkstate
|
|
|
+ }
|
|
|
+ if (allstate === 0) {
|
|
|
+ pnode.checkstate = 0
|
|
|
+ } else if (allstate === 2 * l) {
|
|
|
+ pnode.checkstate = 2
|
|
|
+ } else {
|
|
|
+ pnode.checkstate = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var el = this.itemlist.find("[nodeid=" + pnode[idKey] + "]");
|
|
|
+ if (el.length) {
|
|
|
+ el.removeClass("halfchecked").removeClass("checked").addClass(this.setting.checkclsarr[pnode.checkstate])
|
|
|
+ }
|
|
|
+ setParentNodeCheckBox.call(this, pnode, pidkey, childKey, idKey)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ var compstack = {};
|
|
|
+ z.ui.listener = function(compid) {
|
|
|
+ if (!compid) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!compstack[compid]) {
|
|
|
+ compstack[compid] = new listener(compid)
|
|
|
+ }
|
|
|
+ return compstack[compid]
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function listener(id) {
|
|
|
+ this.stack = {}
|
|
|
+ }
|
|
|
+ listener.prototype.addListener = function(eventName, fun, param, funName) {
|
|
|
+ if (!this.stack[eventName]) {
|
|
|
+ this.stack[eventName] = {}
|
|
|
+ }
|
|
|
+ var funKey = fun;
|
|
|
+ if (funName != undefined) {
|
|
|
+ funKey = funName
|
|
|
+ }
|
|
|
+ if (!this.stack[eventName][funKey]) {
|
|
|
+ this.stack[eventName][funKey] = {}
|
|
|
+ }
|
|
|
+ this.stack[eventName][funKey].fun = fun;
|
|
|
+ this.stack[eventName][funKey].param = Array.prototype.slice.call(arguments, 2)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ listener.prototype.removeListener = function(eventName, fun, funName) {
|
|
|
+ var funKey = fun;
|
|
|
+ if (funName != undefined) {
|
|
|
+ funKey = funName
|
|
|
+ }
|
|
|
+ if (this.stack[eventName] && funKey) {
|
|
|
+ delete this.stack[eventName][funKey]
|
|
|
+ }
|
|
|
+ if (this.stack[eventName] && !funKey) {
|
|
|
+ delete this.stack[eventName]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ listener.prototype.getListener = function(eventName) {
|
|
|
+ return eventName ? this.stack[eventName] || {} : this.stack
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ listener.prototype.execListener = function(eventName, param) {
|
|
|
+ var paramFromExec = Array.prototype.slice.call(arguments, 1);
|
|
|
+ for (var fun_i in this.stack[eventName]) {
|
|
|
+ var funObj = this.stack[eventName][fun_i];
|
|
|
+ if (funObj.fun && typeof funObj.fun === "function") {
|
|
|
+ var _param = funObj.param === undefined ? new Array : funObj.param;
|
|
|
+ if (paramFromExec) {
|
|
|
+ _param = _param.concat(paramFromExec)
|
|
|
+ }
|
|
|
+ funObj.fun.apply(null, _param)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ var _ajax = jQuery.ajax;
|
|
|
+ jQuery.ajax = function(option) {
|
|
|
+ option.url = z.ui.comm.getEntranceUrl(option.url);
|
|
|
+ _ajax.call(this, option)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ var _winopen = window.open;
|
|
|
+ if (window.no_reset_window_open == true) {} else {
|
|
|
+ window.open = function() {
|
|
|
+ arguments[0] = z.ui.comm.getEntranceUrl(arguments[0]);
|
|
|
+ _winopen.apply(this, arguments)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ z.ui.ajax = function(option) {
|
|
|
+ var headers = {
|
|
|
+ "X-Requested-With": "XMLHttpRequest"
|
|
|
+ };
|
|
|
+ var aStr = localStorage.getItem('ACCESS_TOKEN');
|
|
|
+ if (aStr) {
|
|
|
+ headers['Authorization'] = 'Bearer ' + aStr;
|
|
|
+ }
|
|
|
+ var opt = $.extend(true, {
|
|
|
+ headers: headers,
|
|
|
+ type: "post",
|
|
|
+ contentType: "application/x-www-form-urlencoded",
|
|
|
+ dataType: "json",
|
|
|
+ data: {},
|
|
|
+ xhrFields: {
|
|
|
+ withCredentials: true
|
|
|
+ },
|
|
|
+ crossDomain: option.dataType === "jsonp",
|
|
|
+ showLoading: false
|
|
|
+ }, option);
|
|
|
+ if (opt.dataType === "jsonp") {
|
|
|
+ opt.jsonp = "jsonpcallback"
|
|
|
+ }
|
|
|
+ opt.success = function(res) {
|
|
|
+ if (opt.showLoading) {
|
|
|
+ z.ui.loading(false)
|
|
|
+ }
|
|
|
+ if (res && res.error_code) {
|
|
|
+ opt.error(null, res.msg, res)
|
|
|
+ } else {
|
|
|
+ option.success && option.success(res)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ opt.error = function(xhr, ts, err) {
|
|
|
+ if (opt.showLoading) {
|
|
|
+ z.ui.loading(false)
|
|
|
+ }
|
|
|
+ if (option.error) {
|
|
|
+ option.error(xhr, ts, err)
|
|
|
+ } else {
|
|
|
+ z.ui.alertError(ts)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ if (opt.showLoading) {
|
|
|
+ z.ui.loading(true, true)
|
|
|
+ }
|
|
|
+ $.ajax(opt)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.jsonpAjax = function(option) {
|
|
|
+ var opt = $.extend(true, {
|
|
|
+ dataType: "jsonp",
|
|
|
+ jsonp: "jsonpcallback"
|
|
|
+ }, option);
|
|
|
+ z.ui.ajax(opt)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.asynAll = function(option) {
|
|
|
+ var datas = []
|
|
|
+ , fncount = 0
|
|
|
+ , methods = option.methods || []
|
|
|
+ , all = function(index, data) {
|
|
|
+ datas[index] = data;
|
|
|
+ fncount++;
|
|
|
+ if (fncount == methods.length) {
|
|
|
+ option.all.apply(null, datas)
|
|
|
+ }
|
|
|
+ };
|
|
|
+ for (var i = 0, len = methods.length; i < len; i++) {
|
|
|
+ var mtdall = function(data) {
|
|
|
+ all(arguments.callee.index, data)
|
|
|
+ };
|
|
|
+ mtdall.index = i;
|
|
|
+ methods[i](mtdall)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ z.ui.tab = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = new tab(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function tab(selector) {
|
|
|
+ this.selector = selector
|
|
|
+ }
|
|
|
+ tab.prototype.init = function() {
|
|
|
+ var selector = this.selector
|
|
|
+ , isScroll = selector.hasClass("scroll")
|
|
|
+ , scroll = selector.find(">.z-tab-scroll")
|
|
|
+ , tabs = selector.find(">.z-tab-bar [z-tabindex]");
|
|
|
+ var _this = this;
|
|
|
+ this.tabbar = this.selector.children(".z-tab-bar");
|
|
|
+ this.eventQueues = {};
|
|
|
+ this.curTabIndex = -1;
|
|
|
+ this.tabs = tabs;
|
|
|
+ this.isclicktab = false;
|
|
|
+ selector.on("click", ">.z-tab-bar [z-tabindex]", function(event) {
|
|
|
+ var tabindex = $(this).attr("z-tabindex");
|
|
|
+ if ($(this).attr("z-trigger") !== "1" && _this.curTabIndex == tabindex)
|
|
|
+ return;
|
|
|
+ event.tabindex = tabindex;
|
|
|
+ event.link = this;
|
|
|
+ if (_this.dispatchEvents("onBeforeSelect", event) === false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var contents = scroll.find(">.z-tab-content");
|
|
|
+ _this.curTabIndex = tabindex;
|
|
|
+ if (isScroll) {
|
|
|
+ _this.isclicktab = true;
|
|
|
+ var sclTop = contents.eq(tabindex).offset().top - scroll.offset().top + scroll.scrollTop();
|
|
|
+ setTimeout(function() {
|
|
|
+ _this.isclicktab = false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ contents.eq(tabindex).addClass("on").siblings().removeClass("on");
|
|
|
+ var sclTop = 0
|
|
|
+ }
|
|
|
+ scroll.stop().animate({
|
|
|
+ scrollTop: sclTop + "px"
|
|
|
+ });
|
|
|
+ $(this).addClass("on").siblings().removeClass("on");
|
|
|
+ _this.dispatchEvents("onAfterSelect", event)
|
|
|
+ });
|
|
|
+ isScroll && scroll.on("scroll", function(event) {
|
|
|
+ if (_this.isclicktab == true)
|
|
|
+ return;
|
|
|
+ var sct = event.target.scrollTop
|
|
|
+ , tabindex = 0;
|
|
|
+ var hlist = []
|
|
|
+ , scrollH = scroll.height();
|
|
|
+ var contents = scroll.find(">.z-tab-content");
|
|
|
+ for (var i = 0, len = contents.length; i < len; i++) {
|
|
|
+ hlist.push(contents.eq(i).height() + (i == 0 ? -scrollH / 2 : hlist[i - 1]))
|
|
|
+ }
|
|
|
+ for (var i = 0, len = hlist.length - 1; i < len; i++) {
|
|
|
+ if (sct >= hlist[i] && sct < hlist[i + 1]) {
|
|
|
+ tabindex = i + 1;
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (event.tabindex != tabindex) {
|
|
|
+ event.tabindex = tabindex;
|
|
|
+ event.link = _this.tabs.eq(tabindex);
|
|
|
+ _this.curTabIndex = tabindex;
|
|
|
+ _this.dispatchEvents("onAfterSelect", event);
|
|
|
+ tabs.eq(tabindex).addClass("on").siblings().removeClass("on")
|
|
|
+ }
|
|
|
+ });
|
|
|
+ createScrollBar.call(this)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ var resizestack = [];
|
|
|
+ $(window).on("resize", function() {
|
|
|
+ $.each(resizestack, function(index, item) {
|
|
|
+ countScroll.call(this, false)
|
|
|
+ })
|
|
|
+ });
|
|
|
+ function createScrollBar() {
|
|
|
+ if (z.ui.comm.isMobile() || !this.selector.hasClass("cutover"))
|
|
|
+ return;
|
|
|
+ var _this = this;
|
|
|
+ resizestack.push(this);
|
|
|
+ this.tabs.each(function(i, tab) {
|
|
|
+ this.tabwidth = $(this).outerWidth();
|
|
|
+ this.tabindex = i;
|
|
|
+ this.ishidden = false
|
|
|
+ });
|
|
|
+ this.scrollleft = $('<div class="z-tabbar-scroller z-tabbar-scroller-left"><i class="fa fa-caret-left"></i></div>');
|
|
|
+ this.scrollright = $('<div class="z-tabbar-scroller z-tabbar-scroller-right"><i class="fa fa-caret-right"></i></div>');
|
|
|
+ this.tabbar.prepend(this.scrollleft);
|
|
|
+ this.tabbar.append(this.scrollright);
|
|
|
+ this.tabbar.on("mousewheel", function(event, delta) {
|
|
|
+ var originalEvent = event.originalEvent || {};
|
|
|
+ if (_this.isscrollrightshow && (originalEvent.wheelDelta < 0 || delta < 0)) {
|
|
|
+ _this.scrollright.trigger("click")
|
|
|
+ } else if (_this.isscrollleftshow && (originalEvent.wheelDelta > 0 || delta > 0)) {
|
|
|
+ _this.scrollleft.trigger("click")
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.scrollleft.on("click", function(e) {
|
|
|
+ countScroll.call(_this, true, getScrollStartIndex.call(_this, true) - 1)
|
|
|
+ });
|
|
|
+ this.scrollright.on("click", function(e) {
|
|
|
+ countScroll.call(_this, false, getScrollStartIndex.call(_this, false) + 1)
|
|
|
+ });
|
|
|
+ countScroll.call(this, true, 0)
|
|
|
+ }
|
|
|
+ function getScrollStartIndex(isleft) {
|
|
|
+ var i = isleft ? 0 : this.tabs.length - 1
|
|
|
+ , scrollindex = i;
|
|
|
+ while (this.tabs[i]) {
|
|
|
+ var tab = this.tabs[i];
|
|
|
+ if (!tab.ishidden) {
|
|
|
+ scrollindex = i;
|
|
|
+ break
|
|
|
+ }
|
|
|
+ isleft ? i++ : i--
|
|
|
+ }
|
|
|
+ return scrollindex
|
|
|
+ }
|
|
|
+ function scrollToTab(tab) {
|
|
|
+ var leftsidetabindex = getScrollStartIndex.call(this, true);
|
|
|
+ rightsidetabindex = getScrollStartIndex.call(this, false);
|
|
|
+ var tabindex = tab.tabindex;
|
|
|
+ if (tabindex < leftsidetabindex) {
|
|
|
+ countScroll.call(this, true, tabindex)
|
|
|
+ } else if (tabindex > rightsidetabindex) {
|
|
|
+ countScroll.call(this, false, tabindex)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function countScroll(isleft, startindex) {
|
|
|
+ var remainwidth = this.tabbar.width() - 1
|
|
|
+ , isscrollleftshow = false
|
|
|
+ , isscrollrightshow = false
|
|
|
+ , scrollerwidth = 0
|
|
|
+ , alltabslength = this.tabs.length
|
|
|
+ , alltabwidth = 0
|
|
|
+ , maxtabwidth = 0;
|
|
|
+ for (var i = 0; i < alltabslength; i++) {
|
|
|
+ var tab = this.tabs[i];
|
|
|
+ if (maxtabwidth < tab.tabwidth)
|
|
|
+ maxtabwidth = tab.tabwidth;
|
|
|
+ alltabwidth += tab.tabwidth
|
|
|
+ }
|
|
|
+ if (remainwidth < maxtabwidth) {
|
|
|
+ isscrollleftshow = false;
|
|
|
+ isscrollrightshow = false;
|
|
|
+ for (var i = 0; i < alltabslength; i++) {
|
|
|
+ var tab = this.tabs[i];
|
|
|
+ showTab(tab, false)
|
|
|
+ }
|
|
|
+ } else if (alltabwidth <= remainwidth) {
|
|
|
+ isscrollleftshow = false;
|
|
|
+ isscrollrightshow = false;
|
|
|
+ for (var i = 0; i < alltabslength; i++) {
|
|
|
+ var tab = this.tabs[i];
|
|
|
+ showTab(tab, true)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (isleft) {
|
|
|
+ startindex = startindex || 0;
|
|
|
+ if (startindex > 0) {
|
|
|
+ remainwidth -= scrollerwidth;
|
|
|
+ isscrollleftshow = true
|
|
|
+ } else {
|
|
|
+ isscrollleftshow = false
|
|
|
+ }
|
|
|
+ for (var i = 0; i < alltabslength; i++) {
|
|
|
+ var tab = this.tabs[i];
|
|
|
+ if (i < startindex) {
|
|
|
+ showTab(tab, false)
|
|
|
+ } else {
|
|
|
+ remainwidth -= tab.tabwidth;
|
|
|
+ if (remainwidth >= scrollerwidth) {
|
|
|
+ showTab(tab, true)
|
|
|
+ } else if (remainwidth < scrollerwidth && remainwidth >= 0) {
|
|
|
+ if (i == alltabslength - 1) {
|
|
|
+ showTab(tab, true);
|
|
|
+ isscrollrightshow = false
|
|
|
+ } else {
|
|
|
+ showTab(tab, false);
|
|
|
+ isscrollrightshow = true
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ showTab(tab, false);
|
|
|
+ isscrollrightshow = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ startindex = startindex || alltabslength - 1;
|
|
|
+ if (startindex < alltabslength - 1) {
|
|
|
+ remainwidth -= scrollerwidth;
|
|
|
+ isscrollrightshow = true
|
|
|
+ } else {
|
|
|
+ isscrollrightshow = false
|
|
|
+ }
|
|
|
+ for (var i = alltabslength - 1; i >= 0; i--) {
|
|
|
+ var tab = this.tabs[i];
|
|
|
+ if (i > startindex) {
|
|
|
+ showTab(tab, false)
|
|
|
+ } else {
|
|
|
+ remainwidth -= tab.tabwidth;
|
|
|
+ if (remainwidth >= scrollerwidth) {
|
|
|
+ showTab(tab, true)
|
|
|
+ } else if (remainwidth < scrollerwidth && remainwidth >= 0) {
|
|
|
+ if (i == alltabslength - 1) {
|
|
|
+ showTab(tab, true);
|
|
|
+ isscrollleftshow = false
|
|
|
+ } else {
|
|
|
+ showTab(tab, false);
|
|
|
+ isscrollleftshow = true
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ showTab(tab, false);
|
|
|
+ isscrollleftshow = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isscrollleftshow) {
|
|
|
+ this.scrollleft.show()
|
|
|
+ } else {
|
|
|
+ this.scrollleft.hide()
|
|
|
+ }
|
|
|
+ if (isscrollrightshow) {
|
|
|
+ this.scrollright.show()
|
|
|
+ } else {
|
|
|
+ this.scrollright.hide()
|
|
|
+ }
|
|
|
+ this.isscrollleftshow = isscrollleftshow;
|
|
|
+ this.isscrollrightshow = isscrollrightshow;
|
|
|
+ function showTab(tab, isshow) {
|
|
|
+ if (isshow && tab.ishidden == true) {
|
|
|
+ tab.ishidden = false;
|
|
|
+ $(tab).show()
|
|
|
+ } else if (!isshow && tab.ishidden == false) {
|
|
|
+ tab.ishidden = true;
|
|
|
+ $(tab).hide()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tab.prototype.bindEvents = function(events) {
|
|
|
+ var _this = this;
|
|
|
+ z.ui.comm.each(events, function(name, fn) {
|
|
|
+ if (!z.ui.comm.checkType(fn, "Function", true))
|
|
|
+ return;
|
|
|
+ _this.eventQueues[name] = fn
|
|
|
+ });
|
|
|
+ this.selector.find(">.z-tab-bar .on").trigger("click")
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ tab.prototype.dispatchEvents = function(fnname) {
|
|
|
+ if (this.eventQueues[fnname]) {
|
|
|
+ var args = Array.prototype.slice.call(arguments, 1);
|
|
|
+ return this.eventQueues[fnname].apply(null, args)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ tab.prototype.scrollTo = function(dis) {
|
|
|
+ this.scroll.scrollTop(dis)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ tab.prototype.tabSelect = function(tabindex) {
|
|
|
+ this.tabs.eq(tabindex).trigger("click");
|
|
|
+ var tab = this.tabs[tabindex];
|
|
|
+ if (!tab)
|
|
|
+ return;
|
|
|
+ if (tab.ishidden) {
|
|
|
+ scrollToTab.call(this, tab)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ z.ui.xxxx = function(selector) {}
|
|
|
+ ;
|
|
|
+ z.ui.events = function(instance, compclass) {
|
|
|
+ instance.eventQueues = {};
|
|
|
+ compclass.prototype.bindEvents = bindEvents;
|
|
|
+ compclass.prototype.dispatchEvents = dispatchEvents
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function bindEvents(events) {
|
|
|
+ var _this = this;
|
|
|
+ z.ui.comm.each(events, function(name, fn) {
|
|
|
+ if (!z.ui.comm.checkType(fn, "Function", true))
|
|
|
+ return;
|
|
|
+ _this.eventQueues[name] = fn
|
|
|
+ })
|
|
|
+ }
|
|
|
+ function dispatchEvents(fnname) {
|
|
|
+ if (this.eventQueues[fnname]) {
|
|
|
+ var args = Array.prototype.slice.call(arguments, 1);
|
|
|
+ return this.eventQueues[fnname].apply(null, args)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ z.ui.form = {};
|
|
|
+ z.ui.form.TypeSplit = "$";
|
|
|
+ z.ui.form.formBarSearch = function(selector) {
|
|
|
+ if (selector) {
|
|
|
+ var formbar = $(selector).find(".z-form-bar")
|
|
|
+ } else {
|
|
|
+ var formbar = $(".z-form-bar")
|
|
|
+ }
|
|
|
+ formbar.on("keypress", "[name] input:first-child", function(event) {
|
|
|
+ if (event.keyCode == 13) {
|
|
|
+ formbar.find(".z-search-btn").trigger("click")
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.form.getFormFields = function(selector, validateOption) {
|
|
|
+ if (!validateOption || validateOption.enable !== false) {
|
|
|
+ if (!z.ui.validate.validator(selector, validateOption)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var doms = $(selector || window).find("[name]")
|
|
|
+ , returnJson = {};
|
|
|
+ doms.each(function(index, item) {
|
|
|
+ var names = $(this).attr("name").split(z.ui.form.TypeSplit);
|
|
|
+ var tableName = names[0];
|
|
|
+ var fieldName = names[1];
|
|
|
+ if (!tableName || !fieldName)
|
|
|
+ return;
|
|
|
+ if (!returnJson[tableName]) {
|
|
|
+ returnJson[tableName] = {}
|
|
|
+ }
|
|
|
+ var reg = /z-comp-(?:[a-z0-9]+)/;
|
|
|
+ var exec = reg.exec(item.className);
|
|
|
+ if (exec) {
|
|
|
+ var copname = exec[0].split("-")[2];
|
|
|
+ if (z.ui[copname]) {
|
|
|
+ var value = z.ui[copname](item).getValue();
|
|
|
+ var valids = $(item).attr("z-validate");
|
|
|
+ if (valids && valids.indexOf("number") > -1) {
|
|
|
+ value = value == "" ? "-2147483648" : value
|
|
|
+ } else if (copname === "date" || copname === "dateTime") {
|
|
|
+ value = value == "" ? "0001-01-01" : value
|
|
|
+ }
|
|
|
+ SetValueToFiled(returnJson, tableName, fieldName, value)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ switch (this.nodeName.toUpperCase()) {
|
|
|
+ case "INPUT":
|
|
|
+ var type = $(this).attr("type").toUpperCase();
|
|
|
+ switch (type) {
|
|
|
+ case "CHECKBOX":
|
|
|
+ SetValueToFiled(returnJson, tableName, fieldName, this.checked ? 1 : 0);
|
|
|
+ break;
|
|
|
+ case "DATETIME":
|
|
|
+ SetValueToFiled(returnJson, tableName, fieldName, this.value == "" ? "0001-01-01" : this.value);
|
|
|
+ break;
|
|
|
+ case "NUMBER":
|
|
|
+ SetValueToFiled(returnJson, tableName, fieldName, this.value == "" ? "-2147483648" : this.value);
|
|
|
+ break;
|
|
|
+ case "TEXT":
|
|
|
+ SetValueToFiled(returnJson, tableName, fieldName, this.value);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ SetValueToFiled(returnJson, tableName, fieldName, this.value);
|
|
|
+ break
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "SELECT":
|
|
|
+ case "TEXTAREA":
|
|
|
+ SetValueToFiled(returnJson, tableName, fieldName, this.value);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return returnJson;
|
|
|
+ function SetValueToFiled(returnJson, tableName, fieldName, value) {
|
|
|
+ returnJson[tableName][fieldName] = value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.form.childStringify = function(pJsonObj) {
|
|
|
+ var pJsonObjCopy = $.parseJSON(JSON.stringify(pJsonObj));
|
|
|
+ for (var key in pJsonObjCopy) {
|
|
|
+ if (typeof pJsonObjCopy[key] != "string" && typeof pJsonObjCopy[key] != "function" && pJsonObjCopy[key] !== null && pJsonObjCopy[key] !== undefined) {
|
|
|
+ pJsonObjCopy[key] = JSON.stringify(pJsonObjCopy[key]).replace(/"null"/g, '""')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pJsonObjCopy
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.form.setFormFields = function(selector, data, option) {
|
|
|
+ var pselector = $(selector || window);
|
|
|
+ $.each(data, function(key, val) {
|
|
|
+ var tableName = key + z.ui.form.TypeSplit;
|
|
|
+ $.each(val, function(k, v) {
|
|
|
+ var name = key + z.ui.form.TypeSplit + k;
|
|
|
+ var item = pselector.find("[name='" + name + "']");
|
|
|
+ if (!item.length)
|
|
|
+ return;
|
|
|
+ var reg = /z-comp-(?:[a-z0-9]+)/;
|
|
|
+ var exec = reg.exec(item.get(0).className);
|
|
|
+ if (exec) {
|
|
|
+ var copname = exec[0].split("-")[2];
|
|
|
+ if (z.ui[copname]) {
|
|
|
+ var comp = z.ui[copname](item);
|
|
|
+ if (comp && comp.setValue) {
|
|
|
+ if (option && option.cover === false) {
|
|
|
+ var _v = comp.getValue();
|
|
|
+ if (_v === "" || _v === undefined || _v === null) {
|
|
|
+ comp.setValue(v)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ comp.setValue(v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ switch (item.get(0).nodeName.toUpperCase()) {
|
|
|
+ case "INPUT":
|
|
|
+ var type = item.attr("type").toUpperCase();
|
|
|
+ switch (type) {
|
|
|
+ case "CHECKBOX":
|
|
|
+ item.attr("checked", !!v);
|
|
|
+ break;
|
|
|
+ case "DATETIME":
|
|
|
+ case "NUMBER":
|
|
|
+ case "TEXT":
|
|
|
+ item.val(v);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ item.val(v);
|
|
|
+ break
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "SELECT":
|
|
|
+ case "TEXTAREA":
|
|
|
+ item.val(v);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.form.clearFormFields = function(selector) {
|
|
|
+ var doms = $(selector || window).find("[class*='z-comp-']");
|
|
|
+ doms.each(function(index, item) {
|
|
|
+ var reg = /z-comp-(?:[a-z0-9]+)/;
|
|
|
+ var exec = reg.exec(item.className);
|
|
|
+ if (exec) {
|
|
|
+ var copname = exec[0].split("-")[2];
|
|
|
+ if (z.ui[copname]) {
|
|
|
+ var comp = z.ui[copname](item);
|
|
|
+ if (comp && comp.setValue) {
|
|
|
+ comp.setValue("")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ switch (item.get(0).nodeName.toUpperCase()) {
|
|
|
+ case "INPUT":
|
|
|
+ var type = item.attr("type").toUpperCase();
|
|
|
+ switch (type) {
|
|
|
+ case "HIDDEN":
|
|
|
+ break;
|
|
|
+ case "CHECKBOX":
|
|
|
+ item.removeAttr("checked");
|
|
|
+ break;
|
|
|
+ case "DATETIME":
|
|
|
+ case "NUMBER":
|
|
|
+ case "TEXT":
|
|
|
+ item.val("");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ item.val("");
|
|
|
+ break
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "SELECT":
|
|
|
+ case "TEXTAREA":
|
|
|
+ item.val("");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.form.enable = function(selector) {
|
|
|
+ setEnable(selector, true)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.form.disabled = function(selector) {
|
|
|
+ setEnable(selector, false)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function setEnable(selector, enable) {
|
|
|
+ var doms = $(selector || window).find("[name]");
|
|
|
+ doms.each(function(index, item) {
|
|
|
+ var reg = /z-comp-(?:[a-z0-9]+)/;
|
|
|
+ var exec = reg.exec(item.className);
|
|
|
+ if (exec) {
|
|
|
+ var copname = exec[0].split("-")[2];
|
|
|
+ if (z.ui[copname]) {
|
|
|
+ var comp = z.ui[copname](item);
|
|
|
+ if (comp) {
|
|
|
+ if (enable && comp.enable) {
|
|
|
+ comp.enable()
|
|
|
+ } else if (!enable && comp.disabled) {
|
|
|
+ comp.disabled()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (enable) {
|
|
|
+ $(item).removeAttr("disabled")
|
|
|
+ } else {
|
|
|
+ $(item).attr("disabled", "disabled")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ z.ui.textarea = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = new textarea(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function textarea(selector) {
|
|
|
+ this.selector = selector
|
|
|
+ }
|
|
|
+ textarea.prototype.init = function() {
|
|
|
+ if (this.selector.hasClass("z-readonly")) {
|
|
|
+ this.selector.find("textarea").attr("readonly", "readonly")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ textarea.prototype.getValue = function() {
|
|
|
+ return this.selector.find("textarea").val()
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ textarea.prototype.setValue = function(val) {
|
|
|
+ val = z.ui.validate.filter(this.selector, val);
|
|
|
+ this.selector.find("textarea").val(val);
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ textarea.prototype.enable = function() {
|
|
|
+ this.selector.removeClass("z-readonly").find("textarea").removeAttr("readonly");
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ textarea.prototype.disabled = function() {
|
|
|
+ this.selector.addClass("z-readonly").find("textarea").attr("readonly", "readonly");
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.input = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = new input(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function input(selector) {
|
|
|
+ this.selector = selector
|
|
|
+ }
|
|
|
+ input.prototype.init = function(option) {
|
|
|
+ if (this.selector.hasClass("z-readonly")) {
|
|
|
+ this.selector.find("input").attr("readonly", "readonly")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ input.prototype.getValue = function() {
|
|
|
+ return this.selector.find("input").val()
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ input.prototype.setValue = function(val) {
|
|
|
+ val = z.ui.validate.filter(this.selector, val);
|
|
|
+ this.selector.find("input").val(val);
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ input.prototype.enable = function() {
|
|
|
+ this.selector.removeClass("z-readonly").find("input").removeAttr("readonly");
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ input.prototype.disabled = function() {
|
|
|
+ this.selector.addClass("z-readonly").find("input").attr("readonly", "readonly");
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.inputsearch = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = {
|
|
|
+ init: function(option) {
|
|
|
+ if (!z.ui.comm.isDingTalk()) {
|
|
|
+ selector.get(0).comp = new inputComp({
|
|
|
+ selector: selector,
|
|
|
+ comptype: "input",
|
|
|
+ search: true,
|
|
|
+ select: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ selector.get(0).comp = new inputComp({
|
|
|
+ selector: selector,
|
|
|
+ comptype: "input",
|
|
|
+ search: false,
|
|
|
+ select: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.inputselect = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = {
|
|
|
+ init: function(option) {
|
|
|
+ if (!z.ui.comm.isDingTalk()) {
|
|
|
+ selector.get(0).comp = new inputComp({
|
|
|
+ selector: selector,
|
|
|
+ comptype: "input",
|
|
|
+ search: true,
|
|
|
+ select: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ selector.get(0).comp = new mobileInputSelect({
|
|
|
+ selector: selector,
|
|
|
+ comptype: "input"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.select = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = {
|
|
|
+ init: function(option) {
|
|
|
+ if (!z.ui.comm.isDingTalk()) {
|
|
|
+ selector.get(0).comp = new selectComp({
|
|
|
+ selector: selector,
|
|
|
+ comptype: "select"
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ selector.get(0).comp = new mobileInputSelect({
|
|
|
+ selector: selector,
|
|
|
+ comptype: "select"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.selectsearch = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = {
|
|
|
+ init: function(option) {
|
|
|
+ if (!z.ui.comm.isDingTalk()) {
|
|
|
+ selector.get(0).comp = new selectComp({
|
|
|
+ selector: selector,
|
|
|
+ panelheight: 219,
|
|
|
+ comptype: "select",
|
|
|
+ search: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ selector.get(0).comp = new mobileInputSelect({
|
|
|
+ selector: selector,
|
|
|
+ comptype: "select"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.comm.inheritClass(inputComp, inputselect);
|
|
|
+ z.ui.comm.inheritClass(selectComp, inputselect);
|
|
|
+ z.ui.comm.inheritClass(selecttree, inputselect);
|
|
|
+ var compstack = {};
|
|
|
+ z.ui.selecttree = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = new selecttree(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function selecttree(selector) {
|
|
|
+ this.selector = $(selector);
|
|
|
+ this.iscomprender = false;
|
|
|
+ this.value = [];
|
|
|
+ this.valuenode = [];
|
|
|
+ this.placeholder = ""
|
|
|
+ }
|
|
|
+ selecttree.prototype.remove = function() {
|
|
|
+ this.iscomprender = false;
|
|
|
+ this.value = [];
|
|
|
+ this.valuenode = [];
|
|
|
+ this.placeholder = "";
|
|
|
+ this.dropdown.remove();
|
|
|
+ this.textbar.find("span").html("");
|
|
|
+ this.textbar.off("click");
|
|
|
+ this.dropdown.off("click")
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ selecttree.prototype.init = function(option) {
|
|
|
+ if (!option)
|
|
|
+ return;
|
|
|
+ if (this.iscomprender === true) {
|
|
|
+ this.remove()
|
|
|
+ }
|
|
|
+ var _this = this;
|
|
|
+ this.iscomprender = true;
|
|
|
+ option.comptype = "select";
|
|
|
+ option.view = option.view || {};
|
|
|
+ option.panelheight = option.panelheight || 242;
|
|
|
+ option.closebtn = true;
|
|
|
+ this.value = this.selector.attr("value");
|
|
|
+ if (!this.value) {
|
|
|
+ this.value = []
|
|
|
+ } else {
|
|
|
+ this.value = this.value.split(",")
|
|
|
+ }
|
|
|
+ inputselect.call(this, option);
|
|
|
+ this.textbar.click(function() {
|
|
|
+ _this.dropDown();
|
|
|
+ return false
|
|
|
+ });
|
|
|
+ this.dropdown.click(function() {
|
|
|
+ return false
|
|
|
+ });
|
|
|
+ var setting = $.extend(true, {
|
|
|
+ iselecttree: true,
|
|
|
+ onlychildren: true,
|
|
|
+ checkchildstate: 3,
|
|
|
+ view: {},
|
|
|
+ data: {
|
|
|
+ simpleData: {
|
|
|
+ idKey: "id"
|
|
|
+ },
|
|
|
+ key: {
|
|
|
+ name: "name"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ check: {
|
|
|
+ enable: false
|
|
|
+ },
|
|
|
+ callback: {}
|
|
|
+ }, option);
|
|
|
+ this.setting = setting;
|
|
|
+ this.placeholder = option.placeholder || this.selector.find(".z-inputselect-bar span").html();
|
|
|
+ if (setting.check && setting.check.enable === true) {
|
|
|
+ setting.callback.onCheck = function(event, treeId, treeNode) {
|
|
|
+ doCheck.call(_this);
|
|
|
+ if (option.callback && option.callback.onCheck && option.callback.onCheck.apply(this, arguments) === false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ setting.callback.onClick = function(event, treeId, treeNode) {
|
|
|
+ doSelect.call(_this);
|
|
|
+ if (option.callback && option.callback.onClick && option.callback.onClick.apply(this, arguments) === false) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ _this.dropdown.hide()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setting.callback.onLoadSuccess = function(treeid, treedata) {
|
|
|
+ var ztree = $.fn.zTree.getZTreeObj(treeid);
|
|
|
+ _this.tree = ztree;
|
|
|
+ if (ztree.setting.check.enable) {
|
|
|
+ if (_this.value.length > 0) {
|
|
|
+ _this.setValue(_this.value)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (_this.value) {
|
|
|
+ _this.setValue(_this.value[0])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ option.callback && option.callback.onLoadSuccess && option.callback.onLoadSuccess(treeid, treedata)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.ztree(this.dropdown).init(setting)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ selecttree.prototype.getValue = function(fieldname, onlychildren) {
|
|
|
+ if (onlychildren === undefined) {
|
|
|
+ onlychildren = this.setting.onlychildren
|
|
|
+ }
|
|
|
+ var checkchildstate = this.setting.checkchildstate
|
|
|
+ , field = fieldname || this.setting.data.simpleData.idKey;
|
|
|
+ if (this.setting.check.enable) {
|
|
|
+ if (!this.tree)
|
|
|
+ return [];
|
|
|
+ var nodes = this.tree.getCheckedNodes()
|
|
|
+ , valkey = [];
|
|
|
+ $.each(nodes, function(index, item) {
|
|
|
+ if (checkchildstate == 1 && item.check_Child_State != 1) {
|
|
|
+ return
|
|
|
+ } else if (checkchildstate == 2 && item.check_Child_State == 1) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (onlychildren) {
|
|
|
+ if (!item.isParent) {
|
|
|
+ valkey.push(item[field])
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ valkey.push(item[field])
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return valkey
|
|
|
+ } else {
|
|
|
+ var valkey = [];
|
|
|
+ if (!this.tree) {
|
|
|
+ valkey = this.value
|
|
|
+ } else {
|
|
|
+ var nodes = this.tree.getSelectedNodes();
|
|
|
+ $.each(nodes, function(index, item) {
|
|
|
+ valkey.push(item[field])
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return valkey[0] || null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ selecttree.prototype.setValue = function(ids) {
|
|
|
+ var fieldname = this.setting.data.key.name
|
|
|
+ , fieldkey = this.setting.data.simpleData.idKey
|
|
|
+ , valstr = [];
|
|
|
+ if (this.setting.check.enable) {
|
|
|
+ this.tree.checkAllNodes(false);
|
|
|
+ for (var i = 0, l = ids.length; i < l; i++) {
|
|
|
+ var node = this.tree.getNodeByParam(fieldkey, ids[i], null);
|
|
|
+ this.tree.checkNode(node, true, true)
|
|
|
+ }
|
|
|
+ doCheck.call(this)
|
|
|
+ } else {
|
|
|
+ this.tree.cancelSelectedNode();
|
|
|
+ var node = this.tree.getNodeByParam(fieldkey, ids, null);
|
|
|
+ this.tree.selectNode(node);
|
|
|
+ doSelect.call(this)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function doCheck() {
|
|
|
+ var nodes = this.tree.getCheckedNodes();
|
|
|
+ var fieldname = this.tree.setting.data.key.name
|
|
|
+ , valstr = [];
|
|
|
+ var checkchildstate = this.setting.checkchildstate
|
|
|
+ , onlychildren = this.setting.onlychildren;
|
|
|
+ $.each(nodes, function(index, item) {
|
|
|
+ if (checkchildstate == 1 && item.check_Child_State != 1) {
|
|
|
+ return
|
|
|
+ } else if (checkchildstate == 2 && item.check_Child_State == 1) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (onlychildren) {
|
|
|
+ if (!item.isParent) {
|
|
|
+ valstr.push(item[fieldname])
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ valstr.push(item[fieldname])
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.textbar.find("span").html(valstr.join(",") || this.placeholder)
|
|
|
+ }
|
|
|
+ function doSelect() {
|
|
|
+ var nodes = this.tree.getSelectedNodes();
|
|
|
+ var fieldname = this.tree.setting.data.key.name
|
|
|
+ , valstr = [];
|
|
|
+ $.each(nodes, function(index, item) {
|
|
|
+ valstr.push(item[fieldname])
|
|
|
+ });
|
|
|
+ this.textbar.find("span").html(valstr.join(",") || this.placeholder)
|
|
|
+ }
|
|
|
+ function inputComp(option) {
|
|
|
+ var _this = this;
|
|
|
+ this.selector = option.selector;
|
|
|
+ if (this.selector.hasClass("z-readonly")) {
|
|
|
+ this.selector.find("input").attr("readonly", "readonly")
|
|
|
+ }
|
|
|
+ inputselect.call(this, option);
|
|
|
+ this.textbar.find("i").click(function() {
|
|
|
+ if (!_this.isenable)
|
|
|
+ return;
|
|
|
+ _this.dropDown();
|
|
|
+ return false
|
|
|
+ });
|
|
|
+ this.dropdown.on("click", ".z-inputselect-dropdown-item", function() {
|
|
|
+ if (!_this.isenable)
|
|
|
+ return;
|
|
|
+ var $this = $(this);
|
|
|
+ var text = $this.text();
|
|
|
+ var obj;
|
|
|
+ $.each(_this.data, function(i, v) {
|
|
|
+ if (v.value === text.replace(new RegExp('"',"g"), """).replace(new RegExp("'","g"), "$#39;")) {
|
|
|
+ obj = v;
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (_this.dispatchEvents("onBeforeSelect", text, _this.data, obj) === false)
|
|
|
+ return false;
|
|
|
+ _this.textbar.find("input").val(text);
|
|
|
+ if (_this.dispatchEvents("onAfterSelect", text, _this.data, obj) === false)
|
|
|
+ return false;
|
|
|
+ _this.dropdown.hide();
|
|
|
+ return false
|
|
|
+ });
|
|
|
+ if (option.search) {
|
|
|
+ this.selector.find("input").on("input", function(event) {
|
|
|
+ if (!_this.isenable)
|
|
|
+ return;
|
|
|
+ var $this = $(this);
|
|
|
+ clearTimeout(_this.timer);
|
|
|
+ _this.timer = setTimeout(function() {
|
|
|
+ var _data = _this.dispatchEvents("onInput", $this.val(), _this.data);
|
|
|
+ if (!_data) {
|
|
|
+ _data = [];
|
|
|
+ $.each(_this.data, function(i, v) {
|
|
|
+ if (v.value.indexOf($this.val()) > -1) {
|
|
|
+ _data.push(v)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ _this.dropdown.find(".z-inputselect-dropdown-list").html(createDropDown(_data));
|
|
|
+ setDropPositon.call(_this);
|
|
|
+ _this.dropdown.show();
|
|
|
+ _this.dispatchEvents("onAfterInput", $this.val(), _this.data)
|
|
|
+ }, 100)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function selectComp(option) {
|
|
|
+ var _this = this;
|
|
|
+ this.selector = option.selector;
|
|
|
+ this.value = this.selector.attr("value");
|
|
|
+ inputselect.call(this, option);
|
|
|
+ var text = this.selector.find(".z-inputselect-bar span").html();
|
|
|
+ if (!text) {
|
|
|
+ text = z.ui.comm.getTextByValue(this.value, this.data);
|
|
|
+ this.selector.find(".z-inputselect-bar span").html(text)
|
|
|
+ }
|
|
|
+ if (!option.placeholder && !this.value) {
|
|
|
+ this.placeholder = text
|
|
|
+ } else {
|
|
|
+ this.placeholder = option.placeholder
|
|
|
+ }
|
|
|
+ this.textbar.click(function() {
|
|
|
+ if (!_this.isenable)
|
|
|
+ return;
|
|
|
+ _this.dropDown();
|
|
|
+ return false
|
|
|
+ });
|
|
|
+ this.dropdown.on("click", ".z-inputselect-dropdown-item", function() {
|
|
|
+ if (!_this.isenable)
|
|
|
+ return;
|
|
|
+ var $this = $(this);
|
|
|
+ var value = $this.attr("value");
|
|
|
+ var obj;
|
|
|
+ $.each(_this.data, function(i, v) {
|
|
|
+ if (v.value === value.replace(new RegExp('"',"g"), """).replace(new RegExp("'","g"), "$#39;")) {
|
|
|
+ obj = v;
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (_this.dispatchEvents("onBeforeSelect", value, _this.data, obj) === false)
|
|
|
+ return false;
|
|
|
+ var text = $this.text();
|
|
|
+ _this.textbar.find("span").html(_this.dispatchEvents("onSelectFilter", text, value, _this.data, obj) || text);
|
|
|
+ _this.value = value;
|
|
|
+ _this.dropdown.find(".checked").removeClass("checked");
|
|
|
+ $this.addClass("checked");
|
|
|
+ if (_this.dispatchEvents("onAfterSelect", _this.value, _this.data, obj) === false)
|
|
|
+ return false;
|
|
|
+ _this.dropdown.hide();
|
|
|
+ return false
|
|
|
+ });
|
|
|
+ if (option.search) {
|
|
|
+ this.dropdown.find(".z-inputselect-search").click(function() {
|
|
|
+ return false
|
|
|
+ });
|
|
|
+ this.selector.find("input").on("input propertychange", function(event) {
|
|
|
+ if (!_this.isenable)
|
|
|
+ return;
|
|
|
+ var $this = $(this);
|
|
|
+ clearTimeout(_this.timer);
|
|
|
+ _this.timer = setTimeout(function() {
|
|
|
+ var _data = _this.dispatchEvents("onInput", _this.value, _this.data);
|
|
|
+ if (!_data) {
|
|
|
+ _data = matchValue.call(_this, $this.val())
|
|
|
+ }
|
|
|
+ _this.dropdown.show().find(".z-inputselect-dropdown-list").html(createDropDown(_data, _this.value));
|
|
|
+ _this.dispatchEvents("onAfterInput", $this.val(), _this.data)
|
|
|
+ }, 200)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function matchValue(matcher) {
|
|
|
+ var _data = [];
|
|
|
+ for (var i = 0, len = this.data.length; i < len; i++) {
|
|
|
+ var value = this.data[i].text;
|
|
|
+ if (value == null || value === "")
|
|
|
+ continue;
|
|
|
+ var pinyin = z.ui.pinyinUtil.getPinyin(value, "", false, true).join("|").toLowerCase().replace(/\s+/g, "");
|
|
|
+ var fl = z.ui.pinyinUtil.getFirstLetter(value, true).join("|").toLowerCase();
|
|
|
+ if (pinyin.indexOf(matcher) > -1 || fl.indexOf(matcher) > -1 || value.indexOf(matcher) > -1) {
|
|
|
+ _data.push(this.data[i])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return _data
|
|
|
+ }
|
|
|
+ function inputselect(option) {
|
|
|
+ z.ui.events(this, inputselect);
|
|
|
+ var _this = this
|
|
|
+ , selector = this.selector;
|
|
|
+ var opt = this.option = $.extend(true, {
|
|
|
+ onBeforeShowPanel: function() {},
|
|
|
+ onAfterShowPanel: function() {},
|
|
|
+ onCloseBtnClick: function() {},
|
|
|
+ onBeforeSelect: function() {},
|
|
|
+ onAfterSelect: function() {}
|
|
|
+ }, option);
|
|
|
+ this.timer = null;
|
|
|
+ this.eventQueues.onBeforeShowPanel = opt.onBeforeShowPanel;
|
|
|
+ this.eventQueues.onAfterShowPanel = opt.onAfterShowPanel;
|
|
|
+ this.eventQueues.onBeforeSelect = opt.onBeforeSelect;
|
|
|
+ this.eventQueues.onAfterSelect = opt.onAfterSelect;
|
|
|
+ var data = selector.attr("data");
|
|
|
+ this.data = data ? JSON.parse(data) : [];
|
|
|
+ this.isenable = !selector.hasClass("z-readonly");
|
|
|
+ var isselsearch = this.option.isselsearch = opt.comptype == "select" && opt.search === true;
|
|
|
+ if (!option.panelheight) {
|
|
|
+ option.panelheight = this.data.length ? this.data.length * 30 + (isselsearch ? 39 : 0) : null
|
|
|
+ }
|
|
|
+ if (option.closebtn) {
|
|
|
+ $('<div class="z-select-closebtn">×</div>').appendTo(this.selector).click(function(event) {
|
|
|
+ _this.setValue("");
|
|
|
+ _this.option.onCloseBtnClick(event)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (opt.comptype == "select" || opt.select === true) {
|
|
|
+ var str = '<div class="z-inputselect-dropdown" style="' + (option.panelheight ? "height:" + option.panelheight + "px;" : "") + (option.panelwidth ? "width:" + option.panelwidth + "px;" : "") + '">';
|
|
|
+ if (isselsearch) {
|
|
|
+ str += '<div class="z-inputselect-search-bar"><div class="z-inputselect-search"><input class="z-inputselect-searchinput"/><i></i></div></div>'
|
|
|
+ }
|
|
|
+ str += '<div class="z-inputselect-dropdown-list z-position" style="' + (isselsearch ? "top:39px;" : "") + '">';
|
|
|
+ if (this.data) {
|
|
|
+ str += createDropDown(this.data, this.value)
|
|
|
+ }
|
|
|
+ str += "</div></div>";
|
|
|
+ selector.append(str)
|
|
|
+ }
|
|
|
+ this.dropdown = selector.find(".z-inputselect-dropdown");
|
|
|
+ this.textbar = selector.find(".z-inputselect-bar");
|
|
|
+ this.searchinput = selector.find(".z-inputselect-searchinput")
|
|
|
+ }
|
|
|
+ function createDropDown(data, value) {
|
|
|
+ var str = "";
|
|
|
+ $.each(data, function(index, item) {
|
|
|
+ if (typeof item.value === "string") {
|
|
|
+ item.value = item.value.replace(new RegExp('"',"g"), """).replace(new RegExp("'","g"), "$#39;")
|
|
|
+ }
|
|
|
+ str += "<div " + (item.title ? 'title="' + item.title + '"' : "") + ' value="' + (item.value === "" ? "" : item.value) + '" class="z-inputselect-dropdown-item ' + (value && item.value == value ? "checked" : "") + '">' + (item.text || item.value) + "</div>"
|
|
|
+ });
|
|
|
+ return str
|
|
|
+ }
|
|
|
+ function setDropPositon() {
|
|
|
+ var pmod = this.selector.closest(".z-modal-body")
|
|
|
+ , pscl = this.selector.closest(".z-tab-content")
|
|
|
+ , dh = this.dropdown.outerHeight()
|
|
|
+ , dw = this.dropdown.outerWidth();
|
|
|
+ var cmod;
|
|
|
+ if (pscl.length) {
|
|
|
+ cmod = pscl
|
|
|
+ } else if (pmod.length) {
|
|
|
+ cmod = pmod
|
|
|
+ }
|
|
|
+ if (cmod) {
|
|
|
+ var ob = cmod[0].clientHeight + cmod.offset().top - this.selector.offset().top - 34
|
|
|
+ } else {
|
|
|
+ var ob = document.documentElement.clientHeight - this.selector.offset().top - 34
|
|
|
+ }
|
|
|
+ if (cmod) {
|
|
|
+ var or = cmod[0].clientWidth + cmod.offset().left - this.selector.offset().left
|
|
|
+ } else {
|
|
|
+ var or = document.documentElement.clientWidth - this.selector.offset().left
|
|
|
+ }
|
|
|
+ var dl = -1, dr;
|
|
|
+ if (or < dw) {
|
|
|
+ dl += or - dw
|
|
|
+ }
|
|
|
+ if (dh < ob) {
|
|
|
+ this.dropdown.css({
|
|
|
+ left: dl + "px",
|
|
|
+ bottom: "auto",
|
|
|
+ top: "31px"
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ var ot = this.selector.offset().top - (cmod ? cmod.offset().top : 0);
|
|
|
+ if (dh < ot) {
|
|
|
+ this.dropdown.css({
|
|
|
+ left: dl + "px",
|
|
|
+ bottom: "31px",
|
|
|
+ top: "auto"
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ if (ob < ot) {
|
|
|
+ this.dropdown.css({
|
|
|
+ left: dl + "px",
|
|
|
+ bottom: "31px",
|
|
|
+ top: "auto",
|
|
|
+ height: ot + "px"
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.dropdown.css({
|
|
|
+ left: dl + "px",
|
|
|
+ bottom: "auto",
|
|
|
+ top: "31px",
|
|
|
+ height: ob + "px"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ inputselect.prototype.dropDown = function() {
|
|
|
+ if (!this.isenable)
|
|
|
+ return;
|
|
|
+ $(".z-inputselect-dropdown").not(this.dropdown).hide();
|
|
|
+ if (!this.dropdown.is(":hidden")) {
|
|
|
+ this.dropdown.hide()
|
|
|
+ } else {
|
|
|
+ if (this.dispatchEvents("onBeforeShowPanel", this.value, this.data) === false)
|
|
|
+ return;
|
|
|
+ setDropPositon.call(this);
|
|
|
+ this.dropdown.show();
|
|
|
+ var selitem = this.dropdown.find(".checked");
|
|
|
+ if (selitem.length) {
|
|
|
+ var lst = this.dropdown.find(".z-inputselect-dropdown-list");
|
|
|
+ var _ot = selitem.offset().top - lst.offset().top;
|
|
|
+ if (_ot < 0 || _ot > lst.outerHeight() - selitem.outerHeight()) {
|
|
|
+ lst.scrollTop(lst.scrollTop() + _ot)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.dropdown.find(".z-inputselect-searchinput").focus();
|
|
|
+ this.dispatchEvents("onAfterShowPanel", this.value, this.data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ inputselect.prototype.getValue = function() {
|
|
|
+ if (this.option.comptype == "input") {
|
|
|
+ return this.textbar.find("input").val()
|
|
|
+ } else if (this.option.comptype == "select") {
|
|
|
+ return this.value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ inputselect.prototype.getText = function() {
|
|
|
+ if (this.option.comptype == "input") {
|
|
|
+ return this.textbar.find("input").val()
|
|
|
+ } else if (this.option.comptype == "select") {
|
|
|
+ for (var i = 0, len = this.data.length; i < len; i++) {
|
|
|
+ if (this.value === this.data[i].value) {
|
|
|
+ return this.data[i].text
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ inputselect.prototype.setValue = function(val) {
|
|
|
+ if (this.option.comptype == "input") {
|
|
|
+ val = z.ui.validate.filter(this.selector, val);
|
|
|
+ this.textbar.find("input").val(val)
|
|
|
+ } else if (this.option.comptype == "select") {
|
|
|
+ this.value = val;
|
|
|
+ var _this = this;
|
|
|
+ var text = "";
|
|
|
+ _this.dropdown.find(".checked").removeClass("checked");
|
|
|
+ $.each(this.data, function(i, v) {
|
|
|
+ if (v.value === val) {
|
|
|
+ text = v.text;
|
|
|
+ _this.dropdown.find(".z-inputselect-dropdown-item").eq(i).addClass("checked")
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.textbar.find("span").html(text || this.placeholder || "")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ inputselect.prototype.enable = function(val) {
|
|
|
+ this.isenable = true;
|
|
|
+ this.selector.removeClass("z-readonly");
|
|
|
+ if (this.option.comptype == "input") {
|
|
|
+ this.textbar.find("input").removeAttr("readonly")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ inputselect.prototype.disabled = function(val) {
|
|
|
+ this.isenable = false;
|
|
|
+ this.selector.addClass("z-readonly");
|
|
|
+ if (this.option.comptype == "input") {
|
|
|
+ this.textbar.find("input").attr("readonly", "readonly")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function setSelectData(option, callback) {
|
|
|
+ if (option.url) {
|
|
|
+ var ajaxobj = {
|
|
|
+ url: option.url,
|
|
|
+ type: option.type,
|
|
|
+ data: option.data,
|
|
|
+ dataType: option.dataType || "json",
|
|
|
+ contentType: option.contentType || "application/x-www-form-urlencoded",
|
|
|
+ success: function(res) {
|
|
|
+ callback(res);
|
|
|
+ option.success && option.success(res)
|
|
|
+ },
|
|
|
+ error: function(xhr, ts, err) {
|
|
|
+ if (option.error) {
|
|
|
+ option.error.call(xhr, ts, err)
|
|
|
+ } else {
|
|
|
+ z.ui.alertError(ts)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if (ajaxobj.jsonp === true) {
|
|
|
+ ajaxobj.dataType = "jsonp";
|
|
|
+ z.ui.jsonpAjax(ajaxobj)
|
|
|
+ } else {
|
|
|
+ z.ui.ajax(ajaxobj)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ callback(option)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ inputselect.prototype.setSelectData = function(option) {
|
|
|
+ var _this = this;
|
|
|
+ setSelectData.call(this, option, function(data) {
|
|
|
+ _this.option.panelheight = (data.length ? data.length * 30 : 0) + (_this.option.isselsearch ? 39 : 0);
|
|
|
+ _this.data = data;
|
|
|
+ _this.dropdown.height(_this.option.panelheight).find(".z-inputselect-dropdown-list").html(createDropDown(data, _this.value))
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ if (!z.ui.comm.isDingTalk()) {
|
|
|
+ $(document).on("click", function() {
|
|
|
+ $(".z-inputselect-dropdown").hide()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ function mobileInputSelect(option) {
|
|
|
+ var _this = this;
|
|
|
+ this.selector = option.selector;
|
|
|
+ this.value = this.selector.attr("value");
|
|
|
+ var opt = this.option = $.extend(true, {
|
|
|
+ onBeforeShowPanel: function() {},
|
|
|
+ onAfterShowPanel: function() {},
|
|
|
+ onAfterSelect: function() {}
|
|
|
+ }, option);
|
|
|
+ z.ui.events(this, mobileInputSelect);
|
|
|
+ this.eventQueues.onBeforeShowPanel = opt.onBeforeShowPanel;
|
|
|
+ this.eventQueues.onAfterShowPanel = opt.onAfterShowPanel;
|
|
|
+ this.eventQueues.onAfterSelect = opt.onAfterSelect;
|
|
|
+ var data = this.selector.attr("data");
|
|
|
+ this.data = data ? JSON.parse(data) : [];
|
|
|
+ this.isenable = !this.selector.hasClass("z-readonly");
|
|
|
+ this.textbar = this.selector.find(".z-inputselect-bar");
|
|
|
+ if (option.comptype === "select") {
|
|
|
+ var text = this.selector.find(".z-inputselect-bar span").html();
|
|
|
+ if (!text) {
|
|
|
+ text = z.ui.comm.getTextByValue(this.value, this.data);
|
|
|
+ this.selector.find(".z-inputselect-bar span").html(text)
|
|
|
+ }
|
|
|
+ if (!option.placeholder && !this.value) {
|
|
|
+ this.placeholder = text
|
|
|
+ } else {
|
|
|
+ this.placeholder = option.placeholder
|
|
|
+ }
|
|
|
+ this.selector.click(function() {
|
|
|
+ _this.dropDown()
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.textbar.find("i").click(function() {
|
|
|
+ _this.dropDown();
|
|
|
+ return false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mobileInputSelect.prototype.dropDown = function() {
|
|
|
+ if (!this.isenable)
|
|
|
+ return;
|
|
|
+ if (this.dispatchEvents("onBeforeShowPanel", this.value, this.data) === false)
|
|
|
+ return;
|
|
|
+ var _this = this
|
|
|
+ , source = [];
|
|
|
+ if (this.option.comptype === "select") {
|
|
|
+ $.each(this.data, function(i, v) {
|
|
|
+ source.push({
|
|
|
+ key: v.text,
|
|
|
+ value: v.value
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ $.each(this.data, function(i, v) {
|
|
|
+ source.push({
|
|
|
+ key: v.value,
|
|
|
+ value: v.value
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ dd.biz.util.chosen({
|
|
|
+ source: source,
|
|
|
+ selectedKey: _this.getText(),
|
|
|
+ onSuccess: function(result) {
|
|
|
+ _this.setValue(result.value);
|
|
|
+ _this.dispatchEvents("onAfterSelect", result.value, _this.data, {
|
|
|
+ text: result.key,
|
|
|
+ value: result.value
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onFail: function(err) {}
|
|
|
+ });
|
|
|
+ this.dispatchEvents("onAfterShowPanel", this.value, this.data)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ mobileInputSelect.prototype.getValue = function() {
|
|
|
+ if (this.option.comptype == "input") {
|
|
|
+ return this.textbar.find("input").val()
|
|
|
+ } else if (this.option.comptype == "select") {
|
|
|
+ return this.value
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ mobileInputSelect.prototype.getText = function() {
|
|
|
+ if (this.option.comptype == "input") {
|
|
|
+ return this.textbar.find("input").val()
|
|
|
+ } else if (this.option.comptype == "select") {
|
|
|
+ for (var i = 0, len = this.data.length; i < len; i++) {
|
|
|
+ if (this.value === this.data[i].value) {
|
|
|
+ return this.data[i].text
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ mobileInputSelect.prototype.setValue = function(val) {
|
|
|
+ if (this.option.comptype == "input") {
|
|
|
+ val = z.ui.validate.filter(this.selector, val);
|
|
|
+ this.textbar.find("input").val(val)
|
|
|
+ } else if (this.option.comptype == "select") {
|
|
|
+ this.value = val;
|
|
|
+ var _this = this;
|
|
|
+ var text = "";
|
|
|
+ $.each(this.data, function(i, v) {
|
|
|
+ if (v.value === val) {
|
|
|
+ text = v.text;
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.textbar.find("span").html(text || this.placeholder || "")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ mobileInputSelect.prototype.enable = function(val) {
|
|
|
+ this.isenable = true;
|
|
|
+ this.selector.removeClass("z-readonly");
|
|
|
+ if (this.option.comptype == "input") {
|
|
|
+ this.textbar.find("input").removeAttr("readonly")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ mobileInputSelect.prototype.disabled = function(val) {
|
|
|
+ this.isenable = false;
|
|
|
+ this.selector.addClass("z-readonly");
|
|
|
+ if (this.option.comptype == "input") {
|
|
|
+ this.textbar.find("input").attr("readonly", "readonly")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ mobileInputSelect.prototype.setSelectData = function(option) {
|
|
|
+ setSelectData.call(this, option)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ mobileInputSelect.prototype.setSelectData = function(option) {
|
|
|
+ var _this = this;
|
|
|
+ setSelectData.call(this, option, function(data) {
|
|
|
+ _this.data = data
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ z.ui.radio = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = new radio(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function radio(selector) {
|
|
|
+ this.isenable = !selector.hasClass("z-readonly");
|
|
|
+ this.selector = selector;
|
|
|
+ this.value = "";
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ radio.prototype.init = function() {
|
|
|
+ z.ui.events(this, radio);
|
|
|
+ var selector = this.selector
|
|
|
+ , _this = this;
|
|
|
+ this.value = selector.find(".checked").attr("value");
|
|
|
+ selector.find(".z-radio-item").click(function() {
|
|
|
+ if (!_this.isenable) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (_this.dispatchEvents("onBeforeChange", _this.value) === false)
|
|
|
+ return;
|
|
|
+ selector.find(".checked").removeClass("checked");
|
|
|
+ $(this).addClass("checked");
|
|
|
+ _this.value = $(this).attr("value");
|
|
|
+ _this.dispatchEvents("onAfterChange", _this.value)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ radio.prototype.getValue = function() {
|
|
|
+ var val = "";
|
|
|
+ this.selector.find(".z-radio-item").each(function(i, v) {
|
|
|
+ if ($(v).hasClass("checked")) {
|
|
|
+ val = $(v).attr("value")
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return val
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ radio.prototype.setValue = function(val) {
|
|
|
+ var dom;
|
|
|
+ this.selector.find(".z-radio-item").each(function(i, v) {
|
|
|
+ if ($(v).attr("value") == val) {
|
|
|
+ dom = $(v)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!dom) {
|
|
|
+ this.selector.find(".checked").removeClass("checked")
|
|
|
+ } else {
|
|
|
+ this.selector.find(".checked").removeClass("checked");
|
|
|
+ dom.addClass("checked")
|
|
|
+ }
|
|
|
+ this.value = val;
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ radio.prototype.enable = function() {
|
|
|
+ this.isenable = true;
|
|
|
+ this.selector.removeClass("z-readonly");
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ radio.prototype.disabled = function() {
|
|
|
+ this.isenable = false;
|
|
|
+ this.selector.addClass("z-readonly");
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.checkbox = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = new checkbox(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function checkbox(selector) {
|
|
|
+ this.selector = selector;
|
|
|
+ this.isenable = !selector.hasClass("z-readonly");
|
|
|
+ this.value = ""
|
|
|
+ }
|
|
|
+ checkbox.prototype.init = function() {
|
|
|
+ z.ui.events(this, checkbox);
|
|
|
+ var selector = this.selector
|
|
|
+ , _this = this;
|
|
|
+ this.checkbox = selector.find(".z-checkbox-item");
|
|
|
+ this.value = this.checkbox.hasClass("checked") ? 1 : 0;
|
|
|
+ this.checkbox.click(function() {
|
|
|
+ if (!_this.isenable) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (_this.dispatchEvents("onBeforeChange", _this.value) === false)
|
|
|
+ return;
|
|
|
+ $(this).toggleClass("checked");
|
|
|
+ _this.value = _this.value == 1 ? 0 : 1;
|
|
|
+ _this.dispatchEvents("onAfterChange", _this.value)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ checkbox.prototype.getValue = function() {
|
|
|
+ return this.checkbox.hasClass("checked") ? 1 : 0
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ checkbox.prototype.setValue = function(val) {
|
|
|
+ if (!val) {
|
|
|
+ this.value = 0;
|
|
|
+ this.checkbox.removeClass("checked")
|
|
|
+ } else {
|
|
|
+ this.value = 1;
|
|
|
+ this.checkbox.addClass("checked")
|
|
|
+ }
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ checkbox.prototype.enable = function() {
|
|
|
+ this.isenable = true;
|
|
|
+ this.selector.removeClass("z-readonly");
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ checkbox.prototype.disabled = function() {
|
|
|
+ this.isenable = false;
|
|
|
+ this.selector.addClass("z-readonly");
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.switchbtn = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = new switchbtn(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function switchbtn(selector) {
|
|
|
+ this.selector = selector;
|
|
|
+ this.isenable = !selector.hasClass("z-readonly");
|
|
|
+ this.value = ""
|
|
|
+ }
|
|
|
+ switchbtn.prototype.init = function() {
|
|
|
+ z.ui.events(this, switchbtn);
|
|
|
+ var selector = this.selector
|
|
|
+ , _this = this;
|
|
|
+ this.value = this.selector.hasClass("off") ? 0 : 1;
|
|
|
+ this.selector.click(function() {
|
|
|
+ if (!_this.isenable) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (_this.dispatchEvents("onBeforeChange", _this.value) === false)
|
|
|
+ return;
|
|
|
+ $(this).toggleClass("off");
|
|
|
+ _this.value = _this.value == 1 ? 0 : 1;
|
|
|
+ _this.dispatchEvents("onAfterChange", _this.value)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ switchbtn.prototype.getValue = function() {
|
|
|
+ return this.selector.hasClass("off") ? 0 : 1
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ switchbtn.prototype.setValue = function(val) {
|
|
|
+ if (!val) {
|
|
|
+ this.value = 0;
|
|
|
+ this.selector.addClass("off")
|
|
|
+ } else {
|
|
|
+ this.value = 1;
|
|
|
+ this.selector.removeClass("off")
|
|
|
+ }
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ switchbtn.prototype.enable = function() {
|
|
|
+ this.isenable = true;
|
|
|
+ this.selector.removeClass("z-readonly");
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ switchbtn.prototype.disabled = function() {
|
|
|
+ this.isenable = false;
|
|
|
+ this.selector.addClass("z-readonly");
|
|
|
+ return this
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+!function() {
|
|
|
+ "use strict";
|
|
|
+ var isLayui = window.layui && layui.define
|
|
|
+ , ready = {
|
|
|
+ getPath: function() {
|
|
|
+ var jsPath = document.currentScript ? document.currentScript.src : function() {
|
|
|
+ var js = document.scripts, last = js.length - 1, src;
|
|
|
+ for (var i = last; i > 0; i--) {
|
|
|
+ if (js[i].readyState === "interactive") {
|
|
|
+ src = js[i].src;
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return src || js[last].src
|
|
|
+ }();
|
|
|
+ return jsPath.substring(0, jsPath.lastIndexOf("/") + 1)
|
|
|
+ }(),
|
|
|
+ getStyle: function(node, name) {
|
|
|
+ var style = node.currentStyle ? node.currentStyle : window.getComputedStyle(node, null);
|
|
|
+ return style[style.getPropertyValue ? "getPropertyValue" : "getAttribute"](name)
|
|
|
+ },
|
|
|
+ link: function(href, fn, cssname) {
|
|
|
+ if (!laydate.path)
|
|
|
+ return;
|
|
|
+ var head = document.getElementsByTagName("head")[0]
|
|
|
+ , link = document.createElement("link");
|
|
|
+ if (typeof fn === "string")
|
|
|
+ cssname = fn;
|
|
|
+ var app = (cssname || href).replace(/\.|\//g, "");
|
|
|
+ var id = "layuicss-" + app
|
|
|
+ , timeout = 0;
|
|
|
+ link.rel = "stylesheet";
|
|
|
+ link.href = laydate.path + href;
|
|
|
+ link.id = id;
|
|
|
+ if (!document.getElementById(id)) {
|
|
|
+ head.appendChild(link)
|
|
|
+ }
|
|
|
+ if (typeof fn !== "function")
|
|
|
+ return;
|
|
|
+ (function poll() {
|
|
|
+ if (++timeout > 8 * 1e3 / 100) {
|
|
|
+ return window.console && console.error("laydate.css: Invalid")
|
|
|
+ }
|
|
|
+ parseInt(ready.getStyle(document.getElementById(id), "width")) === 1989 ? fn() : setTimeout(poll, 100)
|
|
|
+ }
|
|
|
+ )()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ , laydate = {
|
|
|
+ v: "5.0.9",
|
|
|
+ config: {},
|
|
|
+ index: window.laydate && window.laydate.v ? 1e5 : 0,
|
|
|
+ path: ready.getPath,
|
|
|
+ set: function(options) {
|
|
|
+ var that = this;
|
|
|
+ that.config = lay.extend({}, that.config, options);
|
|
|
+ return that
|
|
|
+ },
|
|
|
+ ready: function(fn) {
|
|
|
+ fn();
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ }
|
|
|
+ , thisDate = function() {
|
|
|
+ var that = this;
|
|
|
+ return {
|
|
|
+ hint: function(content) {
|
|
|
+ that.hint.call(that, content)
|
|
|
+ },
|
|
|
+ config: that.config
|
|
|
+ }
|
|
|
+ }
|
|
|
+ , MOD_NAME = "laydate"
|
|
|
+ , ELEM = ".layui-laydate"
|
|
|
+ , THIS = "layui-this"
|
|
|
+ , SHOW = "layui-show"
|
|
|
+ , HIDE = "layui-hide"
|
|
|
+ , DISABLED = "laydate-disabled"
|
|
|
+ , TIPS_OUT = "开始日期超出了结束日期<br>建议重新选择"
|
|
|
+ , LIMIT_YEAR = [100, 2e5]
|
|
|
+ , ELEM_STATIC = "layui-laydate-static"
|
|
|
+ , ELEM_LIST = "layui-laydate-list"
|
|
|
+ , ELEM_SELECTED = "laydate-selected"
|
|
|
+ , ELEM_HINT = "layui-laydate-hint"
|
|
|
+ , ELEM_PREV = "laydate-day-prev"
|
|
|
+ , ELEM_NEXT = "laydate-day-next"
|
|
|
+ , ELEM_FOOTER = "layui-laydate-footer"
|
|
|
+ , ELEM_CONFIRM = ".laydate-btns-confirm"
|
|
|
+ , ELEM_TIME_TEXT = "laydate-time-text"
|
|
|
+ , ELEM_TIME_BTN = ".laydate-btns-time"
|
|
|
+ , Class = function(options) {
|
|
|
+ var that = this;
|
|
|
+ that.index = ++laydate.index;
|
|
|
+ that.config = lay.extend({}, that.config, laydate.config, options);
|
|
|
+ laydate.ready(function() {
|
|
|
+ that.init()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ , lay = function(selector) {
|
|
|
+ return new LAY(selector)
|
|
|
+ }
|
|
|
+ , LAY = function(selector) {
|
|
|
+ var index = 0
|
|
|
+ , nativeDOM = typeof selector === "object" ? [selector] : (this.selector = selector,
|
|
|
+ document.querySelectorAll(selector || null));
|
|
|
+ for (; index < nativeDOM.length; index++) {
|
|
|
+ this.push(nativeDOM[index])
|
|
|
+ }
|
|
|
+ };
|
|
|
+ LAY.prototype = [];
|
|
|
+ LAY.prototype.constructor = LAY;
|
|
|
+ lay.extend = function() {
|
|
|
+ var ai = 1
|
|
|
+ , args = arguments
|
|
|
+ , clone = function(target, obj) {
|
|
|
+ target = target || (obj.constructor === Array ? [] : {});
|
|
|
+ for (var i in obj) {
|
|
|
+ target[i] = obj[i] && obj[i].constructor === Object ? clone(target[i], obj[i]) : obj[i]
|
|
|
+ }
|
|
|
+ return target
|
|
|
+ };
|
|
|
+ args[0] = typeof args[0] === "object" ? args[0] : {};
|
|
|
+ for (; ai < args.length; ai++) {
|
|
|
+ if (typeof args[ai] === "object") {
|
|
|
+ clone(args[0], args[ai])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return args[0]
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ lay.ie = function() {
|
|
|
+ var agent = navigator.userAgent.toLowerCase();
|
|
|
+ return !!window.ActiveXObject || "ActiveXObject"in window ? (agent.match(/msie\s(\d+)/) || [])[1] || "11" : false
|
|
|
+ }();
|
|
|
+ lay.stope = function(e) {
|
|
|
+ e = e || window.event;
|
|
|
+ e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ lay.each = function(obj, fn) {
|
|
|
+ var key, that = this;
|
|
|
+ if (typeof fn !== "function")
|
|
|
+ return that;
|
|
|
+ obj = obj || [];
|
|
|
+ if (obj.constructor === Object) {
|
|
|
+ for (key in obj) {
|
|
|
+ if (fn.call(obj[key], key, obj[key]))
|
|
|
+ break
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (key = 0; key < obj.length; key++) {
|
|
|
+ if (fn.call(obj[key], key, obj[key]))
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return that
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ lay.digit = function(num, length, end) {
|
|
|
+ var str = "";
|
|
|
+ num = String(num);
|
|
|
+ length = length || 2;
|
|
|
+ for (var i = num.length; i < length; i++) {
|
|
|
+ str += "0"
|
|
|
+ }
|
|
|
+ return num < Math.pow(10, length) ? str + (num | 0) : num
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ lay.elem = function(elemName, attr) {
|
|
|
+ var elem = document.createElement(elemName);
|
|
|
+ lay.each(attr || {}, function(key, value) {
|
|
|
+ elem.setAttribute(key, value)
|
|
|
+ });
|
|
|
+ return elem
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.addStr = function(str, new_str) {
|
|
|
+ str = str.replace(/\s+/, " ");
|
|
|
+ new_str = new_str.replace(/\s+/, " ").split(" ");
|
|
|
+ lay.each(new_str, function(ii, item) {
|
|
|
+ if (!new RegExp("\\b" + item + "\\b").test(str)) {
|
|
|
+ str = str + " " + item
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return str.replace(/^\s|\s$/, "")
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.removeStr = function(str, new_str) {
|
|
|
+ str = str.replace(/\s+/, " ");
|
|
|
+ new_str = new_str.replace(/\s+/, " ").split(" ");
|
|
|
+ lay.each(new_str, function(ii, item) {
|
|
|
+ var exp = new RegExp("\\b" + item + "\\b");
|
|
|
+ if (exp.test(str)) {
|
|
|
+ str = str.replace(exp, "")
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return str.replace(/\s+/, " ").replace(/^\s|\s$/, "")
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.prototype.find = function(selector) {
|
|
|
+ var that = this;
|
|
|
+ var index = 0
|
|
|
+ , arr = []
|
|
|
+ , isObject = typeof selector === "object";
|
|
|
+ this.each(function(i, item) {
|
|
|
+ var nativeDOM = isObject ? [selector] : item.querySelectorAll(selector || null);
|
|
|
+ for (; index < nativeDOM.length; index++) {
|
|
|
+ arr.push(nativeDOM[index])
|
|
|
+ }
|
|
|
+ that.shift()
|
|
|
+ });
|
|
|
+ if (!isObject) {
|
|
|
+ that.selector = (that.selector ? that.selector + " " : "") + selector
|
|
|
+ }
|
|
|
+ lay.each(arr, function(i, item) {
|
|
|
+ that.push(item)
|
|
|
+ });
|
|
|
+ return that
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.prototype.each = function(fn) {
|
|
|
+ return lay.each.call(this, this, fn)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.prototype.addClass = function(className, type) {
|
|
|
+ return this.each(function(index, item) {
|
|
|
+ item.className = LAY[type ? "removeStr" : "addStr"](item.className, className)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.prototype.removeClass = function(className) {
|
|
|
+ return this.addClass(className, true)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.prototype.hasClass = function(className) {
|
|
|
+ var has = false;
|
|
|
+ this.each(function(index, item) {
|
|
|
+ if (new RegExp("\\b" + className + "\\b").test(item.className)) {
|
|
|
+ has = true
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return has
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.prototype.attr = function(key, value) {
|
|
|
+ var that = this;
|
|
|
+ return value === undefined ? function() {
|
|
|
+ if (that.length > 0)
|
|
|
+ return that[0].getAttribute(key)
|
|
|
+ }() : that.each(function(index, item) {
|
|
|
+ item.setAttribute(key, value)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.prototype.removeAttr = function(key) {
|
|
|
+ return this.each(function(index, item) {
|
|
|
+ item.removeAttribute(key)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.prototype.html = function(html) {
|
|
|
+ return this.each(function(index, item) {
|
|
|
+ item.innerHTML = html
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.prototype.val = function(value) {
|
|
|
+ return this.each(function(index, item) {
|
|
|
+ item.value = value
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.prototype.append = function(elem) {
|
|
|
+ return this.each(function(index, item) {
|
|
|
+ typeof elem === "object" ? item.appendChild(elem) : item.innerHTML = item.innerHTML + elem
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.prototype.remove = function(elem) {
|
|
|
+ return this.each(function(index, item) {
|
|
|
+ elem ? item.removeChild(elem) : item.parentNode.removeChild(item)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.prototype.on = function(eventName, fn) {
|
|
|
+ return this.each(function(index, item) {
|
|
|
+ item.attachEvent ? item.attachEvent("on" + eventName, function(e) {
|
|
|
+ e.target = e.srcElement;
|
|
|
+ fn.call(item, e)
|
|
|
+ }) : item.addEventListener(eventName, fn, false)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ LAY.prototype.off = function(eventName, fn) {
|
|
|
+ return this.each(function(index, item) {
|
|
|
+ item.detachEvent ? item.detachEvent("on" + eventName, fn) : item.removeEventListener(eventName, fn, false)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.isLeapYear = function(year) {
|
|
|
+ return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.config = {
|
|
|
+ type: "date",
|
|
|
+ range: false,
|
|
|
+ format: "yyyy-MM-dd",
|
|
|
+ value: null,
|
|
|
+ min: "1900-1-1",
|
|
|
+ max: "2099-12-31",
|
|
|
+ trigger: "focus",
|
|
|
+ show: false,
|
|
|
+ showBottom: true,
|
|
|
+ btns: ["clear", "now", "confirm"],
|
|
|
+ lang: "cn",
|
|
|
+ theme: "default",
|
|
|
+ position: null,
|
|
|
+ calendar: false,
|
|
|
+ mark: {},
|
|
|
+ zIndex: null,
|
|
|
+ done: null,
|
|
|
+ change: null
|
|
|
+ };
|
|
|
+ Class.prototype.lang = function() {
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , text = {
|
|
|
+ cn: {
|
|
|
+ weeks: ["日", "一", "二", "三", "四", "五", "六"],
|
|
|
+ time: ["时", "分", "秒"],
|
|
|
+ timeTips: "选择时间",
|
|
|
+ startTime: "开始时间",
|
|
|
+ endTime: "结束时间",
|
|
|
+ dateTips: "返回日期",
|
|
|
+ month: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二"],
|
|
|
+ tools: {
|
|
|
+ confirm: "确定",
|
|
|
+ clear: "清空",
|
|
|
+ now: "现在"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ en: {
|
|
|
+ weeks: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
|
|
|
+ time: ["Hours", "Minutes", "Seconds"],
|
|
|
+ timeTips: "Select Time",
|
|
|
+ startTime: "Start Time",
|
|
|
+ endTime: "End Time",
|
|
|
+ dateTips: "Select Date",
|
|
|
+ month: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
|
|
+ tools: {
|
|
|
+ confirm: "Confirm",
|
|
|
+ clear: "Clear",
|
|
|
+ now: "Now"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return text[options.lang] || text["cn"]
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.init = function() {
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , dateType = "yyyy|y|MM|M|dd|d|HH|H|mm|m|ss|s"
|
|
|
+ , isStatic = options.position === "static"
|
|
|
+ , format = {
|
|
|
+ year: "yyyy",
|
|
|
+ month: "yyyy-MM",
|
|
|
+ date: "yyyy-MM-dd",
|
|
|
+ time: "HH:mm:ss",
|
|
|
+ datetime: "yyyy-MM-dd HH:mm:ss"
|
|
|
+ };
|
|
|
+ options.elem = lay(options.elem);
|
|
|
+ options.eventElem = lay(options.eventElem);
|
|
|
+ if (!options.elem[0])
|
|
|
+ return;
|
|
|
+ if (options.range === true)
|
|
|
+ options.range = "-";
|
|
|
+ if (options.format === format.date) {
|
|
|
+ options.format = format[options.type]
|
|
|
+ }
|
|
|
+ that.format = options.format.match(new RegExp(dateType + "|.","g")) || [];
|
|
|
+ that.EXP_IF = "";
|
|
|
+ that.EXP_SPLIT = "";
|
|
|
+ lay.each(that.format, function(i, item) {
|
|
|
+ var EXP = new RegExp(dateType).test(item) ? "\\d{" + function() {
|
|
|
+ if (new RegExp(dateType).test(that.format[i === 0 ? i + 1 : i - 1] || "")) {
|
|
|
+ if (/^yyyy|y$/.test(item))
|
|
|
+ return 4;
|
|
|
+ return item.length
|
|
|
+ }
|
|
|
+ if (/^yyyy$/.test(item))
|
|
|
+ return "1,4";
|
|
|
+ if (/^y$/.test(item))
|
|
|
+ return "1,308";
|
|
|
+ return "1,2"
|
|
|
+ }() + "}" : "\\" + item;
|
|
|
+ that.EXP_IF = that.EXP_IF + EXP;
|
|
|
+ that.EXP_SPLIT = that.EXP_SPLIT + "(" + EXP + ")"
|
|
|
+ });
|
|
|
+ that.EXP_IF = new RegExp("^" + (options.range ? that.EXP_IF + "\\s\\" + options.range + "\\s" + that.EXP_IF : that.EXP_IF) + "$");
|
|
|
+ that.EXP_SPLIT = new RegExp("^" + that.EXP_SPLIT + "$","");
|
|
|
+ if (!that.isInput(options.elem[0])) {
|
|
|
+ if (options.trigger === "focus") {
|
|
|
+ options.trigger = "click"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ options.elem.attr("lay-key", that.index);
|
|
|
+ options.eventElem.attr("lay-key", that.index);
|
|
|
+ options.mark = lay.extend({}, options.calendar && options.lang === "cn" ? {
|
|
|
+ "0-1-1": "元旦",
|
|
|
+ "0-2-14": "情人",
|
|
|
+ "0-3-8": "妇女",
|
|
|
+ "0-3-12": "植树",
|
|
|
+ "0-4-1": "愚人",
|
|
|
+ "0-5-1": "劳动",
|
|
|
+ "0-5-4": "青年",
|
|
|
+ "0-6-1": "儿童",
|
|
|
+ "0-9-10": "教师",
|
|
|
+ "0-9-18": "国耻",
|
|
|
+ "0-10-1": "国庆",
|
|
|
+ "0-12-25": "圣诞"
|
|
|
+ } : {}, options.mark);
|
|
|
+ lay.each(["min", "max"], function(i, item) {
|
|
|
+ var ymd = []
|
|
|
+ , hms = [];
|
|
|
+ if (typeof options[item] === "number") {
|
|
|
+ var day = options[item]
|
|
|
+ , time = (new Date).getTime()
|
|
|
+ , STAMP = 864e5
|
|
|
+ , thisDate = new Date(day ? day < STAMP ? time + day * STAMP : day : time);
|
|
|
+ ymd = [thisDate.getFullYear(), thisDate.getMonth() + 1, thisDate.getDate()];
|
|
|
+ day < STAMP || (hms = [thisDate.getHours(), thisDate.getMinutes(), thisDate.getSeconds()])
|
|
|
+ } else {
|
|
|
+ ymd = (options[item].match(/\d+-\d+-\d+/) || [""])[0].split("-");
|
|
|
+ hms = (options[item].match(/\d+:\d+:\d+/) || [""])[0].split(":")
|
|
|
+ }
|
|
|
+ options[item] = {
|
|
|
+ year: ymd[0] | 0 || (new Date).getFullYear(),
|
|
|
+ month: ymd[1] ? (ymd[1] | 0) - 1 : (new Date).getMonth(),
|
|
|
+ date: ymd[2] | 0 || (new Date).getDate(),
|
|
|
+ hours: hms[0] | 0,
|
|
|
+ minutes: hms[1] | 0,
|
|
|
+ seconds: hms[2] | 0
|
|
|
+ }
|
|
|
+ });
|
|
|
+ that.elemID = "layui-laydate" + options.elem.attr("lay-key");
|
|
|
+ if (options.show || isStatic)
|
|
|
+ that.render();
|
|
|
+ isStatic || that.events();
|
|
|
+ if (options.value) {
|
|
|
+ if (options.value.constructor === Date) {
|
|
|
+ that.setValue(that.parse(0, that.systemDate(options.value)))
|
|
|
+ } else {
|
|
|
+ that.setValue(options.value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.render = function() {
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , lang = that.lang()
|
|
|
+ , isStatic = options.position === "static"
|
|
|
+ , elem = that.elem = lay.elem("div", {
|
|
|
+ id: that.elemID,
|
|
|
+ class: ["layui-laydate", options.range ? " layui-laydate-range" : "", options.wrapclass ? " " + options.wrapclass : "", isStatic ? " " + ELEM_STATIC : "", options.theme && options.theme !== "default" && !/^#/.test(options.theme) ? " laydate-theme-" + options.theme : ""].join("")
|
|
|
+ })
|
|
|
+ , elemMain = that.elemMain = []
|
|
|
+ , elemHeader = that.elemHeader = []
|
|
|
+ , elemCont = that.elemCont = []
|
|
|
+ , elemTable = that.table = []
|
|
|
+ , divFooter = that.footer = lay.elem("div", {
|
|
|
+ class: ELEM_FOOTER
|
|
|
+ });
|
|
|
+ if (options.zIndex)
|
|
|
+ elem.style.zIndex = options.zIndex;
|
|
|
+ lay.each(new Array(2), function(i) {
|
|
|
+ if (!options.range && i > 0) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ var divHeader = lay.elem("div", {
|
|
|
+ class: "layui-laydate-header"
|
|
|
+ })
|
|
|
+ , headerChild = [function() {
|
|
|
+ var elem = lay.elem("i", {
|
|
|
+ class: "layui-icon laydate-icon laydate-prev-y"
|
|
|
+ });
|
|
|
+ elem.innerHTML = "";
|
|
|
+ return elem
|
|
|
+ }(), function() {
|
|
|
+ var elem = lay.elem("i", {
|
|
|
+ class: "layui-icon laydate-icon laydate-prev-m"
|
|
|
+ });
|
|
|
+ elem.innerHTML = "";
|
|
|
+ return elem
|
|
|
+ }(), function() {
|
|
|
+ var elem = lay.elem("div", {
|
|
|
+ class: "laydate-set-ym"
|
|
|
+ })
|
|
|
+ , spanY = lay.elem("span")
|
|
|
+ , spanM = lay.elem("span");
|
|
|
+ elem.appendChild(spanY);
|
|
|
+ elem.appendChild(spanM);
|
|
|
+ return elem
|
|
|
+ }(), function() {
|
|
|
+ var elem = lay.elem("i", {
|
|
|
+ class: "layui-icon laydate-icon laydate-next-m"
|
|
|
+ });
|
|
|
+ elem.innerHTML = "";
|
|
|
+ return elem
|
|
|
+ }(), function() {
|
|
|
+ var elem = lay.elem("i", {
|
|
|
+ class: "layui-icon laydate-icon laydate-next-y"
|
|
|
+ });
|
|
|
+ elem.innerHTML = "";
|
|
|
+ return elem
|
|
|
+ }()]
|
|
|
+ , divContent = lay.elem("div", {
|
|
|
+ class: "layui-laydate-content"
|
|
|
+ })
|
|
|
+ , table = lay.elem("table")
|
|
|
+ , thead = lay.elem("thead")
|
|
|
+ , theadTr = lay.elem("tr");
|
|
|
+ lay.each(headerChild, function(i, item) {
|
|
|
+ divHeader.appendChild(item)
|
|
|
+ });
|
|
|
+ thead.appendChild(theadTr);
|
|
|
+ lay.each(new Array(6), function(i) {
|
|
|
+ var tr = table.insertRow(0);
|
|
|
+ lay.each(new Array(7), function(j) {
|
|
|
+ if (i === 0) {
|
|
|
+ var th = lay.elem("th");
|
|
|
+ th.innerHTML = lang.weeks[j];
|
|
|
+ theadTr.appendChild(th)
|
|
|
+ }
|
|
|
+ tr.insertCell(j)
|
|
|
+ })
|
|
|
+ });
|
|
|
+ table.insertBefore(thead, table.children[0]);
|
|
|
+ divContent.appendChild(table);
|
|
|
+ elemMain[i] = lay.elem("div", {
|
|
|
+ class: "layui-laydate-main laydate-main-list-" + i
|
|
|
+ });
|
|
|
+ elemMain[i].appendChild(divHeader);
|
|
|
+ elemMain[i].appendChild(divContent);
|
|
|
+ elemHeader.push(headerChild);
|
|
|
+ elemCont.push(divContent);
|
|
|
+ elemTable.push(table)
|
|
|
+ });
|
|
|
+ lay(divFooter).html(function() {
|
|
|
+ var html = []
|
|
|
+ , btns = [];
|
|
|
+ if (options.type === "datetime") {
|
|
|
+ html.push('<span lay-type="datetime" class="laydate-btns-time">' + lang.timeTips + "</span>")
|
|
|
+ }
|
|
|
+ lay.each(options.btns, function(i, item) {
|
|
|
+ var title = lang.tools[item] || "btn";
|
|
|
+ if (options.range && item === "now")
|
|
|
+ return;
|
|
|
+ if (isStatic && item === "clear")
|
|
|
+ title = options.lang === "cn" ? "重置" : "Reset";
|
|
|
+ btns.push('<span lay-type="' + item + '" class="laydate-btns-' + item + '">' + title + "</span>")
|
|
|
+ });
|
|
|
+ html.push('<div class="laydate-footer-btns">' + btns.join("") + "</div>");
|
|
|
+ return html.join("")
|
|
|
+ }());
|
|
|
+ lay.each(elemMain, function(i, main) {
|
|
|
+ elem.appendChild(main)
|
|
|
+ });
|
|
|
+ options.showBottom && elem.appendChild(divFooter);
|
|
|
+ if (/^#/.test(options.theme)) {
|
|
|
+ var style = lay.elem("style")
|
|
|
+ , styleText = ["#{{id}} .layui-laydate-header{background-color:{{theme}};}", "#{{id}} .layui-this{background-color:{{theme}} !important;}"].join("").replace(/{{id}}/g, that.elemID).replace(/{{theme}}/g, options.theme);
|
|
|
+ if ("styleSheet"in style) {
|
|
|
+ style.setAttribute("type", "text/css");
|
|
|
+ style.styleSheet.cssText = styleText
|
|
|
+ } else {
|
|
|
+ style.innerHTML = styleText
|
|
|
+ }
|
|
|
+ lay(elem).addClass("laydate-theme-molv");
|
|
|
+ elem.appendChild(style)
|
|
|
+ }
|
|
|
+ that.remove(Class.thisElemDate);
|
|
|
+ isStatic ? options.elem.append(elem) : (document.body.appendChild(elem),
|
|
|
+ that.position());
|
|
|
+ that.checkDate().calendar();
|
|
|
+ that.changeEvent();
|
|
|
+ Class.thisElemDate = that.elemID;
|
|
|
+ typeof options.ready === "function" && options.ready(lay.extend({}, options.dateTime, {
|
|
|
+ month: options.dateTime.month + 1
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.remove = function(prev) {
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , elem = lay("#" + (prev || that.elemID));
|
|
|
+ if (!elem.hasClass(ELEM_STATIC)) {
|
|
|
+ that.checkDate(function() {
|
|
|
+ elem.remove()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return that
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.position = function() {
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , elem = that.bindElem || options.elem[0]
|
|
|
+ , rect = elem.getBoundingClientRect()
|
|
|
+ , elemWidth = that.elem.offsetWidth
|
|
|
+ , elemHeight = that.elem.offsetHeight
|
|
|
+ , scrollArea = function(type) {
|
|
|
+ type = type ? "scrollLeft" : "scrollTop";
|
|
|
+ return document.body[type] | document.documentElement[type]
|
|
|
+ }
|
|
|
+ , winArea = function(type) {
|
|
|
+ return document.documentElement[type ? "clientWidth" : "clientHeight"]
|
|
|
+ }
|
|
|
+ , margin = 5
|
|
|
+ , left = rect.left
|
|
|
+ , top = rect.bottom;
|
|
|
+ if (left + elemWidth + margin > winArea("width")) {
|
|
|
+ left = winArea("width") - elemWidth - margin
|
|
|
+ }
|
|
|
+ if (top + elemHeight + margin > winArea()) {
|
|
|
+ top = rect.top > elemHeight ? rect.top - elemHeight : winArea() - elemHeight;
|
|
|
+ top = top - margin * 2
|
|
|
+ }
|
|
|
+ if (options.position) {
|
|
|
+ that.elem.style.position = options.position
|
|
|
+ }
|
|
|
+ that.elem.style.left = left + (options.position === "fixed" ? 0 : scrollArea(1)) + "px";
|
|
|
+ that.elem.style.top = top + (options.position === "fixed" ? 0 : scrollArea()) + "px"
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.hint = function(content) {
|
|
|
+ if (!this.elem)
|
|
|
+ return;
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , div = lay.elem("div", {
|
|
|
+ class: ELEM_HINT
|
|
|
+ });
|
|
|
+ div.innerHTML = content || "";
|
|
|
+ lay(that.elem).find("." + ELEM_HINT).remove();
|
|
|
+ that.elem.appendChild(div);
|
|
|
+ clearTimeout(that.hinTimer);
|
|
|
+ that.hinTimer = setTimeout(function() {
|
|
|
+ lay(that.elem).find("." + ELEM_HINT).remove()
|
|
|
+ }, 3e3)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.getAsYM = function(Y, M, type) {
|
|
|
+ type ? M-- : M++;
|
|
|
+ if (M < 0) {
|
|
|
+ M = 11;
|
|
|
+ Y--
|
|
|
+ }
|
|
|
+ if (M > 11) {
|
|
|
+ M = 0;
|
|
|
+ Y++
|
|
|
+ }
|
|
|
+ return [Y, M]
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.systemDate = function(newDate) {
|
|
|
+ var thisDate = newDate || new Date;
|
|
|
+ return {
|
|
|
+ year: thisDate.getFullYear(),
|
|
|
+ month: thisDate.getMonth(),
|
|
|
+ date: thisDate.getDate(),
|
|
|
+ hours: newDate ? newDate.getHours() : 0,
|
|
|
+ minutes: newDate ? newDate.getMinutes() : 0,
|
|
|
+ seconds: newDate ? newDate.getSeconds() : 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.checkDate = function(fn) {
|
|
|
+ var that = this, thisDate = new Date, options = that.config, dateTime = options.dateTime = options.dateTime || that.systemDate(), thisMaxDate, error, elem = that.bindElem || options.elem[0], valType = that.isInput(elem) ? "val" : "html", value = that.isInput(elem) ? elem.value : options.position === "static" ? "" : elem.innerHTML, checkValid = function(dateTime) {
|
|
|
+ if (dateTime.year > LIMIT_YEAR[1])
|
|
|
+ dateTime.year = LIMIT_YEAR[1],
|
|
|
+ error = true;
|
|
|
+ if (dateTime.month > 11)
|
|
|
+ dateTime.month = 11,
|
|
|
+ error = true;
|
|
|
+ if (dateTime.hours > 23)
|
|
|
+ dateTime.hours = 0,
|
|
|
+ error = true;
|
|
|
+ if (dateTime.minutes > 59)
|
|
|
+ dateTime.minutes = 0,
|
|
|
+ dateTime.hours++,
|
|
|
+ error = true;
|
|
|
+ if (dateTime.seconds > 59)
|
|
|
+ dateTime.seconds = 0,
|
|
|
+ dateTime.minutes++,
|
|
|
+ error = true;
|
|
|
+ thisMaxDate = laydate.getEndDate(dateTime.month + 1, dateTime.year);
|
|
|
+ if (dateTime.date > thisMaxDate)
|
|
|
+ dateTime.date = thisMaxDate,
|
|
|
+ error = true
|
|
|
+ }, initDate = function(dateTime, value, index) {
|
|
|
+ var startEnd = ["startTime", "endTime"];
|
|
|
+ value = (value.match(that.EXP_SPLIT) || []).slice(1);
|
|
|
+ index = index || 0;
|
|
|
+ if (options.range) {
|
|
|
+ that[startEnd[index]] = that[startEnd[index]] || {}
|
|
|
+ }
|
|
|
+ lay.each(that.format, function(i, item) {
|
|
|
+ var thisv = parseFloat(value[i]);
|
|
|
+ if (value[i].length < item.length)
|
|
|
+ error = true;
|
|
|
+ if (/yyyy|y/.test(item)) {
|
|
|
+ if (thisv < LIMIT_YEAR[0])
|
|
|
+ thisv = LIMIT_YEAR[0],
|
|
|
+ error = true;
|
|
|
+ dateTime.year = thisv
|
|
|
+ } else if (/MM|M/.test(item)) {
|
|
|
+ if (thisv < 1)
|
|
|
+ thisv = 1,
|
|
|
+ error = true;
|
|
|
+ dateTime.month = thisv - 1
|
|
|
+ } else if (/dd|d/.test(item)) {
|
|
|
+ if (thisv < 1)
|
|
|
+ thisv = 1,
|
|
|
+ error = true;
|
|
|
+ dateTime.date = thisv
|
|
|
+ } else if (/HH|H/.test(item)) {
|
|
|
+ if (thisv < 1)
|
|
|
+ thisv = 0,
|
|
|
+ error = true;
|
|
|
+ dateTime.hours = thisv;
|
|
|
+ options.range && (that[startEnd[index]].hours = thisv)
|
|
|
+ } else if (/mm|m/.test(item)) {
|
|
|
+ if (thisv < 1)
|
|
|
+ thisv = 0,
|
|
|
+ error = true;
|
|
|
+ dateTime.minutes = thisv;
|
|
|
+ options.range && (that[startEnd[index]].minutes = thisv)
|
|
|
+ } else if (/ss|s/.test(item)) {
|
|
|
+ if (thisv < 1)
|
|
|
+ thisv = 0,
|
|
|
+ error = true;
|
|
|
+ dateTime.seconds = thisv;
|
|
|
+ options.range && (that[startEnd[index]].seconds = thisv)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ checkValid(dateTime)
|
|
|
+ };
|
|
|
+ if (fn === "limit")
|
|
|
+ return checkValid(dateTime),
|
|
|
+ that;
|
|
|
+ value = value || options.value;
|
|
|
+ if (typeof value === "string") {
|
|
|
+ value = value.replace(/\s+/g, " ").replace(/^\s|\s$/g, "")
|
|
|
+ }
|
|
|
+ if (that.startState && !that.endState) {
|
|
|
+ delete that.startState;
|
|
|
+ that.endState = true
|
|
|
+ }
|
|
|
+ if (typeof value === "string" && value) {
|
|
|
+ if (that.EXP_IF.test(value)) {
|
|
|
+ if (options.range) {
|
|
|
+ value = value.split(" " + options.range + " ");
|
|
|
+ that.startDate = that.startDate || that.systemDate();
|
|
|
+ that.endDate = that.endDate || that.systemDate();
|
|
|
+ options.dateTime = lay.extend({}, that.startDate);
|
|
|
+ lay.each([that.startDate, that.endDate], function(i, item) {
|
|
|
+ initDate(item, value[i], i)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ initDate(dateTime, value)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ that.hint("日期格式不合法<br>必须遵循下述格式:<br>" + (options.range ? options.format + " " + options.range + " " + options.format : options.format) + "<br>已为你重置");
|
|
|
+ error = true
|
|
|
+ }
|
|
|
+ } else if (value && value.constructor === Date) {
|
|
|
+ options.dateTime = that.systemDate(value)
|
|
|
+ } else {
|
|
|
+ options.dateTime = that.systemDate();
|
|
|
+ delete that.startState;
|
|
|
+ delete that.endState;
|
|
|
+ delete that.startDate;
|
|
|
+ delete that.endDate;
|
|
|
+ delete that.startTime;
|
|
|
+ delete that.endTime
|
|
|
+ }
|
|
|
+ checkValid(dateTime);
|
|
|
+ if (error && value) {
|
|
|
+ that.setValue(options.range ? that.endDate ? that.parse() : "" : that.parse())
|
|
|
+ }
|
|
|
+ fn && fn();
|
|
|
+ return that
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.mark = function(td, YMD) {
|
|
|
+ var that = this, mark, options = that.config;
|
|
|
+ lay.each(options.mark, function(key, title) {
|
|
|
+ var keys = key.split("-");
|
|
|
+ if ((keys[0] == YMD[0] || keys[0] == 0) && (keys[1] == YMD[1] || keys[1] == 0) && keys[2] == YMD[2]) {
|
|
|
+ mark = title || YMD[2]
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mark && td.html('<span class="laydate-day-mark">' + mark + "</span>");
|
|
|
+ return that
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.limit = function(elem, date, index, time) {
|
|
|
+ var that = this, options = that.config, timestrap = {}, dateTime = options[index > 41 ? "endDate" : "dateTime"], isOut, thisDateTime = lay.extend({}, dateTime, date || {});
|
|
|
+ lay.each({
|
|
|
+ now: thisDateTime,
|
|
|
+ min: options.min,
|
|
|
+ max: options.max
|
|
|
+ }, function(key, item) {
|
|
|
+ timestrap[key] = that.newDate(lay.extend({
|
|
|
+ year: item.year,
|
|
|
+ month: item.month,
|
|
|
+ date: item.date
|
|
|
+ }, function() {
|
|
|
+ var hms = {};
|
|
|
+ lay.each(time, function(i, keys) {
|
|
|
+ hms[keys] = item[keys]
|
|
|
+ });
|
|
|
+ return hms
|
|
|
+ }())).getTime()
|
|
|
+ });
|
|
|
+ isOut = timestrap.now < timestrap.min || timestrap.now > timestrap.max;
|
|
|
+ elem && elem[isOut ? "addClass" : "removeClass"](DISABLED);
|
|
|
+ return isOut
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.calendar = function(value) {
|
|
|
+ var that = this, options = that.config, dateTime = value || options.dateTime, thisDate = new Date, startWeek, prevMaxDate, thisMaxDate, lang = that.lang(), isAlone = options.type !== "date" && options.type !== "datetime", index = value ? 1 : 0, tds = lay(that.table[index]).find("td"), elemYM = lay(that.elemHeader[index][2]).find("span");
|
|
|
+ if (dateTime.year < LIMIT_YEAR[0])
|
|
|
+ dateTime.year = LIMIT_YEAR[0],
|
|
|
+ that.hint("最低只能支持到公元" + LIMIT_YEAR[0] + "年");
|
|
|
+ if (dateTime.year > LIMIT_YEAR[1])
|
|
|
+ dateTime.year = LIMIT_YEAR[1],
|
|
|
+ that.hint("最高只能支持到公元" + LIMIT_YEAR[1] + "年");
|
|
|
+ if (!that.firstDate) {
|
|
|
+ that.firstDate = lay.extend({}, dateTime)
|
|
|
+ }
|
|
|
+ thisDate.setFullYear(dateTime.year, dateTime.month, 1);
|
|
|
+ startWeek = thisDate.getDay();
|
|
|
+ prevMaxDate = laydate.getEndDate(dateTime.month || 12, dateTime.year);
|
|
|
+ thisMaxDate = laydate.getEndDate(dateTime.month + 1, dateTime.year);
|
|
|
+ lay.each(tds, function(index, item) {
|
|
|
+ var YMD = [dateTime.year, dateTime.month]
|
|
|
+ , st = 0;
|
|
|
+ item = lay(item);
|
|
|
+ item.removeAttr("class");
|
|
|
+ if (index < startWeek) {
|
|
|
+ st = prevMaxDate - startWeek + index;
|
|
|
+ item.addClass("laydate-day-prev");
|
|
|
+ YMD = that.getAsYM(dateTime.year, dateTime.month, "sub")
|
|
|
+ } else if (index >= startWeek && index < thisMaxDate + startWeek) {
|
|
|
+ st = index - startWeek;
|
|
|
+ if (!options.range) {
|
|
|
+ st + 1 === dateTime.date && item.addClass(THIS)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ st = index - thisMaxDate - startWeek;
|
|
|
+ item.addClass("laydate-day-next");
|
|
|
+ YMD = that.getAsYM(dateTime.year, dateTime.month)
|
|
|
+ }
|
|
|
+ YMD[1]++;
|
|
|
+ YMD[2] = st + 1;
|
|
|
+ item.attr("lay-ymd", YMD.join("-")).html(YMD[2]);
|
|
|
+ that.mark(item, YMD).limit(item, {
|
|
|
+ year: YMD[0],
|
|
|
+ month: YMD[1] - 1,
|
|
|
+ date: YMD[2]
|
|
|
+ }, index)
|
|
|
+ });
|
|
|
+ lay(elemYM[0]).attr("lay-ym", dateTime.year + "-" + (dateTime.month + 1));
|
|
|
+ lay(elemYM[1]).attr("lay-ym", dateTime.year + "-" + (dateTime.month + 1));
|
|
|
+ if (options.lang === "cn") {
|
|
|
+ lay(elemYM[0]).attr("lay-type", "year").html(dateTime.year + "年");
|
|
|
+ lay(elemYM[1]).attr("lay-type", "month").html(dateTime.month + 1 + "月")
|
|
|
+ } else {
|
|
|
+ lay(elemYM[0]).attr("lay-type", "month").html(lang.month[dateTime.month]);
|
|
|
+ lay(elemYM[1]).attr("lay-type", "year").html(dateTime.year)
|
|
|
+ }
|
|
|
+ if (isAlone) {
|
|
|
+ if (options.range) {
|
|
|
+ value ? that.endDate = that.endDate || {
|
|
|
+ year: dateTime.year + (options.type === "year" ? 1 : 0),
|
|
|
+ month: dateTime.month + (options.type === "month" ? 0 : -1)
|
|
|
+ } : that.startDate = that.startDate || {
|
|
|
+ year: dateTime.year,
|
|
|
+ month: dateTime.month
|
|
|
+ };
|
|
|
+ if (value) {
|
|
|
+ that.listYM = [[that.startDate.year, that.startDate.month + 1], [that.endDate.year, that.endDate.month + 1]];
|
|
|
+ that.list(options.type, 0).list(options.type, 1);
|
|
|
+ options.type === "time" ? that.setBtnStatus("时间", lay.extend({}, that.systemDate(), that.startTime), lay.extend({}, that.systemDate(), that.endTime)) : that.setBtnStatus(true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!options.range) {
|
|
|
+ that.listYM = [[dateTime.year, dateTime.month + 1]];
|
|
|
+ that.list(options.type, 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (options.range && !value) {
|
|
|
+ var EYM = that.getAsYM(dateTime.year, dateTime.month);
|
|
|
+ that.calendar(lay.extend({}, dateTime, {
|
|
|
+ year: EYM[0],
|
|
|
+ month: EYM[1]
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ if (!options.range)
|
|
|
+ that.limit(lay(that.footer).find(ELEM_CONFIRM), null, 0, ["hours", "minutes", "seconds"]);
|
|
|
+ if (!options.range) {
|
|
|
+ var nowdate = new Date;
|
|
|
+ that.limit(lay(that.footer).find(".laydate-btns-now"), {
|
|
|
+ year: nowdate.getFullYear(),
|
|
|
+ month: nowdate.getMonth(),
|
|
|
+ date: nowdate.getDate(),
|
|
|
+ hours: nowdate.getHours(),
|
|
|
+ minutes: nowdate.getMinutes(),
|
|
|
+ seconds: nowdate.getSeconds()
|
|
|
+ }, 0, ["hours", "minutes", "seconds"])
|
|
|
+ }
|
|
|
+ if (options.range && value && !isAlone)
|
|
|
+ that.stampRange();
|
|
|
+ return that
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.list = function(type, index) {
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , dateTime = options.dateTime
|
|
|
+ , lang = that.lang()
|
|
|
+ , isAlone = options.range && options.type !== "date" && options.type !== "datetime"
|
|
|
+ , ul = lay.elem("ul", {
|
|
|
+ class: ELEM_LIST + " " + {
|
|
|
+ year: "laydate-year-list",
|
|
|
+ month: "laydate-month-list",
|
|
|
+ time: "laydate-time-list"
|
|
|
+ }[type]
|
|
|
+ })
|
|
|
+ , elemHeader = that.elemHeader[index]
|
|
|
+ , elemYM = lay(elemHeader[2]).find("span")
|
|
|
+ , elemCont = that.elemCont[index || 0]
|
|
|
+ , haveList = lay(elemCont).find("." + ELEM_LIST)[0]
|
|
|
+ , isCN = options.lang === "cn"
|
|
|
+ , text = isCN ? "年" : ""
|
|
|
+ , listYM = that.listYM[index] || {}
|
|
|
+ , hms = ["hours", "minutes", "seconds"]
|
|
|
+ , startEnd = ["startTime", "endTime"][index];
|
|
|
+ if (listYM[0] < 1)
|
|
|
+ listYM[0] = 1;
|
|
|
+ if (type === "year") {
|
|
|
+ var yearNum, startY = yearNum = listYM[0] - 7;
|
|
|
+ if (startY < 1)
|
|
|
+ startY = yearNum = 1;
|
|
|
+ lay.each(new Array(15), function(i) {
|
|
|
+ var li = lay.elem("li", {
|
|
|
+ "lay-ym": yearNum
|
|
|
+ })
|
|
|
+ , ymd = {
|
|
|
+ year: yearNum
|
|
|
+ };
|
|
|
+ yearNum == listYM[0] && lay(li).addClass(THIS);
|
|
|
+ li.innerHTML = yearNum + text;
|
|
|
+ ul.appendChild(li);
|
|
|
+ if (yearNum < that.firstDate.year) {
|
|
|
+ ymd.month = options.min.month;
|
|
|
+ ymd.date = options.min.date
|
|
|
+ } else if (yearNum >= that.firstDate.year) {
|
|
|
+ ymd.month = options.max.month;
|
|
|
+ ymd.date = options.max.date
|
|
|
+ }
|
|
|
+ that.limit(lay(li), ymd, index);
|
|
|
+ yearNum++
|
|
|
+ });
|
|
|
+ lay(elemYM[isCN ? 0 : 1]).attr("lay-ym", yearNum - 8 + "-" + listYM[1]).html(startY + text + " - " + (yearNum - 1 + text))
|
|
|
+ } else if (type === "month") {
|
|
|
+ lay.each(new Array(12), function(i) {
|
|
|
+ var li = lay.elem("li", {
|
|
|
+ "lay-ym": i
|
|
|
+ })
|
|
|
+ , ymd = {
|
|
|
+ year: listYM[0],
|
|
|
+ month: i
|
|
|
+ };
|
|
|
+ i + 1 == listYM[1] && lay(li).addClass(THIS);
|
|
|
+ li.innerHTML = lang.month[i] + (isCN ? "月" : "");
|
|
|
+ ul.appendChild(li);
|
|
|
+ if (listYM[0] < that.firstDate.year) {
|
|
|
+ ymd.date = options.min.date
|
|
|
+ } else if (listYM[0] >= that.firstDate.year) {
|
|
|
+ ymd.date = options.max.date
|
|
|
+ }
|
|
|
+ that.limit(lay(li), ymd, index)
|
|
|
+ });
|
|
|
+ lay(elemYM[isCN ? 0 : 1]).attr("lay-ym", listYM[0] + "-" + listYM[1]).html(listYM[0] + text)
|
|
|
+ } else if (type === "time") {
|
|
|
+ var setTimeStatus = function() {
|
|
|
+ lay(ul).find("ol").each(function(i, ol) {
|
|
|
+ lay(ol).find("li").each(function(ii, li) {
|
|
|
+ that.limit(lay(li), [{
|
|
|
+ hours: ii
|
|
|
+ }, {
|
|
|
+ hours: that[startEnd].hours,
|
|
|
+ minutes: ii
|
|
|
+ }, {
|
|
|
+ hours: that[startEnd].hours,
|
|
|
+ minutes: that[startEnd].minutes,
|
|
|
+ seconds: ii
|
|
|
+ }][i], index, [["hours"], ["hours", "minutes"], ["hours", "minutes", "seconds"]][i])
|
|
|
+ })
|
|
|
+ });
|
|
|
+ if (!options.range)
|
|
|
+ that.limit(lay(that.footer).find(ELEM_CONFIRM), that[startEnd], 0, ["hours", "minutes", "seconds"])
|
|
|
+ };
|
|
|
+ if (options.range) {
|
|
|
+ if (!that[startEnd])
|
|
|
+ that[startEnd] = {
|
|
|
+ hours: 0,
|
|
|
+ minutes: 0,
|
|
|
+ seconds: 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ that[startEnd] = dateTime
|
|
|
+ }
|
|
|
+ lay.each([24, 60, 60], function(i, item) {
|
|
|
+ var li = lay.elem("li")
|
|
|
+ , childUL = ["<p>" + lang.time[i] + "</p><ol>"];
|
|
|
+ lay.each(new Array(item), function(ii) {
|
|
|
+ childUL.push("<li" + (that[startEnd][hms[i]] === ii ? ' class="' + THIS + '"' : "") + ">" + lay.digit(ii, 2) + "</li>")
|
|
|
+ });
|
|
|
+ li.innerHTML = childUL.join("") + "</ol>";
|
|
|
+ ul.appendChild(li)
|
|
|
+ });
|
|
|
+ setTimeStatus()
|
|
|
+ }
|
|
|
+ if (haveList)
|
|
|
+ elemCont.removeChild(haveList);
|
|
|
+ elemCont.appendChild(ul);
|
|
|
+ if (type === "year" || type === "month") {
|
|
|
+ lay(that.elemMain[index]).addClass("laydate-ym-show");
|
|
|
+ lay(ul).find("li").on("click", function() {
|
|
|
+ var ym = lay(this).attr("lay-ym") | 0;
|
|
|
+ if (lay(this).hasClass(DISABLED))
|
|
|
+ return;
|
|
|
+ if (index === 0) {
|
|
|
+ dateTime[type] = ym;
|
|
|
+ if (isAlone)
|
|
|
+ that.startDate[type] = ym;
|
|
|
+ that.limit(lay(that.footer).find(ELEM_CONFIRM), null, 0)
|
|
|
+ } else {
|
|
|
+ if (isAlone) {
|
|
|
+ that.endDate[type] = ym
|
|
|
+ } else {
|
|
|
+ var YM = type === "year" ? that.getAsYM(ym, listYM[1] - 1, "sub") : that.getAsYM(listYM[0], ym, "sub");
|
|
|
+ lay.extend(dateTime, {
|
|
|
+ year: YM[0],
|
|
|
+ month: YM[1]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (options.type === "year" || options.type === "month") {
|
|
|
+ lay(ul).find("." + THIS).removeClass(THIS);
|
|
|
+ lay(this).addClass(THIS);
|
|
|
+ if (options.type === "month" && type === "year") {
|
|
|
+ that.listYM[index][0] = ym;
|
|
|
+ isAlone && (that[["startDate", "endDate"][index]].year = ym);
|
|
|
+ that.list("month", index)
|
|
|
+ } else {
|
|
|
+ that.tool(this, "confirm")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ that.checkDate("limit").calendar();
|
|
|
+ that.closeList()
|
|
|
+ }
|
|
|
+ that.setBtnStatus();
|
|
|
+ options.range || that.done(null, "change");
|
|
|
+ lay(that.footer).find(ELEM_TIME_BTN).removeClass(DISABLED)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ var span = lay.elem("span", {
|
|
|
+ class: ELEM_TIME_TEXT
|
|
|
+ })
|
|
|
+ , scroll = function() {
|
|
|
+ lay(ul).find("ol").each(function(i) {
|
|
|
+ var ol = this
|
|
|
+ , li = lay(ol).find("li");
|
|
|
+ ol.scrollTop = 25 * (that[startEnd][hms[i]] - 2);
|
|
|
+ if (ol.scrollTop <= 0) {
|
|
|
+ li.each(function(ii, item) {
|
|
|
+ if (!lay(this).hasClass(DISABLED)) {
|
|
|
+ ol.scrollTop = 25 * (ii - 2);
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ , haveSpan = lay(elemHeader[2]).find("." + ELEM_TIME_TEXT);
|
|
|
+ scroll();
|
|
|
+ span.innerHTML = options.range ? [lang.startTime, lang.endTime][index] : lang.timeTips;
|
|
|
+ lay(that.elemMain[index]).addClass("laydate-time-show");
|
|
|
+ if (haveSpan[0])
|
|
|
+ haveSpan.remove();
|
|
|
+ elemHeader[2].appendChild(span);
|
|
|
+ lay(ul).find("ol").each(function(i) {
|
|
|
+ var ol = this;
|
|
|
+ lay(ol).find("li").on("click", function() {
|
|
|
+ var value = this.innerHTML | 0;
|
|
|
+ if (lay(this).hasClass(DISABLED))
|
|
|
+ return;
|
|
|
+ if (options.range) {
|
|
|
+ that[startEnd][hms[i]] = value
|
|
|
+ } else {
|
|
|
+ dateTime[hms[i]] = value
|
|
|
+ }
|
|
|
+ lay(ol).find("." + THIS).removeClass(THIS);
|
|
|
+ lay(this).addClass(THIS);
|
|
|
+ setTimeStatus();
|
|
|
+ scroll();
|
|
|
+ if (that.config.nosecond === true && i == 1 || i == 2) {
|
|
|
+ that.tool(this, "confirm")
|
|
|
+ }
|
|
|
+ (that.endDate || options.type === "time") && that.done(null, "change");
|
|
|
+ that.setBtnStatus()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return that
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.listYM = [];
|
|
|
+ Class.prototype.closeList = function() {
|
|
|
+ var that = this
|
|
|
+ , options = that.config;
|
|
|
+ lay.each(that.elemCont, function(index, item) {
|
|
|
+ lay(this).find("." + ELEM_LIST).remove();
|
|
|
+ lay(that.elemMain[index]).removeClass("laydate-ym-show laydate-time-show")
|
|
|
+ });
|
|
|
+ lay(that.elem).find("." + ELEM_TIME_TEXT).remove()
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.setBtnStatus = function(tips, start, end) {
|
|
|
+ var that = this, options = that.config, isOut, elemBtn = lay(that.footer).find(ELEM_CONFIRM), isAlone = options.range && options.type !== "date" && options.type !== "time";
|
|
|
+ if (isAlone) {
|
|
|
+ start = start || that.startDate;
|
|
|
+ end = end || that.endDate;
|
|
|
+ isOut = that.newDate(start).getTime() > that.newDate(end).getTime();
|
|
|
+ that.limit(null, start) || that.limit(null, end) ? elemBtn.addClass(DISABLED) : elemBtn[isOut ? "addClass" : "removeClass"](DISABLED);
|
|
|
+ if (tips && isOut)
|
|
|
+ that.hint(typeof tips === "string" ? TIPS_OUT.replace(/日期/g, tips) : TIPS_OUT)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.parse = function(state, date) {
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , dateTime = date || (state ? lay.extend({}, that.endDate, that.endTime) : options.range ? lay.extend({}, that.startDate, that.startTime) : options.dateTime)
|
|
|
+ , format = that.format.concat();
|
|
|
+ lay.each(format, function(i, item) {
|
|
|
+ if (/yyyy|y/.test(item)) {
|
|
|
+ format[i] = lay.digit(dateTime.year, item.length)
|
|
|
+ } else if (/MM|M/.test(item)) {
|
|
|
+ format[i] = lay.digit(dateTime.month + 1, item.length)
|
|
|
+ } else if (/dd|d/.test(item)) {
|
|
|
+ format[i] = lay.digit(dateTime.date, item.length)
|
|
|
+ } else if (/HH|H/.test(item)) {
|
|
|
+ format[i] = lay.digit(dateTime.hours, item.length)
|
|
|
+ } else if (/mm|m/.test(item)) {
|
|
|
+ format[i] = lay.digit(dateTime.minutes, item.length)
|
|
|
+ } else if (/ss|s/.test(item)) {
|
|
|
+ format[i] = lay.digit(dateTime.seconds, item.length)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (options.range && !state) {
|
|
|
+ return format.join("") + " " + options.range + " " + that.parse(1)
|
|
|
+ }
|
|
|
+ return format.join("")
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.newDate = function(dateTime) {
|
|
|
+ dateTime = dateTime || {};
|
|
|
+ return new Date(dateTime.year || 1,dateTime.month || 0,dateTime.date || 1,dateTime.hours || 0,dateTime.minutes || 0,dateTime.seconds || 0)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.setValue = function(value) {
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , elem = that.bindElem || options.elem[0]
|
|
|
+ , valType = that.isInput(elem) ? "val" : "html";
|
|
|
+ options.position === "static" || lay(elem)[valType](value || "");
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.stampRange = function() {
|
|
|
+ var that = this, options = that.config, startTime, endTime, tds = lay(that.elem).find("td");
|
|
|
+ if (options.range && !that.endDate)
|
|
|
+ lay(that.footer).find(ELEM_CONFIRM).addClass(DISABLED);
|
|
|
+ if (!that.endDate)
|
|
|
+ return;
|
|
|
+ startTime = that.newDate({
|
|
|
+ year: that.startDate.year,
|
|
|
+ month: that.startDate.month,
|
|
|
+ date: that.startDate.date
|
|
|
+ }).getTime();
|
|
|
+ endTime = that.newDate({
|
|
|
+ year: that.endDate.year,
|
|
|
+ month: that.endDate.month,
|
|
|
+ date: that.endDate.date
|
|
|
+ }).getTime();
|
|
|
+ if (startTime > endTime)
|
|
|
+ return that.hint(TIPS_OUT);
|
|
|
+ lay.each(tds, function(i, item) {
|
|
|
+ var ymd = lay(item).attr("lay-ymd").split("-")
|
|
|
+ , thisTime = that.newDate({
|
|
|
+ year: ymd[0],
|
|
|
+ month: ymd[1] - 1,
|
|
|
+ date: ymd[2]
|
|
|
+ }).getTime();
|
|
|
+ lay(item).removeClass(ELEM_SELECTED + " " + THIS);
|
|
|
+ if (thisTime === startTime || thisTime === endTime) {
|
|
|
+ lay(item).addClass(lay(item).hasClass(ELEM_PREV) || lay(item).hasClass(ELEM_NEXT) ? ELEM_SELECTED : THIS)
|
|
|
+ }
|
|
|
+ if (thisTime > startTime && thisTime < endTime) {
|
|
|
+ lay(item).addClass(ELEM_SELECTED)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.done = function(param, type) {
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , start = lay.extend({}, that.startDate ? lay.extend(that.startDate, that.startTime) : options.dateTime)
|
|
|
+ , end = lay.extend({}, lay.extend(that.endDate, that.endTime));
|
|
|
+ lay.each([start, end], function(i, item) {
|
|
|
+ if (!("month"in item))
|
|
|
+ return;
|
|
|
+ lay.extend(item, {
|
|
|
+ month: item.month + 1
|
|
|
+ })
|
|
|
+ });
|
|
|
+ param = param || [that.parse(), start, end];
|
|
|
+ typeof options[type || "done"] === "function" && options[type || "done"].apply(options, param);
|
|
|
+ return that
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.choose = function(td) {
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , dateTime = options.dateTime
|
|
|
+ , tds = lay(that.elem).find("td")
|
|
|
+ , YMD = td.attr("lay-ymd").split("-")
|
|
|
+ , setDateTime = function(one) {
|
|
|
+ var thisDate = new Date;
|
|
|
+ one && lay.extend(dateTime, YMD);
|
|
|
+ if (options.range) {
|
|
|
+ that.startDate ? lay.extend(that.startDate, YMD) : that.startDate = lay.extend({}, YMD, that.startTime);
|
|
|
+ that.startYMD = YMD
|
|
|
+ }
|
|
|
+ };
|
|
|
+ YMD = {
|
|
|
+ year: YMD[0] | 0,
|
|
|
+ month: (YMD[1] | 0) - 1,
|
|
|
+ date: YMD[2] | 0
|
|
|
+ };
|
|
|
+ if (td.hasClass(DISABLED))
|
|
|
+ return;
|
|
|
+ if (options.range) {
|
|
|
+ lay.each(["startTime", "endTime"], function(i, item) {
|
|
|
+ that[item] = that[item] || {
|
|
|
+ hours: 0,
|
|
|
+ minutes: 0,
|
|
|
+ seconds: 0
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (that.endState) {
|
|
|
+ setDateTime();
|
|
|
+ delete that.endState;
|
|
|
+ delete that.endDate;
|
|
|
+ that.startState = true;
|
|
|
+ tds.removeClass(THIS + " " + ELEM_SELECTED);
|
|
|
+ td.addClass(THIS)
|
|
|
+ } else if (that.startState) {
|
|
|
+ td.addClass(THIS);
|
|
|
+ that.endDate ? lay.extend(that.endDate, YMD) : that.endDate = lay.extend({}, YMD, that.endTime);
|
|
|
+ if (that.newDate(YMD).getTime() < that.newDate(that.startYMD).getTime()) {
|
|
|
+ var startDate = lay.extend({}, that.endDate, {
|
|
|
+ hours: that.startDate.hours,
|
|
|
+ minutes: that.startDate.minutes,
|
|
|
+ seconds: that.startDate.seconds
|
|
|
+ });
|
|
|
+ lay.extend(that.endDate, that.startDate, {
|
|
|
+ hours: that.endDate.hours,
|
|
|
+ minutes: that.endDate.minutes,
|
|
|
+ seconds: that.endDate.seconds
|
|
|
+ });
|
|
|
+ that.startDate = startDate
|
|
|
+ }
|
|
|
+ options.showBottom || that.done();
|
|
|
+ that.stampRange();
|
|
|
+ that.endState = true;
|
|
|
+ that.done(null, "change")
|
|
|
+ } else {
|
|
|
+ td.addClass(THIS);
|
|
|
+ setDateTime();
|
|
|
+ that.startState = true
|
|
|
+ }
|
|
|
+ lay(that.footer).find(ELEM_CONFIRM)[that.endDate ? "removeClass" : "addClass"](DISABLED)
|
|
|
+ } else if (options.position === "static") {
|
|
|
+ setDateTime(true);
|
|
|
+ that.calendar().done().done(null, "change")
|
|
|
+ } else if (options.type === "date") {
|
|
|
+ setDateTime(true);
|
|
|
+ that.setValue(that.parse()).remove().done()
|
|
|
+ } else if (options.type === "datetime") {
|
|
|
+ setDateTime(true);
|
|
|
+ that.calendar().done(null, "change");
|
|
|
+ that.tool(lay(that.footer).find(ELEM_TIME_BTN)[0], "datetime")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.tool = function(btn, type) {
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , dateTime = options.dateTime
|
|
|
+ , isStatic = options.position === "static"
|
|
|
+ , active = {
|
|
|
+ datetime: function() {
|
|
|
+ if (lay(btn).hasClass(DISABLED))
|
|
|
+ return;
|
|
|
+ that.list("time", 0);
|
|
|
+ options.range && that.list("time", 1);
|
|
|
+ lay(btn).attr("lay-type", "date").html(that.lang().dateTips)
|
|
|
+ },
|
|
|
+ date: function() {
|
|
|
+ that.closeList();
|
|
|
+ lay(btn).attr("lay-type", "datetime").html(that.lang().timeTips)
|
|
|
+ },
|
|
|
+ clear: function() {
|
|
|
+ that.setValue("").remove();
|
|
|
+ isStatic && (lay.extend(dateTime, that.firstDate),
|
|
|
+ that.calendar());
|
|
|
+ options.range && (delete that.startState,
|
|
|
+ delete that.endState,
|
|
|
+ delete that.endDate,
|
|
|
+ delete that.startTime,
|
|
|
+ delete that.endTime);
|
|
|
+ that.done(["", {}, {}])
|
|
|
+ },
|
|
|
+ now: function() {
|
|
|
+ if (lay(btn).hasClass(DISABLED))
|
|
|
+ return;
|
|
|
+ var thisDate = new Date;
|
|
|
+ lay.extend(dateTime, that.systemDate(), {
|
|
|
+ hours: thisDate.getHours(),
|
|
|
+ minutes: thisDate.getMinutes(),
|
|
|
+ seconds: thisDate.getSeconds()
|
|
|
+ });
|
|
|
+ that.setValue(that.parse()).remove();
|
|
|
+ isStatic && that.calendar();
|
|
|
+ that.done()
|
|
|
+ },
|
|
|
+ confirm: function() {
|
|
|
+ if (options.range) {
|
|
|
+ if (!that.endDate)
|
|
|
+ return that.hint("请先选择日期范围");
|
|
|
+ if (lay(btn).hasClass(DISABLED))
|
|
|
+ return that.hint(options.type === "time" ? TIPS_OUT.replace(/日期/g, "时间") : TIPS_OUT)
|
|
|
+ } else {
|
|
|
+ if (lay(btn).hasClass(DISABLED))
|
|
|
+ return that.hint("不在有效日期或时间范围内")
|
|
|
+ }
|
|
|
+ that.done();
|
|
|
+ that.setValue(that.parse()).remove()
|
|
|
+ }
|
|
|
+ };
|
|
|
+ active[type] && active[type]()
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.change = function(index) {
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , dateTime = options.dateTime
|
|
|
+ , isAlone = options.range && (options.type === "year" || options.type === "month")
|
|
|
+ , elemCont = that.elemCont[index || 0]
|
|
|
+ , listYM = that.listYM[index]
|
|
|
+ , addSubYeay = function(type) {
|
|
|
+ var startEnd = ["startDate", "endDate"][index]
|
|
|
+ , isYear = lay(elemCont).find(".laydate-year-list")[0]
|
|
|
+ , isMonth = lay(elemCont).find(".laydate-month-list")[0];
|
|
|
+ if (isYear) {
|
|
|
+ listYM[0] = type ? listYM[0] - 15 : listYM[0] + 15;
|
|
|
+ that.list("year", index)
|
|
|
+ }
|
|
|
+ if (isMonth) {
|
|
|
+ type ? listYM[0]-- : listYM[0]++;
|
|
|
+ that.list("month", index)
|
|
|
+ }
|
|
|
+ if (isYear || isMonth) {
|
|
|
+ lay.extend(dateTime, {
|
|
|
+ year: listYM[0]
|
|
|
+ });
|
|
|
+ if (isAlone)
|
|
|
+ that[startEnd].year = listYM[0];
|
|
|
+ options.range || that.done(null, "change");
|
|
|
+ that.setBtnStatus();
|
|
|
+ options.range || that.limit(lay(that.footer).find(ELEM_CONFIRM), {
|
|
|
+ year: listYM[0]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return isYear || isMonth
|
|
|
+ };
|
|
|
+ return {
|
|
|
+ prevYear: function() {
|
|
|
+ if (addSubYeay("sub"))
|
|
|
+ return;
|
|
|
+ dateTime.year--;
|
|
|
+ that.checkDate("limit").calendar();
|
|
|
+ options.range || that.done(null, "change")
|
|
|
+ },
|
|
|
+ prevMonth: function() {
|
|
|
+ var YM = that.getAsYM(dateTime.year, dateTime.month, "sub");
|
|
|
+ lay.extend(dateTime, {
|
|
|
+ year: YM[0],
|
|
|
+ month: YM[1]
|
|
|
+ });
|
|
|
+ that.checkDate("limit").calendar();
|
|
|
+ options.range || that.done(null, "change")
|
|
|
+ },
|
|
|
+ nextMonth: function() {
|
|
|
+ var YM = that.getAsYM(dateTime.year, dateTime.month);
|
|
|
+ lay.extend(dateTime, {
|
|
|
+ year: YM[0],
|
|
|
+ month: YM[1]
|
|
|
+ });
|
|
|
+ that.checkDate("limit").calendar();
|
|
|
+ options.range || that.done(null, "change")
|
|
|
+ },
|
|
|
+ nextYear: function() {
|
|
|
+ if (addSubYeay())
|
|
|
+ return;
|
|
|
+ dateTime.year++;
|
|
|
+ that.checkDate("limit").calendar();
|
|
|
+ options.range || that.done(null, "change")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.changeEvent = function() {
|
|
|
+ var that = this
|
|
|
+ , options = that.config;
|
|
|
+ lay(that.elem).on("click", function(e) {
|
|
|
+ lay.stope(e)
|
|
|
+ });
|
|
|
+ lay.each(that.elemHeader, function(i, header) {
|
|
|
+ lay(header[0]).on("click", function(e) {
|
|
|
+ that.change(i).prevYear()
|
|
|
+ });
|
|
|
+ lay(header[1]).on("click", function(e) {
|
|
|
+ that.change(i).prevMonth()
|
|
|
+ });
|
|
|
+ lay(header[2]).find("span").on("click", function(e) {
|
|
|
+ var othis = lay(this)
|
|
|
+ , layYM = othis.attr("lay-ym")
|
|
|
+ , layType = othis.attr("lay-type");
|
|
|
+ if (!layYM)
|
|
|
+ return;
|
|
|
+ layYM = layYM.split("-");
|
|
|
+ that.listYM[i] = [layYM[0] | 0, layYM[1] | 0];
|
|
|
+ that.list(layType, i);
|
|
|
+ lay(that.footer).find(ELEM_TIME_BTN).addClass(DISABLED)
|
|
|
+ });
|
|
|
+ lay(header[3]).on("click", function(e) {
|
|
|
+ that.change(i).nextMonth()
|
|
|
+ });
|
|
|
+ lay(header[4]).on("click", function(e) {
|
|
|
+ that.change(i).nextYear()
|
|
|
+ })
|
|
|
+ });
|
|
|
+ lay.each(that.table, function(i, table) {
|
|
|
+ var tds = lay(table).find("td");
|
|
|
+ tds.on("click", function() {
|
|
|
+ that.choose(lay(this))
|
|
|
+ })
|
|
|
+ });
|
|
|
+ lay(that.footer).find("span").on("click", function() {
|
|
|
+ var type = lay(this).attr("lay-type");
|
|
|
+ that.tool(this, type)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.isInput = function(elem) {
|
|
|
+ return /input|textarea/.test(elem.tagName.toLocaleLowerCase())
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ Class.prototype.events = function() {
|
|
|
+ var that = this
|
|
|
+ , options = that.config
|
|
|
+ , showEvent = function(elem, bind) {
|
|
|
+ elem.on(options.trigger, function() {
|
|
|
+ bind && (that.bindElem = this);
|
|
|
+ that.render()
|
|
|
+ })
|
|
|
+ };
|
|
|
+ if (!options.elem[0] || options.elem[0].eventHandler)
|
|
|
+ return;
|
|
|
+ showEvent(options.elem, "bind");
|
|
|
+ showEvent(options.eventElem);
|
|
|
+ lay(document).on("click", function(e) {
|
|
|
+ if (e.target === options.elem[0] || e.target === options.eventElem[0] || e.target === lay(options.closeStop)[0]) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ that.remove()
|
|
|
+ }).on("keydown", function(e) {
|
|
|
+ if (e.keyCode === 13) {
|
|
|
+ if (lay("#" + that.elemID)[0] && that.elemID === Class.thisElem) {
|
|
|
+ e.preventDefault();
|
|
|
+ lay(that.footer).find(ELEM_CONFIRM)[0].click()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ lay(window).on("resize", function() {
|
|
|
+ if (!that.elem || !lay(ELEM)[0]) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ that.position()
|
|
|
+ });
|
|
|
+ options.elem[0].eventHandler = true
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ laydate.render = function(options) {
|
|
|
+ var inst = new Class(options);
|
|
|
+ return thisDate.call(inst)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ laydate.getEndDate = function(month, year) {
|
|
|
+ var thisDate = new Date;
|
|
|
+ thisDate.setFullYear(year || thisDate.getFullYear(), month || thisDate.getMonth() + 1, 1);
|
|
|
+ return new Date(thisDate.getTime() - 1e3 * 60 * 60 * 24).getDate()
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ window.lay = window.lay || lay;
|
|
|
+ window.laydatetime = laydate
|
|
|
+}();
|
|
|
+(function() {
|
|
|
+ z.ui.comm.inheritClass(time, dateComp);
|
|
|
+ z.ui.comm.inheritClass(date, dateComp);
|
|
|
+ z.ui.comm.inheritClass(datetime, dateComp);
|
|
|
+ z.ui.comm.inheritClass(laydate, dateComp);
|
|
|
+ z.ui.laydate = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = new laydate(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function laydate(selector) {
|
|
|
+ return dateComp.call(this, selector)
|
|
|
+ }
|
|
|
+ laydate.prototype.init = function(option) {
|
|
|
+ if (!option)
|
|
|
+ return;
|
|
|
+ dateCompInit.call(this, option)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.date = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = new date(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function date(selector) {
|
|
|
+ return dateComp.call(this, selector)
|
|
|
+ }
|
|
|
+ date.prototype.init = function() {
|
|
|
+ dateCompInit.call(this, {
|
|
|
+ type: "date",
|
|
|
+ format: "yyyy-MM-dd"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.datetime = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = new datetime(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function datetime(selector) {
|
|
|
+ return dateComp.call(this, selector)
|
|
|
+ }
|
|
|
+ datetime.prototype.init = function() {
|
|
|
+ dateCompInit.call(this, {
|
|
|
+ type: "datetime",
|
|
|
+ format: "yyyy-MM-dd HH:mm:ss"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.time = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = new time(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function time(selector) {
|
|
|
+ return dateComp.call(this, selector)
|
|
|
+ }
|
|
|
+ time.prototype.init = function(option) {
|
|
|
+ dateCompInit.call(this, {
|
|
|
+ type: "time",
|
|
|
+ format: "HH:mm:ss"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function dateComp(selector) {
|
|
|
+ this.isenable = !selector.hasClass("z-readonly");
|
|
|
+ this.selector = selector
|
|
|
+ }
|
|
|
+ function dateCompInit(option) {
|
|
|
+ if (!this.isenable) {
|
|
|
+ this.selector.find("input").attr("disabled", "disabled")
|
|
|
+ }
|
|
|
+ var _this = this;
|
|
|
+ this.elem = this.selector.find("input").get(0);
|
|
|
+ var opt = $.extend(true, {
|
|
|
+ type: "date",
|
|
|
+ format: "yyyy-MM-dd",
|
|
|
+ elem: this.elem
|
|
|
+ }, option);
|
|
|
+ this.option = opt;
|
|
|
+ if (option.format) {
|
|
|
+ this.elem.value = parseTime(this.elem.value, this.option.format)
|
|
|
+ }
|
|
|
+ if (z.ui.comm.isDingTalk()) {
|
|
|
+ var ev = opt.type + "picker";
|
|
|
+ this.selector.find("input").attr("readonly", "readonly").on("touchstart ", function() {
|
|
|
+ dd.biz.util[ev]({
|
|
|
+ format: opt.format,
|
|
|
+ value: _this.elem.value,
|
|
|
+ onSuccess: function(result) {
|
|
|
+ var val = parseInt(result.value.replace(/[^0-9]/gi, ""));
|
|
|
+ if (opt.maxlink) {
|
|
|
+ var _max = $(opt.maxlink).find("input").val();
|
|
|
+ if (_max) {
|
|
|
+ if (val > parseInt(_max.replace(/[^0-9]/gi, ""))) {
|
|
|
+ $(opt.maxlink).find("input").val(result.value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (opt.minlink) {
|
|
|
+ var _min = $(opt.minlink).find("input").val();
|
|
|
+ if (_min) {
|
|
|
+ if (val < _min.replace(/[^0-9]/gi, "")) {
|
|
|
+ $(opt.minlink).find("input").val(result.value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _this.elem.value = result.value;
|
|
|
+ opt.done(result.value)
|
|
|
+ },
|
|
|
+ onFail: function(err) {}
|
|
|
+ })
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (option.format) {
|
|
|
+ if (option.type == "datetime") {
|
|
|
+ if (option.format.split(" ")[1].split(":").length == 2) {
|
|
|
+ opt.nosecond = true;
|
|
|
+ opt.wrapclass = "nosecond"
|
|
|
+ }
|
|
|
+ } else if (option.type == "time") {
|
|
|
+ if (option.format.split(" ")[0].split(":").length == 2) {
|
|
|
+ opt.nosecond = true;
|
|
|
+ opt.wrapclass = "nosecond"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (opt.maxlink) {
|
|
|
+ var _max = $(opt.maxlink).find("input").val();
|
|
|
+ if (_max) {
|
|
|
+ opt.max = _max
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (opt.minlink) {
|
|
|
+ var _min = $(opt.minlink).find("input").val();
|
|
|
+ if (_min) {
|
|
|
+ opt.min = _min
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var _done = opt.done;
|
|
|
+ opt.done = function() {
|
|
|
+ var date = arguments[1];
|
|
|
+ if (opt.maxlink) {
|
|
|
+ if (!arguments[0]) {
|
|
|
+ z.ui.laydate(opt.maxlink).laydate.config.min = {
|
|
|
+ year: 1970,
|
|
|
+ month: 0,
|
|
|
+ date: 1,
|
|
|
+ hours: 0,
|
|
|
+ minutes: 0,
|
|
|
+ seconds: 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ z.ui.laydate(opt.maxlink).laydate.config.min = {
|
|
|
+ year: date.year,
|
|
|
+ month: date.month - 1,
|
|
|
+ date: date.date,
|
|
|
+ hours: date.hours,
|
|
|
+ minutes: date.minutes,
|
|
|
+ seconds: date.seconds
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (opt.minlink) {
|
|
|
+ if (!arguments[0]) {
|
|
|
+ z.ui.laydate(opt.minlink).laydate.config.max = {
|
|
|
+ year: 2099,
|
|
|
+ month: 12,
|
|
|
+ date: 31,
|
|
|
+ hours: 23,
|
|
|
+ minutes: 59,
|
|
|
+ seconds: 59
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ z.ui.laydate(opt.minlink).laydate.config.max = {
|
|
|
+ year: date.year,
|
|
|
+ month: date.month - 1,
|
|
|
+ date: date.date,
|
|
|
+ hours: date.hours,
|
|
|
+ minutes: date.minutes,
|
|
|
+ seconds: date.seconds
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _done && _done.apply(this, arguments)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ this.laydate = laydatetime.render(opt)
|
|
|
+ }
|
|
|
+ dateComp.prototype.getValue = function() {
|
|
|
+ return this.selector.find("input").val()
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ dateComp.prototype.setValue = function(val) {
|
|
|
+ this.selector.find("input").val(parseTime(val, this.option.format))
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function parseTime(datetime, format) {
|
|
|
+ if (!datetime)
|
|
|
+ return datetime;
|
|
|
+ var val = datetime.replace(/-/g, "/");
|
|
|
+ if (val) {
|
|
|
+ var _date = new Date(val);
|
|
|
+ if (!isNaN(_date.getTime())) {
|
|
|
+ val = _date.format(format)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return val
|
|
|
+ }
|
|
|
+}
|
|
|
+)(window);
|
|
|
+(function() {
|
|
|
+ z.ui.tips = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comptips) {
|
|
|
+ selector.get(0).comptips = new tips(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comptips
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function tips(selector) {
|
|
|
+ this.iscomprender = false;
|
|
|
+ this.selector = selector
|
|
|
+ }
|
|
|
+ tips.prototype.init = function(option) {
|
|
|
+ this.remove();
|
|
|
+ this.iscomprender = true;
|
|
|
+ var opt = $.extend(true, {
|
|
|
+ zid: z.ui.comm.createCompId("z_tips"),
|
|
|
+ width: 0,
|
|
|
+ height: 0,
|
|
|
+ content: "",
|
|
|
+ defaultshow: false,
|
|
|
+ pos: "top",
|
|
|
+ classname: ""
|
|
|
+ }, option);
|
|
|
+ this.pos = opt.pos;
|
|
|
+ var selp = this.selector.parent();
|
|
|
+ this.tips = $('<div style="' + (opt.height ? "height:" + opt.height + "px;" : "") + (opt.width ? "width:" + opt.width + "px;" : "") + (opt.zindex ? "z-index:" + opt.zindex + ";" : "") + '" class="z-tips-wrap ' + opt.classname + '" id="' + opt.zid + '"><i class="z-tips-arrow"></i>' + '<div class="z-tips-box">' + opt.content + "</div></div>").appendTo(selp);
|
|
|
+ this.option = opt;
|
|
|
+ z.ui.comm.setPosition(selp);
|
|
|
+ if (opt.defaultshow) {
|
|
|
+ this.show()
|
|
|
+ } else {
|
|
|
+ if (this.selector.length) {
|
|
|
+ var _this = this;
|
|
|
+ this.selector.on("mouseover", function() {
|
|
|
+ _this.show()
|
|
|
+ }).on("mouseout", function() {
|
|
|
+ _this.hide()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ tips.prototype.show = function() {
|
|
|
+ var spo = this.selector.parent().offset();
|
|
|
+ var ww = $(window).outerWidth()
|
|
|
+ , wh = $(window).outerHeight()
|
|
|
+ , tw = this.tips.outerWidth()
|
|
|
+ , th = this.tips.outerHeight()
|
|
|
+ , sl = this.selector.offset().left
|
|
|
+ , st = this.selector.offset().top
|
|
|
+ , sw = this.selector.outerWidth()
|
|
|
+ , sh = this.selector.outerHeight();
|
|
|
+ var arw = 6
|
|
|
+ , _this = this;
|
|
|
+ var cant = z.ui.comm.getCompAccomTop(this.selector) - th - arw
|
|
|
+ , canb = wh - st - sh - th - arw
|
|
|
+ , canl = sl - tw - arw
|
|
|
+ , canr = ww - sl - sw - tw - arw;
|
|
|
+ var _left = 0
|
|
|
+ , _top = 0;
|
|
|
+ if (this.option.pos === "top") {
|
|
|
+ toTop() || toBottom() || toLeft() || toRight()
|
|
|
+ } else if (this.option.pos === "bottom") {
|
|
|
+ toBottom() || toTop() || toLeft() || toRight()
|
|
|
+ } else if (this.option.pos === "left") {
|
|
|
+ toLeft() || toTop() || toBottom() || toRight()
|
|
|
+ } else if (this.option.pos === "right") {
|
|
|
+ toRight() || toTop() || toBottom() || toLeft()
|
|
|
+ }
|
|
|
+ function toTop() {
|
|
|
+ if (cant > 0) {
|
|
|
+ _top = st - th - spo.top - arw;
|
|
|
+ var l = sl + sw / 2 - tw / 2;
|
|
|
+ _left = l - spo.left;
|
|
|
+ _this.pos = "top";
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function toBottom() {
|
|
|
+ if (canb > 0) {
|
|
|
+ _top = st + sh - spo.top + arw;
|
|
|
+ var l = sl + sw / 2 - tw / 2;
|
|
|
+ _left = l - spo.left;
|
|
|
+ _this.pos = "bottom";
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function toLeft() {
|
|
|
+ if (canl > 0) {
|
|
|
+ _left = sl - tw - spo.left - arw;
|
|
|
+ var t = st + sh / 2 - th / 2;
|
|
|
+ _top = t - spo.top;
|
|
|
+ _this.pos = "left";
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function toRight() {
|
|
|
+ if (canr > 0) {
|
|
|
+ _left = sl + sw - spo.left + arw;
|
|
|
+ var t = st + sh / 2 - th / 2;
|
|
|
+ _top = t - spo.top;
|
|
|
+ _this.pos = "right";
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ((_this.pos == "left" || _this.pos == "right") && _top < 0) {
|
|
|
+ _top = 0;
|
|
|
+ this.tips.find(".z-tips-arrow").css({
|
|
|
+ top: st + sh / 2
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.tips.removeClass("z-tips-pos-top").removeClass("z-tips-pos-left").removeClass("z-tips-pos-left").removeClass("z-tips-pos-right").addClass("z-tips-pos-" + this.pos).show().css({
|
|
|
+ left: _left + "px",
|
|
|
+ top: _top + "px"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ tips.prototype.hide = function() {
|
|
|
+ this.tips.hide()
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ tips.prototype.remove = function() {
|
|
|
+ if (this.iscomprender == false)
|
|
|
+ return;
|
|
|
+ this.iscomprender = false;
|
|
|
+ if (!this.option.defaultshow) {
|
|
|
+ this.selector.off("mouseover", this.show).off("mouseout", this.hide)
|
|
|
+ }
|
|
|
+ this.tips.remove()
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ var compstack = {};
|
|
|
+ z.ui.alert = function(compid) {
|
|
|
+ if (!compid) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!compstack[compid]) {
|
|
|
+ compstack[compid] = new alert(compid)
|
|
|
+ }
|
|
|
+ return compstack[compid]
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function alert(compid) {
|
|
|
+ this.compid = compid;
|
|
|
+ this.timer = null
|
|
|
+ }
|
|
|
+ alert.prototype.init = function(option) {
|
|
|
+ if (compstack[this.compid].alert) {
|
|
|
+ clearTimeout(this.timer);
|
|
|
+ this.alert.stop().remove();
|
|
|
+ if (this.mask) {
|
|
|
+ this.mask.remove()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var opt = $.extend(true, {
|
|
|
+ zid: z.ui.comm.createCompId("z_alert"),
|
|
|
+ iconclass: "",
|
|
|
+ wrapclass: "",
|
|
|
+ content: "",
|
|
|
+ timeout: 0,
|
|
|
+ showclosebtn: false,
|
|
|
+ showmask: false,
|
|
|
+ maskbg: true,
|
|
|
+ onBeforeClose: function() {},
|
|
|
+ onAfterClose: function() {}
|
|
|
+ }, option);
|
|
|
+ var compstr = (opt.showmask ? '<div id="' + opt.zid + "_mask" + '" class="z-modal-mask ' + (opt.maskbg ? "mask" : "") + '" style="' + (opt.zindex ? "z-index:" + parseInt(opt.zindex) : "") + ';"></div>' : "") + '<div class="z-alert-wrap ' + opt.wrapclass + '" id=' + opt.zid + ' style="' + (opt.zindex ? "z-index:" + (parseInt(opt.zindex) + 1) : "") + ';"><div class="z-alert-body">' + '<span class="z-alert-icon ' + opt.iconclass + '"></span><span class="z-alert-content" ' + (opt.iconclass ? 'style="padding-left:77px;"' : "") + ">" + $.trim(opt.content) + "</span>" + (opt.showclosebtn ? '<span class="z-alert-close">×</span>' : "") + "</div></div>";
|
|
|
+ $("body").append(compstr);
|
|
|
+ this.option = opt;
|
|
|
+ this.alert = $("#" + opt.zid);
|
|
|
+ var _this = this;
|
|
|
+ if (opt.showclosebtn === true) {
|
|
|
+ this.alert.find(".z-alert-close").click(function() {
|
|
|
+ _this.close()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (opt.showmask === true) {
|
|
|
+ this.mask = $("#" + opt.zid + "_mask")
|
|
|
+ }
|
|
|
+ this.show();
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ alert.prototype.close = function(data, trigger) {
|
|
|
+ if (trigger === false) {
|
|
|
+ closeAlert.call(this, data)
|
|
|
+ } else {
|
|
|
+ if (this.option.onBeforeClose.call(this, data) === false)
|
|
|
+ return;
|
|
|
+ closeAlert.call(this, data);
|
|
|
+ this.option.onAfterClose(data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function closeAlert(data) {
|
|
|
+ var _this = this;
|
|
|
+ clearTimeout(this.timer);
|
|
|
+ this.alert.fadeOut(function() {
|
|
|
+ _this.alert.remove();
|
|
|
+ compstack[_this.compid] = null
|
|
|
+ });
|
|
|
+ if (this.option.showmask === true) {
|
|
|
+ this.mask.remove()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ alert.prototype.show = function() {
|
|
|
+ var _this = this;
|
|
|
+ var time = parseInt(this.option.timeout);
|
|
|
+ if (!isNaN(time) && time > 0) {
|
|
|
+ _this.timer = setTimeout(function() {
|
|
|
+ _this.close()
|
|
|
+ }, time)
|
|
|
+ }
|
|
|
+ if (this.option.showmask === true) {
|
|
|
+ this.mask.show()
|
|
|
+ }
|
|
|
+ var con = this.alert;
|
|
|
+ this.alert.show().css({
|
|
|
+ top: "50%",
|
|
|
+ left: "50%",
|
|
|
+ marginLeft: -con.width() / 2,
|
|
|
+ marginTop: -con.height() / 2
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ function setArguments(arr) {
|
|
|
+ var res = {};
|
|
|
+ for (var i = 0, len = arr.length; i < len; i++) {
|
|
|
+ if (z.ui.comm.checkType(arr[i], "Function")) {
|
|
|
+ res.callback = arr[i]
|
|
|
+ } else if (z.ui.comm.checkType(arr[i], "String")) {
|
|
|
+ res.content = arr[i]
|
|
|
+ } else if (z.ui.comm.checkType(arr[i], "Number")) {
|
|
|
+ res.timeout = arr[i]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res
|
|
|
+ }
|
|
|
+ z.ui.alertSuccess = function(content, timeout, callback) {
|
|
|
+ var res = setArguments(arguments);
|
|
|
+ z.ui.alert("z_ui_alert_success").init({
|
|
|
+ iconclass: "z-icon z-icon-success",
|
|
|
+ wrapclass: "z-alert-success-wrap",
|
|
|
+ content: res.content || "成功",
|
|
|
+ onAfterClose: res.callback,
|
|
|
+ timeout: res.timeout || 1e3
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.alertError = function(content, callback) {
|
|
|
+ var res = setArguments(arguments);
|
|
|
+ z.ui.alert("z_ui_alert_error").init({
|
|
|
+ iconclass: "z-icon z-icon-error",
|
|
|
+ wrapclass: "z-alert-error-wrap",
|
|
|
+ content: res.content || "错误",
|
|
|
+ onAfterClose: res.callback,
|
|
|
+ timeout: 3e3,
|
|
|
+ showclosebtn: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.alertWarning = function(content, timeout, callback) {
|
|
|
+ var res = setArguments(arguments);
|
|
|
+ z.ui.alert("z_ui_alert_warning").init({
|
|
|
+ iconclass: "z-icon z-icon-warning ",
|
|
|
+ wrapclass: "z-alert-warning-wrap",
|
|
|
+ content: res.content || "警告",
|
|
|
+ onAfterClose: res.callback,
|
|
|
+ timeout: res.timeout || 3e3
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.alertInfo = function(content, timeout, callback) {
|
|
|
+ var res = setArguments(arguments);
|
|
|
+ z.ui.alert("z_ui_alert_info").init({
|
|
|
+ iconclass: "z-icon z-icon-info",
|
|
|
+ wrapclass: "z-alert-info-wrap",
|
|
|
+ content: res.content || "信息",
|
|
|
+ onAfterClose: res.callback,
|
|
|
+ timeout: res.timeout || 3e3
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.loading = function(show, showicon, timeout, content) {
|
|
|
+ if (show === false) {
|
|
|
+ z.ui.alert("z_ui_alert_loading").alert && z.ui.alert("z_ui_alert_loading").close()
|
|
|
+ } else {
|
|
|
+ z.ui.alert("z_ui_alert_loading").init({
|
|
|
+ wrapclass: "z-loading-wrap",
|
|
|
+ timeout: timeout || 0,
|
|
|
+ showmask: true,
|
|
|
+ maskbg: false,
|
|
|
+ content: showicon ? content || "加载中..." : "",
|
|
|
+ zindex: 99999
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ var compstack = {};
|
|
|
+ z.ui.confirm = function(compid) {
|
|
|
+ if (!compid) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!compstack[compid]) {
|
|
|
+ compstack[compid] = new confirm(compid)
|
|
|
+ }
|
|
|
+ return compstack[compid]
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function confirm(compid) {
|
|
|
+ this.iscomprender = false;
|
|
|
+ this.compid = compid
|
|
|
+ }
|
|
|
+ confirm.prototype.init = function(option) {
|
|
|
+ if (this.iscomprender) {
|
|
|
+ this.close()
|
|
|
+ } else {
|
|
|
+ this.iscomprender = true
|
|
|
+ }
|
|
|
+ var opt = {
|
|
|
+ title: option.title || "操作提示",
|
|
|
+ wrapclassname: "z-confirm-wrap",
|
|
|
+ zid: z.ui.comm.createCompId("z_alert"),
|
|
|
+ content: '<div class="z-confirm-body"><div><i class="z-confirm-icon z-icon z-icon-question"></i></div><span class="z-confirm-text">' + option.content + "</span></div>",
|
|
|
+ showclosebtn: false,
|
|
|
+ showmask: option.showmask,
|
|
|
+ buttons: [{
|
|
|
+ text: "确定",
|
|
|
+ classname: "btn btn-lg btn-info",
|
|
|
+ onClick: function(modal) {
|
|
|
+ option.onConfirm && option.onConfirm.call(this);
|
|
|
+ modal.close()
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ text: "取消",
|
|
|
+ classname: "btn btn-lg btn-cancel",
|
|
|
+ onClick: function(modal) {
|
|
|
+ option.onCancel && option.onCancel.call(this);
|
|
|
+ modal.close()
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ };
|
|
|
+ return z.ui.modal("confirm_" + this.compid).init(opt)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ confirm.prototype.close = function() {
|
|
|
+ if (this.iscomprender == false)
|
|
|
+ return;
|
|
|
+ this.iscomprender = false;
|
|
|
+ z.ui.modal("confirm_" + this.compid).close()
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ var compstack = {};
|
|
|
+ z.ui.modal = function(compid) {
|
|
|
+ if (!compid) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!compstack[compid]) {
|
|
|
+ compstack[compid] = new modal(compid)
|
|
|
+ }
|
|
|
+ return compstack[compid]
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function modal(compid) {
|
|
|
+ this.iscomprender = false;
|
|
|
+ this.compid = compid;
|
|
|
+ this.custom = {};
|
|
|
+ this.childcompids = []
|
|
|
+ }
|
|
|
+ modal.prototype.init = function(option) {
|
|
|
+ if (this.iscomprender) {
|
|
|
+ removeModal.call(compstack[this.compid])
|
|
|
+ }
|
|
|
+ this.iscomprender = true;
|
|
|
+ var opt = $.extend(true, {
|
|
|
+ zid: z.ui.comm.createCompId("z_modal"),
|
|
|
+ url: "",
|
|
|
+ data: {},
|
|
|
+ content: "",
|
|
|
+ title: "",
|
|
|
+ pcompid: "",
|
|
|
+ iframe: false,
|
|
|
+ width: 0,
|
|
|
+ height: 0,
|
|
|
+ wrapclassname: "",
|
|
|
+ showhead: true,
|
|
|
+ showclosebtn: true,
|
|
|
+ showmask: true,
|
|
|
+ masktoclose: false,
|
|
|
+ maskbg: true,
|
|
|
+ buttons: [],
|
|
|
+ onLoadSuccess: function() {},
|
|
|
+ onBeforeShow: function() {},
|
|
|
+ onAfterShow: function() {},
|
|
|
+ onBeforeClose: function() {},
|
|
|
+ onAfterClose: function() {},
|
|
|
+ onLoadError: function(xhr, ts, err) {
|
|
|
+ z.ui.alertError(ts)
|
|
|
+ }
|
|
|
+ }, option);
|
|
|
+ if (opt.pcompid) {
|
|
|
+ var pmodal = compstack[opt.pcompid];
|
|
|
+ if (pmodal && pmodal.childcompids.indexOf(this.compid) == -1) {
|
|
|
+ pmodal.childcompids.push(this.compid)
|
|
|
+ }
|
|
|
+ opt.showmask = false;
|
|
|
+ this.zindex = pmodal.zindex
|
|
|
+ } else {
|
|
|
+ var maxindex = this.zindex = 8e3;
|
|
|
+ $.each(compstack, function(k, v) {
|
|
|
+ if (v.iscomprender && maxindex < v.zindex) {
|
|
|
+ maxindex = v.zindex
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.zindex = maxindex + 2
|
|
|
+ }
|
|
|
+ if (opt.width && z.ui.comm.checkType(opt.width, "String") && opt.width.indexOf("%") > -1) {
|
|
|
+ opt.width = document.documentElement.clientWidth * parseFloat(opt.width.substring(0, opt.width.length - 1)) / 100
|
|
|
+ }
|
|
|
+ if (opt.height && z.ui.comm.checkType(opt.height, "String") && opt.height.indexOf("%") > -1) {
|
|
|
+ opt.height = document.documentElement.clientHeight * parseFloat(opt.height.substring(0, opt.height.length - 1)) / 100
|
|
|
+ }
|
|
|
+ if (opt.buttons.length) {
|
|
|
+ var btns = opt.buttons
|
|
|
+ , btnstr = '<div class="z-modal-footer z-btn-bar text-right">';
|
|
|
+ for (var i = 0, len = btns.length; i < len; i++) {
|
|
|
+ btnstr += '<span index="' + i + '" class="z-modal-footer-btn ' + btns[i].classname + '">' + btns[i].text + "</span>"
|
|
|
+ }
|
|
|
+ btnstr += "</div>"
|
|
|
+ }
|
|
|
+ var compstr = (opt.showmask ? '<div id="' + opt.zid + "_mask" + '" class="z-modal-mask ' + (opt.maskbg ? "mask" : "") + '" style="' + (this.zindex ? "z-index:" + this.zindex : "") + ';"></div>' : "") + '<div class="z-modal-wrap ' + opt.wrapclassname + '" id=' + opt.zid + ' style="' + (this.zindex ? "z-index:" + (this.zindex + 1) : "") + ';">' + (opt.showhead ? '<div class="z-modal-head"><span class="z-modal-title">' + opt.title + "</span>" + (opt.showclosebtn ? '<span class="z-modal-close">×</span>' : "") + "</div>" : "") + '<div class="z-modal-body">' + (opt.iframe ? '<iframe frameborder="no" border="0" class="z-modal-iframe"></iframe>' : "") + "</div>" + (opt.buttons.length ? btnstr : "") + '<div class="z-modal-loading">加载中...</div></div>';
|
|
|
+ $("body").append(compstr);
|
|
|
+ this.modal = $("#" + opt.zid);
|
|
|
+ this.option = opt;
|
|
|
+ if (opt.showhead === true) {
|
|
|
+ z.ui.comm.dragBox({
|
|
|
+ dragel: this.modal.find(".z-modal-head"),
|
|
|
+ targel: this.modal
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.modalBody = this.modal.find(".z-modal-body");
|
|
|
+ this.modalloading = this.modal.find(".z-modal-loading");
|
|
|
+ var _this = this;
|
|
|
+ if (opt.showclosebtn === true) {
|
|
|
+ this.modal.find(".z-modal-close").click(function() {
|
|
|
+ _this.close()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (opt.showmask === true) {
|
|
|
+ this.mask = $("#" + opt.zid + "_mask");
|
|
|
+ if (opt.showmask && opt.masktoclose) {
|
|
|
+ this.mask.click(function() {
|
|
|
+ _this.close()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (opt.buttons.length) {
|
|
|
+ this.modal.find(".z-modal-footer").on("click", ".z-modal-footer-btn", function() {
|
|
|
+ var index = $(this).attr("index");
|
|
|
+ opt.buttons[index].onClick(_this)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.reload();
|
|
|
+ this.show();
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function removeModal() {
|
|
|
+ this.iscomprender = false;
|
|
|
+ this.modal && this.modal.remove();
|
|
|
+ this.mask && this.mask.remove()
|
|
|
+ }
|
|
|
+ function unbindPModal() {
|
|
|
+ if (this.option.pcompid) {
|
|
|
+ var pmodal = compstack[this.option.pcompid];
|
|
|
+ if (pmodal) {
|
|
|
+ pmodal.childcompids.splice(pmodal.childcompids.indexOf(this.compid), 1);
|
|
|
+ var pmw = pmodal.option.width || pmodal.modal.width()
|
|
|
+ , pmh = pmodal.option.height || pmodal.modal.height()
|
|
|
+ , pml = parseInt((document.documentElement.clientWidth - pmw) / 2)
|
|
|
+ , pmt = parseInt((document.documentElement.clientHeight - pmh) / 2);
|
|
|
+ pmt = pmt > 50 ? pmt - 20 : pmt;
|
|
|
+ pmodal.modal.css({
|
|
|
+ left: pml + "px",
|
|
|
+ top: pmt + "px"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ modal.prototype.setTitle = function(title) {
|
|
|
+ this.modal.find(".z-modal-head .z-modal-title").html(title)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ modal.prototype.close = function(data, trigger) {
|
|
|
+ if (this.iscomprender == false)
|
|
|
+ return;
|
|
|
+ if (this.childcompids.length > 0) {
|
|
|
+ z.ui.alertWarning("请先关闭子弹窗");
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (trigger === false) {
|
|
|
+ removeModal.call(this, data);
|
|
|
+ unbindPModal.call(this)
|
|
|
+ } else {
|
|
|
+ if (this.option.onBeforeClose.call(this, data) === false)
|
|
|
+ return;
|
|
|
+ removeModal.call(this);
|
|
|
+ unbindPModal.call(this);
|
|
|
+ this.option.onAfterClose.call(this, data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ modal.prototype.show = function() {
|
|
|
+ if (this.iscomprender == false)
|
|
|
+ return;
|
|
|
+ if (this.option.onBeforeShow.call(this) === false)
|
|
|
+ return;
|
|
|
+ var cw = document.documentElement.clientWidth
|
|
|
+ , ch = document.documentElement.clientHeight
|
|
|
+ , mw = this.option.width || this.modal.width() || this.modal.width()
|
|
|
+ , mh = this.option.height || this.modal.height();
|
|
|
+ mw = mw > cw ? cw : mw;
|
|
|
+ mh = mh > ch ? ch : mh;
|
|
|
+ var ml = parseInt((cw - mw) / 2)
|
|
|
+ , mt = parseInt((ch - mh) / 2);
|
|
|
+ mt = mt > 50 ? mt - 20 : mt;
|
|
|
+ if (this.option.pcompid) {
|
|
|
+ var pmodal = compstack[this.option.pcompid];
|
|
|
+ if (pmodal) {
|
|
|
+ var pmw = pmodal.option.width || pmodal.modal.width()
|
|
|
+ , pmh = pmodal.option.height || pmodal.modal.height()
|
|
|
+ , pml = parseInt((cw - mw - pmw - 20) / 2)
|
|
|
+ , pmt = parseInt((ch - pmh) / 2);
|
|
|
+ pmt = pmt > 50 ? pmt - 20 : pmt;
|
|
|
+ pmodal.modal.css({
|
|
|
+ left: pml + "px",
|
|
|
+ top: pmt + "px"
|
|
|
+ });
|
|
|
+ ml = pml + pmw + 20
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.modal.show().css({
|
|
|
+ width: mw + "px",
|
|
|
+ height: mh + "px",
|
|
|
+ left: ml + "px",
|
|
|
+ top: mt + "px"
|
|
|
+ });
|
|
|
+ if (this.option.height) {
|
|
|
+ this.modalBody.css({
|
|
|
+ height: mh - (this.option.showhead === true ? 34 : 0) - (this.option.buttons.length > 0 ? 40 : 0) + "px"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (this.option.showmask) {
|
|
|
+ this.mask.show()
|
|
|
+ }
|
|
|
+ this.option.onAfterShow.call(this)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ modal.prototype.setSize = function(option) {
|
|
|
+ var cw = document.documentElement.clientWidth
|
|
|
+ , ch = document.documentElement.clientHeight;
|
|
|
+ var offset = this.modal.offset()
|
|
|
+ , mw = this.modal.width()
|
|
|
+ , mh = this.modal.height()
|
|
|
+ , mt = offset.top
|
|
|
+ , ml = offset.left;
|
|
|
+ if (option.width) {
|
|
|
+ if (option.width > cw) {
|
|
|
+ mw = cw
|
|
|
+ } else {
|
|
|
+ mw = option.width
|
|
|
+ }
|
|
|
+ ml = (cw - mw) / 2
|
|
|
+ }
|
|
|
+ if (option.height) {
|
|
|
+ if (option.height > ch) {
|
|
|
+ mh = ch
|
|
|
+ } else {
|
|
|
+ mh = option.height
|
|
|
+ }
|
|
|
+ this.modalBody.css({
|
|
|
+ height: mh - (this.option.showhead === true ? 34 : 0) - (this.option.buttons.length > 0 ? 40 : 0) + "px"
|
|
|
+ });
|
|
|
+ mt = (ch - mh) / 2;
|
|
|
+ mt = mt > 50 ? mt - 20 : mt
|
|
|
+ }
|
|
|
+ if (option.top) {
|
|
|
+ if (option.top < 0) {
|
|
|
+ mt = 0
|
|
|
+ } else if (option.top + mh > ch) {
|
|
|
+ mt = ch - mh
|
|
|
+ } else {
|
|
|
+ mt = option.top
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (option.left) {
|
|
|
+ if (option.left < 0) {
|
|
|
+ ml = 0
|
|
|
+ } else if (option.left + mw > cw) {
|
|
|
+ ml = cw - mw
|
|
|
+ } else {
|
|
|
+ ml = option.left
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.modal.css({
|
|
|
+ width: mw,
|
|
|
+ height: mh,
|
|
|
+ left: ml,
|
|
|
+ top: mt
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ modal.prototype.reload = function() {
|
|
|
+ var opt = this.option
|
|
|
+ , _this = this;
|
|
|
+ var cont = $.trim(opt.content);
|
|
|
+ if (cont) {
|
|
|
+ if (opt.iframe) {
|
|
|
+ var body = $(this.modalBody.find(".z-modal-iframe").get(0).contentDocument.body).html(cont);
|
|
|
+ opt.onLoadSuccess.call(_this, null, body)
|
|
|
+ } else {
|
|
|
+ setHtml(this.modalBody, cont);
|
|
|
+ opt.onLoadSuccess.call(_this, null, _this.modalBody)
|
|
|
+ }
|
|
|
+ } else if ($.trim(opt.url)) {
|
|
|
+ this.modalloading.show();
|
|
|
+ if (opt.iframe) {
|
|
|
+ var iframe = this.modalBody.find(".z-modal-iframe");
|
|
|
+ iframe.load(function() {
|
|
|
+ _this.modalloading.hide();
|
|
|
+ try {
|
|
|
+ opt.onLoadSuccess.call(_this, null, $(iframe.get(0).contentDocument.body))
|
|
|
+ } catch (e) {
|
|
|
+ opt.onLoadSuccess.call(_this, null, null)
|
|
|
+ }
|
|
|
+ }).attr("src", opt.url + "?" + $.param(opt.data))
|
|
|
+ } else {
|
|
|
+ var ajaxobj = $.extend(true, {}, opt);
|
|
|
+ ajaxobj.dataType = ajaxobj.dataType || "html";
|
|
|
+ ajaxobj.success = function(res) {
|
|
|
+ if (res.error_code) {
|
|
|
+ ajaxobj.error(null, res.msg, res)
|
|
|
+ } else {
|
|
|
+ _this.modalloading.hide();
|
|
|
+ setHtml(_this.modalBody, res);
|
|
|
+ opt.onLoadSuccess.call(_this, res, _this.modalBody)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ ajaxobj.error = function(xhr, ts, err) {
|
|
|
+ _this.modalloading.hide();
|
|
|
+ opt.onLoadError.call(xhr, ts, err)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.ajax(ajaxobj)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function setHtml(selector, html) {
|
|
|
+ var dom = selector.get(0);
|
|
|
+ dom.innerHTML = html;
|
|
|
+ queueLoadJs(dom)
|
|
|
+ }
|
|
|
+ function queueLoadJs(dom) {
|
|
|
+ var scripts = dom.getElementsByTagName("script");
|
|
|
+ var scriptlen = scripts.length
|
|
|
+ , loadindex = 0;
|
|
|
+ if (scriptlen === 0)
|
|
|
+ return;
|
|
|
+ loadJS(scripts[loadindex]);
|
|
|
+ function loadJS(scriptel) {
|
|
|
+ var domScript = document.createElement("script");
|
|
|
+ var url = scriptel.getAttribute("src");
|
|
|
+ if (url) {
|
|
|
+ domScript.src = url;
|
|
|
+ domScript.onload = domScript.onreadystatechange = function() {
|
|
|
+ if (!this.readyState || "loaded" === this.readyState || "complete" === this.readyState) {
|
|
|
+ this.onload = this.onreadystatechange = null;
|
|
|
+ this.parentNode.removeChild(this);
|
|
|
+ next()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ document.getElementsByTagName("head")[0].appendChild(domScript)
|
|
|
+ } else {
|
|
|
+ $.globalEval((scriptel.text || scriptel.textContent || scriptel.innerHTML || "").replace(/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g, ""));
|
|
|
+ next()
|
|
|
+ }
|
|
|
+ function next() {
|
|
|
+ loadindex++;
|
|
|
+ if (loadindex > scriptlen - 1)
|
|
|
+ return;
|
|
|
+ loadJS(scripts[loadindex])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ var compstack = {};
|
|
|
+ z.ui.progressmodal = function(compid) {
|
|
|
+ if (!compid) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!compstack[compid]) {
|
|
|
+ compstack[compid] = new progressmodal(compid)
|
|
|
+ }
|
|
|
+ return compstack[compid]
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function progressmodal(compid) {
|
|
|
+ this.compid = compid
|
|
|
+ }
|
|
|
+ progressmodal.prototype.init = function(opt) {
|
|
|
+ var _this = this
|
|
|
+ , progress = {};
|
|
|
+ opt.zid = z.ui.comm.createCompId("z_progressmodal");
|
|
|
+ opt.wrapclassname = "z-progressmodal-wrap";
|
|
|
+ opt.title = opt.title || "进度提示";
|
|
|
+ opt.progressoption = opt.progressoption || [];
|
|
|
+ opt.showhead = opt.showhead || false;
|
|
|
+ opt.zindex = 99990;
|
|
|
+ opt.keyid = "id";
|
|
|
+ var constr = '<div class="z-progressmodal-body">';
|
|
|
+ for (var i = 0, len = opt.progressoption.length; i < len; i++) {
|
|
|
+ constr += '<div class="z-progressmodal-row" id="' + this.compid + "_progress" + i + '"></div>'
|
|
|
+ }
|
|
|
+ opt.content = constr + "</div>";
|
|
|
+ opt.onLoadSuccess = function() {
|
|
|
+ for (var i = 0, len = opt.progressoption.length; i < len; i++) {
|
|
|
+ var prog = z.ui.modal(_this.compid + "_modal").modal.find("#" + _this.compid + "_progress" + i);
|
|
|
+ progress[opt.progressoption[i][opt.keyid]] = z.ui.progress(prog).init(opt.progressoption[i])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ compstack[this.compid].modal = z.ui.modal(this.compid + "_modal").init(opt);
|
|
|
+ compstack[this.compid].progress = progress
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ progressmodal.prototype.close = function() {
|
|
|
+ compstack[this.compid].modal.close();
|
|
|
+ delete compstack[this.compid]
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.progress = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comp) {
|
|
|
+ selector.get(0).comp = new progress(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function progress(selector) {
|
|
|
+ this.selector = selector
|
|
|
+ }
|
|
|
+ progress.prototype.init = function(option) {
|
|
|
+ var opt = $.extend({
|
|
|
+ label: "",
|
|
|
+ value: 0,
|
|
|
+ classname: "",
|
|
|
+ showvalue: true
|
|
|
+ }, option);
|
|
|
+ opt.value = this.value = isNaN(parseInt(opt.value)) ? 0 : parseInt(opt.value);
|
|
|
+ opt.height = isNaN(parseInt(opt.height)) ? "" : parseInt(opt.height);
|
|
|
+ if (opt.width) {
|
|
|
+ this.selector.css({
|
|
|
+ width: opt.width
|
|
|
+ })
|
|
|
+ }
|
|
|
+ var compstr = "";
|
|
|
+ if (opt.label != "") {
|
|
|
+ compstr += '<div class="z-progress-label">' + opt.label + "</div>"
|
|
|
+ }
|
|
|
+ compstr += '<div class="z-progress-col">' + '<div class="z-progress-bar" style="' + (opt.height ? "height:" + opt.height + "px;" : "") + '"><span class="bg-confirm" style="width:' + opt.value + "%;" + (opt.barcolor ? "background-color:" + opt.barcolor + ";" : "") + '"></span></div></div>';
|
|
|
+ if (opt.showvalue) {
|
|
|
+ compstr += '<div class="z-progress-text"><div class="z-progress-per">' + (opt.showvalue === false ? "" : opt.value + "%") + "</div></div>"
|
|
|
+ }
|
|
|
+ this.selector.addClass("z-progress-wrap " + (opt.classname || "")).html(compstr);
|
|
|
+ return this
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ progress.prototype.getValue = function() {
|
|
|
+ return this.value
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ progress.prototype.setValue = function(value) {
|
|
|
+ this.value = isNaN(parseInt(value)) ? 0 : parseInt(value);
|
|
|
+ this.selector.find(".z-progress-bar").find("span").width(this.value + "%");
|
|
|
+ this.selector.find(".z-progress-text").html(this.value + "%")
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ z.ui.validate = {};
|
|
|
+ var validateRules = {
|
|
|
+ idcard: {
|
|
|
+ validator: function(aValue) {
|
|
|
+ var testValue = aValue.toLowerCase();
|
|
|
+ var pRegex = new RegExp(/(^\d{15}$)|(^\d{17}([0-9]|x)$)/);
|
|
|
+ if (testValue.match(pRegex) != null)
|
|
|
+ return true;
|
|
|
+ return false
|
|
|
+ },
|
|
|
+ message: "身份证输入不合法"
|
|
|
+ },
|
|
|
+ phone: {
|
|
|
+ validator: function(aValue) {
|
|
|
+ var pRegex = new RegExp(/^((\(\d{3}\))|(\d{3}\-))?1[0-9][0-9]\d{8}|15[89]\d{8}/);
|
|
|
+ if (aValue.match(pRegex) != null && aValue.length == 11)
|
|
|
+ return true;
|
|
|
+ return false
|
|
|
+ },
|
|
|
+ message: "手机号码输入不合法"
|
|
|
+ },
|
|
|
+ telephone: {
|
|
|
+ validator: function(aValue) {
|
|
|
+ var pRegex = new RegExp(/^((\d{3,4}\-)|)\d{7,8}(|([-\u8f6c]{1}\d{1,5}))$/);
|
|
|
+ if (aValue.match(pRegex) != null && aValue.length == 8)
|
|
|
+ return true;
|
|
|
+ return false
|
|
|
+ },
|
|
|
+ message: "电话号码输入不合法"
|
|
|
+ },
|
|
|
+ faxphone: {
|
|
|
+ validator: function(aValue) {
|
|
|
+ var pRegex = new RegExp(/^(0\d{2,3}\-)?([2-9]\d{6,7})+(\-\d{3,})?$/);
|
|
|
+ if (aValue.match(pRegex) != null)
|
|
|
+ return true;
|
|
|
+ return false
|
|
|
+ },
|
|
|
+ message: "传真号码输入不合法"
|
|
|
+ },
|
|
|
+ telorphone: {
|
|
|
+ validator: function(aValue) {
|
|
|
+ var pRegex1 = new RegExp(/^1[3-8]+\d{9}$/);
|
|
|
+ var pRegex2 = new RegExp(/^(0\d{2,3}\-)?([2-9]\d{6,7})+(\-\d{3,})?$/);
|
|
|
+ if (aValue.match(pRegex1) != null || aValue.match(pRegex2) != null)
|
|
|
+ return true;
|
|
|
+ return false
|
|
|
+ },
|
|
|
+ message: "分机号码输入不合法"
|
|
|
+ },
|
|
|
+ email: {
|
|
|
+ validator: function(aValue) {
|
|
|
+ var pRegex = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/);
|
|
|
+ if (aValue.match(pRegex) != null)
|
|
|
+ return true;
|
|
|
+ return false
|
|
|
+ },
|
|
|
+ message: "邮箱地址输入不合法"
|
|
|
+ },
|
|
|
+ zipcode: {
|
|
|
+ validator: function(aValue) {
|
|
|
+ var pRegex = new RegExp(/[1-9]\d{5}(?!\d)/);
|
|
|
+ if (aValue.match(pRegex) != null)
|
|
|
+ return true;
|
|
|
+ return false
|
|
|
+ },
|
|
|
+ message: "邮政编码输入不合法"
|
|
|
+ },
|
|
|
+ required: {
|
|
|
+ validator: function(aValue) {
|
|
|
+ return aValue !== null && aValue !== undefined && aValue !== "" && aValue.trim() != ""
|
|
|
+ },
|
|
|
+ message: "内容不能为空"
|
|
|
+ },
|
|
|
+ number: {
|
|
|
+ validator: function(aValue, negative, precision, min, max) {
|
|
|
+ precision = precision || 0;
|
|
|
+ negative = negative || 0;
|
|
|
+ var strRegex = "";
|
|
|
+ if (precision > 0) {
|
|
|
+ if (negative < 0) {
|
|
|
+ strRegex = new RegExp("^-?[0-9]*([.]{1}[0-9]{0," + precision + "})?$")
|
|
|
+ } else {
|
|
|
+ strRegex = new RegExp("^[0-9]*([.]{1}[0-9]{0," + precision + "})?$")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (negative < 0) {
|
|
|
+ strRegex = /^-?[0-9]+\d*$/
|
|
|
+ } else {
|
|
|
+ strRegex = /^\d+$/
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var res = strRegex.test(aValue);
|
|
|
+ if (res) {
|
|
|
+ if (min !== "" && typeof min !== "undefined") {
|
|
|
+ if (parseFloat(aValue) < parseFloat(min)) {
|
|
|
+ res = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (max !== "" && typeof max !== "undefined") {
|
|
|
+ if (parseFloat(aValue) > parseFloat(max)) {
|
|
|
+ res = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res
|
|
|
+ },
|
|
|
+ filter: function(aValue, negative, precision, min, max) {
|
|
|
+ precision = precision || 0;
|
|
|
+ negative = negative || 0;
|
|
|
+ var val = aValue + ""
|
|
|
+ , isneg = false;
|
|
|
+ if (negative < 0) {
|
|
|
+ isneg = val[0] === "-"
|
|
|
+ }
|
|
|
+ if (precision > 0) {
|
|
|
+ val = val.replace(/[^\d.]/g, "");
|
|
|
+ val = val.replace(/^\./g, "");
|
|
|
+ val = val.replace(/\.{2,}/g, ".");
|
|
|
+ val = val.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
|
|
|
+ var vals = val.split(".");
|
|
|
+ if (vals.length > 1) {
|
|
|
+ vals[1] = vals[1] ? vals[1].substring(0, precision) : "";
|
|
|
+ val = vals.join(".")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ val = val.replace(/[^\d]/g, "")
|
|
|
+ }
|
|
|
+ return val = (isneg ? "-" : "") + val
|
|
|
+ },
|
|
|
+ message: function(aValue, negative, precision, min, max) {
|
|
|
+ return "输入数字错误" + (min !== "" && typeof min !== "undefined" ? ";不能小于" + min : "") + (max !== "" && typeof max !== "undefined" ? ";不能大于" + max : "") + ";"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ length: {
|
|
|
+ validator: function(aValue, minlength, maxlength, ignore) {
|
|
|
+ minlength = minlength || 0;
|
|
|
+ maxlength = maxlength || 0;
|
|
|
+ var len = 0;
|
|
|
+ if (ignore == 1) {
|
|
|
+ for (var i = 0; i < aValue.length; i++) {
|
|
|
+ if (aValue.charAt(i).match(/[^\x00-\xff]/gi) != null)
|
|
|
+ len += 2;
|
|
|
+ else
|
|
|
+ len += 1
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ len = aValue.length
|
|
|
+ }
|
|
|
+ if ((len <= maxlength || maxlength == 0) && len >= minlength) {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ },
|
|
|
+ filter: function(aValue, minlength, maxlength, ignore) {
|
|
|
+ minlength = minlength || 0;
|
|
|
+ maxlength = maxlength || 0;
|
|
|
+ var val = aValue
|
|
|
+ , len = 0;
|
|
|
+ for (var i = 0; i < aValue.length; i++) {
|
|
|
+ if (ignore == 1 && aValue.charAt(i).match(/[^\x00-\xff]/gi) != null) {
|
|
|
+ len += 2
|
|
|
+ } else {
|
|
|
+ len += 1
|
|
|
+ }
|
|
|
+ if (maxlength > 0 && len > maxlength) {
|
|
|
+ val = aValue.substring(0, i);
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return val
|
|
|
+ },
|
|
|
+ message: function(aValue, minlength, maxlength, ignore) {
|
|
|
+ var str = "";
|
|
|
+ if ((!maxlength || maxlength == 0) && minlength) {
|
|
|
+ str += "字符长度必须在" + minlength + "位以上"
|
|
|
+ } else if ((!minlength || minlength == 0) && maxlength) {
|
|
|
+ str += "字符长度必须在" + maxlength + "位以内"
|
|
|
+ } else if (minlength && maxlength && minlength == maxlength) {
|
|
|
+ str += "字符长度必须在" + minlength + "位"
|
|
|
+ } else if (minlength && maxlength) {
|
|
|
+ str += "字符长度必须在" + minlength + "-" + maxlength + "位之间"
|
|
|
+ }
|
|
|
+ str += ignore == 1 ? "(包含中文)" : "";
|
|
|
+ return str
|
|
|
+ }
|
|
|
+ },
|
|
|
+ url: {
|
|
|
+ validator: function(aValue) {
|
|
|
+ var strRegex = "^((https|http|ftp)://)?" + "(([\\w_!~*'()\\.&=+$%-]+: )?[\\w_!~*'()\\.&=+$%-]+@)?" + "(([0-9]{1,3}\\.){3}[0-9]{1,3}" + "|" + "(localhost)|" + "([\\w_!~*'()-]+\\.)*" + "\\w+\\." + "[a-zA-Z]{1,6})" + "(:[0-9]{1,5})?" + "((/?)|" + "(/[\\w_!~*'()\\.;?:@&=+$,%#-]+)+/?)$";
|
|
|
+ var pRegex = new RegExp(strRegex,"i");
|
|
|
+ if (aValue.match(pRegex) != null)
|
|
|
+ return true;
|
|
|
+ return false
|
|
|
+ },
|
|
|
+ message: "URL输入不合法"
|
|
|
+ },
|
|
|
+ date: {
|
|
|
+ validator: function(aValue, itime) {
|
|
|
+ var strRegex = "^(?:19|20)[0-9][0-9](-(?:(?:0[1-9])|(?:1[0-2]))(-(?:(?:0[1-9])|(?:[1-2][0-9])|(?:3[0-1])))?)?";
|
|
|
+ if (itime == 1) {
|
|
|
+ strRegex += " (?:(?:[0-2][0-3])|(?:[0-1][0-9]))(:[0-5][0-9](:[0-5][0-9])?)?"
|
|
|
+ }
|
|
|
+ strRegex += "$";
|
|
|
+ return new RegExp(strRegex).test(aValue)
|
|
|
+ },
|
|
|
+ message: "日期输入不合法"
|
|
|
+ },
|
|
|
+ comparedate: function() {
|
|
|
+ var compares = {};
|
|
|
+ return {
|
|
|
+ validator: function(aValue, comparename, compareindex, item, callback) {
|
|
|
+ if (!validateRules.date.validator.call(this, aValue))
|
|
|
+ return false;
|
|
|
+ compares[comparename + "_" + compareindex] = {
|
|
|
+ item: item,
|
|
|
+ compareindex: parseInt(compareindex),
|
|
|
+ value: aValue
|
|
|
+ };
|
|
|
+ if (compares[comparename + "_" + 0] && compares[comparename + "_" + 1]) {
|
|
|
+ var res = new Date(compares[comparename + "_" + 0].value.replace(/-/g, "/")) <= new Date(compares[comparename + "_" + 1].value.replace(/-/g, "/"));
|
|
|
+ callback(res, compares[comparename + "_" + 0]);
|
|
|
+ callback(res, compares[comparename + "_" + 1]);
|
|
|
+ return res
|
|
|
+ }
|
|
|
+ return true
|
|
|
+ },
|
|
|
+ message: "起始时间必须大于结束时间"
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ };
|
|
|
+ z.ui.validate.validateComps = [];
|
|
|
+ z.ui.validate.faildom = null;
|
|
|
+ z.ui.validate.formInit = function(selector) {
|
|
|
+ if (!z.ui.comm.isIE8()) {
|
|
|
+ $(selector || document).find("[z-validate]").find("input").on("input propertychange", function() {
|
|
|
+ _deal.call(this)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ $(selector || document).find("[z-validate]").find("input").on("keyup", function() {
|
|
|
+ _deal.call(this)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ function initValidate() {
|
|
|
+ var _validates = $(selector || document).find("[z-validate]");
|
|
|
+ _validates.each(function(index, item) {
|
|
|
+ var _that = $(item).find("input").get(0)
|
|
|
+ , _value = $(_that).attr("value");
|
|
|
+ if (_value) {
|
|
|
+ var _nVal = "";
|
|
|
+ var item = _that.parentNode;
|
|
|
+ var reg = /z-comp-(?:[a-z0-9]+)/;
|
|
|
+ var exec = reg.exec(item.className);
|
|
|
+ if (exec) {
|
|
|
+ var copname = exec[0].split("-")[2];
|
|
|
+ if (z.ui[copname]) {
|
|
|
+ var comp = z.ui[copname](item);
|
|
|
+ if (comp && comp.getValue) {
|
|
|
+ _nVal = z.ui.validate.filter(comp.selector, comp.getValue())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ _nVal = z.ui.validate.filter(comp.selector, comp.getValue())
|
|
|
+ }
|
|
|
+ $(_that).attr("value", _nVal)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ initValidate()
|
|
|
+ } catch (err) {
|
|
|
+ console.error(err)
|
|
|
+ }
|
|
|
+ function _deal() {
|
|
|
+ var item = this.parentNode;
|
|
|
+ var className = item.className;
|
|
|
+ var reg = /z-comp-(?:[a-z0-9]+)/;
|
|
|
+ var exec = reg.exec(item.className);
|
|
|
+ if (exec) {
|
|
|
+ var copname = exec[0].split("-")[2];
|
|
|
+ if (z.ui[copname]) {
|
|
|
+ var comp = z.ui[copname](item);
|
|
|
+ if (comp && comp.getValue) {
|
|
|
+ return comp.setValue(z.ui.validate.filter(comp.selector, comp.getValue()))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return comp.setValue(z.ui.validate.filter($(item), $(item).val()))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.validate.filter = function(item, value) {
|
|
|
+ if (typeof value === "undefined")
|
|
|
+ return;
|
|
|
+ var valids = item.attr("z-validate");
|
|
|
+ var res = value;
|
|
|
+ if (!valids)
|
|
|
+ return res;
|
|
|
+ valids = valids.split(" ");
|
|
|
+ for (var i = 0, len = valids.length; i < len; i++) {
|
|
|
+ var valid = valids[i].split("[")
|
|
|
+ , rulename = valid[0];
|
|
|
+ if (validateRules[rulename] && validateRules[rulename].filter) {
|
|
|
+ var args = [res];
|
|
|
+ if (valid[1]) {
|
|
|
+ args = args.concat(valid[1].slice(0, -1).split(","))
|
|
|
+ }
|
|
|
+ res = validateRules[rulename].filter.apply(item, args)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.validate.validator = function(selector, option) {
|
|
|
+ var resreq = true;
|
|
|
+ if (!option || option.validatorRequired !== false) {
|
|
|
+ resreq = validatorRequired(selector, option)
|
|
|
+ }
|
|
|
+ var resrul = validatorRules(selector, option);
|
|
|
+ if (resreq && resrul)
|
|
|
+ return true;
|
|
|
+ if (!option || option.validatorlocate !== false) {
|
|
|
+ validateLocate(z.ui.validate.faildom)
|
|
|
+ }
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.validate.addRules = function(rules) {
|
|
|
+ for (var k in rules) {
|
|
|
+ validateRules[k] = rules[k]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.validate.removeRules = function(rulename) {
|
|
|
+ validateRules[rulename] = null
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function validatorRequired(selector, option) {
|
|
|
+ var res = true;
|
|
|
+ var doms = $(selector || window).find(".z-validate-required");
|
|
|
+ doms.each(function(index, item) {
|
|
|
+ var className = item.className;
|
|
|
+ var reg = /z-comp-(?:[a-z0-9]+)/;
|
|
|
+ var exec = reg.exec(className);
|
|
|
+ if (exec) {
|
|
|
+ var copname = exec[0].split("-")[2];
|
|
|
+ if (z.ui[copname]) {
|
|
|
+ var comp = z.ui[copname](item);
|
|
|
+ if (comp && comp.getValue) {
|
|
|
+ if (!_validator(comp.selector, comp.getValue()) || comp.getValue().trim() === "") {
|
|
|
+ res = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!_validator($(item), $(item).val()) || $(item).val().trim() === "") {
|
|
|
+ res = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return res;
|
|
|
+ function _validator(item, value) {
|
|
|
+ if (!validateRules.required.validator.call(item, value)) {
|
|
|
+ validateFail(item, "required", [value]);
|
|
|
+ return false
|
|
|
+ } else {
|
|
|
+ validateTrue(item, "required");
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function validatorRules(selector, option) {
|
|
|
+ var res = true;
|
|
|
+ var doms = $(selector || window).find("[z-validate]");
|
|
|
+ doms.each(function(index, item) {
|
|
|
+ var className = item.className;
|
|
|
+ var reg = /z-comp-(?:[a-z0-9]+)/;
|
|
|
+ var exec = reg.exec(item.className);
|
|
|
+ if (exec) {
|
|
|
+ var copname = exec[0].split("-")[2];
|
|
|
+ if (z.ui[copname]) {
|
|
|
+ var comp = z.ui[copname](item);
|
|
|
+ if (comp && comp.getValue) {
|
|
|
+ if (!_validator(comp.selector, comp.getValue())) {
|
|
|
+ res = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!_validator($(item), $(item).val())) {
|
|
|
+ res = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return res;
|
|
|
+ function _validator(item, value) {
|
|
|
+ if (!value)
|
|
|
+ return true;
|
|
|
+ var valids = item.attr("z-validate").split(" ");
|
|
|
+ for (var i = 0, len = valids.length; i < len; i++) {
|
|
|
+ if (!valids[i])
|
|
|
+ continue;
|
|
|
+ var valid = valids[i].split("[")
|
|
|
+ , rulename = valid[0];
|
|
|
+ if (validateRules[rulename] && validateRules[rulename].validator) {
|
|
|
+ var args = [value];
|
|
|
+ if (valid[1]) {
|
|
|
+ args = args.concat(valid[1].slice(0, -1).split(","))
|
|
|
+ }
|
|
|
+ if (rulename === "comparedate") {
|
|
|
+ args = args.concat([item, function(res, compare) {
|
|
|
+ if (!res) {
|
|
|
+ validateFail(compare.item, rulename, args)
|
|
|
+ } else {
|
|
|
+ validateTrue(compare.item, rulename)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]);
|
|
|
+ return validateRules.comparedate.validator.apply(item, args)
|
|
|
+ } else {
|
|
|
+ if (!validateRules[rulename].validator.apply(item, args)) {
|
|
|
+ validateFail(item, rulename, args);
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (i == len - 1) {
|
|
|
+ validateTrue(item, rulename);
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function validateFail(item, rulename, args) {
|
|
|
+ item.addClass("z-validate-fail");
|
|
|
+ if (!z.ui.validate.faildom) {
|
|
|
+ z.ui.validate.faildom = item
|
|
|
+ }
|
|
|
+ var msg = z.ui.comm.checkType(validateRules[rulename].message, "Function") ? validateRules[rulename].message.apply(item, args) : validateRules[rulename].message;
|
|
|
+ z.ui.tips(item).init({
|
|
|
+ classname: "z-validate-tips",
|
|
|
+ defaultshow: true,
|
|
|
+ content: msg
|
|
|
+ });
|
|
|
+ var ibar = item.find(".z-inputselect-bar");
|
|
|
+ if (ibar.length) {
|
|
|
+ rmfail(ibar)
|
|
|
+ } else {
|
|
|
+ rmfail(item)
|
|
|
+ }
|
|
|
+ function rmfail($el) {
|
|
|
+ $el.one("click input propertychange change", function() {
|
|
|
+ z.ui.tips(item).remove();
|
|
|
+ item.removeClass("z-validate-fail")
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function validateTrue(item, rulename) {
|
|
|
+ z.ui.tips(item).remove();
|
|
|
+ item.removeClass("z-validate-fail")
|
|
|
+ }
|
|
|
+ z.ui.validate.validateLocate = function(selector) {
|
|
|
+ selector = $(selector);
|
|
|
+ if (selector.length === 0)
|
|
|
+ return;
|
|
|
+ validateLocate(selector)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function validateLocate(faildom) {
|
|
|
+ if (!faildom)
|
|
|
+ return;
|
|
|
+ var seltimes = 0
|
|
|
+ , tep = 0
|
|
|
+ , scrolldom = null;
|
|
|
+ seltab(faildom);
|
|
|
+ if (scrolldom) {
|
|
|
+ scrolldom.scrollTop(scrolldom.scrollTop() + tep + (tep > 0 ? 10 : -10))
|
|
|
+ }
|
|
|
+ z.ui.validate.faildom = null;
|
|
|
+ function seltab(curdom) {
|
|
|
+ var curtab = curdom.parent().closest(".z-comp-tab");
|
|
|
+ if (!curtab.length) {
|
|
|
+ if (z.workflow && z.workflow.selectLeftNodeByEl) {
|
|
|
+ z.workflow.selectLeftNodeByEl(curdom)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var allcons = curtab.children(".z-tab-scroll").children(".z-tab-content")
|
|
|
+ , curcon = curdom.closest(".z-tab-content")
|
|
|
+ , tabindex = allcons.index(curcon);
|
|
|
+ z.ui.tab(curtab).tabSelect(tabindex);
|
|
|
+ seltimes++;
|
|
|
+ if (seltimes === 1) {
|
|
|
+ var ct = curcon.offset().top
|
|
|
+ , ch = curcon.outerHeight()
|
|
|
+ , dt = curdom.offset().top
|
|
|
+ , dh = curdom.outerHeight();
|
|
|
+ if (dt < ct) {
|
|
|
+ tep = dt - ct;
|
|
|
+ scrolldom = curcon
|
|
|
+ } else if (dt + dh > ct + ch) {
|
|
|
+ tep = dt + dh - ct - ch;
|
|
|
+ scrolldom = curcon
|
|
|
+ }
|
|
|
+ }
|
|
|
+ seltab(curtab)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ z.ui.tag = function(selector) {
|
|
|
+ if (!selector) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var selector = $(selector);
|
|
|
+ if (selector.length == 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!selector.get(0).comptag) {
|
|
|
+ selector.get(0).comptag = new tag(selector)
|
|
|
+ }
|
|
|
+ return selector.get(0).comptag
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function tag(selector) {
|
|
|
+ this.iscomprender = false;
|
|
|
+ this.selector = selector;
|
|
|
+ this.data = []
|
|
|
+ }
|
|
|
+ tag.prototype.init = function(option) {
|
|
|
+ this.remove();
|
|
|
+ this.iscomprender = true;
|
|
|
+ var opt = $.extend(true, {
|
|
|
+ zid: z.ui.comm.createCompId("z_tag"),
|
|
|
+ keyid: "id",
|
|
|
+ iconCls: function(tag) {
|
|
|
+ return ""
|
|
|
+ },
|
|
|
+ deletebtn: {
|
|
|
+ className: "fa fa-close",
|
|
|
+ onClick: function(tag, event) {}
|
|
|
+ }
|
|
|
+ }, option);
|
|
|
+ this.option = opt;
|
|
|
+ var _this = this;
|
|
|
+ if (opt.wrapclass) {
|
|
|
+ this.selector.addClass(opt.wrapclass)
|
|
|
+ }
|
|
|
+ this.selector.addClass("z-tag").on("click", ".z-tag-close", function(event) {
|
|
|
+ var tagid = $(this).parents(".z-tag-item").attr("tagid")
|
|
|
+ , tag = _this.getTag(tagid);
|
|
|
+ if (_this.option.deletebtn.onBeforeClick && _this.option.deletebtn.onBeforeClick(tag) === false)
|
|
|
+ return;
|
|
|
+ _this.removeTag(tagid);
|
|
|
+ _this.option.deletebtn.onClick && _this.option.deletebtn.onClick(tag)
|
|
|
+ });
|
|
|
+ this.selector.addClass("z-tag").on("click", ".z-tag-btn", function(event) {
|
|
|
+ var tagid = $(this).parents(".z-tag-item").attr("tagid")
|
|
|
+ , tag = _this.getTag(tagid)
|
|
|
+ , index = $(this).index();
|
|
|
+ _this.option.buttons[index].onClick(tag)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ tag.prototype.getTag = function(id) {
|
|
|
+ for (var i = 0, len = this.data.length; i < len; i++) {
|
|
|
+ if (this.data[i][this.option.keyid] == id) {
|
|
|
+ return this.data[i]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ tag.prototype.addTag = function(tag) {
|
|
|
+ this.selector.append(createTag.call(this, tag));
|
|
|
+ this.data.push(tag)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ tag.prototype.removeTag = function(id) {
|
|
|
+ for (var i = 0, len = this.data.length; i < len; i++) {
|
|
|
+ if (this.data[i][this.option.keyid] == id) {
|
|
|
+ this.data.splice(i, 1);
|
|
|
+ this.selector.find("[tagid='" + id + "']").remove();
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ tag.prototype.getData = function() {
|
|
|
+ return this.data
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ tag.prototype.setData = function(data) {
|
|
|
+ this.data = data || [];
|
|
|
+ var str = "";
|
|
|
+ for (var i = 0, len = this.data.length; i < len; i++) {
|
|
|
+ str += createTag.call(this, this.data[i])
|
|
|
+ }
|
|
|
+ this.selector.html(str)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ tag.prototype.remove = function() {
|
|
|
+ if (this.iscomprender == false)
|
|
|
+ return;
|
|
|
+ this.iscomprender = false;
|
|
|
+ this.selector.html("");
|
|
|
+ this.data = []
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function createTag(tag) {
|
|
|
+ var icon = this.option.iconCls(tag);
|
|
|
+ var showclose = this.option.deletebtn.show ? this.option.deletebtn.show(tag) : 1;
|
|
|
+ var buttons = this.option.buttons;
|
|
|
+ var str = ""
|
|
|
+ , btnstr = "";
|
|
|
+ var minwidth = 2;
|
|
|
+ if (buttons) {
|
|
|
+ btnstr += '<div class="z-tag-mask"><div class="pull-right">';
|
|
|
+ for (i = 0,
|
|
|
+ len = buttons.length; i < len; i++) {
|
|
|
+ minwidth += 30;
|
|
|
+ var button = buttons[i];
|
|
|
+ var show = button.show ? button.show(tag, i) : 1;
|
|
|
+ if (show == 0)
|
|
|
+ break;
|
|
|
+ btnstr += '<div class="z-tag-btn" title="' + (button.title || "") + '"><i class="' + button.className + '"></i></div>'
|
|
|
+ }
|
|
|
+ btnstr += "</div></div>"
|
|
|
+ }
|
|
|
+ str += '<div class="z-tag-item" tagid="' + tag[this.option.keyid] + '">' + (icon ? '<i class="z-tag-icon fa ' + icon + '"></i>' : "") + '<div class="z-tag-content"><div class="z-tag-text" style="min-width:' + minwidth + 'px;">' + tag.text + btnstr + "</div>" + (showclose ? '<div class="z-tag-close"><span>×</span></div>' : "") + "</div></div>";
|
|
|
+ return str
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ var compstack = {};
|
|
|
+ z.ui.loadmore = function(compid) {
|
|
|
+ if (!compid) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (!compstack[compid]) {
|
|
|
+ compstack[compid] = new loadmore(compid)
|
|
|
+ }
|
|
|
+ return compstack[compid]
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ function loadmore(compid) {
|
|
|
+ this.compid = compid;
|
|
|
+ this.canload = true
|
|
|
+ }
|
|
|
+ loadmore.prototype.init = function(option) {
|
|
|
+ if (!option.container)
|
|
|
+ return;
|
|
|
+ var opt = $.extend(true, {
|
|
|
+ lastbottom: 50
|
|
|
+ }, option);
|
|
|
+ var _this = this;
|
|
|
+ var scrlh, scrlt, ofsth;
|
|
|
+ $(opt.container).on("scroll", function(e) {
|
|
|
+ if (this === window) {
|
|
|
+ scrlh = document.documentElement.scrollHeight || document.body.scrollHeight;
|
|
|
+ scrlt = document.documentElement.scrollTop || document.body.scrollTop;
|
|
|
+ ofsth = document.documentElement.offsetHeight || document.body.offsetHeight
|
|
|
+ } else {
|
|
|
+ ofsth = this.offsetHeight;
|
|
|
+ scrlt = this.scrollTop;
|
|
|
+ ofsth = this.offsetHeight
|
|
|
+ }
|
|
|
+ if (!_this.canload || scrlt + opt.lastbottom < scrlh - ofsth)
|
|
|
+ return;
|
|
|
+ _this.canload = false;
|
|
|
+ opt.onLoadMore && opt.onLoadMore.call(_this, scrlt, scrlh, e)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ loadmore.prototype.setload = function(canload) {
|
|
|
+ this.canload = canload
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ var compstack = {};
|
|
|
+ z.ui.lock = function(compid, ismask, fn) {
|
|
|
+ if (!compid) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if ($.isFunction(ismask)) {
|
|
|
+ fn = ismask;
|
|
|
+ ismask = false
|
|
|
+ }
|
|
|
+ if (!compstack[compid]) {
|
|
|
+ var selector = $(compid);
|
|
|
+ var zid = z.ui.comm.createCompId("z_lock");
|
|
|
+ if (ismask) {
|
|
|
+ if (selector.length) {
|
|
|
+ z.ui.comm.setPosition(selector);
|
|
|
+ selector.append('<div id="' + zid + '" class="z-ui-lock-mask"></div>')
|
|
|
+ } else {
|
|
|
+ $("body").append('<div id="' + zid + '" class="z-ui-lock-mask"></div>')
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (selector.length) {
|
|
|
+ selector.addClass("z-readonly")
|
|
|
+ } else {
|
|
|
+ $("body").append('<div id="' + zid + '" class="z-ui-lock-mask"></div>')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ compstack[compid] = {
|
|
|
+ zid: zid,
|
|
|
+ ismask: ismask
|
|
|
+ };
|
|
|
+ if (z.ui.comm.checkType(fn, "Function")) {
|
|
|
+ fn()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.unLock = function(compid) {
|
|
|
+ var comp = compstack[compid];
|
|
|
+ if (!comp)
|
|
|
+ return;
|
|
|
+ var selector = $(compid);
|
|
|
+ if (comp.ismask) {
|
|
|
+ $("#" + comp.zid).remove()
|
|
|
+ } else {
|
|
|
+ if (selector.length) {
|
|
|
+ selector.removeClass("z-readonly")
|
|
|
+ } else {
|
|
|
+ $("#" + comp.zid).remove()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ compstack[compid] = null
|
|
|
+ }
|
|
|
+}
|
|
|
+)();
|
|
|
+(function() {
|
|
|
+ z.ui.comp = {};
|
|
|
+ z.ui.comp.init = function(selector) {
|
|
|
+ if (selector) {
|
|
|
+ var doms = $(selector).find("[class*='z-comp-']")
|
|
|
+ } else {
|
|
|
+ var doms = $("[class*='z-comp-']")
|
|
|
+ }
|
|
|
+ z.ui.validate.formInit(selector);
|
|
|
+ var reg = /z-comp-(?:[a-z0-9]+)/;
|
|
|
+ for (var i = 0, len = doms.length; i < len; i++) {
|
|
|
+ var exec = reg.exec(doms[i].className);
|
|
|
+ if (exec) {
|
|
|
+ var copname = exec[0].split("-")[2];
|
|
|
+ if (z.ui[copname]) {
|
|
|
+ z.ui[copname](doms[i], true).init()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ z.ui.form.formBarSearch(selector)
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ z.ui.comp.getComp = function(formselector, compselector) {
|
|
|
+ return $(formselector).find(compselector).get(0).comp
|
|
|
+ }
|
|
|
+ ;
|
|
|
+ $(function() {
|
|
|
+ z.ui.comp.init()
|
|
|
+ })
|
|
|
+}
|
|
|
+)();
|