angular.module("ModuleSpecialApp",["wapeditorApp"]),angular.module("ModuleSpecialApp").controller("MainCtrl",["$scope","$timeout","$uibModal","widget","config","serviceCommon","serviceSetStyle","serviceBase","serviceSpecialBase","serviceSubmit","serviceMultiSubmit","serviceMultiPage","serviceUpwardCompatible","$sanitize",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){a.modules=[],a.editors=[],a.allPages=e.allPages,a.multipage=e.multipage?e.multipage:[],a.submit={params:{},html:"",multipage:[]},a.isNew=!0,a.allPages&&_.findIndex(a.allPages,{active:!0})==-1&&(a.isNew=!1,a.allPages=[{property:a.allPages,active:!0}]),h.setBaseData("isNew",a.isNew),a.allPages=a.allPages?a.allPages:[{property:[],active:!0}];var o=_.findIndex(a.allPages,{active:!0});a.activeModules=o>-1?h.initActiveModules(a.allPages[o].property):[],a.activePageIndex=o>-1?o:0,i.setBaseData("activePageIndex",a.activePageIndex),a.activeItem={},a.activeIndex=0,a.index=a.activeModules.length?f.getMaxScopeIndex(a.allPages)+1:0,h.setBaseData("index",a.index),a.pageLength=_.isEmpty(a.activeModules)?1:a.activeModules[0].params.pageLength?a.activeModules[0].params.pageLength:1,a.isMultiPage=0==a.index||!(a.activeModules[f.getHeaderIndex(a.activeModules)].params.pageLength>1),a.isLongPage=0==a.index||(a.activeModules[f.getHeaderIndex(a.activeModules)].params.pageLength>1||1==a.activeModules[f.getHeaderIndex(a.activeModules)].params.pageLength&&1==a.allPages.length),a.pageLengths={1:1,2:2,3:3,4:4,5:5},a.lineHeights={1:1,1.25:1.25,1.5:1.5,2:2,2.5:2.5},a.fontSizes={12:12,14:14,16:16,18:18,20:20,22:22,24:24,26:26,28:28,30:30,32:32,34:34,36:36,38:38,40:40},i.setBaseData("allPages",a.allPages),i.setBaseData("multipage",a.multipage),h.setBaseData("pageLength",a.pageLength),a.isNew||(a.activeModules=m.compatibility(a.activeModules),"undefined"==typeof a.activeModules[0].params.pageLength&&(a.activeModules[0].params.pageLength=Math.ceil($(".modules").height()/568)),a.activeModules[0].params.pageLength>1&&(a.pageLength=a.activeModules[0].params.pageLength,a.isMultiPage=!1,a.isLongPage=!0,h.setBaseData("pageLength",a.pageLength),b(function(){$(".app-content").css("height",568*a.pageLength+"px")},100)),b(function(){var b=0,c=height="";$(".modules>div").each(function(){var d=parseInt($(this).attr("index"));if(c=$(this).find("div.ng-scope[ng-controller$='Ctrl']").css("width"),height=$(this).find("div.ng-scope[ng-controller$='Ctrl']").css("height"),d>0){for(var e in a.activeModules)a.activeModules[e].index==d&&(b+=parseInt(a.activeModules[e].marginTop),a.activeModules[e].params.positionStyle.width=parseInt(c),a.activeModules[e].params.positionStyle.height=parseInt(height),a.activeModules[e].params.positionStyle.top=b,a.activeModules[e].positionStyle="position:absolute;width:"+c+";height:"+height+";left:"+a.activeModules[e].params.positionStyle.left+"px;top:"+b+"px;",$(this).find("div[ng-controller]").attr("style",a.activeModules[e].positionStyle));b+=parseInt(height)}e++}),h.setBaseData("activeModules",a.activeModules)},1e3));for(var p in a.activeModules)a.activeModules[p].originParams=angular.copy(a.activeModules[p].params);a.$on("serviceBase.editors.update",function(b,c){a.editors=c}),a.$on("serviceBase.activeItem.update",function(b,c){a.activeItem=c}),a.$on("serviceBase.activeModules.update",function(b,c){a.activeModules=c}),a.$on("serviceBase.activeItem.params.update",function(b,c){a.activeItem.params=c}),a.$on("serviceBase.activeItem.animationName.update",function(b,c){a.activeItem.params.animationStyle.animationName=c}),a.$on("serviceBase.activeItem.style.update",function(b,c,d,e,f){a.activeItem.params[c]=d,a.activeItem[c]=e,"undefined"!=typeof f&&(a.activeItem.transform=f)}),a.$on("updateScope",function(b,c){angular.forEach(c,function(b,c){a[c]=b})}),a.addItem=function(a){h.addItem(a)},a.editItem=function(a){h.editItem(a)},a.deleteItem=function(a){h.deleteItem(a)},a.submit=function(b){a.submit=j.submit(),a.$apply("submit"),$(b.target).parents("form").submit()},a.multiSubmit=function(b){a.submit=k.submit(),a.$apply("submit"),$(b.target).parents("form").submit()},a.init=function(b,c){if(a.modules=h.setModules(b,c),a.activeModules.length>0){var d=[];angular.forEach(a.activeModules,function(a,b){a&&d.push(a.id)})}angular.forEach(a.modules,function(a,b){a.defaultshow&&$.inArray(a.id,d)==-1&&h.addItem(a.id)})},a.setModulePositionStyle=function(a){g.setModulePositionStyle(a)},a.eleAnimationIns=function(a){g.eleAnimationIns(a)},a.savePagePosition=function(){g.savePagePosition(a.activeModules)},a.saveModulePosition=function(){g.saveModulePosition(a.activeItem)},a.changeTextAlign=function(b){g.changeTextAlign(a.activeItem,b)},a.changeBorderWidth=function(){g.changeBorderWidth(a.activeItem)},a.changeInnerHeight=function(){g.changeInnerHeight(a.activeItem)},a.clearModuleStyle=function(){g.clearModuleStyle(a.activeItem)},a.changePageLength=function(b){if(angular.isString(b))if("minus"==b&&a.pageLength>1)b=a.pageLength-1;else{if(!("plus"==b&&a.pageLength<5))return!1;b=a.pageLength+1}var c=g.changePageLength(b,a.activeModules);h.setBaseData("pageLength",parseInt(b)),h.setBaseData("activeModules",c)},a.insertPage=function(){l.insertPage(),a.init(null,["header"])},a.navToPage=function(b){l.navToPage(b),a.activeHeader()},a.removePage=function(b){l.removePage(b),a.activeHeader()},a.copyPage=function(b,c){l.copyPage(b,c),a.activeHeader()},a.changeLock=function(){a.activeItem.params.baseStyle.lock=!a.activeItem.params.baseStyle.lock},a.activeHeader=function(){for(var b in a.activeModules)if("header"==a.activeModules[b].id){a.pageLength=a.activeModules[b].params.pageLength?a.activeModules[b].params.pageLength:1,g.changePageLength(a.pageLength,a.activeModules),h.setBaseData("activeItem",a.activeModules[0]),a.editItem(a.activeModules[b].index);break}},$(".multi-submit").on("click",function(b){a.multiSubmit(b)}),$(".single-submit").on("click",function(b){a.submit(b)}),a.init(null,["header"]),a.activeHeader(),a.$watch("activeItem.params.baseStyle",function(a){a&&g.setModuleBaseStyle(a)},!0),a.$watch("activeItem.params.borderStyle",function(a){a&&g.setModuleBorderStyle(a)},!0),a.$watch("activeItem.params.shadowStyle",function(a){a&&g.setModuleShadowStyle(a)},!0),a.$watch("activeItem.params.animationStyle",function(a){a&&g.setModuleAnimationStyle(a)},!0),a.$watch("activeItem.params.positionStyle",function(a){a&&g.setModulePositionStyle(a)},!0)}]),angular.module("ModuleSpecialApp").controller("SpecialDisplay",["$scope","serviceCopy","config",function(a,b,c){a.pages=c.pages,a.links=c.links,angular.forEach(a.pages,function(b,c){b.copyLink=a.links.appHome+"id="+b.id}),a.success=function(a){var a=parseInt(a),c=$(' 复制成功');b.copySuccess(a,c)}}]),angular.module("ModuleSpecialApp").directive("we7Multipage",function(){return{replace:!0,templateUrl:"directive-multipage-multipage.html"}}),angular.module("ModuleSpecialApp").service("serviceSpecialBase",["$rootScope","serviceBase",function(a,b){var c={},d={activePageIndex:0,isMultiPage:!0,isLongPage:!0,allPages:[],multipage:[]};return c.getBaseData=function(a){return d[a]},c.setBaseData=function(a,b){angular.isObject(a)?angular.forEach(a,function(a,b){d[b]=a}):d[a]=b},c}]),angular.module("ModuleSpecialApp").service("serviceCopy",["$rootScope",function(a){var b={};return b.copySuccess=function(a,b){var a=parseInt(a),b=b,c=$("#copy-"+a).next().html();(!c||c.indexOf(' 复制成功')<0)&&$("#copy-"+a).after(b),setTimeout(function(){b.remove()},2e3)},b}]),angular.module("ModuleSpecialApp").service("serviceMultiPage",["$rootScope","serviceCommon","serviceBase","serviceSpecialBase",function(a,b,c,d){var e={};return e.insertPage=function(){e.saveCurPage();var b=d.getBaseData("allPages"),f=d.getBaseData("activePageIndex");b[f].active=!1,b.push({property:[],active:!0}),$(".app-content").css("height","568px"),f=_.findIndex(b,{active:!0}),c.setBaseData({activeModules:[],pageLength:1}),d.setBaseData({allPages:b,isMultiPage:!0,isLongPage:!1,activePageIndex:f}),a.$broadcast("updateScope",{allPages:b,isMultiPage:!0,isLongPage:!1,pageLength:1,activePageIndex:f,activeModules:[]})},e.navToPage=function(b){var f=d.getBaseData("activePageIndex");if(f==b)return!1;e.saveCurPage();var g=d.getBaseData("allPages"),h=g[b].property;g[f].active=!1,g[b].active=!0,f=b,c.setBaseData("activeModules",h),c.setBaseData("activeItem",h[0]),d.setBaseData({allPages:g,activePageIndex:f}),a.$broadcast("updateScope",{allPages:g,activePageIndex:f,activeModules:h})},e.removePage=function(b){var f=[],g=d.getBaseData("allPages"),h=d.getBaseData("multipage");if(1==g.length)return!1;e.saveCurPage(),h.splice(parseInt(b),1);var i=_.clone(g),j=g.length-1,k=j-b;g=[];for(var l in i)if(l!=b)switch(k){case 0:parseInt(l)+1==b?(g.push({property:i[l].property,active:!0}),f=i[l].property):g.push({property:i[l].property,active:!1});break;default:l-1==b?(g.push({property:i[l].property,active:!0}),f=i[l].property):g.push({property:i[l].property,active:!1})}activePageIndex=_.findIndex(g,{active:!0}),1==g.length&&(d.setBaseData({isMultiPage:!0,isLongPage:!0}),a.$broadcast("updateScope",{isMultiPage:!0,isLongPage:!0})),c.setBaseData("activeModules",f),d.setBaseData({allPages:g,activePageIndex:activePageIndex}),a.$broadcast("updateScope",{allPages:g,activePageIndex:activePageIndex,activeModules:f})},e.copyPage=function(b,f){e.saveCurPage();var g=c.getBaseData("index"),h=d.getBaseData("allPages"),i=d.getBaseData("multipage");i.splice(parseInt(b),0,i[b]);var j=angular.copy(h);h=[];for(var k in j)if(k==b){h.push({property:j[k].property,active:!1});var l=angular.copy(j[k].property);for(var m in l)l[m].index=g++;h.push({property:l,active:!0});var n=l}else h.push({property:j[k].property,active:!1});activePageIndex=_.findIndex(h,{active:!0}),c.setBaseData("activeModules",n),c.setBaseData("index",g),d.setBaseData({allPages:h,multipage:i,isMultiPage:!0,isLongPage:!1,activePageIndex:activePageIndex}),f.stopPropagation(),a.$broadcast("updateScope",{allPages:h,isMultiPage:!0,isLongPage:!1,activePageIndex:activePageIndex,activeModules:n})},e.saveCurPage=function(){var e=c.getBaseData("activeModules"),f=c.getBaseData("pageLength"),g=d.getBaseData("allPages"),h=d.getBaseData("multipage"),i=_.findIndex(g,{active:!0}),j="",k=$($(".modules").html());k.find("div.ng-scope[ng-controller$='Ctrl']").each(function(){var a=$(this).parent().parent(),d=_.findIndex(e,{index:parseInt(a.attr("index"))}),g="",h=angular.copy(e[d].params);$(this).find(".js-default-content").remove(),$(this).find(".bar").remove();var i=a.attr("name").toLowerCase();if("header"!=i){var k=$(this).css("top"),l=$(this).css("left"),m=$(this).css("width"),n=$(this).css("height"),o="position:absolute;top:"+k+";left:"+l+";width:"+m+";height:"+n+";";e[d].params.positionStyle.top=parseInt(k),e[d].params.positionStyle.left=parseInt(l),e[d].params.positionStyle.width=parseInt(m),e[d].params.positionStyle.height=parseInt(n),e[d].positionStyle=o}else e[d].params.pageLength=f;switch(i){case"link":var p=this;angular.forEach(h.items,function(a,c){(a.selectCate.pid||a.selectCate.cid)&&$(p).find(".list-group").children().eq(c).replaceWith("