summaryrefslogtreecommitdiffstats
path: root/js/vendor/angular-ui/modules/directives/if/if.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/vendor/angular-ui/modules/directives/if/if.js')
-rw-r--r--js/vendor/angular-ui/modules/directives/if/if.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/js/vendor/angular-ui/modules/directives/if/if.js b/js/vendor/angular-ui/modules/directives/if/if.js
new file mode 100644
index 000000000..db650aca1
--- /dev/null
+++ b/js/vendor/angular-ui/modules/directives/if/if.js
@@ -0,0 +1,39 @@
+/*
+ * Defines the ui-if tag. This removes/adds an element from the dom depending on a condition
+ * Originally created by @tigbro, for the @jquery-mobile-angular-adapter
+ * https://github.com/tigbro/jquery-mobile-angular-adapter
+ */
+angular.module('ui.directives').directive('uiIf', [function () {
+ return {
+ transclude: 'element',
+ priority: 1000,
+ terminal: true,
+ restrict: 'A',
+ compile: function (element, attr, transclude) {
+ return function (scope, element, attr) {
+
+ var childElement;
+ var childScope;
+
+ scope.$watch(attr['uiIf'], function (newValue) {
+ if (childElement) {
+ childElement.remove();
+ childElement = undefined;
+ }
+ if (childScope) {
+ childScope.$destroy();
+ childScope = undefined;
+ }
+
+ if (newValue) {
+ childScope = scope.$new();
+ transclude(childScope, function (clone) {
+ childElement = clone;
+ element.after(clone);
+ });
+ }
+ });
+ };
+ }
+ };
+}]); \ No newline at end of file