3 <script language="javascript" type="text/javascript">
7 var plaintext = '{{$editselect}}';
9 function initEditor(cb){
11 $("#profile-jot-text-loading").show();
12 if(plaintext == 'none') {
13 $("#profile-jot-text-loading").hide();
14 $("#profile-jot-text").addClass("profile-jot-text-full").removeClass("profile-jot-text-empty");
15 $("#jot-category").show();
16 $("#jot-category").addClass("jot-category-ex");
17 $("#jot-profile-jot-wrapper").show();
18 $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
19 $("#profile-jot-text").bbco_autocomplete('bbcode');
21 $("a#jot-perms-icon").colorbox({
23 'transition' : 'elastic'
25 $(".jothidden").show();
26 if (typeof cb!="undefined") cb();
31 mode : "specific_textareas",
32 editor_selector: {{$editselect}},
33 auto_focus: "profile-jot-text",
34 plugins : "bbcode,paste,autoresize, inlinepopups",
35 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
36 theme_advanced_buttons2 : "",
37 theme_advanced_buttons3 : "",
38 theme_advanced_toolbar_location : "top",
39 theme_advanced_toolbar_align : "center",
40 theme_advanced_blockformats : "blockquote,code",
41 theme_advanced_resizing : true,
42 gecko_spellcheck : true,
43 paste_text_sticky : true,
44 entity_encoding : "raw",
45 add_unload_trigger : false,
46 remove_linebreaks : false,
47 //force_p_newlines : false,
48 //force_br_newlines : true,
49 forced_root_block : 'div',
51 content_css: "{{$baseurl}}/view/custom_tinymce.css",
52 theme_advanced_path : false,
53 file_browser_callback : "fcFileBrowser",
54 setup : function(ed) {
56 ed.onKeyDown.add(function(ed,e) {
61 ed.onKeyUp.add(function(ed, e) {
62 var txt = tinyMCE.activeEditor.getContent();
63 match = txt.match(/@([^ \n]+)$/);
66 cPopup = new ACPopup(this,baseurl+"/acl");
68 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
69 if(! cPopup.ready) cPopup = null;
72 if(cPopup !== null) { cPopup.close(); cPopup = null; }
76 if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
77 $('#profile-jot-desc').html(ispublic);
80 $('#profile-jot-desc').html(' ');
86 $('#character-counter').removeClass('red');
87 $('#character-counter').removeClass('orange');
88 $('#character-counter').addClass('grey');
90 if((textlen > 140) && (textlen <= 420)) {
91 $('#character-counter').removeClass('grey');
92 $('#character-counter').removeClass('red');
93 $('#character-counter').addClass('orange');
96 $('#character-counter').removeClass('grey');
97 $('#character-counter').removeClass('orange');
98 $('#character-counter').addClass('red');
100 $('#character-counter').text(textlen);
103 ed.onInit.add(function(ed) {
104 ed.pasteAsPlainText = true;
105 $("#profile-jot-text-loading").hide();
106 $(".jothidden").show();
107 if (typeof cb!="undefined") cb();
114 $("a#jot-perms-icon").colorbox({
116 'transition' : 'elastic'
119 if (typeof cb!="undefined") cb();
123 function enableOnUser(){
133 <script type="text/javascript" src="{{$baseurl}}/js/ajaxupload.js" ></script>
135 var ispublic = '{{$ispublic}}';
138 $(document).ready(function() {
140 /* enable tinymce on focus and click */
141 $("#profile-jot-text").focus(enableOnUser);
142 $("#profile-jot-text").click(enableOnUser);
147 /* show images / file browser window
152 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
154 addeditortext(embedcode);
156 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
158 addeditortext(embedcode);
161 $('#wall-image-upload').on('click', function(){
162 Dialog.doImageBrowser("main");
165 $('#wall-file-upload').on('click', function(){
166 Dialog.doFileBrowser("main");
170 var uploader = new window.AjaxUpload(
172 { action: 'wall_upload/{{$nickname}}',
174 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
175 onComplete: function(file,response) {
176 addeditortext(response);
177 $('#profile-rotator').hide();
181 var file_uploader = new window.AjaxUpload(
183 { action: 'wall_attach/{{$nickname}}',
185 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
186 onComplete: function(file,response) {
187 addeditortext(response);
188 $('#profile-rotator').hide();
198 function deleteCheckedItems() {
199 if(confirm('{{$delitems}}')) {
202 $("#item-delete-selected").hide();
203 $('#item-delete-selected-rotator').show();
205 $('.item-select').each( function() {
206 if($(this).is(':checked')) {
207 if(checkedstr.length != 0) {
208 checkedstr = checkedstr + ',' + $(this).val();
211 checkedstr = $(this).val();
215 $.post('item', { dropitems: checkedstr }, function(data) {
216 window.location.reload();
221 function jotGetLink() {
222 reply = prompt("{{$linkurl}}");
223 if(reply && reply.length) {
224 reply = bin2hex(reply);
225 $('#profile-rotator').show();
226 $.get('parse_url?binurl=' + reply, function(data) {
228 $('#profile-rotator').hide();
233 function jotVideoURL() {
234 reply = prompt("{{$vidurl}}");
235 if(reply && reply.length) {
236 addeditortext('[video]' + reply + '[/video]');
240 function jotAudioURL() {
241 reply = prompt("{{$audurl}}");
242 if(reply && reply.length) {
243 addeditortext('[audio]' + reply + '[/audio]');
248 function jotGetLocation() {
249 reply = prompt("{{$whereareu}}", $('#jot-location').val());
250 if(reply && reply.length) {
251 $('#jot-location').val(reply);
255 function jotShare(id) {
256 // if ($('#jot-popup').length != 0) $('#jot-popup').show();
258 // $('#like-rotator-' + id).show();
259 // $.get('share/' + id, function(data) {
260 // if (!editor) $("#profile-jot-text").val("");
261 // initEditor(function(){
262 // addeditortext(data);
263 // $('#like-rotator-' + id).hide();
264 // $(window).scrollTop(0);
269 $.get('share/' + id, function(data) {
270 if (!editor) $("#profile-jot-text").val("");
271 initEditor(function(){
278 $("#jot-popup").show();
281 function linkdropper(event) {
282 var linkFound = event.dataTransfer.types.contains("text/uri-list");
284 event.preventDefault();
287 function linkdrop(event) {
288 var reply = event.dataTransfer.getData("text/uri-list");
289 event.target.textContent = reply;
290 event.preventDefault();
291 if(reply && reply.length) {
292 reply = bin2hex(reply);
293 $('#profile-rotator').show();
294 $.get('parse_url?binurl=' + reply, function(data) {
295 if (!editor) $("#profile-jot-text").val("");
296 initEditor(function(){
298 $('#profile-rotator').hide();
304 function itemTag(id) {
305 reply = prompt("{{$term}}");
306 if(reply && reply.length) {
307 reply = reply.replace('#','');
311 $('body').css('cursor', 'wait');
313 $.get('tagger/' + id + '?term=' + reply);
314 if(timer) clearTimeout(timer);
315 timer = setTimeout(NavUpdate,3000);
321 function itemFiler(id) {
323 var bordercolor = $("input").css("border-color");
325 $.get('filer/', function(data){
326 $.colorbox({html:data});
327 $("#id_term").keypress(function(){
328 $(this).css("border-color",bordercolor);
330 $("#select_term").change(function(){
331 $("#id_term").css("border-color",bordercolor);
334 $("#filer_save").click(function(e){
336 reply = $("#id_term").val();
337 if(reply && reply.length) {
339 $('body').css('cursor', 'wait');
340 $.get('filer/' + id + '?term=' + reply, NavUpdate);
341 // if(timer) clearTimeout(timer);
342 // timer = setTimeout(NavUpdate,3000);
346 $("#id_term").css("border-color","#FF0000");
354 function jotClearLocation() {
355 $('#jot-coord').val('');
356 $('#profile-nolocation-wrapper').hide();
359 function addeditortext(data) {
360 if(plaintext == 'none') {
361 var currentText = $("#profile-jot-text").val();
362 $("#profile-jot-text").val(currentText + data);
365 tinyMCE.execCommand('mceInsertRawHTML',false,data);
371 var modal = $('#jot-modal').modal();
372 var jot = $("#profile-jot-form");
374 // Clear bs modal on close
375 // We need this to prevent that the modal displays old content
376 $('body').on('hidden.bs.modal', '#jot-modal', function () {
377 $(this).removeData('bs.modal');
378 $("#jot-content").append(jot);
382 .find('#jot-modal-body')
388 // the following functions show/hide the specific jot content
389 // in dependence of the selected nav
390 function aclActive() {
391 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content").hide();
392 $(".modal-body #profile-jot-acl-wrapper").show();
393 $("#jot-text-lnk, #jot-preview-lnk").parent("li").removeClass("active");
394 $("#jot-perms-lnk").parent("li").addClass("active");
397 function jotActive() {
398 $(".modal-body #profile-jot-acl-wrapper, .modal-body #jot-preview-content").hide();
399 $(".modal-body #profile-jot-wrapper").show();
400 $("#jot-perms-lnk, #jot-preview-lnk").parent("li").removeClass("active");
401 $("#jot-text-lnk").parent("li").addClass("active");
404 function previewActive() {
405 $(".modal-body #profile-jot-wrapper, .modal-body #profile-jot-acl-wrapper").hide();
406 $("#jot-text-lnk, #jot-perms-lnk").parent("li").removeClass("active");
407 $("#jot-preview-lnk").parent("li").addClass("active");