3 {{*<script language="javascript" type="text/javascript">*}}
9 var plaintext = '{{$editselect}}';
11 function initEditor(cb){
13 $("#profile-jot-text-loading").show();
14 if(plaintext == 'none') {
15 $("#profile-jot-text-loading").hide();
16 //$("#profile-jot-text").addClass("profile-jot-text-full").removeClass("profile-jot-text-empty");
17 $("#jot-category").show();
18 $("#jot-category").addClass("jot-category-ex");
19 $("#jot-profile-jot-wrapper").show();
20 $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
21 $("#profile-jot-text").bbco_autocomplete('bbcode');
23 $("a#jot-perms-icon").colorbox({
25 'transition' : 'elastic'
27 $(".jothidden").show();
28 if (typeof cb!="undefined") cb();
33 mode : "specific_textareas",
34 editor_selector: {{$editselect}},
35 auto_focus: "profile-jot-text",
36 plugins : "bbcode,paste,autoresize, inlinepopups",
37 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
38 theme_advanced_buttons2 : "",
39 theme_advanced_buttons3 : "",
40 theme_advanced_toolbar_location : "top",
41 theme_advanced_toolbar_align : "center",
42 theme_advanced_blockformats : "blockquote,code",
43 theme_advanced_resizing : true,
44 gecko_spellcheck : true,
45 paste_text_sticky : true,
46 entity_encoding : "raw",
47 add_unload_trigger : false,
48 remove_linebreaks : false,
49 //force_p_newlines : false,
50 //force_br_newlines : true,
51 forced_root_block : 'div',
53 content_css: "{{$baseurl}}/view/custom_tinymce.css",
54 theme_advanced_path : false,
55 file_browser_callback : "fcFileBrowser",
56 setup : function(ed) {
58 ed.onKeyDown.add(function(ed,e) {
63 ed.onKeyUp.add(function(ed, e) {
64 var txt = tinyMCE.activeEditor.getContent();
65 match = txt.match(/@([^ \n]+)$/);
68 cPopup = new ACPopup(this,baseurl+"/acl");
70 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
71 if(! cPopup.ready) cPopup = null;
74 if(cPopup !== null) { cPopup.close(); cPopup = null; }
78 if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
79 $('#profile-jot-desc').html(ispublic);
82 $('#profile-jot-desc').html(' ');
88 $('#character-counter').removeClass('red');
89 $('#character-counter').removeClass('orange');
90 $('#character-counter').addClass('grey');
92 if((textlen > 140) && (textlen <= 420)) {
93 $('#character-counter').removeClass('grey');
94 $('#character-counter').removeClass('red');
95 $('#character-counter').addClass('orange');
98 $('#character-counter').removeClass('grey');
99 $('#character-counter').removeClass('orange');
100 $('#character-counter').addClass('red');
102 $('#character-counter').text(textlen);
105 ed.onInit.add(function(ed) {
106 ed.pasteAsPlainText = true;
107 $("#profile-jot-text-loading").hide();
108 $(".jothidden").show();
109 if (typeof cb!="undefined") cb();
118 $("a#jot-perms-icon").colorbox({
120 'transition' : 'elastic'
124 if (typeof cb!="undefined") cb();
128 function enableOnUser(){
138 <script type="text/javascript" src="{{$baseurl}}/js/ajaxupload.js" ></script>
140 var ispublic = '{{$ispublic}}';
143 $(document).ready(function() {
145 /* enable tinymce on focus and click */
146 $("#profile-jot-text").focus(enableOnUser);
147 $("#profile-jot-text").click(enableOnUser);
152 /* show images / file browser window
157 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
158 ///@todo this part isn't ideal and need to be done in a better way
159 jotTextOpenUI(document.getElementById("profile-jot-text"));
161 addeditortext(embedcode);
163 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
164 jotTextOpenUI(document.getElementById("profile-jot-text"));
166 addeditortext(embedcode);
169 $('#wall-image-upload').on('click', function(){
170 Dialog.doImageBrowser("main");
174 $('#wall-file-upload').on('click', function(){
175 Dialog.doFileBrowser("main");
180 var uploader = new window.AjaxUpload(
182 { action: 'wall_upload/{{$nickname}}',
184 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
185 onComplete: function(file,response) {
186 addeditortext(response);
187 $('#profile-rotator').hide();
191 var file_uploader = new window.AjaxUpload(
193 { action: 'wall_attach/{{$nickname}}',
195 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
196 onComplete: function(file,response) {
197 addeditortext(response);
198 $('#profile-rotator').hide();
207 function deleteCheckedItems() {
208 if(confirm('{{$delitems}}')) {
210 var ItemsToDelete = {};
212 $("#item-delete-selected").hide();
213 $('#item-delete-selected-rotator').show();
214 $('body').css('cursor', 'wait');
216 $('.item-select').each( function() {
217 if($(this).is(':checked')) {
218 if(checkedstr.length != 0) {
219 checkedstr = checkedstr + ',' + $(this).val();
220 var deleteItem = this.closest(".wall-item-container");
221 ItemsToDelete[deleteItem.id] = deleteItem;
224 checkedstr = $(this).val();
227 // Get the corresponding item container
228 var deleteItem = this.closest(".wall-item-container");
229 ItemsToDelete[deleteItem.id] = deleteItem;
233 // Fade the the the container from the items we want to delete
234 for(var key in ItemsToDelete) {
235 $(ItemsToDelete[key]).fadeTo('fast', 0.33);
238 $.post('item', { dropitems: checkedstr }, function(data) {
240 // Loop through the ItemsToDelete Object and remove
241 // corresponding item div
242 for(var key in ItemsToDelete) {
243 $(ItemsToDelete[key]).remove();
245 $('body').css('cursor', 'auto');
246 $('#item-delete-selected-rotator').hide();
251 function jotGetLink() {
252 reply = prompt("{{$linkurl}}");
253 if(reply && reply.length) {
254 reply = bin2hex(reply);
255 $('#profile-rotator').show();
256 $.get('parse_url?binurl=' + reply, function(data) {
258 $('#profile-rotator').hide();
263 function jotVideoURL() {
264 reply = prompt("{{$vidurl}}");
265 if(reply && reply.length) {
266 addeditortext('[video]' + reply + '[/video]');
270 function jotAudioURL() {
271 reply = prompt("{{$audurl}}");
272 if(reply && reply.length) {
273 addeditortext('[audio]' + reply + '[/audio]');
278 function jotGetLocation() {
279 reply = prompt("{{$whereareu}}", $('#jot-location').val());
280 if(reply && reply.length) {
281 $('#jot-location').val(reply);
285 function jotShare(id) {
286 // if ($('#jot-popup').length != 0) $('#jot-popup').show();
288 // $('#like-rotator-' + id).show();
289 // $.get('share/' + id, function(data) {
290 // if (!editor) $("#profile-jot-text").val("");
291 // initEditor(function(){
292 // addeditortext(data);
293 // $('#like-rotator-' + id).hide();
294 // $(window).scrollTop(0);
299 $.get('share/' + id, function(data) {
300 if (!editor) $("#profile-jot-text").val("");
301 initEditor(function(){
308 $("#jot-popup").show();
311 function linkdropper(event) {
312 var linkFound = event.dataTransfer.types.contains("text/uri-list");
314 event.preventDefault();
317 function linkdrop(event) {
318 var reply = event.dataTransfer.getData("text/uri-list");
319 event.target.textContent = reply;
320 event.preventDefault();
321 if(reply && reply.length) {
322 reply = bin2hex(reply);
323 $('#profile-rotator').show();
324 $.get('parse_url?binurl=' + reply, function(data) {
325 if (!editor) $("#profile-jot-text").val("");
326 initEditor(function(){
328 $('#profile-rotator').hide();
334 function itemTag(id) {
335 reply = prompt("{{$term}}");
336 if(reply && reply.length) {
337 reply = reply.replace('#','');
341 $('body').css('cursor', 'wait');
343 $.get('tagger/' + id + '?term=' + reply);
344 if(timer) clearTimeout(timer);
345 timer = setTimeout(NavUpdate,3000);
351 function itemFiler(id) {
353 var bordercolor = $("input").css("border-color");
355 $.get('filer/', function(data){
356 $.colorbox({html:data});
357 $("#id_term").keypress(function(){
358 $(this).css("border-color",bordercolor);
360 $("#select_term").change(function(){
361 $("#id_term").css("border-color",bordercolor);
364 $("#filer_save").click(function(e){
366 reply = $("#id_term").val();
367 if(reply && reply.length) {
369 $('body').css('cursor', 'wait');
370 $.get('filer/' + id + '?term=' + reply, NavUpdate);
371 // if(timer) clearTimeout(timer);
372 // timer = setTimeout(NavUpdate,3000);
376 $("#id_term").css("border-color","#FF0000");
384 function jotClearLocation() {
385 $('#jot-coord').val('');
386 $('#profile-nolocation-wrapper').hide();
389 function addeditortext(data) {
390 if(plaintext == 'none') {
391 var currentText = $("#profile-jot-text").val();
392 $("#profile-jot-text").val(currentText + data);
395 tinyMCE.execCommand('mceInsertRawHTML',false,data);
401 var modal = $('#jot-modal').modal();
402 var jot = $("#profile-jot-form");
404 // Clear bs modal on close
405 // We need this to prevent that the modal displays old content
406 $('body').on('hidden.bs.modal', '#jot-modal', function () {
407 $(this).removeData('bs.modal');
408 $("#jot-content").append(jot);
412 .find('#jot-modal-body')
418 // the following functions show/hide the specific jot content
419 // in dependence of the selected nav
420 function aclActive() {
421 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();
422 $(".modal-body #profile-jot-acl-wrapper").show();
426 function previewActive() {
427 $(".modal-body #profile-jot-wrapper, .modal-body #profile-jot-acl-wrapper,.modal-body #jot-fbrowser-wrapper").hide();
431 function jotActive() {
432 $(".modal-body #profile-jot-acl-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();
433 $(".modal-body #profile-jot-wrapper").show();
435 //make sure jot text does have really the active class (we do this because there are some
436 // other events which trigger jot text
437 toggleJotNav($("#jot-modal .jot-nav #jot-text-lnk"));
440 function fbrowserActive() {
441 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #profile-jot-acl-wrapper").hide();
443 $(".modal-body #jot-fbrowser-wrapper").show();
445 $(function() {Dialog.showJot();});