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.
 
 
 
 
 
 

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