diff --git a/src/public/javascripts/content.js b/src/public/javascripts/content.js index 3a40f47af3a..83e77da428a 100644 --- a/src/public/javascripts/content.js +++ b/src/public/javascripts/content.js @@ -103,7 +103,7 @@ var content = (function(){ return { statusChecker : function(repo, sync, product_id){ fadeUpdate("#prod_sync_start_" + product_id, ' '); - var updateField = $('#' + common.escapeId("repo_bar_" + repo)); + var updateField = $('#' + KT.common.escapeId("repo_bar_" + repo)); updateField.fadeOut('fast'); updateField.html(''); cancelButton = $('') @@ -177,7 +177,7 @@ var content = (function(){ }); }, cancelSync : function(repoid, syncid, updateField, pu){ - var btn = $('#' + common.escapeId("cancel_" + repoid)); + var btn = $('#' + KT.common.escapeId("cancel_" + repoid)); var prod_id = getProductId(updateField); btn.addClass("disabled"); pu.stop(); diff --git a/src/public/javascripts/katello.js b/src/public/javascripts/katello.js index b3fbf0b44bc..1b3255c2594 100644 --- a/src/public/javascripts/katello.js +++ b/src/public/javascripts/katello.js @@ -18,6 +18,9 @@ * Date: 09/01/2010 */ +//Katello global object namespace that all others should be attached to +var KT = {}; + //i18n global variable var i18n = {}; @@ -54,21 +57,8 @@ function log(msg) { }, 0); } -var helptip = (function() { - return { - handle_close: function(){ - var key = this.id.split("helptip-opened_")[1]; - $("#helptip-opened_" + key).hide(); - $("#helptip-closed_" + key).show(); - helptip.disable(key); - }, - handle_open: function(){ - var key = this.id.split("helptip-closed_")[1]; - $("#helptip-opened_" + key).show(); - $("#helptip-closed_" + key).hide(); - helptip.enable(key); - }, - enable: function(key) { +KT.helptip = (function($) { + var enable = function(key) { $.ajax({ type: "POST", url: "/users/enable_helptip", @@ -76,16 +66,32 @@ var helptip = (function() { cache: false }); }, - disable: function(key) { + disable = function(key) { $.ajax({ type: "POST", url: "/users/disable_helptip", data: { "key":key}, cache: false }); - } + }, + handle_close = function(){ + var key = this.id.split("helptip-opened_")[1]; + $("#helptip-opened_" + key).hide(); + $("#helptip-closed_" + key).show(); + disable(key); + }, + handle_open = function(){ + var key = this.id.split("helptip-closed_")[1]; + $("#helptip-opened_" + key).show(); + $("#helptip-closed_" + key).hide(); + enable(key); + }; + + return { + handle_close : handle_close, + handle_open : handle_open }; -})(); +})(jQuery); //override the jQuery UJS $.rails.allowAction $.rails.allowAction = function(element) { @@ -94,7 +100,7 @@ $.rails.allowAction = function(element) { if (!message) { return true; } if ($.rails.fire(element, 'confirm')) { - common.customConfirm(message, function() { + KT.common.customConfirm(message, function() { callback = $.rails.fire(element, 'confirm:complete', [answer]); if(callback) { @@ -119,7 +125,7 @@ $.expr[':'].contains = function(a, i, m) { }; //requires jQuery -var common = (function() { +KT.common = (function() { return { height: function() { return $(window).height(); @@ -144,6 +150,7 @@ var common = (function() { var html = "
" + message + "
"; var confirmTrue = new Boolean(true); var confirmFalse = new Boolean(false); + $(html).dialog({ closeOnEscape: false, open: function (event, ui) { @@ -297,12 +304,12 @@ $(document).ready(function (){ }); //Add a handler for helptips - $(".helptip-open").live('click', helptip.handle_close); - $(".helptip-close").live('click', helptip.handle_open); + $(".helptip-open").live('click', KT.helptip.handle_close); + $(".helptip-close").live('click', KT.helptip.handle_open); - common.orgSwitcherSetup(); - common.orgFilterSetup(); - common.thirdLevelNavSetup(); + KT.common.orgSwitcherSetup(); + KT.common.orgFilterSetup(); + KT.common.thirdLevelNavSetup(); }); /** @@ -328,6 +335,6 @@ $(window).ready(function(){ } }); - window.alert = function(message){common.customAlert(message);return false;}; - $.rails.confirm = function(message) { common.customConfirm(message); return false;}; + window.alert = function(message){KT.common.customAlert(message);return false;}; + $.rails.confirm = function(message) { KT.common.customConfirm(message); return false;}; }); \ No newline at end of file diff --git a/src/public/javascripts/notices.js b/src/public/javascripts/notices.js index 5948a11c83e..5eba9363164 100644 --- a/src/public/javascripts/notices.js +++ b/src/public/javascripts/notices.js @@ -93,7 +93,7 @@ var notices = (function() { }, checkNoticesInResponse : function(xhr) { if (xhr !== undefined) { - var message = common.decode(xhr.getResponseHeader('X-Message')); + var message = KT.common.decode(xhr.getResponseHeader('X-Message')); if (message === "null") {message = null;} var messageType = xhr.getResponseHeader('X-Message-Type'); if (message) { diff --git a/src/public/javascripts/panel.js b/src/public/javascripts/panel.js index 1e7eb3db99e..807899f498f 100644 --- a/src/public/javascripts/panel.js +++ b/src/public/javascripts/panel.js @@ -272,7 +272,7 @@ var panel = (function(){ //if there is a lot in the list, make the panel a bit larger if ($('#content').height() > 642){ - var extraHeight = common.height() - 192; + var extraHeight = KT.common.height() - 192; if (isSubpanel) { extraHeight -= subpanelSpacing; } @@ -381,8 +381,8 @@ var panel = (function(){ } }, handleScroll : function(jQPanel, container, top, bodyY, spacing, offset) { - var scrollY = common.scrollTop(), - scrollX = common.scrollLeft(), + var scrollY = KT.common.scrollTop(), + scrollX = KT.common.scrollLeft(), isfixed = jQPanel.css('position') === 'fixed'; offset = offset ? offset : 10; diff --git a/src/public/javascripts/promotion.js b/src/public/javascripts/promotion.js index c10dba7b13f..fb243c896f8 100644 --- a/src/public/javascripts/promotion.js +++ b/src/public/javascripts/promotion.js @@ -46,7 +46,7 @@ var promotion_page = (function($){ }, //Finds the add/remove buttons in the left pane find_button = function(id, type) { - return $("a[class~=content_add_remove][data-id=" + common.escapeId(id) + "][data-type=" + type + "]"); + return $("a[class~=content_add_remove][data-id=" + KT.common.escapeId(id) + "][data-type=" + type + "]"); }, conflict = function(){ //conflict object that stores conflict information @@ -791,7 +791,7 @@ var registerEvents = function(){ return false; } var id = promotion_page.get_changeset().id; - common.customConfirm(button.attr('data-confirm-text'), function(){ + KT.common.customConfirm(button.attr('data-confirm-text'), function(){ button.addClass('disabled'); $.ajax({ type: "DELETE", diff --git a/src/public/javascripts/role_sliding_tree.js b/src/public/javascripts/role_sliding_tree.js index 73d227a725b..a2aa58d094c 100644 --- a/src/public/javascripts/role_sliding_tree.js +++ b/src/public/javascripts/role_sliding_tree.js @@ -900,7 +900,7 @@ var pageActions = (function($){ $('#remove_role').live('click', function(){ var button = $(this); - common.customConfirm(button.attr('data-confirm-text'), function(){ + KT.common.customConfirm(button.attr('data-confirm-text'), function(){ roleActions.removeRole(button); }); }); diff --git a/src/public/javascripts/test/js/katelloTests.js b/src/public/javascripts/test/js/katelloTests.js index c8e7d687d4c..1910778a4f4 100644 --- a/src/public/javascripts/test/js/katelloTests.js +++ b/src/public/javascripts/test/js/katelloTests.js @@ -12,6 +12,6 @@ test('localize_i18n', function() { }) test('escapeSelector', function() { - var val = common.escapeId("#my.val"); + var val = KT.common.escapeId("#my.val"); ok(val.indexOf("\\") != -1, "properly escape Jquery selectors"); })