/** Include JSON library **/ var JSON; if (!JSON) { JSON = {} } (function() { function str(a, b) { var c, d, e, f, g = gap, h, i = b[a]; if (i && typeof i === "object" && typeof i.toJSON === "function") { i = i.toJSON(a) } if (typeof rep === "function") { i = rep.call(b, a, i) } switch (typeof i) { case"string": return quote(i); case"number": return isFinite(i) ? String(i) : "null"; case"boolean": case"null": return String(i); case"object": if (!i) { return"null" } gap += indent; h = []; if (Object.prototype.toString.apply(i) === "[object Array]") { f = i.length; for (c = 0; c < f; c += 1) { h[c] = str(c, i) || "null" } e = h.length === 0 ? "[]" : gap ? "[\n" + gap + h.join(",\n" + gap) + "\n" + g + "]" : "[" + h.join(",") + "]"; gap = g; return e } if (rep && typeof rep === "object") { f = rep.length; for (c = 0; c < f; c += 1) { if (typeof rep[c] === "string") { d = rep[c]; e = str(d, i); if (e) { h.push(quote(d) + (gap ? ": " : ":") + e) } } } } else { for (d in i) { if (Object.prototype.hasOwnProperty.call(i, d)) { e = str(d, i); if (e) { h.push(quote(d) + (gap ? ": " : ":") + e) } } } } e = h.length === 0 ? "{}" : gap ? "{\n" + gap + h.join(",\n" + gap) + "\n" + g + "}" : "{" + h.join(",") + "}"; gap = g; return e } } function quote(a) { escapable.lastIndex = 0; return escapable.test(a) ? '"' + a.replace(escapable, function(a) { var b = meta[a]; return typeof b === "string" ? b : "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4) }) + '"' : '"' + a + '"' } function f(a) { return a < 10 ? "0" + a : a } "use strict"; if (typeof Date.prototype.toJSON !== "function") { Date.prototype.toJSON = function(a) { return isFinite(this.valueOf()) ? this.getUTCFullYear() + "-" + f(this.getUTCMonth() + 1) + "-" + f(this.getUTCDate()) + "T" + f(this.getUTCHours()) + ":" + f(this.getUTCMinutes()) + ":" + f(this.getUTCSeconds()) + "Z" : null }; String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function(a) { return this.valueOf() } } var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta = {"\b": "\\b", "\t": "\\t", "\n": "\\n", "\f": "\\f", "\r": "\\r", '"': '\\"', "\\": "\\\\"}, rep; if (typeof JSON.stringify !== "function") { JSON.stringify = function(a, b, c) { var d; gap = ""; indent = ""; if (typeof c === "number") { for (d = 0; d < c; d += 1) { indent += " " } } else if (typeof c === "string") { indent = c } rep = b; if (b && typeof b !== "function" && (typeof b !== "object" || typeof b.length !== "number")) { throw new Error("JSON.stringify") } return str("", {"": a}) } } if (typeof JSON.parse !== "function") { JSON.parse = function(text, reviver) { function walk(a, b) { var c, d, e = a[b]; if (e && typeof e === "object") { for (c in e) { if (Object.prototype.hasOwnProperty.call(e, c)) { d = walk(e, c); if (d !== undefined) { e[c] = d } else { delete e[c] } } } } return reviver.call(a, b, e) } var j; text = String(text); cx.lastIndex = 0; if (cx.test(text)) { text = text.replace(cx, function(a) { return"\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4) }) } if (/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]").replace(/(?:^|:|,)(?:\s*\[)+/g, ""))) { j = eval("(" + text + ")"); return typeof reviver === "function" ? walk({"": j}, "") : j } throw new SyntaxError("JSON.parse") } } })() /** END JSON Object **/ // In the case where our joms.jQuery // is overriden by other jQuery. if (typeof (joms) == 'undefined') { // We will recreate our joms namespace // with joms.jQuery pointing to their jQuery. joms = { jQuery: window.jQuery, extend: function(obj) { this.jQuery.extend(this, obj); } } } var joms_message_sending = false; joms.extend({ plugins: { extend: function(obj) { joms.jQuery.extend(joms.plugins, obj); }, initialize: function() { joms.jQuery.each(joms.plugins, function(index, value) { try { value.initialize(); } catch (err) { //Handle errors here } }); } }, sharebox: { showFileUpload: function(type, id) { var ajaxCall = 'jax.call("community", "files,ajaxFileUploadForm","' + type + '",' + id + ')'; cWindowShow(ajaxCall, '', 600, 400); }, uploadVideo: function(creatortype, groupid) { var ajaxCall = "jax.call('community', 'videos,ajaxUploadVideo', '" + creatortype + "', '" + groupid + "');"; cWindowShow(ajaxCall, '', 450, 500); } }, activities: { infiniteScrollLoaded: 0, infinitesScrollenable: 1, init: function() { // Capture activity delete button joms.jQuery('#activity-stream-container').on( 'click', '.dropdown-menu [data-action=delete]', function( e ) { e.preventDefault(); var li = joms.jQuery( e.target ).closest('[data-streamid]'); joms.activities.remove('', li.data('streamid')); }); // Initialize map joms.activities.initMap(); // Start auto update joms.activities.loadNewStream(); // Initialize infinite scroll. if ( joms.activities.infinitesScrollenable && !joms.activities.infiniteScrollLoaded ) { joms.activities.infiniteScroll(); } }, showMap: function(id, addr) { // this function can be used in multiple places. so we need to detect where are we // check if we're in any activity streams if (joms.jQuery('li[data-streamid=' + id + ']').find('.cMapHeatzone').length == 0) { var mapWidth = joms.jQuery('li[data-streamid=' + id + ']').find('.cStream-Actions').width(); var mapHTML = '
'; mapHTML += '
'; mapHTML += '
'; mapHTML += ''; mapHTML += ''; mapHTML += ''; mapHTML += '
'; joms.jQuery('#newsfeed-map-' + id + ' .newsfeed-mapFade').append(mapHTML); joms.jQuery('li[data-streamid=' + id + ']').find('.cStream-Actions').prepend(mapHTML); // Reposition the heatzone var heatLeft = (mapWidth / 2) - 15; joms.jQuery('li[data-streamid=' + id + ']').find('.cMapHeatzone').css({ 'top': '40px', left: heatLeft + 'px' }); joms.maps.init(); } //check if we're in video page if (joms.jQuery('#video-' + id).length) { var mapWidth = joms.jQuery('#video-' + id).find('.video-map-location').width(); var mapHTML = ''; if (joms.jQuery('.video-map').height() == 0) { joms.jQuery('#video-' + id).find('.video-map-location').html(mapHTML); joms.jQuery('#video-' + id).find('.video-map').css({height: 'auto'}); } else { joms.jQuery('#video-' + id).find('.video-map-location').html(''); joms.jQuery('#video-' + id).find('.video-map').css({height: 'auto'}); } } }, getContent: function(activityId) { jax.call('community', 'activities,ajaxGetContent', activityId); }, setContent: function(activityId, content) { joms.jQuery("#profile-newsfeed-item-content-" + activityId).html(content) .removeClass("small profile-newsfeed-item-action").addClass("newsfeed-content-hidden").slideDown(); }, showVideo: function(activityId) { joms.jQuery('#profile-newsfeed-item-content-' + activityId + ' .video-object').slideDown(); joms.jQuery('#profile-newsfeed-item-content-' + activityId + ' .video-object embed').css('width', joms.jQuery('#profile-newsfeed-item-content-' + activityId).width()); }, selectCustom: function(type) { if (type == 'predefined') { joms.jQuery('#custom-text').css('display', 'none'); joms.jQuery('#custom-predefined').css('display', 'block'); } else { joms.jQuery('#custom-text').css('display', 'block'); joms.jQuery('#custom-predefined').css('display', 'none'); } }, addCustom: function() { if (joms.jQuery('input[name=custom-message]:checked').val() == 'predefined') { var selected = joms.jQuery('#custom-predefined').val(); var selectedText = joms.jQuery('#custom-predefined :selected').html(); if (selected != 'default') { jax.call('community', 'activities,ajaxAddPredefined', selected, selectedText); } } else { customText = joms.jQuery.trim(joms.jQuery('#custom-text').val()); if (customText.length != 0) { jax.call('community', 'activities,ajaxAddPredefined', 'system.message', customText); } } }, append: function(html) { // Filter only the list var data = joms.jQuery(html).find('ul.cStreamList li'); joms.jQuery('#activity-more,#activity-exclusions').remove(); joms.jQuery('#activity-stream-container ul.cStreamList').append(html); joms.jQuery('body').focus(); }, initMap: function() { if (joms.jQuery('.newsfeed-mapFade') != null || joms.jQuery('.newsfeed-map-heatzone') != null) { if (joms.jQuery('.newsfeed-mapFade').length) { joms.jQuery('.newsfeed-mapFade').live('mouseover', function(e) { joms.jQuery(this).find('img:eq(2)').fadeOut(0); }); joms.jQuery('.newsfeed-mapFade').live('mouseout', function(e) { joms.jQuery(this).find('img:eq(2)').fadeIn(0); }); joms.jQuery('.newsfeed-map-heatzone').live('mouseover', function(e) { joms.jQuery(this).parent().find('img:eq(1)').fadeOut(); }); joms.jQuery('.newsfeed-map-heatzone').live('mouseout', function(e) { joms.jQuery(this).parent().find('img:eq(1)').fadeIn(0); }); } } }, /** * Load more stream post at the bottom of the stream list */ more: function() { // List object var stream = joms.jQuery('.cMain > #activity-stream-container ul.list-unstyled'); //Get stream of group & event if (stream.length <= 0) stream = joms.jQuery('#activity-stream-container ul.list-unstyled'); // Retrieve the earliest activity id to exclude the activity var exclusions = ''; if (stream.find('li[data-streamid]').length > 0) { exclusions = stream.find('li[data-streamid]').last().data('streamid'); } //check if this is group/event var apptype = ''; var appid = ''; if (joms.jQuery('#apptype').length > 0) { apptype = joms.jQuery('#apptype').val(); } if (joms.jQuery('#appid').length > 0) { appid = joms.jQuery('#appid').val(); } // Stream filter type stored as 'data' in the main list var filter = stream.data('filter'); var filterId = stream.data('filterid'); // Show loading image joms.jQuery('#activity-more .btn').hide(); joms.jQuery('#activity-more .loading').show(); jax.call('community', 'activities,ajaxGetOlderActivities', exclusions, filter, filterId, stream.data('filter-value')); }, // Append the new stream data to the top prependOldStream: function(html) { //Get container container = joms.jQuery('.cMain > #activity-stream-container'); //Get group & event container if (container.length <= 0) container = joms.jQuery('#activity-stream-container'); // var btn = container.find('#activity-more'); // btn.prev('ul').append( html ); joms.jQuery( html ).children('li').appendTo('.cMain #activity-stream-container > ul.list-unstyled'); container.find('#activity-more .loading').hide(); // Show "more" button or clear scroll delay. if ( !joms.activities.infiniteScrollLoaded ) { joms.jQuery('#activity-more .btn').show(); } else { setTimeout(function() { joms.activities.infiniteScrollDelay = 0; }, 1000 ); } }, /** * Once called, query the server and return the most recent items. */ loadNewStream: function() { if (joms.jQuery('.joms-latest-activities-container').data('actid') > -1) { joms.jQuery('.joms-latest-activities-container').css('display', 'none'); return; } // Ajax call to just find out how many new items there is var stream = joms.jQuery('#activity-stream-container ul'); // Disable cWindow loading function jax.loadingFunction = function() { } var tmpArray = new Array(); var i = 0 joms.jQuery('#activity-stream-container > ul li').each(function(){ if( joms.jQuery(this).data('streamid') ){ tmpArray[i] = joms.jQuery(this).data('streamid'); i++; } }); tmpArray.sort(function(a,b){return b - a}) jax.call('community', 'activities,ajaxGetRecentActivitiesCount', tmpArray[0], stream.data('filter'), stream.data('filterid'), stream.data('filter-value') ); }, /* Show the "new updates available message" and queue the next message query */ announceNewStream: function(count, nextPing, textMessage) { if (joms.jQuery('.joms-latest-activities-container').data('actid') > -1) { joms.jQuery('.joms-latest-activities-container').css('display', 'none'); return; } // If there is any new stream, annouce it at the top of the stream l, if (count > 0) { joms.jQuery('.joms-latest-activities-container') .html('
' + textMessage + '
') .show(); } else { // Hide the announcement joms.jQuery('.joms-latest-activities-container').hide(); } // Only check if auto-refresh is enabled if (nextPing != 0) setTimeout('joms.activities.loadNewStream()', nextPing); }, // Append the new stream data to the top appendNewStream: function(html, nextPing) { // Hide the announcement joms.jQuery('.joms-latest-activities-container').hide().empty(); // Prepend data. joms.jQuery( html ).children('li').prependTo('.cMain #activity-stream-container > ul.list-unstyled'); }, // User wanted to see the rest of the new stream items showNewStream: function() { var stream = joms.jQuery('#activity-stream-container ul.list-unstyled'); jax.call('community', 'activities,ajaxGetRecentActivities',stream.find('li[data-streamid]').first().data('streamid'),stream.data('filter'),stream.data('filterid'),stream.data('filter-value')); return false; }, remove: function(app, activityid) { var ajaxCall = "jax.call('community', 'activities,ajaxConfirmDeleteActivity', '" + app + "', '" + activityid + "');"; cWindowShow(ajaxCall, '', 450, 100); }, editLocation: function(activityid) { var ajaxCall = "jax.call('community', 'activities,ajaxeditLocation', '" + activityid + "');"; cWindowShow(ajaxCall, '', 450, 100); }, saveLocation: function(activityid,elem){ var ct = joms.jQuery('#cWindow').find('#editlocation'), input = ct.find('#editlocation-selector input'), map = ct.find('#editlocation-map'), name = input.val(), lat = map.data('lat'), lng = map.data('lng'); if ( !name || !lat || !lng ) return; jax.call( 'community','activities,ajaxSaveLocation', activityid, name, lat, lng ); }, removeLocation: function(activityid){ var ajaxCall = "jax.call('community', 'activities,ajaxRemoveLocation', '" + activityid + "');"; cWindowShow(ajaxCall, '', 450, 100); }, infiniteScroll: function () { if ( joms.activities.infiniteScrollLoaded ) return; // Disable infinite scroll on mobile. var ua = navigator.userAgent.toLowerCase(); var mobile = !!ua.match( /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i ); if ( mobile ) return; // Cache window and document for faster access. var win = joms.jQuery( window ), doc = joms.jQuery( document ); // Hide "more" button. joms.jQuery('#activity-more .btn').show(); win.on( 'scroll', function() { if ( win.scrollTop() == doc.height() - win.height() ) { if ( joms.activities.infiniteScrollDelay ) return; joms.activities.infiniteScrollDelay = 1; joms.activities.more(); // reset delay flag in case of request timeout setTimeout(function() { joms.activities.infiniteScrollDelay = 0; }, 10000 ); } }); // Update infinite scroll flag. joms.activities.infiniteScrollLoaded = 1; } }, apps: { windowTitle: '', toggle: function(id) { joms.jQuery(id).children('.app-box-actions').slideToggle('fast'); joms.jQuery(id).children('.app-box-footer').slideToggle('fast'); joms.jQuery(id).children('.app-box-content').slideToggle('fast', function() { joms.jQuery.cookie(id, joms.jQuery(this).css('display')); } ); }, showAboutWindow: function(appName) { var ajaxCall = "jax.call('community', 'apps,ajaxShowAbout', '" + appName + "');"; cWindowShow(ajaxCall, '', 450, 100); }, showPrivacyWindow: function(appName) { var ajaxCall = "jax.call('community', 'apps,ajaxShowPrivacy', '" + appName + "');"; cWindowShow(ajaxCall, '', 450, 100); }, showSettingsWindow: function(id, appName) { var ajaxCall = "jax.call('community', 'apps,ajaxShowSettings', '" + id + "', '" + appName + "');"; cWindowShow(ajaxCall, '', 450, 100); }, savePrivacy: function() { var value = joms.jQuery('input[name=privacy]:checked').val(); var appName = joms.jQuery('input[name=appname]').val(); jax.call('community', 'apps,ajaxSavePrivacy', appName, value); }, saveSettings: function() { jax.call('community', 'apps,ajaxSaveSettings', jax.getFormValues('appSetting')); }, remove: function(appName) { var ajaxCall = "jax.call('community', 'apps,ajaxRemove', '" + appName + "');"; cWindowShow(ajaxCall, this.windowTitle, 450, 100); }, add: function(appName) { jax.call('community', 'apps,ajaxAdd', appName); }, initToggle: function() { joms.jQuery('.app-box').each(function() { var id = '#' + joms.jQuery(this).attr('id'); if (joms.jQuery.cookie(id) == 'none') { joms.jQuery(id).addClass('collapse'); joms.jQuery(id).children('.app-box-actions').css('display', 'none'); joms.jQuery(id).children('.app-box-footer').css('display', 'none'); joms.jQuery(id).children('.app-box-content').css('display', 'none'); } }); } }, bookmarks: { show: function(currentURI) { var ajaxCall = "jax.call('community', 'bookmarks,ajaxShowBookmarks','" + currentURI + "');"; cWindowShow(ajaxCall, '', 450, 100); }, email: function(currentURI) { var formContent = jax.getFormValues('bookmarks-email'); var content = formContent[1][1]; var email = formContent[0][1]; var ajaxCall = "jax.call('community', 'bookmarks,ajaxEmailPage','" + currentURI + "','" + email + "',\"" + content + "\");"; cWindowShow(ajaxCall, '', 450, 100); } }, report: { emptyMessage: '', checkReport: function() { if (joms.jQuery('#report-message').val() == '') { joms.jQuery('#report-message-error').html(this.emptyMessage).css('color', 'red'); return false; } return true; }, showWindow: function(reportFunc, arguments) { var ajaxCall = 'jax.call("community" , "system,ajaxReport" , "' + reportFunc + '","' + location.href + '" ,' + arguments + ');'; cWindowShow(ajaxCall, '', 450, 100); }, submit: function(reportFunc, pageLink, arguments) { if (joms.report.checkReport()) { var formVars = jax.getFormValues('report-form'); var ajaxcall = 'jax.call("community", "system,ajaxSendReport","' + reportFunc + '","' + location.href + '","' + formVars[1][1] + '" , ' + arguments + ')'; cWindowShow(ajaxcall, '', 450, 100); } } }, featured: { add: function(uniqueId, controller) { var ajaxCall = "jax.call('community', '" + controller + ",ajaxAddFeatured', '" + uniqueId + "');"; cWindowShow(ajaxCall, '', 450, 100); }, remove: function(uniqueId, controller) { var ajaxCall = "jax.call('community','" + controller + ",ajaxRemoveFeatured','" + uniqueId + "');"; cWindowShow(ajaxCall, '', 450, 100); } }, flash: { enabled: function() { // ie try { try { // avoid fp6 minor version lookup issues // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); try { axo.AllowScriptAccess = 'always'; } catch (e) { return '6,0,0'; } } catch (e) { } return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; // other browsers } catch (e) { try { if (navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) { return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; } } catch (e) { } } return false; } }, invitation: { showForm: function(users, callback, cid, displayFriends, displayEmail) { var ajaxCall = 'jax.call("community", "system,ajaxShowInvitationForm","' + users + '","' + callback + '","' + cid + '","' + displayFriends + '","' + displayEmail + '")'; var height = 520; height = displayFriends != "0" ? height : height - 108; height = displayEmail != "0" ? height : height - 108; cWindowShow(ajaxCall, '', 550, height); }, send: function(callback, cid) { var form = joms.jQuery('#community-invitation-form'), values = form.serializeArray(), friends = [], params = []; if ( values && values.length ) { for ( var i = 0, val; i < values.length; i++ ) { val = values[i]; if ( val.name === 'friends[]' && friends.indexOf( val.value ) < 0 ) friends.push( val.value ); } } params.push([ 'friendsearch', form.find('[name=friendsearch]').val() ]); params.push([ 'emails', form.find('[name=emails]').val() ]); params.push([ 'message', form.find('[name=message]').val() ]); friends.length && params.push([ 'friends', friends.join(',') ]); jax.call('community', 'system,ajaxSubmitInvitation', callback, cid, params); }, selectMember: function(element) { joms.jQuery('#community-invited-list ' + element).remove(); if (joms.jQuery(element + ' input').is(':checked')) { joms.jQuery(element).clone().appendTo('#community-invited-list'); //joms.jQuery(element).remove(); joms.jQuery(element).addClass('invitation-item-invited').children('.invitation-checkbox').show(); } }, selectMemberUnique: function(element) { if (joms.jQuery(element + ' input').is(':checked')) { joms.jQuery('#community-invited-list').empty(); joms.jQuery(element).clone().appendTo('#community-invited-list'); joms.jQuery(element).remove(); joms.jQuery(element).addClass('invitation-item-invited').children('.invitation-checkbox').show(); } else { joms.jQuery(element).remove(); } }, filterMember: function() { joms.jQuery('#community-invitation-list li').each(function(index) { element = joms.jQuery(this).attr('id'); if (joms.jQuery('#community-invited-list #' + element).is('li')) { joms.jQuery(this).remove(); } //check the selected friend list if (joms.jQuery('#inbox-selected-to').length > 0) { if (joms.jQuery('#inbox-selected-to #' + element).is('li')) { joms.jQuery(this).remove(); } } }); }, showResult: function() { joms.jQuery('#cInvitationTabContainer div').removeClass('active'); joms.jQuery('#cInvitationTabContainer #community-invitation').addClass('active'); }, showSelected: function() { joms.jQuery('#cInvitationTabContainer div').removeClass('active'); joms.jQuery('#cInvitationTabContainer #community-invited').addClass('active'); }, selectNone: function(listID) { joms.jQuery(listID).find('li').each(function() { joms.jQuery(this).remove(); }); }, selectAll: function(listID) { joms.jQuery(listID).find('li').each(function() { joms.jQuery(this).find('input').attr('checked', 'checked'); if (joms.jQuery(this).find('input').attr('checked')) { joms.invitation.selectMember('#' + joms.jQuery(this).attr('id')); } }); } }, memberlist: { submit: function() { if (joms.jQuery('input#title').val() == '') { joms.jQuery('#filter-title-error').show(); return false; } if (joms.jQuery('textarea#description').val() == '') { joms.jQuery('#filter-description-error').show(); return false; } joms.jQuery('#jsform-memberlist-addlist').submit(); }, showSaveForm: function(keys, filterJson) { var keys = keys.split(','); var values = Array(); var avatarOnly = joms.jQuery('#avatar:checked').val() != 1 ? 0 : 1; for (var i = 0; i < keys.length; i++) { var tmpArray = new Array(); var value = ''; var key = keys[i]; if ((filterJson['fieldType' + key] == 'date' || filterJson['fieldType' + key] == 'birthdate') && filterJson['condition' + key] == 'between') { value = filterJson[ 'value' + keys[i] ] + ',' + filterJson[ 'value' + keys[i] + '_2' ] } else { value = filterJson[ 'value' + keys[ i ] ]; } values[i] = new Array('field=' + filterJson['field' + keys[i] ], 'condition=' + filterJson['condition' + keys[i]], 'fieldType=' + filterJson['fieldType' + keys[i]], 'value=' + value ); } var valuesString = ''; for (var x = 0; x < values.length; x++) { valuesString += '"' + values[x] + '"'; if ((x + 1) != values.length) valuesString += ','; } var ajaxCall = 'jax.call("community", "memberlist,ajaxShowSaveForm","' + joms.jQuery("input[name=operator]:checked").val() + '","' + avatarOnly + '",' + valuesString + ');'; cWindowShow(ajaxCall, '', 470, 300); } }, notifications: { showWindow: function() { var ajaxCall = 'jax.call("community", "notification,ajaxGetNotification", "")'; cWindowShow(ajaxCall, '', 450, 200); }, updateNotifyCount: function() { var notifyCount = joms.jQuery('#toolbar-item-notify-count').text(); if (joms.jQuery.trim(notifyCount) != '' && notifyCount > 0) { //first we update the count. if the updated count == 0, then we hide the tab. notifyCount = notifyCount - 1; joms.jQuery('#toolbar-item-notify-count').html(notifyCount); if (notifyCount == 0) { joms.jQuery('#toolbar-item-notify').hide(); setTimeout('cWindowHide()', 1000); } } }, showRequest: function() { var ajaxCall = 'jax.call("community", "notification,ajaxGetRequest", "")'; cMiniWindowShow(ajaxCall, '', 450, 100); }, showInbox: function() { var ajaxCall = 'jax.call("community", "notification,ajaxGetInbox", "")'; cMiniWindowShow(ajaxCall, '', 450, 100); }, showUploadPhoto: function(albumId, groupId) { var ajaxCall = 'jax.call("community", "photos,ajaxUploadPhoto","' + albumId + '","' + groupId + '")'; cWindowShow(ajaxCall, '', 600, 400); } }, filters: { bind: function() { var loading = this.loading; joms.jQuery(document).ready(function() { //sorting option binding for members display joms.jQuery('.newest-member').bind('click', function() { if (!joms.jQuery(this).hasClass('active-state')) { loading(joms.jQuery(this).attr('class')); jax.call('community', 'frontpage,ajaxGetNewestMember', frontpageUsers); } }); joms.jQuery('.active-member').bind('click', function() { if (!joms.jQuery(this).hasClass('active-state')) { loading(joms.jQuery(this).attr('class')); jax.call('community', 'frontpage,ajaxGetActiveMember', frontpageUsers); } }); joms.jQuery('.popular-member').bind('click', function() { if (!joms.jQuery(this).hasClass('active-state')) { loading(joms.jQuery(this).attr('class')); jax.call('community', 'frontpage,ajaxGetPopularMember', frontpageUsers); } }); joms.jQuery('.featured-member').bind('click', function() { if (!joms.jQuery(this).hasClass('active-state')) { loading(joms.jQuery(this).attr('class')); jax.call('community', 'frontpage,ajaxGetFeaturedMember', frontpageUsers); } }); //sorting option binding for activity stream joms.jQuery('.all-activity').bind('click', function() { loading(joms.jQuery(this).attr('class')); joms.ajax.call('frontpage,ajaxGetActivities', ['all'], { success: function() { } }); joms.jQuery('.all-activity').parents('li.filter').addClass('active').siblings().removeClass('active'); }); joms.jQuery('.me-and-friends-activity').bind('click', function() { loading(joms.jQuery(this).attr('class')); joms.ajax.call('frontpage,ajaxGetActivities', ['me-and-friends'], { success: function() { } }); joms.jQuery('.me-and-friends-activity').parents('li.filter').addClass('active').siblings().removeClass('active'); }); joms.jQuery('.active-profile-and-friends-activity').bind('click', function() { if (!joms.jQuery(this).hasClass('active-state')) { loading(joms.jQuery(this).attr('class')); jax.call('community', 'frontpage,ajaxGetActivities', 'active-profile-and-friends', joms.user.getActive()); } }); joms.jQuery('.active-profile-activity').bind('click', function() { if (!joms.jQuery(this).hasClass('active-state')) { loading(joms.jQuery(this).attr('class')); jax.call('community', 'frontpage,ajaxGetActivities', 'active-profile', joms.user.getActive()); } }); joms.jQuery('.p-active-profile-and-friends-activity').bind('click', function() { if (!joms.jQuery(this).hasClass('active-state')) { loading(joms.jQuery(this).attr('class')); jax.call('community', 'frontpage,ajaxGetActivities', 'active-profile-and-friends', joms.user.getActive(), 'profile'); } }); joms.jQuery('.p-active-profile-activity').bind('click', function() { if (!joms.jQuery(this).hasClass('active-state')) { loading(joms.jQuery(this).attr('class')); jax.call('community', 'frontpage,ajaxGetActivities', 'active-profile', joms.user.getActive(), 'profile'); } }); // sorting and binding for videos joms.jQuery('.newest-videos').bind('click', function() { if (!joms.jQuery(this).hasClass('active-state')) { loading(joms.jQuery(this).attr('class')); jax.call('community', 'frontpage,ajaxGetNewestVideos', frontpageVideos); } }); joms.jQuery('.popular-videos').bind('click', function() { if (!joms.jQuery(this).hasClass('active-state')) { loading(joms.jQuery(this).attr('class')); jax.call('community', 'frontpage,ajaxGetPopularVideos', frontpageVideos); } }); joms.jQuery('.featured-videos').bind('click', function() { if (!joms.jQuery(this).hasClass('active-state')) { loading(joms.jQuery(this).attr('class')); jax.call('community', 'frontpage,ajaxGetFeaturedVideos', frontpageVideos); } }); // remove last link border joms.jQuery('.popular-member').css('border-right', '0').css('padding-right', '0'); }); }, loading: function(element) { elParent = joms.jQuery('.' + element).parent().parent().attr('id'); if (typeof elParent == 'undefined') { elParent = joms.jQuery('.' + element).parent().attr('id'); } joms.jQuery('#' + elParent + ' .loading').show(); joms.jQuery('#' + elParent + ' a').removeClass('active-state'); joms.jQuery('.' + element).addClass('active-state'); }, hideLoading: function() { joms.jQuery('.loading').hide(); // rebind the tooltip joms.jQuery('.jomTipsJax').addClass('jomTips'); joms.tooltip.setup(); } }, groups: { invitation: { accept: function(groupId) { jax.call('community', 'groups,ajaxAcceptInvitation', groupId) }, reject: function(groupId) { jax.call('community', 'groups,ajaxRejectInvitation', groupId); } }, addInvite: function(element) { var parentId = joms.jQuery('#' + element).parent().attr('id'); if (parentId == "friends-list") { joms.jQuery("#friends-invited").append(joms.jQuery('#' + element)).html(); } else { joms.jQuery("#friends-list").append(joms.jQuery('#' + element)).html(); } }, removeTopic: function(title, groupid, topicid) { var ajaxCall = 'jax.call("community","groups,ajaxShowRemoveDiscussion", "' + groupid + '","' + topicid + '");'; cWindowShow(ajaxCall, title, 450, 100); }, lockTopic: function(title, groupid, topicid) { var ajaxCall = 'jax.call("community","groups,ajaxShowLockDiscussion", "' + groupid + '","' + topicid + '");'; cWindowShow(ajaxCall, title, 450, 100); }, editBulletin: function() { if (joms.jQuery('#bulletin-edit-data').css('display') == 'none') { joms.jQuery('#bulletin-edit-data').show(); joms.jQuery('.cPageStory-Author,.cPageStory-Content').hide(); } else { joms.jQuery('#bulletin-edit-data').hide(); joms.jQuery('.cPageStory-Author,.cPageStory-Content').show(); } }, removeBulletin: function(title, groupid, bulletinid) { var ajaxCall = 'jax.call("community", "groups,ajaxShowRemoveBulletin", "' + groupid + '","' + bulletinid + '");'; cWindowShow(ajaxCall, title, 450, 100); }, unpublish: function(groupid) { var ajaxCall = 'jax.call("community", "groups,ajaxShowUnpublishGroup", "' + groupid + '");'; cWindowShow(ajaxCall, '', 450, 100); }, leave: function(groupid) { var ajaxCall = 'jax.call("community", "groups,ajaxShowLeaveGroup", "' + groupid + '");'; cWindowShow(ajaxCall, '', 450, 100); }, join: function(groupid, joinfromdiscussion) { jax.call("community", "groups,ajaxJoinGroup", [groupid], [joinfromdiscussion]); }, joinComplete: function(msg) { joms.jQuery('input#join').val(msg); joms.jQuery('.loading-icon').hide(); joms.jQuery('#add-reply').show(); joms.jQuery('#add-reply').click(function() { joms.jQuery('div#community-groups-wrap').hide(); joms.jQuery('textarea#wall-message').css('width', '100%'); joms.jQuery('.reply-form').show(); }); }, edit: function() { // Check if input is already displayed joms.jQuery('#community-group-info .cdata').each(function() { // Test if the next div is cinput if (joms.jQuery(this).next().html() && joms.jQuery(this).css('display') != 'none') joms.jQuery(this).css('display', 'none'); else joms.jQuery(this).css('display', 'block'); }); joms.jQuery('#community-group-info .cinput').each(function() { if (joms.jQuery(this).css('display') == 'none') joms.jQuery(this).css('display', 'block'); else joms.jQuery(this).css('display', 'none'); }); if (joms.jQuery('div#community-group-info-actions').css('display') != 'none') joms.jQuery('div#community-group-info-actions').css('display', 'none'); else joms.jQuery('div#community-group-info-actions').css('display', 'block'); }, save: function(groupid) { var name = joms.jQuery('#community-group-name').val(); var description = joms.jQuery('#community-group-description').val(); var website = joms.jQuery('#community-group-website').val(); var category = joms.jQuery('#community-group-category').val(); var approvals = joms.jQuery("input[@name='group-approvals']:checked").val(); jax.call('community', 'groups,ajaxSaveGroup', groupid, name, description, website, category, approvals); }, update: function(groupName, groupDescription, groupWebsite, groupCategory) { // Re-update group data joms.jQuery('#community-group-data-name').html(groupName); joms.jQuery('#community-group-data-description').html(groupDescription); joms.jQuery('#community-group-data-website').html(groupWebsite); joms.jQuery('#community-group-data-category').html(groupCategory); this.edit(); }, deleteGroup: function(groupId) { var ajaxCall = "jax.call('community', 'groups,ajaxWarnGroupDeletion', '" + groupId + "');"; cWindowShow(ajaxCall, '', 450, 100, 'error'); }, toggleSearchSubmenu: function(e) { joms.jQuery(e).next('ul').toggle().find('input[type=text]').focus(); }, confirmMemberRemoval: function(memberId, groupId) { var ajaxCall = function() { jax.call("community", "groups,ajaxConfirmMemberRemoval", memberId, groupId); }; cWindowShow(ajaxCall, '', 450, 80, 'warning'); }, removeMember: function(memberId, groupId) { var banMember = joms.jQuery('#cWindow input[name=block]').attr('checked'); if (banMember) { jax.call('community', 'groups,ajaxBanMember', memberId, groupId); } else { jax.call('community', 'groups,ajaxRemoveMember', memberId, groupId); } } }, photos: { multiUpload: { label: { filename: 'Filename', size: 'Size', status: 'Status', filedrag: 'Drag files here.', addfiles: 'Add Files', startupload: 'Start Upload', invalidfiletype: 'Invalid File Type', exceedfilesize: 'Image file size exceeded limit', stopupload: 'Stop Upload' }, groupid: '', noticeDivId: 'photoUploaderNotice', defaultMsg: '', groupEmptyValidateMsg: '', uploadingCreateMsg: '', uploadingSelectMsg: '', refreshNeeded: false, defaultUploadUrl: 'index.php?option=com_community&view=photos&task=multiUpload', maxFileSize: '10mb', _init: function(groupid, uploadMsg) { if (groupid != undefined && parseInt(groupid) > 0) { joms.photos.multiUpload.groupid = groupid; } if (uploadMsg != undefined && typeof uploadMsg == "object") { for (var indexes in uploadMsg) { joms.photos.multiUpload[indexes] = uploadMsg[indexes]; } } var ua = navigator.userAgent.toLowerCase(); var isMobile = !!ua.match( /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i ); pluploader = joms.jQuery("#multi_uploader").pluploadQueue({ // General settings //runtimes: 'silverlight,gears,html5,browserplus,html4', runtimes: 'gears,html5,browserplus,html4', url: 'index.php?option=com_community&view=photos&task=multiUpload', max_file_size: joms.photos.multiUpload.maxFileSize, chunk_size: joms.photos.multiUpload.maxFileSize, unique_names: true, // Resize images on clientside if we can (not supported in some mobile browsers) resize: isMobile ? false : {width: 2100, height: 2100, quality: 90}, // Specify what files to browse for filters: [ {title: "Image files", extensions: "jpg,gif,png,jpeg"} ], // Flash/Silverlight paths flash_swf_url: 'components/com_community/assets/multiupload_js/plupload.flash.swf', silverlight_xap_url: 'components/com_community/assets/multiupload_js/plupload.silverlight.xap', // PreInit events, bound before any internal events preinit: { Init: function(up, info) { joms.photos.multiUpload.log('[Init]', 'Info:', info, 'Features:', up.features); }, BeforeUpload: function() { if (joms.jQuery("#new-album").css('display') !== 'none') { if (joms.photos.multiUpload.groupid != '' && joms.jQuery('#album-name').val() == "") { joms.photos.multiUpload.stopUploading(); alert(joms.photos.multiUpload.groupEmptyValidateMsg); return; } else { joms.photos.multiUpload.stopUploading(); var albumName = joms.jQuery('#album-name').val().trim(); jax.call('community', 'photos,ajaxCreateAlbum', albumName, joms.photos.multiUpload.groupid); } } else { var newAlbumName = joms.jQuery('#albumid option:selected').html(); var msgToUse = joms.photos.multiUpload.uploadingSelectMsg.replace('%1$s', '' + newAlbumName + ''); joms.photos.multiUpload.displayNotice(msgToUse); joms.photos.multiUpload.assignUploadUrl(joms.photos.multiUpload.getSelectedAlbumId()); } joms.photos.multiUpload.hideShowInput(true); joms.jQuery('#photo-uploader').css('overflow', 'hidden'); }, UploadFile: function(up, file) { joms.photos.multiUpload.log('[UploadFile]', file); // You can override settings before the file is uploaded // Disable Upload Button when upload is running joms.jQuery('.plupload_start').addClass('plupload_disabled'); }, FileUploaded: function(uploader, file, response) { //uploadData = response.response.split("'")[5]; try { var uploadData = joms.jQuery.parseJSON(response.response); } catch (e) { joms.photos.multiUpload.removeQueue(file.id); pluploader.pluploadQueue().stop(); joms.photos.multiUpload.displayNotice('Error Uploading.'); } var uploadedFile = pluploader.pluploadQueue().getFile(file.id); if (uploadData != undefined && uploadedFile != undefined) { if (uploadData.error != undefined && uploadData.photoId == '') // there is error { joms.photos.multiUpload.removeQueue(file.id); joms.jQuery('#upload-footer').show(); joms.jQuery('#message-between').hide(); joms.jQuery('.add-more').hide(); cWindowResize(); try { pluploader.pluploadQueue().stop(); } catch (e) { } joms.photos.multiUpload.showThumbnail(); joms.photos.multiUpload.displayNotice('' + uploadData.msg + ''); joms.jQuery('.plupload_file_name span').bind('click', function(event) { joms.photos.multiUpload.editTitle(event) }); } else // update photo details into file dictionary { joms.jQuery('#album-name').attr('albumid', uploadData.albumId); uploadedFile.imgSrc = uploadData.info; uploadedFile.photoId = uploadData.photoId; joms.photos.multiUpload.refreshNeeded = true; } } }, FilesAdded: function(up, files) { joms.jQuery('.plupload_file_name span').unbind('click'); joms.jQuery('.plupload_button.plupload_start').show(); joms.jQuery('.plupload_button.plupload_start').css('display', 'inline-block'); }, FilesRemoved: function(up, files) { if (pluploader.pluploadQueue().files.length == 0) { joms.jQuery('.plupload_button.plupload_start').hide(); } }, UploadComplete: function(uploader) { joms.photos.multiUpload.uploadCompleteShow(); setTimeout("joms.photos.multiUpload.showThumbnail(); joms.photos.multiUpload.enableEditTitle();", 1000); } }, // Post init events, bound after the internal events init: { Refresh: function(up) { // Called when upload shim is moved joms.photos.multiUpload.log('[Refresh]'); }, StateChanged: function(up) { // Called when the state of the queue is changed joms.photos.multiUpload.log('[StateChanged]', up.state == plupload.STARTED ? "STARTED" : "STOPPED"); }, QueueChanged: function(up) { // Called when the files in queue are changed by adding/removing files joms.photos.multiUpload.log('[QueueChanged]'); }, UploadProgress: function(up, file) { // Called while a file is being uploaded joms.photos.multiUpload.log('[UploadProgress]', 'File:', file, "Total:", up.total); }, FilesAdded: function(up, files) { // Callced when files are added to queue joms.photos.multiUpload.log('[FilesAdded]'); plupload.each(files, function(file) { joms.photos.multiUpload.log(' File:', file); }); }, FilesRemoved: function(up, files) { // Called when files where removed from queue joms.photos.multiUpload.log('[FilesRemoved]'); plupload.each(files, function(file) { joms.photos.multiUpload.log(' File:', file); }); }, FileUploaded: function(up, file, info) { // Called when a file has finished uploading joms.photos.multiUpload.log('[FileUploaded] File:', file, "Info:", info); }, ChunkUploaded: function(up, file, info) { // Called when a file chunk has finished uploading joms.photos.multiUpload.log('[ChunkUploaded] File:', file, "Info:", info); }, Error: function(up, args) { // Called when a error has occured // Handle file specific error and general error if (args.file) { joms.photos.multiUpload.log('[error]', args, "File:", args.file); } else { joms.photos.multiUpload.log('[error]', args); } } } }); //This part added checking for IE7 and will disable multiupload in IE7 or earlier if ((pluploader.pluploadQueue().runtime == 'html4') || (joms.jQuery.browser.msie && (parseInt(joms.jQuery.browser.version) <= 7)) || (joms.jQuery.browser.mozilla && (joms.jQuery.browser.version.slice(0, 3)) == 1.9)) { joms.photos.multiUpload.getBrowserNotSupport(); } joms.jQuery('.plupload_button.plupload_start').hide(); joms.jQuery("#cwin_close_btn").click(function() { if (joms.photos.multiUpload.refreshNeeded) { joms.photos.multiUpload.refreshBrowser(); } }); if (joms.jQuery.browser.msie) { joms.jQuery('div.plupload.html5').css('top', 230); } }, log: function() { var str = ""; plupload.each(arguments, function(arg) { var row = ""; if (typeof (arg) != "string") { plupload.each(arg, function(value, key) { // Convert items in File objects to human readable form if (arg instanceof plupload.File) { // Convert status to human readable switch (value) { case plupload.QUEUED: value = 'QUEUED'; break; case plupload.UPLOADING: value = 'UPLOADING'; break; case plupload.FAILED: value = 'FAILED'; break; case plupload.DONE: value = 'DONE'; break; } } if (typeof (value) != "function") { row += (row ? ', ' : '') + key + '=' + value; } }); str += row + " "; } else { str += arg + " "; } }); joms.jQuery('#log').val(joms.jQuery('#log').val() + str + "\r\n"); }, getSelectedAlbumId: function() { if (typeof pluploader == 'undefined') return false; if (joms.jQuery('#album-name').length <= 0) return false; if (joms.jQuery('#album-name').attr('albumid') != undefined && parseInt(joms.jQuery('#album-name').attr('albumid')) > 0 && joms.jQuery("#new-album").css('display') == 'inline') { return joms.jQuery('#album-name').attr('albumid'); } else { if(joms.jQuery('#albumid').val()){ return joms.jQuery('#albumid').val(); } else { return joms.jQuery('#album-name').attr('albumid'); } } }, showThumbnail: function() { var uploader = pluploader.pluploadQueue(); for (var i = 0; i < uploader.files.length; i++) { var imgNode = document.createElement('img'); imgNode.id = 'plupload_' + uploader.files[i].id; imgNode.setAttribute('class', 'plupupload_thumbnail'); imgNode.src = uploader.files[i].imgSrc; joms.jQuery('#' + uploader.files[i].id + '.plupload_done .plupload_file_name').prepend(imgNode); } // Show uploaded complete notice msg. var newAlbumName = joms.jQuery('#albumid option:selected').html(); var msgToUse = joms.photos.multiUpload.uploadedCompleteMsg.replace('%1$s', '' + newAlbumName + ''); joms.photos.multiUpload.displayNotice(msgToUse); }, assignUploadUrl: function(albumId) { if (typeof pluploader == 'undefined') return false; var urlDefault = joms.photos.multiUpload.defaultUploadUrl; var uploader = pluploader.pluploadQueue(); if (urlDefault.match(/&+/)) { urlDefault = urlDefault + '&albumid=' + albumId + '&batchcount=' + uploader.files.length; } else { urlDefault = urlDefault + '?albumid=' + albumId + '&batchcount=' + uploader.files.length; } joms.jQuery("#multi_uploader").pluploadQueue().settings.url = urlDefault; }, assignNewAlbum: function(albumId, albumName) { // joms.jQuery('#album-name').attr('albumid', albumId); // assignUploadUrl( albumId ); if (typeof pluploader == 'undefined') return false; if (joms.jQuery('#albumid').length <= 0) return false; if (albumName != undefined) // User create new album { var newAlbumName = albumName; var newOption = new Option(newAlbumName, albumId); joms.jQuery('#albumid').append(newOption).val(albumId); joms.photos.multiUpload.assignUploadUrl(albumId); joms.jQuery('#album-name').val(''); } else // User select album from dropdown { joms.jQuery('#albumid').val(albumId); var newAlbumName = joms.jQuery('#albumid option:selected').html(); } // Show Notice Album XXX Created. Photo(s) uploading... var msgToUse = joms.photos.multiUpload.uploadingCreateMsg.replace('%1$s', '' + newAlbumName + ''); joms.photos.multiUpload.displayNotice(msgToUse); joms.photos.multiUpload.showExistingAlbum(); setTimeout("joms.jQuery('#multi_uploader').pluploadQueue().start()", 500); }, showExistingAlbum: function() { joms.jQuery("#select-album").show(); joms.jQuery("#new-album").hide(); joms.jQuery("#newalbum").hide(); if (pluploader.pluploadQueue().files.length > 0) { joms.jQuery('.plupload_start').removeClass('plupload_disabled'); } }, createNewAlbum: function() { joms.jQuery("#select-album").hide(); joms.jQuery("#new-album").show(); joms.jQuery("#newalbum").show(); }, startUploading: function() { joms.jQuery("#multi_uploader").pluploadQueue().start(); }, stopUploading: function() { joms.jQuery("#multi_uploader").pluploadQueue().stop(); }, goToAlbum: function(goUrl) { document.location.href = goUrl; }, getBrowserNotSupport: function() { jax.call('community', 'photos,ajaxGotoOldUpload', joms.photos.multiUpload.getSelectedAlbumId(), joms.photos.multiUpload.groupid); }, goToOldUpload: function(goUrl) { document.location.href = goUrl; }, refreshBrowser: function() { window.location.reload(); }, updateLabel: function(labels) { labels = joms.jQuery.parseJSON(labels); var labelToUpdate = ['filename', 'size', 'status', 'filedrag', 'addfiles', 'startupload', 'stopupload']; for (var i = 0; i < labelToUpdate.length; i++) { if (typeof labels[labelToUpdate[i]] != 'undefined' && labels[labelToUpdate[i]] != '') { joms.photos.multiUpload.label[labelToUpdate[i]] = labels[labelToUpdate[i]]; } } }, enableEditTitle: function() { if (joms.jQuery('.plupload_file_name span').length > 0) { joms.jQuery('.plupload_file_name span').unbind('click'); joms.jQuery('.plupload_file_name span').bind('click', function(event) { joms.photos.multiUpload.editTitle(event) }); } }, // Enable changing photo title editTitle: function(event) { joms.jQuery('.plupload_file_name span').unbind('click'); var obj = (event.target) ? event.target : event.which; var fileId = joms.jQuery(obj).parent().parent().attr('id'); var editInput = ''; joms.jQuery(obj).html(editInput); joms.jQuery(obj).find('input').unbind("keypress").unbind("focusout"); joms.jQuery(obj).find('input').bind('keypress', function(event) { keyCode = event.keyCode; if (keyCode == 13) { joms.photos.multiUpload.saveCaption(this, joms.jQuery(this).parent()); joms.jQuery('.plupload_file_name span').bind('click', function(event) { joms.photos.multiUpload.editTitle(event) }); } }); joms.jQuery(obj).find('input').bind('focusout', function() { joms.photos.multiUpload.saveCaption(this, joms.jQuery(this).parent()); joms.jQuery('.plupload_file_name span').bind('click', function(event) { joms.photos.multiUpload.editTitle(event) }); }); }, saveCaption: function(inputObj, spanObj) { var fileId = joms.jQuery(inputObj).attr('target'); var currentFile = pluploader.pluploadQueue().getFile(fileId); var value = joms.jQuery(inputObj).val(); currentFile.name = value; var saveValue = encodeURIComponent(value); jax.call("community", "photos,ajaxSaveCaption", currentFile.photoId, saveValue, false); joms.jQuery(spanObj).html(value); }, displayNotice: function(msg) { joms.jQuery('#' + joms.photos.multiUpload.noticeDivId).html(msg); }, hideShowInput: function(hide) { if (hide != undefined && hide === true) { joms.jQuery('#upload-header').hide(); joms.jQuery('.custom_plupload_buttons').hide(); } else { joms.jQuery('#upload-header').show(); joms.jQuery('.custom_plupload_buttons').show(); joms.jQuery('.plupload_button.plupload_start').hide(); } cWindowResize(); }, uploadCompleteShow: function() { joms.jQuery('div#upload-footer').show(); cWindowResize(); var uploader = pluploader.pluploadQueue(); joms.ajax.call('photos,ajaxUpdateCounter', [joms.photos.multiUpload.getSelectedAlbumId(),JSON.stringify(uploader)]); }, removeQueue: function(fileId) { var fileQueue = pluploader.pluploadQueue().files; var fileToDelete = []; var count = 0; for (var i = 0; i < fileQueue.length; i++) { if (fileQueue[i].id == fileId) { fileToDelete[count] = fileQueue[i]; count++; } else { if (count > 0) { fileToDelete[count] = fileQueue[i]; count++; } } } for (var i = 0; i < fileToDelete.length; i++) { pluploader.pluploadQueue().removeFile(fileToDelete[i]); fileToDelete[i] = ''; } } }, uploadAvatar: function(type, id) { var jaxCall = jax.call("community", "photos,ajaxUploadAvatar", type, id); cWindowShow(jaxCall, '', 450, 100); }, ajaxUpload: function(type, id, isCustom) { if ( joms.photos.ajaxUpload.uploading ) return; joms.photos.ajaxUpload.uploading = true; var url = joms.jQuery('#jsform-uploadavatar').prop('action'); joms.jQuery.ajaxFileUpload ( { url: url, secureuri: false, fileElementId: 'filedata', dataType: 'json', beforeSend: function() { }, complete: function() { joms.photos.ajaxUpload.uploading = false; }, success: function(data, status) { if (data.error == 'true') { joms.jQuery('span.error').remove(); joms.jQuery('#avatar-upload').prepend('' + data.msg + ''); return false; } else { url = data.msg; joms.jQuery('span.error').remove(); var oldAvatar = ''; joms.jQuery('#thumb-crop').css('min-height', 0); joms.jQuery('#large-avatar-pic').prop('src', url); joms.jQuery('#thumb-hold > img').prop('src', url); joms.jQuery('div.status-anchor img').prop('src', url); joms.jQuery('#large-avatar-pic').load(function() { var resizeW = Math.round((64 / 160) * joms.jQuery('#large-avatar-pic').width()); var resizeH = Math.round((64 / 160) * joms.jQuery('#large-avatar-pic').height()); joms.jQuery('#thumb-hold > img').css( { width: resizeW + 'px', height: resizeH + 'px', marginLeft: '0px', marginTop: '0px' } ); }); switch (type) { case 'event': oldAvatar = joms.jQuery('.js-focus-avatar img').prop('src'); var eventAvatar = url.replace('event-', ''); joms.jQuery('.js-focus-avatar img').prop('src', eventAvatar); if (oldAvatar.search('assets/event.png') > -1) { if (isCustom) { selected = joms.jQuery('input:radio[name=repeattype]:checked').val(); custom = '{"call":["CEvents","getEventRepeatSaveHTML","' + selected + '"], "library":"events", "arg":["repeattype"]}'; jax.call('community', 'photos,ajaxUploadAvatar', type, id, custom); } else { jax.call('community', 'photos,ajaxUploadAvatar', type, id); } } break; case 'group': oldAvatar = joms.jQuery('.js-focus-avatar img').prop('src'); var groupAvatar = url.replace('group-', ''); joms.jQuery('.js-focus-avatar img').prop('src', groupAvatar); if (oldAvatar.search('assets/group.png') > -1) { jax.call('community', 'photos,ajaxUploadAvatar', type, id); } break; case 'profile': oldAvatar = joms.jQuery('.js-focus-avatar img').prop('src'); if (data.info.length != 0) { var thumbUrl = data.info; var profileAvatar = thumbUrl.replace('thumb_', ''); // Update Status Bar Thumbnail joms.jQuery('.status-author > img').prop('src', thumbUrl); // Update News feed thumbnail joms.jQuery('.cStream-Avatar img[data-author="' + id + '"]').prop('src', thumbUrl); /* Update profile avatar */ joms.jQuery('.js-focus-avatar img').prop('src', profileAvatar); } if (oldAvatar.search('assets/user-') > -1) { jax.call('community', 'photos,ajaxUploadAvatar', type, id); } break; } } } } ) return false; }, loadImgSelect: function() { joms.jQuery('#large-avatar-pic').unbind('load'); joms.jQuery('#large-avatar-pic').load(function() { joms.photos.ajaxImgSelect(); cWindowAutoResize(); }); } , ajaxImgSelect: function() { var imgH = joms.jQuery('#large-avatar-pic').height(); var imgW = 160; if (imgH < 160) { imgW = imgH; } if (imgH > 160) { imgH = 160; } // Create select object joms.jQuery('#large-avatar-pic').imgAreaSelect( { handles: true, aspectRatio: '1:1', x1: 0, y1: 0, x2: imgW, y2: imgH, show: false, hide: true, enable: false, parent: '#cWindowContentWrap', minHeight: 64, minWidth: 64, onInit: joms.photos.previewThumb, onSelectChange: joms.photos.previewThumb } ); var ias = joms.jQuery('#large-avatar-pic').imgAreaSelect({instance: true}); ias.setOptions({show: true, hide: false, enable: true}); ias.update(); // cWindowAutoResize(); }, saveThumb: function(type, id) { var ias = joms.jQuery('#large-avatar-pic').imgAreaSelect({instance: true}); var obj = ias.getSelection(); jax.call('community', 'photos,ajaxUpdateThumbnail', type, id, obj.x1, obj.y1, obj.width, obj.height); }, previewThumb: function(img, selection) { var scaleX = 64 / (selection.width || 1); var scaleY = 64 / (selection.height || 1); joms.jQuery('#thumb-hold >img').css( { width: Math.round(scaleX * joms.jQuery('#large-avatar-pic').width()) + 'px', height: Math.round(scaleY * joms.jQuery('#large-avatar-pic').height()) + 'px', marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' } ); }, ajaxRemoveImgSelect: function() { joms.jQuery('.imgareaselect-selection').parent().remove(); joms.jQuery('.imgareaselect-outer').remove(); }, /* * Since version 2.4 * for Photo slider */ photoSlider: { moveSpace: 4, partialOpacity: 0.6, fullOpacity: 1, intervalTime: 30, timer: '', controlObj: '', event: '', parentElem: '', stopAnimeId: '', img_thumbId: 'photoSlider_thumb', img_thumbClass: 'currentView', thumbnail: { width: 0, height: 0 }, /* * @param1 String sliding html element id * @param2 String classname of items inside sliding html element (use to stop sliding when mouse focus on item) * @param3 JSON options to override sliding configuration */ _init: function(elementId, stopAnimeId, options) { if (options != undefined) { joms.photos.photoSlider.updateConfig(options); } var objElement = joms.jQuery('#' + elementId); joms.photos.photoSlider.controlObj = objElement; joms.photos.photoSlider.parentElem = joms.jQuery(objElement.parent()); if (stopAnimeId != undefined && stopAnimeId != '') { joms.photos.photoSlider.stopAnimeId = stopAnimeId; joms.jQuery('.' + joms.photos.photoSlider.stopAnimeId).css('opacity', joms.photos.photoSlider.partialOpacity); var index = joms.gallery.getPlaylistIndex(joms.gallery.currentPhoto().id); joms.jQuery('.' + joms.photos.photoSlider.stopAnimeId).eq(index).css('opacity', joms.photos.photoSlider.fullOpacity); } joms.photos.photoSlider.parentElem.bind({ 'mouseover': function(event) { var elemWidth = joms.photos.photoSlider.getValue(joms.jQuery(this).css('width')); var elemHeight = joms.photos.photoSlider.getValue(joms.jQuery(this).css('height')); var offset = joms.jQuery(this).offset(); if ((event.pageY > (offset.top + elemHeight * 0.1)) && (event.pageY < (offset.top + elemHeight * 0.9))) { joms.photos.photoSlider.moveContent(event); } }, 'mousemove': function(event) { joms.photos.photoSlider.updateMousePos(event); }, 'mouseout': function(event) { joms.photos.photoSlider.reset(event); } }); // Resize according to parent's width to avoid breaking in certain browser styling var customwidth = joms.photos.photoSlider.parentElem.parent().width(); joms.jQuery(".photo_slider").css('width', customwidth + 'px'); setTimeout(function(){ joms.photos.photoSlider.switchPhoto(); }, 0 ); }, updateConfig: function(options) { var availableOption = ['moveSpace', 'partialOpacity', 'fullOpacity', 'intervalTime']; if (typeof options == 'object') { for (var i = 0; i < availableOption.length; i++) { if (options[availableOption[i]] != undefined && parseInt(options[availableOption[i]]) != 'NaN' && options[availableOption[i]] > 0) { joms.photos.photoSlider[availableOption[i]] = options[availableOption[i]]; } } } }, moveContent: function(event) { joms.photos.photoSlider.parentElem.unbind("mouseover"); joms.photos.photoSlider.timer = setInterval("joms.photos.photoSlider.animate()", joms.photos.photoSlider.intervalTime); if (joms.photos.photoSlider.stopAnimeId != '' && joms.jQuery('.' + joms.photos.photoSlider.stopAnimeId).length > 0) { var thumbnailItem = joms.jQuery('.' + joms.photos.photoSlider.stopAnimeId).eq(0); joms.photos.photoSlider.thumbnail.width = joms.photos.photoSlider.getValue(thumbnailItem.css('width')); joms.photos.photoSlider.thumbnail.height = joms.photos.photoSlider.getValue(thumbnailItem.css('height')); } }, animate: function() { // Disable photo slider in photo tag mode if (joms.jQuery('#startTagMode').length > 0 && joms.jQuery('#startTagMode').css('display') == 'none') { joms.photos.photoSlider.stop(); return false; } var leftPos = joms.photos.photoSlider.getValue(joms.photos.photoSlider.controlObj.css('left')); var sliderWidth = joms.photos.photoSlider.getValue(joms.photos.photoSlider.controlObj.css('width')); var elemWidth = joms.photos.photoSlider.getValue(joms.photos.photoSlider.parentElem.css('width')); var midVal = elemWidth / 2; if (joms.photos.photoSlider.getMouseXPosition() > midVal) { if (((leftPos + sliderWidth) - elemWidth) >= 0) //end of div { joms.photos.photoSlider.controlObj.css('left', (leftPos - joms.photos.photoSlider.moveSpace) + 'px'); } } else { if (leftPos < 0) { joms.photos.photoSlider.controlObj.css('left', (leftPos + joms.photos.photoSlider.moveSpace) + 'px'); } } }, updateMousePos: function(event) { joms.photos.photoSlider.event = event; }, getMouseXPosition: function() { return joms.photos.photoSlider.event.pageX - joms.photos.photoSlider.parentElem.offset().left; }, getMouseYPosition: function() { return joms.photos.photoSlider.event.pageY - joms.photos.photoSlider.parentElem.offset().top; }, getValue: function(strVal) { if (strVal == '' || strVal == 'auto') { intVal = 0; } else { intVal = parseInt(strVal.replace('px', '')); if (typeof intVal != 'number' || intVal == 'NaN') { intVal = 0; } } return intVal; }, // display image in photo canvas when thumbnail being clicked viewImage: function(photoid) { // Disable switch photo in photo tag mode if (joms.jQuery('#startTagMode').length > 0 && joms.jQuery('#startTagMode').css('display') == 'none') { return false; } if (joms.gallery != undefined && jsPlaylist != undefined) { joms.photos.photoSlider.stop(); joms.gallery.displayPhoto(jsPlaylist.photos[joms.gallery.getPlaylistIndex(photoid)]); } }, // switch the highlight when user click on next/prev navigator switchPhoto: function() { if (joms.photos.photoSlider.controlObj == undefined || joms.photos.photoSlider.controlObj == '') { return false; } var hash = window.location.hash || '', href = window.location.href, currentPhotoId; href = href.replace( hash, '' ); if ( hash && hash.match( /^#photoid=\d+$/ ) ) { currentPhotoId = hash.replace( '#photoid=', '' ); } if ( !currentPhotoId ) { currentPhotoId = href.match(/.+photoid=(\d+).*/); currentPhotoId = currentPhotoId && currentPhotoId[1]; } if ( !currentPhotoId ) { currentPhotoId = joms.photos.photoSlider.controlObj.find(img).eq(0).attr('id'); } joms.photos.photoSlider.controlObj.find('img').removeClass(joms.photos.photoSlider.img_thumbClass); joms.photos.photoSlider.controlObj.find('img[id="' + currentPhotoId + '"]').addClass(joms.photos.photoSlider.img_thumbClass); var img = joms.jQuery('img#photoSlider_thumb' + currentPhotoId).css('opacity', joms.photos.photoSlider.fullOpacity); joms.jQuery('.image_thumb').not(img).css('opacity', joms.photos.photoSlider.partialOpacity); // Change data-src to src if ( !img.attr('src') && img.data('src') ) img[0].src = img.data('src'); // Change next data-src to src var next = img; for ( var i = 0; i < 6; i++ ) { next = next.closest('li').next('li'); if ( !next.length ) break; next = next.find('img'); if ( next.length && !next.attr('src') && next.data('src') ) next[0].src = next.data('src'); } // Change prev data-src to src var prev = img; for ( var i = 6; i > 0; i-- ) { prev = prev.closest('li').prev('li'); if ( !prev.length ) break; prev = prev.find('img'); if ( prev.length && !prev.attr('src') && prev.data('src') ) prev[0].src = prev.data('src'); } // calculate var li = img.closest('li'), liLeft = (li.position() || {}).left, ul = li.closest('ul'), ulLeft = (ul.position() || {}).left, ulWidth = ul.width(), div = ul.closest('div'), divWidth = div.width(), divHalf = divWidth / 2 - li.outerWidth( true ) / 2; if ( ulWidth < divWidth ) ulLeft = divWidth / 2 - ulWidth / 2; else ulLeft = Math.max( 0 - (ulWidth - divWidth), Math.min( 0, 0 - liLeft + divHalf ) ); ul.stop().animate({ left: ulLeft }); }, // use for updating thumbnail when there is photo rotation updateThumb: function(id, thumbSrc) { var finder = 'img[id="' + joms.photos.photoSlider.img_thumbId + id + '"]'; if (joms.jQuery('.slider-gallery').find(finder).length == 1) { joms.jQuery('.slider-gallery').find(finder).attr('src', thumbSrc); } }, // use for updating photoslider for photo removal removeThumb: function(photoid) { joms.jQuery('#cPhoto' + photoid).remove(); var numItems = joms.photos.photoSlider.controlObj.find('img').length var itemSpace = 79; joms.photos.photoSlider.controlObj.css('width', (numItems * itemSpace) + 'px'); }, // avoid stopping sliding when mouse falls between the gap among the images thumbnails reset: function(event) { var offset = joms.photos.photoSlider.parentElem.offset(); // Prevent propagation effect and messed up the animation if ((event.pageX > offset.left && event.pageX < (offset.left + joms.photos.photoSlider.getValue(joms.photos.photoSlider.parentElem.css('width')))) && (event.pageY > offset.top && event.pageY < (offset.top + joms.photos.photoSlider.getValue(joms.photos.photoSlider.parentElem.css('height'))))) { return false; } joms.photos.photoSlider.stop(); }, // stop the sliding anitmation stop: function() { clearInterval(joms.photos.photoSlider.timer); joms.photos.photoSlider.timer = ''; joms.photos.photoSlider.event = ''; joms.photos.photoSlider.parentElem.unbind("mouseover").unbind("mousemove").unbind("mouseout"); joms.photos.photoSlider._init(joms.photos.photoSlider.controlObj.attr('id'), joms.photos.photoSlider.stopAnimeId); } } }, tooltips: { currentJaxCall: '', currentJElement: '', currentTimeout: '', minitipStyle: {top: 0, left: 0, width: 500, height: 100}, showDialog: function(classCheck) { if (joms.tooltips.currentJElement == '' || joms.tooltips.currentJaxCall == '') { if (joms.tooltips.currentTimeout != '') clearTimeout(joms.tooltips.currentTimeout); return false; } if (joms.tooltips.currentJElement.hasClass(classCheck)) { //cMinitipShow(joms.tooltips.currentJaxCall, '', joms.tooltips.minitipStyle.width, 100); joms.minitip._init(joms.tooltips.currentJaxCall, '', joms.tooltips.minitipStyle.width, joms.tooltips.minitipStyle.height); joms.tooltips.repositionMinitip(); joms.jQuery('#' + joms.minitip.id.canvas).addClass(classCheck); joms.jQuery('#' + joms.minitip.id.canvas).attr('currentMinitip', joms.tooltips.currentJElement.attr('id')); } }, addMinitipContent: function(html) { if (joms.jQuery('#' + joms.minitip.id.canvas).length > 0) { //cMinitipAddContent(html); joms.tooltips.repositionMinitip(); joms.minitip.addContent(html); } }, repositionMinitip: function() { var topToUse = joms.tooltips.currentJElement.offset().top - (joms.jQuery('#' + joms.minitip.id.canvas).height() + 20); if (joms.jQuery.browser.msie && joms.jQuery.browser.version.substr(0, 1) <= 7) { var leftToUse = joms.tooltips.currentJElement.offset().left - 65; } else { var leftToUse = joms.tooltips.currentJElement.offset().left + 30; } joms.jQuery('#' + joms.minitip.id.canvas).css( { 'top': topToUse, 'left': leftToUse }); }, setDelay: function(jElement, jaxCall, classCheck, widthToUse, heightToUse, event) { if (jElement.attr('id') == undefined) { jElement.attr('id', 'temp_minitooltip' + Math.random().toString()); } if (joms.jQuery('#' + joms.minitip.id.canvas).length > 0) { if (jElement.attr('id') == joms.jQuery('#' + joms.minitip.id.canvas).attr('currentMinitip')) { return false; } } if (widthToUse != undefined && parseInt(widthToUse) > 0) { joms.tooltips.minitipStyle.width = widthToUse; } if (heightToUse != undefined && parseInt(heightToUse) > 0) { joms.tooltips.minitipStyle.height = heightToUse; } joms.tooltips.currentJElement = jElement; joms.tooltips.currentJElement.bind("mouseout", function() { joms.jQuery(this).removeClass(classCheck); clearTimeout(joms.tooltips.currentTimeout); joms.tooltips.reset(); joms.minitip.hide(); }); joms.tooltips.currentJElement.addClass(classCheck); joms.tooltips.currentJaxCall = jaxCall; joms.tooltips.currentTimeout = setTimeout("joms.tooltips.showDialog('" + classCheck + "')", 500); }, reset: function() { joms.tooltips.currentJaxCall = ''; //joms.tooltips.currentJElement = ''; joms.tooltips.currentTimeout = ''; } }, friends: { saveTag: function() { var formVars = jax.getFormValues('tagsForm'); jax.call("community", "friends,ajaxFriendTagSave", formVars); return false; }, saveGroup: function(userid) { if (document.getElementById('newtag').value == '') { window.alert('TPL_DB_INVALIDTAG'); } else { jax.call("community", "friends,ajaxAddGroup", userid, joms.jQuery('#newtag').val()); } }, cancelRequest: function(friendsId) { var ajaxCall = 'jax.call("community" , "friends,ajaxCancelRequest" , "' + friendsId + '");'; cWindowShow(ajaxCall, '', 450, 100); }, connect: function(friendid) { var ajaxCall = 'jax.call("community", "friends,ajaxConnect", ' + friendid + ')'; cWindowShow(ajaxCall, '', 450, 140); }, addNow: function() { var formVars = jax.getFormValues('addfriend'); jax.call("community", "friends,ajaxSaveFriend", formVars); return false; }, confirmFriendRemoval: function(friendId) { var ajaxCall = function() { jax.call("community", "friends,ajaxConfirmFriendRemoval", friendId); }; cWindowShow(ajaxCall, '', 450, 80, 'warning'); }, remove: function(friendId) { var blockFriend = joms.jQuery('#cWindow input[name=block]').attr('checked'); var ajaxCall; if (blockFriend) { ajaxCall = function() { jax.call("community", "friends,ajaxBlockFriend", friendId); }; } else { ajaxCall = function() { jax.call("community", "friends,ajaxRemoveFriend", friendId); }; } cWindowShow(ajaxCall, '', 450, 80, 'warning'); }, updateFriendList: function(friends, error) { currentFriends = ''; noFriend = ''; if (joms.jQuery('#community-invitation-list').hasClass('load-more')) { currentFriends = joms.jQuery('#community-invitation-list').html(); } else { //check empty result if (joms.jQuery.trim(friends) == '') { noFriend = error; } } newFriends = currentFriends + friends + noFriend; joms.jQuery('#community-invitation-list').html(newFriends); //removed selected friend form the list joms.invitation.filterMember(); //set result list as active joms.jQuery('.cTabNav #ctab-result').click(); }, loadFriend: function(name, callback, cid, limitstart, limit) { if (joms.jQuery('#community-invitation-list').hasClass('load-more')) { joms.jQuery('#community-invitation-list').removeClass('load-more'); } jax.call('community', 'system,ajaxLoadFriendsList', name, callback, cid, limitstart, limit); }, loadMoreFriend: function(callback, cid, limitstart, limit) { name = joms.jQuery('#friend-search-filter').val(); joms.jQuery('#community-invitation-list').addClass('load-more'); jax.call('community', 'system,ajaxLoadFriendsList', name, callback, cid, limitstart, limit); }, showForm: function(users, callback, cid, displayFriends, onClickAction) { var ajaxCall = 'jax.call("community", "system,ajaxShowFriendsForm","' + users + '","' + callback + '","' + cid + '","' + displayFriends + '","' + onClickAction + '")'; var height = 520; height = displayFriends != "0" ? height : height - 108; height = height - 108; cWindowShow(ajaxCall, '', 550, height); }, selectRecipients: function() { //reset old list joms.jQuery("#community-invited-list li").each(function(index) { var friendId = joms.jQuery(this).attr('id'); if (joms.jQuery('#inbox-selected-to #' + friendId).length > 0) { } else { var friend = joms.jQuery(this).clone(); friend.appendTo('#inbox-selected-to'); } }); joms.jQuery('.invitation-check label').empty(); cWindowHide(); } }, messaging: { loadComposeWindow: function(userid) { var ajaxCall = 'jax.call("community", "inbox,ajaxCompose", ' + userid + ')'; cWindowShow(ajaxCall, '', 450, 295); }, sendCompleted: function() { joms_message_sending = false; }, send: function() { if (joms_message_sending) return false; joms_message_sending = true; var formVars = jax.getFormValues('writeMessageForm'); jax.call("community", "inbox,ajaxSend", formVars); return false; }, confirmDeleteMarked: function(task) { var msgIds = new Array(); joms.jQuery("#inbox-listing INPUT[type='checkbox']").each(function() { if (joms.jQuery(this).attr('checked')) { msgIds.push(joms.jQuery(this).attr('value')); } }); if (msgIds.toString() != '') { var ajaxCall = 'jax.call("community", "inbox,ajaxDeleteMessages", "' + task + '")' } else { var ajaxCall = 'jax.call("community", "inbox,ajaxDeleteMessages", "' + task + '","empty")' } cWindowShow(ajaxCall, '', 450, 100); }, deleteMarked: function(task) { var msgIds = new Array(); joms.jQuery("#inbox-listing INPUT[type='checkbox']").each(function() { if (joms.jQuery(this).attr('checked')) { msgIds.push(joms.jQuery(this).attr('value')); } }); if (task == 'inbox') jax.call('community', 'inbox,ajaxRemoveFullMessages', msgIds.toString()); else jax.call('community', 'inbox,ajaxRemoveSentMessages', msgIds.toString()); return false; } }, walls: { insertOrder: 'prepend', add: function(uniqueId, addFunc) { jax.loadingFunction = function() { joms.jQuery('#wall-message,#wall-submit').attr('disabled', true); } jax.doneLoadingFunction = function() { joms.jQuery('#wall-message,#wall-submit').attr('disabled', false); }; if (typeof getCacheId == 'function') { cache_id = getCacheId(); } else { cache_id = ""; } jax.call('community', addFunc, joms.jQuery('#wall-message').val(), uniqueId, cache_id); }, insert: function(html) { joms.jQuery('#wall-message').val(''); if (joms.walls.insertOrder == 'prepend') { joms.jQuery('#wall-containter').prepend(html); } else { if(joms.jQuery('#wall-containter .cComment:last').length > 0){ joms.jQuery('#wall-containter .cComment:last').after(html); }else{ joms.jQuery('#wall-containter').prepend(html); } } }, remove: function(type, wallId, contentId) { if (confirm('Are you sure you want to delete this wall?')) { jax.call('community', type + ',ajaxRemoveWall', wallId, contentId); joms.jQuery('#wall_' + wallId).fadeOut('normal', function() { joms.jQuery(this).remove() }); // Process ajax calls } }, update: function(id, message) { //Hide popups cWindowHide(); //Update the existing html codes joms.jQuery('#wall_' + id).replaceWith(message); }, save: function(id, editableFunc) { jax.call('community', 'system,ajaxUpdateWall', id, joms.jQuery('#wall-edit-' + id).val(), editableFunc); }, edit: function(id, permissionFunc) { if (joms.jQuery('#wall-edit-' + id).val() != null) { joms.jQuery('#wall-message-' + id).show(); joms.jQuery('#wall-edit-container-' + id).children().remove(); } else { // Hide current message joms.jQuery('#wall-message-' + id).hide(); joms.jQuery('#wall_' + id + ' div.content').prepend('').prepend('
'); jax.call('community', 'system,ajaxEditWall', id, permissionFunc); joms.utils.textAreaWidth('#wall-edit-' + id); joms.utils.autogrow('#wall-edit-' + id); } }, more: function() { // Pass the necessary params to ajaxGetOlderWalls var groupId = joms.jQuery('#wall-groupId').val(); var discussionId = joms.jQuery('#wall-discussionId').val(); var limitStart = joms.jQuery('#wall-limitStart').val(); // Show loading image joms.jQuery('#wall-more .more-wall-text').hide(); joms.jQuery('#wall-more .loading').show(); jax.call('community', 'system,ajaxGetOlderWalls', groupId, discussionId, limitStart); }, append: function(html) { //joms.jQuery("#wallContent div.wallComments:last").css('border-bottom', '1px dotted #333'); joms.jQuery('#wall-more,#wall-groupId,#wall-discussionId,#wall-limitStart').remove(); joms.jQuery('#wall-containter').append(html); }, prepend: function(html) { joms.jQuery('#wall-more').remove(); joms.jQuery('#wall-groupId').remove(); joms.jQuery('#wall-discussionId').remove(); joms.jQuery('#wall-limitStart').remove(); joms.jQuery('#wall-containter').prepend(html); }, showVideoWindow: function(videoId) { var ajaxCall = 'jax.call("community" , "videos,ajaxShowVideoWindow", "' + videoId + '");'; cWindowShow(ajaxCall, '', 640, 360); } }, toolbar: { timeout: 500, closetimer: 0, ddmenuitem: 0, open: function(id) { if (joms.jQuery('#' + id).length > 0) { // cancel close timer joms.toolbar.cancelclosetime(); // close old layer if (joms.toolbar.ddmenuitem) { joms.toolbar.ddmenuitem.style.visibility = 'hidden'; } // get new layer and show it joms.toolbar.ddmenuitem = document.getElementById(id); joms.toolbar.ddmenuitem.style.visibility = 'visible'; } }, close: function() { if (joms.toolbar.ddmenuitem) { joms.toolbar.ddmenuitem.style.visibility = 'hidden'; } }, closetime: function() { joms.toolbar.closetimer = window.setTimeout(joms.toolbar.close, joms.toolbar.timeout); }, cancelclosetime: function() { if (joms.toolbar.closetimer) { window.clearTimeout(joms.toolbar.closetimer); joms.toolbar.closetimer = null; } } }, registrations: { showTermsWindow: function(fb) { var ajaxCall = 'jax.call("community", "register,ajaxShowTnc", "' + fb + '")'; cWindowShow(ajaxCall, this.windowTitle, 600, 350); }, authenticate: function() { jax.call("community", "register,ajaxGenerateAuthKey"); }, authenticateAssign: function() { jax.call("community", "register,ajaxAssignAuthKey"); }, assignAuthKey: function(fname, lblname, authkey) { eval("document.forms['" + fname + "'].elements['" + lblname + "'].value = '" + authkey + "';"); }, showWarning: function(message, title) { cWindowShow('joms.jQuery(\'#cWindowContent\').html(\'' + message + '\')', title, 450, 200, 'warning'); } }, miniwall: { initialize: function() { var container = joms.jQuery('#activity-stream-container'); // Support comment removal joms.jQuery('a[href="#removeComment"]').on( 'click', function() { var wallid = joms.jQuery(this).parents('[data-commentid]').data('commentid'); joms.miniwall.remove(wallid); }); // Show all comments. container.on( 'click', 'a[href="#showallcomments"]', function( e ) { e.preventDefault(); var el = joms.jQuery( this ); if ( el.data('loading') ) return; el.data( 'loading', 1 ); var streamid = el.closest('li').data('streamid'); jax.call( 'community', 'system,ajaxStreamShowComments', streamid ); }); // Resize form textarea to fit the comment width perfectly joms.jQuery('.cStream-Form textarea').width(joms.jQuery('.cStream-Form').width() - 12); }, add: function(id, host) { //Isn't an event if (typeof host == 'undefined') return; var targetBlock = null; var cmtBlock = null; if (joms.miniwall.type(host) == 'cModule-ActivityStream') { cmtBlock = joms.jQuery("#cModule-ActivityStream").find("#wall-cmt-" + id); } else { cmtBlock = joms.jQuery(".cMain").find("#wall-cmt-" + id); } var textarea = cmtBlock.find('textarea'); if ( !textarea.data('inittextntags') ) { joms.miniwall._add( id, cmtBlock, textarea.val() ); return; } textarea.textntags( 'val', function( cmt ) { joms.miniwall._add( id, cmtBlock, cmt ); }); }, _add: function( id, cmtBlock, cmt ) { cmt = joms.jQuery.trim(cmt); if (cmt.length > 0) { cmtBlock.find('.wall-coc-form-action.add').attr('disabled', true); cmtBlock.find('.wall-coc-errors').hide(); jax.loadingFunction = function() { cmtBlock.find('textarea').attr('disabled', true); cmtBlock.find('.wall-coc-form-actions').append('Posting...'); jax.loadingFunction = function() { } // clear the callbacks after each call }; jax.doneLoadingFunction = function() { cmtBlock.find('.wall-coc-form-actions').find('em').remove(); cmtBlock.find('textarea').attr('disabled', false).val(''); cmtBlock.find('.wall-coc-form-action.add').attr('disabled', false); // update comment count cmtCountObj = cmtBlock.parent().parent().find('.wall-cmt-count'); curCmtCount = parseInt(cmtCountObj.html()); cmtCountObj.parent().fadeOut('fast', function() { // plus one and update the value again cmtCountObj.html(curCmtCount + 1); cmtCountObj.parent().fadeIn('fast'); }); jax.doneLoadingFunction = function() { } // clear the callbacks after each call }; jax.call("community", "system,ajaxStreamAddComment", id, cmt); } }, insert: function(id, text) { // Form must be there, if a user cannot comment joms.jQuery('#wall-cmt-' + id + ' .wallform').before(text); // comment with zero comment could will have this class to hide the whole // comment area, remove it after we insert a new comment joms.jQuery('#wall-cmt-' + id + ' .wallnone').removeClass('wallnone'); joms.miniwall.cancel(id); }, loadall: function(id, text) { // remove all element first joms.jQuery('li[data-streamid=' + id + '] div[data-commentid]').remove(); // replace the 'more' link with proper content joms.jQuery('li[data-streamid=' + id + '] div[data-commentmore]').replaceWith(text); //joms.miniwall.initialize(); }, cancel: function(id, host) { // Clear up the textarea // joms.jQuery('#wall-cmt-' + id + ' textarea').val(''); //joms.jQuery('#wall-cmt-'+ id +' .show-cmt').show(); joms.jQuery('#wall-cmt-' + id + ' .wall-coc-errors').hide(); joms.jQuery('#wall-cmt-' + id + '.wall-coc-form-action.add').removeAttr('disabled'); // Hide the form and container as defined by data-formblock attr joms.jQuery('#wall-cmt-' + id + ' [data-formblock]').hide(); /** * will only show [Reply] if there is comment, hide everything otherwise */ if (joms.jQuery('li[data-streamid=' + id + '] [data-commentid]').length > 0)//test { joms.jQuery('li[data-streamid=' + id + '] [data-replyblock]').show(); } }, remove: function(id) { var cmtCountObj = joms.jQuery('#wall-' + id).parent().parent().parent().find('.wall-cmt-count'); // change comment color to red while its being removed via ajax jax.loadingFunction = function() { joms.jQuery('#wall-' + id) .css({backgroundColor: '#ffdddd'}) .find('.wall-coc-remove-link').show().html('Removing...'); jax.loadingFunction = function() { } // clear the callbacks after each call }; // setup callbacks after loading jax.doneLoadingFunction = function() { // find the currently shown value of the comment count var curCmtCount = parseInt(cmtCountObj.html()); //alert(curCmtCount); if (curCmtCount > 0) { // if this is the last comment, remove the last 'Reply' link as well if (curCmtCount == 1) { joms.jQuery('#wall-' + id).parent().parent().find('.cComment:last').addClass('wallnone'); } // flash the count so it looks more interesting cmtCountObj.parent().fadeOut('fast', function() { // minus one and update the value again cmtCountObj.html(curCmtCount - 1); cmtCountObj.parent().fadeIn('fast'); }); } // now remove the display of that particular comment joms.jQuery('[data-commentid=' + id + ']').fadeOut('fast', function() { joms.jQuery(this).remove(); }).find('.wall-coc-remove-link').hide(); //joms.miniwall.initialize(); jax.doneLoadingFunction = function() { } // clear the callbacks after each call }; jax.call('community', 'system,ajaxStreamRemoveComment', id); }, show: function(id, host) { //Isn't an event if (typeof host == 'undefined') return; var targetBlock = null; var replyBlock = null; if (joms.miniwall.type(host) == 'cModule-ActivityStream') { targetBlock = joms.jQuery("#cModule-ActivityStream").find('li[data-streamid=' + id + '] [data-formblock]'); replyBlock = joms.jQuery("#cModule-ActivityStream").find('li[data-streamid=' + id + '] [data-replyblock]'); } else { targetBlock = joms.jQuery(".cMain").find('li[data-streamid=' + id + '] [data-formblock]'); replyBlock = joms.jQuery(".cMain").find('li[data-streamid=' + id + '] [data-replyblock]'); } targetBlock.show(); targetBlock.find("button").attr('onclick', "joms.miniwall.add('" + id + "', this);return false;"); replyBlock.hide(); // @todo: should only autogrow once. var textarea = targetBlock.find('textarea'); if (!textarea.data('autogrow')) { joms.utils.textAreaWidth(textarea); joms.utils.autogrow(textarea); textarea.focus(); textarea.blur(function() { if (joms.jQuery(this).val() == '') joms.miniwall.cancel(id); }).data('autogrow', true); } }, type: function(host) { var tracker = joms.jQuery(host); //Make sure we won't jump to an infinite loop var limitor = 50; var htype = ''; while (tracker.prop("tagName") != undefined && tracker.prop("tagName") != joms.jQuery("body").prop("tagName") && limitor > 0) { if (htype == '' && (tracker.attr("id") == 'cModule-ActivityStream' || tracker.attr("class") == 'cMain')) { htype = (tracker.attr("id") != undefined) ? tracker.attr("id") : tracker.attr("class"); } tracker = tracker.parent(); limitor--; } return htype; } }, comments: { add: function(id) { var cmt = joms.jQuery('#' + id + ' textarea').val(); if (cmt != '') { joms.jQuery('#' + id + '.wall-coc-form-action.add').attr('disabled', true); if (typeof getCacheId == 'function') { cache_id = getCacheId(); } else { cache_id = ""; } jax.call("community", "plugins,walls,ajaxAddComment", id, cmt, cache_id); } }, insert: function(id, text) { joms.jQuery('#' + id + ' form').before(text); joms.comments.cancel(id); }, remove: function(obj) { var cmtDiv = joms.jQuery(obj).parents('.cComment'); var index = joms.jQuery(cmtDiv).index(); var parentId = joms.jQuery(obj).parents('.cComment').parent().attr('id'); jax.call("community", "plugins,walls,ajaxRemoveComment", parentId, index); }, cancel: function(id) { joms.jQuery('#' + id + ' textarea').val(''); joms.jQuery('#' + id + ' textarea').height('auto'); joms.jQuery('#' + id + ' form').hide(); joms.jQuery('#' + id + ' .show-cmt').show(); joms.jQuery('#' + id + ' .wall-coc-errors').hide(); joms.jQuery('#' + id + '.wall-coc-form-action.add').removeAttr('disabled'); }, show: function(id) { var w = joms.jQuery('#' + id + ' form').parent().width(); joms.jQuery('#' + id + '.wall-coc-form-action.add').removeAttr('disabled'); joms.jQuery('#' + id + ' form').width(w).show(); joms.jQuery('#' + id + ' .show-cmt').hide(); var textarea = joms.jQuery('#' + id + ' textarea'); if (!textarea.data('autogrow')) { joms.utils.textAreaWidth(textarea); joms.utils.autogrow(textarea); textarea.blur(function() { if (joms.jQuery(this).val() == '') joms.comments.cancel(id); }).data('autogrow', true); } }, edit: function(id, parentid, host) { //Isn't an event if (typeof host == 'undefined') return; var targetBlock = null; if (joms.miniwall.type(host) == 'cModule-ActivityStream') { targetBlock = joms.jQuery("#cModule-ActivityStream"); } else { targetBlock = joms.jQuery(".cMain"); } targetBlock.find('div[data-commentid=' + id + ']').hide(); var temp = document.createElement("div"); var oldValue = targetBlock.find('div[data-commentid=' + id + '] .cStream-Content span.comment').html(); targetBlock.find('li[data-streamid=' + parentid + '] [data-formblock]').show(); targetBlock.find('li[data-streamid=' + parentid + '] [data-replyblock]').hide(); // @todo: should only autogrow once. var textarea = targetBlock.find('li[data-streamid=' + parentid + '] .cStream-Form').find('textarea'); temp.innerHTML = oldValue; var sanitized = temp.textContent || temp.innerText; textarea.val(sanitized); targetBlock.find('li[data-streamid=' + parentid + '] button').attr('onClick', 'joms.comments.saveEdit(' + id + ',' + parentid + ', this);return false;'); targetBlock.find('li[data-streamid=' + parentid + '] .cStream-FormCancel').attr('onClick', 'joms.comments.cancelEdit(' + id + ',' + parentid + ', this);return false;'); if (!textarea.data('autogrow')) { joms.utils.textAreaWidth(textarea); joms.utils.autogrow(textarea); textarea.focus(); /*textarea.blur(function(){ if (joms.jQuery(this).val()=='') joms.miniwall.cancel(id); }).data('autogrow', true);*/ } }, cancelEdit: function(id, parentid) { joms.jQuery('div[data-commentid=' + id + ']').show(); joms.jQuery('li[data-streamid=' + parentid + '] .cStream-FormCancel').attr('onClick', 'joms.miniwall.cancel(' + parentid + ');return false;'); joms.jQuery('li[data-streamid=' + parentid + '] button').attr('onClick', 'joms.miniwall.add(' + parentid + ');return false;'); joms.miniwall.cancel(parentid); }, saveEdit: function(id, parentid, host) { var targetBlock = null; if (joms.miniwall.type(host) == 'cModule-ActivityStream') { targetBlock = joms.jQuery("#cModule-ActivityStream"); } else { targetBlock = joms.jQuery(".cMain"); } var textarea = targetBlock.find('li[data-streamid=' + parentid + '] .cStream-Form').find('textarea'); if ( !textarea.data('inittextntags') ) { jax.call('community', 'system,ajaxeditComment', id, textarea.val(), parentid); return; } textarea.textntags( 'val', function( cmt ) { jax.call('community', 'system,ajaxeditComment', id, cmt, parentid); }); } }, utils: { // Resize the width of the giventext to follow the innerWidth of // another DOM object // The textarea must be visible textAreaWidth: function(target) { with (joms.jQuery(target)) { css('width', '100%'); // Google Chrome doesn't return correct outerWidth() else things would be nicer. css('width', parseInt(parent().width()) - parseInt(css('borderLeftWidth')) - parseInt(css('borderRightWidth')) - parseInt(css('padding-left')) - parseInt(css('padding-right')) + 11 ); } }, autogrow: function(id, options) { if (options == undefined) options = {}; // In JomSocial, by default every autogrow element will have a 300 maxHeight. options.maxHeight = options.maxHeight || 300; joms.jQuery(id).autogrow(options); } }, // asynchronous google map loader map: { // callback queue queue: [], // google map proxy execute: function( callback ) { if ( window.google && window.google.maps && window.google.maps.places ) { callback(); return; } if ( joms.map.loading ) { joms.map.queue.push( callback ); return; } joms.map.loading = true; joms.map.queue.push( callback ); joms.map.loadScript(); }, // google map library loader loadScript: function() { var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false&callback=joms.map.loadScriptCallback'; document.body.appendChild(script); }, // callback for google map library loader loadScriptCallback: function() { if ( joms.map.queue && joms.map.queue.length ) while ( joms.map.queue.length ) ( joms.map.queue.shift() )(); joms.map.loading = false; } }, maps: { mapsObj: null, geocoder: null, init: function() { if (joms.jQuery('.cMapFade') != null || joms.jQuery('.cMapHeatzone') != null) { joms.jQuery('.cMapFade').live('mouseover', function(e) { joms.jQuery(this).find('img:eq(2)').fadeOut(0); }); joms.jQuery('.cMapFade').live('mouseout', function(e) { joms.jQuery(this).find('img:eq(2)').fadeIn(0); }); joms.jQuery('.cMapHeatzone').live('mouseover', function(e) { joms.jQuery(this).parent().find('img:eq(1)').fadeOut(0); }); joms.jQuery('.cMapHeatzone').live('mouseout', function(e) { joms.jQuery(this).parent().find('img:eq(1)').fadeIn(0); }); } }, initialize: function(target, address, title, info) { joms.map.execute(function() { if (typeof google.maps == 'undefined') { // Google map is not loaded yet, wait another 1 seconds? setTimeout('joms.maps.initialize(\'' + target + '\', \'' + address + '\')', 1000); } else { joms.maps.geocoder = new google.maps.Geocoder(); joms.maps.geocoder.geocode({'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { if (joms.maps.mapsObj == null) { joms.maps.mapsObj = new Array(); } // @todo: unoptimized, should not load a random location first var latlng = new google.maps.LatLng(-34.397, 150.644); var mapOptions = { zoom: 14, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP } // Map id is incremented for each map var mapId = joms.maps.mapsObj.length; joms.maps.mapsObj[mapId] = new google.maps.Map(document.getElementById(target), mapOptions); joms.maps.mapsObj[mapId].setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: joms.maps.mapsObj[mapId], position: results[0].geometry.location, title: title }); if (info.length > 0) { var infowindow = new google.maps.InfoWindow({ content: info }); google.maps.event.addListener(marker, 'click', function() { var mapId = joms.jQuery('div#' + target).data('maps'); infowindow.open(joms.maps.mapsObj[mapId], marker); }); } // Store map object in the div id joms.jQuery('div#' + target).data('maps', mapId); } else { alert("Geocode was not successful for the following reason: " + status); } }); } }); }, addMarker: function(target, lat, lng, title, info) { joms.map.execute(function() { if (joms.maps.mapsObj == null) { // Google map is not loaded yet, wait another 1 seconds? setTimeout('joms.maps.addMarker(\'' + target + '\', ' + lat + ', ' + lng + ', \'' + title + '\', \'' + info + '\')', 1000); } else { var mapId = joms.jQuery('div#' + target).data('maps'); var myLatlng = new google.maps.LatLng(lat, lng); var marker = new google.maps.Marker({ position: myLatlng, map: joms.maps.mapsObj[mapId], title: title }); if (info.length > 0) { var infowindow = new google.maps.InfoWindow({ content: info }); google.maps.event.addListener(marker, 'click', function() { var mapId = joms.jQuery('div#' + target).data('maps'); infowindow.open(joms.maps.mapsObj[mapId], marker); }); } } }); } }, connect: { checkRealname: function(value) { var tmpLoadingFunction = jax.loadingFunction; jax.loadingFunction = function() { }; jax.doneLoadingFunction = function() { jax.loadingFunction = tmpLoadingFunction; }; jax.call('community', 'connect,ajaxCheckName', value); }, checkEmail: function(value) { var tmpLoadingFunction = jax.loadingFunction; jax.loadingFunction = function() { }; jax.doneLoadingFunction = function() { jax.loadingFunction = tmpLoadingFunction; }; jax.call('community', 'connect,ajaxCheckEmail', value); }, checkUsername: function(value) { var tmpLoadingFunction = jax.loadingFunction; jax.loadingFunction = function() { }; jax.doneLoadingFunction = function() { jax.loadingFunction = tmpLoadingFunction; }; jax.call('community', 'connect,ajaxCheckUsername', value); }, // Displays popup that requires user to update their details upon update: function() { var ajaxCall = "jax.call('community', 'connect,ajaxUpdate' );"; cWindowShow(ajaxCall, '', 450, 200); }, updateEmail: function() { joms.jQuery('#facebook-email-update').submit(); }, importData: function() { var importStatus = joms.jQuery('#importstatus').is(':checked') ? 1 : 0; var importAvatar = joms.jQuery('#importavatar').is(':checked') ? 1 : 0; jax.call('community', 'connect,ajaxImportData', importStatus, importAvatar); }, mergeNotice: function() { var ajaxCall = "jax.call('community','connect,ajaxMergeNotice');"; cWindowShow(ajaxCall, '', 450, 200); }, merge: function() { var ajaxCall = "jax.call('community','connect,ajaxMerge');"; cWindowShow(ajaxCall, '', 450, 200); }, validateUser: function() { // Validate existing user var ajaxCall = "jax.call('community','connect,ajaxValidateLogin','" + joms.jQuery('#existingusername').val() + "','" + joms.jQuery('#existingpassword').val() + "');"; cWindowShow(ajaxCall, '', 450, 200); }, newUser: function() { var ajaxCall = "jax.call('community','connect,ajaxShowNewUserForm');"; cWindowShow(ajaxCall, '', 450, 200); }, existingUser: function() { var ajaxCall = "jax.call('community','connect,ajaxShowExistingUserForm');"; cWindowShow(ajaxCall, '', 450, 200); }, selectType: function() { if (joms.jQuery('[name=membertype]:checked').val() == '1') { var tnc = joms.jQuery('#tnc:checked').val(); if ((joms.jQuery('#tnc:checked').length == 0) && (joms.jQuery('#tnc').length == 1)) { joms.jQuery('span#err_msg').css('display', 'block'); return false; } joms.connect.newUser(); } else { joms.connect.existingUser(); } }, validateNewAccount: function() { // Check for errors on the forms. jax.call('community', 'connect,ajaxCheckEmail', joms.jQuery('#newemail').val()); jax.call('community', 'connect,ajaxCheckUsername', joms.jQuery('#newusername').val()); jax.call('community', 'connect,ajaxCheckName', joms.jQuery('#newname').val()); var isValid = true; if (joms.jQuery('#newname').val() == "" || joms.jQuery('#error-newname').css('display') != 'none') { isValid = false; } if (joms.jQuery('#newusername').val() == "" || joms.jQuery('#error-newusername').css('display') != 'none') { isValid = false; } if (joms.jQuery('#newemail').val() == '' || joms.jQuery('#error-newemail').css('display') != 'none') { isValid = false; } if(joms.jQuery('.jsProfileType').length > 0 && joms.jQuery('.jsProfileType input:checked').length == 0){ jax.call('community', 'connect,ajaxCheckProfileType'); isValid = false; } if (isValid) { var profileType = ''; if (joms.jQuery('.jsProfileType').length > 0 && joms.jQuery('.jsProfileType input').length > 0) { profileType = (joms.jQuery('.jsProfileType input:checked').length > 0) ? joms.jQuery('.jsProfileType input:checked').val() : profileType; } var ajaxCall = "jax.call('community', 'connect,ajaxCreateNewAccount' , '" + joms.jQuery('#newname').val() + "', '" + joms.jQuery('#newusername').val() + "','" + joms.jQuery('#newemail').val() + "','" + profileType + "');"; cWindowShow(ajaxCall, '', 450, 200); } } }, // Video component videos: { playProfileVideo: function(id, userid) { var ajaxCall = "jax.call('community', 'profile,ajaxPlayProfileVideo', " + id + ", " + userid + ")"; cWindowShow(ajaxCall, '', 640, 360); }, linkConfirmProfileVideo: function(id) { var ajaxCall = "jax.call('community', 'profile,ajaxConfirmLinkProfileVideo', '" + id + "');"; cWindowShow(ajaxCall, '', 450, 100); }, linkProfileVideo: function(id) { var ajaxCall = "jax.call('community', 'profile,ajaxLinkProfileVideo', '" + id + "');"; cWindowShow(ajaxCall, '', 450, 100); }, removeConfirmProfileVideo: function(userid, videoid) { var ajaxCall = "jax.call('community', 'profile,ajaxRemoveConfirmLinkProfileVideo', '" + userid + "', '" + videoid + "');"; cWindowShow(ajaxCall, '', 450, 100); }, removeLinkProfileVideo: function(userid, videoid) { var ajaxCall = "jax.call('community', 'profile,ajaxRemoveLinkProfileVideo', '" + userid + "', '" + videoid + "');"; cWindowShow(ajaxCall, '', 450, 100); }, showEditWindow: function(id, redirectUrl) { if (typeof redirectUrl == 'undefined') redirectUrl = ''; var ajaxCall = "jax.call('community', 'videos,ajaxEditVideo', '" + id + "' , '" + redirectUrl + "');"; cWindowShow(ajaxCall, '', 450, 400); }, deleteVideo: function(videoId, currentTask, userId) { var ajaxCall = "jax.call('community' , 'videos,ajaxRemoveVideo', '" + videoId + "','" + currentTask + "','" + userId + "');"; cWindowShow(ajaxCall, '', 450, 150); }, playerConf: { // Default flowplayer configuration here }, addVideo: function(creatortype, groupid) { if (typeof creatortype == "undefined" || creatortype == "") { var creatortype = ""; var groupid = ""; } var ajaxCall = "jax.call('community', 'videos,ajaxAddVideo', '" + creatortype + "', '" + groupid + "');"; cWindowShow(ajaxCall, '', 600, 500); }, linkVideo: function(creatortype, groupid) { var ajaxCall = "jax.call('community', 'videos,ajaxLinkVideo', '" + creatortype + "', '" + groupid + "');"; cWindowShow(ajaxCall, '', 450, 100); }, uploadVideo: function(creatortype, groupid) { var ajaxCall = "jax.call('community', 'videos,ajaxUploadVideo', '" + creatortype + "', '" + groupid + "');"; cWindowShow(ajaxCall, '', 450, 100); }, submitLinkVideo: function() { var isValid = true; var videoLinkUrl = joms.jQuery('#linkVideo input[name=videoLinkUrl]'); if ( !joms.jQuery.trim(videoLinkUrl.val()) ) { videoLinkUrl.addClass('invalid'); videoLinkUrl.siblings('#videoLinkUrlError').show(); isValid = false; } else { videoLinkUrl.removeClass('invalid'); videoLinkUrl.siblings('#videoLinkUrlError').hide(); } var videoCategory = joms.jQuery('#linkVideo select[name=category_id]'); if ( !videoCategory.val() ) { videoCategory.addClass('invalid'); videoCategory.siblings('#videoCategoryError').show(); isValid = false; } else { videoCategory.removeClass('invalid'); videoCategory.siblings('#videoCategoryError').hide(); } if (isValid) { joms.jQuery('#cwin-wait').css("margin-left", "20px"); joms.jQuery('#cwin-wait').show(); document.linkVideo.submit(); } }, submitUploadVideo: function() { var isValid = true; var videoFile = joms.jQuery('#uploadVideo input[name=videoFile]'); if ( !joms.jQuery.trim(videoFile.val()) ) { videoFile.addClass('invalid'); isValid = false; } else { videoFile.removeClass('invalid'); } var videoTitle = joms.jQuery('#uploadVideo input[name=title]'); if ( !joms.jQuery.trim(videoTitle.val()) ) { videoTitle.addClass('invalid'); videoTitle.siblings('#videoTitleError').show(); isValid = false; } else { videoTitle.removeClass('invalid'); videoTitle.siblings('#videoTitleError').hide(); } var videoCategory = joms.jQuery('#uploadVideo select[name=category_id]'); if ( !videoCategory.val() ) { videoCategory.addClass('invalid'); videoCategory.siblings('#videoCategoryError').show(); isValid = false; } else { videoCategory.removeClass('invalid'); videoCategory.siblings('#videoCategoryError').hide(); } if (isValid) { joms.jQuery('#cwin-wait').css("margin-left", "20px"); joms.jQuery('#cwin-wait').show(); document.uploadVideo.submit(); } }, fetchThumbnail: function(videoId) { var ajaxCall = "jax.call('community' , 'videos,ajaxFetchThumbnail', '" + videoId + "','myvideos');"; cWindowShow(ajaxCall, '', 450, 150); }, toggleSearchSubmenu: function(e) { joms.jQuery(e).next('ul').toggle().find('input[type=text]').focus(); }, selectVideoTagFriends: function(videoId) { //reset old list joms.jQuery("#community-invited-list li").each(function(index) { var friendId = joms.jQuery(this).attr('id'); friendId = friendId.substr('invitation-friend-'.length); jax.call('community', 'videos,ajaxAddVideoTag', videoId, friendId); }); joms.jQuery('.invitation-check label').empty(); cWindowHide(); }, addVideoTextTag: function(tags, textRemove) { var videoTextTags = joms.jQuery('.videoTextTags'); if (typeof (tags) == 'string') tags = eval('(' + tags + ')'); // If it's a single tag, put it into an array anyway. var singleTag = false; if (!joms.jQuery.isArray(tags)) { tags = [tags]; singleTag = true; } // Create video tag joms.jQuery.each(tags, function(i, tag) { if (tag.id == undefined) return; // videoTextTag var videoTextTag = joms.jQuery(''); videoTextTag.data('tag', tag) .attr('id', 'videoTextTag-' + tag.id) .appendTo(videoTextTags); // videoTextTagLink var videoTextTagLink = joms.jQuery('
'); videoTextTagLink.attr('href', tag.profileUrl) .html(tag.displayName) .prependTo(videoTextTag); // videoTextTagActions if (tag.canRemove) { /* Temporarily belong inside this if condition */ var videoTextTagActions = joms.jQuery(''); videoTextTagActions.appendTo(videoTextTag); var videoTextTagAction_remove = joms.jQuery(''); videoTextTagAction_remove.addClass('_remove') .html(textRemove) .click(function() { joms.videos.removeVideoTag(tag); }) .appendTo(videoTextTagActions); videoTextTagActions.before(' ').prepend('(').append(')'); } }); joms.videos.commifyTextTags(); }, removeVideoTag: function(tag) { jax.call('community', 'videos,ajaxRemoveVideoTag', tag.videoId, tag.userId); if (tag == undefined) { joms.jQuery('.videoTextTags').remove(); } else { joms.jQuery('#videoTextTag-' + tag.id).remove(); } joms.videos.commifyTextTags(); }, commifyTextTags: function() { // Remove all comma joms.jQuery('.videoTextTags .comma').remove(); // Rebuild comma videoTextTag = joms.jQuery('.videoTextTag'); videoTextTag.each(function(i) { if (i == 0) return; var comma = joms.jQuery(''); comma.html(', ') .prependTo(this); }); }, checkSize: function(data) { //disable the button joms.jQuery('form#uploadVideo button').prop("disabled", true); if (joms.jQuery.browser.msie) { joms.jQuery('form#uploadVideo button').prop("disabled", false); return false; } else { Size = data.files[0].size; } jax.call('community', 'videos,ajaxCheckFileSize', Size); } }, users: { banUser: function(userId, isBlocked) { var ajaxCall = "jax.call('community', 'profile,ajaxBanUser', '" + userId + "' , '" + isBlocked + "');"; cWindowShow(ajaxCall, '', 450, 100); }, removePicture: function(userId) { var ajaxCall = "jax.call('community', 'profile,ajaxRemovePicture', '" + userId + "');"; cWindowShow(ajaxCall, '', 450, 100); }, updateURL: function(userId) { var ajaxCall = "jax.call('community', 'profile,ajaxUpdateURL', '" + userId + "');"; cWindowShow(ajaxCall, '', 450, 100); }, uploadNewPicture: function(userId) { var ajaxCall = "jax.call('community', 'profile,ajaxUploadNewPicture', '" + userId + "');"; cWindowShow(ajaxCall, '', 450, 100); }, /** * Do display block confirm dialog */ confirmBlockUser: function(userId) { var ajaxCall = 'jax.call("community", "profile,ajaxConfirmBlockUser", "' + userId + '");'; cWindowShow(ajaxCall, '', 450, 100); }, /** * Do block user */ blockUser: function(userId) { var ajaxCall = 'jax.call("community", "profile,ajaxBlockUser", "' + userId + '");'; cWindowShow(ajaxCall, '', 450, 100); }, /** * Do display unblock confirm dialog */ confirmUnBlockUser: function(userId) { var ajaxCall = 'jax.call("community", "profile,ajaxConfirmUnBlockUser", "' + userId + '");'; cWindowShow(ajaxCall, '', 450, 100); }, /** * Do unblock user */ unBlockUser: function(userId, layout) { layout = layout || null; var ajaxCall = 'jax.call("community", "profile,ajaxUnblockUser", "' + userId + '", "' + layout + '");'; cWindowShow(ajaxCall, '', 450, 100); }, /** * Do display ignore confirm dialog */ confirmIgnoreUser: function(userId) { var ajaxCall = 'jax.call("community", "profile,ajaxConfirmIgnoreUser", "' + userId + '");'; cWindowShow(ajaxCall, '', 450, 100); }, /** * Do ignore */ ignoreUser: function(userId) { var ajaxCall = 'jax.call("community", "profile,ajaxIgnoreUser", "' + userId + '");'; cWindowShow(ajaxCall, '', 450, 100); }, /** * Do display Unignore confirm dialog */ confirmUnIgnoreUser: function(userId) { var ajaxCall = 'jax.call("community", "profile,ajaxConfirmUnIgnoreUser", "' + userId + '");'; cWindowShow(ajaxCall, '', 450, 100); }, /** * Do unignore user */ unIgnoreUser: function(userId) { var ajaxCall = 'jax.call("community", "profile,ajaxUnIgnoreUser", "' + userId + '");'; cWindowShow(ajaxCall, '', 450, 100); }, removeCover: function(userId) { var ajaxCall = "jax.call('community', 'profile,ajaxRemoveCover', '" + userId + "');"; cWindowShow(ajaxCall, '', 450, 100); } }, user: { getActive: function( ) { // return the current active user return js_profileId; } }, events: { deleteEvent: function(eventId) { var ajaxCall = "jax.call('community', 'events,ajaxWarnEventDeletion', '" + eventId + "');"; cWindowShow(ajaxCall, '', 450, 100, 'warning'); }, join: function(eventId) { var ajaxCall = 'jax.call("community", "events,ajaxRequestInvite", "' + eventId + '", location.href );'; cWindowShow(ajaxCall, '', 450, 100); }, leave: function(eventId) { var ajaxCall = 'jax.call("community", "events,ajaxIgnoreEvent", "' + eventId + '");'; cWindowShow(ajaxCall, '', 450, 100); }, sendmail: function(eventId) { var ajaxCall = 'jax.call("community", "events,ajaxSendEmail", "' + eventId + '");'; cWindowShow(ajaxCall, '', 450, 300); }, confirmBlockGuest: function(userId, eventId) { var ajaxCall = 'jax.call("community", "events,ajaxConfirmBlockGuest", "' + userId + '", "' + eventId + '");'; cWindowShow(ajaxCall, '', 450, 100); }, blockGuest: function(userId, eventId) { var ajaxCall = 'jax.call("community", "events,ajaxBlockGuest", "' + userId + '", "' + eventId + '");'; cWindowShow(ajaxCall, '', 450, 100); }, confirmUnblockGuest: function(userId, eventId) { var ajaxCall = 'jax.call("community", "events,ajaxConfirmUnblockGuest", "' + userId + '", "' + eventId + '");'; cWindowShow(ajaxCall, '', 450, 100); }, unblockGuest: function(userId, eventId) { var ajaxCall = 'jax.call("community", "events,ajaxUnblockGuest", "' + userId + '", "' + eventId + '");'; cWindowShow(ajaxCall, '', 450, 100); }, confirmRemoveGuest: function(userId, eventId) { var ajaxCall = 'jax.call("community", "events,ajaxConfirmRemoveGuest", "' + userId + '", "' + eventId + '");'; cWindowShow(ajaxCall, '', 450, 80, 'warning'); }, removeGuest: function(userId, eventId) { var blockGuest = joms.jQuery('#cWindow input[name=block]').attr('checked'); var ajaxCall = '' if (blockGuest) { ajaxCall = 'jax.call("community", "events,ajaxBlockGuest", "' + userId + '", "' + eventId + '");'; } else { ajaxCall = 'jax.call("community", "events,ajaxRemoveGuest", "' + userId + '", "' + eventId + '");'; } cWindowShow(ajaxCall, '', 450, 100, 'warning'); }, joinNow: function(eventId) { jax.call("community", "events,ajaxJoinInvitation", eventId); }, rejectNow: function(eventId) { jax.call('community', 'events,ajaxRejectInvitation', eventId); }, toggleSearchSubmenu: function(e) { joms.jQuery(e).next('ul').toggle().find('input[type=text]').focus(); }, displayNearbyEvents: function(location) { joms.ajax.call('events,ajaxDisplayNearbyEvents', [location], { success: function(html) { joms.jQuery('#community-event-nearby-listing').html(html); } }); }, getDayEvent: function(day, month, year, groupid) { //show loading image jax.loadingFunction = function() { joms.jQuery('.loading-icon').show(); }; jax.doneLoadingFunction = function() { joms.jQuery('.loading-icon').hide(); }; //since 2.6 : added groupid param if applicable jax.cacheCall('community', 'events,ajaxGetEvents', day, month, year, groupid); }, displayDayEvent: function(response) { joms.jQuery('.events-list').html(''); var day_event = eval('(' + response + ')'); if (day_event.length > 0) { //events exist, unhide the 'happening event' joms.jQuery('strong.happening_title').show(); } else { joms.jQuery('strong.happening_title').hide(); } for (var i = 0; i < day_event.length; i++) { var start_day = day_event[i]['start']; var end_day = day_event[i]['end']; joms.jQuery('.events-list').html(joms.jQuery('.events-list').html() + '
  • ' + day_event[i]['title'] + '
  • '); joms.jQuery('a[class^="date_day_"]').mouseenter(function() { var date_str = joms.jQuery(this).attr('class').split('_'); var start = date_str[2]; var end = parseInt(date_str[3]) + 1; for (var j = start; j < end; j++) { joms.jQuery('.event_date_' + j).addClass('highlightrunning'); } }); joms.jQuery('a[class^="date_day_"]').mouseleave(function() { joms.jQuery('.highlightrunning').removeClass('highlightrunning'); }); if (i + 1 != day_event.length) { joms.jQuery('.events-list').html(joms.jQuery('.events-list').html()); } } }, getCalendar: function(month, year) { jax.cacheCall('community', 'events,ajaxGetCalendar', month, year); }, displayCalendar: function(response) { joms.jQuery('div#event').html(response); init_calendar(); }, switchImport: function(importType) { if (importType == 'file') { joms.jQuery('#event-import-url').css('display', 'none'); joms.jQuery('#event-import-file').css('display', 'block'); joms.jQuery('#import-type').val('file'); } if (importType == 'url') { joms.jQuery('#event-import-file').css('display', 'none'); joms.jQuery('#event-import-url').css('display', 'block'); joms.jQuery('#import-type').val('url'); } }, showMapWindow: function() { var ajaxCall = 'jax.call("community", "events,ajaxShowMap");'; cWindowShow(ajaxCall, '', 450, 100); }, showDesc: function() { joms.jQuery('#event-discription').show(); joms.jQuery('#event-description-link').hide(); }, submitRSVP: function(eventId, e) { var select = joms.jQuery( e ), parent = select.parent(), label = select.prev('span'), value = select.val(), klass = select.attr('class'), text = select.find('option:selected').text(); if ( joms.events.submitRSVP.processing ) return false; // create unclickable layer parent.append('
    '); setTimeout(function() { label.html('Processing...'); label.removeAttr('class'); joms.events.submitRSVP.processing = true; joms.ajax.call( 'events,ajaxUpdateStatus', [ eventId, select.val() ], { success: function( html ) { joms.events.submitRSVP.processing = false; joms.jQuery("#community-event-members").replaceWith( html ); label.attr('class', select.find('option:selected').attr('class') ); label.html( text ); parent.children('.noclick').remove(); } }); }, 100 ); }, save: function() { var ajaxCall = "jax.call('community', 'events,ajaxShowRepeatOption');"; cWindowShow(ajaxCall, '', 450, 100); }, uploadAvatar: function(type, id, isRecurring) { var custom = null; if (isRecurring) { custom = '{"call":["CEvents","getEventRepeatSaveHTML"], "library":"events", "arg":{"radio":"repeattype"}}'; } var jaxCall = jax.call("community", "photos,ajaxUploadAvatar", type, id, custom); cWindowShow(jaxCall, '', 450, 100); } }, profile: { confirmRemoveAvatar: function() { var ajaxCall = 'jax.call("community", "profile,ajaxConfirmRemoveAvatar");'; cWindowShow(ajaxCall, '', 450, 100); }, setStatusLimit: function(textAreaElement) { joms.jQuery(textAreaElement).keyup(function() { var max = parseInt(joms.jQuery(this).attr('maxlength')); if (joms.jQuery(this).val().length > max) { joms.jQuery(this).val(joms.jQuery(this).val().substr(0, joms.jQuery(this).attr('maxlength'))); } joms.jQuery('#profile-status-notice span').html((max - joms.jQuery(this).val().length)); }); } }, privacy: { init: function() { joms.jQuery('select.js_PrivacySelect').each(function() { var tmpHTML = ""; var currValue; // get current value of pre-selected item from the dropdown joms.jQuery(this).find('option').each(function() { if (joms.jQuery(this).attr('selected')) { currValue = joms.jQuery(this).val(); } }); // construct HTML tmpHTML += "
    \n"; tmpHTML += "
    " + joms.jQuery(this).find('option[selected="selected"]').text() + "
    \n"; tmpHTML += "
    \n
      \n"; joms.jQuery(this).find('option').each(function() { var currOptVal = joms.jQuery(this).val(); // add extra class for currently selected option if (currOptVal == currValue) { tmpHTML += "
    • "; } else { tmpHTML += "
    • "; } tmpHTML += "" + joms.jQuery(this).text() + "
    • \n"; }); tmpHTML += "
    \n
    \n
    "; // write HTML joms.jQuery(this).parent().prepend(tmpHTML); // hide original select box joms.jQuery(this).hide(); }); joms.jQuery('.js_dropDownChild').die('click touchstart'); joms.jQuery('.js_dropDownChild').live('click touchstart', function(e) { e.preventDefault(); var selectedVal = joms.jQuery(this).attr('name'); var selectedText = ""; // once clicked, change the select to pick that one joms.jQuery(this).closest('.js_PriContainer').find('option').each(function() { // traverse through each select box and mark the same value as 'selected' = true if (joms.jQuery(this).val() == selectedVal) { joms.jQuery(this).attr('selected', 'selected'); selectedText = joms.jQuery(this).text(); } else { joms.jQuery(this).attr('selected', false); } }); // get current selection value var dropDownObj = joms.jQuery(this).parent().parent().parent().parent().find('dt'); var currShowVal = dropDownObj.attr('name'); dropDownObj.removeClass('js_dropSelect-' + currShowVal).addClass('js_dropSelect-' + selectedVal).attr('name', selectedVal).html('' + selectedText + ''); joms.privacy.closeAll(); }); // click trigger to open joms.jQuery('.js_dropDownMaster dt').die('click touchstart'); joms.jQuery('.js_dropDownMaster dt').live('click touchstart', function(e) { e.preventDefault(); if (joms.jQuery(this).parent().data('state')) { // joms.jQuery(this).parent().data('state',0).removeClass('js_Current').find('dd').hide(); joms.privacy.closeAll(); joms.jQuery('body').unbind('click'); } else { joms.privacy.closeAll(); joms.jQuery(this).parent().parent().addClass('js_PrivacyOpen'); joms.jQuery(this).parent().data('state', 1).addClass('js_Current').find('dd').show(); joms.jQuery('body').bind('click', function(e) { var tarObj = joms.jQuery(e.target); if (tarObj.parents('.js_PriContainer').length == 0) { joms.privacy.closeAll(); } }); } }); }, closeAll: function() { joms.jQuery('.js_PriContainer').removeClass('js_PrivacyOpen'); joms.jQuery('.js_dropDownMaster').each(function() { joms.jQuery(this).data('state', 0).removeClass('js_Current').find('dd').hide(); }); } }, tooltip: { setup: function( ) { joms.jQuery('.jomNameTips').tipsy({live: true, gravity: 'sw'}); //return; // Hide all active visible qTip joms.jQuery('.qtip-active').hide(); setTimeout('joms.jQuery(\'.qtip-active\').hide()', 150); try { clearTimeout(joms.jQuery.fn.qtip.timers.show); } catch (e) { } // Scan the document and setup the tooltip that has .jomTips joms.jQuery(".jomTips").each(function() { var tipStyle = 'tipNormal'; var tipWidth = 220; var tipPos = {corner: {target: 'topMiddle', tooltip: 'bottomMiddle'}} var tipShow = true; var tipHide = {when: {event: 'mouseout'}, effect: {length: 10}} if (joms.jQuery(this).hasClass('tipRight')) { tipStyle = 'tipRight'; tipWidth = 320; tipPos = {corner: {target: 'rightMiddle', tooltip: 'leftMiddle'}} } if (joms.jQuery(this).hasClass('tipWide')) { tipWidth = 420; } if (joms.jQuery(this).hasClass('tipFullWidth')) { tipWidth = joms.jQuery(this).innerWidth() - 20; } // Split the title and the content var title = ''; var content = joms.jQuery(this).attr('title'); var contentArray = ''; if (content) { contentArray = content.split('::'); } // Remove the 'title' attributes from the existing .jomTips classes joms.jQuery(this).attr('title', ''); if (contentArray.length == 2) { content = contentArray[1]; title = {text: contentArray[0]}; } else title = title = {text: ''}; ; joms.jQuery(this).qtip({ content: { text: content, title: title }, style: {name: tipStyle, width: tipWidth}, position: tipPos, hide: tipHide, show: {solo: true, effect: {length: 50}} }).removeClass('jomTips'); }); return true; }, setStyle: function() { joms.jQuery.fn.qtip.styles.tipNormal = {// Last part is the name of the style width: 320, border: { width: 7, radius: 5 }, tip: true, name: 'dark' // Inherit the rest of the attributes from the preset dark style } joms.jQuery.fn.qtip.styles.tipRight = {// Last part is the name of the style tip: 'leftMiddle', name: 'tipNormal' // Inherit the rest of the attributes from the preset dark style } return true; } }, like: { init: function() { // Bind like press joms.jQuery('a[href="#like"]').live('click', function() { var streamid = joms.jQuery(this).parents('li.stream').data('streamid'); jax.call('community', 'system,ajaxStreamAddLike', streamid); return false; }); // Bind unlike press joms.jQuery('a[href="#unlike"]').live('click', function() { var streamid = joms.jQuery(this).parents('li.stream').data('streamid'); jax.call('community', 'system,ajaxStreamUnlike', streamid); return false; }); }, extractData: function(id) { id = id.split('-'); var data = []; data['element'] = id[1]; data['itemid'] = id[2]; // replace element _ with . data['element'] = data['element'].replace('_', '.'); return data; }, like: function(e) { var like = joms.jQuery(e).parents('.like-snippet'); var data = this.extractData(like.attr('id')); // Remove the onclick attribute value to avoid double processing joms.jQuery(e).unbind('onclick'); joms.ajax.call('system,ajaxLike', [data['element'], data['itemid']], { success: function(html) { like.replaceWith(html); } }); }, newLike: function(e) { var like = joms.jQuery(e).parent(); var data = this.extractData(like.attr('id')); // Remove the onclick attribute value to avoid double processing joms.jQuery(e).unbind('onclick'); var counter = joms.jQuery(joms.jQuery(e).children()[1]).html(); joms.ajax.call('system,ajaxLike', [data['element'], data['itemid']], { success: function(html) { counter = parseInt(counter) + 1; joms.jQuery(e).addClass('js-focus-like'); joms.jQuery(e).attr('onclick', 'joms.like.newDislike(this)'); joms.jQuery(joms.jQuery(e).children()[1]).html(counter); } }); }, newDislike: function(e) { var like = joms.jQuery(e).parent(); var data = this.extractData(like.attr('id')); // Remove the onclick attribute value to avoid double processing joms.jQuery(e).unbind('onclick'); var counter = joms.jQuery(joms.jQuery(e).children()[1]).html(); joms.ajax.call('system,ajaxDislike', [data['element'], data['itemid']], { success: function(html) { counter = parseInt(counter) - 1; joms.jQuery(e).removeClass('js-focus-like'); joms.jQuery(e).attr('onclick', 'joms.like.newLike(this)'); joms.jQuery(joms.jQuery(e).children()[1]).html(counter); } }); }, dislike: function(e) { var like = joms.jQuery(e).parents('.like-snippet'); var data = this.extractData(like.attr('id')); // Remove the onclick attribute value to avoid double processing joms.jQuery(e).unbind('onclick'); joms.ajax.call('system,ajaxDislike', [data['element'], data['itemid']], { success: function(html) { like.replaceWith(html); } }); }, unlike: function(e) { var like = joms.jQuery(e).parents('.like-snippet'); var data = this.extractData(like.attr('id')); // Remove the onclick attribute value to avoid double processing joms.jQuery(e).unbind('onclick'); joms.ajax.call('system,ajaxUnlike', [data['element'], data['itemid']], { success: function(html) { like.replaceWith(html); } }); } }, tag: { add: function(element, id) { jax.call('community', 'system,ajaxAddTag', element, id, joms.jQuery('#tag-addbox').val()); }, pick: function(element, id, tag) { jax.call('community', 'system,ajaxAddTag', element, id, tag); }, remove: function(id) { jax.call('community', 'system,ajaxRemoveTag', id); }, moreHide: function(element, id) { joms.jQuery('#tag-list li').each(function(i, l) { if (i > 8) { // @todo: limit should come from global config joms.jQuery(l).hide(); } }); joms.jQuery('.more-tag-show').show(); joms.jQuery('.more-tag-hide').hide(); }, moreShow: function(element, id) { joms.jQuery('#tag-list li').each(function(i, l) { if (i > 8) { // @todo: limit should come from global config joms.jQuery(l).show(); } }); joms.jQuery('.more-tag-show').hide(); joms.jQuery('.more-tag-hide').show(); }, toggleMore: function(element, id) { // Hide/show other tags joms.jQuery('#tag-list li').each(function(i, l) { if (i > 8) { // @todo: limit should come from global config joms.jQuery(l).toggle(); } }); }, list: function(tag) { var ajaxCall = "jax.call('community', 'system,ajaxShowTagged', '" + tag + "');"; cWindowShow(ajaxCall, '', 450, 100); }, edit: function(element, cid) { // start edit window joms.tag.moreShow(element, cid); var tagClass = element + "-" + cid; joms.jQuery('#tag-editor.tag-editor-' + tagClass + ',.tag-token a.tag-delete').show(); }, done: function(element, cid) { joms.tag.moreHide(element, cid); var tagClass = element + "-" + cid; joms.jQuery('#tag-editor.tag-editor-' + tagClass + ',.tag-token a.tag-delete').hide(); } }, geolocation: { showNearByEvents: function(location) { joms.map.execute(function() { joms.jQuery('#community-event-nearby-listing').show(); joms.jQuery('#showNearByEventsLoading').show(); // Check if already have the input if (typeof (location) == 'undefined') { // Check if the browsers support W3C Geolocation API if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(location) { var lat = location.coords.latitude; var lng = location.coords.longitude; // Reverse Geocoding - Google Maps Javascript API V3 Services geocoder = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(lat, lng); geocoder.geocode({'latLng': latlng}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { if (results[4]) { location = results[4].formatted_address; joms.geolocation.setCookie('currentLocation', location); joms.events.displayNearbyEvents(location); } } else { alert("Geocoder failed due to: " + status); } }); }); } else // If the browser not support W3C Geolocation API, show the error message { alert('Sorry, your browser does not support this feature.'); joms.jQuery('#community-event-nearby-listing').hide(); joms.jQuery('#showNearByEventsLoading').hide(); } } else { joms.events.displayNearbyEvents(location); } }); }, validateNearByEventsForm: function() { var location = joms.jQuery('#userInputLocation').val(); if (location.length != 0) { joms.geolocation.showNearByEvents(location); } }, setCookie: function(c_name, value) { var exdate = new Date(); // Calculate expiry date 1 hour from now exdate.setTime(exdate.getTime() + (60 * 60 * 1000)); document.cookie = c_name + "=" + escape(value) + ";expires=" + exdate; }, getCookie: function(c_name) { if (document.cookie.length > 0) { c_start = document.cookie.indexOf(c_name + "="); if (c_start != -1) { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf(";", c_start); if (c_end == -1) c_end = document.cookie.length; return unescape(document.cookie.substring(c_start, c_end)); } } return ""; } }, file: { showFileUpload: function(type, id) { var ajaxCall = 'jax.call("community", "files,ajaxFileUploadForm","' + type + '",' + id + ')'; cWindowShow(ajaxCall, '', 600, 400); }, enableEditName: function() { if (joms.jQuery('.plupload_file_name span').length > 0) { joms.jQuery('.plupload_file_name span').unbind('click'); joms.jQuery('.plupload_file_name span').bind('click', function(event) { joms.file.editName(event) }); } }, editName: function(event) { joms.jQuery('.plupload_file_name span').unbind('click'); var obj = (event.target) ? event.target : event.which; var fileId = joms.jQuery(obj).parent().parent().attr('id'); var editInput = ''; joms.jQuery(obj).html(editInput); joms.jQuery(obj).find('input').unbind("keypress").unbind("focusout"); joms.jQuery(obj).find('input').bind('keypress', function(event) { keyCode = event.keyCode; if (keyCode == 13) { joms.file.saveName(this, joms.jQuery(this).parent()); joms.jQuery('.plupload_file_name span').bind('click', function(event) { joms.file.editName(event) }); } }); joms.jQuery(obj).find('input').bind('focusout', function() { joms.file.saveName(this, joms.jQuery(this).parent()); joms.jQuery('.plupload_file_name span').bind('click', function(event) { joms.file.editName(event) }); }); }, saveName: function(inputObj, spanObj) { var fileId = joms.jQuery(inputObj).attr('target'); var currentFile = joms.jQuery("#html5_uploader").pluploadQueue().getFile(parseInt(fileId)); var value = joms.jQuery(inputObj).val(); currentFile.name = value; var saveValue = encodeURIComponent(value); jax.call("community", "files,ajaxSaveName", currentFile.id, saveValue); joms.jQuery(spanObj).html(value); }, ajaxDeleteFile: function(type, id) { jax.call("community", "files,ajaxDeleteFile", type, id) }, ajaxUploadFile: function(url, type, size) { var reloadPage = false; var pluploader = joms.file.___uploader = joms.jQuery("#html5_uploader").pluploadQueue({ // General settings runtimes: 'html5,html4', url: url, max_file_size: size + 'mb', chunk_size: size + 'mb', unique_names: true, filters: [{'title': "Media files", 'extensions': type}], preinit: { FileUploaded: function(uploader, file, response) { try { var uploadData = joms.jQuery.parseJSON(response.response); } catch (e) { joms.jQuery("#html5_uploader").pluploadQueue().stop(); } var uploadedFile = joms.jQuery("#html5_uploader").pluploadQueue().getFile(file.id); uploadedFile.id = uploadData.id; if (typeof uploadData.msg != 'undefined') { joms.jQuery("#html5_uploader").pluploadQueue().stop(); joms.jQuery('#cWindowContent').prepend('' + uploadData.msg + ' '); } }, UploadComplete: function(uploader) { setTimeout("joms.file.enableEditName();", 1000); reloadPage = true; joms.jQuery('#upload-footer').show(); cWindowResize(); joms.jQuery('a.add-more').click(function() { joms.jQuery("#html5_uploader").pluploadQueue().splice(); joms.jQuery(".plupload_buttons").show(); joms.jQuery(".plupload_file_status").hide(); joms.jQuery('div#upload-footer').hide(); cWindowResize(); }); } } }); // fix the button for html4 if ( pluploader.pluploadQueue().runtime == 'html4' ) { joms.file.ieUploadButtonFix(); } joms.jQuery('.plupload_header').remove(); joms.jQuery('span.plupload_upload_status').remove(); //reposition the input type file joms.jQuery('input:file').parent().css('top', '245px'); joms.jQuery("#cwin_close_btn").click(function() { if (reloadPage) window.location.reload(); }); }, ieUploadButtonFix: function() { var uploader = joms.file.___uploader; if ( !uploader ) return; var btn = uploader.find('.plupload_add'); var form = uploader.find('form'); var file = form.find('input[type=file]'); if ( !btn.length || !file.length ) return; btn.wrap(''); var span = btn.parent(); span.css({ display: 'inline-block', position: 'relative', overflow: 'hidden' }); form.appendTo( span ); setTimeout(function(){ form.css({ margin: 0, padding: 0, position: 'absolute', left: 0, top: 0, right: '', bottom: '', width: '100%', height: '100%', overflow: 'hidden' }); file.css({ margin: 0, padding: 0, position: 'absolute', width: '70px', fontSize: '30px' }) }, 1000 ); }, viewFile: function(type, parentId) { var ajaxCall = 'jax.call("community", "files,ajaxviewFiles","' + type + '","' + parentId + '")'; cWindowShow(ajaxCall, '', 600, 400); }, ajaxdownloadFile: function(type, id) { var ajaxCall = 'jax.call("community","files,ajaxFileDownload","' + type + '","' + id + '")'; cWindowShow(ajaxCall, '', 600, 200); }, getFileList: function(extension, groupid, startlimit, limit, type) { //reset the load more counter joms.jQuery('#load-more-btn').html(''); jax.call('community', 'files,ajaxgetFileList', extension, groupid, startlimit, limit, type); }, updateFileList: function(files, extension) { currentFiles = joms.jQuery('#' + extension).html(); newFiles = currentFiles + files; joms.jQuery('#' + extension).html(newFiles); }, viewMore: function(type, id) { var ajaxCall = 'jax.call("community","files,ajaxviewMore","' + type + '","' + id + '")'; cWindowShow(ajaxCall, '', 600, 200); }, loadFile: function(name, groupid, startlimit, limit, type) { joms.jQuery('#load-more-btn').html(''); jax.call('community', 'files,ajaxgetFileList', name, groupid, startlimit, limit, type); }, searchFileUpdate: function(files, extension) { joms.jQuery(joms.jQuery('ul.cTabNav li.active').children().attr('href')).html(files); }, startdownload: function(url) { var id = 'dl_' + (new Date).getTime(); url = url.replace('&', '&'); joms.jQuery('