人人商城

post.html 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. {template 'common/header'}
  2. <ul class="nav nav-tabs">
  3. <li {if $_GPC['a'] == 'mass' && $do == 'list'}class="active"{/if}><a href="{php echo url('material/mass/')}">定时群发</a></li>
  4. <li {if $_GPC['a'] == 'mass' && $do == 'send'}class="active"{/if}><a href="{php echo url('material/mass/send')}">发送记录</a></li>
  5. <li {if $type == 'image'}class="active"{/if}><a href="{php echo url('material/display/list', array('type' => 'image'));}">图片</a></li>
  6. <li {if $type == 'voice'}class="active"{/if}><a href="{php echo url('material/display/list', array('type' => 'voice'));}">语音</a></li>
  7. <li {if $type == 'video'}class="active"{/if}><a href="{php echo url('material/display/list', array('type' => 'video'));}">视频</a></li>
  8. <li {if $type == 'news' || $action == 'post'}class="active"{/if}><a href="{php echo url('material/display/list', array('type' => 'news'));}">图文</a></li>
  9. </ul>
  10. {php load()->func('tpl')}
  11. {php echo tpl_ueditor('', '', array('allow_upload_video' => false));}
  12. <form action="" class="form form-horizontal" ng-controller="post">
  13. <input type="hidden" name="replies" value="">
  14. <div class="panel panel-default clearfix">
  15. <div class="panel-heading">回复内容</div>
  16. <div class="panel-body">
  17. <div class="row clearfix reply">
  18. <div class="col-xs-6 col-sm-3 col-md-3 panel-group">
  19. <div class="panel panel-default" ng-repeat="item in context.items">
  20. <div class="panel-body" ng-if="$index == 0">
  21. <div class="img">
  22. <i class="default">封面图片</i>
  23. <img src="" ng-src="{{item.thumb}}">
  24. <span class="text-left">{{item.title}}</span>
  25. <div class="mask">
  26. <a href="javascript:;" ng-click="context.exportFromCms(item)"><i class="fa fa-book"></i>导入文章</a>
  27. <a href="javascript:;" ng-click="context.exportFromNews(item)"><i class="fa fa-book"></i>导入图文</a>
  28. <a href="javascript:;" ng-click="context.editItem(item)"><i class="fa fa-edit"></i>编辑</a>
  29. <a href="javascript:;" ng-click="context.removeItem(item)"><i class="fa fa-times"></i>删除</a>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="panel-body" ng-if="$index != 0">
  34. <div class="text">
  35. <h4>{{item.title}}</h4>
  36. </div>
  37. <div class="img">
  38. <img src="" ng-src="{{item.thumb}}">
  39. <i class="default">缩略图</i>
  40. </div>
  41. <div class="mask">
  42. <a href="javascript:;" ng-click="context.exportFromCms(item)"><i class="fa fa-book"></i> 导入文章</a>
  43. <a href="javascript:;" ng-click="context.editItem(item)"><i class="fa fa-edit"></i> 编辑</a>
  44. <a href="javascript:;" ng-click="context.removeItem(item)"><i class="fa fa-times"></i> 删除</a>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="panel panel-default" ng-show="context.items.length < 8">
  49. <div class="panel-body">
  50. <div class="add" ng-click="context.items.length >= 8 ? '' : context.addItem();"><span><i class="fa fa-plus"></i> 添加</span></div>
  51. </div>
  52. </div>
  53. </div>
  54. <div class="col-xs-6 col-sm-9 col-md-9 aside" id="edit-container">
  55. <div class="card">
  56. <div class="arrow-left"></div>
  57. <div class="inner">
  58. <div class="panel panel-default">
  59. <div class="panel-body">
  60. <div class="form-group">
  61. <label class="col-xs-12 col-sm-3 col-md-2 control-label">标题</label>
  62. <div class="col-sm-9 col-xs-12">
  63. <input type="text" class="form-control" placeholder="添加图文消息的标题" ng-model="context.activeItem.title"/>
  64. <input type="hidden" ng-model="context.activeItem.id" />
  65. </div>
  66. </div>
  67. <div class="form-group">
  68. <label class="col-xs-12 col-sm-3 col-md-2 control-label">作者</label>
  69. <div class="col-sm-9 col-xs-12">
  70. <input type="text" class="form-control" placeholder="添加图文消息的作者" ng-model="context.activeItem.author"/>
  71. </div>
  72. </div>
  73. <div class="form-group" ng-show="!context.activeItem.isFirst">
  74. <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
  75. <div class="col-sm-9 col-xs-12">
  76. <input type="text" class="form-control" placeholder="添加排序" ng-model="context.activeItem.displayorder"/>
  77. <span class="help-block">排序只能在提交后显示。按照从大到小的顺序对图文排序</span>
  78. </div>
  79. </div>
  80. <div class="form-group">
  81. <label class="col-xs-12 col-sm-3 col-md-2 control-label">封面</label>
  82. <div class="col-sm-9 col-xs-12">
  83. <div class="col-xs-3 img" ng-if="context.activeItem.thumb == ''">
  84. <span ng-click="context.changeItem(context.activeItem)"><i class="fa fa-plus-circle green"></i>&nbsp;添加图片</span>
  85. </div>
  86. <div class="col-xs-3 img" ng-if="context.activeItem.thumb != ''">
  87. <h3 ng-click="context.changeItem(context.activeItem)">重新上传</h3>
  88. <img ng-src="{{ context.activeItem.thumb }}">
  89. </div>
  90. </div>
  91. </div>
  92. <div class="form-group">
  93. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  94. <div class="col-sm-9 col-xs-12">
  95. <label>
  96. 封面(大图片建议尺寸:360像素 * 200像素)
  97. </label>
  98. </div>
  99. </div>
  100. <div class="form-group">
  101. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  102. <div class="col-sm-9 col-xs-12">
  103. <label class="checkbox-inline">
  104. <input type="checkbox" value="1" ng-model="context.activeItem.incontent" ng-checked="context.activeItem.incontent"/> 封面图片显示在正文中
  105. </label>
  106. </div>
  107. </div>
  108. <div class="form-group">
  109. <label class="col-xs-12 col-sm-3 col-md-2 control-label">描述</label>
  110. <div class="col-sm-9 col-xs-12">
  111. <textarea class="form-control" placeholder="添加图文消息的简短描述" ng-model="context.activeItem.description"></textarea>
  112. </div>
  113. </div>
  114. <div class="form-group">
  115. <label class="col-xs-12 col-sm-3 col-md-2 control-label">详情</label>
  116. <div class="col-sm-9 col-xs-12">
  117. <div ng-my-editor ng-my-value="context.activeItem.content"></div>
  118. </div>
  119. </div>
  120. <div class="form-group">
  121. <label class="col-xs-12 col-sm-3 col-md-2 control-label">来源</label>
  122. <div class="col-sm-9 col-xs-12">
  123. <div class="input-group">
  124. <input type="text" class="form-control" placeholder="图文消息的来源地址" ng-model="context.activeItem.url"/>
  125. <span class="input-group-btn">
  126. <button class="btn btn-default" type="button" ng-click="context.selectLink()"><i class="fa fa-external-link"></i> 系统链接</button>
  127. </span>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. <div class="btn btn-primary" ng-click="context.sync()" id="btn-submit">提 交</div>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. </form>
  141. <script>
  142. require(['angular.sanitize', 'bootstrap', 'underscore'], function(angular, $, _){
  143. var running = false;
  144. window.onbeforeunload = function(e) {
  145. if(running) {
  146. return (e || window.event).returnValue = '正在进行创建图文,确定离开页面吗.';
  147. }
  148. }
  149. angular.module('app', ['ngSanitize']).controller('post', function($scope, $http){
  150. $scope.context = {};
  151. $scope.context.items = [];
  152. $scope.context.hasimgs = []; //已经同步的图片
  153. $scope.context.wximgs = []; //已经同步的图片对应的微信url
  154. if(!$.isArray($scope.context.items)) {
  155. $scope.context.items = [];
  156. }
  157. if($scope.context.items.length == 0) {
  158. $scope.context.items.push(
  159. {
  160. id: '',
  161. title: '',
  162. author: '',
  163. thumb: '',
  164. media_id: '',
  165. displayorder: '0',
  166. description: '',
  167. content: '',
  168. url: ''
  169. }
  170. );
  171. }
  172. //当前编辑的回复项目的索引
  173. $scope.context.activeIndex = 0;
  174. //当前编辑的回复项目
  175. $scope.context.activeItem = $scope.context.items[$scope.context.activeIndex];
  176. $scope.context.editItem = function(item){
  177. var index = $.inArray(item, $scope.context.items);
  178. if(index == -1) return false
  179. $scope.context.triggerActiveItem(index);
  180. };
  181. $scope.context.triggerActiveItem = function(index) {
  182. var top = index * 110 + 120;
  183. $('#edit-container').css('marginTop', top);
  184. $("html,body").animate({scrollTop:top + 50},500);
  185. $scope.context.activeIndex = index;
  186. $scope.context.activeItem = $scope.context.items[$scope.context.activeIndex];
  187. $scope.context.activeItem.detail = $scope.context.activeItem.content != '';
  188. };
  189. $scope.context.changeItem = function(item) {
  190. require(['fileUploader'], function(uploader){
  191. uploader.init(function(imgs){
  192. $scope.context.activeItem.thumb = imgs.url;
  193. $scope.$apply()
  194. }, {'direct' : true, 'multiple' : false});
  195. });
  196. };
  197. $scope.context.selectLink = function(){
  198. util.linkBrowser(function(href){
  199. var url = '{$_W['siteroot']}app';
  200. $scope.context.activeItem.url = url + href.replace('./index', '/index');
  201. $scope.$digest();
  202. });
  203. };
  204. $scope.context.addItem = function(){
  205. $scope.context.items.push({
  206. id: '',
  207. title: '',
  208. author: '',
  209. thumb: '',
  210. displayorder: '0',
  211. description: '',
  212. content: '',
  213. url: ''
  214. });
  215. var index = $scope.context.items.length - 1;
  216. $scope.context.triggerActiveItem(index);
  217. };
  218. $scope.context.removeItem = function(item){
  219. require(['underscore'], function(_){
  220. $scope.context.items = _.without($scope.context.items, item);
  221. $scope.context.triggerActiveItem(0);
  222. $scope.$digest();
  223. });
  224. };
  225. //导入文章
  226. $scope.context.exportFromCms = function(item) {
  227. var index = $.inArray(item, $scope.context.items);
  228. if(index == -1) return false
  229. $scope.context.triggerActiveItem(index);
  230. $scope.context.searchCms();
  231. }
  232. $scope.context.searchCms = function(page) {
  233. var html = {};
  234. html['header'] = '<ul role="tablist" class="nav nav-pills" style="font-size:14px; margin-top:-20px;">'+
  235. ' <li role="presentation" class="active" id="li_goodslist"><a data-toggle="tab" role="tab" aria-controls="articlelist" href="#articlelist">文章列表</a></li>'+
  236. '</ul>';
  237. html['content'] =
  238. '<div class="tab-content">'+
  239. '<div id="articlelist" class="tab-pane active" role="tabpanel">' +
  240. ' <table class="table table-hover">' +
  241. ' <thead class="navbar-inner">' +
  242. ' <tr>' +
  243. ' <th style="width:40%;">标题</th>' +
  244. ' <th style="width:30%">创建时间</th>' +
  245. ' <th style="width:30%; text-align:right">' +
  246. ' <div class="input-group input-group-sm">' +
  247. ' <input type="text" class="form-control">' +
  248. ' <span class="input-group-btn">' +
  249. ' <button class="btn btn-default" type="button"><i class="fa fa-search"></i></button>' +
  250. ' </span>' +
  251. ' </div>' +
  252. ' </th>' +
  253. ' </tr>' +
  254. ' </thead>' +
  255. ' <tbody></tbody>'+
  256. ' </table>'+
  257. ' <div id="pager" style="text-align:center;"></div>'+
  258. '</div>'+
  259. '</div>';
  260. html['footer'] = '';
  261. html['articleitem'] =
  262. '<%_.each(list, function(item) {%> \n' +
  263. '<tr>\n' +
  264. ' <td><a href="#" data-cover-attachment-url="<%=item.attachment%>" title="<%=item.title%>"><%=item.title%></a></td>\n' +
  265. ' <td><%=item.createtime%></td>\n' +
  266. ' <td class="text-right">\n' +
  267. ' <button class="btn btn-default js-btn-select" js-id="<%=item.id%>">选取</button>\n' +
  268. ' </td>\n' +
  269. '</tr>\n' +
  270. '<%});%>\n';
  271. if (!$('#link-search-cms')[0]) {
  272. $scope.modalobj = util.dialog(html['header'], html['content'], html['footer'] ,{'containerName' : 'link-search-cms'});
  273. $scope.modalobj.find('.modal-body').css({'height':'680px','overflow-y':'auto' });
  274. $scope.modalobj.modal('show');
  275. $scope.modalobj.on('hidden.bs.modal', function(){$scope.modalobj.remove();});
  276. $('#link-search-cms').data('modal', $scope.modalobj);
  277. } else {
  278. $scope.modalobj = $('#link-search-cms').data('modal');
  279. }
  280. page = page || 1;
  281. $http.get('./index.php?c=utility&a=link&do=articlelist' + '&page=' + page).success(function(result, status, headers, config){
  282. if (result.message.list) {
  283. $scope.modalobj.find('#articlelist').data('articles', result.message.list);
  284. $scope.modalobj.find('#articlelist tbody').html(_.template(html['articleitem'])(result.message));
  285. $scope.modalobj.find('#pager').html(result.message.pager);
  286. $scope.modalobj.find('#pager .pagination li[class!=\'active\'] a').click(function(){
  287. $scope.context.searchCms($(this).attr('page'));
  288. return false;
  289. });
  290. $scope.modalobj.find('.js-btn-select').click(function(){
  291. $scope.context.addCms($(this).attr('js-id'));
  292. $scope.$apply();
  293. $scope.modalobj.modal('hide');
  294. });
  295. }
  296. });
  297. };
  298. $scope.context.addCms = function(id) {
  299. var article =$scope.modalobj.find('#articlelist').data('articles')[id];
  300. $scope.context.activeItem.title = article.title;
  301. $scope.context.activeItem.thumb = article.thumb_url;
  302. $scope.context.activeItem.author = article.author;
  303. $scope.context.activeItem.description = article.description;
  304. $scope.context.activeItem.content = article.content;
  305. $scope.context.activeItem.url = article.linkurl;
  306. };
  307. $scope.context.exportFromNews = function(item) {
  308. var index = $.inArray(item, $scope.context.items);
  309. if(index == -1) return false
  310. $scope.context.triggerActiveItem(index);
  311. $scope.context.searchNews();
  312. }
  313. $scope.context.searchNews = function(page) {
  314. var html = {};
  315. html['header'] = '<ul role="tablist" class="nav nav-pills" style="font-size:14px; margin-top:-20px;">'+
  316. ' <li role="presentation" class="active" id="li_newslist"><a data-toggle="tab" role="tab" aria-controls="newslist" href="#newslist">图文列表</a></li>'+
  317. '</ul>';
  318. html['content'] =
  319. '<div class="tab-content">'+
  320. '<div id="newslist" class="tab-pane active" role="tabpanel">' +
  321. ' <table class="table table-hover">' +
  322. ' <thead class="navbar-inner">' +
  323. ' <tr>' +
  324. ' <th style="width:40%;">标题</th>' +
  325. ' <th style="width:30%">创建时间</th>' +
  326. ' <th style="width:30%; text-align:right">' +
  327. ' <div class="input-group input-group-sm">' +
  328. ' <input type="text" class="form-control">' +
  329. ' <span class="input-group-btn">' +
  330. ' <button class="btn btn-default" type="button"><i class="fa fa-search"></i></button>' +
  331. ' </span>' +
  332. ' </div>' +
  333. ' </th>' +
  334. ' </tr>' +
  335. ' </thead>' +
  336. ' <tbody></tbody>'+
  337. ' </table>'+
  338. ' <div id="pager" style="text-align:center;"></div>'+
  339. '</div>'+
  340. '</div>';
  341. html['footer'] = '';
  342. html['newsitem'] =
  343. '<%_.each(list, function(item) {%> \n' +
  344. '<tr>\n' +
  345. ' <td><a href="#" data-cover-attachment-url="<%=item.attachment%>" title="<%=item.title%>"><%=item.title%></a></td>\n' +
  346. ' <td><%=item.createtime%></td>\n' +
  347. ' <td class="text-right">\n' +
  348. ' <button class="btn btn-default js-btn-select" js-id="<%=item.id%>">选取</button>\n' +
  349. ' </td>\n' +
  350. '</tr>\n' +
  351. '<%});%>\n';
  352. if (!$('#link-search-news')[0]) {
  353. $scope.modalobj = util.dialog(html['header'], html['content'], html['footer'] ,{'containerName' : 'link-search-news'});
  354. $scope.modalobj.find('.modal-body').css({'height':'680px','overflow-y':'auto' });
  355. $scope.modalobj.modal('show');
  356. $scope.modalobj.on('hidden.bs.modal', function(){$scope.modalobj.remove();});
  357. $('#link-search-news').data('modal', $scope.modalobj);
  358. } else {
  359. $scope.modalobj = $('#link-search-news').data('modal');
  360. }
  361. page = page || 1;
  362. $http.get('./index.php?c=utility&a=link&do=newschunk' + '&page=' + page).success(function(result, status, headers, config){
  363. if (result.message.list) {
  364. $scope.modalobj.find('#newslist').data('news', result.message.list);
  365. $scope.modalobj.find('#newslist tbody').html(_.template(html['newsitem'])(result.message));
  366. $scope.modalobj.find('#pager').html(result.message.pager);
  367. $scope.modalobj.find('#pager .pagination li[class!=\'active\'] a').click(function(){
  368. $scope.context.searchCms($(this).attr('page'));
  369. return false;
  370. });
  371. $scope.modalobj.find('.js-btn-select').click(function(){
  372. $scope.context.addNews($(this).attr('js-id'));
  373. $scope.$apply();
  374. $scope.modalobj.modal('hide');
  375. });
  376. }
  377. });
  378. };
  379. $scope.context.addNews = function(id) {
  380. var news =$scope.modalobj.find('#newslist').data('news')[id];
  381. $scope.context.items = news.items;
  382. $scope.$apply();
  383. $scope.context.triggerActiveItem(0);
  384. };
  385. $scope.context.uploadMedia = function(thumbs, thumb){
  386. running = true;
  387. util.message('创建图文中...,请不要关闭或刷新浏览器,', '', 'info');
  388. var num = 0;
  389. var thumbs = thumbs;
  390. var prop = function(thumbs, thumb) {
  391. if(thumb) {
  392. var thumb = thumb;
  393. } else {
  394. var thumb = thumbs.shift();
  395. }
  396. if(!thumb) {
  397. $scope.context.getDetailImgs();
  398. return false;
  399. }
  400. if(thumb.val == '') {
  401. prop(thumbs);
  402. return false;
  403. }
  404. $http.post("{php echo url('material/post/thumb');}", thumb).success(function(dat){
  405. if(dat.message.errno != 0) {
  406. num++;
  407. if(num < 5) {
  408. prop(thumbs, thumb);
  409. return false;
  410. } else {
  411. util.message('第' + (thumb.index + 1) + '条图文的缩略图上传失败.请更换图片', '', 'error');
  412. $('#btn-submit').attr('disabled', false);
  413. return false;
  414. }
  415. } else {
  416. $scope.context.items[thumb.index].media_id = dat.message.message.media_id;
  417. }
  418. prop(thumbs);
  419. });
  420. }
  421. prop(thumbs);
  422. };
  423. $scope.context.getDetailImgs = function(){
  424. var details = [];
  425. angular.forEach($scope.context.items, function(val1, index1){
  426. this.push({'index': index1, 'val': val1.content});
  427. }, details);
  428. $http.post("{php echo url('material/post/details');}", details).success(function(dat){
  429. if(dat.message.errno != 0) {
  430. util.message(dat.message.message, '', 'error');
  431. $('#btn-submit').attr('disabled', false);
  432. return false;
  433. } else {
  434. $scope.context.imgs = dat.message.message;
  435. $scope.context.uploadDetailImgs();
  436. }
  437. });
  438. };
  439. $scope.context.uploadDetailImgs = function(){
  440. var images = $scope.context.imgs;
  441. var num = 0;
  442. var propimage = function(image) {
  443. if(image) {
  444. var image = image;
  445. } else {
  446. var image = images.shift();
  447. }
  448. if(!image) {
  449. $scope.context.submit();
  450. return false;
  451. }
  452. $http.post("{php echo url('material/post/image');}", {'image': image, 'hasimgs': $scope.context.hasimgs, 'wximgs': $scope.context.wximgs}).success(function(dat){
  453. if(dat.message.errno != 0) {
  454. if(num < 5) {
  455. num++;
  456. propimage(image);
  457. return false;
  458. } else {
  459. util.message('图片上传到微信失败,原因:' + dat.message.message + "<br>解决方案:您可以删除该图片或者替换其他图片.<br><a target='_blank' href='"+image+"'>点击查看图片<a>", '', 'error');
  460. $('#btn-submit').attr('disabled', false);
  461. return false;
  462. }
  463. } else {
  464. $scope.context.hasimgs.push(image);
  465. $scope.context.wximgs.push(dat.message.message);
  466. }
  467. propimage();
  468. });
  469. }
  470. propimage();
  471. };
  472. $scope.context.submit = function() {
  473. $('#btn-submit').attr('disabled', true);
  474. $http.post("{php echo url('material/post/submit');}", {items: $scope.context.items, 'hasimgs': $scope.context.hasimgs, 'wximgs': $scope.context.wximgs}).success(function(dat){
  475. if(dat.message.errno != 0) {
  476. $('#btn-submit').attr('disabled', false);
  477. util.message(dat.message.message, '', 'error');
  478. } else {
  479. running = false;
  480. util.message('创建微信图文成功,正在跳转到图文列表. ', "{php echo url('material/display/list', array('type' => 'news', 'sync' => 1));}", 'success');
  481. return false;
  482. }
  483. });
  484. };
  485. $scope.context.sync = function() {
  486. var error = {title: '', action: ''};
  487. angular.forEach($scope.context.items, function(val, index){
  488. if(!$.trim(val.title)) {
  489. this.title += '第' + (index + 1) + '条图文回复没有设置标题<br>';
  490. }
  491. if(!$.trim(val.thumb)) {
  492. this.title += '第' + (index + 1) + '条图文回复没有设置缩略图<br>';
  493. }
  494. if(!$.trim(val.content)) {
  495. this.title += '第' + (index + 1) + '条图文回复没有设置详情<br>';
  496. }
  497. }, error);
  498. if(error.title) {
  499. util.message(error.title, '', 'error');
  500. $('#btn-submit').attr('disabled', false);
  501. return false;
  502. }
  503. var thumbs = [];
  504. angular.forEach($scope.context.items, function(val, index){
  505. if(!val.media_id) {
  506. this.push({'index': index, 'val': val.thumb});
  507. }
  508. }, thumbs);
  509. $scope.context.uploadMedia(thumbs);
  510. return;
  511. }
  512. }).directive('ngMyEditor', function(){
  513. var editor = {
  514. 'scope' : {
  515. 'value' : '=ngMyValue'
  516. },
  517. 'template' : '<textarea id="editor" style="height:600px;width:100%;"></textarea>',
  518. 'link' : function ($scope, element, attr) {
  519. if(!element.data('editor')) {
  520. editor = UE.getEditor('editor', ueditoroption);
  521. element.data('editor', editor);
  522. editor.addListener('contentChange', function() {
  523. $scope.value = editor.getContent();
  524. $scope.$root.$$phase || $scope.$apply('value');
  525. });
  526. editor.addListener('ready', function(){
  527. if (editor && editor.getContent() != $scope.value) {
  528. editor.setContent($scope.value);
  529. }
  530. $scope.$watch('value', function (value) {
  531. if (editor && editor.getContent() != value) {
  532. editor.setContent(value ? value : '');
  533. }
  534. });
  535. });
  536. }
  537. }
  538. };
  539. return editor;
  540. });
  541. angular.bootstrap(document, ['app']);
  542. });
  543. </script>
  544. {template 'common/footer'}