From 745caf3829ba3375e93e1948198b043c766a3116 Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Mon, 17 May 2010 14:17:28 -0700 Subject: [PATCH] And changing that previous $ -> jQuery move to stick with a force-fed $ a la (function($){/*...*/})(jQuery); * * thanks bleroy for the gentle reminder ;) --HG-- branch : dev --- .../Modules/Orchard.Themes/Scripts/base.js | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Themes/Scripts/base.js b/src/Orchard.Web/Modules/Orchard.Themes/Scripts/base.js index cf3c647d0..a5f3d1ec7 100644 --- a/src/Orchard.Web/Modules/Orchard.Themes/Scripts/base.js +++ b/src/Orchard.Web/Modules/Orchard.Themes/Scripts/base.js @@ -1,7 +1,8 @@ -//todo: (heskew) make use of the autofocus attribute instead -jQuery.fn.extend({ +(function($){ +//todo: (heskew) make use of the autofocus attribute instead +$.fn.extend({ helpfullyFocus: function() { - var _this = jQuery(this); + var _this = $(this); var firstError = _this.find(".input-validation-error").first(); // try to focus the first error on the page if (firstError.size() === 1) { @@ -16,12 +17,12 @@ jQuery.fn.extend({ return autofocus.focus(); }, toggleWhatYouControl: function() { - var _this = jQuery(this); - var _controllees = jQuery("[data-controllerid=" + _this.attr("id") + "]"); + var _this = $(this); + var _controllees = $("[data-controllerid=" + _this.attr("id") + "]"); var _controlleesAreHidden = _controllees.is(":hidden"); if (_this.is(":checked") && _controlleesAreHidden) { _controllees.hide(); // <- unhook this when the following comment applies - jQuery(_controllees.show()[0]).find("input").focus(); // <- aaaand a slideDown there...eventually + $(_controllees.show()[0]).find("input").focus(); // <- aaaand a slideDown there...eventually } else if (!(_this.is(":checked") && _controlleesAreHidden)) { //_controllees.slideUp(200); <- hook this back up when chrome behaves, or when I care less _controllees.hide() @@ -30,27 +31,27 @@ jQuery.fn.extend({ }); // collapsable areas - anything with a data-controllerid attribute has its visibility controlled by the id-ed radio/checkbox (function() { - jQuery("[data-controllerid]").each(function() { - var controller = jQuery("#" + jQuery(this).attr("data-controllerid")); + $("[data-controllerid]").each(function() { + var controller = $("#" + $(this).attr("data-controllerid")); if (controller.data("isControlling")) { return; } controller.data("isControlling", 1); if (!controller.is(":checked")) { - jQuery("[data-controllerid=" + controller.attr("id") + "]").hide(); + $("[data-controllerid=" + controller.attr("id") + "]").hide(); } if (controller.is(":checkbox")) { - controller.click(jQuery(this).toggleWhatYouControl); + controller.click($(this).toggleWhatYouControl); } else if (controller.is(":radio")) { - jQuery("[name=" + controller.attr("name") + "]").click(function() { jQuery("[name=" + jQuery(this).attr("name") + "]").each(jQuery(this).toggleWhatYouControl); }); + $("[name=" + controller.attr("name") + "]").click(function() { $("[name=" + $(this).attr("name") + "]").each($(this).toggleWhatYouControl); }); } }); })(); // inline form link buttons (form.inline.link button) swapped out for a link that submits said form (function() { - jQuery("form.inline.link").each(function() { - var _this = jQuery(this); - var link = jQuery(""); + $("form.inline.link").each(function() { + var _this = $(this); + var link = $(""); var button = _this.children("button").first(); link.text(button.text()) .addClass(button.attr("class")) @@ -58,10 +59,11 @@ jQuery.fn.extend({ .unload(function() { _this = 0; }); _this.replaceWith(link); _this.css({ "position": "absolute", "left": "-9999em" }); - jQuery("body").append(_this); + $("body").append(_this); }); })(); // a little better autofocus -jQuery(function() { - jQuery("body").helpfullyFocus(); -}); \ No newline at end of file +$(function() { + $("body").helpfullyFocus(); +}); +})(jQuery); \ No newline at end of file