Skip to content

Commit

Permalink
More instances of .live() and .die() replaced with .on() and .off()
Browse files Browse the repository at this point in the history
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
  • Loading branch information
madhuracj committed Dec 2, 2014
1 parent 410d1c3 commit d03c3ad
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 60 deletions.
13 changes: 6 additions & 7 deletions js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2068,13 +2068,12 @@ $(function () {
* The below two functions hide the "Dismiss notification" tooltip when a user
* is hovering a link or button that is inside an ajax message
*/
$('span.ajax_notification a, span.ajax_notification button, span.ajax_notification input')
.live('mouseover', function () {
$(document).on('mouseover', 'span.ajax_notification a, span.ajax_notification button, span.ajax_notification input', function () {
if ($(this).parents('span.ajax_notification').is(':data(tooltip)')) {
$(this).parents('span.ajax_notification').tooltip('disable');
}
})
.live('mouseout', function () {
});
$(document).on('mouseout', 'span.ajax_notification a, span.ajax_notification button, span.ajax_notification input', function () {
if ($(this).parents('span.ajax_notification').is(':data(tooltip)')) {
$(this).parents('span.ajax_notification').tooltip('enable');
}
Expand Down Expand Up @@ -3987,7 +3986,7 @@ function printPage()
AJAX.registerTeardown('functions.js', function () {
$('input#print').unbind('click');
$(document).off('click', 'a.create_view.ajax');
$('#createViewDialog').find('input, select').die('keydown');
$(document).off('keydown', '#createViewDialog input, #createViewDialog select');
});

AJAX.registerOnload('functions.js', function () {
Expand All @@ -4004,7 +4003,7 @@ AJAX.registerOnload('functions.js', function () {
* and used to submit the Ajax request when the ENTER key is pressed.
*/
if ($('#createViewDialog').length !== 0) {
$('#createViewDialog').find('input, select').live('keydown', function (e) {
$(document).on('keydown', '#createViewDialog input, #createViewDialog select', function (e) {
if (e.which === 13) { // 13 is the ENTER key
e.preventDefault();

Expand All @@ -4014,7 +4013,7 @@ AJAX.registerOnload('functions.js', function () {

$(this).closest('.ui-dialog').find('.ui-button:first').click();
}
}); // end $.live()
}); // end $(document).on()
}

var $elm = $('textarea[name="view[as]"]');
Expand Down
4 changes: 2 additions & 2 deletions js/gis_data_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ function insertDataAndClose() {
AJAX.registerTeardown('gis_data_editor.js', function () {
$(document).off('click', "#gis_editor input[name='gis_data[save]']");
$(document).off('submit', '#gis_editor');
$('#gis_editor').find("input[type='text']").die('change');
$(document).off('change', "#gis_editor input[type='text']");
$(document).off('change', "#gis_editor select.gis_type");
$(document).off('click', '#gis_editor a.close_gis_editor, #gis_editor a.cancel_gis_editor');
$(document).off('click', '#gis_editor a.addJs.addPoint');
Expand Down Expand Up @@ -245,7 +245,7 @@ AJAX.registerOnload('gis_data_editor.js', function () {
/**
* Trigger asynchronous calls on data change and update the output.
*/
$('#gis_editor').find("input[type='text']").live('change', function () {
$(document).on('change', "#gis_editor input[type='text']", function () {
var $form = $('form#gis_data_editor_form');
$.post('gis_data_editor.php', $form.serialize() + "&generate=true&ajax_request=true", function (data) {
if (typeof data !== 'undefined' && data.success === true) {
Expand Down
38 changes: 19 additions & 19 deletions js/makegrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -770,27 +770,27 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi

// if the select/editor is changed un-check the 'checkbox_null_<field_name>_<row_index>'.
if ($td.is('.enum, .set')) {
$editArea.find('select').live('change', function (e) {
$editArea.on('change', 'select', function (e) {
$checkbox.prop('checked', false);
});
} else if ($td.is('.relation')) {
$editArea.find('select').live('change', function (e) {
$editArea.on('change', 'select', function (e) {
$checkbox.prop('checked', false);
});
$editArea.find('.browse_foreign').live('click', function (e) {
$editArea.on('click', '.browse_foreign', function (e) {
$checkbox.prop('checked', false);
});
} else {
$(g.cEdit).find('.edit_box').live('keypress change', function (e) {
$(g.cEdit).on('keypress change', '.edit_box', function (e) {
$checkbox.prop('checked', false);
});
// Capture ctrl+v (on IE and Chrome)
$(g.cEdit).find('.edit_box').live('keydown', function (e) {
$(g.cEdit).on('keydown', '.edit_box', function (e) {
if (e.ctrlKey && e.which == 86) {
$checkbox.prop('checked', false);
}
});
$editArea.find('textarea').live('keydown', function (e) {
$editArea.on('keydown', 'textarea', function (e) {
$checkbox.prop('checked', false);
});
}
Expand Down Expand Up @@ -865,7 +865,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
}); // end $.post()

$editArea.show();
$editArea.find('select').live('change', function (e) {
$editArea.on('change', 'select', function (e) {
$(g.cEdit).find('.edit_box').val($(this).val());
});
g.isEditCellTextEditable = true;
Expand Down Expand Up @@ -895,7 +895,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
}); // end $.post()

$editArea.show();
$editArea.find('select').live('change', function (e) {
$editArea.on('change', 'select', function (e) {
$(g.cEdit).find('.edit_box').val($(this).val());
});
}
Expand Down Expand Up @@ -925,7 +925,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
}); // end $.post()

$editArea.show();
$editArea.find('select').live('change', function (e) {
$editArea.on('change', 'select', function (e) {
$(g.cEdit).find('.edit_box').val($(this).val());
});
}
Expand All @@ -934,12 +934,12 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
var value = $td.data('value');
$(g.cEdit).find('.edit_box').val(value);
$editArea.append('<textarea></textarea>');
$editArea.find('textarea')
.val(value)
.live('keyup', function (e) {
$editArea.find('textarea').val(value);
$editArea
.on('keyup', 'textarea', function (e) {
$(g.cEdit).find('.edit_box').val($(this).val());
});
$(g.cEdit).find('.edit_box').live('keyup', function (e) {
$(g.cEdit).on('keyup', '.edit_box', function (e) {
$editArea.find('textarea').val($(this).val());
});
$editArea.append('<div class="cell_edit_hint">' + g.cellEditHint + '</div>');
Expand Down Expand Up @@ -970,12 +970,12 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
$td.data('original_data', data.value);
$(g.cEdit).find('.edit_box').val(data.value);
$editArea.append('<textarea></textarea>');
$editArea.find('textarea')
.val(data.value)
.live('keyup', function (e) {
$editArea.find('textarea').val(data.value);
$editArea
.on('keyup', 'textarea', function (e) {
$(g.cEdit).find('.edit_box').val($(this).val());
});
$(g.cEdit).find('.edit_box').live('keyup', function (e) {
$(g.cEdit).on('keyup', '.edit_box', function (e) {
$editArea.find('textarea').val($(this).val());
});
$editArea.append('<div class="cell_edit_hint">' + g.cellEditHint + '</div>');
Expand Down Expand Up @@ -1760,7 +1760,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
$(g.cEditStd).find('.edit_box').focus(function (e) {
g.showEditArea();
});
$(g.cEditStd).find('.edit_box, select').live('keydown', function (e) {
$(g.cEditStd).on'keydown', '.edit_box, select', function (e) {
if (e.which == 13) {
// post on pressing "Enter"
e.preventDefault();
Expand All @@ -1776,7 +1776,7 @@ function PMA_makegrid(t, enableResize, enableReorder, enableVisib, enableGridEdi
$(g.cEditTextarea).find('.edit_box').focus(function (e) {
g.showEditArea();
});
$(g.cEditTextarea).find('.edit_box, select').live('keydown', function (e) {
$(g.cEditTextarea).on('keydown', '.edit_box, select', function (e) {
if (e.which == 13 && !e.shiftKey) {
// post on pressing "Enter"
e.preventDefault();
Expand Down
29 changes: 13 additions & 16 deletions js/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,10 @@ $(function () {
/**
* Bind all "fast filter" events
*/
$('#pma_navigation_tree li.fast_filter span')
.live('click', PMA_fastFilter.events.clear);
$('#pma_navigation_tree li.fast_filter input.searchClause')
.live('focus', PMA_fastFilter.events.focus)
.live('blur', PMA_fastFilter.events.blur)
.live('keyup', PMA_fastFilter.events.keyup);
$(document).on('click', '#pma_navigation_tree li.fast_filter span', PMA_fastFilter.events.clear);
$(document).on('focus', '#pma_navigation_tree li.fast_filter input.searchClause', PMA_fastFilter.events.focus);
$(document).on('blur', '#pma_navigation_tree li.fast_filter input.searchClause', PMA_fastFilter.events.blur);
$(document).on('keyup', '#pma_navigation_tree li.fast_filter input.searchClause', PMA_fastFilter.events.keyup);

/**
* Ajax handler for pagination
Expand All @@ -152,16 +150,18 @@ $(function () {
/**
* Node highlighting
*/
$('#pma_navigation_tree.highlight li:not(.fast_filter)').live(
$(document).on(
'mouseover',
'#pma_navigation_tree.highlight li:not(.fast_filter)',
function () {
if ($('li:visible', this).length === 0) {
$(this).addClass('activePointer');
}
}
);
$('#pma_navigation_tree.highlight li:not(.fast_filter)').live(
$(document).on(
'mouseout',
'#pma_navigation_tree.highlight li:not(.fast_filter)',
function () {
$(this).removeClass('activePointer');
}
Expand Down Expand Up @@ -210,9 +210,7 @@ $(function () {
dialog.editorDialog(0, $(this).parent());
});
/** Export Triggers and Events */
$('li.trigger div:eq(1) a.ajax img,' +
' li.event div:eq(1) a.ajax img'
).live('click', function (event) {
$(document).on('click', 'li.trigger div:eq(1) a.ajax img, li.event div:eq(1) a.ajax img', function (event) {
event.preventDefault();
var dialog = new RTE.object();
dialog.exportDialog($(this).parent());
Expand Down Expand Up @@ -1045,12 +1043,11 @@ var ResizeHandler = function () {
$('#topmenu').menuResizer('resize');
}
// Register the events for the resizer and the collapser
$('#pma_navigation_resizer')
.live('mousedown', {'resize_handler': this}, this.mousedown);
var $collapser = $('#pma_navigation_collapser');
$collapser.live('click', {'resize_handler': this}, this.collapse);
$(document).on('mousedown', '#pma_navigation_resizer', {'resize_handler': this}, this.mousedown);
$(document).on('click', '#pma_navigation_collapser', {'resize_handler': this}, this.collapse);

// Add the correct arrow symbol to the collapser
$collapser.html(this.getSymbol($('#pma_navigation').width()));
$('#pma_navigation_collapser').html(this.getSymbol($('#pma_navigation').width()));
// Fix navigation tree height
$(window).on('resize', this.treeResize);
// need to call this now and then, browser might decide
Expand Down
18 changes: 9 additions & 9 deletions js/rte.js
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ $(function () {
}
var dialog = new RTE.object(type);
dialog.editorDialog($(this).hasClass('add_anchor'), $(this));
}); // end $.live()
}); // end $(document).on()

/**
* Attach Ajax event handlers for the Execute routine functionality
Expand All @@ -795,7 +795,7 @@ $(function () {
event.preventDefault();
var dialog = new RTE.object('routine');
dialog.executeDialog($(this));
}); // end $.live()
}); // end $(document).on()

/**
* Attach Ajax event handlers for Export of Routines, Triggers and Events
Expand All @@ -804,7 +804,7 @@ $(function () {
event.preventDefault();
var dialog = new RTE.object();
dialog.exportDialog($(this));
}); // end $.live()
}); // end $(document).on()

/**
* Attach Ajax event handlers for Drop functionality
Expand All @@ -814,7 +814,7 @@ $(function () {
event.preventDefault();
var dialog = new RTE.object();
dialog.dropDialog($(this));
}); // end $.live()
}); // end $(document).on()

/**
* Attach Ajax event handlers for the "Change event/routine type"
Expand All @@ -826,7 +826,7 @@ $(function () {
.closest('table')
.find('tr.recurring_event_row, tr.onetime_event_row, tr.routine_return_row, td.routine_direction_cell')
.toggle();
}); // end $.live()
}); // end $(document).on()

/**
* Attach Ajax event handlers for the "Change parameter type"
Expand All @@ -847,7 +847,7 @@ $(function () {
$row.find('select[name^=item_param_opts_text]'),
$row.find('select[name^=item_param_opts_num]')
);
}); // end $.live()
}); // end $(document).on()

/**
* Attach Ajax event handlers for the "Change the type of return
Expand All @@ -863,7 +863,7 @@ $(function () {
$table.find('select[name=item_returnopts_text]'),
$table.find('select[name=item_returnopts_num]')
);
}); // end $.live()
}); // end $(document).on()

/**
* Attach Ajax event handlers for the "Add parameter to routine" functionality
Expand Down Expand Up @@ -900,7 +900,7 @@ $(function () {
$newrow.find('select[name^=item_param_opts_text]'),
$newrow.find('select[name^=item_param_opts_num]')
);
}); // end $.live()
}); // end $(document).on()

/**
* Attach Ajax event handlers for the
Expand Down Expand Up @@ -940,5 +940,5 @@ $(function () {
});
index++;
});
}); // end $.live()
}); // end $(document).on()
}); // end of $()
2 changes: 1 addition & 1 deletion js/server_databases.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,5 @@ AJAX.registerOnload('server_databases.js', function () {
PMA_ajaxShowMessage(data.error, false);
}
}); // end $.post()
}); // end $().live()
}); // end $(document).on()
}); // end $()
4 changes: 2 additions & 2 deletions js/server_privileges.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ AJAX.registerTeardown('server_privileges.js', function () {
$(document).off('click', "a.edit_user_group_anchor.ajax");
$(document).off('click', "button.mult_submit[value=export]");
$(document).off('click', "a.export_user_anchor.ajax");
$("#initials_table").find("a.ajax").die('click');
$(document).off('click', "#initials_table a.ajax");
$('#checkbox_drop_users_db').unbind('click');
$(document).off("click", ".checkall_box");
});
Expand Down Expand Up @@ -338,7 +338,7 @@ AJAX.registerOnload('server_privileges.js', function () {
* @name paginate_users_table_click
* @memberOf jQuery
*/
$("#initials_table").find("a.ajax").live('click', function (event) {
$(document).on('click', "#initials_table a.ajax", function (event) {
event.preventDefault();
var $msgbox = PMA_ajaxShowMessage();
$.get($(this).attr('href'), {'ajax_request' : true}, function (data) {
Expand Down
2 changes: 1 addition & 1 deletion js/server_variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ AJAX.registerOnload('server_variables.js', function () {
);

/* Launches the variable editor */
$editLink.live('click', function (event) {
$(document).on('click', 'a.editLink', function (event) {
event.preventDefault();
editVariable(this);
});
Expand Down
3 changes: 2 additions & 1 deletion js/tbl_structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ AJAX.registerOnload('tbl_structure.js', function () {
/**
*Ajax action for submitting the "Column Change" and "Add Column" form
*/
$(".append_fields_form.ajax").die().live('submit', function (event) {
$(".append_fields_form.ajax").off();
$(document).on('submit', ".append_fields_form.ajax", function (event) {
event.preventDefault();
/**
* @var the_form object referring to the export form
Expand Down
4 changes: 2 additions & 2 deletions js/tbl_zoom_plot_jqplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ AJAX.registerTeardown('tbl_zoom_plot_jqplot.js', function () {
$('#tableid_3').unbind('change');
$('#inputFormSubmitId').unbind('click');
$('#togglesearchformlink').unbind('click');
$("#dataDisplay").find(':input').die('keydown');
$(document).on('keydown', "#dataDisplay :input");
$('button.button-reset').unbind('click');
$('div#resizer').unbind('resizestop');
$('div#querychart').unbind('jqplotDataClick');
Expand Down Expand Up @@ -427,7 +427,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function () {
* in the dialog. Used to submit the Ajax
* request when the ENTER key is pressed.
*/
$("#dataDisplay").find(':input').live('keydown', function (e) {
$(document).on('keydown', "#dataDisplay :input", function (e) {
if (e.which === 13) { // 13 is the ENTER key
e.preventDefault();
if (typeof buttonOptions[PMA_messages.strSave] === 'function') {
Expand Down

0 comments on commit d03c3ad

Please sign in to comment.