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.
 
 
 
 
 
 

349 lines
8.7 KiB

  1. <script 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,fullscreen,autoresize",
  26. theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code,fullscreen",
  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('&#160;');
  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 type="text/javascript">
  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. /* enable character counter */
  119. $("#profile-jot-text").focus(charCounter);
  120. $("#profile-jot-text").click(charCounter);
  121. var uploader = new window.AjaxUpload(
  122. 'wall-image-upload',
  123. { action: 'wall_upload/$nickname',
  124. name: 'userfile',
  125. onSubmit: function(file,ext) { $('#profile-rotator').show(); },
  126. onComplete: function(file,response) {
  127. addeditortext(response);
  128. $('#profile-rotator').hide();
  129. }
  130. }
  131. );
  132. var file_uploader = new window.AjaxUpload(
  133. 'wall-file-upload',
  134. { action: 'wall_attach/$nickname',
  135. name: 'userfile',
  136. onSubmit: function(file,ext) { $('#profile-rotator').show(); },
  137. onComplete: function(file,response) {
  138. addeditortext(response);
  139. $('#profile-rotator').hide();
  140. }
  141. }
  142. );
  143. });
  144. function deleteCheckedItems() {
  145. var checkedstr = '';
  146. $('.item-select').each( function() {
  147. if($(this).is(':checked')) {
  148. if(checkedstr.length != 0) {
  149. checkedstr = checkedstr + ',' + $(this).val();
  150. }
  151. else {
  152. checkedstr = $(this).val();
  153. }
  154. }
  155. });
  156. $.post('item', { dropitems: checkedstr }, function(data) {
  157. window.location.reload();
  158. });
  159. }
  160. function jotGetLink() {
  161. reply = prompt("$linkurl");
  162. if(reply && reply.length) {
  163. reply = bin2hex(reply);
  164. $('#profile-rotator').show();
  165. $.get('parse_url?binurl=' + reply, function(data) {
  166. addeditortext(data);
  167. $('#profile-rotator').hide();
  168. });
  169. }
  170. }
  171. function jotVideoURL() {
  172. reply = prompt("$vidurl");
  173. if(reply && reply.length) {
  174. addeditortext('[video]' + reply + '[/video]');
  175. }
  176. }
  177. function jotAudioURL() {
  178. reply = prompt("$audurl");
  179. if(reply && reply.length) {
  180. addeditortext('[audio]' + reply + '[/audio]');
  181. }
  182. }
  183. function jotGetLocation() {
  184. reply = prompt("$whereareu", $('#jot-location').val());
  185. if(reply && reply.length) {
  186. $('#jot-location').val(reply);
  187. }
  188. }
  189. function jotShare(id) {
  190. if ($('#jot-popup').length != 0) $('#jot-popup').show();
  191. $('#like-rotator-' + id).show();
  192. $.get('share/' + id, function(data) {
  193. if (!editor) $("#profile-jot-text").val("");
  194. initEditor(function(){
  195. addeditortext(data);
  196. $('#like-rotator-' + id).hide();
  197. $(window).scrollTop(0);
  198. });
  199. });
  200. }
  201. function linkdropper(event) {
  202. var linkFound = event.dataTransfer.types.contains("text/uri-list");
  203. if(linkFound)
  204. event.preventDefault();
  205. }
  206. function linkdrop(event) {
  207. var reply = event.dataTransfer.getData("text/uri-list");
  208. event.target.textContent = reply;
  209. event.preventDefault();
  210. if(reply && reply.length) {
  211. reply = bin2hex(reply);
  212. $('#profile-rotator').show();
  213. $.get('parse_url?binurl=' + reply, function(data) {
  214. if (!editor) $("#profile-jot-text").val("");
  215. initEditor(function(){
  216. addeditortext(data);
  217. $('#profile-rotator').hide();
  218. });
  219. });
  220. }
  221. }
  222. function itemTag(id) {
  223. reply = prompt("$term");
  224. if(reply && reply.length) {
  225. reply = reply.replace('#','');
  226. if(reply.length) {
  227. commentBusy = true;
  228. $('body').css('cursor', 'wait');
  229. $.get('tagger/' + id + '?term=' + reply);
  230. if(timer) clearTimeout(timer);
  231. timer = setTimeout(NavUpdate,3000);
  232. liking = 1;
  233. }
  234. }
  235. }
  236. function itemFiler(id) {
  237. var bordercolor = $("input").css("border-color");
  238. $.get('filer/', function(data){
  239. $.fancybox(data);
  240. $("#id_term").keypress(function(){
  241. $(this).css("border-color",bordercolor);
  242. })
  243. $("#select_term").change(function(){
  244. $("#id_term").css("border-color",bordercolor);
  245. })
  246. $("#filer_save").click(function(e){
  247. e.preventDefault();
  248. reply = $("#id_term").val();
  249. if(reply && reply.length) {
  250. commentBusy = true;
  251. $('body').css('cursor', 'wait');
  252. $.get('filer/' + id + '?term=' + reply);
  253. if(timer) clearTimeout(timer);
  254. timer = setTimeout(NavUpdate,3000);
  255. liking = 1;
  256. $.fancybox.close();
  257. } else {
  258. $("#id_term").css("border-color","#FF0000");
  259. }
  260. return false;
  261. });
  262. });
  263. }
  264. function jotClearLocation() {
  265. $('#jot-coord').val('');
  266. $('#profile-nolocation-wrapper').hide();
  267. }
  268. function addeditortext(data) {
  269. if(plaintext == 'none') {
  270. var currentText = $("#profile-jot-text").val();
  271. $("#profile-jot-text").val(currentText + data);
  272. }
  273. else
  274. tinyMCE.execCommand('mceInsertRawHTML',false,data);
  275. }
  276. $geotag
  277. function charCounter() {
  278. // character count part deux
  279. //$(this).val().length is not a function Line 282(3)
  280. $('#profile-jot-text').keyup(function() {
  281. var textlen = 0;
  282. var maxLen1 = 140;
  283. var maxLen2 = 420;
  284. $('#character-counter').removeClass('jothidden');
  285. textLen = $(this).val().length;
  286. if(textLen <= maxLen1) {
  287. $('#character-counter').removeClass('red');
  288. $('#character-counter').removeClass('orange');
  289. $('#character-counter').addClass('grey');
  290. }
  291. if((textLen > maxLen1) && (textlen <= maxLen2)) {
  292. $('#character-counter').removeClass('grey');
  293. $('#character-counter').removeClass('red');
  294. $('#character-counter').addClass('orange');
  295. }
  296. if(textLen > maxLen2) {
  297. $('#character-counter').removeClass('grey');
  298. $('#character-counter').removeClass('orange');
  299. $('#character-counter').addClass('red');
  300. }
  301. $('#character-counter').text( textLen );
  302. });
  303. $('#profile-jot-text').keyup();
  304. }
  305. </script>