From b0d4d089ffd501b3365fece7cf2a978c5afca575 Mon Sep 17 00:00:00 2001 From: Phillip Klinefelter Date: Tue, 28 Apr 2015 16:33:33 -0700 Subject: [PATCH 1/2] DDF-1178 Updated lodash --- search-ui/standard/bower.json | 2 +- search-ui/standard/src/main/webapp/main.js | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/search-ui/standard/bower.json b/search-ui/standard/bower.json index 8f71794b02..b27d751745 100644 --- a/search-ui/standard/bower.json +++ b/search-ui/standard/bower.json @@ -19,7 +19,7 @@ "jquery-cookie": "1.4.1", "jquery-ui": "1.10.4", "jqueryui-timepicker-addon": "v1.4.5", - "lodash": "2.4.1", + "lodash": "3.7.0", "marionette": "2.4.1", "moment": "2.5.1", "multiselect": "ehynds/jquery-ui-multiselect-widget#2489720d3b06cf52025d5b7bbd3187ea15a8253f", diff --git a/search-ui/standard/src/main/webapp/main.js b/search-ui/standard/src/main/webapp/main.js index 0319d90e6c..fd133cb194 100644 --- a/search-ui/standard/src/main/webapp/main.js +++ b/search-ui/standard/src/main/webapp/main.js @@ -32,8 +32,7 @@ require.config({ backbonecometd: 'lib/backbone-cometd/backbone.cometd.extension', backboneundo: 'lib/Backbone.Undo.js/Backbone.Undo', poller: 'lib/backbone-poller/backbone.poller', - underscore: 'lib/lodash/dist/lodash.underscore.min', - lodash: 'lib/lodash/dist/lodash.min', + underscore: 'lib/lodash/lodash.min', marionette: 'lib/marionette/lib/backbone.marionette.min', // TODO test combining modelbinder: 'lib/backbone.modelbinder/Backbone.ModelBinder.min', @@ -165,7 +164,8 @@ require.onError = function (err) { } }; -require(['jquery', +require(['underscore', + 'jquery', 'backbone', 'marionette', 'application', @@ -173,9 +173,17 @@ require(['jquery', 'properties', 'js/HandlebarsHelpers', 'js/ApplicationHelpers'], - function ($, Backbone, Marionette, app, ich, properties) { + function (_, $, Backbone, Marionette, app, ich, properties) { 'use strict'; + // Make lodash compatible with Backbone + var lodash = _.noConflict(); + _.mixin({ + 'debounce': _.debounce || lodash.debounce, + 'defer': _.defer || lodash.defer, + 'pluck': _.pluck || lodash.pluck + }); + var document = window.document; //in here we drop in any top level patches, etc. From 6d4bd52ac65448ea5aef2944845703fee51a8d7e Mon Sep 17 00:00:00 2001 From: Phillip Klinefelter Date: Tue, 28 Apr 2015 16:02:32 -0700 Subject: [PATCH 2/2] DDF-1178 Split property names on camel case and all non-word characters --- .../standard/src/main/webapp/js/HandlebarsHelpers.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/search-ui/standard/src/main/webapp/js/HandlebarsHelpers.js b/search-ui/standard/src/main/webapp/js/HandlebarsHelpers.js index dfa894898b..e40af45c3d 100644 --- a/search-ui/standard/src/main/webapp/js/HandlebarsHelpers.js +++ b/search-ui/standard/src/main/webapp/js/HandlebarsHelpers.js @@ -294,15 +294,15 @@ define([ } }, propertyTitle: function (str) { - if(str && typeof str === "string") { - return str.split("-").join(" ").replace(/\w\S*/g, function (word) { - return word.charAt(0).toUpperCase() + word.substr(1); - }); + if (_.isString(str)) { + return _.chain(str).words().map(function(word) { + return _.capitalize(word); + }).join(' '); } return str; }, safeString: function (str) { - if(str && typeof str === "string") { + if (_.isString(str)) { return new Handlebars.SafeString(str); } return str; @@ -311,7 +311,7 @@ define([ return str.split('-').join(' '); }, encodeString: function (str) { - if(str && typeof str === "string") { + if (_.isString(str)) { return encodeURIComponent(str); } return str;