Clean up some JS
This commit is contained in:
parent
fc526ff315
commit
804b6cc490
11 changed files with 64 additions and 68 deletions
|
|
@ -22,8 +22,8 @@ javascripts:
|
||||||
- public/javascripts/vendor/charCount.js
|
- public/javascripts/vendor/charCount.js
|
||||||
- public/javascripts/jquery.autocomplete-custom.js
|
- public/javascripts/jquery.autocomplete-custom.js
|
||||||
- public/javascripts/jquery.infieldlabel-custom.js
|
- public/javascripts/jquery.infieldlabel-custom.js
|
||||||
- public/javascripts/fileuploader-custom.js
|
|
||||||
- public/javascripts/keycodes.js
|
- public/javascripts/keycodes.js
|
||||||
|
- public/javascripts/fileuploader-custom.js
|
||||||
- public/javascripts/diaspora.js
|
- public/javascripts/diaspora.js
|
||||||
- public/javascripts/widgets/i18n.js
|
- public/javascripts/widgets/i18n.js
|
||||||
- public/javascripts/widgets/alert.js
|
- public/javascripts/widgets/alert.js
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@ var ApiConsole = {
|
||||||
prettyPrint: function(obj, indent)
|
prettyPrint: function(obj, indent)
|
||||||
{
|
{
|
||||||
var result = "";
|
var result = "";
|
||||||
if (indent == null) indent = "";
|
if (indent === null) { indent = ""; }
|
||||||
|
|
||||||
for (var property in obj)
|
for (var property in obj)
|
||||||
{
|
{
|
||||||
var value = obj[property];
|
var value = obj[property];
|
||||||
if (typeof value == 'string')
|
if (typeof value == 'string')
|
||||||
value = "'" + value + "'";
|
{ value = "'" + value + "'"; }
|
||||||
else if (typeof value == 'object')
|
else if (typeof value == 'object')
|
||||||
{
|
{
|
||||||
if (value instanceof Array)
|
if (value instanceof Array)
|
||||||
|
|
@ -46,7 +46,7 @@ var ApiConsole = {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,9 +60,9 @@ var AspectEdit = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (person.attr('data-aspect_id') != undefined && // a request doesn't have a data-aspect_id, but an existing contact does
|
if (person.attr('data-aspect_id') !== undefined && // a request doesn't have a data-aspect_id, but an existing contact does
|
||||||
dropzone.attr('data-aspect_id') != person.attr('data-aspect_id')) {
|
dropzone.attr('data-aspect_id') != person.attr('data-aspect_id')) {
|
||||||
var aspect_id = person.attr('data-aspect_id')
|
var aspect_id = person.attr('data-aspect_id');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "PUT",
|
type: "PUT",
|
||||||
url: "/aspect_memberships/garbage",
|
url: "/aspect_memberships/garbage",
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ var AspectFilters = {
|
||||||
}
|
}
|
||||||
listElement.removeClass('selected');
|
listElement.removeClass('selected');
|
||||||
|
|
||||||
if(AspectFilters.selectedGUIDS.length == 0){
|
if(AspectFilters.selectedGUIDS.length === 0){
|
||||||
homeListElement.addClass('selected');
|
homeListElement.addClass('selected');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,7 +117,7 @@ var AspectFilters = {
|
||||||
// update the open aspects in the user
|
// update the open aspects in the user
|
||||||
updateURL = "/user";
|
updateURL = "/user";
|
||||||
updateURL += '?';
|
updateURL += '?';
|
||||||
if(AspectFilters.selectedGUIDS.length == 0){
|
if(AspectFilters.selectedGUIDS.length === 0){
|
||||||
updateURL += 'user[a_ids][]=home';
|
updateURL += 'user[a_ids][]=home';
|
||||||
} else {
|
} else {
|
||||||
for(i=0; i < AspectFilters.selectedGUIDS.length; i++){
|
for(i=0; i < AspectFilters.selectedGUIDS.length; i++){
|
||||||
|
|
@ -127,7 +127,7 @@ var AspectFilters = {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : updateURL,
|
url : updateURL,
|
||||||
type: "PUT",
|
type: "PUT"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
performAjax: function(newURL) {
|
performAjax: function(newURL) {
|
||||||
|
|
@ -157,9 +157,9 @@ var AspectFilters = {
|
||||||
// (not cached because this element changes)
|
// (not cached because this element changes)
|
||||||
|
|
||||||
var textarea = $("#publisher textarea");
|
var textarea = $("#publisher textarea");
|
||||||
var photozone = $('#photodropzone')
|
var photozone = $('#photodropzone');
|
||||||
|
|
||||||
if( post != "" ) {
|
if( post !== "" ) {
|
||||||
textarea.val(post);
|
textarea.val(post);
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
}
|
}
|
||||||
|
|
@ -175,7 +175,7 @@ var AspectFilters = {
|
||||||
Diaspora.widgets.publish("stream/reloaded");
|
Diaspora.widgets.publish("stream/reloaded");
|
||||||
|
|
||||||
// fade contents back in
|
// fade contents back in
|
||||||
if(AspectFilters.requests == 0){
|
if(AspectFilters.requests === 0){
|
||||||
AspectFilters.fadeIn();
|
AspectFilters.fadeIn();
|
||||||
AspectFilters.performAspectUpdate();
|
AspectFilters.performAspectUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,12 @@ $(document).ready(function() {
|
||||||
$(this).fadeTo(200,0.4);
|
$(this).fadeTo(200,0.4);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.added').live('ajax:success', function(data, json, xhr) {
|
$('.added').live('ajax:success', function(data, jsonString, xhr) {
|
||||||
var json = $.parseJSON(json);
|
var json = $.parseJSON(jsonString);
|
||||||
var contactPictures = $(".contact_pictures");
|
var contactPictures = $(".contact_pictures");
|
||||||
|
|
||||||
if( contactPictures.length > 0 ) {
|
if( contactPictures.length > 0 ) {
|
||||||
if( contactPictures[0].childElementCount == 0 ) {
|
if( contactPictures[0].childElementCount === 0 ) {
|
||||||
$("#no_contacts").fadeIn(200);
|
$("#no_contacts").fadeIn(200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -79,8 +79,8 @@ $(document).ready(function() {
|
||||||
$(this).fadeTo(200,0.4);
|
$(this).fadeTo(200,0.4);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.add').live('ajax:success', function(data, json, xhr) {
|
$('.add').live('ajax:success', function(data, jsonString, xhr) {
|
||||||
var json = $.parseJSON(json);
|
var json = $.parseJSON(jsonString);
|
||||||
if( $("#no_contacts").is(':visible') ) {
|
if( $("#no_contacts").is(':visible') ) {
|
||||||
$("#no_contacts").fadeOut(200);
|
$("#no_contacts").fadeOut(200);
|
||||||
}
|
}
|
||||||
|
|
@ -90,8 +90,10 @@ $(document).ready(function() {
|
||||||
|
|
||||||
if($('#aspects_list').length == 1) {
|
if($('#aspects_list').length == 1) {
|
||||||
$('.aspect_list').attr('data-contact_id', json.contact_id);
|
$('.aspect_list').attr('data-contact_id', json.contact_id);
|
||||||
$('.aspect_list ul').find('.add').each(function(a,b){$(b).attr('href', $(b).attr('href').replace('contacts','aspect_memberships'));})
|
$('.aspect_list ul').find('.add').each(function(a,b){
|
||||||
};
|
$(b).attr('href', $(b).attr('href').replace('contacts','aspect_memberships'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$(this).fadeTo(200,1);
|
$(this).fadeTo(200,1);
|
||||||
});
|
});
|
||||||
|
|
@ -104,8 +106,8 @@ $(document).ready(function() {
|
||||||
$(this).children("img").attr("src","/images/icons/monotone_check_yes.png");
|
$(this).children("img").attr("src","/images/icons/monotone_check_yes.png");
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.new_aspect').live('ajax:success', function(data, json, xhr){
|
$('.new_aspect').live('ajax:success', function(data, jsonString, xhr){
|
||||||
var json = JSON.parse(json);
|
var json = JSON.parse(jsonString);
|
||||||
$('#aspects_list ul').append(json.html);
|
$('#aspects_list ul').append(json.html);
|
||||||
$("#aspects_list ul li[data-guid='" + json.aspect_id + "'] .add.button").click();
|
$("#aspects_list ul li[data-guid='" + json.aspect_id + "'] .add.button").click();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var Diaspora = { };
|
var Diaspora = { };
|
||||||
|
vara = 5;
|
||||||
|
|
||||||
Diaspora.WidgetCollection = function() {
|
Diaspora.WidgetCollection = function() {
|
||||||
this.initialized = false;
|
this.initialized = false;
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,12 @@ qq.extend = function(first, second){
|
||||||
* @param {Number} [from] The index at which to begin the search
|
* @param {Number} [from] The index at which to begin the search
|
||||||
*/
|
*/
|
||||||
qq.indexOf = function(arr, elt, from){
|
qq.indexOf = function(arr, elt, from){
|
||||||
if (arr.indexOf) return arr.indexOf(elt, from);
|
if (arr.indexOf) { return arr.indexOf(elt, from); }
|
||||||
|
|
||||||
from = from || 0;
|
from = from || 0;
|
||||||
var len = arr.length;
|
var len = arr.length;
|
||||||
|
|
||||||
if (from < 0) from += len;
|
if (from < 0) { from += len; }
|
||||||
|
|
||||||
for (; from < len; from++){
|
for (; from < len; from++){
|
||||||
if (from in arr && arr[from] === elt){
|
if (from in arr && arr[from] === elt){
|
||||||
|
|
@ -89,7 +89,7 @@ qq.remove = function(element){
|
||||||
|
|
||||||
qq.contains = function(parent, descendant){
|
qq.contains = function(parent, descendant){
|
||||||
// compareposition returns false in this case
|
// compareposition returns false in this case
|
||||||
if (parent == descendant) return true;
|
if (parent == descendant) { return true; }
|
||||||
|
|
||||||
if (parent.contains){
|
if (parent.contains){
|
||||||
return parent.contains(descendant);
|
return parent.contains(descendant);
|
||||||
|
|
@ -120,7 +120,7 @@ qq.toElement = (function(){
|
||||||
* Fixes opacity in IE6-8.
|
* Fixes opacity in IE6-8.
|
||||||
*/
|
*/
|
||||||
qq.css = function(element, styles){
|
qq.css = function(element, styles){
|
||||||
if (styles.opacity != null){
|
if (styles.opacity !== null){
|
||||||
if (typeof element.style.opacity != 'string' && typeof(element.filters) != 'undefined'){
|
if (typeof element.style.opacity != 'string' && typeof(element.filters) != 'undefined'){
|
||||||
styles.filter = 'alpha(opacity=' + Math.round(100 * styles.opacity) + ')';
|
styles.filter = 'alpha(opacity=' + Math.round(100 * styles.opacity) + ')';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ $(document).ready(function(){
|
||||||
if(conv.hasClass('unread') ){
|
if(conv.hasClass('unread') ){
|
||||||
conv.removeClass('unread');
|
conv.removeClass('unread');
|
||||||
}
|
}
|
||||||
if(cBadge.html() != null) {
|
if(cBadge.html() !== null) {
|
||||||
cBadge.html().replace(/\d+/, function(num){
|
cBadge.html().replace(/\d+/, function(num){
|
||||||
num = parseInt(num);
|
num = parseInt(num);
|
||||||
cBadge.html(parseInt(num)-1);
|
cBadge.html(parseInt(num)-1);
|
||||||
|
|
@ -30,7 +30,7 @@ $(document).ready(function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).bind("popstate", function(){
|
$(window).bind("popstate", function(){
|
||||||
if (location.href.match(/conversations\/\d+/) != null) {
|
if (location.href.match(/conversations\/\d+/) !== null) {
|
||||||
$.getScript(location.href, function() {
|
$.getScript(location.href, function() {
|
||||||
Diaspora.widgets.directionDetector.updateBinds();
|
Diaspora.widgets.directionDetector.updateBinds();
|
||||||
});
|
});
|
||||||
|
|
@ -72,7 +72,7 @@ $(document).ready(function(){
|
||||||
|
|
||||||
// remove the paginator when we're done.
|
// remove the paginator when we're done.
|
||||||
$(document).ajaxError(function(e,xhr,opt){
|
$(document).ajaxError(function(e,xhr,opt){
|
||||||
if (xhr.status == 404) $('a.next_page').remove();
|
if (xhr.status == 404) { $('a.next_page').remove(); }
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#reply_to_conversation').live('click', function(evt) {
|
$('#reply_to_conversation').live('click', function(evt) {
|
||||||
|
|
@ -84,7 +84,7 @@ $(document).ready(function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
var resize = function(){
|
var resize = function(){
|
||||||
var inboxSidebar = $('#conversation_inbox');
|
var inboxSidebar = $('#conversation_inbox'),
|
||||||
inboxSidebarOffset = inboxSidebar.offset().top,
|
inboxSidebarOffset = inboxSidebar.offset().top,
|
||||||
windowHeight = $(window).height();
|
windowHeight = $(window).height();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,5 +112,5 @@ isInsertion : function(keyCode){
|
||||||
}else {
|
}else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
$('.stream_element').live('mousedown', function(evt){
|
$('.stream_element').live('mousedown', function(evt){
|
||||||
var note = $(this).closest('.stream_element'),
|
var note = $(this).closest('.stream_element'),
|
||||||
note_id = note.attr('data-guid'),
|
note_id = note.attr('data-guid'),
|
||||||
nBadge = $("#notification_badge .badge_count")
|
nBadge = $("#notification_badge .badge_count");
|
||||||
|
|
||||||
if(note.hasClass('unread') ){
|
if(note.hasClass('unread') ){
|
||||||
note.removeClass('unread');
|
note.removeClass('unread');
|
||||||
|
|
@ -10,7 +10,7 @@ $('.stream_element').live('mousedown', function(evt){
|
||||||
type: 'PUT'
|
type: 'PUT'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(nBadge.html() != null) {
|
if(nBadge.html() !== null) {
|
||||||
nBadge.html().replace(/\d+/, function(num){
|
nBadge.html().replace(/\d+/, function(num){
|
||||||
num = parseInt(num);
|
num = parseInt(num);
|
||||||
nBadge.html(parseInt(num)-1);
|
nBadge.html(parseInt(num)-1);
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,6 @@ var Publisher = {
|
||||||
}
|
}
|
||||||
return Publisher.cachedInput;
|
return Publisher.cachedInput;
|
||||||
},
|
},
|
||||||
cachedSubmit : false,
|
|
||||||
submit: function(){
|
|
||||||
if(!Publisher.cachedSubmit){
|
|
||||||
Publisher.cachedSubmit = Publisher.form().find('#status_message_submit');
|
|
||||||
}
|
|
||||||
return Publisher.cachedSubmit;
|
|
||||||
},
|
|
||||||
|
|
||||||
cachedHiddenInput : false,
|
cachedHiddenInput : false,
|
||||||
hiddenInput: function(){
|
hiddenInput: function(){
|
||||||
|
|
@ -107,7 +100,7 @@ var Publisher = {
|
||||||
},
|
},
|
||||||
generateHiddenInput : function(visibleString){
|
generateHiddenInput : function(visibleString){
|
||||||
var resultString = visibleString;
|
var resultString = visibleString;
|
||||||
for(i in this.sortedMentions()){
|
for(var i in this.sortedMentions()){
|
||||||
var mention = this.mentions[i];
|
var mention = this.mentions[i];
|
||||||
var start = resultString.slice(0, mention.visibleStart);
|
var start = resultString.slice(0, mention.visibleStart);
|
||||||
var insertion = mention.mentionString;
|
var insertion = mention.mentionString;
|
||||||
|
|
@ -165,14 +158,14 @@ var Publisher = {
|
||||||
},
|
},
|
||||||
updateMentionLocations : function(effectiveCursorIndex, offset){
|
updateMentionLocations : function(effectiveCursorIndex, offset){
|
||||||
var changedMentions = this.mentionsAfter(effectiveCursorIndex);
|
var changedMentions = this.mentionsAfter(effectiveCursorIndex);
|
||||||
for(i in changedMentions){
|
for(var i in changedMentions){
|
||||||
var mention = changedMentions[i];
|
var mention = changedMentions[i];
|
||||||
mention.visibleStart += offset;
|
mention.visibleStart += offset;
|
||||||
mention.visibleEnd += offset;
|
mention.visibleEnd += offset;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mentionAt : function(visibleCursorIndex){
|
mentionAt : function(visibleCursorIndex){
|
||||||
for(i in this.mentions){
|
for(var i in this.mentions){
|
||||||
var mention = this.mentions[i];
|
var mention = this.mentions[i];
|
||||||
if(visibleCursorIndex > mention.visibleStart && visibleCursorIndex < mention.visibleEnd){
|
if(visibleCursorIndex > mention.visibleStart && visibleCursorIndex < mention.visibleEnd){
|
||||||
return i;
|
return i;
|
||||||
|
|
@ -182,14 +175,14 @@ var Publisher = {
|
||||||
},
|
},
|
||||||
mentionsAfter : function(visibleCursorIndex){
|
mentionsAfter : function(visibleCursorIndex){
|
||||||
var resultMentions = [];
|
var resultMentions = [];
|
||||||
for(i in this.mentions){
|
for(var i in this.mentions){
|
||||||
var mention = this.mentions[i];
|
var mention = this.mentions[i];
|
||||||
if(visibleCursorIndex <= mention.visibleStart){
|
if(visibleCursorIndex <= mention.visibleStart){
|
||||||
resultMentions.push(mention);
|
resultMentions.push(mention);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resultMentions;
|
return resultMentions;
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
repopulateHiddenInput: function(){
|
repopulateHiddenInput: function(){
|
||||||
var newHiddenVal = Publisher.autocompletion.mentionList.generateHiddenInput(Publisher.input().val());
|
var newHiddenVal = Publisher.autocompletion.mentionList.generateHiddenInput(Publisher.input().val());
|
||||||
|
|
@ -207,8 +200,8 @@ var Publisher = {
|
||||||
var input = Publisher.input();
|
var input = Publisher.input();
|
||||||
var selectionStart = input[0].selectionStart;
|
var selectionStart = input[0].selectionStart;
|
||||||
var selectionEnd = input[0].selectionEnd;
|
var selectionEnd = input[0].selectionEnd;
|
||||||
var isDeletion = (event.keyCode == KEYCODES.DEL && selectionStart < input.val().length) || (event.keyCode == KEYCODES.BACKSPACE && (selectionStart > 0 || selectionStart != selectionEnd))
|
var isDeletion = (event.keyCode == KEYCODES.DEL && selectionStart < input.val().length) || (event.keyCode == KEYCODES.BACKSPACE && (selectionStart > 0 || selectionStart != selectionEnd));
|
||||||
var isInsertion = (KEYCODES.isInsertion(event.keyCode) && event.keyCode != KEYCODES.RETURN )
|
var isInsertion = (KEYCODES.isInsertion(event.keyCode) && event.keyCode != KEYCODES.RETURN );
|
||||||
|
|
||||||
if(isDeletion){
|
if(isDeletion){
|
||||||
Publisher.autocompletion.mentionList.deletionAt(selectionStart, selectionEnd, event.keyCode);
|
Publisher.autocompletion.mentionList.deletionAt(selectionStart, selectionEnd, event.keyCode);
|
||||||
|
|
@ -226,15 +219,15 @@ var Publisher = {
|
||||||
var stringEnd = inputContent.slice(stringLoc[1]);
|
var stringEnd = inputContent.slice(stringLoc[1]);
|
||||||
|
|
||||||
input.val(stringStart + formatted + stringEnd);
|
input.val(stringStart + formatted + stringEnd);
|
||||||
var offset = formatted.length - (stringLoc[1] - stringLoc[0])
|
var offset = formatted.length - (stringLoc[1] - stringLoc[0]);
|
||||||
Publisher.autocompletion.mentionList.updateMentionLocations(stringStart.length, offset);
|
Publisher.autocompletion.mentionList.updateMentionLocations(stringStart.length, offset);
|
||||||
return [stringStart.length, stringStart.length + formatted.length]
|
return [stringStart.length, stringStart.length + formatted.length];
|
||||||
},
|
},
|
||||||
|
|
||||||
findStringToReplace: function(value, cursorIndex){
|
findStringToReplace: function(value, cursorIndex){
|
||||||
var atLocation = value.lastIndexOf('@', cursorIndex);
|
var atLocation = value.lastIndexOf('@', cursorIndex);
|
||||||
if(atLocation == -1){return [0,0];}
|
if(atLocation == -1){return [0,0];}
|
||||||
var nextAt = cursorIndex
|
var nextAt = cursorIndex;
|
||||||
|
|
||||||
if(nextAt == -1){nextAt = value.length;}
|
if(nextAt == -1){nextAt = value.length;}
|
||||||
return [atLocation, nextAt];
|
return [atLocation, nextAt];
|
||||||
|
|
@ -247,7 +240,7 @@ var Publisher = {
|
||||||
if(stringLoc[0] <= 2){
|
if(stringLoc[0] <= 2){
|
||||||
stringLoc[0] = 0;
|
stringLoc[0] = 0;
|
||||||
}else{
|
}else{
|
||||||
stringLoc[0] -= 2
|
stringLoc[0] -= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
var relevantString = value.slice(stringLoc[0], stringLoc[1]).replace(/\s+$/,"");
|
var relevantString = value.slice(stringLoc[0], stringLoc[1]).replace(/\s+$/,"");
|
||||||
|
|
@ -270,9 +263,9 @@ var Publisher = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
determineSubmitAvailability: function(){
|
determineSubmitAvailability: function(){
|
||||||
var onlyWhitespaces = (Publisher.input().val().trim() == '');
|
var onlyWhitespaces = (Publisher.input().val().trim() === '');
|
||||||
var isSubmitDisabled = Publisher.submit().attr('disabled');
|
var isSubmitDisabled = Publisher.submit().attr('disabled');
|
||||||
var isPhotoAttached = ($("#photodropzone").children().length > 0)
|
var isPhotoAttached = ($("#photodropzone").children().length > 0);
|
||||||
if ((onlyWhitespaces && !isPhotoAttached) && !isSubmitDisabled) {
|
if ((onlyWhitespaces && !isPhotoAttached) && !isSubmitDisabled) {
|
||||||
Publisher.submit().attr('disabled', true);
|
Publisher.submit().attr('disabled', true);
|
||||||
} else if ((!onlyWhitespaces || isPhotoAttached) && isSubmitDisabled) {
|
} else if ((!onlyWhitespaces || isPhotoAttached) && isSubmitDisabled) {
|
||||||
|
|
@ -295,29 +288,29 @@ var Publisher = {
|
||||||
$(this).toggleClass("dim");
|
$(this).toggleClass("dim");
|
||||||
var public_field= $("#publisher #status_message_public");
|
var public_field= $("#publisher #status_message_public");
|
||||||
|
|
||||||
(public_field.val() == 'false')?(public_field.val('true')):(public_field.val('false'));
|
(public_field.val() == 'false') ? (public_field.val('true')) : (public_field.val('false'));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
toggleServiceField: function(service){
|
toggleServiceField: function(service){
|
||||||
Publisher.createCounter(service);
|
Publisher.createCounter(service);
|
||||||
|
|
||||||
var provider = service.attr('id');
|
var provider = service.attr('id');
|
||||||
var hidden_field = $('#publisher [name="services[]"][value="'+provider+'"]')
|
var hidden_field = $('#publisher [name="services[]"][value="'+provider+'"]');
|
||||||
if(hidden_field.length > 0){
|
if(hidden_field.length > 0){
|
||||||
hidden_field.remove();
|
hidden_field.remove();
|
||||||
} else {
|
} else {
|
||||||
$("#publisher .content_creation form").append(
|
$("#publisher .content_creation form").append(
|
||||||
'<input id="services_" name="services[]" type="hidden" value="'+provider+'">');
|
'<input id="services_" name="services[]" type="hidden" value="'+provider+'">');
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
toggleAspectIds: function(aspectId) {
|
toggleAspectIds: function(aspectId) {
|
||||||
var hidden_field = $('#publisher [name="aspect_ids[]"][value="'+aspectId+'"]')
|
var hidden_field = $('#publisher [name="aspect_ids[]"][value="'+aspectId+'"]');
|
||||||
if(hidden_field.length > 0){
|
if(hidden_field.length > 0){
|
||||||
hidden_field.remove();
|
hidden_field.remove();
|
||||||
} else {
|
} else {
|
||||||
$("#publisher .content_creation form").append(
|
$("#publisher .content_creation form").append(
|
||||||
'<input id="aspect_ids_" name="aspect_ids[]" type="hidden" value="'+aspectId+'">');
|
'<input id="aspect_ids_" name="aspect_ids[]" type="hidden" value="'+aspectId+'">');
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
createCounter: function(service){
|
createCounter: function(service){
|
||||||
var counter = $("#publisher .counter");
|
var counter = $("#publisher .counter");
|
||||||
|
|
@ -328,7 +321,7 @@ var Publisher = {
|
||||||
if(a.length > 0){
|
if(a.length > 0){
|
||||||
$.each(a, function(index, value){
|
$.each(a, function(index, value){
|
||||||
var num = parseInt($(value).attr('maxchar'));
|
var num = parseInt($(value).attr('maxchar'));
|
||||||
if (min > num) { min = num}
|
if (min > num) { min = num; }
|
||||||
});
|
});
|
||||||
$('#status_message_fake_text').charCount({allowed: min, warning: min/10 });
|
$('#status_message_fake_text').charCount({allowed: min, warning: min/10 });
|
||||||
}
|
}
|
||||||
|
|
@ -338,11 +331,11 @@ var Publisher = {
|
||||||
$('#publisher .aspect_badge').bind("click", function(){
|
$('#publisher .aspect_badge').bind("click", function(){
|
||||||
var unremovedAspects = $(this).parent().children('.aspect_badge').length - $(this).parent().children(".aspect_badge.removed").length;
|
var unremovedAspects = $(this).parent().children('.aspect_badge').length - $(this).parent().children(".aspect_badge.removed").length;
|
||||||
if(!$(this).hasClass('removed') && ( unremovedAspects == 1 )){
|
if(!$(this).hasClass('removed') && ( unremovedAspects == 1 )){
|
||||||
alert(Diaspora.widgets.i18n.t('publisher.at_least_one_aspect'))
|
alert(Diaspora.widgets.i18n.t('publisher.at_least_one_aspect'));
|
||||||
}else{
|
}else{
|
||||||
Publisher.toggleAspectIds($(this).children('a').attr('data-guid'));
|
Publisher.toggleAspectIds($(this).children('a').attr('data-guid'));
|
||||||
$(this).toggleClass("removed");
|
$(this).toggleClass("removed");
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
|
|
@ -353,7 +346,7 @@ var Publisher = {
|
||||||
Publisher.bindPublicIcon();
|
Publisher.bindPublicIcon();
|
||||||
Publisher.bindAspectToggles();
|
Publisher.bindAspectToggles();
|
||||||
|
|
||||||
if ($("#status_message_fake_text").val() == "") {
|
if ($("#status_message_fake_text").val() === "") {
|
||||||
Publisher.close();
|
Publisher.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue