From 2c3b07933eee0bb00cd792d859d5e766c7cbc2d5 Mon Sep 17 00:00:00 2001 From: salimnanji Date: Tue, 22 Sep 2015 11:18:18 -0400 Subject: [PATCH] Dynamic directory path for template folder Using a query to find the location of the current file so you can place the acute.select.js file in any folder. For example, when in "components/acute-select/acute/acute.select/acute.select.js", javascript would try to load "/template" now will load "components/acute-select/acute/acute.select/template" --- acute/acute.select/acute.select.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/acute/acute.select/acute.select.js b/acute/acute.select/acute.select.js index fd27bf6..47df558 100644 --- a/acute/acute.select/acute.select.js +++ b/acute/acute.select/acute.select.js @@ -1040,8 +1040,12 @@ angular.module("acute.select", []) // Service to allow host pages to change settings for all instances (in their module.run function) .factory('acuteSelectService', function() { + // Get directory of script + var fileName = "acute.select.js"; + var directory = document.querySelector('script[src$="' + fileName + '"]').getAttribute('src').replace(fileName,""); + var defaultSettings = { - "templatePath": "/acute.select/template", + "templatePath": directory + "template", "noItemsText": "No items found.", "placeholderText": "Please select...", "itemHeight": 24, @@ -1089,4 +1093,4 @@ angular.module("acute.select", []) defaultSettings[settingName] = value; } } -}); \ No newline at end of file +});