From 15ad37c207d2660c903b527a73b1b40dc15800e7 Mon Sep 17 00:00:00 2001 From: David HAN SZE CHUEN Date: Wed, 26 Feb 2014 23:43:54 +1100 Subject: [PATCH 1/2] Add ability to use another "ace" function from the directive's input attribute This is useful when using this directive inside a popup window that has its own "ace" function. --- src/ui-ace.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ui-ace.js b/src/ui-ace.js index 053c30e..009170d 100644 --- a/src/ui-ace.js +++ b/src/ui-ace.js @@ -95,11 +95,18 @@ angular.module('ui.ace', []) */ var opts = angular.extend({}, options, scope.$eval(attrs.uiAce)); + /** + * ACE library reference + * Use our own "ace" reference or use the global one. + * @type object + */ + var ace = opts.ace || window.ace; + /** * ACE editor * @type object */ - var acee = window.ace.edit(elm[0]); + var acee = ace.edit(elm[0]); /** * ACE editor session. From f613fc03414cd6a13c464e6d2e3b8161b134b77c Mon Sep 17 00:00:00 2001 From: David HAN SZE CHUEN Date: Wed, 26 Feb 2014 23:53:11 +1100 Subject: [PATCH 2/2] Move the "ace" function check inside the directive so that it only blurbs when the user tries to use it --- src/ui-ace.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ui-ace.js b/src/ui-ace.js index 009170d..2441cf9 100644 --- a/src/ui-ace.js +++ b/src/ui-ace.js @@ -7,10 +7,6 @@ angular.module('ui.ace', []) .constant('uiAceConfig', {}) .directive('uiAce', ['uiAceConfig', function (uiAceConfig) { - if (angular.isUndefined(window.ace)) { - throw new Error('ui-ace need ace to work... (o rly?)'); - } - /** * Sets editor options such as the wrapping mode or the syntax checker. * @@ -102,6 +98,10 @@ angular.module('ui.ace', []) */ var ace = opts.ace || window.ace; + if (!ace) { + throw new Error('ui-ace need ace to work... (o rly?)'); + } + /** * ACE editor * @type object