learun-webApp.js 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657
  1. var app = angular.module('webAppDesign', [])
  2. .run(['$rootScope', '$lrfnRequest', '$lrmDesigner', function ($rootScope, $lrfnRequest, $lrmDesigner) {
  3. $rootScope.windowWidth = $lrfnRequest("windowWidth");
  4. $rootScope.windowHeight = $lrfnRequest("windowHeight") - 41;
  5. var _projectId = $lrfnRequest("projectId");
  6. $rootScope.designer = $lrmDesigner.init(_projectId);
  7. }])
  8. .controller('lrAppCtrl', ['$rootScope', '$scope', '$lrGetIframe', function ($rootScope, $scope, $lrGetIframe) {
  9. $scope.pageTemplates = $rootScope.designer.templates.getPageTemps();
  10. $scope.addPage = $rootScope.designer.addPage;
  11. $scope.btnSaveProject = $rootScope.designer.saveProject;
  12. //$scope.isTabsAdded = true;
  13. //加载完成开始初始化
  14. $rootScope.$on('iframeLoaded', function (event) {
  15. $rootScope.designer.vm.isBeginView = true;
  16. $lrGetIframe('phoneDIndex').doBroadcast('init', $rootScope.designer.currentPage);
  17. $scope.$apply();
  18. });
  19. }])
  20. //用来设置窗口大小
  21. .controller('lrAppMidbarCtrl', ['$scope', '$rootScope', function ($scope, $rootScope) {
  22. var phoneHeight = 765.284, phoneWidth = 387.578;
  23. var iframeH = 568, iframeW = 320, iframeMT = 84.9764;
  24. $scope.phoneScale = '1';
  25. $scope.phoneHeight = phoneHeight + 'px';
  26. $scope.phoneWidth = +phoneWidth + 'px';
  27. $scope.phoneIframeH = iframeH + 'px';
  28. $scope.phoneIframeW = iframeW + 'px';
  29. $scope.phoneIframeMT = iframeMT + 'px';
  30. $scope.marginTop = (($rootScope.windowHeight - phoneHeight - 82) / 2 > 0 ? ($rootScope.windowHeight - phoneHeight - 82) / 2 : 0) + "px";
  31. $scope.changePhoneScale = function () {
  32. var _height = parseFloat($scope.phoneScale) * phoneHeight;
  33. $scope.phoneHeight = _height + 'px';
  34. $scope.phoneWidth = parseFloat($scope.phoneScale) * phoneWidth + 'px';
  35. $scope.marginTop = (($rootScope.windowHeight - _height - 82) / 2 > 0 ? ($rootScope.windowHeight - _height - 82) / 2 : 0) + "px";
  36. $scope.phoneIframeH = parseFloat($scope.phoneScale) * iframeH + 'px';
  37. $scope.phoneIframeW = parseFloat($scope.phoneScale) * iframeW + 'px';
  38. $scope.phoneIframeMT = parseFloat($scope.phoneScale) * iframeMT + 'px';
  39. };
  40. }])
  41. /*扩展标签属性*/
  42. .directive("lrappComponents", ["$rootScope", "$lrmComponents", function ($rootScope, $lrmComponents) {
  43. return {
  44. restrict: "E",
  45. replace: true,
  46. template: '<div ng-repeat="component in $root.componentGroups" class="lr-item-row lr-component" data-value="{{component.id}}"><i class="fa {{component.icon}}"></i>{{component.text}}</div>',
  47. link: function (scope, element, attr) {
  48. $rootScope.componentGroups = $lrmComponents.all();
  49. }
  50. }
  51. }])
  52. .directive("lrappPagetree", ["$rootScope", function ($rootScope) {
  53. return {
  54. restrict: "E",
  55. require: '?ngModel',
  56. replace: true,
  57. template: '<div></div>',
  58. link: function (scope, element, attr, ngModel) {
  59. if (!ngModel)
  60. {
  61. return;
  62. }
  63. ngModel.$render = function () {
  64. ngModel.$viewValue(element);
  65. }
  66. }
  67. }
  68. }])
  69. .directive('lrappBox', function () {
  70. return {
  71. restrict: 'E',
  72. replace: true,
  73. transclude: true,
  74. template:
  75. '<div class="lr-box expanded">' +
  76. '<h4 class="lr-box-toggle"></h4>' +
  77. '<div class="lr-box-content" ng-transclude></div>' +
  78. '</div>',
  79. link: function (scope, element, attr) {
  80. var toggle = element.find('.lr-box-toggle');
  81. element.find('h4').html('<span class="caret"></span>' + attr.name);
  82. toggle.on('click', function () {
  83. if (element.is('.expanded')) {
  84. element.removeClass('expanded');
  85. }
  86. else {
  87. element.addClass('expanded');
  88. }
  89. });
  90. }
  91. };
  92. })
  93. .directive("lrappToggleb", ["$rootScope", function (e) {
  94. return {
  95. restrict: "E",
  96. require: '?ngModel',
  97. template: '<span class="left-text"></span><div class="track"><div class="handle"></div></div><span class="right-text" ></span>',
  98. link: function (scope, element, attr, ngModel) {
  99. ngModel.$render = function () {
  100. if (ngModel.$viewValue) {
  101. element.addClass("active");
  102. }
  103. };
  104. element.on("click", function () {
  105. scope.$apply(cgValue);
  106. });
  107. function cgValue() {
  108. element.addClass("animate");
  109. var flag = element.is(".active");
  110. if (flag) {
  111. element.removeClass("active");
  112. }
  113. else {
  114. element.addClass("active");
  115. }
  116. ngModel.$setViewValue(!flag);
  117. }
  118. }
  119. }
  120. }])
  121. .directive('lrappColorPicker', function () {
  122. return {
  123. restrict: "E",
  124. replace: true,
  125. template: '<div class="input-append color" data-form="colorpicker" data-color="#ffffff" data-color-format="hex">' +
  126. '<span class="add-on"><i style="background-color: #ffffff"></i></span>' +
  127. '<input type="text" value="#ffffff" />' +
  128. '</div>',
  129. link: function (scope, element, attr) {
  130. if (attr.value) {
  131. attr.color = attr.value;
  132. element.find('i').css('background-color', attr.value);
  133. element.find('input').val(attr.value);
  134. }
  135. element.colorpicker();
  136. }
  137. }
  138. })
  139. /*数据模型*/
  140. .factory('$lrmComponents', ['$rootScope', function ($rootScope) {//组件类型
  141. var _doRemove = function (data) {
  142. var components = $rootScope.designer.currentPage.ChildNodes;
  143. components.splice(components.indexOf(data), 1);
  144. $rootScope.designer.templates.fnPageTree.refresh();
  145. $rootScope.designer.currentPage = $rootScope.designer.templates.getHasTemps()[0];
  146. $rootScope.designer.currentFocus = $rootScope.designer.templates.getHasTemps()[0];
  147. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgSelectTemplatePage, { "cmd": "removeComponent", object: $rootScope.designer.templates.getHasTemps()[0] });
  148. $.webappDesigner.attributes($rootScope.designer);
  149. }
  150. var components = [
  151. {
  152. id: "lrHeader",
  153. text: "标题",
  154. icon: "fa-header",
  155. setValue: function (name, value, data) {
  156. switch (name) {
  157. case "text":
  158. if (data.text != value) {
  159. data.text = value;
  160. data.attr.text = value;
  161. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "componentAttr", "attrName": 'text', "object": data });
  162. $rootScope.designer.templates.fnPageTree.refreshNode(data.id, data.text);
  163. }
  164. break;
  165. case "size":
  166. if (data.attr.size != value) {
  167. data.attr.size = value;
  168. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "componentAttr", "attrName": 'size', "object": data });
  169. }
  170. break;
  171. case "weightSize":
  172. if (data.attr.weight.size != value) {
  173. data.attr.weight.size = value;
  174. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "componentAttr", "attrName": 'weightSize', "object": data });
  175. }
  176. case "italic":
  177. if (data.attr.weight.isItalic != value) {
  178. data.attr.weight.isItalic = value;
  179. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "componentAttr", "attrName": 'isItalic', "object": data });
  180. }
  181. break;
  182. case "color":
  183. if (data.attr.color != value) {
  184. data.attr.color = value;
  185. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "componentAttr", "attrName": 'color', "object": data });
  186. }
  187. break;
  188. case "align":
  189. if (data.attr.align != value) {
  190. data.attr.align = value;
  191. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "componentAttr", "attrName": 'align', "object": data });
  192. }
  193. break;
  194. }
  195. },
  196. },
  197. {
  198. id: "lrParagraph",
  199. text: "段落",
  200. icon: "fa fa-align-left",
  201. setValue: function (name, value, data) {
  202. if (data.attr[name] != value) {
  203. data.attr[name] = value;
  204. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "componentAttr", "attrName": name, "object": data });
  205. }
  206. }
  207. },
  208. //{ id: "lrBtnBar", text: "按钮组", icon: "fa fa-th-large" },
  209. {
  210. id: "lrBtn",
  211. text: "按钮",
  212. icon: "fa fa-square",
  213. setValue: function (name, value, data) {
  214. switch (name) {
  215. case "link":
  216. if (data.attr.link != value)
  217. {
  218. data.attr.link = value;
  219. }
  220. break;
  221. case "text":
  222. if (data.attr.text != value) {
  223. data.attr.text = value;
  224. data.text = value;
  225. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "componentAttr", "attrName": 'text', "object": data });
  226. $rootScope.designer.templates.fnPageTree.refreshNode(data.id, data.text);
  227. }
  228. break;
  229. case "weightSize":
  230. case "italic":
  231. if (data.attr.weight[name] != value) {
  232. data.attr.weight[name] = value;
  233. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "componentAttr", "attrName": name, "object": data });
  234. }
  235. break;
  236. case "size":
  237. case "color":
  238. case "align":
  239. case "btnType":
  240. case "btnTheme":
  241. case "btnSize":
  242. if (data.attr[name] != value) {
  243. data.attr[name] = value;
  244. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "componentAttr", "attrName": name, "object": data });
  245. }
  246. break;
  247. }
  248. },
  249. },
  250. {
  251. id: "lrInput",
  252. text: "文本框",
  253. icon: "fa fa-italic",
  254. setValue: function (name, value, data) {
  255. if (data.attr[name] != value) {
  256. data.attr[name] = value;
  257. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "componentAttr", "attrName": name, "object": data });
  258. }
  259. }
  260. },
  261. {
  262. id: "lrList3",
  263. text: "列表类型一",
  264. icon: "fa fa-th-list",
  265. setValue: function (name, value, data) {
  266. if (data.attr[name] != value) {
  267. data.attr[name] = value;
  268. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "componentAttr", "attrName": name, "object": data });
  269. }
  270. }
  271. },
  272. {
  273. id: "lrList4",
  274. text: "列表类型二",
  275. icon: "fa fa-list-ul",
  276. setValue: function (name, value, data) {
  277. if (data.attr[name] != value) {
  278. data.attr[name] = value;
  279. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "componentAttr", "attrName": name, "object": data });
  280. }
  281. }
  282. }
  283. //{ id: "lrTextarea", text: "文本区", icon: "fa fa-align-justify" }
  284. ];
  285. return {
  286. all: function () {
  287. return components;
  288. },
  289. getOne:function(id){
  290. for(var i in components)
  291. {
  292. if (components[i].id == id)
  293. {
  294. return components[i];
  295. }
  296. }
  297. },
  298. doRemove: _doRemove
  299. };
  300. }])
  301. .factory('$lrmTemplates', ['$rootScope', '$lrfnGuid', '$lrdialogTop', function ($rootScope, $lrfnGuid, $lrdialogTop) {//模板类型(树形菜单)
  302. /*设置空白页的属性的方法*/
  303. var setBlankPageValue = function (name, value, data) {
  304. switch (name) {
  305. case "text":
  306. if (data.text != value) {
  307. data.text = value;
  308. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "pageText", "value": value });
  309. refreshTreeNode(data.id, data.text);
  310. }
  311. break;
  312. case "routing":
  313. if (data.attr.routing != value)
  314. {
  315. data.attr.routing = value;
  316. }
  317. break;
  318. case "bgColor":
  319. if (data.attr.bgColor != value)
  320. {
  321. data.attr.bgColor = value;
  322. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "pageBgColor", "value": value });
  323. }
  324. break;
  325. case "isTabed":
  326. if (data.attr.isTabed != value) {
  327. data.attr.isTabed = value;
  328. }
  329. break;
  330. case "isPadding":
  331. if (data.attr.isPadding != value) {
  332. data.attr.isPadding = value;
  333. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "pageIsPadding", "value": value });
  334. }
  335. break;
  336. case "isHeadHide":
  337. if (data.attr.isHeadHide != value) {
  338. data.attr.isHeadHide = value;
  339. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "pageIsHeadHide", "value": value });
  340. }
  341. break;
  342. }
  343. };
  344. var pageTemplates = [{//页面模板
  345. value: "lrPageBlank",
  346. text: "页面",
  347. png: "../../Content/webApp/img/template-blank.png",
  348. img: "fa fa-file-o",
  349. hasChildren: false,
  350. isexpand: false,
  351. parentnodes: "0",
  352. attr: {
  353. value: 'lrPageBlank',
  354. type: 'page',
  355. routing: '/',
  356. bgColor: '#ffffff',
  357. isTabed: 'true',
  358. isPadding: 'true',
  359. isHeadHide: 'false',
  360. isFirst:false
  361. },
  362. setValue: setBlankPageValue,
  363. doButton: function (data) {
  364. if (hasTemplates.length > 1) {
  365. hasTemplates.splice(hasTemplates.indexOf(data), 1);
  366. refreshTree();
  367. $rootScope.designer.currentPage = hasTemplates[0];
  368. $rootScope.designer.currentFocus = hasTemplates[0];
  369. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgSelectTemplatePage, { "cmd": "removePage", object: hasTemplates[0] });
  370. $.webappDesigner.attributes($rootScope.designer);
  371. }
  372. else {
  373. $lrdialogTop('必须保留一个页面', 'error');
  374. }
  375. },
  376. type:"page"
  377. }];
  378. var hasTemplates = [];
  379. /*刷新模板树*/
  380. function refreshTree(id) {
  381. var _id = "";
  382. if ($rootScope.pageTree != undefined) {
  383. $rootScope.pageTree.treeview({
  384. data: hasTemplates,
  385. isTool: true,
  386. nodeTools: [{ text: '删除', img: 'fa fa-trash-o' },
  387. { text: '复制', img: 'fa fa-clone' },
  388. {
  389. text: '标记默认页',
  390. img: 'fa fa-thumb-tack',
  391. node:"page",
  392. callback: function (id) {
  393. for (var i in hasTemplates)
  394. {
  395. hasTemplates[i].attr.isFirst = false;
  396. if (hasTemplates[i].id == id)
  397. {
  398. hasTemplates[i].attr.isFirst = true;
  399. $rootScope.pageTree.refreshNodeIcon(id, "fa fa-yahoo", ".fa-yahoo");
  400. }
  401. }
  402. }
  403. }],
  404. onnodeclick: function (item) {
  405. treeNotChecked();
  406. var _currentPage = $rootScope.designer.currentPage;
  407. var _currentFocus = $rootScope.designer.currentFocus;
  408. if (_currentFocus.id != item.id) {
  409. $rootScope.designer.currentFocus = item;
  410. if (item.parentnodes == "0")//说明是页面
  411. {
  412. $rootScope.designer.currentPage = item;
  413. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgSelectTemplatePage, { "cmd": "selectPage", "object": item });
  414. }
  415. else {
  416. if (item.parentnodes != _currentPage.id) {
  417. for (var i in hasTemplates) {
  418. var _page = hasTemplates[i];
  419. if (_page.id == item.parentnodes) {
  420. $rootScope.designer.currentPage = _page;
  421. break;
  422. }
  423. }
  424. }
  425. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgSelectTemplatePage, { "cmd": "selectComponent", "object": item, "currentPage": $rootScope.designer.currentPage });
  426. }
  427. $.webappDesigner.attributes($rootScope.designer);
  428. }
  429. }
  430. });
  431. if (id == undefined) {
  432. _id = hasTemplates[0].id
  433. }
  434. else {
  435. _id = id;
  436. }
  437. $rootScope.pageTree.setNodeChecked(_id);
  438. treeNotChecked();
  439. for (var i in hasTemplates) {
  440. if (hasTemplates[i].attr.isFirst == true) {
  441. $rootScope.pageTree.refreshNodeIcon(hasTemplates[i].id, "fa fa-yahoo", ".fa-yahoo");
  442. break;
  443. }
  444. }
  445. }
  446. }
  447. function refreshTreeNode(nodeId,text)
  448. {
  449. $rootScope.pageTree.refreshNode(nodeId, text);
  450. }
  451. /*设置tabs的属性的方法*/
  452. var setTabsValue = function (name, value, data) {
  453. switch (name) {
  454. case "bgColor":
  455. if (data.attr.bgColor != value) {
  456. data.attr.bgColor = value;
  457. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "tabsBgColor", "value": value });
  458. }
  459. break;
  460. case "iconColor":
  461. if (data.attr.iconColor != value) {
  462. data.attr.iconColor = value;
  463. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "tabsIconColor", "value": value });
  464. }
  465. case "iconType":
  466. if (data.attr.iconType != value) {
  467. data.attr.iconType = value;
  468. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "tabsIconType", "value": value });
  469. }
  470. break;
  471. }
  472. };
  473. /*设置tab属性*/
  474. var setTabValue = function (name, value, data) {
  475. switch (name)
  476. {
  477. case "text":
  478. if (data.attr.text != value)
  479. {
  480. data.attr.text = value;
  481. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "tabText", "value": value });
  482. $rootScope.tabsTree.refreshNode(data.id, value);
  483. }
  484. break;
  485. case "iconOn":
  486. if (data.attr.iconOn != value) {
  487. data.attr.iconOn = value;
  488. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "tabIconOn", "value": value });
  489. }
  490. break;
  491. case "iconOff":
  492. if (data.attr.iconOff != value) {
  493. data.attr.iconOff = value;
  494. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgAttr, { "cmd": "tabIconOff", "value": value });
  495. }
  496. break;
  497. case "innerTabPage":
  498. if (data.attr.lrInnerTabPage != value) {
  499. data.attr.lrInnerTabPage = value;
  500. }
  501. break;
  502. }
  503. }
  504. /*删除tab*/
  505. var removeTab = function (data)
  506. {
  507. if (hasTabsTemplates[0].ChildNodes.length > 1) {
  508. hasTabsTemplates[0].ChildNodes.splice(hasTabsTemplates[0].ChildNodes.indexOf(data), 1);
  509. refreshTabsTree();
  510. focusTabsNode(hasTabsTemplates[0].ChildNodes[0].id);
  511. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.doTabTemplate, { "cmd": "removeTab", id: hasTabsTemplates[0].ChildNodes[0].id });
  512. }
  513. else {
  514. $lrdialogTop('Tab不能全部删除', 'error');
  515. }
  516. }
  517. /*tabs树*/
  518. var tabTemplate = {
  519. text: "Tab页",
  520. img: "fa fa-cube",
  521. hasChildren: false,
  522. isexpand: false,
  523. parentnodes: "lrTabs",
  524. attr: {
  525. value: "lrTab",
  526. iconOn: "ion-ios-home",
  527. iconOff: "ion-ios-home-outline",
  528. innerTabPage: "DefaultPage",
  529. },
  530. setValue: setTabValue,
  531. doButton: removeTab
  532. };
  533. var hasTabsTemplates = [
  534. {
  535. id:"lrTabs",//页面模板
  536. value: "lrTabs",
  537. text: "Tabs控制器",
  538. img: "fa fa-sitemap",
  539. hasChildren: true,
  540. isexpand: true,
  541. parentnodes: "0",
  542. attr: {
  543. type: 'tabs',
  544. value: 'lrTabs',
  545. bgColor: 'stable',
  546. iconColor: "dark",
  547. iconType:"top"
  548. },
  549. setValue: setTabsValue,
  550. doButton: function () {
  551. var _dst = angular.copy(tabTemplate);
  552. _dst.id = $lrfnGuid();
  553. hasTabsTemplates[0].ChildNodes.push(_dst);
  554. refreshTabsTree();
  555. focusTabsNode(_dst.id);
  556. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.doTabTemplate, { "cmd": "addTab", id: _dst.id });
  557. }
  558. }];
  559. function refreshTabsTree()
  560. {
  561. if ($rootScope.tabsTree != undefined) {
  562. $rootScope.tabsTree.treeview({
  563. data: hasTabsTemplates,
  564. onnodeclick: function (item) {
  565. pTreeNotChecked();
  566. var _currentPage = $rootScope.designer.currentPage;
  567. var _currentFocus = $rootScope.designer.currentFocus;
  568. if (_currentFocus.id != item.id)
  569. {
  570. if (_currentPage.id != "lrTabs") {
  571. $rootScope.designer.currentPage = hasTabsTemplates[0];
  572. }
  573. $rootScope.designer.currentFocus = item;
  574. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.cgSelectTemplatePage, { "cmd": "lrTabs", "data": hasTabsTemplates[0].ChildNodes, "focus": item });
  575. $.webappDesigner.attributes($rootScope.designer);
  576. }
  577. }
  578. });
  579. }
  580. }
  581. function focusTabsNode(id)
  582. {
  583. for (var i in hasTabsTemplates[0].ChildNodes) {
  584. var item = hasTabsTemplates[0].ChildNodes[i];
  585. if (item.id == id) {
  586. $rootScope.designer.currentFocus = item;
  587. $.webappDesigner.attributes($rootScope.designer);
  588. break;
  589. }
  590. }
  591. pTreeNotChecked();
  592. $rootScope.tabsTree.setNodeChecked(id);
  593. }
  594. /*取消选中*/
  595. function pTreeNotChecked() {
  596. if ($rootScope.pageTree != undefined) {
  597. $rootScope.pageTree.setNodeChecked("");
  598. }
  599. }
  600. function treeNotChecked()
  601. {
  602. if ($rootScope.tabsTree != undefined)
  603. {
  604. $rootScope.tabsTree.setNodeChecked("");
  605. }
  606. }
  607. return {
  608. init: function (data) {
  609. hasTemplates = data;
  610. },
  611. getPageTemps: function () {
  612. return pageTemplates;
  613. },
  614. getHasTemps: function () {
  615. return hasTemplates;
  616. },
  617. getHasTabsTemps: function () {
  618. return hasTabsTemplates;
  619. },
  620. getComponent: function (id, pageId) {
  621. for (var i in hasTemplates) {
  622. var item = hasTemplates[i];
  623. if (item.hasChildren && pageId == item.id) {
  624. for (var j in item.ChildNodes) {
  625. var _childone = item.ChildNodes[j];
  626. if (_childone.id == id) {
  627. return _childone;
  628. }
  629. }
  630. }
  631. }
  632. return null;
  633. },
  634. addPage: function (data) {
  635. var _id = ""; var _dst = {};
  636. if (data == undefined) {
  637. _dst = angular.copy(pageTemplates[0]);
  638. _dst.id = $lrfnGuid();
  639. _id = _dst.id;
  640. hasTemplates.push(_dst);
  641. }
  642. else {
  643. _dst = data;
  644. _id = data.id;
  645. hasTemplates.push(data);
  646. }
  647. refreshTree(_id);
  648. return _dst;
  649. },
  650. addComponent: function (obj) {
  651. for (var i in hasTemplates) {
  652. var item = hasTemplates[i];
  653. if (item.id == obj.parentnodes) {
  654. hasTemplates[i].hasChildren = true;
  655. hasTemplates[i].isexpand = true;
  656. if (hasTemplates[i].ChildNodes == undefined) {
  657. hasTemplates[i].ChildNodes = [];
  658. }
  659. hasTemplates[i].ChildNodes.push(obj);
  660. }
  661. }
  662. },
  663. initTabs: function (data) {
  664. var _data = [
  665. {
  666. id: "lrtab0001",
  667. text: "首页",
  668. img: "fa fa-cube",
  669. hasChildren: false,
  670. isexpand: false,
  671. parentnodes: "lrTabs",
  672. attr: {
  673. value: "lrTab",
  674. iconOn: "ion-ios-home",
  675. iconOff: "ion-ios-home-outline",
  676. innerTabPage: "DefaultPage",
  677. },
  678. setValue: setTabValue,
  679. doButton: removeTab
  680. },
  681. {
  682. id: "lrtab0002",
  683. text: "实例",
  684. img: "fa fa-cube",
  685. hasChildren: false,
  686. isexpand: false,
  687. parentnodes: "lrTabs",
  688. attr: {
  689. value: "lrTab",
  690. iconOn: "ion-ios-book",
  691. iconOff: "ion-ios-book-outline",
  692. innerTabPage: "DefaultPage",
  693. },
  694. setValue: setTabValue,
  695. doButton: removeTab
  696. },
  697. {
  698. id: "lrtab0003",
  699. text: "通知",
  700. img: "fa fa-cube",
  701. hasChildren: false,
  702. isexpand: false,
  703. parentnodes: "lrTabs",
  704. attr: {
  705. value: "lrTab",
  706. iconOn: "ion-ios-bell",
  707. iconOff: "ion-ios-bell-outline",
  708. innerTabPage: "DefaultPage",
  709. },
  710. setValue: setTabValue,
  711. doButton: removeTab
  712. },
  713. {
  714. id: "lrtab0004",
  715. text: "我的",
  716. img: "fa fa-cube",
  717. hasChildren: false,
  718. isexpand: false,
  719. parentnodes: "lrTabs",
  720. attr: {
  721. value: "lrTab",
  722. iconOn: "ion-ios-person",
  723. iconOff: "ion-ios-person-outline",
  724. innerTabPage: "DefaultPage",
  725. },
  726. setValue: setTabValue,
  727. doButton: removeTab
  728. }
  729. ];
  730. if (data == undefined)
  731. {
  732. data = _data;
  733. }
  734. hasTabsTemplates[0].ChildNodes = data;
  735. },
  736. fnPageTree: {
  737. init: function (obj) {
  738. $rootScope.pageTree = obj;
  739. refreshTree();
  740. },
  741. refresh: refreshTree,
  742. focusNode: function (id) {
  743. treeNotChecked();
  744. $rootScope.pageTree.setNodeChecked(id);
  745. },
  746. refreshNode: refreshTreeNode
  747. },
  748. fnTabsTree: {
  749. init: function (obj) {
  750. $rootScope.tabsTree = obj;
  751. refreshTabsTree();
  752. },
  753. refresh: refreshTabsTree,
  754. focusNode: focusTabsNode
  755. }
  756. };
  757. }])
  758. .factory('$lrmDesigner', ['$rootScope', '$lrmComponents', '$lrmTemplates', '$http', '$lrdialogTop', '$lrGetIframe', '$lrfnGuid', function ($rootScope, $lrmComponents, $lrmTemplates, $http, $lrdialogTop, $lrGetIframe, $lrfnGuid) {
  759. var designer = {
  760. projectId: "",
  761. projectName: "",
  762. projectIcon: "icon-webApp.png",
  763. currentPage: {},
  764. currentFocus: {},
  765. isTabsAdded:false,
  766. templates: $lrmTemplates,
  767. components:$lrmComponents,
  768. api: {
  769. saveProjectUrl: "../../AppManage/AppProjects/SaveForm",
  770. getProjectUrl: "../../AppManage/AppProjects/GetFormJson"
  771. },
  772. doPhoneBroadcast: function (cmd, data) {
  773. $lrGetIframe('phoneDIndex').doBroadcast(cmd, data);
  774. },
  775. vm: {
  776. isBeginView: false
  777. },
  778. addPage: function (pageTemplate) {
  779. var _dst = angular.copy(pageTemplate);
  780. _dst.id = $lrfnGuid();
  781. designer.currentPage = _dst;
  782. designer.currentFocus = _dst;
  783. designer.templates.addPage(_dst);
  784. designer.doPhoneBroadcast(appBroadcastCode.cgSelectTemplatePage, { "cmd": "addPage", "object": _dst });
  785. $.webappDesigner.attributes(designer);
  786. },
  787. saveProject: function () {
  788. var _projectEntity = {
  789. "Name": designer.projectName,
  790. "Icon": designer.projectIcon,
  791. };
  792. if (_projectEntity.Name == "") {
  793. $lrdialogTop('请输入项目名称', 'error');
  794. return false;
  795. }
  796. $http.post(designer.api.saveProjectUrl + "?keyValue=" + designer.projectId, _projectEntity)
  797. .success(function (data) {
  798. $lrdialogTop('保存成功', 'success');
  799. })
  800. .error(function () {
  801. $lrdialogTop('保存失败', 'error');
  802. });
  803. }
  804. };
  805. function onBroadcast() {
  806. $rootScope.$on(appBroadcastCode.addComponent, function (event, data) {//添加组件
  807. try {
  808. var treeOne = {
  809. text: data.text,
  810. img: data.img,
  811. parentnodes: designer.currentPage.id,
  812. id: data.id,
  813. attr: data,
  814. setValue: designer.components.getOne(data.value).setValue,
  815. doButton: designer.components.doRemove
  816. };
  817. designer.templates.addComponent(treeOne);
  818. designer.templates.fnPageTree.refresh(treeOne.id);
  819. designer.currentFocus = treeOne;
  820. $.webappDesigner.attributes(designer);
  821. }
  822. catch (e)
  823. {
  824. console.log(e.message);
  825. }
  826. });
  827. $rootScope.$on(appBroadcastCode.doTabTemplatePhone, function (event, data) {//对tab的操作
  828. switch (data.cmd)
  829. {
  830. case "selectTab":
  831. designer.templates.fnTabsTree.focusNode(data.id);
  832. break;
  833. case "duplicate":
  834. var _dst = angular.copy(data.object);
  835. _dst.id = $lrfnGuid();
  836. designer.templates.getHasTabsTemps()[0].ChildNodes.push(_dst);
  837. designer.templates.fnTabsTree.refresh();
  838. designer.templates.fnTabsTree.focusNode(_dst.id);
  839. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.doTabTemplate, { "cmd": "addTab", id: _dst.id });
  840. break;
  841. case "remove":
  842. var _lists = designer.templates.getHasTabsTemps()[0].ChildNodes;
  843. if (_lists.length > 1) {
  844. _lists.splice(_lists.indexOf(data.object), 1);
  845. designer.templates.fnTabsTree.refresh();
  846. designer.templates.fnTabsTree.focusNode(_lists[0].id);
  847. $rootScope.designer.doPhoneBroadcast(appBroadcastCode.doTabTemplate, { "cmd": "removeTab", id: _lists[0].id });
  848. }
  849. else {
  850. $lrdialogTop('Tab不能全部删除', 'error');
  851. }
  852. break;
  853. }
  854. });
  855. $rootScope.$on(appBroadcastCode.doComponentPhone, function (event, data) {//对tab的操作
  856. designer.templates.fnPageTree.focusNode(data.id);
  857. designer.currentFocus = designer.templates.getComponent(data.id, designer.currentPage.id);
  858. $.webappDesigner.attributes(designer);
  859. });
  860. }
  861. return {
  862. init: function (projectId) {
  863. designer.projectId = projectId;
  864. if (designer.projectId == "") {
  865. var tempData = designer.templates.addPage();
  866. designer.templates.initTabs();
  867. designer.currentPage = tempData;
  868. designer.currentFocus = tempData;
  869. $.webappDesigner.attributes(designer);
  870. }
  871. else {
  872. $http.get(designer.api.getProjectUrl + "?keyValue=" + designer.projectId)
  873. .success(function (data) {
  874. designer.projectName = data.Name;
  875. designer.projectIcon = data.Icon;
  876. })
  877. .error(function () {
  878. designer.projectId = "";
  879. $lrdialogTop('获取数据失败', 'error');
  880. });
  881. }
  882. onBroadcast();
  883. return designer;
  884. }
  885. };
  886. }])
  887. /*方法*/
  888. .factory('$lrfnRequest', function () {//获取传递参数
  889. return function (keyValue) {
  890. var search = location.search.slice(1);
  891. var arr = search.split("&");
  892. for (var i = 0; i < arr.length; i++) {
  893. var ar = arr[i].split("=");
  894. if (ar[0] == keyValue) {
  895. if (unescape(ar[1]) == 'undefined') {
  896. return "";
  897. } else {
  898. return unescape(ar[1]);
  899. }
  900. }
  901. }
  902. return "";
  903. }
  904. })
  905. .factory('$lrfnGuid', function () {
  906. return function () {
  907. var guid = "";
  908. for (var i = 1; i <= 32; i++) {
  909. var n = Math.floor(Math.random() * 16.0).toString(16);
  910. guid += n;
  911. if ((i == 8) || (i == 12) || (i == 16) || (i == 20)) guid += "-";
  912. }
  913. return guid;
  914. };
  915. })
  916. .factory('$lrdialogTop', function () {
  917. return function (content, type) {
  918. $(".tip_container").remove();
  919. var bid = parseInt(Math.random() * 100000);
  920. $("body").prepend('<div id="tip_container' + bid + '" class="container tip_container"><div id="tip' + bid + '" class="mtip"><i class="micon"></i><span id="tsc' + bid + '"></span><i id="mclose' + bid + '" class="mclose"></i></div></div>');
  921. var $this = $(this);
  922. var $tip_container = $("#tip_container" + bid);
  923. var $tip = $("#tip" + bid);
  924. var $tipSpan = $("#tsc" + bid);
  925. //先清楚定时器
  926. clearTimeout(window.timer);
  927. //主体元素绑定事件
  928. $tip.attr("class", type).addClass("mtip");
  929. $tipSpan.html(content);
  930. $tip_container.slideDown(300);
  931. //提示层隐藏定时器
  932. window.timer = setTimeout(function () {
  933. $tip_container.slideUp(300);
  934. $(".tip_container").remove();
  935. }, 4000);
  936. $("#tip_container" + bid).css("left", ($(window).width() - $("#tip_container" + bid).width()) / 2);
  937. }
  938. })
  939. .factory('$lrGetIframe', function () {
  940. function isbrowsername() {
  941. var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  942. var isOpera = userAgent.indexOf("Opera") > -1;
  943. if (isOpera) {
  944. return "Opera"
  945. }; //判断是否Opera浏览器
  946. if (userAgent.indexOf("Firefox") > -1) {
  947. return "FF";
  948. } //判断是否Firefox浏览器
  949. if (userAgent.indexOf("Chrome") > -1) {
  950. if (window.navigator.webkitPersistentStorage.toString().indexOf('DeprecatedStorageQuota') > -1) {
  951. return "Chrome";
  952. } else {
  953. return "360";
  954. }
  955. }//判断是否Chrome浏览器//360浏览器
  956. if (userAgent.indexOf("Safari") > -1) {
  957. return "Safari";
  958. } //判断是否Safari浏览器
  959. if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
  960. return "IE";
  961. }; //判断是否IE浏览器
  962. }
  963. return function (id) {
  964. if (isbrowsername() == "Chrome" || isbrowsername() == "FF") {
  965. return frames[id].contentWindow;
  966. }
  967. else {
  968. return frames[id];
  969. }
  970. }
  971. });
  972. /*Dom操作和给外部调用的方法*/
  973. (function ($) {
  974. function lrAppBox(name, strhtml) {
  975. var html = '<div class="lr-box expanded">';
  976. html += '<h4 class="lr-box-toggle" onClick="lrappbox(this)"><span class="caret"></span>' + name + '</h4>';
  977. html += '<div class="lr-box-content">' + strhtml + '</div>';
  978. html += '</div>';
  979. return html;
  980. }
  981. function lrAppColorPicker(color, width, name) {
  982. var html = '<div class="input-append color" data-form="colorpicker" data-color="' + color + '" style="width:' + width + 'px;" data-color-format="hex">' +
  983. '<span class="add-on"><i style="background-color: ' + color + '"></i></span>' +
  984. '<input type="text" data-name="'+name+'" value="' + color + '" />' +
  985. '</div>';
  986. return html;
  987. }
  988. function buttonGroup(name,data,value, style) {
  989. var html = '<div class="btn-group" style="' + style + '">';
  990. for (var i in data) {
  991. var _item = data[i];
  992. var _icon = _item.icon == undefined ? '<span style="font-size:18px; line-height: 19px;">' + _item.text + '</span>' : '<span class="' + _item.icon + '"></span>';
  993. var _actived = "";
  994. if (_item.value == value)
  995. {
  996. _actived = "actived";
  997. }
  998. html += '<a type="button" class="btn btn-default ' + _actived + ' b' + data.length + ' " onClick="lrappBtnGroup(this)"><input type="text" data-name="' + name + '" style="display:none;" value="' + _item.value + '" >' + _icon + '</a>';
  999. }
  1000. html += '</div>';
  1001. return html;
  1002. }
  1003. function lrAppToggle(name,value) {
  1004. var _active = '';
  1005. if (value == 'true' )
  1006. {
  1007. _active = 'active';
  1008. }
  1009. var _html = '<lrapp-toggle class="' + _active + '" onClick="lrappToggle(this)"><input type="text" data-name="' + name + '" style="display:none;" value="' + value + '" > <span class="left-text " ></span><div class="track"><div class="handle"></div></div><span class="right-text" ></span></lrapp-toggle>';
  1010. return _html;
  1011. }
  1012. function lrCombox(name, value, data, width) {
  1013. var _option = '';
  1014. for (var i in data)
  1015. {
  1016. var item = data[i];
  1017. _option += '<li data-value="' + item.value + '" data-icon = "' + item.icon + '" >' + item.text + '</li>';
  1018. }
  1019. var _html = '<div id="' + name + '" type="select" class="ui-select" data-name="' + name + '" data-value="' + value + '" style="width:' + width + 'px;display: inline-block;" >' + _option + '</div>';
  1020. return _html;
  1021. };
  1022. var _tempsAttr = {//模板属性设置
  1023. lrTabs: function (data) {
  1024. var _html = "";
  1025. var _boxHtml = "";
  1026. var _color = [
  1027. { text: "Light", value: "light", icon: "<span class='color-square light-bg light-border space-right'></span>" },
  1028. { text: "Stable", value: "stable", icon: "<span class='color-square stable-bg stable-border space-right'></span>" },
  1029. { text: "Dark", value: "dark", icon: "<span class='color-square dark-bg dark-border space-right'></span>" },
  1030. { text: "Positive", value: "positive", icon: "<span class='color-square positive-bg positive-border space-right'></span>" },
  1031. { text: "Balanced", value: "balanced", icon: "<span class='color-square balanced-bg balanced-border space-right'></span>" },
  1032. { text: "Assertive", value: "assertive", icon: "<span class='color-square assertive-bg assertive-border space-right'></span>" },
  1033. { text: "Calm", value: "calm", icon: "<span class='color-square calm-bg calm-border space-right'></span>" },
  1034. { text: "Energized", value: "energized", icon: "<span class='color-square energized-bg energized-border space-right'></span>" },
  1035. { text: "Royal", value: "royal", icon: "<span class='color-square royal-bg royal-border space-right'></span>" }
  1036. ];
  1037. var _types = [
  1038. { text: "顶部图标", value: "top", icon: "" },
  1039. { text: "只有图标", value: "only", icon: "" },
  1040. { text: "左侧图标", value: "left", icon: "" },
  1041. ];
  1042. _html += '<div class="lr-app-right-header"><span class="lr-app-title">' + data.text + '</span></div>';
  1043. _boxHtml += '<div class="form-group"><label class="control-label">背景色</label>' + lrCombox("bgColor", data.attr.bgColor, _color, 205) + '</div>';
  1044. _boxHtml += '<div class="form-group"><label class="control-label">图标色</label>' + lrCombox("iconColor", data.attr.iconColor, _color, 205) + '</div>';
  1045. _boxHtml += '<div class="form-group"><label class="control-label">类型</label>' + lrCombox("iconType", data.attr.iconType, _types, 205) + '</div>';
  1046. _html += lrAppBox('样式', _boxHtml);
  1047. _html += '<div style="margin:10px;"><button type="button" class="btn btn-danger btn-block">增加新的Tab</button></div>';
  1048. return _html;
  1049. },
  1050. lrTab: function (data,designer) {
  1051. var _html = "";
  1052. var _boxHtml = "";
  1053. var _pages = designer.templates.getHasTemps();
  1054. var _innerPages = [];
  1055. for (var i in _pages)
  1056. {
  1057. var _item = _pages[i];
  1058. var _point = { text: _item.text, value: _item.id, icon: "" };
  1059. _innerPages.push(_point);
  1060. }
  1061. _html += '<div class="lr-app-right-header"><span class="lr-app-typePage"><a>Tabs控制器</a><span class="lr-app-slash">/</span></span>' + data.text + '</div>';
  1062. _boxHtml += '<div class="form-group"><label class="control-label">标题</label><input type="text" class="form-control" data-name="text" value="' + data.text + '" ></div>';
  1063. _boxHtml += '<div class="form-group"><label class="control-label">未选中图标</label>' + lrCombox("iconOff", data.attr.iconOff, webAppData.iconList, 205) + '</div>';
  1064. _boxHtml += '<div class="form-group"><label class="control-label">选中图标</label>' + lrCombox("iconOn", data.attr.iconOn, webAppData.iconList, 205) + '</div>';
  1065. _boxHtml += '<div class="form-group"><label class="control-label">内嵌页面</label>' + lrCombox("innerTabPage", data.attr.innerTabPage, _innerPages, 205) + '</div>';
  1066. _html += lrAppBox('设置', _boxHtml);
  1067. _html += '<div style="margin:10px;"><button type="button" class="btn btn-danger btn-block">删除</button></div>';
  1068. return _html;
  1069. },
  1070. lrPageBlank: function (data) {
  1071. var _html = "";
  1072. var _boxHtml = "";
  1073. _html += '<div class="lr-app-right-header"><span class="lr-app-title">' + data.text + '</span></div>';
  1074. _html += '<div class="lr-box" style="padding-top:10px;">';
  1075. _html += '<div class="form-group"><label class="control-label">标题</label><input type="text" class="form-control W" data-name="text" value="' + data.text + '" ></div>';
  1076. _html += '<div class="form-group"><label class="control-label">路由</label><input type="text" class="form-control W" data-name="routing" value="' + data.attr.routing + '"></div></div>';
  1077. _boxHtml = '<div class="form-group"><label class="control-label">Color</label>' + lrAppColorPicker(data.attr.bgColor, 205, "bgColor") + '</div>';
  1078. _html += lrAppBox('背景', _boxHtml);
  1079. _boxHtml = '<div class="form-group form-toggle "><label class="control-label">显示tabs</label>' + lrAppToggle('isTabed', data.attr.isTabed) + '</div>';
  1080. _boxHtml += '<div class="form-group form-toggle "><label class="control-label">内边距</label>' + lrAppToggle('isPadding',data.attr.isPadding) + '</div>';
  1081. _boxHtml += '<div class="form-group form-toggle "><label class="control-label">隐藏头部</label>' + lrAppToggle('isHeadHide', data.attr.isHeadHide) + '</div>';
  1082. _html += lrAppBox('混合属性', _boxHtml);
  1083. _html += '<div style="margin:10px;"><button type="button" class="btn btn-danger btn-block">删除</button></div>';
  1084. return _html;
  1085. },
  1086. lrHeader: function (data, designer) {
  1087. var _html = '';
  1088. var _boxHtml = '';
  1089. var _size = [{ text: "H1", value: "H1", icon: "" },
  1090. { text: "H2", value: "H2", icon: "" },
  1091. { text: "H3", value: "H3", icon: "" },
  1092. { text: "H4", value: "H4", icon: "" },
  1093. { text: "H5", value: "H5", icon: "" }
  1094. ];
  1095. var _weightSize = [{ text: "200", value: "200", icon: "" },
  1096. { text: "300", value: "300", icon: "" },
  1097. { text: "400", value: "400", icon: "" },
  1098. { text: "500", value: "500", icon: "" },
  1099. { text: "600", value: "600", icon: "" }
  1100. ];
  1101. _html += '<div class="lr-app-right-header"><span class="lr-app-typePage"><a>' + designer.currentPage.text + '</a><span class="lr-app-slash">/</span></span>' + data.text + '</div>';
  1102. _boxHtml = '<div class="form-group"><input type="text" class="form-control W " data-name="text" value="' + data.text + '" ></div>';
  1103. _boxHtml += '<div class="form-group"><label class="control-label">Size</label>' + lrCombox("size", data.attr.size, _size, 205) + '</div>';
  1104. _boxHtml += '<div class="form-group"><label class="control-label">Weight</label>' + lrCombox("weightSize", data.attr.weight.size, _weightSize, 100);
  1105. _boxHtml += buttonGroup("italic", [{ 'text': 'I', 'value': 'false' }, { 'icon': 'fa fa-italic', 'value': 'true' }], data.attr.weight.isItalic, "margin-left:5px;");
  1106. _boxHtml += '</div>';
  1107. _boxHtml += '<div class="form-group"><label class="control-label">Color</label>' + lrAppColorPicker(data.attr.color, 205, "color") + '</div>';
  1108. _boxHtml += '<div class="form-group"><label class="control-label">Align</label>';
  1109. _boxHtml += buttonGroup("align", [{ 'icon': 'fa fa-align-left', "value": "left" }, { 'icon': 'fa fa-align-center', "value": "center" }, { 'icon': 'fa fa-align-right', "value": "right" }, { 'icon': 'fa fa-align-justify', "value": "justify" }], data.attr.align);
  1110. _boxHtml += '</div>';
  1111. _html += lrAppBox('Text', _boxHtml);
  1112. _html += '<div style="margin:10px;"><button type="button" class="btn btn-danger btn-block">删除</button></div>';
  1113. return _html;
  1114. },
  1115. lrParagraph: function (data, designer) {
  1116. var _html = '';
  1117. var _boxHtml = '';
  1118. var _size = [
  1119. { text: "12px", value: "12px", icon: "" },
  1120. { text: "13px", value: "13px", icon: "" },
  1121. { text: "14px", value: "14px", icon: "" },
  1122. { text: "15px", value: "15px", icon: "" },
  1123. { text: "16px", value: "16px", icon: "" },
  1124. { text: "17px", value: "17px", icon: "" },
  1125. { text: "18px", value: "18px", icon: "" },
  1126. { text: "19px", value: "19px", icon: "" },
  1127. { text: "20px", value: "20px", icon: "" },
  1128. { text: "21px", value: "21px", icon: "" },
  1129. { text: "22px", value: "22px", icon: "" },
  1130. { text: "23px", value: "23px", icon: "" },
  1131. { text: "24px", value: "24px", icon: "" },
  1132. { text: "25px", value: "25px", icon: "" }
  1133. ];
  1134. _html += '<div class="lr-app-right-header"><span class="lr-app-typePage"><a>' + designer.currentPage.text + '</a><span class="lr-app-slash">/</span></span>' + data.text + '</div>';
  1135. _boxHtml += '<div class="form-group"><label class="control-label">Size</label>' + lrCombox("size", data.attr.size, _size, 205) + '</div>';
  1136. _boxHtml += '<div class="form-group"><label class="control-label">Color</label>' + lrAppColorPicker(data.attr.color, 205, "color") + '</div>';
  1137. _boxHtml += '<div class="form-group"><label class="control-label">Align</label>';
  1138. _boxHtml += buttonGroup("align", [{ 'icon': 'fa fa-align-left', "value": "left" }, { 'icon': 'fa fa-align-center', "value": "center" }, { 'icon': 'fa fa-align-right', "value": "right" }, { 'icon': 'fa fa-align-justify', "value": "justify" }], data.attr.align);
  1139. _boxHtml += '</div>';
  1140. _boxHtml += '<div class="form-group"><label class="control-label">内容</label><textarea class="form-control W" data-name="content" style="resize: none;height:100px;">' + data.attr.content + '</textarea></div>';
  1141. _html += lrAppBox('Text', _boxHtml);
  1142. _html += '<div style="margin:10px;"><button type="button" class="btn btn-danger btn-block">删除</button></div>';
  1143. return _html;
  1144. },
  1145. lrBtn: function (data, designer) {
  1146. var _html = '';
  1147. var _boxHtml = '';
  1148. var _pages = designer.templates.getHasTemps();
  1149. var _innerPages = [];
  1150. for (var i in _pages) {
  1151. var _item = _pages[i];
  1152. var _point = { text: _item.text, value: _item.id, icon: "" };
  1153. _innerPages.push(_point);
  1154. }
  1155. var _size = [
  1156. { text: "12px", value: "12px" },
  1157. { text: "13px", value: "13px" },
  1158. { text: "14px", value: "14px" },
  1159. { text: "15px", value: "15px" },
  1160. { text: "16px", value: "16px" },
  1161. { text: "17px", value: "17px" },
  1162. { text: "18px", value: "18px" },
  1163. { text: "19px", value: "19px" },
  1164. { text: "20px", value: "20px" },
  1165. { text: "21px", value: "21px" },
  1166. { text: "22px", value: "22px" },
  1167. { text: "23px", value: "23px" },
  1168. { text: "24px", value: "24px" },
  1169. { text: "25px", value: "25px" }
  1170. ];
  1171. var _weightSize = [{ text: "200", value: "200" },
  1172. { text: "300", value: "300" },
  1173. { text: "400", value: "400" },
  1174. { text: "500", value: "500" },
  1175. { text: "600", value: "600" }
  1176. ];
  1177. var _color = [
  1178. { text: "Light", value: "light", icon: "<span class='color-square light-bg light-border space-right'></span>" },
  1179. { text: "Stable", value: "stable", icon: "<span class='color-square stable-bg stable-border space-right'></span>" },
  1180. { text: "Dark", value: "dark", icon: "<span class='color-square dark-bg dark-border space-right'></span>" },
  1181. { text: "Positive", value: "positive", icon: "<span class='color-square positive-bg positive-border space-right'></span>" },
  1182. { text: "Balanced", value: "balanced", icon: "<span class='color-square balanced-bg balanced-border space-right'></span>" },
  1183. { text: "Assertive", value: "assertive", icon: "<span class='color-square assertive-bg assertive-border space-right'></span>" },
  1184. { text: "Calm", value: "calm", icon: "<span class='color-square calm-bg calm-border space-right'></span>" },
  1185. { text: "Energized", value: "energized", icon: "<span class='color-square energized-bg energized-border space-right'></span>" },
  1186. { text: "Royal", value: "royal", icon: "<span class='color-square royal-bg royal-border space-right'></span>" }
  1187. ];
  1188. _html += '<div class="lr-app-right-header"><span class="lr-app-typePage"><a>' + designer.currentPage.text + '</a><span class="lr-app-slash">/</span></span>' + data.text + '</div>';
  1189. _boxHtml = '<div class="form-group"><label class="control-label">连接</label>' + lrCombox("link", data.attr.link, _innerPages, 205) + '</div>';
  1190. _html += lrAppBox('连接', _boxHtml);
  1191. _boxHtml = '<div class="form-group"><input type="text" class="form-control W " data-name="text" value="' + data.text + '" ></div>';
  1192. _boxHtml += '<div class="form-group"><label class="control-label">Size</label>' + lrCombox("size", data.attr.size, _size, 205) + '</div>';
  1193. _boxHtml += '<div class="form-group"><label class="control-label">Weight</label>' + lrCombox("weightSize", data.attr.weight.size, _weightSize, 100);
  1194. _boxHtml += buttonGroup("italic", [{ 'text': 'I', 'value': 'false' }, { 'icon': 'fa fa-italic', 'value': 'true' }], data.attr.weight.isItalic, "margin-left:5px;");
  1195. _boxHtml += '</div>';
  1196. _boxHtml += '<div class="form-group"><label class="control-label">Color</label>' + lrAppColorPicker(data.attr.color, 205, "color") + '</div>';
  1197. _boxHtml += '<div class="form-group"><label class="control-label">Align</label>';
  1198. _boxHtml += buttonGroup("align", [{ 'icon': 'fa fa-align-left', "value": "left" }, { 'icon': 'fa fa-align-center', "value": "center" }, { 'icon': 'fa fa-align-right', "value": "right" }, { 'icon': 'fa fa-align-justify', "value": "justify" }], data.attr.align);
  1199. _boxHtml += '</div>';
  1200. _html += lrAppBox('文本', _boxHtml);
  1201. _boxHtml = '<div class="form-group"><label class="control-label">类型</label>' + lrCombox("btnType", data.attr.btnType, [{ text: "Default", value: "default" }, { text: "Clear", value: "clear" }, { text: "Outline", value: "outline" }], 205) + '</div>';
  1202. _boxHtml += '<div class="form-group"><label class="control-label">主题</label>' + lrCombox("btnTheme", data.attr.btnTheme, _color, 205) + '</div>';
  1203. _boxHtml += '<div class="form-group"><label class="control-label">尺寸</label>' + lrCombox("btnSize", data.attr.btnSize, [{ text: "Standard", value: "standard" }, { text: "Large", value: "large" }, { text: "Small", value: "small" }], 205) + '</div>';
  1204. _html += lrAppBox('样式', _boxHtml);
  1205. _html += '<div style="margin:10px;"><button type="button" class="btn btn-danger btn-block">删除</button></div>';
  1206. return _html;
  1207. },
  1208. lrInput: function (data, designer) {
  1209. var _html = '';
  1210. var _boxHtml = '';
  1211. var _type = [{ text: "Text", value: "text" },
  1212. { text: "Password", value: "password" }
  1213. ];
  1214. _html += '<div class="lr-app-right-header"><span class="lr-app-typePage"><a>' + designer.currentPage.text + '</a><span class="lr-app-slash">/</span></span>' + data.text + '</div>';
  1215. _boxHtml = '<div class="form-group"><label class="control-label">Placeholder</label><input type="text" class="form-control" data-name="placeholder" value="' + data.attr.placeholder + '" ></div>';
  1216. _boxHtml += '<div class="form-group"><label class="control-label">Type</label>' + lrCombox("inputType", data.attr.inputType, _type, 205) + '</div>';
  1217. _boxHtml += '<div class="form-group"><label class="control-label">Name</label><input type="text" class="form-control" data-name="name" value="' + data.attr.name + '" ></div>';
  1218. _html += lrAppBox('输入框设置', _boxHtml);
  1219. _html += '<div style="margin:10px;"><button type="button" class="btn btn-danger btn-block">删除</button></div>';
  1220. return _html;
  1221. },
  1222. lrList3: function (data, designer) {
  1223. var _html = '';
  1224. var _boxHtml = '';
  1225. var _pages = designer.templates.getHasTemps();
  1226. var _innerPages = [];
  1227. for (var i in _pages) {
  1228. var _item = _pages[i];
  1229. var _point = { text: _item.text, value: _item.id, icon: "" };
  1230. _innerPages.push(_point);
  1231. }
  1232. var _color = [
  1233. { text: "Light", value: "light", icon: "<span class='color-square light-bg light-border space-right'></span>" },
  1234. { text: "Stable", value: "stable", icon: "<span class='color-square stable-bg stable-border space-right'></span>" },
  1235. { text: "Dark", value: "dark", icon: "<span class='color-square dark-bg dark-border space-right'></span>" },
  1236. { text: "Positive", value: "positive", icon: "<span class='color-square positive-bg positive-border space-right'></span>" },
  1237. { text: "Balanced", value: "balanced", icon: "<span class='color-square balanced-bg balanced-border space-right'></span>" },
  1238. { text: "Assertive", value: "assertive", icon: "<span class='color-square assertive-bg assertive-border space-right'></span>" },
  1239. { text: "Calm", value: "calm", icon: "<span class='color-square calm-bg calm-border space-right'></span>" },
  1240. { text: "Energized", value: "energized", icon: "<span class='color-square energized-bg energized-border space-right'></span>" },
  1241. { text: "Royal", value: "royal", icon: "<span class='color-square royal-bg royal-border space-right'></span>" }
  1242. ];
  1243. _html += '<div class="lr-app-right-header"><span class="lr-app-typePage"><a>' + designer.currentPage.text + '</a><span class="lr-app-slash">/</span></span>' + data.text + '</div>';
  1244. _boxHtml = '<div class="form-group"><label class="control-label">连接</label>' + lrCombox("link", data.attr.link, _innerPages, 205) + '</div>';
  1245. _html += lrAppBox('连接', _boxHtml);
  1246. _boxHtml = '<div class="form-group"><label class="control-label">显示文本</label><input type="text" class="form-control" data-name="name" value="' + data.attr.name + '" ></div>';
  1247. _boxHtml += '<div class="form-group"><label class="control-label">主题</label>' + lrCombox("color", data.attr.color, _color, 205) + '</div>';
  1248. _boxHtml += '<div class="form-group"><label class="control-label">图标</label>' + lrCombox("icon", data.attr.icon, webAppData.iconList, 205) + '</div>';
  1249. _html += lrAppBox('列表设置', _boxHtml);
  1250. _html += '<div style="margin:10px;"><button type="button" class="btn btn-danger btn-block">删除</button></div>';
  1251. return _html;
  1252. },
  1253. lrList4: function (data, designer) {
  1254. var _html = '';
  1255. var _boxHtml = '';
  1256. var _pages = designer.templates.getHasTemps();
  1257. var _innerPages = [];
  1258. for (var i in _pages) {
  1259. var _item = _pages[i];
  1260. var _point = { text: _item.text, value: _item.id, icon: "" };
  1261. _innerPages.push(_point);
  1262. }
  1263. var _color = [
  1264. { text: "a", value: "a", icon: "<span class='color-square bgcolor_a light-border space-right'></span>" },
  1265. { text: "b", value: "b", icon: "<span class='color-square bgcolor_b light-border space-right'></span>" },
  1266. { text: "c", value: "c", icon: "<span class='color-square bgcolor_c light-border space-right'></span>" },
  1267. { text: "d", value: "d", icon: "<span class='color-square bgcolor_d light-border space-right'></span>" },
  1268. { text: "e", value: "e", icon: "<span class='color-square bgcolor_e light-border space-right'></span>" },
  1269. { text: "f", value: "f", icon: "<span class='color-square bgcolor_f light-border space-right'></span>" },
  1270. { text: "g", value: "g", icon: "<span class='color-square bgcolor_g light-border space-right'></span>" },
  1271. { text: "h", value: "h", icon: "<span class='color-square bgcolor_h light-border space-right'></span>" }
  1272. ];
  1273. _html += '<div class="lr-app-right-header"><span class="lr-app-typePage"><a>' + designer.currentPage.text + '</a><span class="lr-app-slash">/</span></span>' + data.text + '</div>';
  1274. _boxHtml = '<div class="form-group"><label class="control-label">连接</label>' + lrCombox("link", data.attr.link, _innerPages, 205) + '</div>';
  1275. _html += lrAppBox('连接', _boxHtml);
  1276. _boxHtml = '<div class="form-group"><label class="control-label">显示文本</label><input type="text" class="form-control" data-name="name" value="' + data.attr.name + '" ></div>';
  1277. _boxHtml += '<div class="form-group"><label class="control-label">主题</label>' + lrCombox("color", data.attr.color, _color, 205) + '</div>';
  1278. _boxHtml += '<div class="form-group"><label class="control-label">图标</label>' + lrCombox("icon", data.attr.icon, webAppData.iconList, 205) + '</div>';
  1279. _html += lrAppBox('列表设置', _boxHtml);
  1280. _html += '<div style="margin:10px;"><button type="button" class="btn btn-danger btn-block">删除</button></div>';
  1281. return _html;
  1282. },
  1283. }
  1284. $.webappDesigner = {
  1285. attributes: function (data) {
  1286. //console.log(data.currentFocus);
  1287. //var $webAppDesign = angular.element('#webAppDesign');
  1288. //var $rootScope = $webAppDesign.scope().$root;
  1289. var _currentFocus = data.currentFocus;
  1290. var _attr = _currentFocus.attr;
  1291. var _currentPage = data.currentPage;
  1292. var strhtml = '';
  1293. var strBoxHtml = '';
  1294. strhtml = _tempsAttr[_attr.value](_currentFocus, data);
  1295. $('.lr-app-right-bar').html(strhtml).ready(function () {
  1296. $('.color').colorpicker();
  1297. $('.ui-select').each(function (r) {
  1298. $(this).ComboBox({
  1299. height: "400px",
  1300. }).bind('change', function () {
  1301. var $obj = $(this);
  1302. var _value = $obj.attr('data-value');
  1303. var _name = $obj.attr("data-name");
  1304. data.currentFocus.setValue(_name, _value, data.currentFocus);
  1305. });
  1306. });
  1307. $('.lr-app-right-bar input').unbind();
  1308. $('.lr-app-right-bar input').bind('input propertychange', function () {
  1309. var $obj = $(this);
  1310. var _value = $obj.val();
  1311. var _name = $obj.attr("data-name");
  1312. if (_name == "routing")
  1313. {
  1314. if (_value.indexOf("/") < 0)
  1315. {
  1316. _value = "/" + _value;
  1317. $obj.val(_value);
  1318. }
  1319. }
  1320. data.currentFocus.setValue(_name, _value, data.currentFocus);
  1321. });
  1322. $('.lr-app-right-bar textarea').unbind();
  1323. $('.lr-app-right-bar textarea').bind('valuechange', function () {
  1324. var $obj = $(this);
  1325. var _value = $obj.val();
  1326. var _name = $obj.attr("data-name");
  1327. data.currentFocus.setValue(_name, _value, data.currentFocus);
  1328. });
  1329. $('button').on('click', function () {
  1330. data.currentFocus.doButton(data.currentFocus);
  1331. });
  1332. });
  1333. },
  1334. doBroadcast: function (name, data) {//发送广播
  1335. var $webAppDesign = angular.element('#webAppDesign');
  1336. var $rootScope = $webAppDesign.scope().$root;
  1337. $rootScope.$broadcast(name, data);//iframeLoaded
  1338. }
  1339. };
  1340. $.event.special.valuechange = {
  1341. teardown: function (namespaces) {
  1342. $(this).unbind('.valuechange');
  1343. },
  1344. handler: function (e) {
  1345. $.event.special.valuechange.triggerChanged($(this));
  1346. },
  1347. add: function (obj) {
  1348. $(this)
  1349. .on(
  1350. 'keyup.valuechange cut.valuechange paste.valuechange input.valuechange',
  1351. obj.selector, $.event.special.valuechange.handler)
  1352. },
  1353. triggerChanged: function (element) {
  1354. var current = element[0].contentEditable === 'true' ? element
  1355. .html() : element.val(), previous = typeof element
  1356. .data('previous') === 'undefined' ? element[0].defaultValue
  1357. : element.data('previous')
  1358. if (current !== previous) {
  1359. element.trigger('valuechange', [element.data('previous')])
  1360. element.data('previous', current)
  1361. }
  1362. }
  1363. }
  1364. $.fn.ComboBox = function (options) {
  1365. //options参数:description,height,width,allowSearch,url,param,data
  1366. options.id = "key";
  1367. options.text = "text";
  1368. var $select = $(this);
  1369. var json = options.data = [];
  1370. var _description = $select.attr("data-value");
  1371. $select.find('li').each(function (r) {
  1372. var $obj = $(this);
  1373. var _text = $obj.html();
  1374. var _value = $obj.attr('data-value');
  1375. var _icon = $obj.attr('data-icon');
  1376. var _a = {};
  1377. _a[options.id] = _value;
  1378. _a[options.text] = _text;
  1379. _a["icon"] = (_icon == "undefined" ? "" : _icon);
  1380. if (_description == _value)
  1381. {
  1382. _description = _a["icon"] + _text;
  1383. }
  1384. json.push(_a);
  1385. });
  1386. var _name = $select.attr("data-name");
  1387. if (options) {
  1388. if ($select.find('.ui-select-text').length == 0) {
  1389. var $select_html = "";
  1390. $select_html += "<div class=\"ui-select-text\" style='color:#999;'>" + _description + "</div>";
  1391. $select_html += "<div class=\"ui-select-option\">";
  1392. $select_html += "<div class=\"ui-select-option-content\" style=\"max-height: " + options.height + "\">" + $select.html() + "</div>";
  1393. if (options.allowSearch) {
  1394. $select_html += "<div class=\"ui-select-option-search\"><input type=\"text\" class=\"form-control\" placeholder=\"搜索关键字\" /><span class=\"input-query\" title=\"Search\"><i class=\"fa fa-search\"></i></span></div>";
  1395. }
  1396. $select_html += "</div>";
  1397. $select.html('');
  1398. $select.append($select_html);
  1399. }
  1400. }
  1401. var $option_html = $($("<p>").append($select.find('.ui-select-option').clone()).html());
  1402. $option_html.attr('id', $select.attr('id') + '-option');
  1403. $select.find('.ui-select-option').remove();
  1404. if ($option_html.length > 0) {
  1405. $('body').find('#' + $select.attr('id') + '-option').remove();
  1406. }
  1407. $('body').prepend($option_html);
  1408. var $option = $("#" + $select.attr('id') + "-option");
  1409. //var json = options.data;
  1410. loadComboBoxView(json);
  1411. function loadComboBoxView(json, searchValue, m) {
  1412. if (json.length > 0) {
  1413. var $_html = $('<ul></ul>');
  1414. if (options.description) {
  1415. $_html.append('<li data-value="">' + options.description + '</li>');
  1416. }
  1417. $.each(json, function (i) {
  1418. var row = json[i];
  1419. var title = row[options.title];
  1420. if (title == undefined) {
  1421. title = "";
  1422. }
  1423. if (searchValue != undefined) {
  1424. if (row[m.text].indexOf(searchValue) != -1) {
  1425. $_html.append('<li data-value="' + row[options.id] + '" title="' + title + '">' + row.icon + row[options.text] + '</li>');
  1426. }
  1427. }
  1428. else {
  1429. $_html.append('<li data-value="' + row[options.id] + '" title="' + title + '">' + row.icon + row[options.text] + '</li>');
  1430. }
  1431. });
  1432. $option.find('.ui-select-option-content').html($_html);
  1433. $option.find('li').css('padding', "0 5px");
  1434. $option.find('li').click(function (e) {
  1435. var data_text = $(this).html();
  1436. var data_value = $(this).attr('data-value');
  1437. $select.attr("data-value", data_value).attr("data-text", data_text);
  1438. $select.find('.ui-select-text').html(data_text).css('color', '#000');
  1439. $option.slideUp(150);
  1440. $select.trigger("change");
  1441. e.stopPropagation();
  1442. }).hover(function (e) {
  1443. if (!$(this).hasClass('liactive')) {
  1444. $(this).toggleClass('on');
  1445. }
  1446. e.stopPropagation();
  1447. });
  1448. }
  1449. }
  1450. //操作搜索事件
  1451. if (options.allowSearch) {
  1452. $option.find('.ui-select-option-search').find('input').bind("keypress", function (e) {
  1453. if (event.keyCode == "13") {
  1454. var value = $(this).val();
  1455. loadComboBoxView($(this)[0].options.data, value, $(this)[0].options);
  1456. }
  1457. }).focus(function () {
  1458. $(this).select();
  1459. })[0]["options"] = options;
  1460. }
  1461. $select.unbind('click');
  1462. $select.bind("click", function (e) {
  1463. if ($select.attr('readonly') == 'readonly' || $select.attr('disabled') == 'disabled') {
  1464. return false;
  1465. }
  1466. $(this).addClass('ui-select-focus');
  1467. if ($option.is(":hidden")) {
  1468. $select.find('.ui-select-option').hide();
  1469. $('.ui-select-option').hide();
  1470. var left = $select.offset().left;
  1471. var top = $select.offset().top + 35;
  1472. var width = $select.width();
  1473. if (options.width) {
  1474. width = options.width;
  1475. }
  1476. if (($option.height() + top) < $(window).height()) {
  1477. $option.slideDown(150).css({ top: top, left: left, width: width });
  1478. } else {
  1479. var _top = (top - $option.height() - 32)
  1480. $option.show().css({ top: _top, left: left, width: width });
  1481. $option.attr('data-show', true);
  1482. }
  1483. $option.css('border-top', '1px solid #ccc');
  1484. $option.find('li').removeClass('liactive');
  1485. $option.find('[data-value=' + $select.attr('data-value') + ']').addClass('liactive');
  1486. $option.find('.ui-select-option-search').find('input').select();
  1487. } else {
  1488. if ($option.attr('data-show')) {
  1489. $option.hide();
  1490. } else {
  1491. $option.slideUp(150);
  1492. }
  1493. }
  1494. e.stopPropagation();
  1495. });
  1496. $(document).click(function (e) {
  1497. var e = e ? e : window.event;
  1498. var tar = e.srcElement || e.target;
  1499. if (!$(tar).hasClass('form-control')) {
  1500. if ($option.attr('data-show')) {
  1501. $option.hide();
  1502. } else {
  1503. $option.slideUp(150);
  1504. }
  1505. $select.removeClass('ui-select-focus');
  1506. e.stopPropagation();
  1507. }
  1508. });
  1509. return $select;
  1510. }
  1511. $.fn.ComboBoxSetValue = function (value) {
  1512. if ($.isNullOrEmpty(value)) {
  1513. return;
  1514. }
  1515. var $select = $(this);
  1516. var $option = $("#" + $select.attr('id') + "-option");
  1517. $select.attr('data-value', value);
  1518. var data_text = $option.find('ul').find('[data-value=' + value + ']').html();
  1519. if (data_text) {
  1520. $select.attr('data-text', data_text);
  1521. $select.find('.ui-select-text').html(data_text).css('color', '#000');
  1522. $option.find('ul').find('[data-value=' + value + ']').addClass('liactive')
  1523. }
  1524. return $select;
  1525. }
  1526. })(window.jQuery);
  1527. function lrappbox(a) {
  1528. var $obj = $(a).parent();
  1529. if ($obj.is('.expanded')) {
  1530. $obj.removeClass('expanded');
  1531. }
  1532. else {
  1533. $obj.addClass('expanded');
  1534. }
  1535. }
  1536. function lrappBtnGroup(a) {
  1537. var $obj = $(a).parent();
  1538. $input = $(a).find('input');
  1539. $obj.find('.actived').removeClass('actived');
  1540. $(a).addClass('actived');
  1541. $input.trigger('propertychange');
  1542. }
  1543. function lrappToggle(a) {
  1544. var $obj = $(a);
  1545. $input = $obj.find('input');
  1546. $obj.addClass("animate");
  1547. var flag = $obj.is(".active");
  1548. if (flag) {
  1549. $input.val(false);
  1550. $obj.removeClass("active");
  1551. }
  1552. else {
  1553. $input.val(true);
  1554. $obj.addClass("active");
  1555. }
  1556. $input.trigger('propertychange');
  1557. }