From: Coleman Watts <coleman@civicrm.org>
Date: Tue, 25 Mar 2014 19:27:56 +0000 (-0400)
Subject: CRM-14383 - Update closures that use lodash
X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=4b513f23d6f151a4265b1b210baa6d57325b38d0;p=civicrm-core.git

CRM-14383 - Update closures that use lodash
---

diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php
index 39b3161360..799d1ee2ca 100644
--- a/CRM/Core/Resources.php
+++ b/CRM/Core/Resources.php
@@ -546,7 +546,7 @@ class CRM_Core_Resources {
       $.fn.select2.defaults.formatNoMatches = " . json_encode(ts("None found.")) . ";
       $.fn.select2.defaults.formatLoadMore = " . json_encode(ts("Loading...")) . ";
       $.fn.select2.defaults.formatSearching = " . json_encode(ts("Searching...")) . ";
-      $.fn.select2.defaults.formatInputTooShort = function(){return cj(this).data('api-entity') == 'contact' ? $contactSearch : $otherSearch};
+      $.fn.select2.defaults.formatInputTooShort = function(){return CRM.$(this).data('api-entity') == 'contact' ? $contactSearch : $otherSearch};
     ";
 
     // Contact create profiles with localized names
diff --git a/js/Common.js b/js/Common.js
index 3cf1ffb093..8e5d854e3a 100644
--- a/js/Common.js
+++ b/js/Common.js
@@ -1,6 +1,7 @@
 // https://civicrm.org/licensing
 var CRM = CRM || {};
-var cj = jQuery;
+var cj = CRM.$ = jQuery;
+CRM._ = _;
 
 /**
  * Short-named function for string translation, defined in global scope so it's available everywhere.
@@ -199,7 +200,7 @@ CRM.validate = CRM.validate || {
   functions: []
 };
 
-(function ($, undefined) {
+(function ($, _, undefined) {
   "use strict";
 
   // Theme classes for unattached elements
@@ -866,4 +867,4 @@ CRM.validate = CRM.validate || {
     result = sign + (j ? i.substr(0, j) + separator : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + separator) + (2 ? decimal + Math.abs(value - i).toFixed(2).slice(2) : '');
     return format.replace(/1.*234.*56/, result);
   };
-})(jQuery);
+})(jQuery, _);
diff --git a/js/crm.backbone.js b/js/crm.backbone.js
index 46ed699808..eb45249c17 100644
--- a/js/crm.backbone.js
+++ b/js/crm.backbone.js
@@ -1,5 +1,4 @@
-(function($) {
-  var CRM = (window.CRM) ? (window.CRM) : (window.CRM = {});
+(function($, _) {
   if (!CRM.Backbone) CRM.Backbone = {};
 
   /**
@@ -565,8 +564,8 @@
   var wrapError = function (model, options) {
     var error = options.error;
     options.error = function(resp) {
-      if (error) error(model, resp, options);
+      if (error) error(model, resp, optio)
       model.trigger('error', model, resp, options);
     };
   };
-})(cj);
+})(CRM.$, CRM._);
diff --git a/js/jquery/jquery.crmProfileSelector.js b/js/jquery/jquery.crmProfileSelector.js
index 3c09e7f460..98da5842c3 100644
--- a/js/jquery/jquery.crmProfileSelector.js
+++ b/js/jquery/jquery.crmProfileSelector.js
@@ -1,4 +1,4 @@
-(function($) {
+(function($, _) {
   var ufGroupCollection = new CRM.UF.UFGroupCollection(_.sortBy(CRM.initialProfileList.values, 'title'));
   //var ufGroupCollection = new CRM.UF.UFGroupCollection(CRM.initialProfileList.values, {
   //  comparator: 'title' // no point, this doesn't work with subcollections
@@ -63,4 +63,4 @@
     });
   });
 
-})(cj);
+})(CRM.$, CRM._);
diff --git a/js/model/crm.designer.js b/js/model/crm.designer.js
index 729778ae6a..2553b157f6 100644
--- a/js/model/crm.designer.js
+++ b/js/model/crm.designer.js
@@ -1,5 +1,4 @@
-(function($) {
-  var CRM = (window.CRM) ? (window.CRM) : (window.CRM = {});
+(function($, _) {
   if (!CRM.Designer) CRM.Designer = {};
 
   // TODO Optimize this class
@@ -114,4 +113,4 @@
       return fieldsByEntitySection;
     }
   });
-})(cj);
+})(CRM.$, CRM._);
diff --git a/js/model/crm.schema-mapped.js b/js/model/crm.schema-mapped.js
index 7dbc192d27..1a59c0e73f 100644
--- a/js/model/crm.schema-mapped.js
+++ b/js/model/crm.schema-mapped.js
@@ -1,8 +1,7 @@
 /**
  * Dynamically-generated alternative to civi.core.js
  */
-(function($) {
-  var CRM = (window.CRM) ? (window.CRM) : (window.CRM = {});
+(function($, _) {
   if (!CRM.Schema) CRM.Schema = {};
 
   /**
@@ -45,4 +44,4 @@
   };
 
   CRM.Schema.loadModels(CRM.civiSchema);
-})(cj);
\ No newline at end of file
+})(CRM.$, CRM._);
diff --git a/js/model/crm.uf.js b/js/model/crm.uf.js
index f75cbbff8d..c5c2563e38 100644
--- a/js/model/crm.uf.js
+++ b/js/model/crm.uf.js
@@ -1,5 +1,4 @@
-(function($) {
-  var CRM = (window.CRM) ? (window.CRM) : (window.CRM = {});
+(function($, _) {
   if (!CRM.UF) CRM.UF = {};
 
   var YESNO = [
@@ -776,4 +775,4 @@
   CRM.UF.UFGroupCollection = CRM.Backbone.Collection.extend({
     model: CRM.UF.UFGroupModel
   });
-})(cj);
+})(CRM.$, CRM._);
diff --git a/js/view/crm.designer.js b/js/view/crm.designer.js
index 01e75f26bd..d43f1ccfb6 100644
--- a/js/view/crm.designer.js
+++ b/js/view/crm.designer.js
@@ -1,4 +1,4 @@
-(function($) {
+(function($, _) {
   if (!CRM.Designer) CRM.Designer = {};
 
   /**
@@ -874,4 +874,4 @@
     }
   });
 
-})(cj);
+})(CRM.$, CRM._);
diff --git a/js/view/crm.profile-selector.js b/js/view/crm.profile-selector.js
index 306279a250..6521f19572 100644
--- a/js/view/crm.profile-selector.js
+++ b/js/view/crm.profile-selector.js
@@ -1,5 +1,4 @@
-(function($) {
-  var CRM = (window.CRM) ? (window.CRM) : (window.CRM = {});
+(function($, _) {
   if (!CRM.ProfileSelector) CRM.ProfileSelector = {};
 
   CRM.ProfileSelector.Option = Backbone.Marionette.ItemView.extend({
@@ -185,4 +184,4 @@
       view.render();
     }
   });
-})(cj);
+})(CRM.$, CRM._);
diff --git a/templates/CRM/Contact/Page/View/Summary.js b/templates/CRM/Contact/Page/View/Summary.js
index 15331c3171..ef63940e86 100644
--- a/templates/CRM/Contact/Page/View/Summary.js
+++ b/templates/CRM/Contact/Page/View/Summary.js
@@ -1,5 +1,5 @@
 // http://civicrm.org/licensing
-(function($) {
+(function($, _) {
 
   var ajaxFormParams = {
     dataType:'json',
@@ -328,4 +328,4 @@
       });
     $().crmAccordions();
   });
-})(cj);
+})(CRM.$, CRM._);