2 <script type="text/javascript" src="{{$baseurl}}/view/js/ajaxupload.js"></script>
3 <script type="text/javascript" src="{{$baseurl}}/view/js/linkPreview.js"></script>
4 <script type="text/javascript" src="{{$baseurl}}/view/theme/frio/js/jot.js"></script>
6 <script type="text/javascript">
10 function initEditor(callback) {
11 if (editor == false) {
12 $("#profile-jot-text-loading").show();
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 + '/search/acl');
19 $("#profile-jot-text").bbco_autocomplete('bbcode');
20 $("a#jot-perms-icon").colorbox({
22 'transition' : 'elastic'
24 $(".jothidden").show();
25 $("#profile-jot-text").keyup(function(){
26 var textlen = $(this).val().length;
27 $('#character-counter').text(textlen);
32 if (typeof callback != "undefined") {
37 function enableOnUser(){
42 <script type="text/javascript">
43 var ispublic = '{{$ispublic nofilter}}';
44 aStr.linkurl = '{{$linkurl}}';
47 $(document).ready(function() {
49 /* enable editor on focus and click */
50 $("#profile-jot-text").focus(enableOnUser);
51 $("#profile-jot-text").click(enableOnUser);
53 // When clicking on a forum in acl we should remove the profile jot textarea
54 // default value before inserting the forum mention
55 $("body").on('click', '#jot-modal .acl-list-item.forum', function(){
56 jotTextOpenUI(document.getElementById("profile-jot-text"));
60 /* show images / file browser window
65 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
66 ///@todo this part isn't ideal and need to be done in a better way
67 jotTextOpenUI(document.getElementById("profile-jot-text"));
69 addeditortext(embedcode);
71 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
72 jotTextOpenUI(document.getElementById("profile-jot-text"));
74 addeditortext(embedcode);
77 $('#wall-image-upload').on('click', function(){
78 Dialog.doImageBrowser("main");
82 $('#wall-file-upload').on('click', function(){
83 Dialog.doFileBrowser("main");
88 function deleteCheckedItems() {
89 if(confirm('{{$delitems}}')) {
91 var ItemsToDelete = {};
93 $("#item-delete-selected").hide();
94 $('#item-delete-selected-rotator').show();
95 $('body').css('cursor', 'wait');
97 $('.item-select').each( function() {
98 if($(this).is(':checked')) {
99 if(checkedstr.length != 0) {
100 checkedstr = checkedstr + ',' + $(this).val();
101 var deleteItem = this.closest(".wall-item-container");
102 ItemsToDelete[deleteItem.id] = deleteItem;
105 checkedstr = $(this).val();
108 // Get the corresponding item container
109 var deleteItem = this.closest(".wall-item-container");
110 ItemsToDelete[deleteItem.id] = deleteItem;
114 // Fade the the the container from the items we want to delete
115 for(var key in ItemsToDelete) {
116 $(ItemsToDelete[key]).fadeTo('fast', 0.33);
119 $.post('item', { dropitems: checkedstr }, function(data) {
121 // Loop through the ItemsToDelete Object and remove
122 // corresponding item div
123 for(var key in ItemsToDelete) {
124 $(ItemsToDelete[key]).remove();
126 $('body').css('cursor', 'auto');
127 $('#item-delete-selected-rotator').hide();
132 function jotVideoURL() {
133 reply = prompt("{{$vidurl}}");
134 if(reply && reply.length) {
135 addeditortext('[video]' + reply + '[/video]');
139 function jotAudioURL() {
140 reply = prompt("{{$audurl}}");
141 if(reply && reply.length) {
142 addeditortext('[audio]' + reply + '[/audio]');
146 function jotGetLocation() {
147 reply = prompt("{{$whereareu}}", $('#jot-location').val());
148 if(reply && reply.length) {
149 $('#jot-location').val(reply);
153 function jotShare(id) {
154 $.get('share/' + id, function(data) {
155 // remove the former content of the text input
156 $("#profile-jot-text").val("");
157 initEditor(function(){
164 $("#jot-popup").show();
167 function linkDropper(event) {
168 var linkFound = event.dataTransfer.types.contains("text/uri-list");
170 event.preventDefault();
173 function linkDrop(event) {
174 var reply = event.dataTransfer.getData("text/uri-list");
175 var noAttachment = '';
176 event.target.textContent = reply;
177 event.preventDefault();
178 if(reply && reply.length) {
179 reply = bin2hex(reply);
180 $('#profile-rotator').show();
181 if (currentText.includes("[attachment") && currentText.includes("[/attachment]")) {
182 noAttachment = '&noAttachment=1';
184 $.get('parse_url?binurl=' + reply + noAttachment, function(data) {
185 if (!editor) $("#profile-jot-text").val("");
186 initEditor(function(){
188 $('#profile-rotator').hide();
191 autosize.update($("#profile-jot-text"));
195 function itemTag(id) {
196 reply = prompt("{{$term}}");
197 if(reply && reply.length) {
198 reply = reply.replace('#','');
202 $('body').css('cursor', 'wait');
204 $.get('tagger/' + id + '?term=' + reply);
205 if(timer) clearTimeout(timer);
206 timer = setTimeout(NavUpdate,3000);
212 function itemFiler(id) {
213 var bordercolor = $("input").css("border-color");
215 $.get('filer/', function(data){
216 $.colorbox({html:data});
217 $("#id_term").keypress(function(){
218 $(this).css("border-color",bordercolor);
220 $("#select_term").change(function(){
221 $("#id_term").css("border-color",bordercolor);
224 $("#filer_save").click(function(e){
226 reply = $("#id_term").val();
227 if(reply && reply.length) {
229 $('body').css('cursor', 'wait');
230 $.get('filer/' + id + '?term=' + reply, NavUpdate);
231 // if(timer) clearTimeout(timer);
232 // timer = setTimeout(NavUpdate,3000);
236 $("#id_term").css("border-color","#FF0000");
244 function jotClearLocation() {
245 $('#jot-coord').val('');
246 $('#profile-nolocation-wrapper').hide();
249 function addeditortext(data) {
251 var textfield = document.getElementById("profile-jot-text");
252 // check if the textfield does have the default-value
253 jotTextOpenUI(textfield);
254 // save already existent content
255 var currentText = $("#profile-jot-text").val();
256 //insert the data as new value
257 textfield.value = currentText + data;
258 autosize.update($("#profile-jot-text"));
264 var modal = $('#jot-modal').modal();
265 jotcache = $("#jot-sections");
267 // Auto focus on the first enabled field in the modal
268 modal.on('shown.bs.modal', function (e) {
269 $('#jot-modal-content').find('select:not([disabled]), input:not([type=hidden]):not([disabled]), textarea:not([disabled])').first().focus();
273 .find('#jot-modal-content')
277 // Jot attachment live preview.
278 linkPreview = $('#profile-jot-text').linkPreview();
281 // Activate the jot text section in the jot modal
282 function jotActive() {
283 // Make sure jot text does have really the active class (we do this because there are some
284 // other events which trigger jot text (we need to do this for the desktop and mobile
286 var elem = $("#jot-modal .jot-nav #jot-text-lnk");
287 var elemMobile = $("#jot-modal .jot-nav #jot-text-lnk-mobile")
288 toggleJotNav(elem[0]);
289 toggleJotNav(elemMobile[0]);