// XXX: Should I do crazy SN.X.Y.Z.A namespace instead?
var SN_WHITELIST = SN_WHITELIST || {};
-SN_WHITELIST.updateButtons = function() {
+SN_WHITELIST.updateButtons = function () {
$("ul > li > a.remove_row").show();
$("ul > li > a.add_row").hide();
$("ul > li > a.add_row:last").show();
};
-SN_WHITELIST.resetRow = function(row) {
+SN_WHITELIST.resetRow = function (row) {
$("input", row).val('');
// Make sure the default domain is the first selection
$("select option:first", row).val();
$("a.remove_row", row).show();
};
-SN_WHITELIST.addRow = function() {
+SN_WHITELIST.addRow = function () {
var row = $(this).closest("li");
var newRow = row.clone();
$(row).find('a.add_row').hide();
SN_WHITELIST.resetRow(newRow);
- $(newRow).insertAfter(row).show("blind", "fast", function() {
+ $(newRow).insertAfter(row).show("blind", "fast", function () {
SN_WHITELIST.updateButtons();
});
};
-SN_WHITELIST.removeRow = function() {
+SN_WHITELIST.removeRow = function () {
var that = this;
$("#confirm-dialog").dialog({
buttons : {
- "Confirm" : function() {
+ "Confirm" : function () {
$(this).dialog("close");
- $(that).closest("li").hide("blind", "fast", function() {
+ $(that).closest("li").hide("blind", "fast", function () {
$(this).remove();
SN_WHITELIST.updateButtons();
});
},
- "Cancel" : function() {
+ "Cancel" : function () {
$(this).dialog("close");
}
}
if ($(this).closest('li').find(':input[name^=username]').val()) {
$("#confirm-dialog").dialog("open");
} else {
- $(that).closest("li").hide("blind", "fast", function() {
+ $(that).closest("li").hide("blind", "fast", function () {
$(this).remove();
SN_WHITELIST.updateButtons();
});
}
};
-$(document).ready(function() {
+$(document).ready(function () {
$("#confirm-dialog").dialog({
autoOpen: false,
modal: true
});
- $('.add_row').live('click', SN_WHITELIST.addRow);
- $('.remove_row').live('click', SN_WHITELIST.removeRow);
+ $(document).on('click', '.add_row', SN_WHITELIST.addRow);
+ $(document).on('click', '.remove_row', SN_WHITELIST.removeRow);
SN_WHITELIST.updateButtons();
});
var SN_EXTENDED = SN_EXTENDED || {};
-SN_EXTENDED.reorder = function(cls) {
+SN_EXTENDED.reorder = function (cls) {
var divs = $('div[class=' + cls + ']');
- $(divs).each(function(i, div) {
+ $(divs).each(function (i, div) {
$(div).find('a.add_row').hide();
$(div).find('a.remove_row').show();
SN_EXTENDED.replaceIndex(SN_EXTENDED.rowIndex(div), i);
}
};
-SN_EXTENDED.rowIndex = function(div) {
+SN_EXTENDED.rowIndex = function (div) {
var idstr = $(div).attr('id');
var id = idstr.match(/\d+/);
return id;
};
-SN_EXTENDED.rowCount = function(cls) {
+SN_EXTENDED.rowCount = function (cls) {
var divs = $.find('div[class=' + cls + ']');
return divs.length;
};
-SN_EXTENDED.replaceIndex = function(elem, oldIndex, newIndex) {
- $(elem).find('*').each(function() {
- $.each(this.attributes, function(i, attrib) {
+SN_EXTENDED.replaceIndex = function (elem, oldIndex, newIndex) {
+ $(elem).find('*').each(function () {
+ $.each(this.attributes, function (i, attrib) {
var regexp = /extprofile-.*-\d.*/;
var value = attrib.value;
var match = value.match(regexp);
});
}
-SN_EXTENDED.resetRow = function(elem) {
+SN_EXTENDED.resetRow = function (elem) {
$(elem).find('input, textarea').attr('value', '');
$(elem).find('input').removeAttr('disabled');
$(elem).find("select option[value='office']").attr("selected", true);
$(elem).find("input:checkbox").attr('checked', false);
- $(elem).find("input[name$=-start], input[name$=-end]").each(function() {
+ $(elem).find("input[name$=-start], input[name$=-end]").each(function () {
$(this).removeClass('hasDatepicker');
$(this).datepicker({ dateFormat: 'd M yy' });
});
};
-SN_EXTENDED.addRow = function() {
+SN_EXTENDED.addRow = function () {
var div = $(this).closest('div');
var id = div.attr('id');
var cls = div.attr('class');
SN_EXTENDED.reorder(cls);
};
-SN_EXTENDED.removeRow = function() {
+SN_EXTENDED.removeRow = function () {
var div = $(this).closest('div');
var id = $(div).attr('id');
$("#confirm-dialog").dialog({
buttons : {
- "Confirm" : function() {
+ "Confirm" : function () {
$(this).dialog("close");
var target = $(that).closest('tr');
- target.fadeOut("slow", function() {
+ target.fadeOut("slow", function () {
$(target).remove();
SN_EXTENDED.reorder(cls);
});
},
- "Cancel" : function() {
+ "Cancel" : function () {
$(this).dialog("close");
}
}
}
};
-$(document).ready(function() {
+$(document).ready(function () {
$("#confirm-dialog").dialog({
autoOpen: false,
source: 'finduser',
minLength: 2 });
- $('.add_row').live('click', SN_EXTENDED.addRow);
- $('.remove_row').live('click', SN_EXTENDED.removeRow);
+ $(document).on('click', '.add_row', SN_EXTENDED.addRow);
+ $(document).on('click', '.remove_row', SN_EXTENDED.removeRow);
- $('input:checkbox[name$=current]').each(function() {
+ $('input:checkbox[name$=current]').each(function () {
var input = $(this).parent().siblings('input[id$=-end]');
if ($(this).is(':checked')) {
$(input).attr('disabled', 'true');
}
});
- $('input:checkbox[name$=current]').live('click', function() {
+ $(document).on('click', 'input:checkbox[name$=current]', function () {
var input = $(this).parent().siblings('input[id$=-end]');
if ($(this).is(':checked')) {
$(input).val('');
$(function() {
// Notice lists...
- $('.notice .author').live('mouseenter', function(e) {
+ $(document).on('mouseenter', '.notice .author', function(e) {
var notice = $(this).closest('.notice');
var popup = notice.find('.remote-profile-options');
if (popup.length) {
popup.fadeIn();
}
});
- $('.notice').live('mouseleave', function(e) {
+ $(document).on('mouseleave', '.notice', function(e) {
var notice = $(this);
var popup = notice.find('.remote-profile-options');
if (popup.length) {
});
// Profile lists...
- $('.profile .avatar').live('mouseenter', function(e) {
+ $(document).on('mouseenter', '.profile .avatar', function(e) {
var profile = $(this).closest('.profile');
var popup = profile.find('.remote-profile-options');
if (popup.length) {
popup.fadeIn();
}
});
- $('.profile').live('mouseleave', function(e) {
+ $(document).on('mouseleave', '.profile', function(e) {
var profile = $(this);
var popup = profile.find('.remote-profile-options');
if (popup.length) {
* @note Everything in here should eventually migrate over to /js/util.js's SN.
*/
-SN.Init.OStatusCookie = function() {
+SN.Init.OStatusCookie = function () {
if (SN.U.StatusNetInstance.Get() === null) {
SN.U.StatusNetInstance.Set({RemoteProfile: null});
}
};
SN.U.DialogBox = {
- Subscribe: function(a) {
+ Subscribe: function (a) {
var f = a.parent().find('.form_settings');
if (f.length > 0) {
f.show();
type: 'GET',
dataType: 'xml',
url: a[0].href + ((a[0].href.match(/[\\?]/) === null)?'?':'&') + 'ajax=1',
- beforeSend: function(formData) {
+ beforeSend: function (formData) {
a.addClass('processing');
},
error: function (xhr, textStatus, errorThrown) {
alert(errorThrown || textStatus);
},
- success: function(data, textStatus, xhr) {
+ success: function (data, textStatus, xhr) {
if (typeof($('form', data)[0]) != 'undefined') {
a.after(document._importNode($('form', data)[0], true));
.find('.submit')
.addClass('submit_dialogbox')
.removeClass('submit')
- .bind('click', function() {
+ .bind('click', function () {
form.addClass('processing');
});
- form.find('button.close').click(function(){
+ form.find('button.close').click(function (){
form.hide();
return false;
SN.Init.OStatusCookie();
form.find('#profile').val(SN.U.StatusNetInstance.Get().RemoteProfile);
- form.find("[type=submit]").bind('click', function() {
+ form.find("[type=submit]").bind('click', function () {
SN.U.StatusNetInstance.Set({RemoteProfile: form.find('#profile').val()});
return true;
});
}
};
-SN.Init.Subscribe = function() {
- $('.entity_subscribe .entity_remote_subscribe, .entity_tag .entity_remote_tag')
- .live('click', function() { SN.U.DialogBox.Subscribe($(this)); return false; });
+SN.Init.Subscribe = function () {
+ $(document).on('click',
+ '.entity_subscribe .entity_remote_subscribe, .entity_tag .entity_remote_tag',
+ function () { SN.U.DialogBox.Subscribe($(this)); return false; });
};
-$(document).ready(function() {
+$(document).ready(function () {
SN.Init.Subscribe();
- $('.form_remote_authorize').bind('submit', function() { $(this).addClass(SN.C.S.Processing); return true; });
+ $('.form_remote_authorize').bind('submit', function () {
+ $(this).addClass(SN.C.S.Processing); return true;
+ });
});
{
function onEndShowScripts($action)
{
- $action->inlineScript('$("a[rel~=external]:not([class~=attachment])").live("click", function(){ window.open(this.href); return false; });');
+ $action->inlineScript('$(document).on("click", "a[rel~=external]:not([class~=attachment])", function () { window.open(this.href); return false; });');
return true;
}
var QnA = {
// @fixme: Should use ID
- close: function(form, best) {
+ close: function (form, best) {
var notice = $(form).closest('li.hentry.notice.question');
notice.find('input#qna-best-answer,#qna-question-close').hide();
}
},
- init: function() {
+ init: function () {
QnA.NoticeInlineAnswerSetup();
- $('form.form_question_show').live('submit', function() {
+ $(document).on('submit', 'form.form_question_show', function () {
QnA.close(this);
});
- $('form.form_answer_show').live('submit', function() {
+ $(document).on('submit', 'form.form_answer_show', function () {
QnA.close(this, true);
});
},
*
* @param {jQuery} notice: jQuery object containing one notice
*/
- NoticeInlineAnswerTrigger: function(notice) {
+ NoticeInlineAnswerTrigger: function (notice) {
// Find the notice we're replying to...
var id = $($('.notice_id', notice)[0]).text();
var parentNotice = notice;
// See if the form's already open...
var answerForm = $('.qna_answer_form', list);
- var hideReplyPlaceholders = function(notice) {
+ var hideReplyPlaceholders = function (notice) {
// Do we still have a dummy answer placeholder? If so get rid of
// reply place holders for this question. If the current user hasn't
// answered the question we want to direct her to providing an
}
}
- var nextStep = function() {
+ var nextStep = function () {
var dummyAnswer = $('ul.qna-dummy', notice);
dummyAnswer.hide();
text.focus();
- $('body').click(function(e) {
+ $('body').click(function (e) {
var dummyAnswer = $('ul.qna-dummy', notice);
var style = dummyAnswer.attr('style');
var ans = $(notice).find('li.hentry.notice.anwer', notice)
var openAnswers = $('li.notice-answer');
if (openAnswers.length > 0) {
var target = $(e.target);
- openAnswers.each(function() {
+ openAnswers.each(function () {
// Did we click outside this one?
var answerItem = $(this);
if (answerItem.length == 0) {
answerItem = $('<li class="notice-answer"></li>');
- var intermediateStep = function(formMaster) {
+ var intermediateStep = function (formMaster) {
// @todo cache the form if we can (worth it?)
var formEl = document._importNode(formMaster, true);
$(formEl).data('NoticeFormSetup', true);
// Warning: this can have a delay, which looks bad.
// @fixme this fallback may or may not work
var url = $('#answer-action').attr('value');
- $.get(url, {ajax: 1}, function(data, textStatus, xhr) {
+ $.get(url, {ajax: 1}, function (data, textStatus, xhr) {
intermediateStep($('form', data)[0]);
});
}
* Sets up event handlers for inline reply mini-form placeholders.
* Uses 'live' rather than 'bind', so applies to future as well as present items.
*/
- NoticeInlineAnswerSetup: function() {
+ NoticeInlineAnswerSetup: function () {
- $('li.qna-dummy-placeholder input.placeholder')
- .live('focus', function() {
+ $(document).on('focus',
+ 'li.qna-dummy-placeholder input.placeholder',
+ function () {
var notice = $(this).closest('li.notice');
QnA.NoticeInlineAnswerTrigger(notice);
return false;
},
- AnswerFormSetup: function(form) {
+ AnswerFormSetup: function (form) {
form.find('textarea').focus();
*
* @access public
*/
- FormAnswerXHR: function(form) {
+ FormAnswerXHR: function (form) {
//SN.C.I.NoticeDataGeo = {};
form.append('<input type="hidden" name="ajax" value="1"/>');
* @param {String} text
* @access private
*/
- var showFeedback = function(cls, text) {
+ var showFeedback = function (cls, text) {
form.append(
$('<p class="form_response"></p>')
.addClass(cls)
/**
* Hide the previous response feedback, if any.
*/
- var removeFeedback = function() {
+ var removeFeedback = function () {
form.find('.form_response').remove();
};
dataType: 'xml',
timeout: '60000',
- beforeSend: function(formData) {
+ beforeSend: function (formData) {
if (form.find('.notice_data-text:first').val() == '') {
form.addClass(SN.C.S.Warning);
}
}
},
- success: function(data, textStatus) {
+ success: function (data, textStatus) {
removeFeedback();
var errorResult = $('#'+SN.C.S.Error, data);
}
}
},
- complete: function(xhr, textStatus) {
+ complete: function (xhr, textStatus) {
form
.removeClass(SN.C.S.Processing)
.find('.submit')
}
};
-$(document).ready(function() {
+$(document).ready(function () {
QnA.init();
});