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.
 
 
 
 
 
 

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