Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

353 lines
8.7 KiB

  1. <script language="javascript" type="text/javascript">
  2. var editor=false;
  3. var textlen = 0;
  4. var plaintext = '{{$editselect}}';
  5. function initEditor(cb){
  6. if (editor==false){
  7. $("#profile-jot-text-loading").show();
  8. if(plaintext == 'none') {
  9. $("#profile-jot-text-loading").hide();
  10. $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
  11. $("#profile-jot-text").contact_autocomplete(baseurl+"/acl");
  12. editor = true;
  13. $("a#jot-perms-icon").colorbox({
  14. 'inline' : true,
  15. 'transition' : 'elastic'
  16. });
  17. $(".jothidden").show();
  18. if (typeof cb!="undefined") cb();
  19. return;
  20. }
  21. tinyMCE.init({
  22. theme : "advanced",
  23. mode : "specific_textareas",
  24. editor_selector: {{$editselect}},
  25. auto_focus: "profile-jot-text",
  26. plugins : "bbcode,paste,autoresize, inlinepopups",
  27. theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
  28. theme_advanced_buttons2 : "",
  29. theme_advanced_buttons3 : "",
  30. theme_advanced_toolbar_location : "top",
  31. theme_advanced_toolbar_align : "center",
  32. theme_advanced_blockformats : "blockquote,code",
  33. theme_advanced_resizing : true,
  34. gecko_spellcheck : true,
  35. paste_text_sticky : true,
  36. entity_encoding : "raw",
  37. add_unload_trigger : false,
  38. remove_linebreaks : false,
  39. //force_p_newlines : false,
  40. //force_br_newlines : true,
  41. forced_root_block : 'div',
  42. convert_urls: false,
  43. content_css: "{{$baseurl}}/view/custom_tinymce.css",
  44. theme_advanced_path : false,
  45. file_browser_callback : "fcFileBrowser",
  46. setup : function(ed) {
  47. cPopup = null;
  48. ed.onKeyDown.add(function(ed,e) {
  49. if(cPopup !== null)
  50. cPopup.onkey(e);
  51. });
  52. ed.onKeyUp.add(function(ed, e) {
  53. var txt = tinyMCE.activeEditor.getContent();
  54. match = txt.match(/@([^ \n]+)$/);
  55. if(match!==null) {
  56. if(cPopup === null) {
  57. cPopup = new ACPopup(this,baseurl+"/acl");
  58. }
  59. if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
  60. if(! cPopup.ready) cPopup = null;
  61. }
  62. else {
  63. if(cPopup !== null) { cPopup.close(); cPopup = null; }
  64. }
  65. textlen = txt.length;
  66. if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
  67. $('#profile-jot-desc').html(ispublic);
  68. }
  69. else {
  70. $('#profile-jot-desc').html('&nbsp;');
  71. }
  72. //Character count
  73. if(textlen <= 140) {
  74. $('#character-counter').removeClass('red');
  75. $('#character-counter').removeClass('orange');
  76. $('#character-counter').addClass('grey');
  77. }
  78. if((textlen > 140) && (textlen <= 420)) {
  79. $('#character-counter').removeClass('grey');
  80. $('#character-counter').removeClass('red');
  81. $('#character-counter').addClass('orange');
  82. }
  83. if(textlen > 420) {
  84. $('#character-counter').removeClass('grey');
  85. $('#character-counter').removeClass('orange');
  86. $('#character-counter').addClass('red');
  87. }
  88. $('#character-counter').text(textlen);
  89. });
  90. ed.onInit.add(function(ed) {
  91. ed.pasteAsPlainText = true;
  92. $("#profile-jot-text-loading").hide();
  93. $(".jothidden").show();
  94. if (typeof cb!="undefined") cb();
  95. });
  96. }
  97. });
  98. editor = true;
  99. // setup acl popup
  100. $("a#jot-perms-icon").colorbox({
  101. 'inline' : true,
  102. 'transition' : 'elastic'
  103. });
  104. } else {
  105. if (typeof cb!="undefined") cb();
  106. }
  107. }
  108. function enableOnUser(){
  109. if (editor) return;
  110. $(this).val("");
  111. initEditor();
  112. }
  113. </script>
  114. <script type="text/javascript" src="{{$baseurl}}/js/ajaxupload.js" ></script>
  115. <script>
  116. var ispublic = '{{$ispublic}}';
  117. $(document).ready(function() {
  118. /* enable tinymce on focus and click */
  119. $("#profile-jot-text").focus(enableOnUser);
  120. $("#profile-jot-text").click(enableOnUser);
  121. /* show images / file browser window
  122. *
  123. **/
  124. /* callback */
  125. $('body').on('fbrowser.image', function(e, filename, embedcode, id) {
  126. $.colorbox.close();
  127. addeditortext(embedcode);
  128. });
  129. $('body').on('fbrowser.file', function(e, filename, embedcode, id) {
  130. $.colorbox.close();
  131. addeditortext(embedcode);
  132. });
  133. $('#wall-image-upload').on('click', function(){
  134. $.colorbox({href: baseurl + "/fbrowser/image/?mode=minimal", iframe:true,innerWidth:'500px',innerHeight:'400px'})
  135. });
  136. $('#wall-file-upload').on('click', function(){
  137. $.colorbox({href: baseurl + "/fbrowser/file/?mode=minimal", iframe:true,innerWidth:'500px',innerHeight:'400px'})
  138. });
  139. /**
  140. var uploader = new window.AjaxUpload(
  141. 'wall-image-upload',
  142. { action: 'wall_upload/{{$nickname}}',
  143. name: 'userfile',
  144. onSubmit: function(file,ext) { $('#profile-rotator').show(); },
  145. onComplete: function(file,response) {
  146. addeditortext(response);
  147. $('#profile-rotator').hide();
  148. }
  149. }
  150. );
  151. var file_uploader = new window.AjaxUpload(
  152. 'wall-file-upload',
  153. { action: 'wall_attach/{{$nickname}}',
  154. name: 'userfile',
  155. onSubmit: function(file,ext) { $('#profile-rotator').show(); },
  156. onComplete: function(file,response) {
  157. addeditortext(response);
  158. $('#profile-rotator').hide();
  159. }
  160. }
  161. );
  162. }
  163. **/
  164. });
  165. function deleteCheckedItems() {
  166. if(confirm('{{$delitems}}')) {
  167. var checkedstr = '';
  168. $("#item-delete-selected").hide();
  169. $('#item-delete-selected-rotator').show();
  170. $('.item-select').each( function() {
  171. if($(this).is(':checked')) {
  172. if(checkedstr.length != 0) {
  173. checkedstr = checkedstr + ',' + $(this).val();
  174. }
  175. else {
  176. checkedstr = $(this).val();
  177. }
  178. }
  179. });
  180. $.post('item', { dropitems: checkedstr }, function(data) {
  181. window.location.reload();
  182. });
  183. }
  184. }
  185. function jotGetLink() {
  186. reply = prompt("{{$linkurl}}");
  187. if(reply && reply.length) {
  188. reply = bin2hex(reply);
  189. $('#profile-rotator').show();
  190. $.get('parse_url?binurl=' + reply, function(data) {
  191. addeditortext(data);
  192. $('#profile-rotator').hide();
  193. });
  194. }
  195. }
  196. function jotVideoURL() {
  197. reply = prompt("{{$vidurl}}");
  198. if(reply && reply.length) {
  199. addeditortext('[video]' + reply + '[/video]');
  200. }
  201. }
  202. function jotAudioURL() {
  203. reply = prompt("{{$audurl}}");
  204. if(reply && reply.length) {
  205. addeditortext('[audio]' + reply + '[/audio]');
  206. }
  207. }
  208. function jotGetLocation() {
  209. reply = prompt("{{$whereareu}}", $('#jot-location').val());
  210. if(reply && reply.length) {
  211. $('#jot-location').val(reply);
  212. }
  213. }
  214. function jotShare(id) {
  215. if ($('#jot-popup').length != 0) $('#jot-popup').show();
  216. $('#like-rotator-' + id).show();
  217. $.get('share/' + id, function(data) {
  218. if (!editor) $("#profile-jot-text").val("");
  219. initEditor(function(){
  220. addeditortext(data);
  221. $('#like-rotator-' + id).hide();
  222. $(window).scrollTop(0);
  223. });
  224. });
  225. }
  226. function linkdropper(event) {
  227. var linkFound = event.dataTransfer.types.contains("text/uri-list");
  228. if(linkFound)
  229. event.preventDefault();
  230. }
  231. function linkdrop(event) {
  232. var reply = event.dataTransfer.getData("text/uri-list");
  233. event.target.textContent = reply;
  234. event.preventDefault();
  235. if(reply && reply.length) {
  236. reply = bin2hex(reply);
  237. $('#profile-rotator').show();
  238. $.get('parse_url?binurl=' + reply, function(data) {
  239. if (!editor) $("#profile-jot-text").val("");
  240. initEditor(function(){
  241. addeditortext(data);
  242. $('#profile-rotator').hide();
  243. });
  244. });
  245. }
  246. }
  247. function itemTag(id) {
  248. reply = prompt("{{$term}}");
  249. if(reply && reply.length) {
  250. reply = reply.replace('#','');
  251. if(reply.length) {
  252. commentBusy = true;
  253. $('body').css('cursor', 'wait');
  254. $.get('tagger/' + id + '?term=' + reply);
  255. if(timer) clearTimeout(timer);
  256. timer = setTimeout(NavUpdate,3000);
  257. liking = 1;
  258. }
  259. }
  260. }
  261. function itemFiler(id) {
  262. var bordercolor = $("input").css("border-color");
  263. $.get('filer/', function(data){
  264. $.colorbox({html:data});
  265. $("#id_term").keypress(function(){
  266. $(this).css("border-color",bordercolor);
  267. })
  268. $("#select_term").change(function(){
  269. $("#id_term").css("border-color",bordercolor);
  270. })
  271. $("#filer_save").click(function(e){
  272. e.preventDefault();
  273. reply = $("#id_term").val();
  274. if(reply && reply.length) {
  275. commentBusy = true;
  276. $('body').css('cursor', 'wait');
  277. $.get('filer/' + id + '?term=' + reply, NavUpdate);
  278. // if(timer) clearTimeout(timer);
  279. // timer = setTimeout(NavUpdate,3000);
  280. liking = 1;
  281. $.colorbox.close();
  282. } else {
  283. $("#id_term").css("border-color","#FF0000");
  284. }
  285. return false;
  286. });
  287. });
  288. }
  289. function jotClearLocation() {
  290. $('#jot-coord').val('');
  291. $('#profile-nolocation-wrapper').hide();
  292. }
  293. function addeditortext(data) {
  294. if(plaintext == 'none') {
  295. var currentText = $("#profile-jot-text").val();
  296. $("#profile-jot-text").val(currentText + data);
  297. }
  298. else
  299. tinyMCE.execCommand('mceInsertRawHTML',false,data);
  300. }
  301. {{$geotag}}
  302. </script>