2 <script type="text/javascript" src="{{$baseurl}}/view/js/ajaxupload.js" ></script>
4 <script type="text/javascript">
8 function initEditor(callback) {
10 $("#profile-jot-text-loading").show();
11 $("#profile-jot-text-loading").hide();
12 //$("#profile-jot-text").addClass("profile-jot-text-full").removeClass("profile-jot-text-empty");
13 $("#jot-category").show();
14 $("#jot-category").addClass("jot-category-ex");
15 $("#jot-profile-jot-wrapper").show();
16 $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
17 $("#profile-jot-text").bbco_autocomplete('bbcode');
18 $("a#jot-perms-icon").colorbox({
20 'transition' : 'elastic'
22 $(".jothidden").show();
23 $("#profile-jot-text").keyup(function(){
24 var textlen = $(this).val().length;
25 $('#character-counter').text(textlen);
30 if (typeof callback != "undefined") {
35 function enableOnUser(){
40 <script type="text/javascript">
41 var ispublic = '{{$ispublic}}';
44 $(document).ready(function() {
46 /* enable editor on focus and click */
47 $("#profile-jot-text").focus(enableOnUser);
48 $("#profile-jot-text").click(enableOnUser);
50 // When clicking on a forum in acl we should remove the profile jot textarea
51 // default value before inserting the forum mention
52 $("body").on('click', '#jot-modal .acl-list-item.forum', function(){
53 jotTextOpenUI(document.getElementById("profile-jot-text"));
57 /* show images / file browser window
62 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
63 ///@todo this part isn't ideal and need to be done in a better way
64 jotTextOpenUI(document.getElementById("profile-jot-text"));
66 addeditortext(embedcode);
68 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
69 jotTextOpenUI(document.getElementById("profile-jot-text"));
71 addeditortext(embedcode);
74 $('#wall-image-upload').on('click', function(){
75 Dialog.doImageBrowser("main");
79 $('#wall-file-upload').on('click', function(){
80 Dialog.doFileBrowser("main");
85 function deleteCheckedItems() {
86 if(confirm('{{$delitems}}')) {
88 var ItemsToDelete = {};
90 $("#item-delete-selected").hide();
91 $('#item-delete-selected-rotator').show();
92 $('body').css('cursor', 'wait');
94 $('.item-select').each( function() {
95 if($(this).is(':checked')) {
96 if(checkedstr.length != 0) {
97 checkedstr = checkedstr + ',' + $(this).val();
98 var deleteItem = this.closest(".wall-item-container");
99 ItemsToDelete[deleteItem.id] = deleteItem;
102 checkedstr = $(this).val();
105 // Get the corresponding item container
106 var deleteItem = this.closest(".wall-item-container");
107 ItemsToDelete[deleteItem.id] = deleteItem;
111 // Fade the the the container from the items we want to delete
112 for(var key in ItemsToDelete) {
113 $(ItemsToDelete[key]).fadeTo('fast', 0.33);
116 $.post('item', { dropitems: checkedstr }, function(data) {
118 // Loop through the ItemsToDelete Object and remove
119 // corresponding item div
120 for(var key in ItemsToDelete) {
121 $(ItemsToDelete[key]).remove();
123 $('body').css('cursor', 'auto');
124 $('#item-delete-selected-rotator').hide();
129 function jotGetLink() {
130 var currentText = $("#profile-jot-text").val();
131 var noAttachment = '';
132 reply = prompt("{{$linkurl}}");
133 if(reply && reply.length) {
134 reply = bin2hex(reply);
135 $('#profile-rotator').show();
136 if (currentText.includes("[attachment") && currentText.includes("[/attachment]")) {
137 noAttachment = '&noAttachment=1';
139 $.get('parse_url?binurl=' + reply + noAttachment, function(data) {
141 $('#profile-rotator').hide();
143 autosize.update($("#profile-jot-text"));
147 function jotVideoURL() {
148 reply = prompt("{{$vidurl}}");
149 if(reply && reply.length) {
150 addeditortext('[video]' + reply + '[/video]');
154 function jotAudioURL() {
155 reply = prompt("{{$audurl}}");
156 if(reply && reply.length) {
157 addeditortext('[audio]' + reply + '[/audio]');
162 function jotGetLocation() {
163 reply = prompt("{{$whereareu}}", $('#jot-location').val());
164 if(reply && reply.length) {
165 $('#jot-location').val(reply);
169 function jotShare(id) {
170 $.get('share/' + id, function(data) {
171 // remove the former content of the text input
172 $("#profile-jot-text").val("");
173 initEditor(function(){
180 $("#jot-popup").show();
183 function linkDropper(event) {
184 var linkFound = event.dataTransfer.types.contains("text/uri-list");
186 event.preventDefault();
189 function linkDrop(event) {
190 var reply = event.dataTransfer.getData("text/uri-list");
191 var noAttachment = '';
192 event.target.textContent = reply;
193 event.preventDefault();
194 if(reply && reply.length) {
195 reply = bin2hex(reply);
196 $('#profile-rotator').show();
197 if (currentText.includes("[attachment") && currentText.includes("[/attachment]")) {
198 noAttachment = '&noAttachment=1';
200 $.get('parse_url?binurl=' + reply + noAttachment, function(data) {
201 if (!editor) $("#profile-jot-text").val("");
202 initEditor(function(){
204 $('#profile-rotator').hide();
207 autosize.update($("#profile-jot-text"));
211 function itemTag(id) {
212 reply = prompt("{{$term}}");
213 if(reply && reply.length) {
214 reply = reply.replace('#','');
218 $('body').css('cursor', 'wait');
220 $.get('tagger/' + id + '?term=' + reply);
221 if(timer) clearTimeout(timer);
222 timer = setTimeout(NavUpdate,3000);
228 function itemFiler(id) {
230 var bordercolor = $("input").css("border-color");
232 $.get('filer/', function(data){
233 $.colorbox({html:data});
234 $("#id_term").keypress(function(){
235 $(this).css("border-color",bordercolor);
237 $("#select_term").change(function(){
238 $("#id_term").css("border-color",bordercolor);
241 $("#filer_save").click(function(e){
243 reply = $("#id_term").val();
244 if(reply && reply.length) {
246 $('body').css('cursor', 'wait');
247 $.get('filer/' + id + '?term=' + reply, NavUpdate);
248 // if(timer) clearTimeout(timer);
249 // timer = setTimeout(NavUpdate,3000);
253 $("#id_term").css("border-color","#FF0000");
261 function jotClearLocation() {
262 $('#jot-coord').val('');
263 $('#profile-nolocation-wrapper').hide();
266 function addeditortext(data) {
268 var textfield = document.getElementById("profile-jot-text");
269 // check if the textfield does have the default-value
270 jotTextOpenUI(textfield);
271 // save already existent content
272 var currentText = $("#profile-jot-text").val();
273 //insert the data as new value
274 textfield.value = currentText + data;
275 autosize.update($("#profile-jot-text"));
281 var modal = $('#jot-modal').modal();
282 jotcache = $("#jot-sections");
284 // Auto focus on the first enabled field in the modal
285 modal.on('shown.bs.modal', function (e) {
286 $('#jot-modal-content').find('select:not([disabled]), input:not([type=hidden]):not([disabled]), textarea:not([disabled])').first().focus();
290 .find('#jot-modal-content')
295 // Activate the jot text section in the jot modal
296 function jotActive() {
297 // Make sure jot text does have really the active class (we do this because there are some
298 // other events which trigger jot text (we need to do this for the desktop and mobile
300 var elem = $("#jot-modal .jot-nav #jot-text-lnk");
301 var elemMobile = $("#jot-modal .jot-nav #jot-text-lnk-mobile")
302 toggleJotNav(elem[0]);
303 toggleJotNav(elemMobile[0]);