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.
 
 
 
 
 
 

362 lines
11 KiB

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