plugin.js 109 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783
  1. var palette = [
  2. ["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)", "rgb(153, 153, 153)", "rgb(183, 183, 183)",
  3. "rgb(204, 204, 204)", "rgb(217, 217, 217)", "rgb(239, 239, 239)", "rgb(243, 243, 243)", "rgb(255, 255, 255)"],
  4. ["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)",
  5. "rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"],
  6. ["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)",
  7. "rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)",
  8. "rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)",
  9. "rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)",
  10. "rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)",
  11. "rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)",
  12. "rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)",
  13. "rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)",
  14. "rgb(133, 32, 12)", "rgb(153, 0, 0)", "rgb(180, 95, 6)", "rgb(191, 144, 0)", "rgb(56, 118, 29)",
  15. "rgb(19, 79, 92)", "rgb(17, 85, 204)", "rgb(11, 83, 148)", "rgb(53, 28, 117)", "rgb(116, 27, 71)",
  16. "rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)",
  17. "rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"]
  18. ];
  19. // RGB转16进制(rgb2hex)
  20. function colorRGB2Hex(color) {
  21. var rgb = color.split(',');
  22. var r = parseInt(rgb[0].split('(')[1]);
  23. var g = parseInt(rgb[1]);
  24. var b = parseInt(rgb[2].split(')')[0]);
  25. var hex = "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
  26. return hex;
  27. }
  28. // 基于颜色插件 获取颜色值
  29. function getFontColor(obj) {
  30. var fontColor = $(obj).spectrum("get");
  31. fontColor = 'rgb(' + fontColor._r + ',' + fontColor._g + ',' + fontColor._b + ')';
  32. return colorRGB2Hex(fontColor);
  33. }
  34. // 基于颜色插件 获取颜色值的透明度
  35. function getAlpha(obj) {
  36. return $(obj).spectrum("get")._a;
  37. }
  38. // 汉字 字符
  39. function getByteLen(val) {
  40. var len = 0;
  41. for (var i = 0; i < val.length; i++) {
  42. var a = val.charAt(i);
  43. if (a.match(/[^\x00-\xff]/ig) != null) {
  44. len += 2;
  45. } else {
  46. len += 1;
  47. }
  48. }
  49. return len;
  50. }
  51. // 第三方分享
  52. // 分享位置
  53. /*
  54. $(".plugin-share .con").click(function () {
  55. $(".plugin-share .con").removeClass("active");
  56. $(this).addClass("active");
  57. });
  58. */
  59. // 分享方式
  60. $(".plugin-share .s-way .s-ul li").click(function () {
  61. var $elShow = $(".plugin-share .app-share");
  62. var i = $(this).data("way");
  63. $(this).addClass("active").siblings().removeClass("active");
  64. if (i == 1) {
  65. $elShow.show();
  66. } else {
  67. $elShow.hide();
  68. }
  69. });
  70. // 第三方分享 点击保存,验证
  71. var wechatId = '';
  72. var wechatSecret = '';
  73. var shareText = '';
  74. var shareUrl = '';
  75. var shareWay = 1;
  76. $("#shareModal .plugin-save").click(function () {
  77. var $wxId = $("#shareModal input[name=wxId]");
  78. var $wxSecret = $("#shareModal input[name=wxSecret]");
  79. var $text = $("#shareModal input[name=text]");
  80. var $link1 = $("#shareModal input[name=link1]");
  81. var way = $("#shareModal .s-ul li.active").attr("data-way");
  82. if (way == 1) {
  83. if ($wxId.val().length > 0 && $wxSecret.val().length > 0) {
  84. $wxSecret.next(".error").hide();
  85. } else {
  86. $wxSecret.next(".error").show();
  87. }
  88. wechatId = $wxId.val();
  89. wechatSecret = $wxSecret.val();
  90. } else {
  91. $wxSecret.next(".error").hide();
  92. wechatId = '';
  93. wechatSecret = '';
  94. }
  95. if (verifyUrl($link1.val())) {
  96. $link1.parents(".form-group").removeClass("form-error");
  97. } else {
  98. $link1.parents(".form-group").addClass("form-error");
  99. }
  100. var errorLEength = $(".plugin-share .error:visible").length;
  101. if (errorLEength == 0) {
  102. $("#shareModal").modal("hide");
  103. } else {
  104. $("#shareModal").modal("show");
  105. }
  106. shareText = $text.val();
  107. shareUrl = $link1.val();
  108. shareWay = way;
  109. share = {"way": way, "wxId": wechatId, "wxSecret": wechatSecret, "shareText": shareText, "shareUrl": shareUrl};
  110. });
  111. $("#keystoreModal .plugin-save").click(function () {
  112. var storeFileContent = $("input[name=store_file_content]").val();
  113. var storeStorepass = $("input[name=store_storepass]").val();
  114. var storeAlias = $("input[name=store_alias]").val();
  115. var storeKeypass = $("input[name=store_keypass]").val();
  116. if(storeFileContent){
  117. if(!(storeStorepass && storeAlias && storeKeypass)){
  118. layer.msg('请填写必填项');
  119. return false;
  120. }
  121. }
  122. androidKey = {
  123. 'save':'1',
  124. 'type':'2',
  125. 'file_url': storeFileContent,
  126. 'store_pass': storeStorepass,
  127. 'alias': storeAlias,
  128. 'key_pass': storeKeypass
  129. }
  130. $("#keystoreModal").modal("hide");
  131. })
  132. // 左侧栏 显示方式
  133. // 左侧栏背景颜色
  134. $("#colorPicker5").spectrum({
  135. color: "#f3f3f3",//初始化颜色
  136. showInput: true,//显示输入
  137. showAlpha: true, // 透明度
  138. containerClassName: "full-spectrum",
  139. showInitial: true,//显示初始颜色,提供现在选择的颜色和初始颜色对比
  140. showPalette: true,//显示选择器面板
  141. showSelectionPalette: true,//记住选择过的颜色
  142. maxPaletteSize: 7,//记住选择过的颜色的最大数量
  143. preferredFormat: "hex",//输入框颜色格式,(hex十六进制,hex3十六进制可以的话只显示3位,hsl,rgb三原色,name英文名显示)
  144. hideAfterPaletteSelect: true,// 点击左侧选择颜色,面板关闭
  145. chooseText: "确定",
  146. cancelText: "取消",
  147. move: function (color) {//选择器右边面板移动时触发
  148. },
  149. show: function () {//选择器面板显示时触发
  150. },
  151. beforeShow: function () {//选择器面板显示之前触发,返回false时不显示
  152. },
  153. hide: function (color) {//选择器面板隐藏时触发
  154. updateAsideBackground(color);
  155. },
  156. //选择器面板颜色设置
  157. palette: palette
  158. });
  159. function updateAsideBackground(color) {
  160. $("#asideModal .aside-modal .a-left .phone .bg").css("background-color", color);
  161. }
  162. // 左侧栏字体颜色
  163. $("#asideFontColor").spectrum({
  164. color: "#333",//初始化颜色
  165. showInput: true,//显示输入
  166. showAlpha: true, // 透明度
  167. containerClassName: "full-spectrum",
  168. showInitial: true,//显示初始颜色,提供现在选择的颜色和初始颜色对比
  169. showPalette: true,//显示选择器面板
  170. showSelectionPalette: true,//记住选择过的颜色
  171. maxPaletteSize: 7,//记住选择过的颜色的最大数量
  172. preferredFormat: "hex",//输入框颜色格式,(hex十六进制,hex3十六进制可以的话只显示3位,hsl,rgb三原色,name英文名显示)
  173. hideAfterPaletteSelect: true,// 点击左侧选择颜色,面板关闭
  174. chooseText: "确定",
  175. cancelText: "取消",
  176. move: function (color) {//选择器右边面板移动时触发
  177. },
  178. show: function () {//选择器面板显示时触发
  179. },
  180. beforeShow: function () {//选择器面板显示之前触发,返回false时不显示
  181. },
  182. hide: function (color) {//选择器面板隐藏时触发
  183. updateAsideFontColor(color);
  184. },
  185. //选择器面板颜色设置
  186. palette: palette
  187. });
  188. function updateAsideFontColor(color) {
  189. $("#asideModal .a-left .aside-nav li .iconfont").css("color", color);
  190. $("#asideModal .a-left .aside-nav li .text").css("color", color);
  191. }
  192. tab.radioRound({
  193. el: "#displayMode li",
  194. checkedClass: "icon-radio-checked"
  195. });
  196. // 左侧栏 顶部显示APP图标
  197. tab.radioTick({
  198. el: ".plugin-aside .top-show ul li"
  199. });
  200. // 左侧栏 图标显示隐藏
  201. $(".plugin-aside .top-show ul li").click(function () {
  202. var i = $(this).index();
  203. var $icon = $("#asideModal .a-left .phone .aside-icon");
  204. if (i == 0) {
  205. $icon.show();
  206. } else {
  207. $icon.hide();
  208. }
  209. });
  210. // 左侧栏 显示方式
  211. /*
  212. $("#displayMode li").click(function () {
  213. var index = $(this).index();
  214. $("#asideModal .phone .b-right img").eq(index).show().siblings().hide();
  215. });
  216. */
  217. // 左侧栏 下拉框change字体颜色设置、显示链接输入框
  218. $(".plugin-aside .n-list select").change(function () {
  219. $(this).css("color", "#333");
  220. var selectedVal = $(this).find(":selected").val();
  221. // console.log(selectedVal);
  222. if (selectedVal == "link_app" || selectedVal == "link_url") {
  223. $(this).parents("dd").find(".n-link").css("visibility", "visible").addClass("link-show");
  224. } else {
  225. $(this).parents("dd").find(".n-link").css("visibility", "hidden").removeClass("link-show");
  226. }
  227. });
  228. // 左侧栏 点击图标
  229. var asideIconIndex = -1;
  230. $(".plugin-aside .n-list .add-icon").click(function () {
  231. asideIconIndex = $(this).parents("dd").index();
  232. $("#iconsModal").modal("show");
  233. });
  234. // 左侧栏 设置图标
  235. $(".plugin-modal .icons li").click(function () {
  236. var i = $(this).index();
  237. // console.log(i);
  238. $("#iconsModal").modal("hide");
  239. $('#asideModal').css({'overflow-y': 'scroll'});
  240. $("body").css("overflow", "hidden");
  241. $(".aside-modal .aside-nav li").eq(asideIconIndex).find(".iconfont").attr("class", "fl iconfont icon-" + i);
  242. $(".plugin-aside .n-list dd").eq(asideIconIndex).find(".add-icon").find(".iconfont").attr({
  243. "class": "iconfont icon-" + i,
  244. "data-index": i
  245. }).css("color", "#333");
  246. });
  247. //左侧栏 增加导航 默认显示1个
  248. $(".plugin-aside .n-list .add-config").click(function () {
  249. var $dd = $(".plugin-aside .n-list dd:hidden");
  250. $dd.eq(0).show();
  251. });
  252. // 左侧栏 实时文字
  253. $(".plugin-aside .n-list .n-text").bind("input propertychange", function () {
  254. var i = $(this).parents("dd").index();
  255. // console.log(i);
  256. var thisVal = $(this).val();
  257. if (thisVal.length == 0) {
  258. $("#asideModal .a-left .aside-nav li").eq(i).find(".text").text("");
  259. } else {
  260. // $("#asideModal .a-left .aside-nav li").eq(i).find(".text").text(thisVal);
  261. $("#asideModal .a-left .aside-nav li").eq(i).show().find(".text").text(thisVal);
  262. }
  263. });
  264. // 左侧栏 恢复默认
  265. $(".plugin-aside .set-nav .reset").click(function () {
  266. // $("#colorPicker4").spectrum("set", "rgb(249, 249, 249)");
  267. // li恢复到隐藏
  268. $("#asideModal .a-left .aside-nav li").hide();
  269. // 去除错误状态
  270. $(".plugin-aside .n-list").find(".error").remove();
  271. // 恢复左侧导航文字为空
  272. $("#asideModal .a-left .aside-nav li .text").text("");
  273. // 恢复 配置导航显示1个
  274. $(".plugin-aside .set-nav .n-list dd:nth-of-type(n+2)").hide();
  275. // 导航名称默认恢复为空
  276. $(".plugin-aside .n-list .n-text").val('');
  277. // 恢复图标
  278. $("#asideModal .a-left .aside-nav li .iconfont").attr("class", "iconfont fl");
  279. $(".plugin-aside .n-list .add-icon .iconfont").attr({
  280. "class": "iconfont icon-jia",
  281. "data-index": ""
  282. }).css("color", "#eee");
  283. // select恢复到默认
  284. $(".plugin-aside .n-list select").each(function () {
  285. $(this).css("color", "#999");
  286. $(this).find("option").eq(0).attr("selected", "selected");
  287. });
  288. // 链接输入框恢复到默认
  289. $(".plugin-aside .n-list .n-link").css("visibility", "hidden").val("").removeClass("link-show");
  290. });
  291. // 左侧栏 删除
  292. $(".plugin-aside .n-list .n-delete").click(function () {
  293. var $this = $(this).parents("dd");
  294. var i = $this.index();
  295. $this.hide();
  296. $this.find(".n-link").removeClass("link-show").show();
  297. $this.find("select").eq(0).attr("selected", "selected");
  298. $("#asideModal .a-left .aside-nav li").eq(i).find(".text").text("");
  299. $("#asideModal .a-left .aside-nav li").eq(i).find(".iconfont").attr("class", "iconfont fl");
  300. });
  301. // 升级提示 select选择自定义,自定义输入框显示
  302. $(".plugin-upgrade-prompt select").change(function () {
  303. var selectedVal = $(this).find(":selected").val();
  304. if (selectedVal == 2) {
  305. $(this).next("input").show();
  306. } else {
  307. $(this).next("input").hide();
  308. $(this).next("input").val("");
  309. }
  310. });
  311. // 升级提示 选项卡
  312. tab.radioRound({
  313. el: ".plugin-upgrade-prompt .version li",
  314. checkedClass: "icon-radio-checked"
  315. });
  316. tab.radioRound({
  317. el: ".plugin-upgrade-prompt .time li",
  318. checkedClass: "icon-radio-checked"
  319. });
  320. tab.radioTick({
  321. el: ".plugin-upgrade-prompt .style li"
  322. });
  323. // URL 拉起APP
  324. $("#urlAppModal .plugin-url-app ul li").click(function () {
  325. var i = $(this).index();
  326. if (i == 0) {
  327. $(this).parents(".plugin-url-app").find(".color-warning").show();
  328. } else {
  329. $(this).parents(".plugin-url-app").find(".color-warning").hide();
  330. }
  331. });
  332. // 下拉刷新
  333. $("#refreshModal .plugin-refresh ul li").click(function () {
  334. var i = $(this).index();
  335. if (i == 0) {
  336. $(this).parents(".plugin-refresh").find(".color-warning").show();
  337. } else {
  338. $(this).parents(".plugin-refresh").find(".color-warning").hide();
  339. }
  340. });
  341. // 加载进度条颜色
  342. $("#colorPicker1").spectrum({
  343. color: "#157df1",//初始化颜色
  344. showInput: true,//显示输入
  345. showAlpha: true, // 透明度
  346. containerClassName: "full-spectrum",
  347. showInitial: true,//显示初始颜色,提供现在选择的颜色和初始颜色对比
  348. showPalette: true,//显示选择器面板
  349. showSelectionPalette: true,//记住选择过的颜色
  350. maxPaletteSize: 7,//记住选择过的颜色的最大数量
  351. preferredFormat: "hex",//输入框颜色格式,(hex十六进制,hex3十六进制可以的话只显示3位,hsl,rgb三原色,name英文名显示)
  352. hideAfterPaletteSelect: true,// 点击左侧选择颜色,面板关闭
  353. chooseText: "确定",
  354. cancelText: "取消",
  355. move: function (color) {//选择器右边面板移动时触发
  356. },
  357. show: function () {//选择器面板显示时触发
  358. },
  359. beforeShow: function () {//选择器面板显示之前触发,返回false时不显示
  360. },
  361. hide: function (color) {//选择器面板隐藏时触发
  362. updateLoadingBackground(color);
  363. },
  364. //选择器面板颜色设置
  365. palette: palette
  366. });
  367. function updateLoadingBackground(color) {
  368. $(".plugin-loading .con-1 .tit2 .progress1").css("background-color", color);
  369. return color;
  370. };
  371. function updateStateBackground(color) {
  372. $(".plugin-state .state-bgcolor").css("background-color", color);
  373. };
  374. function updateTitleBackground(color) {
  375. $(".plugin-title .state-bgcolor").css("background-color", color);
  376. };
  377. function updateTitleFontColor(color) {
  378. $(".plugin-title .title-top .text").css("color", color);
  379. $(".plugin-title .title-top .iconfont").css("color", color);
  380. }
  381. // 配置插件 index
  382. var activeIndex1;
  383. var activeIndex2;
  384. $(".encapsulation3 .plugin-list1 .col-sm-2").click(function () {
  385. activeIndex1 = $(this).index();
  386. // console.log("免费" + activeIndex1);
  387. activeIndex2 = undefined;
  388. // console.log("付费" + activeIndex2);
  389. });
  390. $(".encapsulation3 .plugin-list2 .col-sm-2").click(function () {
  391. activeIndex2 = $(this).index();
  392. // console.log("付费" + activeIndex2);
  393. activeIndex1 = undefined;
  394. // console.log("免费" + activeIndex1);
  395. });
  396. /*
  397. $(".config-plugin .choose-cancel").click(function () {
  398. $(this).parents(".plugin-modal").find(".plugin-save").addClass("plugin-cancel");
  399. });
  400. */
  401. // 保存按钮 操作
  402. $(".plugin-save").click(function () {
  403. var has = $(this).hasClass("plugin-cancel");
  404. if (has) {
  405. $(".encapsulation3 .plugin-list1 .col-sm-2").eq(activeIndex1).find(".con").removeClass("active");
  406. $(this).removeClass("plugin-cancel");
  407. } else {
  408. $(".encapsulation3 .plugin-list1 .col-sm-2").eq(activeIndex1).find(".con").addClass("active").find(".icon-checkbox1").addClass("icon-checkbox-checked1 add-checked");
  409. }
  410. });
  411. $(".plugin-save").click(function () {
  412. var has = $(this).hasClass("plugin-cancel");
  413. if (has) {
  414. $(".encapsulation3 .plugin-list2 .col-sm-2").eq(activeIndex2).find(".con").removeClass("active");
  415. $(this).removeClass("plugin-cancel");
  416. } else {
  417. $(".encapsulation3 .plugin-list2 .col-sm-2").eq(activeIndex2).find(".con").addClass("active").find(".icon-checkbox1").addClass("icon-checkbox-checked1 add-checked");
  418. }
  419. });
  420. $(document).on("click", ".add-checked", function (e) {
  421. // console.log(123);
  422. $(".plugin-modal").modal("hide");
  423. $(this).removeClass("add-checked icon-checkbox-checked1");
  424. $(this).parents(".con").removeClass("active");
  425. e.stopPropagation();
  426. });
  427. // 加载动画
  428. $(".plugin-loading .con").click(function () {
  429. $(this).parents(".plugin-loading").find(".con").removeClass("active");
  430. $(this).addClass("active");
  431. var i = $(this).parent(".col-sm-5").index();
  432. // console.log(i);
  433. var that = $(this).parents(".plugin-loading").find(".color-picker-wrap");
  434. if (i == 1) {
  435. that.hide();
  436. } else {
  437. that.show();
  438. }
  439. });
  440. // 清除缓存
  441. $(".config-plugin .plugin-common .common-ul li").click(function () {
  442. $(this).addClass("active").siblings().removeClass("active");
  443. var index = $(this).index();
  444. if (index == 0) {
  445. $(this).parents(".plugin-common").find(".bg-text-color").show();
  446. $(this).parents(".plugin-common").find(".be-hidden").hide();
  447. } else {
  448. $(this).parents(".plugin-common").find(".bg-text-color").hide();
  449. $(this).parents(".plugin-common").find(".be-hidden").show();
  450. }
  451. });
  452. // 极光推送
  453. $('.plugin-modal .app-key').bind('input propertychange', function () {
  454. var valLength = $(this).val().length;
  455. // console.log(valLength);
  456. if (valLength > 0) {
  457. $(this).parents(".plugin-modal").find(".plugin-save").prop("disabled", false);
  458. } else {
  459. $(this).parents(".plugin-modal").find(".plugin-save").prop("disabled", true);
  460. }
  461. });
  462. // 退出提示
  463. $(".plugin-exit .mode dd").click(function () {
  464. $(this).addClass("active").siblings().removeClass("active");
  465. $(this).parents(".mode").find(".icon-radio").removeClass("icon-radio-checked");
  466. $(this).find(".icon-radio").addClass("icon-radio-checked");
  467. });
  468. // 引导页
  469. $(".thumbnail").change(function () {
  470. $("#guideModal .plugin-save").prop("disabled", false);
  471. });
  472. $(".plugin-guide .radio-tick li").click(function () {
  473. var type = $(this).data("type");
  474. var $parents = $(this).parents("#guideModal");
  475. if (type == -1) {
  476. $(".experience-color", $parents).hide();
  477. $(".experience-btn", $parents).hide();
  478. } else {
  479. $(".experience-color", $parents).show();
  480. $(".experience-btn", $parents).show();
  481. }
  482. });
  483. // 引导页 立即体验文字颜色
  484. $("#experienceTextColor").spectrum({
  485. color: "#fff",//初始化颜色
  486. showInput: true,//显示输入
  487. showAlpha: true, // 透明度
  488. containerClassName: "full-spectrum",
  489. showInitial: true,//显示初始颜色,提供现在选择的颜色和初始颜色对比
  490. showPalette: true,//显示选择器面板
  491. showSelectionPalette: true,//记住选择过的颜色
  492. maxPaletteSize: 7,//记住选择过的颜色的最大数量
  493. preferredFormat: "hex",//输入框颜色格式,(hex十六进制,hex3十六进制可以的话只显示3位,hsl,rgb三原色,name英文名显示)
  494. hideAfterPaletteSelect: true,// 点击左侧选择颜色,面板关闭
  495. chooseText: "确定",
  496. cancelText: "取消",
  497. move: function (color) {//选择器右边面板移动时触发
  498. },
  499. show: function () {//选择器面板显示时触发
  500. },
  501. beforeShow: function () {//选择器面板显示之前触发,返回false时不显示
  502. },
  503. hide: function (color) {//选择器面板隐藏时触发
  504. updateGuideFontColor(color);
  505. },
  506. //选择器面板颜色设置
  507. palette: palette
  508. });
  509. // console.log(getFontColor("#experienceTextColor"));
  510. function updateGuideFontColor(color) {
  511. $("#guideModal .experience-btn").css({"color": color, "border-color": color});
  512. };
  513. // 引导页 上传图片预览
  514. $("#guideModal .thumbnail").change(function () {
  515. var index = $(this).parents(".col-sm-3").index();
  516. var file = this.files[0];
  517. var name = $(this).val();
  518. // console.log(name);
  519. // 判断文件类型
  520. var type = (name.substr(name.lastIndexOf("."))).toLowerCase();
  521. // console.log(type);
  522. var typeModal = '<div class="modal fade" id="typeModal" tabindex="-1" role="dialog">\
  523. <div class="modal-dialog modal-sm" role="document">\
  524. <div class="modal-content">\
  525. <div class="modal-body">\
  526. <div class="text-center">\
  527. <div><span class="icon icon-modal-error2"></span></div>\
  528. <p class="color-333 mt5">您上传的图片格式不正确,请重新上传!</p>\
  529. <div class="mt15">\
  530. <button type="button" class="ms-btn ms-btn-default w90" data-dismiss="modal">确定</button>\
  531. </div>\
  532. </div>\
  533. </div>\
  534. </div>\
  535. </div>\
  536. </div>';
  537. if (type != ".jpg" && type != ".gif" && type != ".jpeg" && type != ".png") {
  538. $("#typeModal").remove();
  539. $("body").append(typeModal);
  540. $("#typeModal").modal("show");
  541. return false;
  542. };
  543. if (file.size/(1024*1024) > 1) {
  544. Modal.generalModal({
  545. backdrop: false, // 点击阴影是否关闭弹窗, // true 开启; false 关闭
  546. p: '图片过大,请上传1M以内的图片', // 弹窗内容
  547. align: 'center', // 弹窗内容排列顺序 left center right
  548. successBtnText: '确定', // 确定按钮文字
  549. successBtnModal: true, // 点击确定按钮是否关闭弹窗 true 关闭 false 不关闭
  550. });
  551. $(this).val("");
  552. return false;
  553. };
  554. var reader = new FileReader();
  555. reader.readAsDataURL(file);
  556. reader.onload = function () {
  557. $("#guideModal .modal-aside-left .bg img").eq(index).attr("src", this.result);
  558. };
  559. });
  560. // 引导页删除上传图片
  561. $(".plugin-guide .upload-img .icon-delete2").click(function () {
  562. var index = $(this).parents(".col-sm-3").index();
  563. $("#guideModal .modal-aside-left .bg img").eq(index).attr("src", "");
  564. });
  565. /*
  566. // 状态栏背景颜色
  567. $("#colorPicker22").spectrum({
  568. color: "#157df1",//初始化颜色
  569. showInput: true,//显示输入
  570. showAlpha: true, // 透明度
  571. containerClassName: "full-spectrum",
  572. showInitial: true,//显示初始颜色,提供现在选择的颜色和初始颜色对比
  573. showPalette: true,//显示选择器面板
  574. showSelectionPalette: true,//记住选择过的颜色
  575. maxPaletteSize: 7,//记住选择过的颜色的最大数量
  576. preferredFormat: "hex",//输入框颜色格式,(hex十六进制,hex3十六进制可以的话只显示3位,hsl,rgb三原色,name英文名显示)
  577. hideAfterPaletteSelect: true,// 点击左侧选择颜色,面板关闭
  578. chooseText: "确定",
  579. cancelText: "取消",
  580. move: function (color) {//选择器右边面板移动时触发
  581. },
  582. show: function () {//选择器面板显示时触发
  583. },
  584. beforeShow: function () {//选择器面板显示之前触发,返回false时不显示
  585. },
  586. hide: function (color) {//选择器面板隐藏时触发
  587. updateStateBackground(color);
  588. },
  589. //选择器面板颜色设置
  590. palette: palette
  591. });
  592. // 标题栏背景颜色 字体颜色
  593. $("#colorPicker3").spectrum({
  594. color: "#157df1",//初始化颜色
  595. showInput: true,//显示输入
  596. showAlpha: true, // 透明度
  597. containerClassName: "full-spectrum",
  598. showInitial: true,//显示初始颜色,提供现在选择的颜色和初始颜色对比
  599. showPalette: true,//显示选择器面板
  600. showSelectionPalette: true,//记住选择过的颜色
  601. maxPaletteSize: 7,//记住选择过的颜色的最大数量
  602. preferredFormat: "hex",//输入框颜色格式,(hex十六进制,hex3十六进制可以的话只显示3位,hsl,rgb三原色,name英文名显示)
  603. hideAfterPaletteSelect: true,// 点击左侧选择颜色,面板关闭
  604. chooseText: "确定",
  605. cancelText: "取消",
  606. move: function (color) {//选择器右边面板移动时触发
  607. },
  608. show: function () {//选择器面板显示时触发
  609. },
  610. beforeShow: function () {//选择器面板显示之前触发,返回false时不显示
  611. },
  612. hide: function (color) {//选择器面板隐藏时触发
  613. updateTitleBackground(color);
  614. },
  615. //选择器面板颜色设置
  616. palette: palette
  617. });
  618. $("#titFontColor").spectrum({
  619. color: "#fff",//初始化颜色
  620. showInput: true,//显示输入
  621. showAlpha: true, // 透明度
  622. containerClassName: "full-spectrum",
  623. showInitial: true,//显示初始颜色,提供现在选择的颜色和初始颜色对比
  624. showPalette: true,//显示选择器面板
  625. showSelectionPalette: true,//记住选择过的颜色
  626. maxPaletteSize: 7,//记住选择过的颜色的最大数量
  627. preferredFormat: "hex",//输入框颜色格式,(hex十六进制,hex3十六进制可以的话只显示3位,hsl,rgb三原色,name英文名显示)
  628. hideAfterPaletteSelect: true,// 点击左侧选择颜色,面板关闭
  629. chooseText: "确定",
  630. cancelText: "取消",
  631. move: function (color) {//选择器右边面板移动时触发
  632. },
  633. show: function () {//选择器面板显示时触发
  634. },
  635. beforeShow: function () {//选择器面板显示之前触发,返回false时不显示
  636. },
  637. hide: function (color) {//选择器面板隐藏时触发
  638. updateTitleFontColor(color);
  639. },
  640. //选择器面板颜色设置
  641. palette: palette
  642. });
  643. // 状态栏 文字颜色
  644. $(".plugin-modal .bg-text-color .writing li").click(function () {
  645. var index = $(this).index();
  646. $(this).addClass("active").siblings().removeClass("active");
  647. if (index == 0) {
  648. $(this).parents(".plugin-state").find(".common-top").removeClass("black").addClass("white");
  649. // $(this).parents("#asideModal").find(".a-left").find(".aside-nav").removeClass("black").addClass("white")
  650. } else {
  651. $(this).parents(".plugin-state").find(".common-top").removeClass("white").addClass("black");
  652. // $(this).parents("#asideModal").find(".a-left").find(".aside-nav").removeClass("white").addClass("black");
  653. }
  654. });
  655. // 标题栏 标题文字实时展现
  656. $(".plugin-title .input-title").bind("input propertychange", function () {
  657. var thisVal = $(this).val();
  658. $(this).parents(".plugin-title").find(".title-top").find(".text").text(thisVal);
  659. });
  660. // 标题栏 选择左功能键图标
  661. $(".plugin-title .function-keys.f-left li").click(function () {
  662. var i = $(this).index();
  663. var no = $(this).hasClass("rule-out");
  664. var checked = $(this).hasClass("active");
  665. var disabled = $(this).hasClass("disabled");
  666. if (disabled) return;
  667. var $parent = $(this).parents(".function-keys");
  668. if (checked) {
  669. $(this).removeClass("active").find(".iconfont").removeClass("icon-checkbox-checked1");
  670. $(".plugin-title .title-top .t-left span").eq(i).hide();
  671. } else {
  672. $(this).addClass("active").find(".iconfont").addClass("icon-checkbox-checked1");
  673. var dis1 = $(this).hasClass("disabled");
  674. // 不是disabled的状态,点击li,头部预览图标显示
  675. if (!dis1) {
  676. $(".plugin-title .title-top .t-left span").eq(i).show();
  677. }
  678. }
  679. var checkedLength = $parent.find(".active").length;
  680. // 超过2个
  681. if (checkedLength > 1) {
  682. $("li", $parent).not(".active").addClass("disabled");
  683. } else {
  684. $("li", $parent).not(".active").removeClass("disabled");
  685. }
  686. // 点击无
  687. var dis = $(this).hasClass("disabled");
  688. if (no && !dis) {
  689. if (checked) {
  690. $(this).removeClass("active").find(".iconfont").removeClass("icon-checkbox-checked1");
  691. $("li", $parent).removeClass("disabled");
  692. } else {
  693. $(this).addClass("active").find(".iconfont").addClass("icon-checkbox-checked1").parents(".active").siblings().removeClass("active").addClass("disabled").find(".iconfont").removeClass("icon-checkbox-checked1");
  694. $(".plugin-title .title-top .t-left span").hide();
  695. }
  696. } else {
  697. }
  698. var aside = $("li[data-aside=1]", $parent).attr("data-aside");
  699. var $asideChecked = $("li[data-aside=1]", $parent).hasClass("active");
  700. var asideDis = $("li[data-aside=1]", $parent).hasClass("disabled");
  701. // 点击侧边栏出提示
  702. if (aside == 1 && $asideChecked && !asideDis) {
  703. $parent.next(".plugin-remind").show();
  704. } else {
  705. $parent.next(".plugin-remind").hide();
  706. }
  707. // 左侧是否选中了侧边栏
  708. if ($(".plugin-title .function-keys.f-right li[data-right-key='aside']").hasClass("active")) {
  709. $(".plugin-title .function-keys.f-left li[data-left-key='aside']").addClass("disabled");
  710. }
  711. if ($(".plugin-title .function-keys.f-left li[data-left-key='aside']").hasClass("active")) {
  712. $(".plugin-title .function-keys.f-right li[data-right-key='aside']").addClass("disabled");
  713. } else {
  714. if ($(".plugin-title .function-keys.f-right li.disabled").length <= 1) {
  715. $(".plugin-title .function-keys.f-right li[data-right-key='aside']").removeClass("disabled");
  716. }
  717. }
  718. });
  719. // 标题栏 选择右功能键图标
  720. $(".plugin-title .function-keys.f-right li").click(function () {
  721. var i = $(this).index();
  722. var no = $(this).hasClass("rule-out");
  723. var checked = $(this).hasClass("active");
  724. var $parent = $(this).parents(".function-keys");
  725. var disabled = $(this).hasClass("disabled");
  726. if (disabled) return;
  727. if (checked) {
  728. $(this).removeClass("active").find(".iconfont").removeClass("icon-checkbox-checked1");
  729. $(".plugin-title .title-top .t-right span").eq(i).hide();
  730. } else {
  731. $(this).addClass("active").find(".iconfont").addClass("icon-checkbox-checked1");
  732. var dis1 = $(this).hasClass("disabled");
  733. if (!dis1) {
  734. $(".plugin-title .title-top .t-right span").eq(i).show();
  735. }
  736. }
  737. var checkedLength = $parent.find(".active").length;
  738. // 超过2个
  739. if (checkedLength > 1) {
  740. $("li", $parent).not(".active").addClass("disabled");
  741. } else {
  742. $("li", $parent).not(".active").removeClass("disabled");
  743. }
  744. // 点击无
  745. var dis = $(this).hasClass("disabled");
  746. if (no && !dis) {
  747. if (checked) {
  748. $(this).removeClass("active").find(".iconfont").removeClass("icon-checkbox-checked1");
  749. $("li", $parent).removeClass("disabled");
  750. } else {
  751. $(this).addClass("active").find(".iconfont").addClass("icon-checkbox-checked1").parents(".active").siblings().removeClass("active").addClass("disabled").find(".iconfont").removeClass("icon-checkbox-checked1");
  752. $(".plugin-title .title-top .t-right span").hide();
  753. }
  754. } else {
  755. }
  756. var aside = $("li[data-aside=1]", $parent).attr("data-aside");
  757. var $asideChecked = $("li[data-aside=1]", $parent).hasClass("active");
  758. var asideDis = $("li[data-aside=1]", $parent).hasClass("disabled");
  759. // 点击侧边栏出提示
  760. if (aside == 1 && $asideChecked && !asideDis) {
  761. $parent.next(".plugin-remind").show();
  762. $(".plugin-title .function-keys.f-left li[data-left-key='aside']").addClass("disabled");
  763. } else {
  764. $parent.next(".plugin-remind").hide();
  765. // 获取右侧置灰个数,超过一个不在开启
  766. if ($(".plugin-title .function-keys.f-left li.disabled").length <= 1) {
  767. $(".plugin-title .function-keys.f-left li[data-left-key='aside']").removeClass("disabled");
  768. }
  769. }
  770. // 左侧是否选中了侧边栏
  771. if ($(".plugin-title .function-keys.f-left li[data-left-key='aside']").hasClass("active")) {
  772. $(".plugin-title .function-keys.f-right li[data-right-key='aside']").addClass("disabled");
  773. }
  774. if ($(".plugin-title .function-keys.f-right li[data-right-key='aside']").hasClass("active")) {
  775. $(".plugin-title .function-keys.f-left li[data-left-key='aside']").addClass("disabled");
  776. } else {
  777. if ($(".plugin-title .function-keys.f-left li.disabled").length <= 1) {
  778. $(".plugin-title .function-keys.f-left li[data-left-key='aside']").removeClass("disabled");
  779. }
  780. }
  781. });
  782. $(".plugin-title .function-keys").on("click", ".disabled", function () {
  783. $(this).removeClass("active").find(".iconfont").removeClass("icon-checkbox-checked1");
  784. })
  785. // 标题栏 显示 隐藏
  786. $("#titleShow li").click(function () {
  787. var i = $(this).index();
  788. if (i == 1) {
  789. $(".plugin-title .title-top .t-left span").hide();
  790. $(".plugin-title .title-top .t-right span").hide();
  791. $(".plugin-title .function-keys li").removeClass("active disabled").find(".iconfont").removeClass("icon-checkbox-checked1");
  792. $(".plugin-title .function-keys.f-left li:eq(0)").addClass("active").find(".iconfont").addClass("icon-checkbox-checked1");
  793. $(".plugin-title .function-keys.f-right li:eq(0)").addClass("active").find(".iconfont").addClass("icon-checkbox-checked1");
  794. $(".plugin-title .bg-text-color").hide();
  795. $(".plugin-title .function-keys-wrap").hide();
  796. } else {
  797. $(".plugin-title .title-top .t-left span").eq(0).show();
  798. $(".plugin-title .title-top .t-right span").eq(0).show();
  799. $(".plugin-title .bg-text-color").show();
  800. $(".plugin-title .function-keys-wrap").show();
  801. }
  802. });
  803. // 标题栏点击保存
  804. $("#titleModal .plugin-save").click(function () {
  805. var leftKeys = []; // 标题栏左侧功能键
  806. var rightKeys = []; // 标题栏右侧功能键
  807. function getKeys(obj, data, arr) {
  808. $(obj).each(function () {
  809. var has = $(this).hasClass("active");
  810. var val = $(this).attr(data);
  811. if (has) {
  812. arr.push(val);
  813. }
  814. });
  815. }
  816. getKeys(".function-keys.f-left li", "data-left-key", leftKeys);
  817. getKeys(".function-keys.f-right li", "data-right-key", rightKeys);
  818. var titleBg = getFontColor("#colorPicker3"); // 背景色
  819. var fontColor = getFontColor("#titFontColor"); // 文字色
  820. var showTitle = $("#titleShow .active").attr("data-show"); // 显示Or隐藏
  821. var titleVal = $('#titleModal input[name=title]').val(); // 标题栏文字
  822. if (showTitle == 1) {
  823. titleBar = {show: showTitle};
  824. } else {
  825. titleBar = {
  826. show: showTitle,
  827. bgColor: titleBg,
  828. titleColor: fontColor,
  829. title: titleVal,
  830. leftKey: leftKeys,
  831. rightKey: rightKeys
  832. };
  833. }
  834. console.log(titleBar);
  835. });
  836. */
  837. // 状态标题栏 状态栏背景颜色
  838. $("#colorPicker2").spectrum({
  839. color: "#d9d9d9", //初始化颜色
  840. showInput: true, //显示输入
  841. showAlpha: true, // 透明度
  842. containerClassName: "full-spectrum",
  843. showInitial: true,//显示初始颜色,提供现在选择的颜色和初始颜色对比
  844. showPalette: true,//显示选择器面板
  845. showSelectionPalette: true,//记住选择过的颜色
  846. maxPaletteSize: 7,//记住选择过的颜色的最大数量
  847. preferredFormat: "hex",//输入框颜色格式,(hex十六进制,hex3十六进制可以的话只显示3位,hsl,rgb三原色,name英文名显示)
  848. hideAfterPaletteSelect: true,// 点击左侧选择颜色,面板关闭
  849. chooseText: "确定",
  850. cancelText: "取消",
  851. move: function (color) {//选择器右边面板移动时触发
  852. },
  853. show: function () {//选择器面板显示时触发
  854. },
  855. beforeShow: function () {//选择器面板显示之前触发,返回false时不显示
  856. },
  857. hide: function (color) {//选择器面板隐藏时触发
  858. updateStateBackground(color);
  859. },
  860. //选择器面板颜色设置
  861. palette: palette
  862. });
  863. // 状态标题栏 标题栏背景颜色 字体颜色
  864. $("#colorPicker3").spectrum({
  865. color: "#157df1",//初始化颜色
  866. showInput: true,//显示输入
  867. showAlpha: true, // 透明度
  868. containerClassName: "full-spectrum",
  869. showInitial: true,//显示初始颜色,提供现在选择的颜色和初始颜色对比
  870. showPalette: true,//显示选择器面板
  871. showSelectionPalette: true,//记住选择过的颜色
  872. maxPaletteSize: 7,//记住选择过的颜色的最大数量
  873. preferredFormat: "hex",//输入框颜色格式,(hex十六进制,hex3十六进制可以的话只显示3位,hsl,rgb三原色,name英文名显示)
  874. hideAfterPaletteSelect: true,// 点击左侧选择颜色,面板关闭
  875. chooseText: "确定",
  876. cancelText: "取消",
  877. move: function (color) {//选择器右边面板移动时触发
  878. },
  879. show: function () {//选择器面板显示时触发
  880. },
  881. beforeShow: function () {//选择器面板显示之前触发,返回false时不显示
  882. },
  883. hide: function (color) {//选择器面板隐藏时触发
  884. updateTitleBackground(color);
  885. },
  886. //选择器面板颜色设置
  887. palette: palette
  888. });
  889. $("#titFontColor").spectrum({
  890. color: "#fff",//初始化颜色
  891. showInput: true,//显示输入
  892. showAlpha: true, // 透明度
  893. containerClassName: "full-spectrum",
  894. showInitial: true,//显示初始颜色,提供现在选择的颜色和初始颜色对比
  895. showPalette: true,//显示选择器面板
  896. showSelectionPalette: true,//记住选择过的颜色
  897. maxPaletteSize: 7,//记住选择过的颜色的最大数量
  898. preferredFormat: "hex",//输入框颜色格式,(hex十六进制,hex3十六进制可以的话只显示3位,hsl,rgb三原色,name英文名显示)
  899. hideAfterPaletteSelect: true,// 点击左侧选择颜色,面板关闭
  900. chooseText: "确定",
  901. cancelText: "取消",
  902. move: function (color) {//选择器右边面板移动时触发
  903. },
  904. show: function () {//选择器面板显示时触发
  905. },
  906. beforeShow: function () {//选择器面板显示之前触发,返回false时不显示
  907. },
  908. hide: function (color) {//选择器面板隐藏时触发
  909. updateTitleFontColor(color);
  910. },
  911. //选择器面板颜色设置
  912. palette: palette
  913. });
  914. function updateStateBackground(color) {
  915. $("#titleModal .state-bgcolor").css("background-color", color);
  916. };
  917. function updateTitleBackground(color) {
  918. $(".plugin-title .title-top").css("background-color", color);
  919. };
  920. function updateTitleFontColor(color) {
  921. $(".plugin-title .title-top .text").css("color", color);
  922. $(".plugin-title .title-top .iconfont").css("color", color);
  923. }
  924. // 状态标题栏 状态栏显示、隐藏
  925. $("#titleModal .state-show-toggle li").click(function () {
  926. var state = $(this).data("state");
  927. var titleShow = $("#titleShow .active").attr("data-show");
  928. var $parents = $(this).parents(".config-plugin");
  929. if (state == 2) {
  930. $(".state-way ", $parents).hide();
  931. $(".state-way [data-state-way=1]", $parents).addClass("active").siblings().removeClass("active");
  932. $(".be-hidden1", $parents).show();
  933. $("#titleModal .state-top").removeClass("state-top-extension").hide();
  934. if (titleShow == 1) {
  935. $(".title-wrap1").show();
  936. $(".title-wrap1 .title-way").hide();
  937. $("#titleModal .state-bg-extension").hide();
  938. $("#titleModal .title-top").hide();
  939. } else {
  940. $(".title-wrap1").show();
  941. $(".title-wrap1 .title-way").show();
  942. $("#titleModal .state-bg-extension").hide();
  943. $("#titleModal .title-top").show();
  944. }
  945. } else {
  946. $(".state-way", $parents).show();
  947. $(".be-hidden1", $parents).hide();
  948. $("#titleModal .state-top").show();
  949. $("#titleModal .state-bg-color1").show();
  950. }
  951. });
  952. // 状态栏标题栏 选择背景图延伸
  953. $("#titleModal .state-way-ul li").click(function () {
  954. var state = $(this).attr("data-state-way");
  955. var $parents = $(this).parents("#titleModal");
  956. if (state == 2) {
  957. $(".state-bg-color1", $parents).hide();
  958. $(".title-wrap1", $parents).hide();
  959. $(".state-bg-extension", $parents).show();
  960. $(".state-top", $parents).addClass("state-top-extension");
  961. $(".title-top", $parents).hide();
  962. } else {
  963. $(".state-bg-color1", $parents).show();
  964. $(".title-wrap1", $parents).show();
  965. $(".state-bg-extension", $parents).hide();
  966. $(".state-top", $parents).removeClass("state-top-extension");
  967. $(".title-top", $parents).show();
  968. }
  969. });
  970. // 状态标题栏 状态栏 字体颜色设置黑白
  971. $("#titleModal .bg-text-color1 .writing li").click(function () {
  972. var state = $(this).attr("data-state-font-color");
  973. var $parents = $(this).parents("#titleModal");
  974. $(this).addClass("active").siblings().removeClass("active");
  975. if (state == 1) {
  976. $(".state-top", $parents).removeClass("black").addClass("white");
  977. } else {
  978. $(".state-top", $parents).removeClass("white").addClass("black");
  979. }
  980. });
  981. // 状态标题栏 标题栏显示、隐藏
  982. $("#titleShow li").click(function () {
  983. var i = $(this).data("show");
  984. if (i == 1) {
  985. $("#titleModal .title-way").hide();
  986. $("#titleModal .title-top").hide();
  987. $("#titleModal .be-hidden2").show();
  988. // $(".plugin-title .title-top .t-left span").hide();
  989. // $(".plugin-title .title-top .t-right span").hide();
  990. // $(".plugin-title .function-keys li").removeClass("active disabled").find(".iconfont").removeClass("icon-checkbox-checked1");
  991. // $(".plugin-title .function-keys.f-left li:eq(0)").addClass("active").find(".iconfont").addClass("icon-checkbox-checked1");
  992. // $(".plugin-title .function-keys.f-right li:eq(0)").addClass("active").find(".iconfont").addClass("icon-checkbox-checked1");
  993. // $(".plugin-title .bg-text-color").hide();
  994. // $(".plugin-title .function-keys-wrap").hide();
  995. } else {
  996. $("#titleModal .title-way").show();
  997. $("#titleModal .title-top").show();
  998. $("#titleModal .be-hidden2").hide();
  999. // $(".plugin-title .title-top .t-left span").eq(0).show();
  1000. // $(".plugin-title .title-top .t-right span").eq(0).show();
  1001. // $(".plugin-title .bg-text-color").show();
  1002. // $(".plugin-title .function-keys-wrap").show();
  1003. }
  1004. });
  1005. // 状态标题栏 标题栏 标题文字实时展现
  1006. $(".plugin-title .input-title").bind("input propertychange", function () {
  1007. var thisVal = $(this).val();
  1008. $(this).parents(".plugin-title").find(".title-top").find(".text").text(thisVal);
  1009. });
  1010. // 状态标题栏 标题栏 选择左功能键图标
  1011. $(".plugin-title .function-keys.f-left li").click(function () {
  1012. var i = $(this).index();
  1013. var no = $(this).hasClass("rule-out");
  1014. var checked = $(this).hasClass("active");
  1015. var $parent = $(this).parents(".function-keys");
  1016. var disabled = $(this).hasClass("disabled");
  1017. if (disabled) return;
  1018. var $right = $(".plugin-title .function-keys.f-right");
  1019. var $leftAside = $(".plugin-title .function-keys.f-left li[data-left-key='aside']");
  1020. var $rightAside = $(".plugin-title .function-keys.f-right li[data-right-key='aside']");
  1021. var $leftShare = $(".plugin-title .function-keys.f-left li[data-left-key='share']");
  1022. var $rightShare = $(".plugin-title .function-keys.f-right li[data-right-key='share']");
  1023. if (checked) {
  1024. $(this).removeClass("active").find(".iconfont").removeClass("icon-checkbox-checked1");
  1025. $(".plugin-title .title-top .t-left span").eq(i).hide();
  1026. } else {
  1027. $(this).addClass("active").find(".iconfont").addClass("icon-checkbox-checked1");
  1028. var dis1 = $(this).hasClass("disabled");
  1029. // 不是disabled的状态,点击li,头部预览图标显示
  1030. if (!dis1) {
  1031. $(".plugin-title .title-top .t-left span").eq(i).show();
  1032. }
  1033. }
  1034. // 点击左侧侧边栏,右侧侧边栏增加disabled
  1035. if ($leftAside.hasClass("active")) {
  1036. $rightAside.addClass("disabled disabled1");
  1037. } else {
  1038. $rightAside.removeClass("disabled disabled1");
  1039. }
  1040. // 点击左侧分享,右侧分享增加disabled
  1041. if ($leftShare.hasClass("active")) {
  1042. $rightShare.addClass("disabled disabled1");
  1043. } else {
  1044. $rightShare.removeClass("disabled disabled1");
  1045. }
  1046. var checkedLength = $parent.find(".active").length;
  1047. // console.log("left:" + checkedLength);
  1048. // 超过2个
  1049. if (checkedLength > 1) {
  1050. $("li", $parent).not(".active").addClass("disabled");
  1051. } else {
  1052. $("li", $parent).not(".active,.disabled1").removeClass("disabled");
  1053. }
  1054. // console.log($right.find(".active").length);
  1055. if ($right.find(".active").length == 2) {
  1056. if ($rightAside.hasClass("active")) {
  1057. $rightAside.removeClass("disabled");
  1058. } else {
  1059. $rightAside.addClass("disabled");
  1060. }
  1061. if ($rightShare.hasClass("active")) {
  1062. $rightShare.removeClass("disabled");
  1063. } else {
  1064. $rightShare.addClass("disabled");
  1065. }
  1066. }
  1067. /*
  1068. // 点击无
  1069. var dis = $(this).hasClass("disabled");
  1070. if (no && !dis) {
  1071. if (checked) {
  1072. $(this).removeClass("active").find(".iconfont").removeClass("icon-checkbox-checked1");
  1073. $("li", $parent).not(".disabled1").removeClass("disabled");
  1074. } else {
  1075. $(this).addClass("active").find(".iconfont").addClass("icon-checkbox-checked1").parents(".active").siblings().removeClass("active").addClass("disabled").find(".iconfont").removeClass("icon-checkbox-checked1");
  1076. $(".plugin-title .title-top .t-left span").hide();
  1077. }
  1078. }
  1079. */
  1080. var aside = $("li[data-aside=1]", $parent).attr("data-aside");
  1081. var $asideChecked = $("li[data-aside=1]", $parent).hasClass("active");
  1082. var asideDis = $("li[data-aside=1]", $parent).hasClass("disabled");
  1083. // 点击侧边栏出提示
  1084. if (aside == 1 && $asideChecked && !asideDis) {
  1085. $parent.next(".plugin-remind").show();
  1086. } else {
  1087. $parent.next(".plugin-remind").hide();
  1088. }
  1089. var share = $("li[data-share=1]", $parent).attr("data-share");
  1090. var $shareChecked = $("li[data-share=1]", $parent).hasClass("active");
  1091. var shareDis = $("li[data-share=1]", $parent).hasClass("disabled");
  1092. // 点击分享出提示
  1093. if (share == 1 && $shareChecked && !shareDis) {
  1094. $parent.next(".plugin-remind").next(".plugin-remind1").show();
  1095. } else {
  1096. $parent.next(".plugin-remind").next(".plugin-remind1").hide();
  1097. }
  1098. });
  1099. // 状态标题栏 标题栏 选择右功能键图标
  1100. $(".plugin-title .function-keys.f-right li").click(function () {
  1101. var i = $(this).index();
  1102. var no = $(this).hasClass("rule-out");
  1103. var checked = $(this).hasClass("active");
  1104. var $parent = $(this).parents(".function-keys");
  1105. var disabled = $(this).hasClass("disabled");
  1106. var $left = $(".plugin-title .function-keys.f-left");
  1107. var $leftAside = $(".plugin-title .function-keys.f-left li[data-left-key='aside']");
  1108. var $rightAside = $(".plugin-title .function-keys.f-right li[data-right-key='aside']");
  1109. var $leftShare = $(".plugin-title .function-keys.f-left li[data-left-key='share']");
  1110. var $rightShare = $(".plugin-title .function-keys.f-right li[data-right-key='share']");
  1111. if (disabled) return;
  1112. if (checked) {
  1113. $(this).removeClass("active").find(".iconfont").removeClass("icon-checkbox-checked1");
  1114. $(".plugin-title .title-top .t-right span").eq(i).hide();
  1115. } else {
  1116. $(this).addClass("active").find(".iconfont").addClass("icon-checkbox-checked1");
  1117. var dis1 = $(this).hasClass("disabled");
  1118. if (!dis1) {
  1119. $(".plugin-title .title-top .t-right span").eq(i).show();
  1120. }
  1121. }
  1122. // 点击右侧侧边栏,给左侧侧边栏增加disabled
  1123. if ($rightAside.hasClass("active")) {
  1124. $leftAside.addClass("disabled disabled1");
  1125. } else {
  1126. $leftAside.removeClass("disabled disabled1");
  1127. }
  1128. // 点击右侧分享,给左侧分享增加disabled
  1129. if ($rightShare.hasClass("active")) {
  1130. $leftShare.addClass("disabled disabled1");
  1131. } else {
  1132. $leftShare.removeClass("disabled disabled1");
  1133. }
  1134. var checkedLength = $parent.find(".active").length;
  1135. // console.log("right:" + checkedLength);
  1136. // 超过2个
  1137. if (checkedLength > 1) {
  1138. $("li", $parent).not(".active").addClass("disabled");
  1139. } else {
  1140. $("li", $parent).not(".active,.disabled1").removeClass("disabled");
  1141. // console.log("left:" + $left.find(".active").length);
  1142. }
  1143. // console.log($left.find(".active").length);
  1144. if ($left.find(".active").length == 2) {
  1145. if ($leftAside.hasClass("active")) {
  1146. $leftAside.removeClass("disabled");
  1147. } else {
  1148. $leftAside.addClass("disabled");
  1149. }
  1150. if ($leftShare.hasClass("active")) {
  1151. $leftShare.removeClass("disabled");
  1152. } else {
  1153. $leftShare.addClass("disabled");
  1154. }
  1155. }
  1156. /*
  1157. // 点击无
  1158. var dis = $(this).hasClass("disabled");
  1159. if (no && !dis) {
  1160. if (checked) {
  1161. $(this).removeClass("active").find(".iconfont").removeClass("icon-checkbox-checked1");
  1162. $("li", $parent).not(".disabled1").removeClass("disabled");
  1163. } else {
  1164. $(this).addClass("active").find(".iconfont").addClass("icon-checkbox-checked1").parents(".active").siblings().removeClass("active").addClass("disabled").find(".iconfont").removeClass("icon-checkbox-checked1");
  1165. $(".plugin-title .title-top .t-right span").hide();
  1166. }
  1167. } else {
  1168. }
  1169. */
  1170. var aside = $("li[data-aside=1]", $parent).attr("data-aside");
  1171. var $asideChecked = $("li[data-aside=1]", $parent).hasClass("active");
  1172. var asideDis = $("li[data-aside=1]", $parent).hasClass("disabled");
  1173. // 点击侧边栏出提示
  1174. if (aside == 1 && $asideChecked && !asideDis) {
  1175. $parent.next(".plugin-remind").show();
  1176. $(".plugin-title .function-keys.f-left li[data-left-key='aside']").addClass("disabled");
  1177. } else {
  1178. $parent.next(".plugin-remind").hide();
  1179. }
  1180. var share = $("li[data-share=1]", $parent).attr("data-share");
  1181. var $shareChecked = $("li[data-share=1]", $parent).hasClass("active");
  1182. var shareDis = $("li[data-share=1]", $parent).hasClass("disabled");
  1183. // 点击分享出提示
  1184. if (share == 1 && $shareChecked && !shareDis) {
  1185. $parent.next(".plugin-remind").next(".plugin-remind1").show();
  1186. } else {
  1187. $parent.next(".plugin-remind").next(".plugin-remind1").hide();
  1188. }
  1189. });
  1190. /*
  1191. $(".plugin-title .function-keys").on("click", ".disabled", function () {
  1192. $(this).removeClass("active").find(".iconfont").removeClass("icon-checkbox-checked1");
  1193. });
  1194. */
  1195. // 状态标题栏点击保存取值
  1196. $("#titleModal .plugin-save").click(function () {
  1197. stateBar = {}; // 清空状态栏
  1198. titleBar = {}; // 清空标题栏
  1199. // 状态标题栏 状态栏取值
  1200. // 状态栏显示、隐藏
  1201. var showState = $("#titleModal .state-show-toggle .active").attr("data-state"); // 1 显示 2 隐藏
  1202. // 状态栏显示方式
  1203. var stateWay = $("#titleModal .state-way-ul .active").attr("data-state-way"); // 1 自定义 2 背景图延伸
  1204. // 状态栏背景颜色
  1205. var stateBgColor = getFontColor("#colorPicker2");
  1206. // 状态栏背景透明度
  1207. var stateBgColorAlpha = getAlpha("#colorPicker2");
  1208. // 状态栏文字颜色
  1209. var stateFontColor = $("#titleModal .writing .active").attr("data-state-font-color"); // 1 白色 2 黑色
  1210. // 状态标题栏 标题栏取值
  1211. // 标题栏 显示、隐藏
  1212. var showTitle = $("#titleShow .active").attr("data-show"); // // 0 显示 1 隐藏
  1213. // 标题栏 输入文字
  1214. var titleVal = $('#titleModal input[name=title]').val();
  1215. // 标题栏 背景颜色
  1216. var titleBg = getFontColor("#colorPicker3");
  1217. // 标题栏 背景颜色透明度
  1218. var titleBgAlpha = getAlpha("#colorPicker3");
  1219. // 标题栏 字体颜色
  1220. var titleFontColor = getFontColor("#titFontColor");
  1221. // 标题栏 字体透明度
  1222. var titleFontColorAlpha = getAlpha("#titFontColor");
  1223. // 左侧功能键 取值
  1224. var leftKeys = [];
  1225. // 右侧功能键 取值
  1226. var rightKeys = [];
  1227. function getKeys(obj, data, arr) {
  1228. $(obj).each(function () {
  1229. var has = $(this).hasClass("active");
  1230. var val = $(this).attr(data);
  1231. if (has) {
  1232. arr.push(val);
  1233. }
  1234. });
  1235. }
  1236. getKeys(".function-keys.f-left li", "data-left-key", leftKeys);
  1237. getKeys(".function-keys.f-right li", "data-right-key", rightKeys);
  1238. if (showState != 2 && stateWay == 2) showTitle = 1; // 显示状态栏且延伸则标题栏不显示
  1239. titleBar.show = showTitle;
  1240. if (showTitle != 1) {
  1241. titleBar.title = titleVal;
  1242. titleBar.bgColor = titleBg;
  1243. titleBar.bgAlpha = titleBgAlpha;
  1244. titleBar.titleColor = titleFontColor;
  1245. titleBar.titleAlpha = titleFontColorAlpha;
  1246. titleBar.leftKey = leftKeys;
  1247. titleBar.rightKey = rightKeys;
  1248. }
  1249. stateBar.state = showState;
  1250. if (showState != 2) {
  1251. stateBar.way = stateWay;
  1252. if (stateWay == 2) { // 延伸
  1253. stateBar.fontColor = stateFontColor;
  1254. } else { // 自定义颜色
  1255. stateBar.bgColor = stateBgColor;
  1256. stateBar.bgAlpha = stateBgColorAlpha;
  1257. stateBar.fontColor = stateFontColor;
  1258. }
  1259. }
  1260. });
  1261. // 导航栏背景颜色 字体图标颜色
  1262. $("#colorPicker4").spectrum({
  1263. color: "#157df1",//初始化颜色
  1264. showInput: true,//显示输入
  1265. showAlpha: true, // 透明度
  1266. containerClassName: "full-spectrum",
  1267. showInitial: true,//显示初始颜色,提供现在选择的颜色和初始颜色对比
  1268. showPalette: true,//显示选择器面板
  1269. showSelectionPalette: true,//记住选择过的颜色
  1270. maxPaletteSize: 7,//记住选择过的颜色的最大数量
  1271. preferredFormat: "hex",//输入框颜色格式,(hex十六进制,hex3十六进制可以的话只显示3位,hsl,rgb三原色,name英文名显示)
  1272. hideAfterPaletteSelect: true,// 点击左侧选择颜色,面板关闭
  1273. chooseText: "确定",
  1274. cancelText: "取消",
  1275. move: function (color) {//选择器右边面板移动时触发
  1276. },
  1277. show: function () {//选择器面板显示时触发
  1278. },
  1279. beforeShow: function () {//选择器面板显示之前触发,返回false时不显示
  1280. },
  1281. hide: function (color) {//选择器面板隐藏时触发
  1282. updateNavBackground(color);
  1283. },
  1284. //选择器面板颜色设置
  1285. palette: palette
  1286. });
  1287. $("#navFontColor1").spectrum({
  1288. color: "#ddd",//初始化颜色
  1289. showInput: true,//显示输入
  1290. showAlpha: true, // 透明度
  1291. containerClassName: "full-spectrum",
  1292. showInitial: true,//显示初始颜色,提供现在选择的颜色和初始颜色对比
  1293. showPalette: true,//显示选择器面板
  1294. showSelectionPalette: true,//记住选择过的颜色
  1295. maxPaletteSize: 7,//记住选择过的颜色的最大数量
  1296. preferredFormat: "hex",//输入框颜色格式,(hex十六进制,hex3十六进制可以的话只显示3位,hsl,rgb三原色,name英文名显示)
  1297. hideAfterPaletteSelect: true,// 点击左侧选择颜色,面板关闭
  1298. chooseText: "确定",
  1299. cancelText: "取消",
  1300. move: function (color) {//选择器右边面板移动时触发
  1301. },
  1302. show: function () {//选择器面板显示时触发
  1303. },
  1304. beforeShow: function () {//选择器面板显示之前触发,返回false时不显示
  1305. },
  1306. hide: function (color) {//选择器面板隐藏时触发
  1307. updateNavFontColor1(color);
  1308. },
  1309. //选择器面板颜色设置
  1310. palette: palette
  1311. });
  1312. $("#navFontColor2").spectrum({
  1313. color: "#fff",//初始化颜色
  1314. showInput: true,//显示输入
  1315. showAlpha: true, // 透明度
  1316. containerClassName: "full-spectrum",
  1317. showInitial: true,//显示初始颜色,提供现在选择的颜色和初始颜色对比
  1318. showPalette: true,//显示选择器面板
  1319. showSelectionPalette: true,//记住选择过的颜色
  1320. maxPaletteSize: 7,//记住选择过的颜色的最大数量
  1321. preferredFormat: "hex",//输入框颜色格式,(hex十六进制,hex3十六进制可以的话只显示3位,hsl,rgb三原色,name英文名显示)
  1322. hideAfterPaletteSelect: true,// 点击左侧选择颜色,面板关闭
  1323. chooseText: "确定",
  1324. cancelText: "取消",
  1325. move: function (color) {//选择器右边面板移动时触发
  1326. },
  1327. show: function () {//选择器面板显示时触发
  1328. },
  1329. beforeShow: function () {//选择器面板显示之前触发,返回false时不显示
  1330. },
  1331. hide: function (color) {//选择器面板隐藏时触发
  1332. updateNavFontColor2(color);
  1333. },
  1334. //选择器面板颜色设置
  1335. palette: palette
  1336. });
  1337. function updateNavBackground(color) {
  1338. $(".plugin-nav .state-bgcolor").css("background-color", color);
  1339. }
  1340. function updateNavFontColor1(color) {
  1341. $(".plugin-nav .nav-top ul li").not(":eq(0)").find(".n-icon").css("color", color);
  1342. $(".plugin-nav .nav-top ul li").not(":eq(0)").find(".icon-null").css("border-color", color);
  1343. $(".plugin-nav .nav-top ul li").not(":eq(0)").find(".n-text").css("color", color);
  1344. }
  1345. function updateNavFontColor2(color) {
  1346. $(".plugin-nav .nav-top ul li").eq(0).find(".n-icon").css("color", color);
  1347. $(".plugin-nav .nav-top ul li").eq(0).find(".icon-null").css("border-color", color);
  1348. $(".plugin-nav .nav-top ul li").eq(0).find(".n-text").css("color", color);
  1349. }
  1350. // console.log(getFontColor("#navFontColor1"));
  1351. // 导航栏 下拉框change字体颜色设置、显示链接输入框
  1352. $(".plugin-nav .n-list select").change(function () {
  1353. $(this).css("color", "#333");
  1354. var selectedVal = $(this).find(":selected").val();
  1355. // console.log(selectedVal);
  1356. if (selectedVal == 'link_app' || selectedVal == 'link_url') {
  1357. $(this).parents("dd").find(".n-link").css("visibility", "visible").addClass("link-show");
  1358. } else {
  1359. $(this).parents("dd").find(".n-link").css("visibility", "hidden").removeClass("link-show");
  1360. }
  1361. });
  1362. // 导航栏 图标、文字3种不同 显示方式
  1363. $(".plugin-nav .set-nav .set-bottom ul li").click(function () {
  1364. var i = $(this).index();
  1365. $(".plugin-nav .set-nav .set-bottom ul li").removeClass("active").find(".icon-radio").removeClass("icon-radio-checked");
  1366. $(this).addClass("active").find(".icon-radio").addClass("icon-radio-checked");
  1367. if (i == 0) {
  1368. $(".plugin-nav .n-list .n-text").show();
  1369. $(".plugin-nav .n-list .add-icon").show();
  1370. $(".plugin-nav .nav-top .n-icon").show();
  1371. $(".plugin-nav .nav-top .n-text").show();
  1372. $(".plugin-nav .n-nav .nav-name").show();
  1373. $(".plugin-nav .n-nav .nav-icon").show();
  1374. } else if (i == 1) {
  1375. $(".plugin-nav .n-list .n-text").hide();
  1376. $(".plugin-nav .n-list .add-icon").show();
  1377. $(".plugin-nav .nav-top .n-text").hide();
  1378. $(".plugin-nav .nav-top .n-icon").show();
  1379. $(".plugin-nav .n-nav .nav-name").hide();
  1380. $(".plugin-nav .n-nav .nav-icon").show();
  1381. } else {
  1382. $(".plugin-nav .n-list .n-text").show();
  1383. $(".plugin-nav .n-list .add-icon").hide();
  1384. $(".plugin-nav .nav-top .n-text").show();
  1385. $(".plugin-nav .nav-top .n-icon").hide();
  1386. $(".plugin-nav .n-nav .nav-name").show();
  1387. $(".plugin-nav .n-nav .nav-icon").hide();
  1388. }
  1389. });
  1390. // 导航栏点击图标
  1391. var clickIconIndex = -1;
  1392. $(".plugin-nav .n-list .add-icon").click(function () {
  1393. clickIconIndex = $(this).parents("dd").index();
  1394. $("#iconsModal").modal("show");
  1395. });
  1396. // 导航栏 设置图标
  1397. $(".plugin-modal .icons li").click(function () {
  1398. var i = $(this).index();
  1399. // console.log(i);
  1400. $("#iconsModal").modal("hide");
  1401. $('#navModal').css({'overflow-y': 'scroll'});
  1402. $("body").css("overflow", "hidden");
  1403. $(".plugin-nav .nav-top ul li").eq(clickIconIndex).find(".n-icon").attr("class", "n-icon iconfont icon-" + i + "");
  1404. $(".plugin-nav .n-list dd").eq(clickIconIndex).find(".add-icon").find(".iconfont").attr({
  1405. "class": "iconfont icon-" + i,
  1406. "data-index": i
  1407. }).css("color", "#333");
  1408. });
  1409. /*
  1410. $('#iconsModal').on('hidden.bs.modal', function() {
  1411. $('#navModal').css({'overflow-y':'scroll'});
  1412. });
  1413. */
  1414. // 导航栏 增加配置导航 默认显示2个
  1415. $(".plugin-nav .n-list .add-config").click(function () {
  1416. $dd = $(".plugin-nav .n-list dd");
  1417. var showLength = $(".plugin-nav .n-list dd:visible").length;
  1418. $(".plugin-nav .nav-top ul li").eq(showLength).css("display", "table-cell");
  1419. $(".plugin-nav .n-list dd:hidden").eq(0).show();
  1420. if (showLength >= 4) {
  1421. $(this).addClass("disabled");
  1422. } else {
  1423. $(this).removeClass("disabled");
  1424. }
  1425. });
  1426. // 导航栏 实时文字
  1427. $(".plugin-nav .n-list .n-text").bind("input propertychange", function () {
  1428. var i = $(this).parents("dd").index();
  1429. // console.log(i);
  1430. var thisVal = $(this).val();
  1431. if (thisVal.length == 0) {
  1432. $(".plugin-nav .nav-top ul li").eq(i).find(".n-text").text('空白');
  1433. } else {
  1434. $(".plugin-nav .nav-top ul li").eq(i).find(".n-text").text(thisVal);
  1435. }
  1436. });
  1437. // 导航栏 恢复默认
  1438. $(".plugin-nav .set-nav .reset").click(function () {
  1439. // $("#colorPicker4").spectrum("set", "rgb(249, 249, 249)");
  1440. // 去除错误状态
  1441. $(".plugin-nav .n-list").find(".error").remove();
  1442. // 恢复文字
  1443. $(".plugin-nav .nav-top ul li .n-text").text('空白');
  1444. // 恢复 配置导航显示2个
  1445. $(".plugin-nav .set-nav .n-list dd:nth-of-type(n+3)").hide();
  1446. // 预览导航 恢复到2个
  1447. $(".plugin-nav .nav-top ul li:nth-of-type(n+3)").hide();
  1448. // 导航名称默认恢复为空
  1449. $(".plugin-nav .n-list .n-text").val('');
  1450. // 恢复图标
  1451. $(".plugin-nav .nav-top .n-icon").attr("class", "n-icon icon-null").css("display", "inline-block");
  1452. $(".plugin-nav .n-list .add-icon .iconfont").attr({
  1453. "class": "iconfont icon-jia",
  1454. "data-index": ""
  1455. }).css("color", "#eee");
  1456. // select恢复到默认
  1457. $(".plugin-nav .n-list select").each(function () {
  1458. $(this).css("color", "#999");
  1459. $(this).find("option").eq(0).attr("selected", "selected");
  1460. });
  1461. // 链接输入框恢复到默认
  1462. $(".plugin-nav .n-list .n-link").css("visibility", "hidden").val("").removeClass("link-show");
  1463. // 新增导航按钮去除disabled
  1464. $(".plugin-nav .n-list .add-config").removeClass("disabled");
  1465. });
  1466. // 导航栏 删除
  1467. $(".plugin-nav .n-list .n-delete").click(function () {
  1468. var $This = $(this).parents("dd");
  1469. var i = $This.index();
  1470. $This.hide();
  1471. $This.find(".n-link").removeClass("link-show").show();
  1472. $This.find("select").eq(0).attr("selected", "selected");
  1473. $(".plugin-nav .nav-top ul li").eq(i).hide();
  1474. var showLength = $(".plugin-nav .n-list dd:visible").length;
  1475. if (showLength < 5) {
  1476. $(".plugin-nav .n-list .add-config").removeClass("disabled");
  1477. } else {
  1478. $(".plugin-nav .n-list .add-config").addClass("disabled");
  1479. }
  1480. });
  1481. // 导航栏 保存
  1482. $("#navModal .plugin-save").click(function () {
  1483. var $dd = $(".plugin-nav .n-list dd:visible");
  1484. // 导航栏
  1485. $("#config8").parent().removeClass("active");
  1486. $("#config8").find(".iconfont").removeClass("icon-checkbox-checked1");
  1487. var navBgColor = getFontColor("#colorPicker4");
  1488. var navBgColorAlpha = getAlpha("#colorPicker4");
  1489. var navDefaultFontColor = getFontColor("#navFontColor1");
  1490. var navDefaultFontColorAlpha = getAlpha("#navFontColor1");
  1491. var navCheckedFontColor = getFontColor("#navFontColor2");
  1492. var navCheckedFontColorAlpha = getAlpha("#navFontColor2");
  1493. var iconNameShow = $("#iconNameShow .active").attr("data-show");
  1494. // 第1个导航配置
  1495. var navName0 = $dd.eq(0).find(".n-text").val();
  1496. var navFun0 = $dd.eq(0).find(":selected").val();
  1497. var navIcon0 = $dd.eq(0).find(".iconfont").attr("data-index");
  1498. var navUrl0 = $dd.eq(0).find(".link-show").val();
  1499. // 第2个导航配置
  1500. var navName1 = $dd.eq(1).find(".n-text").val();
  1501. var navFun1 = $dd.eq(1).find(":selected").val();
  1502. var navIcon1 = $dd.eq(1).find(".iconfont").attr("data-index");
  1503. var navUrl1 = $dd.eq(1).find(".link-show").val();
  1504. // 第3个导航配置
  1505. var navName2 = $dd.eq(2).find(".n-text").val();
  1506. var navFun2 = $dd.eq(2).find(":selected").val();
  1507. var navIcon2 = $dd.eq(2).find(".iconfont").attr("data-index");
  1508. var navUrl2 = $dd.eq(2).find(".link-show").val();
  1509. // 第4个导航配置
  1510. var navName3 = $dd.eq(3).find(".n-text").val();
  1511. var navFun3 = $dd.eq(3).find(":selected").val();
  1512. var navIcon3 = $dd.eq(3).find(".iconfont").attr("data-index");
  1513. var navUrl3 = $dd.eq(3).find(".link-show").val();
  1514. // 第5个导航配置
  1515. var navName4 = $dd.eq(4).find(".n-text").val();
  1516. var navFun4 = $dd.eq(4).find(":selected").val();
  1517. var navIcon4 = $dd.eq(4).find(".iconfont").attr("data-index");
  1518. var navUrl4 = $dd.eq(4).find(".link-show").val();
  1519. var nameOnOff1 = false;
  1520. var iconOnOff1 = false;
  1521. var selectOnOff1 = false;
  1522. var linkOnOff1 = true;
  1523. var iconOnOff2 = false;
  1524. var selectOnOff2 = false;
  1525. var linkOnOff2 = true;
  1526. var nameOnOff3 = false;
  1527. var selectOnOff3 = false;
  1528. var linkOnOff3 = true;
  1529. var vLength1 = $dd.length;
  1530. // url 正则
  1531. var match = /^((ht|f)tps?):\/\/([\w\-]+(\.[\w\-]+)*\/)*[\w\-]+(\.[\w\-]+)*\/?(\?([\w\-\.,@?^=%&:\/~\+#]*)+)?/;
  1532. $dd.find('.error').remove();
  1533. var nameErrorText = "请输入导航名称,四个字以内";
  1534. var selectErrorText = "请选择导航功能";
  1535. var iconErrorText = "请选择图标";
  1536. var linkErrorText = "请输入http://或https://的链接地址";
  1537. // 验证 判断
  1538. // 显示名称和图标
  1539. if (iconNameShow == 0) {
  1540. for (var i = 0; i < vLength1; i++) {
  1541. var This1 = $dd.eq(i);
  1542. var thisNameLength1 = getByteLen($.trim(This1.find(".n-text").val()));
  1543. var thisSelVal1 = This1.find(":selected").val();
  1544. var hasIcon1 = This1.find(".add-icon").find(".iconfont").hasClass("icon-jia");
  1545. var thisUrl1 = This1.find(".link-show").val();
  1546. var linkVisble1 = This1.find(".n-link").hasClass("link-show");
  1547. // 导航功能
  1548. if (thisSelVal1 == 0) {
  1549. This1.addClass("form-error");
  1550. This1.append('<div class="error">' + selectErrorText + '</div>');
  1551. selectOnOff1 = false;
  1552. return false;
  1553. } else {
  1554. This1.removeClass("form-error");
  1555. This1.find(".error").remove();
  1556. selectOnOff1 = true;
  1557. }
  1558. // 名称
  1559. if (thisNameLength1 > 0 && thisNameLength1 <= 8) {
  1560. This1.removeClass("form-error");
  1561. This1.find(".error").remove();
  1562. nameOnOff1 = true;
  1563. } else {
  1564. This1.addClass("form-error");
  1565. This1.append('<div class="error">' + nameErrorText + '</div>');
  1566. nameOnOff1 = false;
  1567. return false;
  1568. }
  1569. // 图标
  1570. if (!hasIcon1) {
  1571. This1.removeClass("form-error");
  1572. This1.find(".error").remove();
  1573. iconOnOff1 = true;
  1574. } else {
  1575. This1.addClass("form-error");
  1576. This1.append('<div class="error">' + iconErrorText + '</div>');
  1577. iconOnOff1 = false;
  1578. return false;
  1579. }
  1580. // console.log(match.tidings(thisUrl1));
  1581. // 链接
  1582. if (linkVisble1) {
  1583. if (!match.test(thisUrl1)) {
  1584. This1.addClass("form-error");
  1585. This1.append('<div class="error">' + linkErrorText + '</div>');
  1586. linkOnOff1 = false;
  1587. return false;
  1588. } else {
  1589. This1.removeClass("form-error");
  1590. This1.find(".error").remove();
  1591. linkOnOff1 = true;
  1592. }
  1593. } else {
  1594. linkOnOff1 = true;
  1595. }
  1596. }
  1597. if (selectOnOff1 && nameOnOff1 && iconOnOff1 && linkOnOff1) {
  1598. $("#navModal").modal("hide");
  1599. $("#config8").parent().addClass("active");
  1600. $("#config8").find(".iconfont").addClass("icon-checkbox-checked1");
  1601. }
  1602. } else if (iconNameShow == 1) { /*只显示图标*/
  1603. for (var i = 0; i < vLength1; i++) {
  1604. var This2 = $dd.eq(i);
  1605. // var thisNameLength2 = getByteLen(This2.find(".n-text").val());
  1606. var thisSelVal2 = This2.find(":selected").val();
  1607. var hasIcon2 = This2.find(".add-icon").find(".iconfont").hasClass("icon-jia");
  1608. var thisUrl2 = This2.find(".link-show").val();
  1609. var linkVisble2 = This2.find(".n-link").hasClass("link-show");
  1610. // 导航功能
  1611. if (thisSelVal2 == 0) {
  1612. This2.addClass("form-error");
  1613. This2.append('<div class="error">' + selectErrorText + '</div>');
  1614. selectOnOff2 = false;
  1615. return false;
  1616. } else {
  1617. This2.removeClass("form-error");
  1618. This2.find(".error").remove();
  1619. selectOnOff2 = true;
  1620. }
  1621. // 图标
  1622. if (!hasIcon2) {
  1623. This2.removeClass("form-error");
  1624. This2.find(".error").remove();
  1625. iconOnOff2 = true;
  1626. } else {
  1627. This2.addClass("form-error");
  1628. This2.append('<div class="error">' + iconErrorText + '</div>');
  1629. iconOnOff2 = false;
  1630. return false;
  1631. }
  1632. // console.log(match.tidings(thisUrl2));
  1633. // 链接
  1634. if (linkVisble2) {
  1635. if (!match.test(thisUrl2)) {
  1636. This2.addClass("form-error");
  1637. This2.append('<div class="error">' + linkErrorText + '</div>');
  1638. linkOnOff2 = false;
  1639. return false;
  1640. } else {
  1641. This2.removeClass("form-error");
  1642. This2.find(".error").remove();
  1643. linkOnOff2 = true;
  1644. }
  1645. } else {
  1646. linkOnOff2 = true;
  1647. }
  1648. }
  1649. if (selectOnOff2 && iconOnOff2 && linkOnOff2) {
  1650. $("#navModal").modal("hide");
  1651. $("#config8").parent().addClass("active");
  1652. $("#config8").find(".iconfont").addClass("icon-checkbox-checked1");
  1653. }
  1654. } else { /*只显示名称*/
  1655. for (var i = 0; i < vLength1; i++) {
  1656. var This3 = $dd.eq(i);
  1657. var thisNameLength3 = getByteLen($.trim(This3.find(".n-text").val()));
  1658. var thisSelVal3 = This3.find(":selected").val();
  1659. var thisUrl3 = This3.find(".link-show").val();
  1660. var linkVisble3 = This3.find(".n-link").hasClass("link-show");
  1661. // 导航功能
  1662. if (thisSelVal3 == 0) {
  1663. This3.addClass("form-error");
  1664. This3.append('<div class="error">' + selectErrorText + '</div>');
  1665. selectOnOff3 = false;
  1666. return false;
  1667. } else {
  1668. This3.removeClass("form-error");
  1669. This3.find(".error").remove();
  1670. selectOnOff3 = true;
  1671. }
  1672. // 名称
  1673. if (thisNameLength3 > 0 && thisNameLength3 <= 8) {
  1674. This3.removeClass("form-error");
  1675. This3.find(".error").remove();
  1676. nameOnOff3 = true;
  1677. } else {
  1678. This3.addClass("form-error");
  1679. This3.append('<div class="error">' + nameErrorText + '</div>');
  1680. nameOnOff3 = false;
  1681. return false;
  1682. }
  1683. // 链接
  1684. if (linkVisble3) {
  1685. if (!match.test(thisUrl3)) {
  1686. This3.addClass("form-error");
  1687. This3.append('<div class="error">' + linkErrorText + '</div>');
  1688. linkOnOff3 = false;
  1689. return false;
  1690. } else {
  1691. This3.removeClass("form-error");
  1692. This3.find(".error").remove();
  1693. linkOnOff3 = true;
  1694. }
  1695. } else {
  1696. linkOnOff3 = true;
  1697. }
  1698. }
  1699. // console.log(nameOnOff3);
  1700. if (selectOnOff3 && nameOnOff3 && linkOnOff3) {
  1701. $("#navModal").modal("hide");
  1702. $("#config8").parent().addClass("active");
  1703. $("#config8").find(".iconfont").addClass("icon-checkbox-checked1");
  1704. }
  1705. }
  1706. if (typeof (navName0) === 'undefined' || iconNameShow == 1) navName0 = '';
  1707. if (typeof (navName1) === 'undefined' || iconNameShow == 1) navName1 = '';
  1708. if (typeof (navName2) === 'undefined' || iconNameShow == 1) navName2 = '';
  1709. if (typeof (navName3) === 'undefined' || iconNameShow == 1) navName3 = '';
  1710. if (typeof (navName4) === 'undefined' || iconNameShow == 1) navName4 = '';
  1711. if (typeof (navFun0) === 'undefined') navFun0 = '';
  1712. if (typeof (navFun1) === 'undefined') navFun1 = '';
  1713. if (typeof (navFun2) === 'undefined') navFun2 = '';
  1714. if (typeof (navFun3) === 'undefined') navFun3 = '';
  1715. if (typeof (navFun4) === 'undefined') navFun4 = '';
  1716. if (typeof (navIcon0) === 'undefined' || iconNameShow == 2) navIcon0 = '';
  1717. if (typeof (navIcon1) === 'undefined' || iconNameShow == 2) navIcon1 = '';
  1718. if (typeof (navIcon2) === 'undefined' || iconNameShow == 2) navIcon2 = '';
  1719. if (typeof (navIcon3) === 'undefined' || iconNameShow == 2) navIcon3 = '';
  1720. if (typeof (navIcon4) === 'undefined' || iconNameShow == 2) navIcon4 = '';
  1721. if (typeof (navUrl0) === 'undefined') navUrl0 = '';
  1722. if (typeof (navUrl1) === 'undefined') navUrl1 = '';
  1723. if (typeof (navUrl2) === 'undefined') navUrl2 = '';
  1724. if (typeof (navUrl3) === 'undefined') navUrl3 = '';
  1725. if (typeof (navUrl4) === 'undefined') navUrl4 = '';
  1726. var dataIconName = [];
  1727. if (navName0 || navFun0 || navIcon0 || navUrl0) dataIconName[0] = {
  1728. text: navName0,
  1729. action: navFun0,
  1730. icon: navIcon0,
  1731. url: navUrl0
  1732. };
  1733. if (navName1 || navFun1 || navIcon1 || navUrl1) dataIconName[1] = {
  1734. text: navName1,
  1735. action: navFun1,
  1736. icon: navIcon1,
  1737. url: navUrl1
  1738. };
  1739. if (navName2 || navFun2 || navIcon2 || navUrl2) dataIconName[2] = {
  1740. text: navName2,
  1741. action: navFun2,
  1742. icon: navIcon2,
  1743. url: navUrl2
  1744. };
  1745. if (navName3 || navFun3 || navIcon3 || navUrl3) dataIconName[3] = {
  1746. text: navName3,
  1747. action: navFun3,
  1748. icon: navIcon3,
  1749. url: navUrl3
  1750. };
  1751. if (navName4 || navFun4 || navIcon4 || navUrl4) dataIconName[4] = {
  1752. text: navName4,
  1753. action: navFun4,
  1754. icon: navIcon4,
  1755. url: navUrl4
  1756. };
  1757. navData = {
  1758. menuBackgroundColor: navBgColor,
  1759. menuBackgroundColorAlpha: navBgColorAlpha,
  1760. menuTextColor: navDefaultFontColor,
  1761. menuTextColorAlpha: navDefaultFontColorAlpha,
  1762. menuPressedTextColor: navCheckedFontColor,
  1763. menuPressedTextColorAlpha: navCheckedFontColorAlpha,
  1764. show: iconNameShow,
  1765. menu: dataIconName
  1766. };
  1767. console.log(navData);
  1768. });
  1769. // 左侧栏 取值
  1770. $("#asideModal .plugin-save").click(function () {
  1771. $("#configAside").parent().removeClass("active");
  1772. $("#configAside").find(".iconfont").removeClass("icon-checkbox-checked1");
  1773. var $dd = $(".plugin-aside .n-list dd:visible");
  1774. // 背景色
  1775. var asideBgColor = getFontColor("#colorPicker5");
  1776. // 背景色透明度
  1777. var asideBgColorAlpha = getAlpha("#colorPicker5");
  1778. // 文字和图标颜色
  1779. var asideFontColor = getFontColor("#asideFontColor");
  1780. // 文字和图标颜色透明度
  1781. var asideFontColorAlpha = getAlpha("#asideFontColor");
  1782. // 显示方式
  1783. // var asideDisplay = $(".plugin-aside .set-nav .set-bottom ul .active").attr("data-display");
  1784. // 显示APP
  1785. var asideShowApp = $(".plugin-aside .top-show ul li.active").attr("data-app-show");
  1786. // 第1个导航配置
  1787. var navName0 = $dd.eq(0).find(".n-text").val();
  1788. var navFun0 = $dd.eq(0).find(":selected").val();
  1789. var navIcon0 = $dd.eq(0).find(".iconfont").attr("data-index");
  1790. var navUrl0 = $dd.eq(0).find(".link-show").val();
  1791. // 第2个导航配置
  1792. var navName1 = $dd.eq(1).find(".n-text").val();
  1793. var navFun1 = $dd.eq(1).find(":selected").val();
  1794. var navIcon1 = $dd.eq(1).find(".iconfont").attr("data-index");
  1795. var navUrl1 = $dd.eq(1).find(".link-show").val();
  1796. // 第3个导航配置
  1797. var navName2 = $dd.eq(2).find(".n-text").val();
  1798. var navFun2 = $dd.eq(2).find(":selected").val();
  1799. var navIcon2 = $dd.eq(2).find(".iconfont").attr("data-index");
  1800. var navUrl2 = $dd.eq(2).find(".link-show").val();
  1801. // 第4个导航配置
  1802. var navName3 = $dd.eq(3).find(".n-text").val();
  1803. var navFun3 = $dd.eq(3).find(":selected").val();
  1804. var navIcon3 = $dd.eq(3).find(".iconfont").attr("data-index");
  1805. var navUrl3 = $dd.eq(3).find(".link-show").val();
  1806. // 第5个导航配置
  1807. var navName4 = $dd.eq(4).find(".n-text").val();
  1808. var navFun4 = $dd.eq(4).find(":selected").val();
  1809. var navIcon4 = $dd.eq(4).find(".iconfont").attr("data-index");
  1810. var navUrl4 = $dd.eq(4).find(".link-show").val();
  1811. // 第6个导航配置
  1812. var navName5 = $dd.eq(5).find(".n-text").val();
  1813. var navFun5 = $dd.eq(5).find(":selected").val();
  1814. var navIcon5 = $dd.eq(5).find(".iconfont").attr("data-index");
  1815. var navUrl5 = $dd.eq(5).find(".link-show").val();
  1816. // 第7个导航配置
  1817. var navName6 = $dd.eq(6).find(".n-text").val();
  1818. var navFun6 = $dd.eq(6).find(":selected").val();
  1819. var navIcon6 = $dd.eq(6).find(".iconfont").attr("data-index");
  1820. var navUrl6 = $dd.eq(6).find(".link-show").val();
  1821. // 第8个导航配置
  1822. var navName7 = $dd.eq(7).find(".n-text").val();
  1823. var navFun7 = $dd.eq(7).find(":selected").val();
  1824. var navIcon7 = $dd.eq(7).find(".iconfont").attr("data-index");
  1825. var navUrl7 = $dd.eq(7).find(".link-show").val();
  1826. // 第9个导航配置
  1827. var navName8 = $dd.eq(8).find(".n-text").val();
  1828. var navFun8 = $dd.eq(8).find(":selected").val();
  1829. var navIcon8 = $dd.eq(8).find(".iconfont").attr("data-index");
  1830. var navUrl8 = $dd.eq(8).find(".link-show").val();
  1831. // 第10个导航配置
  1832. var navName9 = $dd.eq(9).find(".n-text").val();
  1833. var navFun9 = $dd.eq(9).find(":selected").val();
  1834. var navIcon9 = $dd.eq(9).find(".iconfont").attr("data-index");
  1835. var navUrl9 = $dd.eq(9).find(".link-show").val();
  1836. var nameOnOff1 = false;
  1837. var iconOnOff1 = false;
  1838. var selectOnOff1 = false;
  1839. var linkOnOff1 = true;
  1840. var vLength1 = $dd.length;
  1841. // url 正则
  1842. var match = /^((ht|f)tps?):\/\/([\w\-]+(\.[\w\-]+)*\/)*[\w\-]+(\.[\w\-]+)*\/?(\?([\w\-\.,@?^=%&:\/~\+#]*)+)?/;
  1843. $dd.find('.error').remove();
  1844. var nameErrorText = "请输入导航名称,十个字以内";
  1845. var selectErrorText = "请选择导航功能";
  1846. var iconErrorText = "请选择图标";
  1847. var linkErrorText = "请输入http://或https://的链接地址";
  1848. // 验证 判断
  1849. for (var i = 0; i < vLength1; i++) {
  1850. var This1 = $dd.eq(i);
  1851. var thisNameLength1 = getByteLen($.trim(This1.find(".n-text").val()));
  1852. var thisSelVal1 = This1.find(":selected").val();
  1853. var hasIcon1 = This1.find(".add-icon").find(".iconfont").hasClass("icon-jia");
  1854. var thisUrl1 = This1.find(".link-show").val();
  1855. var linkVisble1 = This1.find(".n-link").hasClass("link-show");
  1856. // 导航功能
  1857. if (thisSelVal1 == 0) {
  1858. This1.addClass("form-error");
  1859. This1.append('<div class="error">' + selectErrorText + '</div>');
  1860. selectOnOff1 = false;
  1861. return false;
  1862. } else {
  1863. This1.removeClass("form-error");
  1864. This1.find(".error").remove();
  1865. selectOnOff1 = true;
  1866. }
  1867. // 名称
  1868. if (thisNameLength1 > 0 && thisNameLength1 <= 20) {
  1869. This1.removeClass("form-error");
  1870. This1.find(".error").remove();
  1871. nameOnOff1 = true;
  1872. } else {
  1873. This1.addClass("form-error");
  1874. This1.append('<div class="error">' + nameErrorText + '</div>');
  1875. nameOnOff1 = false;
  1876. return false;
  1877. }
  1878. // 图标
  1879. if (!hasIcon1) {
  1880. This1.removeClass("form-error");
  1881. This1.find(".error").remove();
  1882. iconOnOff1 = true;
  1883. } else {
  1884. This1.addClass("form-error");
  1885. This1.append('<div class="error">' + iconErrorText + '</div>');
  1886. iconOnOff1 = false;
  1887. return false;
  1888. }
  1889. // console.log(match.tidings(thisUrl1));
  1890. // 链接
  1891. if (linkVisble1) {
  1892. if (!match.test(thisUrl1)) {
  1893. This1.addClass("form-error");
  1894. This1.append('<div class="error">' + linkErrorText + '</div>');
  1895. linkOnOff1 = false;
  1896. return false;
  1897. } else {
  1898. This1.removeClass("form-error");
  1899. This1.find(".error").remove();
  1900. linkOnOff1 = true;
  1901. }
  1902. } else {
  1903. linkOnOff1 = true;
  1904. }
  1905. }
  1906. // console.log(linkOnOff1);
  1907. if (selectOnOff1 && nameOnOff1 && iconOnOff1 && linkOnOff1) {
  1908. $("#asideModal").modal("hide");
  1909. $("#configAside").parent().addClass("active");
  1910. $("#configAside").find(".iconfont").addClass("icon-checkbox-checked1");
  1911. }
  1912. if (typeof (navName0) === 'undefined') navName0 = '';
  1913. if (typeof (navName1) === 'undefined') navName1 = '';
  1914. if (typeof (navName2) === 'undefined') navName2 = '';
  1915. if (typeof (navName3) === 'undefined') navName3 = '';
  1916. if (typeof (navName4) === 'undefined') navName4 = '';
  1917. if (typeof (navName5) === 'undefined') navName5 = '';
  1918. if (typeof (navName6) === 'undefined') navName6 = '';
  1919. if (typeof (navName7) === 'undefined') navName7 = '';
  1920. if (typeof (navName8) === 'undefined') navName8 = '';
  1921. if (typeof (navName9) === 'undefined') navName9 = '';
  1922. if (typeof (navFun0) === 'undefined') navFun0 = '';
  1923. if (typeof (navFun1) === 'undefined') navFun1 = '';
  1924. if (typeof (navFun2) === 'undefined') navFun2 = '';
  1925. if (typeof (navFun3) === 'undefined') navFun3 = '';
  1926. if (typeof (navFun4) === 'undefined') navFun4 = '';
  1927. if (typeof (navFun5) === 'undefined') navFun5 = '';
  1928. if (typeof (navFun6) === 'undefined') navFun6 = '';
  1929. if (typeof (navFun7) === 'undefined') navFun7 = '';
  1930. if (typeof (navFun8) === 'undefined') navFun8 = '';
  1931. if (typeof (navFun9) === 'undefined') navFun9 = '';
  1932. if (typeof (navIcon0) === 'undefined') navIcon0 = '';
  1933. if (typeof (navIcon1) === 'undefined') navIcon1 = '';
  1934. if (typeof (navIcon2) === 'undefined') navIcon2 = '';
  1935. if (typeof (navIcon3) === 'undefined') navIcon3 = '';
  1936. if (typeof (navIcon4) === 'undefined') navIcon4 = '';
  1937. if (typeof (navIcon5) === 'undefined') navIcon5 = '';
  1938. if (typeof (navIcon6) === 'undefined') navIcon6 = '';
  1939. if (typeof (navIcon7) === 'undefined') navIcon7 = '';
  1940. if (typeof (navIcon8) === 'undefined') navIcon8 = '';
  1941. if (typeof (navIcon9) === 'undefined') navIcon9 = '';
  1942. if (typeof (navUrl0) === 'undefined') navUrl0 = '';
  1943. if (typeof (navUrl1) === 'undefined') navUrl1 = '';
  1944. if (typeof (navUrl2) === 'undefined') navUrl2 = '';
  1945. if (typeof (navUrl3) === 'undefined') navUrl3 = '';
  1946. if (typeof (navUrl4) === 'undefined') navUrl4 = '';
  1947. if (typeof (navUrl5) === 'undefined') navUrl5 = '';
  1948. if (typeof (navUrl6) === 'undefined') navUrl6 = '';
  1949. if (typeof (navUrl7) === 'undefined') navUrl7 = '';
  1950. if (typeof (navUrl8) === 'undefined') navUrl8 = '';
  1951. if (typeof (navUrl9) === 'undefined') navUrl9 = '';
  1952. var dataIconName = [];
  1953. if (navName0 || navFun0 || navIcon0 || navUrl0) dataIconName[0] = {
  1954. text: navName0,
  1955. action: navFun0,
  1956. icon: navIcon0,
  1957. url: navUrl0
  1958. };
  1959. if (navName1 || navFun1 || navIcon1 || navUrl1) dataIconName[1] = {
  1960. text: navName1,
  1961. action: navFun1,
  1962. icon: navIcon1,
  1963. url: navUrl1
  1964. };
  1965. if (navName2 || navFun2 || navIcon2 || navUrl2) dataIconName[2] = {
  1966. text: navName2,
  1967. action: navFun2,
  1968. icon: navIcon2,
  1969. url: navUrl2
  1970. };
  1971. if (navName3 || navFun3 || navIcon3 || navUrl3) dataIconName[3] = {
  1972. text: navName3,
  1973. action: navFun3,
  1974. icon: navIcon3,
  1975. url: navUrl3
  1976. };
  1977. if (navName4 || navFun4 || navIcon4 || navUrl4) dataIconName[4] = {
  1978. text: navName4,
  1979. action: navFun4,
  1980. icon: navIcon4,
  1981. url: navUrl4
  1982. };
  1983. if (navName5 || navFun5 || navIcon5 || navUrl5) dataIconName[5] = {
  1984. text: navName5,
  1985. action: navFun5,
  1986. icon: navIcon5,
  1987. url: navUrl5
  1988. };
  1989. if (navName6 || navFun6 || navIcon6 || navUrl6) dataIconName[6] = {
  1990. text: navName6,
  1991. action: navFun6,
  1992. icon: navIcon6,
  1993. url: navUrl6
  1994. };
  1995. if (navName7 || navFun7 || navIcon7 || navUrl7) dataIconName[7] = {
  1996. text: navName7,
  1997. action: navFun7,
  1998. icon: navIcon7,
  1999. url: navUrl7
  2000. };
  2001. if (navName8 || navFun8 || navIcon8 || navUrl8) dataIconName[8] = {
  2002. text: navName8,
  2003. action: navFun8,
  2004. icon: navIcon8,
  2005. url: navUrl8
  2006. };
  2007. if (navName9 || navFun9 || navIcon9 || navUrl9) dataIconName[9] = {
  2008. text: navName9,
  2009. action: navFun9,
  2010. icon: navIcon9,
  2011. url: navUrl9
  2012. };
  2013. asideData = {
  2014. asideBgColor: asideBgColor,
  2015. asideBgColorAlpha: asideBgColorAlpha,
  2016. asideFontColor: asideFontColor,
  2017. asideFontColorAlpha: asideFontColorAlpha,
  2018. // asideDisplay: asideDisplay,
  2019. asideShowApp: asideShowApp,
  2020. menu: dataIconName
  2021. };
  2022. console.log(asideData);
  2023. });
  2024. // 长按图片保存点击保存
  2025. $("#photoSaveModal .plugin-save").click(function () {
  2026. supportLongPressSavePicture = $("#photoSaveModal").find("ul>li.active").data('photo-save');
  2027. console.log(supportLongPressSavePicture);
  2028. });
  2029. // 支持二维码扫码点击保存
  2030. $("#identifyCodeModal .plugin-save").click(function () {
  2031. supportQrcodeScan = $("#identifyCodeModal").find("ul>li.active").data('identify-code');
  2032. console.log(supportQrcodeScan);
  2033. });
  2034. // 支持侧滑返回
  2035. $("#skidBackModal .plugin-save").click(function () {
  2036. skidBack = $("#skidBackModal").find("ul>li.active").data('skid-back');
  2037. console.log(skidBack);
  2038. });
  2039. // 支持无网提示
  2040. $("#noNetModal .plugin-save").click(function () {
  2041. noNet = $("#noNetModal").find("ul>li.active").data('no-net');
  2042. console.log(noNet);
  2043. });
  2044. // 支持APK安装器
  2045. $("#installTipModal .plugin-save").click(function () {
  2046. installTip = $("#installTipModal").find("ul>li.active").data('install-tip');
  2047. console.log(installTip);
  2048. });
  2049. // 支持屏幕常亮
  2050. $("#keepScreenModal .plugin-save").click(function () {
  2051. keepScreen = $("#keepScreenModal").find("ul>li.active").data('keep-screen');
  2052. console.log(keepScreen);
  2053. });
  2054. // 支持隐藏虚拟按键
  2055. $("#hideBottomModal .plugin-save").click(function () {
  2056. hideBottom = $("#hideBottomModal").find("ul>li.active").data('hide-bottom');
  2057. console.log(hideBottom);
  2058. });
  2059. // 网页缩放
  2060. // 开启 关闭
  2061. $(".plugin-web-zoom .fun li").click(function () {
  2062. var attr = $(this).attr("data-web-zoom");
  2063. if (attr == -1) {
  2064. $(this).parents(".plugin-web-zoom").find(".zoom-in").hide();
  2065. } else {
  2066. $(this).parents(".plugin-web-zoom").find(".zoom-in").show();
  2067. }
  2068. });
  2069. // 支持网页缩放
  2070. $("#webZoomModal .plugin-save").click(function () {
  2071. supportZoom = $("#webZoomModal").find("ul>li.active").data('web-zoom');
  2072. console.log(supportZoom);
  2073. });
  2074. // 引导页保存
  2075. $("#guideModal .plugin-save").click(function () {
  2076. // 是否显示“立即体验”,以及按钮颜色
  2077. supportGuideEnterMainPageButton = $('#guideModal .experience').find("li.active").data('type');
  2078. guideEnterMainPageButtonColor = getFontColor("#experienceTextColor");
  2079. guide = {};
  2080. $('#guideModal').find(".plugin-guide img").each(function (index, element) {
  2081. guide[index] = $(element).attr('src');
  2082. });
  2083. });
  2084. // UA设置
  2085. $("#uaModal .plugin-save").click(function () {
  2086. userAgent = {};
  2087. userAgent.appendUa = $.trim($('#uaModal').find("input[name='appendUa']").val());
  2088. userAgent.completeUa = $.trim($('#uaModal').find("input[name='completeUa']").val());
  2089. if (!userAgent.appendUa && !userAgent.completeUa) {
  2090. $('#uaModal').find("input[name='completeUa']").parents(".form-group").addClass("form-error");
  2091. } else {
  2092. $('#uaModal').find("input[name='completeUa']").parents(".form-group").removeClass("form-error");
  2093. }
  2094. var errorLength = $(".plugin-ua .form-error").length;
  2095. if (errorLength > 0) {
  2096. $("#uaModal").modal("show");
  2097. $("[data-target=#uaModal]").removeClass("active").find(".icon-checkbox1").removeClass("icon-checkbox-checked1 add-checked");
  2098. } else {
  2099. $("#uaModal").modal("hide");
  2100. $("[data-target=#uaModal]").addClass("active").find(".icon-checkbox1").addClass("icon-checkbox-checked1 add-checked");
  2101. }
  2102. });
  2103. $(".toStore").on('click', function () {
  2104. $('#msModal8').modal('show');
  2105. appName = $("input[name=app]").val();
  2106. url = $("input[name=url]").val();
  2107. device = $("#device").find(".active").attr("data-device");
  2108. screen = $("#screen").find(".active").attr("data-screen");
  2109. version = $("input[name=version]").val();
  2110. bundle = $("input[name=bundle]").val();
  2111. appIcon = $(".pack-step2 #appIcon").find("img").attr('src');// ICON图标
  2112. startPage = $("input[name='startPage']").parent().find("img").attr("src"); // 启动图
  2113. splashShowTime = $(".pack-step2 .start-time ").find("ul>li.active").data("start-time"); // 启动图显示时长
  2114. isSupportShowSplashSkipButton = $(".pack-step2 .show-skip").find("ul>li.active").data("show"); // 是否显示跳过按钮
  2115. // 获取插件
  2116. plugin = {};
  2117. var hasChecked1 = $("#config1").find(".iconfont").hasClass("icon-checkbox-checked1"); // 加载动画
  2118. var hasChecked2 = $("#config2").find(".iconfont").hasClass("icon-checkbox-checked1"); // 清理缓存
  2119. var hasChecked3 = $("#config3").find(".iconfont").hasClass("icon-checkbox-checked1"); // 浏览器
  2120. var hasChecked4 = $("#config4").find(".iconfont").hasClass("icon-checkbox-checked1"); // 退出提示
  2121. var hasChecked5 = $("#config5").find(".iconfont").hasClass("icon-checkbox-checked1"); // 第三方分享
  2122. var hasChecked6 = $("#config6").find(".iconfont").hasClass("icon-checkbox-checked1"); // 极光推送
  2123. var hasChecked7 = $("#config7").find(".iconfont").hasClass("icon-checkbox-checked1"); // 友盟统计
  2124. var hasChecked8 = $("#config8").find(".iconfont").hasClass("icon-checkbox-checked1"); // 导航栏
  2125. var hasChecked9 = $("#config9").find(".iconfont").hasClass("icon-checkbox-checked1"); // 状态栏
  2126. var hasChecked10 = $("#config10").find(".iconfont").hasClass("icon-checkbox-checked1"); // 标题栏
  2127. var hasChecked11 = $("#config11").find(".iconfont").hasClass("icon-checkbox-checked1"); // 引导页
  2128. var configAsideChecked = $("#configAside").find(".iconfont").hasClass("icon-checkbox-checked1"); // 左侧栏
  2129. var longPressSavePictureChecked = $("#configPhotoSave").find(".iconfont").hasClass("icon-checkbox-checked1"); // 长按图片保存
  2130. var qrcodeScanChecked = $("#configIdentifyCode").find(".iconfont").hasClass("icon-checkbox-checked1"); // 扫一扫
  2131. var webZoomChecked = $("#configWebZoom").find(".iconfont").hasClass("icon-checkbox-checked1"); // 网页缩放
  2132. var userAgentChecked = $("#userAgent").find(".iconfont").hasClass("icon-checkbox-checked1");
  2133. var isSkidBack = $("#configSkidBack").find(".iconfont").hasClass("icon-checkbox-checked1"); // 侧滑返回
  2134. var isNoNet = $("#configNoNet").find(".iconfont").hasClass("icon-checkbox-checked1"); // 无网提示
  2135. var isInstallTip = $("#configInstallTip").find(".iconfont").hasClass("icon-checkbox-checked1"); // APK安装器
  2136. var isKeepScreen = $("#configKeepScreen").find(".iconfont").hasClass("icon-checkbox-checked1"); // 屏幕常亮
  2137. var isHideBottom = $("#configHideBottom").find(".iconfont").hasClass("icon-checkbox-checked1"); // 屏幕常亮
  2138. var hasKeystore = $('#configKeystore').find(".iconfont").hasClass("icon-checkbox-checked1"); // 安卓证书
  2139. plugin.supportLongPressSavePicture = 0;
  2140. plugin.supportQrcodeScan = 0;
  2141. plugin.supportZoom = 0;
  2142. plugin.userAgent = {};
  2143. plugin.skidBack = 0;
  2144. plugin.noNet = 0;
  2145. plugin.installTip = 0;
  2146. plugin.keepScreen = 0;
  2147. plugin.hideBottom = 0;
  2148. if (longPressSavePictureChecked) plugin.supportLongPressSavePicture = supportLongPressSavePicture;
  2149. if (qrcodeScanChecked) plugin.supportQrcodeScan = supportQrcodeScan;
  2150. if (webZoomChecked) plugin.supportZoom = supportZoom;
  2151. if (userAgentChecked) plugin.userAgent = userAgent;
  2152. if (isSkidBack) plugin.skidBack = skidBack;
  2153. if (isNoNet) plugin.noNet = noNet;
  2154. if (isInstallTip) plugin.installTip = installTip;
  2155. if (isKeepScreen) plugin.keepScreen = keepScreen;
  2156. if (isHideBottom) plugin.hideBottom = hideBottom;
  2157. // 下拉刷新
  2158. var hasCheckedRefresh = $("#configRefresh").find(".iconfont").hasClass("icon-checkbox-checked1");
  2159. if (hasCheckedRefresh) {
  2160. refreshVal = $("#refreshModal").find(".plugin-refresh").find(".active").attr("data-refresh");
  2161. plugin.refresh = refreshVal;
  2162. } else {
  2163. plugin.refresh = 0;
  2164. }
  2165. // URL 拉起APP
  2166. var hasCheckedUrlApp = $("#configUrlApp").find(".iconfont").hasClass("icon-checkbox-checked1");
  2167. plugin.urlApp = 0;
  2168. if (hasCheckedUrlApp) {
  2169. urlAppVal = $("#urlAppModal").find(".plugin-url-app").find(".active").attr("data-url-app");
  2170. plugin.urlApp = urlAppVal;
  2171. }
  2172. // 加载配置
  2173. if (hasChecked1) {
  2174. way = $("#loadingModal").find(".plugin-loading").find(".active").attr("data-way");
  2175. color = $("#loadingModal").find(".plugin-loading").find(".sp-preview-inner").css("background-color");
  2176. color = colorRGB2Hex(color);
  2177. plugin.loading = {way: way, color: color};
  2178. } else {
  2179. plugin.loading = {};
  2180. }
  2181. // 清理缓存
  2182. if (hasChecked2) {
  2183. plugin.cache = $("#cacheModal").find(".plugin-cache").find(".active").attr("data-cache");
  2184. } else {
  2185. plugin.cache = 0;
  2186. }
  2187. // 浏览器内核
  2188. if (hasChecked3) {
  2189. android = $("#browserModal").find("#androidKernel").find(".active").attr("data-android-kernel");
  2190. ios = $("#browserModal").find("#iosKernel").find(".active").attr("data-ios-kernel");
  2191. plugin.browser = {android: android, ios: ios}
  2192. } else {
  2193. plugin.browser = {};
  2194. }
  2195. // 退出提示
  2196. if (hasChecked4) {
  2197. exit = $("#exitModal").find(".plugin-exit").find(".active").attr("data-exit");
  2198. plugin.exit = exit;
  2199. } else {
  2200. plugin.exit = 0;
  2201. }
  2202. // 第三方分享
  2203. if (hasChecked5) {
  2204. plugin.share = share;
  2205. }
  2206. // 极光推送
  2207. plugin.jPushId = '';
  2208. if (hasChecked6) {
  2209. jPushId = $.trim($('#auroraModal input[name="jPushId"]').val());
  2210. if (jPushId) plugin.jPushId = jPushId;
  2211. }
  2212. // 友盟统计
  2213. plugin.umengKey = '';
  2214. if (hasChecked7) {
  2215. umengIosKey = $.trim($('#alliesModal input[name="umeng_ios_key"]').val());
  2216. umengAndroidKey = $.trim($('#alliesModal input[name="umeng_android_key"]').val());
  2217. plugin.umengKey = {
  2218. ios: umengIosKey,
  2219. android: umengAndroidKey
  2220. };
  2221. }
  2222. // 导航栏
  2223. plugin.nav = '';
  2224. if (hasChecked8 && navData) plugin.nav = navData;
  2225. // 状态标题栏
  2226. plugin.titleBar = '';
  2227. plugin.stateBar = '';
  2228. if (hasChecked10) {
  2229. plugin.titleBar = titleBar;
  2230. plugin.stateBar = stateBar;
  2231. }
  2232. // 侧边栏
  2233. plugin.asideData = '';
  2234. if (configAsideChecked && asideData) plugin.asideData = asideData;
  2235. console.info(plugin);
  2236. // 引导页
  2237. plugin.guide = {};
  2238. if (hasChecked11) {
  2239. plugin.guide = guide;
  2240. plugin.support_guide_enter_main_page_button = supportGuideEnterMainPageButton;
  2241. plugin.guide_enter_main_page_button_color = guideEnterMainPageButtonColor;
  2242. }
  2243. if(hasKeystore) {
  2244. delete androidKey.save;
  2245. plugin.androidKey = androidKey;
  2246. }
  2247. // 是否点击跳过
  2248. //var isSkip = $(this).hasClass('skip');
  2249. formData = new FormData();
  2250. formData.append('id', id);
  2251. formData.append('appName', appName);
  2252. formData.append('url', url);
  2253. formData.append('device', device);
  2254. formData.append('appVersion', version);
  2255. formData.append('bundleId', bundle);
  2256. formData.append('splashMode', screen);
  2257. formData.append('icon', appIcon);
  2258. formData.append('splash', startPage);
  2259. formData.append('isSupportShowSplashSkipButton', isSupportShowSplashSkipButton);
  2260. formData.append('splashShowTime', splashShowTime);
  2261. formData.append('plugin', JSON.stringify(plugin));
  2262. $.ajax({
  2263. url: '/pack/store',
  2264. type: 'POST',
  2265. cache: false,
  2266. data: formData,
  2267. processData: false,
  2268. contentType: false,
  2269. success: function (result) {
  2270. $('#msModal8').modal('hide');
  2271. if (result.code != 200) {
  2272. if (result.code == -10001) {
  2273. alert(result.msg, function () {
  2274. window.location.href = '/user/login';
  2275. });
  2276. } else {
  2277. alert(result.msg);
  2278. }
  2279. return;
  2280. }
  2281. window.location.href = result.data.url
  2282. }
  2283. });
  2284. });
  2285. $(function () {
  2286. $(document).on('click', "div[data-target='#navModal']", function () {
  2287. console.info(navData);
  2288. // 设置导航背景色
  2289. if (navData.menuBackgroundColor) {
  2290. $("#colorPicker4").spectrum("set", navData.menuBackgroundColor);
  2291. updateNavBackground(navData.menuBackgroundColor);
  2292. }
  2293. // 字体色
  2294. if (navData.menuTextColor) {
  2295. $("#navFontColor1").spectrum("set", navData.menuTextColor);
  2296. updateNavFontColor1(navData.menuTextColor);
  2297. }
  2298. // 选中色
  2299. if (navData.menuPressedTextColor) {
  2300. $("#navFontColor2").spectrum("set", navData.menuPressedTextColor);
  2301. updateNavFontColor2(navData.menuPressedTextColor);
  2302. }
  2303. //显示类型
  2304. $("#navModal").find("#iconNameShow li[data-show='" + navData.show + "']").trigger('click');
  2305. //设置导航值
  2306. var jsonLength = 0;
  2307. if (navData.menu) {
  2308. $.each(navData.menu, function () {
  2309. jsonLength++;
  2310. });
  2311. }
  2312. // 需要补充的导航个数
  2313. var addLength = jsonLength - 2;
  2314. if (addLength > 0) {
  2315. for (var i = 0; i < addLength; i++) {
  2316. $(".plugin-nav .nav-top ul li").eq(i + 2).css("display", "table-cell");
  2317. $(".plugin-nav .n-list dd:hidden").eq(i + 2).show();
  2318. }
  2319. }
  2320. if (navData.menu) {
  2321. // 填充数据
  2322. $.each(navData.menu, function (key, item) {
  2323. var dd = $(".plugin-nav .n-list dd");
  2324. if (item.text) {
  2325. dd.eq(key).find("input[name='navText']").val(item.text);
  2326. $(".plugin-nav .nav-top ul li").eq(key).find(".n-text").text(item.text);
  2327. }
  2328. dd.eq(key).find("select").val(item.action);
  2329. dd.eq(key).find("select").trigger('change');
  2330. if (item.icon) {
  2331. dd.eq(key).find(".add-icon span").attr('class', 'iconfont icon-' + item.icon);
  2332. dd.eq(key).find(".add-icon span").css('color', 'rgb(51, 51, 51)');
  2333. dd.eq(key).find(".add-icon span").attr('data-index', item.icon);
  2334. $(".plugin-nav .nav-top ul li").eq(key).find(".n-icon").attr("class", "n-icon iconfont icon-" + item.icon + "");
  2335. }
  2336. dd.eq(key).find("input[name='navLink']").val(item.url);
  2337. });
  2338. }
  2339. });
  2340. // 状态标题栏设置默认值
  2341. $(document).on('click', "div[data-target='#titleModal']", function () {
  2342. // 状态栏设置
  2343. if (stateBar.state == 2) { // 隐藏
  2344. $(".plugin-title").find(".state-show-toggle li[data-state='2']").trigger('click');
  2345. } else {
  2346. if (stateBar.way == 2) { // 延伸
  2347. $(".plugin-title .state-way-ul").find("li[data-state-way='2']").trigger('click');
  2348. } else { // 自定义
  2349. $(".plugin-title .state-way-ul").find("li[data-state-way='1']").trigger('click');
  2350. if (stateBar.bgColor) {
  2351. // 设置背景色
  2352. $("#colorPicker2").spectrum("set", stateBar.bgColor);
  2353. updateStateBackground(stateBar.bgColor);
  2354. //$("$colorPicker2").css('opacity', stateBar.bgAlpha);
  2355. //$("#titleModal .state-bgcolor").css("opacity", '0.5');
  2356. }
  2357. }
  2358. // 设置文字色
  2359. if (stateBar.fontColor) {
  2360. $(".plugin-title .bg-text-color1").find("li[data-state-font-color=" + stateBar.fontColor + "]").trigger('click');
  2361. }
  2362. }
  2363. // 显示或隐藏
  2364. if (titleBar.show == 1) {
  2365. $(".plugin-title").find("#titleShow li[data-show='1']").trigger('click');
  2366. return;
  2367. }
  2368. if (!titleBar.title) titleBar.title = $("input[name=app]").val();
  2369. $(".plugin-title .input-title").val(titleBar.title);
  2370. $(".plugin-title .input-title").parents(".plugin-title").find(".title-top").find(".text").text(titleBar.title);
  2371. // 设置颜色
  2372. if (titleBar.bgColor) {
  2373. $("#colorPicker3").spectrum("set", titleBar.bgColor);
  2374. updateTitleBackground(titleBar.bgColor);
  2375. }
  2376. if (titleBar.titleColor) {
  2377. $("#titFontColor").spectrum("set", titleBar.titleColor);
  2378. updateTitleFontColor(titleBar.titleColor);
  2379. }
  2380. if (titleBar.leftKey) {
  2381. $.each(titleBar.leftKey, function (key, val) {
  2382. if (!$("#leftKey").find("li[data-left-key='" + val + "']").hasClass('active')) {
  2383. // 设置功能键
  2384. $("#leftKey").find("li[data-left-key='" + val + "']").trigger('click');
  2385. console.log(val);
  2386. }
  2387. });
  2388. }
  2389. if (titleBar.rightKey) {
  2390. $.each(titleBar.rightKey, function (key, v) {
  2391. // 设置功能键,是否选中,选中后不再触发点击
  2392. if (!$("#rightKey").find("li[data-right-key='" + v + "']").hasClass('active')) {
  2393. $("#rightKey").find("li[data-right-key='" + v + "']").trigger('click');
  2394. console.log(v);
  2395. }
  2396. });
  2397. }
  2398. });
  2399. // 第三方分享设置默认值
  2400. $(document).on('click', "div[data-target='#shareModal']", function () {
  2401. if (share.way == 1) {
  2402. $(".plugin-share .s-ul").find("li[data-way='1']").trigger('click');
  2403. } else {
  2404. $(".plugin-share .s-ul").find("li[data-way='0']").trigger('click');
  2405. }
  2406. $("#shareModal input[name=wxId]").val(share.wxId);
  2407. $("#shareModal input[name=wxSecret]").val(share.wxSecret);
  2408. $("#shareModal input[name=text]").val(share.shareText);
  2409. $("#shareModal input[name=link1]").val(share.shareUrl);
  2410. });
  2411. // 第三方分享设置默认值
  2412. $(document).on('click', "div[data-target='#keystoreModal']", function () {
  2413. $('#keystoreModal .keystore-wrap').find("input[name='store_file_content']").val(androidKey.file_url);
  2414. $('#keystoreModal .keystore-wrap').find("input[name='store_storepass']").val(androidKey.store_pass);
  2415. $('#keystoreModal .keystore-wrap').find("input[name='store_alias']").val(androidKey.alias);
  2416. $('#keystoreModal .keystore-wrap').find("input[name='store_keypass']").val(androidKey.key_pass);
  2417. });
  2418. // 侧边栏设置默认值
  2419. $(document).on('click', "div[data-target='#asideModal']", function () {
  2420. var iconImg = $(".step2").find("#appIcon img").attr('src');
  2421. $("#asideModal").find(".aside-icon img").attr('src', iconImg);
  2422. // 背景色
  2423. if (asideData.asideBgColor) {
  2424. $("#colorPicker5").spectrum("set", asideData.asideBgColor);
  2425. updateAsideBackground(asideData.asideBgColor);
  2426. }
  2427. // 字体色
  2428. if (asideData.asideFontColor) {
  2429. $("#asideFontColor").spectrum("set", asideData.asideFontColor);
  2430. updateAsideFontColor(asideData.asideFontColor);
  2431. }
  2432. // 显示方式
  2433. $("#asideModal").find("#displayMode li[data-display='" + asideData.asideDisplay + "']").trigger('click');
  2434. // 是否显示APP
  2435. $("#asideModal").find(".top-show li[data-app-show='" + asideData.asideShowApp + "']").trigger('click');
  2436. //设置导航值
  2437. var jsonLength = 0;
  2438. if (asideData.menu) {
  2439. $.each(asideData.menu, function () {
  2440. jsonLength++;
  2441. });
  2442. }
  2443. // 需要补充的导航个数
  2444. var addLength = jsonLength - 1;
  2445. if (addLength > 0) {
  2446. for (var i = 0; i < addLength; i++) {
  2447. $(".plugin-aside .nav-top ul li").eq(i + 1).css("display", "table-cell");
  2448. $(".plugin-aside .n-list dd:hidden").eq(i + 1).show();
  2449. }
  2450. }
  2451. if (asideData.menu) {
  2452. // 填充数据
  2453. $.each(asideData.menu, function (key, item) {
  2454. var dd = $(".plugin-aside .n-list dd");
  2455. if (item.text) {
  2456. dd.eq(key).find("input[name='navText']").val(item.text);
  2457. dd.eq(key).find("input[name='navText']").bind('input propertychange', function () {
  2458. //$(this).val(item.text);
  2459. }).trigger('propertychange');
  2460. $(".plugin-aside .nav-top ul li").eq(key).find(".n-text").text(item.text);
  2461. }
  2462. dd.eq(key).find("select").val(item.action);
  2463. dd.eq(key).find("select").trigger('change');
  2464. if (item.icon) {
  2465. dd.eq(key).find(".add-icon span").attr('class', 'iconfont icon-' + item.icon);
  2466. dd.eq(key).find(".add-icon span").css('color', 'rgb(51, 51, 51)');
  2467. dd.eq(key).find(".add-icon span").attr('data-index', item.icon);
  2468. item.icon.split('menu');
  2469. $(".aside-modal .aside-nav li").eq(key).find(".iconfont").attr("class", "fl iconfont icon-" + item.icon);
  2470. $(".plugin-aside .nav-top ul li").eq(key).find(".n-icon").attr("class", "n-icon iconfont icon-" + item.icon + "");
  2471. }
  2472. dd.eq(key).find("input[name='navLink']").val(item.url);
  2473. });
  2474. }
  2475. });
  2476. // // 状态栏设置默认值
  2477. // $(document).on('click', "div[data-target='#stateModal']", function () {
  2478. // // 设置颜色
  2479. // $("#colorPicker22").spectrum("set", stateBar.bgColor);
  2480. // });
  2481. //------------------ 长按图片保存 -------------------//
  2482. $(document).on('click', "div[data-target='#photoSaveModal']", function () {
  2483. $("#photoSaveModal").find("ul>li[data-photo-save='" + supportLongPressSavePicture + "']").trigger('click');
  2484. });
  2485. //------------------ 支持二维码扫码 -------------------//
  2486. $(document).on('click', "div[data-target='#identifyCodeModal']", function () {
  2487. $("#identifyCodeModal").find("ul>li[data-identify-code='" + supportQrcodeScan + "']").trigger('click');
  2488. });
  2489. //------------------ 支持侧滑返回 -------------------//
  2490. $(document).on('click', "div[data-target='#skidBackModal']", function () {
  2491. $("#skidBackModal").find("ul>li[data-skid-back='" + skidBack + "']").trigger('click');
  2492. });
  2493. //------------------ 支持无网提示 -------------------//
  2494. $(document).on('click', "div[data-target='#noNetModal']", function () {
  2495. $("#noNetModal").find("ul>li[data-no-net='" + noNet + "']").trigger('click');
  2496. });
  2497. //------------------ 支持APk安装器 -------------------//
  2498. $(document).on('click', "div[data-target='#installTipModal']", function () {
  2499. $("#installTipModal").find("ul>li[data-install-tip='" + installTip + "']").trigger('click');
  2500. });
  2501. //------------------ 支持屏幕常亮 -------------------//
  2502. $(document).on('click', "div[data-target='#keepScreenModal']", function () {
  2503. $("#keepScreenModal").find("ul>li[data-keep-screen='" + keepScreen + "']").trigger('click');
  2504. });
  2505. //------------------ 支持网页缩放 -------------------//
  2506. $(document).on('click', "div[data-target='#webZoomModal']", function () {
  2507. $("#webZoomModal").find("ul>li[data-web-zoom='" + supportZoom + "']").trigger('click');
  2508. });
  2509. //------------------ 设置引导页的“立即体验”按钮及其颜色 -------------------//
  2510. $(document).on('click', "div[data-target='#guideModal']", function () {
  2511. $("#guideModal").find(".experience ul>li[data-type='" + supportGuideEnterMainPageButton + "']").trigger('click');
  2512. if (supportGuideEnterMainPageButton == -1) {
  2513. $("#experienceTextColor").spectrum("set", '#ffffff');
  2514. } else {
  2515. $("#experienceTextColor").spectrum("set", guideEnterMainPageButtonColor);
  2516. }
  2517. });
  2518. //------------------ UA设置 -------------------//
  2519. $(document).on('click', "div[data-target='#uaModal']", function () {
  2520. $("#uaModal input[name='appendUa']").val(plugin.userAgent.appendUa);
  2521. $("#uaModal input[name='completeUa']").val(plugin.userAgent.completeUa);
  2522. });
  2523. // 提示滚动条
  2524. $(".plugin-modal .modal-body").scroll(function () {
  2525. var sclollTop = $(this).scrollTop();
  2526. // console.log(sclollTop);
  2527. if (sclollTop > 0) {
  2528. $(this).find(".more-gif").hide();
  2529. } else {
  2530. $(this).find(".more-gif").show();
  2531. }
  2532. });
  2533. // 手势配置
  2534. tab.radioRound({
  2535. el: ".gestures-list1 li",
  2536. checkedClass: "icon-radio-checked"
  2537. });
  2538. });