poly-js-utils
Advanced tools
Comparing version 1.0.9 to 1.1.0
{ | ||
"name": "poly-js-utils", | ||
"version": "1.0.9", | ||
"version": "1.1.0", | ||
"description": "Common client-side tools used in HSS Sites themes and locators.", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
@@ -103,3 +103,8 @@ module.exports = { | ||
"org_link": "http://example.com/1/", | ||
"base_link": "http://example.com/" | ||
"base_link": "http://example.com/", | ||
"kaltura_default_uiconf": 99999, | ||
"kaltura_embed_url": "https://cdnapisec.kaltura.com/p/", | ||
"kaltura_partner_id": 00000, | ||
"kaltura_service_url": "https://www.kaltura.com/", | ||
"kalturaVideosQueue": ['a', 'b', 'c'] | ||
}; |
@@ -113,2 +113,19 @@ var $ = require('jquery'); | ||
describe("Test getting the page name", function() { | ||
it('should return the last part of the pathname', function() { | ||
var url = "http://www.example.com:3000/some/path/file.js?hello=world"; | ||
expect(utils.getPageName(url)).toEqual("file.js"); | ||
}); | ||
it('should return index if the pathname has no elements', function() { | ||
var url = "http://www.example.com/"; | ||
expect(utils.getPageName(url)).toEqual("index"); | ||
}); | ||
it('should give us the filename with no trailing slash', function() { | ||
var url = "http://www.example.com/test/slash/"; | ||
expect(utils.getPageName(url)).toEqual("slash"); | ||
}); | ||
}); | ||
describe("Add formatted phone", function() { | ||
@@ -179,2 +196,5 @@ it("should add a formatted version of the specified property", function() { | ||
}); | ||
it("should return an empty string if the date string is empty", function() { | ||
expect(utils.formatDate("")).toEqual(""); | ||
}); | ||
}); | ||
@@ -181,0 +201,0 @@ |
@@ -166,2 +166,17 @@ var viewHelpers = require('../src/view-helpers'); | ||
}); | ||
describe("Formatting links with a certain protocol", function() { | ||
it("should format the href with the protocol and value", function() { | ||
var expected = "mailto:me@me.com"; | ||
expect(viewHelpers.formatHref("mailto", "me@me.com")).toEqual(expected); | ||
}); | ||
it("should do nothing if the protocol is missing", function() { | ||
expect(viewHelpers.formatHref(undefined, "http://www.google.com")).toEqual(undefined); | ||
}); | ||
it("should do nothing if the value is missing", function() { | ||
expect(viewHelpers.formatHref("tel")).toEqual(undefined); | ||
}); | ||
}); | ||
}); |
@@ -21,3 +21,2 @@ var _ = require('underscore'); | ||
// Appends a suffix to the filename part of a url path. | ||
@@ -44,4 +43,3 @@ var appendToUrlPath = function(path, suffix) { | ||
// Get the url for an image resized to the given (or closest | ||
// available) target width. | ||
// Get the url for an image resized to the given (or closest available) target width. | ||
var resize = function(data, photoKey, targetWidth) { | ||
@@ -53,5 +51,3 @@ // Default to original photo url if resize not ready | ||
} | ||
var width = targetWidth ? "-width-" + resizeWidth(targetWidth) : ""; | ||
var urlParts = utils.parseUrl(photo); | ||
@@ -58,0 +54,0 @@ urlParts.pathname = appendToUrlPath(urlParts.pathname, width); |
@@ -158,2 +158,6 @@ /**************************/ | ||
var getKalturaVideosQueue = function() { | ||
return _get("kalturaVideosQueue"); | ||
}; | ||
exports.loadData = loadData; | ||
@@ -178,1 +182,2 @@ exports.getProfile = getProfile; | ||
exports.getKalturaServiceUrl = getKalturaServiceUrl; | ||
exports.getKalturaVideosQueue = getKalturaVideosQueue; |
@@ -13,8 +13,9 @@ /*eslint-env node*/ | ||
var KALTURA_URL = "https://www.kaltura.com/p/2027791/sp/202779100/embedIframeJs/uiconf_id/32676902/partner_id/2027791"; | ||
var KALTURA_UICONF_ID = '32676902'; | ||
var KALTURA_HEIGHT = "393"; | ||
var KALTURA_PREFERRED_FLAVOR = "1600"; | ||
var JSContext = require('./jscontext'); | ||
var _getKalturaVideosQueue = function(){ | ||
return window.JSContext.kalturaVideosQueue; | ||
}; | ||
var _setKalturaVideoQueue = function(array){ | ||
@@ -35,5 +36,3 @@ window.JSContext.kalturaVideosQueue = array; | ||
if (!_isKalturaLoaded()) { | ||
$.getScript( | ||
"https://www.kaltura.com/p/2027791/sp/202779100/embedIframeJs/uiconf_id/32676902/partner_id/2027791" | ||
) | ||
$.getScript(KALTURA_URL) | ||
.done(function() { | ||
@@ -58,5 +57,5 @@ if(_.isFunction(callback)){ | ||
'entry_id': videoId, | ||
'uiconf_id': '32676902', | ||
'uiconf_id': KALTURA_UICONF_ID, | ||
'width': '100%', | ||
'height': '393', | ||
'height': KALTURA_HEIGHT, | ||
'flashvars': { | ||
@@ -69,3 +68,3 @@ 'sourceSelector': { | ||
}, | ||
'mediaProxy.preferedFlavorBR': '1600' | ||
'mediaProxy.preferedFlavorBR': KALTURA_PREFERRED_FLAVOR | ||
} | ||
@@ -77,3 +76,3 @@ }); | ||
var kalturaPartnerId = JSContext.getKalturaPartnerId(); | ||
var kalturaVideosQueue = _getKalturaVideosQueue(); | ||
var kalturaVideosQueue = JSContext.getKalturaVideosQueue(); | ||
@@ -99,3 +98,3 @@ /* Loop throught the videos queue and load each one and then pop it from the queue */ | ||
var _unQueueVideo = function(videoId){ | ||
_setKalturaVideoQueue(_.reject(_getKalturaVideosQueue(), function(id){ return id === videoId; })); | ||
_setKalturaVideoQueue(_.reject(JSContext.getKalturaVideosQueue(), function(id){ return id === videoId; })); | ||
}; | ||
@@ -102,0 +101,0 @@ |
/******************/ | ||
/* Mapbox helpers */ | ||
/* Google Maps helpers */ | ||
/******************/ | ||
@@ -4,0 +4,0 @@ |
@@ -5,15 +5,11 @@ var $ = require('jquery'); | ||
var JSContext = require('./jscontext'); | ||
var Utils = require('./utils'); | ||
var _titleTemplate = '<title><%= title %></title>'; | ||
var _metaTagTemplate = '<meta name="<%= name %>" content="<%= content %>" >'; | ||
var _getCurrentPageName = function(slug) { | ||
var _getCurrentPageName = function() { | ||
var slug = JSContext.getSlug(); | ||
var parts = window.location.pathname.split('/'); | ||
var fileName = parts.pop(); | ||
if (parts.length && window.location.pathname.split('').pop() === '/') { | ||
fileName = parts.pop(); | ||
} | ||
if(fileName === slug || fileName === "") { | ||
var fileName = Utils.getPageName(window.location); | ||
if(fileName === slug) { | ||
fileName = "index"; | ||
@@ -20,0 +16,0 @@ } |
@@ -82,2 +82,15 @@ var $ = require('jquery'); | ||
// We often want the name of the current page, which is the same as the deepest part of the path, | ||
// in most versioned themes. | ||
var getPageName = function(location) { | ||
var parsedUrl = this.parseUrl(location); | ||
var pathParts = _.reject(parsedUrl.pathname.split('/'), function(part) { return part === ""; }); | ||
var fileName = pathParts.pop(); | ||
if(!fileName) { | ||
fileName = "index"; | ||
} | ||
return fileName; | ||
}; | ||
var addFormattedPhone = function(object, property) { | ||
@@ -121,3 +134,3 @@ if (object[property]) { | ||
dateFormat = dateFormat || "MMMM DD YYYY, h:mm a"; | ||
return moment.utc(dateString).local().format(dateFormat); | ||
return dateString ? moment.utc(dateString).local().format(dateFormat) : ""; | ||
}; | ||
@@ -209,2 +222,3 @@ | ||
exports.parseUrl = parseUrl; | ||
exports.getPageName = getPageName; | ||
exports.addFormattedPhone = addFormattedPhone; | ||
@@ -211,0 +225,0 @@ exports.twitterUrl = twitterUrl; |
@@ -140,2 +140,8 @@ /****************************/ | ||
var formatHref = function(protocol, value) { | ||
if(protocol && value) { | ||
return protocol + ":" + value; | ||
} | ||
}; | ||
exports.makeAbsolute = utils.makeAbsolute; | ||
@@ -150,2 +156,3 @@ exports.phoneFormat = phoneFormat; | ||
exports.getURLForSlug = getURLForSlug; | ||
exports.formatHref = formatHref; | ||
exports.resize = resizing.resize; |
88109
28
1896