Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 espaco 1
/**
2
 * angular-ui-utils - Swiss-Army-Knife of AngularJS tools (with no external dependencies!)
3
 * @version v0.1.1 - 2014-02-05
4
 * @link http://angular-ui.github.com
5
 * @license MIT License, http://www.opensource.org/licenses/MIT
6
 */
7
// READ: http://docs-next.angularjs.org/guide/ie
8
// element tags are statically defined in order to accommodate lazy-loading whereby directives are also unknown
9
 
10
// The ieshiv takes care of our ui.directives and AngularJS's ng-view, ng-include, ng-pluralize, ng-switch.
11
// However, IF you have custom directives that can be used as html tags (yours or someone else's) then
12
// add list of directives into <code>window.myCustomTags</code>
13
 
14
// <!--[if lte IE 8]>
15
//    <script>
16
//    window.myCustomTags = [ 'yourCustomDirective', 'somebodyElsesDirective' ]; // optional
17
//    </script>
18
//    <script src="build/angular-ui-ieshiv.js"></script>
19
// <![endif]-->
20
 
21
(function (window, document) {
22
  "use strict";
23
 
24
  var tags = [ "ngInclude", "ngPluralize", "ngView", "ngSwitch", "uiCurrency", "uiCodemirror", "uiDate", "uiEvent",
25
                "uiKeypress", "uiKeyup", "uiKeydown", "uiMask", "uiMapInfoWindow", "uiMapMarker", "uiMapPolyline",
26
                "uiMapPolygon", "uiMapRectangle", "uiMapCircle", "uiMapGroundOverlay", "uiModal", "uiReset",
27
                "uiScrollfix", "uiSelect2", "uiShow", "uiHide", "uiToggle", "uiSortable", "uiTinymce"
28
                ];
29
 
30
  window.myCustomTags =  window.myCustomTags || []; // externally defined by developer using angular-ui directives
31
  tags.push.apply(tags, window.myCustomTags);
32
 
33
  var toCustomElements = function (str) {
34
    var result = [];
35
    var dashed = str.replace(/([A-Z])/g, function ($1) {
36
      return " " + $1.toLowerCase();
37
    });
38
    var tokens = dashed.split(" ");
39
 
40
    // If a token is just a single name (i.e. no namespace) then we juse define the elements the name given
41
    if (tokens.length === 1) {
42
      var name = tokens[0];
43
 
44
      result.push(name);
45
      result.push("x-" + name);
46
      result.push("data-" + name);
47
    } else {
48
      var ns = tokens[0];
49
      var dirname = tokens.slice(1).join("-");
50
 
51
      // this is finite list and it seemed senseless to create a custom method
52
      result.push(ns + ":" + dirname);
53
      result.push(ns + "-" + dirname);
54
      result.push("x-" + ns + "-" + dirname);
55
      result.push("data-" + ns + "-" + dirname);
56
    }
57
    return result;
58
  };
59
 
60
  for (var i = 0, tlen = tags.length; i < tlen; i++) {
61
    var customElements = toCustomElements(tags[i]);
62
    for (var j = 0, clen = customElements.length; j < clen; j++) {
63
      var customElement = customElements[j];
64
      document.createElement(customElement);
65
    }
66
  }
67
 
68
})(window, document);