dora.public.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /**
  2. * Created by Administrator on 2015/11/16.
  3. */
  4. $(function(){
  5. $('#selectAll').click(function(){
  6. if($(this).prop('checked')){
  7. $('.datalist input[name=listItem]').prop('checked',true);
  8. }else{
  9. $('.datalist input[name=listItem]').prop('checked',false);
  10. }
  11. getSelectIds();
  12. });
  13. });
  14. function getSelectIds(){
  15. var checkBoxList = $(".datalist input[name='listItem']:checkbox");
  16. var ids = '';
  17. var nids = '';
  18. if(checkBoxList.length>0){
  19. $(checkBoxList).each(function(i){
  20. if (true == $(this).prop("checked")) {
  21. ids += $(this).prop('value') + ',';
  22. if($(this).attr('nid')){
  23. nids += $(this).attr('nid') + ',';
  24. }
  25. }
  26. });
  27. $('#targetIds').val(ids.substring(0,ids.length - 1));
  28. $('#expandIds').val(nids.substring(0,nids.length - 1));
  29. }
  30. }
  31. //angularJs https Post方法封装
  32. function angularHttpPost($http,isValid,url,formData,callBack){
  33. if(isValid){
  34. $http({
  35. method : 'POST',
  36. url : url,
  37. data : $.param(formData), // pass in data as strings
  38. headers : { 'Content-Type': 'application/x-www-form-urlencoded' } // set the headers so angular passing info as form data (not request payload)
  39. })
  40. .success(function(data) {
  41. // 关闭所有模态窗口
  42. $('.modal').each(function(i){
  43. $(this).modal("hide");
  44. });
  45. if(data == 'success'){
  46. callBack(data);
  47. }else{
  48. $.tipsShow({ message : data, type : 'warning' });
  49. }
  50. });
  51. }
  52. else{
  53. $.tipsShow({ message : "参数校验不通过", type : 'warning' });
  54. }
  55. }
  56. /*初始化上传图片按钮
  57. * id 初始化上传按钮
  58. * type 文件类型
  59. * key 上传对象是所属 管理员头像、用户头像、文档首图等,后台根据key来进行不同规格的图片压缩
  60. * */
  61. function initUploadFyBtn(id,type,key,callBack){
  62. var typedes = 'Image Files';
  63. var filtertype = '*.gif; *.jpg; *.png';
  64. var buttonText = '上传图片';
  65. var uploadApi = '/system/upload';
  66. var autoUpdate = true;
  67. var sizeLimit = 1024 * 1024 * 1;
  68. var adminId = $('#adminId').val();
  69. var buttonWidth = 100;
  70. var buttonStyle = 'uploadify-btn-default';
  71. if(type == 'zip'){
  72. typedes = 'Zip Files';
  73. filtertype = '*.zip';
  74. buttonText = '安装本地模板(*.zip)';
  75. uploadApi = '/admin/manage/updateCMSTemplate';
  76. sizeLimit = 1024 * 1024 * 3;
  77. buttonWidth = 130;
  78. buttonStyle = 'uploadify-btn-primary';
  79. }
  80. $("#"+id).uploadify({
  81. //指定swf文件
  82. 'swf': '/plugins/uploadify/uploadify.swf',
  83. //后台处理的页面
  84. 'uploader': uploadApi + '?adminId='+adminId+'&type='+type+'&key='+key,
  85. //按钮显示的文字
  86. 'buttonText': buttonText,
  87. 'buttonClass' : buttonStyle,
  88. //显示的高度和宽度,默认 height 30;width 120
  89. //'height': 15,
  90. 'width': buttonWidth,
  91. //上传文件的类型 默认为所有文件 'All Files' ; '*.*'
  92. //在浏览窗口底部的文件类型下拉菜单中显示的文本
  93. 'fileTypeDesc': typedes,
  94. //允许上传的文件后缀
  95. 'fileTypeExts': filtertype,
  96. //发送给后台的其他参数通过formData指定
  97. //'formData': { 'adminUserId' : adminUserId , 'type': type, 'key': key},
  98. sizeLimit :sizeLimit,
  99. //上传文件页面中,你想要用来作为文件队列的元素的id, 默认为false 自动生成, 不带#
  100. //'queueID': 'fileQueue',
  101. //选择文件后自动上传
  102. 'auto': autoUpdate,
  103. //设置为true将允许多文件上传
  104. 'multi': false,
  105. //上传成功
  106. 'onUploadSuccess' : function(file, data, response) {
  107. if(data === 'typeError'){
  108. $.tipsShow({
  109. message : "文件类型不正确,请重试!",
  110. type : 'warning',
  111. callBack : function(){
  112. return;
  113. }
  114. });
  115. }else {
  116. callBack(data);
  117. }
  118. },
  119. 'onComplete': function(event, queueID, fileObj, response, data) {//当单个文件上传完成后触发
  120. //event:事件对象(the event object)
  121. //ID:该文件在文件队列中的唯一表示
  122. //fileObj:选中文件的对象,他包含的属性列表
  123. //response:服务器端返回的Response文本,我这里返回的是处理过的文件名称
  124. //data:文件队列详细信息和文件上传的一般数据
  125. alert("文件:" + fileObj.name + " 上传成功!");
  126. },
  127. //上传错误
  128. 'onUploadError' : function(file, errorCode, errorMsg, errorString) {
  129. alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
  130. },
  131. 'onError': function(event, queueID, fileObj) {//当单个文件上传出错时触发
  132. alert("文件:" + fileObj.name + " 上传失败!");
  133. }
  134. });
  135. }
  136. /*滑动组件
  137. * adsId 广告id
  138. * containerId 自定义广告容器ID
  139. * showPoint 是否显示小圆点 默认false
  140. *
  141. */
  142. function initSlides(jsonData){
  143. var jsonData = jsonData || {};
  144. jsonData.adsId = jsonData.adsId || '';
  145. jsonData.containerId = jsonData.containerId || '';
  146. jsonData.showPoint = jsonData.showPoint || false;
  147. if(jsonData.adsId && jsonData.containerId){
  148. this.init(jsonData);
  149. }
  150. }
  151. initSlides.prototype = {
  152. init : function(jsonData){
  153. $.ajax({
  154. url:"/content/requestAds/ads/item?uid="+jsonData.adsId,
  155. type:"get",
  156. dataType:"json",
  157. success:function(data){
  158. if(!data){
  159. return;
  160. }
  161. if(data.type === "1"){
  162. //var imgContent = data.content;
  163. var imgList = data.items;
  164. var imgItems = "";
  165. var imgIcons = "";
  166. for(var i=0;i<imgList.length;i++){
  167. var item = imgList[i];
  168. if(i==0){
  169. imgIcons += "<li data-target='#carousel-example-generic' data-slide-to='0' class='active'></li>";
  170. imgItems += "<div class='item active'><a href='"+item.link+"' target='"+item.target+"'><img width='"+item.width+"' height='"+item.height+"' src='"+item.sImg+"' alt='"+item.alt+"'></a></div>";
  171. }
  172. else{
  173. imgIcons += "<li data-target='#carousel-example-generic' data-slide-to='"+i+"'></li>";
  174. imgItems += "<div class='item'><a href='"+item.link+"' target='"+item.target+"'><img width='"+item.width+"' height='"+item.height+"' src='"+item.sImg+"' alt='"+item.alt+"'></a></div>";
  175. }
  176. }
  177. adsTemp(imgItems,imgIcons,jsonData,imgList.length);
  178. }else{
  179. var contentObj = data.items[0];
  180. var txtHtml = "";
  181. txtHtml += "<a href='"+contentObj.link+"' target='_blank'><i class='fa fa-tags'></i>"+contentObj.title+"</a>";
  182. $("#"+jsonData.containerId).html(txtHtml);
  183. }
  184. }
  185. });
  186. }
  187. };
  188. function adsTemp(imgItems,imgIcons,jsonData,imgListLength){
  189. var adsHtml = "";
  190. adsHtml += "<div id='carousel-example-generic' class='carousel slide' data-ride='carousel'>";
  191. adsHtml += " <ol class='carousel-indicators'>";
  192. if(jsonData.showPoint){
  193. adsHtml += imgIcons;
  194. }
  195. adsHtml += " </ol>";
  196. adsHtml += " <div class='carousel-inner' role='listbox'>";
  197. adsHtml += imgItems;
  198. adsHtml += " </div>";
  199. if(imgListLength > 1){
  200. adsHtml += " <a class='left carousel-control' href='#carousel-example-generic' role='button' data-slide='prev'>";
  201. adsHtml += " <span class='glyphicon glyphicon-chevron-left' aria-hidden='true'></span>";
  202. adsHtml += " <span class='sr-only'>Previous</span>";
  203. adsHtml += " </a>";
  204. adsHtml += " <a class='right carousel-control' href='#carousel-example-generic' role='button' data-slide='next'>";
  205. adsHtml += " <span class='glyphicon glyphicon-chevron-right' aria-hidden='true'></span>";
  206. adsHtml += " <span class='sr-only'>Next</span>";
  207. adsHtml += " </a>";
  208. }
  209. adsHtml += "</div>";
  210. $("#"+jsonData.containerId).html(adsHtml);
  211. }