compass-jquery-plugin 0.3.2.3 → 0.3.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (235) hide show
  1. data/README.md +54 -37
  2. data/VERSION.yml +1 -1
  3. data/lib/handle_attributes.rb +4 -4
  4. data/lib/handle_js_files.rb +5 -5
  5. data/lib/jqtouch_theme.rb +2 -2
  6. data/lib/jquery/dynatree.rb +2 -2
  7. data/lib/jquery/emulators.rb +1 -1
  8. data/lib/jquery/flash_messages.rb +6 -6
  9. data/lib/jquery/graphics.rb +5 -0
  10. data/lib/jquery/gridify/assertions.rb +1 -1
  11. data/lib/jquery/gridify/grid.rb +76 -59
  12. data/lib/jquery/gridify/grid_column.rb +73 -67
  13. data/lib/jquery/gridify/grid_finder.rb +79 -79
  14. data/lib/jquery/gridify/grid_options.rb +154 -149
  15. data/lib/jquery/gridify/grid_view.rb +143 -143
  16. data/lib/jquery/gridify.rb +25 -25
  17. data/lib/jquery/ical/calendar.rb +2 -2
  18. data/lib/jquery/ical/event.rb +48 -44
  19. data/lib/jquery/ical/helpers/ui_event_helper.rb +3 -3
  20. data/lib/jquery/jqgrid/jqgrid.rb +58 -58
  21. data/lib/jquery/jqgrid.rb +1 -1
  22. data/lib/jquery/jqtouch.rb +1 -1
  23. data/lib/jquery/jquery.rb +117 -117
  24. data/lib/jquery/jquery_auto_complete.rb +9 -9
  25. data/lib/jquery/jquery_json_response.rb +12 -12
  26. data/lib/jquery/jquery_selector_assertions.rb +55 -53
  27. data/lib/jquery/jstree.rb +2 -2
  28. data/lib/jquery/mobile.rb +1 -1
  29. data/lib/jquery/ribbon.rb +2 -2
  30. data/lib/jquery/secret_sauce/controller/ui_dialog_controls.rb +5 -5
  31. data/lib/jquery/secret_sauce/controller/ui_grid_controls.rb +5 -5
  32. data/lib/jquery/secret_sauce/helpers/ui_dialog_helper.rb +1 -1
  33. data/lib/jquery/secret_sauce/helpers/ui_form_helper.rb +39 -39
  34. data/lib/jquery/secret_sauce/helpers/ui_grid_helper.rb +74 -74
  35. data/lib/jquery/secret_sauce/model/find_for_grid.rb +21 -21
  36. data/lib/jquery/secret_sauce.rb +1 -1
  37. data/lib/jquery/tools.rb +1 -1
  38. data/lib/jquery_mobile_theme.rb +2 -2
  39. data/lib/jquery_ui_theme.rb +12 -12
  40. data/templates/dynatree/config/initializers/dynatree.rb +3 -3
  41. data/templates/dynatree/jquery/dynatree/aero.scss +16 -16
  42. data/templates/dynatree/jquery/dynatree/aqua.scss +16 -16
  43. data/templates/dynatree/jquery/dynatree/crystal.scss +16 -16
  44. data/templates/dynatree/jquery/dynatree/xp.scss +17 -17
  45. data/templates/dynatree/jquery.dynatree.js +2926 -2912
  46. data/templates/emulators/config/initializers/emulators.rb +6 -6
  47. data/templates/graphics/config/initializers/graphics.rb +5 -0
  48. data/templates/graphics/jquery/ganttView.scss +89 -0
  49. data/templates/graphics/jquery.ganttView.js +1669 -0
  50. data/templates/graphics/jquery.ganttView.min.js +70 -0
  51. data/templates/{jquery → graphics}/jquery.sparkline.js +466 -438
  52. data/templates/{jquery → graphics}/jquery.sparkline.min.js +0 -0
  53. data/templates/graphics/manifest.rb +9 -0
  54. data/templates/jqgrid/config/initializers/jqgrid.rb +1 -1
  55. data/templates/jqgrid/i18n/jqgrid/locale-ar.js +131 -125
  56. data/templates/jqgrid/i18n/jqgrid/locale-bg.js +135 -131
  57. data/templates/jqgrid/i18n/jqgrid/locale-bg1251.js +135 -131
  58. data/templates/jqgrid/i18n/jqgrid/locale-cat.js +132 -126
  59. data/templates/jqgrid/i18n/jqgrid/locale-cn.js +137 -131
  60. data/templates/jqgrid/i18n/jqgrid/locale-cs.js +133 -127
  61. data/templates/jqgrid/i18n/jqgrid/locale-da.js +132 -126
  62. data/templates/jqgrid/i18n/jqgrid/locale-de.js +138 -132
  63. data/templates/jqgrid/i18n/jqgrid/locale-el.js +131 -125
  64. data/templates/jqgrid/i18n/jqgrid/locale-en.js +133 -127
  65. data/templates/jqgrid/i18n/jqgrid/locale-es.js +133 -127
  66. data/templates/jqgrid/i18n/jqgrid/locale-fa.js +19 -16
  67. data/templates/jqgrid/i18n/jqgrid/locale-fi.js +132 -126
  68. data/templates/jqgrid/i18n/jqgrid/locale-fr.js +131 -125
  69. data/templates/jqgrid/i18n/jqgrid/locale-gl.js +131 -125
  70. data/templates/jqgrid/i18n/jqgrid/locale-he.js +132 -126
  71. data/templates/jqgrid/i18n/jqgrid/locale-hu.js +133 -127
  72. data/templates/jqgrid/i18n/jqgrid/locale-is.js +131 -125
  73. data/templates/jqgrid/i18n/jqgrid/locale-it.js +8 -1
  74. data/templates/jqgrid/i18n/jqgrid/locale-ja.js +139 -136
  75. data/templates/jqgrid/i18n/jqgrid/locale-nl.js +4 -1
  76. data/templates/jqgrid/i18n/jqgrid/locale-no.js +14 -1
  77. data/templates/jqgrid/i18n/jqgrid/locale-pl.js +132 -126
  78. data/templates/jqgrid/i18n/jqgrid/locale-pt-br.js +132 -126
  79. data/templates/jqgrid/i18n/jqgrid/locale-pt.js +130 -124
  80. data/templates/jqgrid/i18n/jqgrid/locale-ro.js +144 -138
  81. data/templates/jqgrid/i18n/jqgrid/locale-ru.js +132 -126
  82. data/templates/jqgrid/i18n/jqgrid/locale-sk.js +132 -126
  83. data/templates/jqgrid/i18n/jqgrid/locale-sr.js +133 -127
  84. data/templates/jqgrid/i18n/jqgrid/locale-sv.js +132 -126
  85. data/templates/jqgrid/i18n/jqgrid/locale-tr.js +131 -125
  86. data/templates/jqgrid/i18n/jqgrid/locale-ua.js +132 -126
  87. data/templates/jqgrid/jquery.jqGrid.js +12735 -10444
  88. data/templates/jqgrid/jquery.jqGrid.min.js +477 -469
  89. data/templates/jqgrid/public/stylesheets/ellipsis-xbl.xml +12 -10
  90. data/templates/jqtouch/config/initializers/jqtouch.rb +3 -3
  91. data/templates/jqtouch/jquery/touch/jqtouch.scss +1 -1
  92. data/templates/jqtouch/jquery.jqtouch.js +10025 -10043
  93. data/templates/jquery/config/initializers/jquery.rb +2 -4
  94. data/templates/jquery/history.adapter.jquery.js +71 -0
  95. data/templates/jquery/history.adapter.jquery.min.js +4 -0
  96. data/templates/jquery/history.html4.js +690 -0
  97. data/templates/jquery/history.html4.min.js +21 -0
  98. data/templates/jquery/history.js +1297 -0
  99. data/templates/jquery/history.min.js +29 -0
  100. data/templates/jquery/i18n/jquery.ui/datepicker-af.js +20 -20
  101. data/templates/jquery/i18n/jquery.ui/datepicker-ar-DZ.js +19 -19
  102. data/templates/jquery/i18n/jquery.ui/datepicker-ar.js +19 -19
  103. data/templates/jquery/i18n/jquery.ui/datepicker-az.js +19 -19
  104. data/templates/jquery/i18n/jquery.ui/datepicker-bg.js +8 -8
  105. data/templates/jquery/i18n/jquery.ui/datepicker-bs.js +20 -20
  106. data/templates/jquery/i18n/jquery.ui/datepicker-ca.js +20 -20
  107. data/templates/jquery/i18n/jquery.ui/datepicker-cs.js +20 -20
  108. data/templates/jquery/i18n/jquery.ui/datepicker-da.js +14 -14
  109. data/templates/jquery/i18n/jquery.ui/datepicker-de.js +20 -20
  110. data/templates/jquery/i18n/jquery.ui/datepicker-el.js +20 -20
  111. data/templates/jquery/i18n/jquery.ui/datepicker-en-AU.js +20 -20
  112. data/templates/jquery/i18n/jquery.ui/datepicker-en-GB.js +20 -20
  113. data/templates/jquery/i18n/jquery.ui/datepicker-en-NZ.js +20 -20
  114. data/templates/jquery/i18n/jquery.ui/datepicker-eo.js +20 -20
  115. data/templates/jquery/i18n/jquery.ui/datepicker-es.js +20 -20
  116. data/templates/jquery/i18n/jquery.ui/datepicker-et.js +20 -20
  117. data/templates/jquery/i18n/jquery.ui/datepicker-eu.js +20 -20
  118. data/templates/jquery/i18n/jquery.ui/datepicker-fa.js +18 -18
  119. data/templates/jquery/i18n/jquery.ui/datepicker-fi.js +15 -15
  120. data/templates/jquery/i18n/jquery.ui/datepicker-fo.js +20 -20
  121. data/templates/jquery/i18n/jquery.ui/datepicker-fr-CH.js +20 -20
  122. data/templates/jquery/i18n/jquery.ui/datepicker-fr.js +22 -22
  123. data/templates/jquery/i18n/jquery.ui/datepicker-gl.js +20 -20
  124. data/templates/jquery/i18n/jquery.ui/datepicker-he.js +20 -20
  125. data/templates/jquery/i18n/jquery.ui/datepicker-hr.js +20 -20
  126. data/templates/jquery/i18n/jquery.ui/datepicker-hu.js +20 -20
  127. data/templates/jquery/i18n/jquery.ui/datepicker-hu.min.js +1 -1
  128. data/templates/jquery/i18n/jquery.ui/datepicker-hy.js +20 -20
  129. data/templates/jquery/i18n/jquery.ui/datepicker-id.js +20 -20
  130. data/templates/jquery/i18n/jquery.ui/datepicker-is.js +20 -20
  131. data/templates/jquery/i18n/jquery.ui/datepicker-it.js +20 -20
  132. data/templates/jquery/i18n/jquery.ui/datepicker-ja.js +20 -20
  133. data/templates/jquery/i18n/jquery.ui/datepicker-ko.js +20 -20
  134. data/templates/jquery/i18n/jquery.ui/datepicker-kz.js +20 -20
  135. data/templates/jquery/i18n/jquery.ui/datepicker-lt.js +20 -20
  136. data/templates/jquery/i18n/jquery.ui/datepicker-lv.js +20 -20
  137. data/templates/jquery/i18n/jquery.ui/datepicker-ml.js +20 -20
  138. data/templates/jquery/i18n/jquery.ui/datepicker-ms.js +20 -20
  139. data/templates/jquery/i18n/jquery.ui/datepicker-nl.js +20 -20
  140. data/templates/jquery/i18n/jquery.ui/datepicker-no.js +16 -16
  141. data/templates/jquery/i18n/jquery.ui/datepicker-no.min.js +2 -2
  142. data/templates/jquery/i18n/jquery.ui/datepicker-pl.js +20 -20
  143. data/templates/jquery/i18n/jquery.ui/datepicker-pt-BR.js +20 -20
  144. data/templates/jquery/i18n/jquery.ui/datepicker-pt.js +20 -20
  145. data/templates/jquery/i18n/jquery.ui/datepicker-rm.js +18 -18
  146. data/templates/jquery/i18n/jquery.ui/datepicker-ro.js +20 -20
  147. data/templates/jquery/i18n/jquery.ui/datepicker-ru.js +20 -20
  148. data/templates/jquery/i18n/jquery.ui/datepicker-sk.js +20 -20
  149. data/templates/jquery/i18n/jquery.ui/datepicker-sl.js +20 -20
  150. data/templates/jquery/i18n/jquery.ui/datepicker-sq.js +20 -20
  151. data/templates/jquery/i18n/jquery.ui/datepicker-sr-SR.js +20 -20
  152. data/templates/jquery/i18n/jquery.ui/datepicker-sr.js +20 -20
  153. data/templates/jquery/i18n/jquery.ui/datepicker-sv.js +14 -14
  154. data/templates/jquery/i18n/jquery.ui/datepicker-ta.js +20 -20
  155. data/templates/jquery/i18n/jquery.ui/datepicker-th.js +20 -20
  156. data/templates/jquery/i18n/jquery.ui/datepicker-tr.js +20 -20
  157. data/templates/jquery/i18n/jquery.ui/datepicker-uk.js +20 -20
  158. data/templates/jquery/i18n/jquery.ui/datepicker-vi.js +20 -20
  159. data/templates/jquery/i18n/jquery.ui/datepicker-zh-CN.js +20 -20
  160. data/templates/jquery/i18n/jquery.ui/datepicker-zh-HK.js +20 -20
  161. data/templates/jquery/i18n/jquery.ui/datepicker-zh-TW.js +20 -20
  162. data/templates/jquery/{partials → jquery/ui}/_flash_messages.scss +0 -0
  163. data/templates/jquery/jquery/ui/_theme.scss +14 -13
  164. data/templates/jquery/jquery/ui/contextMenu/configure.png +0 -0
  165. data/templates/jquery/jquery/ui/contextMenu/copy.png +0 -0
  166. data/templates/jquery/jquery/ui/contextMenu/cut.png +0 -0
  167. data/templates/jquery/jquery/ui/contextMenu/delete.png +0 -0
  168. data/templates/jquery/jquery/ui/contextMenu/edit.png +0 -0
  169. data/templates/jquery/jquery/ui/contextMenu/exit.png +0 -0
  170. data/templates/jquery/jquery/ui/contextMenu/new.png +0 -0
  171. data/templates/jquery/jquery/ui/contextMenu/paste.png +0 -0
  172. data/templates/jquery/jquery/ui/contextMenu/rename.png +0 -0
  173. data/templates/jquery/jquery/ui/contextMenu/show.png +0 -0
  174. data/templates/jquery/jquery/ui/contextMenu/trash.png +0 -0
  175. data/templates/jquery/jquery/ui/contextMenu.scss +16 -10
  176. data/templates/jquery/jquery-ui.js +11839 -23066
  177. data/templates/jquery/jquery-ui.min.js +401 -795
  178. data/templates/jquery/jquery.bgiframe.js +27 -25
  179. data/templates/jquery/jquery.contextMenu.js +209 -196
  180. data/templates/jquery/jquery.cookie.js +3 -1
  181. data/templates/jquery/jquery.dotimeout.js +236 -228
  182. data/templates/jquery/jquery.dst.js +154 -151
  183. data/templates/jquery/jquery.farbtastic.js +293 -293
  184. data/templates/jquery/jquery.flashMessages.js +26 -0
  185. data/templates/jquery/jquery.flashMessages.min.js +1 -0
  186. data/templates/jquery/jquery.form.js +803 -786
  187. data/templates/jquery/jquery.haml.js +248 -247
  188. data/templates/jquery/jquery.hotkeys.js +89 -89
  189. data/templates/jquery/jquery.js +8141 -8106
  190. data/templates/jquery/jquery.layout.js +2451 -2415
  191. data/templates/jquery/jquery.min.js +167 -166
  192. data/templates/jquery/jquery.mousewheel.js +62 -54
  193. data/templates/jquery/jquery.offline.js +171 -171
  194. data/templates/jquery/jquery.pngFix.js +76 -76
  195. data/templates/jquery/jquery.replacetext.js +83 -83
  196. data/templates/jquery/jquery.themeswitchertool.js +202 -177
  197. data/templates/jquery/jquery.tmpl.js +478 -473
  198. data/templates/jquery/jquery.tmplPlus.js +82 -81
  199. data/templates/jquery/jrails.js +178 -175
  200. data/templates/jquery/json.js +77 -7
  201. data/templates/jquery/json2.js +480 -0
  202. data/templates/jquery/json2.min.js +7 -0
  203. data/templates/jquery/lib/tasks/haml.rake +2 -2
  204. data/templates/jquery/manifest.rb +21 -17
  205. data/templates/jstree/jquery.jstree.js +5967 -4536
  206. data/templates/mobile/config/initializers/mobile.rb +1 -1
  207. data/templates/mobile/jquery/mobile/_base.scss +944 -927
  208. data/templates/mobile/jquery/mobile/default.scss +61 -48
  209. data/templates/mobile/jquery/mobile/valencia.scss +56 -42
  210. data/templates/mobile/jquery.mobile.js +4461 -4347
  211. data/templates/mobile/jquery.mobile.min.js +11 -2
  212. data/templates/mobile/lib/tasks/jquery.mobile.rake +12 -12
  213. data/templates/ribbon/config/initializers/ribbon.rb +2 -2
  214. data/templates/ribbon/jquery.ribbon.js +50 -29
  215. data/templates/secret_sauce/secret_sauce.js +8 -8
  216. data/templates/tools/flowplayer.js +945 -1
  217. data/templates/tools/jquery.tools.js +4645 -4335
  218. data/templates/tools/jquery.tools.min.js +37 -37
  219. data/templates/tools/lib/tasks/jquery.tools.rake +4 -4
  220. data/templates/tools/swfobject.js +813 -773
  221. metadata +33 -21
  222. data/templates/jquery/haml.js +0 -506
  223. data/templates/jquery/haml.min.js +0 -5
  224. data/templates/jquery/jquery/ui/contextMenu/door.png +0 -0
  225. data/templates/jquery/jquery/ui/contextMenu/page_white_copy.png +0 -0
  226. data/templates/jquery/jquery/ui/contextMenu/page_white_delete.png +0 -0
  227. data/templates/jquery/jquery/ui/contextMenu/page_white_edit.png +0 -0
  228. data/templates/jquery/jquery/ui/contextMenu/page_white_new.png +0 -0
  229. data/templates/jquery/jquery/ui/contextMenu/page_white_paste.png +0 -0
  230. data/templates/jquery/jquery.compat-1.3.js +0 -291
  231. data/templates/jquery/jquery.compat-1.3.min.js +0 -6
  232. data/templates/jquery/jquery.flash_messages.js +0 -5
  233. data/templates/jquery/jquery.flash_messages.min.js +0 -1
  234. data/templates/jquery/jquery.history.js +0 -194
  235. data/templates/jquery/jquery.history.min.js +0 -5
@@ -7,476 +7,481 @@
7
7
  * Dual licensed under the MIT or GPL Version 2 licenses.
8
8
  * http://jquery.org/license
9
9
  */
10
- (function( jQuery, undefined ){
11
- var oldManip = jQuery.fn.domManip, tmplItmAtt = "_tmplitem", htmlExpr = /^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
12
- newTmplItems = {}, wrappedItems = {}, appendToTmplItems, topTmplItem = { key: 0, data: {} }, itemKey = 0, cloneIndex = 0, stack = [];
13
-
14
- function newTmplItem( options, parentItem, fn, data ) {
15
- // Returns a template item data structure for a new rendered instance of a template (a 'template item').
16
- // The content field is a hierarchical array of strings and nested items (to be
17
- // removed and replaced by nodes field of dom elements, once inserted in DOM).
18
- var newItem = {
19
- data: data || (parentItem ? parentItem.data : {}),
20
- _wrap: parentItem ? parentItem._wrap : null,
21
- tmpl: null,
22
- parent: parentItem || null,
23
- nodes: [],
24
- calls: tiCalls,
25
- nest: tiNest,
26
- wrap: tiWrap,
27
- html: tiHtml,
28
- update: tiUpdate
29
- };
30
- if ( options ) {
31
- jQuery.extend( newItem, options, { nodes: [], parent: parentItem });
32
- }
33
- if ( fn ) {
34
- // Build the hierarchical content to be used during insertion into DOM
35
- newItem.tmpl = fn;
36
- newItem._ctnt = newItem._ctnt || newItem.tmpl( jQuery, newItem );
37
- newItem.key = ++itemKey;
38
- // Keep track of new template item, until it is stored as jQuery Data on DOM element
39
- (stack.length ? wrappedItems : newTmplItems)[itemKey] = newItem;
40
- }
41
- return newItem;
42
- }
43
-
44
- // Override appendTo etc., in order to provide support for targeting multiple elements. (This code would disappear if integrated in jquery core).
45
- jQuery.each({
46
- appendTo: "append",
47
- prependTo: "prepend",
48
- insertBefore: "before",
49
- insertAfter: "after",
50
- replaceAll: "replaceWith"
51
- }, function( name, original ) {
52
- jQuery.fn[ name ] = function( selector ) {
53
- var ret = [], insert = jQuery( selector ), elems, i, l, tmplItems,
54
- parent = this.length === 1 && this[0].parentNode;
55
-
56
- appendToTmplItems = newTmplItems || {};
57
- if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
58
- insert[ original ]( this[0] );
59
- ret = this;
60
- } else {
61
- for ( i = 0, l = insert.length; i < l; i++ ) {
62
- cloneIndex = i;
63
- elems = (i > 0 ? this.clone(true) : this).get();
64
- jQuery( insert[i] )[ original ]( elems );
65
- ret = ret.concat( elems );
66
- }
67
- cloneIndex = 0;
68
- ret = this.pushStack( ret, name, insert.selector );
69
- }
70
- tmplItems = appendToTmplItems;
71
- appendToTmplItems = null;
72
- jQuery.tmpl.complete( tmplItems );
73
- return ret;
74
- };
75
- });
76
-
77
- jQuery.fn.extend({
78
- // Use first wrapped element as template markup.
79
- // Return wrapped set of template items, obtained by rendering template against data.
80
- tmpl: function( data, options, parentItem ) {
81
- return jQuery.tmpl( this[0], data, options, parentItem );
82
- },
83
-
84
- // Find which rendered template item the first wrapped DOM element belongs to
85
- tmplItem: function() {
86
- return jQuery.tmplItem( this[0] );
87
- },
88
-
89
- // Consider the first wrapped element as a template declaration, and get the compiled template or store it as a named template.
90
- template: function( name ) {
91
- return jQuery.template( name, this[0] );
92
- },
93
-
94
- domManip: function( args, table, callback, options ) {
95
- if ( args[0] && jQuery.isArray( args[0] )) {
96
- var dmArgs = jQuery.makeArray( arguments ), elems = args[0], elemsLength = elems.length, i = 0, tmplItem;
97
- while ( i < elemsLength && !(tmplItem = jQuery.data( elems[i++], "tmplItem" ))) {}
98
- if ( tmplItem && cloneIndex ) {
99
- dmArgs[2] = function( fragClone ) {
100
- // Handler called by oldManip when rendered template has been inserted into DOM.
101
- jQuery.tmpl.afterManip( this, fragClone, callback );
102
- };
103
- }
104
- oldManip.apply( this, dmArgs );
105
- } else {
106
- oldManip.apply( this, arguments );
107
- }
108
- cloneIndex = 0;
109
- if ( !appendToTmplItems ) {
110
- jQuery.tmpl.complete( newTmplItems );
111
- }
112
- return this;
113
- }
114
- });
115
-
116
- jQuery.extend({
117
- // Return wrapped set of template items, obtained by rendering template against data.
118
- tmpl: function( tmpl, data, options, parentItem ) {
119
- var ret, topLevel = !parentItem;
120
- if ( topLevel ) {
121
- // This is a top-level tmpl call (not from a nested template using {{tmpl}})
122
- parentItem = topTmplItem;
123
- tmpl = jQuery.template[tmpl] || jQuery.template( null, tmpl );
124
- wrappedItems = {}; // Any wrapped items will be rebuilt, since this is top level
125
- } else if ( !tmpl ) {
126
- // The template item is already associated with DOM - this is a refresh.
127
- // Re-evaluate rendered template for the parentItem
128
- tmpl = parentItem.tmpl;
129
- newTmplItems[parentItem.key] = parentItem;
130
- parentItem.nodes = [];
131
- if ( parentItem.wrapped ) {
132
- updateWrapped( parentItem, parentItem.wrapped );
133
- }
134
- // Rebuild, without creating a new template item
135
- return jQuery( build( parentItem, null, parentItem.tmpl( jQuery, parentItem ) ));
136
- }
137
- if ( !tmpl ) {
138
- return []; // Could throw...
139
- }
140
- if ( typeof data === "function" ) {
141
- data = data.call( parentItem || {} );
142
- }
143
- if ( options && options.wrapped ) {
144
- updateWrapped( options, options.wrapped );
145
- }
146
- ret = jQuery.isArray( data ) ?
147
- jQuery.map( data, function( dataItem ) {
148
- return dataItem ? newTmplItem( options, parentItem, tmpl, dataItem ) : null;
149
- }) :
150
- [ newTmplItem( options, parentItem, tmpl, data ) ];
151
- return topLevel ? jQuery( build( parentItem, null, ret ) ) : ret;
152
- },
153
-
154
- // Return rendered template item for an element.
155
- tmplItem: function( elem ) {
156
- var tmplItem;
157
- if ( elem instanceof jQuery ) {
158
- elem = elem[0];
159
- }
160
- while ( elem && elem.nodeType === 1 && !(tmplItem = jQuery.data( elem, "tmplItem" )) && (elem = elem.parentNode) ) {}
161
- return tmplItem || topTmplItem;
162
- },
163
-
164
- // Set:
165
- // Use $.template( name, tmpl ) to cache a named template,
166
- // where tmpl is a template string, a script element or a jQuery instance wrapping a script element, etc.
167
- // Use $( "selector" ).template( name ) to provide access by name to a script block template declaration.
168
-
169
- // Get:
170
- // Use $.template( name ) to access a cached template.
171
- // Also $( selectorToScriptBlock ).template(), or $.template( null, templateString )
172
- // will return the compiled template, without adding a name reference.
173
- // If templateString includes at least one HTML tag, $.template( templateString ) is equivalent
174
- // to $.template( null, templateString )
175
- template: function( name, tmpl ) {
176
- if (tmpl) {
177
- // Compile template and associate with name
178
- if ( typeof tmpl === "string" ) {
179
- // This is an HTML string being passed directly in.
180
- tmpl = buildTmplFn( tmpl )
181
- } else if ( tmpl instanceof jQuery ) {
182
- tmpl = tmpl[0] || {};
183
- }
184
- if ( tmpl.nodeType ) {
185
- // If this is a template block, use cached copy, or generate tmpl function and cache.
186
- tmpl = jQuery.data( tmpl, "tmpl" ) || jQuery.data( tmpl, "tmpl", buildTmplFn( tmpl.innerHTML ));
187
- // Issue: In IE, if the container element is not a script block, the innerHTML will remove quotes from attribute values whenever the value does not include white space.
188
- // This means that foo="${x}" will not work if the value of x includes white space: foo="${x}" -> foo=value of x.
189
- // To correct this, include space in tag: foo="${ x }" -> foo="value of x"
190
- }
191
- return typeof name === "string" ? (jQuery.template[name] = tmpl) : tmpl;
192
- }
193
- // Return named compiled template
194
- return name ? (typeof name !== "string" ? jQuery.template( null, name ):
195
- (jQuery.template[name] ||
196
- // If not in map, treat as a selector. (If integrated with core, use quickExpr.exec)
197
- jQuery.template( null, htmlExpr.test( name ) ? name : jQuery( name )))) : null;
198
- },
199
-
200
- encode: function( text ) {
201
- // Do HTML encoding replacing < > & and ' and " by corresponding entities.
202
- return ("" + text).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;");
203
- }
204
- });
205
-
206
- jQuery.extend( jQuery.tmpl, {
207
- tag: {
208
- "tmpl": {
209
- _default: { $2: "null" },
210
- open: "if($notnull_1){_=_.concat($item.nest($1,$2));}"
211
- // tmpl target parameter can be of type function, so use $1, not $1a (so not auto detection of functions)
212
- // This means that {{tmpl foo}} treats foo as a template (which IS a function).
213
- // Explicit parens can be used if foo is a function that returns a template: {{tmpl foo()}}.
214
- },
215
- "wrap": {
216
- _default: { $2: "null" },
217
- open: "$item.calls(_,$1,$2);_=[];",
218
- close: "call=$item.calls();_=call._.concat($item.wrap(call,_));"
219
- },
220
- "each": {
221
- _default: { $2: "$index, $value" },
222
- open: "if($notnull_1){$.each($1a,function($2){with(this){",
223
- close: "}});}"
224
- },
225
- "if": {
226
- open: "if(($notnull_1) && $1a){",
227
- close: "}"
228
- },
229
- "else": {
230
- _default: { $1: "true" },
231
- open: "}else if(($notnull_1) && $1a){"
232
- },
233
- "html": {
234
- // Unecoded expression evaluation.
235
- open: "if($notnull_1){_.push($1a);}"
236
- },
237
- "=": {
238
- // Encoded expression evaluation. Abbreviated form is ${}.
239
- _default: { $1: "$data" },
240
- open: "if($notnull_1){_.push($.encode($1a));}"
241
- },
242
- "!": {
243
- // Comment tag. Skipped by parser
244
- open: ""
245
- }
246
- },
247
-
248
- // This stub can be overridden, e.g. in jquery.tmplPlus for providing rendered events
249
- complete: function( items ) {
250
- newTmplItems = {};
251
- },
252
-
253
- // Call this from code which overrides domManip, or equivalent
254
- // Manage cloning/storing template items etc.
255
- afterManip: function afterManip( elem, fragClone, callback ) {
256
- // Provides cloned fragment ready for fixup prior to and after insertion into DOM
257
- var content = fragClone.nodeType === 11 ?
258
- jQuery.makeArray(fragClone.childNodes) :
259
- fragClone.nodeType === 1 ? [fragClone] : [];
260
-
261
- // Return fragment to original caller (e.g. append) for DOM insertion
262
- callback.call( elem, fragClone );
263
-
264
- // Fragment has been inserted:- Add inserted nodes to tmplItem data structure. Replace inserted element annotations by jQuery.data.
265
- storeTmplItems( content );
266
- cloneIndex++;
267
- }
268
- });
269
-
270
- //========================== Private helper functions, used by code above ==========================
271
-
272
- function build( tmplItem, nested, content ) {
273
- // Convert hierarchical content into flat string array
274
- // and finally return array of fragments ready for DOM insertion
275
- var frag, ret = content ? jQuery.map( content, function( item ) {
276
- return (typeof item === "string") ?
277
- // Insert template item annotations, to be converted to jQuery.data( "tmplItem" ) when elems are inserted into DOM.
278
- (tmplItem.key ? item.replace( /(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g, "$1 " + tmplItmAtt + "=\"" + tmplItem.key + "\" $2" ) : item) :
279
- // This is a child template item. Build nested template.
280
- build( item, tmplItem, item._ctnt );
281
- }) :
282
- // If content is not defined, insert tmplItem directly. Not a template item. May be a string, or a string array, e.g. from {{html $item.html()}}.
283
- tmplItem;
284
- if ( nested ) {
285
- return ret;
286
- }
287
-
288
- // top-level template
289
- ret = ret.join("");
290
-
291
- // Support templates which have initial or final text nodes, or consist only of text
292
- // Also support HTML entities within the HTML markup.
293
- ret.replace( /^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/, function( all, before, middle, after) {
294
- frag = jQuery( middle ).get();
295
-
296
- storeTmplItems( frag );
297
- if ( before ) {
298
- frag = unencode( before ).concat(frag);
299
- }
300
- if ( after ) {
301
- frag = frag.concat(unencode( after ));
302
- }
303
- });
304
- return frag ? frag : unencode( ret );
305
- }
306
-
307
- function unencode( text ) {
308
- // Use createElement, since createTextNode will not render HTML entities correctly
309
- var el = document.createElement( "div" );
310
- el.innerHTML = text;
311
- return jQuery.makeArray(el.childNodes);
312
- }
313
-
314
- // Generate a reusable function that will serve to render a template against data
315
- function buildTmplFn( markup ) {
316
- return new Function("jQuery","$item",
317
- "var $=jQuery,call,_=[],$data=$item.data;" +
318
-
319
- // Introduce the data as local variables using with(){}
320
- "with($data){_.push('" +
321
-
322
- // Convert the template into pure JavaScript
323
- jQuery.trim(markup)
324
- .replace( /([\\'])/g, "\\$1" )
325
- .replace( /[\r\t\n]/g, " " )
326
- .replace( /\$\{([^\}]*)\}/g, "{{= $1}}" )
327
- .replace( /\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
328
- function( all, slash, type, fnargs, target, parens, args ) {
329
- var tag = jQuery.tmpl.tag[ type ], def, expr, exprAutoFnDetect;
330
- if ( !tag ) {
331
- throw "Template command not found: " + type;
332
- }
333
- def = tag._default || [];
334
- if ( parens && !/\w$/.test(target)) {
335
- target += parens;
336
- parens = "";
337
- }
338
- if ( target ) {
339
- target = unescape( target );
340
- args = args ? ("," + unescape( args ) + ")") : (parens ? ")" : "");
341
- // Support for target being things like a.toLowerCase();
342
- // In that case don't call with template item as 'this' pointer. Just evaluate...
343
- expr = parens ? (target.indexOf(".") > -1 ? target + unescape( parens ) : ("(" + target + ").call($item" + args)) : target;
344
- exprAutoFnDetect = parens ? expr : "(typeof(" + target + ")==='function'?(" + target + ").call($item):(" + target + "))";
345
- } else {
346
- exprAutoFnDetect = expr = def.$1 || "null";
347
- }
348
- fnargs = unescape( fnargs );
349
- return "');" +
350
- tag[ slash ? "close" : "open" ]
351
- .split( "$notnull_1" ).join( target ? "typeof(" + target + ")!=='undefined' && (" + target + ")!=null" : "true" )
352
- .split( "$1a" ).join( exprAutoFnDetect )
353
- .split( "$1" ).join( expr )
354
- .split( "$2" ).join( fnargs || def.$2 || "" ) +
355
- "_.push('";
356
- }) +
357
- "');}return _;"
358
- );
359
- }
360
- function updateWrapped( options, wrapped ) {
361
- // Build the wrapped content.
362
- options._wrap = build( options, true,
363
- // Suport imperative scenario in which options.wrapped can be set to a selector or an HTML string.
364
- jQuery.isArray( wrapped ) ? wrapped : [htmlExpr.test( wrapped ) ? wrapped : jQuery( wrapped ).html()]
365
- ).join("");
366
- }
367
-
368
- function unescape( args ) {
369
- return args ? args.replace( /\\'/g, "'").replace(/\\\\/g, "\\" ) : null;
370
- }
371
- function outerHtml( elem ) {
372
- var div = document.createElement("div");
373
- div.appendChild( elem.cloneNode(true) );
374
- return div.innerHTML;
375
- }
376
-
377
- // Store template items in jQuery.data(), ensuring a unique tmplItem data data structure for each rendered template instance.
378
- function storeTmplItems( content ) {
379
- var keySuffix = "_" + cloneIndex, elem, elems, newClonedItems = {}, i, l, m;
380
- for ( i = 0, l = content.length; i < l; i++ ) {
381
- if ( (elem = content[i]).nodeType !== 1 ) {
382
- continue;
383
- }
384
- elems = elem.getElementsByTagName("*");
385
- for ( m = elems.length - 1; m >= 0; m-- ) {
386
- processItemKey( elems[m] );
387
- }
388
- processItemKey( elem );
389
- }
390
- function processItemKey( el ) {
391
- var pntKey, pntNode = el, pntItem, tmplItem, key;
392
- // Ensure that each rendered template inserted into the DOM has its own template item,
393
- if ( (key = el.getAttribute( tmplItmAtt ))) {
394
- while ( pntNode.parentNode && (pntNode = pntNode.parentNode).nodeType === 1 && !(pntKey = pntNode.getAttribute( tmplItmAtt ))) { }
395
- if ( pntKey !== key ) {
396
- // The next ancestor with a _tmplitem expando is on a different key than this one.
397
- // So this is a top-level element within this template item
398
- // Set pntNode to the key of the parentNode, or to 0 if pntNode.parentNode is null, or pntNode is a fragment.
399
- pntNode = pntNode.parentNode ? (pntNode.nodeType === 11 ? 0 : (pntNode.getAttribute( tmplItmAtt ) || 0)) : 0;
400
- if ( !(tmplItem = newTmplItems[key]) ) {
401
- // The item is for wrapped content, and was copied from the temporary parent wrappedItem.
402
- tmplItem = wrappedItems[key];
403
- tmplItem = newTmplItem( tmplItem, newTmplItems[pntNode]||wrappedItems[pntNode] );
404
- tmplItem.key = ++itemKey;
405
- newTmplItems[itemKey] = tmplItem;
406
- }
407
- if ( cloneIndex ) {
408
- cloneTmplItem( key );
409
- }
410
- }
411
- el.removeAttribute( tmplItmAtt );
412
- } else if ( cloneIndex && (tmplItem = jQuery.data( el, "tmplItem" )) ) {
413
- // This was a rendered element, cloned during append or appendTo etc.
414
- // TmplItem stored in jQuery data has already been cloned in cloneCopyEvent. We must replace it with a fresh cloned tmplItem.
415
- cloneTmplItem( tmplItem.key );
416
- newTmplItems[tmplItem.key] = tmplItem;
417
- pntNode = jQuery.data( el.parentNode, "tmplItem" );
418
- pntNode = pntNode ? pntNode.key : 0;
419
- }
420
- if ( tmplItem ) {
421
- pntItem = tmplItem;
422
- // Find the template item of the parent element.
423
- // (Using !=, not !==, since pntItem.key is number, and pntNode may be a string)
424
- while ( pntItem && pntItem.key != pntNode ) {
425
- // Add this element as a top-level node for this rendered template item, as well as for any
426
- // ancestor items between this item and the item of its parent element
427
- pntItem.nodes.push( el );
428
- pntItem = pntItem.parent;
429
- }
430
- // Delete content built during rendering - reduce API surface area and memory use, and avoid exposing of stale data after rendering...
431
- delete tmplItem._ctnt;
432
- delete tmplItem._wrap;
433
- // Store template item as jQuery data on the element
434
- jQuery.data( el, "tmplItem", tmplItem );
435
- }
436
- function cloneTmplItem( key ) {
437
- key = key + keySuffix;
438
- tmplItem = newClonedItems[key] =
439
- (newClonedItems[key] || newTmplItem( tmplItem, newTmplItems[tmplItem.parent.key + keySuffix] || tmplItem.parent ));
440
- }
441
- }
442
- }
443
-
444
- //---- Helper functions for template item ----
445
-
446
- function tiCalls( content, tmpl, data, options ) {
447
- if ( !content ) {
448
- return stack.pop();
449
- }
450
- stack.push({ _: content, tmpl: tmpl, item:this, data: data, options: options });
451
- }
452
-
453
- function tiNest( tmpl, data, options ) {
454
- // nested template, using {{tmpl}} tag
455
- return jQuery.tmpl( jQuery.template( tmpl ), data, options, this );
456
- }
457
-
458
- function tiWrap( call, wrapped ) {
459
- // nested template, using {{wrap}} tag
460
- var options = call.options || {};
461
- options.wrapped = wrapped;
462
- // Apply the template, which may incorporate wrapped content,
463
- return jQuery.tmpl( jQuery.template( call.tmpl ), call.data, options, call.item );
464
- }
465
-
466
- function tiHtml( filter, textOnly ) {
467
- var wrapped = this._wrap;
468
- return jQuery.map(
469
- jQuery( jQuery.isArray( wrapped ) ? wrapped.join("") : wrapped ).filter( filter || "*" ),
470
- function(e) {
471
- return textOnly ?
472
- e.innerText || e.textContent :
473
- e.outerHTML || outerHtml(e);
474
- });
475
- }
476
-
477
- function tiUpdate() {
478
- var coll = this.nodes;
479
- jQuery.tmpl( null, null, null, this).insertBefore( coll[0] );
480
- jQuery( coll ).remove();
481
- }
482
- })( jQuery );
10
+ (function(jQuery, undefined) {
11
+ var oldManip = jQuery.fn.domManip, tmplItmAtt = "_tmplitem", htmlExpr = /^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
12
+ newTmplItems = {}, wrappedItems = {}, appendToTmplItems, topTmplItem = { key: 0, data: {} }, itemKey = 0, cloneIndex = 0, stack = [];
13
+
14
+ function newTmplItem(options, parentItem, fn, data) {
15
+ // Returns a template item data structure for a new rendered instance of a template (a 'template item').
16
+ // The content field is a hierarchical array of strings and nested items (to be
17
+ // removed and replaced by nodes field of dom elements, once inserted in DOM).
18
+ var newItem = {
19
+ data: data || (parentItem ? parentItem.data : {}),
20
+ _wrap: parentItem ? parentItem._wrap : null,
21
+ tmpl: null,
22
+ parent: parentItem || null,
23
+ nodes: [],
24
+ calls: tiCalls,
25
+ nest: tiNest,
26
+ wrap: tiWrap,
27
+ html: tiHtml,
28
+ update: tiUpdate
29
+ };
30
+ if (options) {
31
+ jQuery.extend(newItem, options, { nodes: [], parent: parentItem });
32
+ }
33
+ if (fn) {
34
+ // Build the hierarchical content to be used during insertion into DOM
35
+ newItem.tmpl = fn;
36
+ newItem._ctnt = newItem._ctnt || newItem.tmpl(jQuery, newItem);
37
+ newItem.key = ++itemKey;
38
+ // Keep track of new template item, until it is stored as jQuery Data on DOM element
39
+ (stack.length ? wrappedItems : newTmplItems)[itemKey] = newItem;
40
+ }
41
+ return newItem;
42
+ }
43
+
44
+ // Override appendTo etc., in order to provide support for targeting multiple elements. (This code would disappear if integrated in jquery core).
45
+ jQuery.each({
46
+ appendTo: "append",
47
+ prependTo: "prepend",
48
+ insertBefore: "before",
49
+ insertAfter: "after",
50
+ replaceAll: "replaceWith"
51
+ }, function(name, original) {
52
+ jQuery.fn[ name ] = function(selector) {
53
+ var ret = [], insert = jQuery(selector), elems, i, l, tmplItems,
54
+ parent = this.length === 1 && this[0].parentNode;
55
+
56
+ appendToTmplItems = newTmplItems || {};
57
+ if (parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1) {
58
+ insert[ original ](this[0]);
59
+ ret = this;
60
+ } else {
61
+ for (i = 0,l = insert.length; i < l; i++) {
62
+ cloneIndex = i;
63
+ elems = (i > 0 ? this.clone(true) : this).get();
64
+ jQuery(insert[i])[ original ](elems);
65
+ ret = ret.concat(elems);
66
+ }
67
+ cloneIndex = 0;
68
+ ret = this.pushStack(ret, name, insert.selector);
69
+ }
70
+ tmplItems = appendToTmplItems;
71
+ appendToTmplItems = null;
72
+ jQuery.tmpl.complete(tmplItems);
73
+ return ret;
74
+ };
75
+ });
76
+
77
+ jQuery.fn.extend({
78
+ // Use first wrapped element as template markup.
79
+ // Return wrapped set of template items, obtained by rendering template against data.
80
+ tmpl: function(data, options, parentItem) {
81
+ return jQuery.tmpl(this[0], data, options, parentItem);
82
+ },
83
+
84
+ // Find which rendered template item the first wrapped DOM element belongs to
85
+ tmplItem: function() {
86
+ return jQuery.tmplItem(this[0]);
87
+ },
88
+
89
+ // Consider the first wrapped element as a template declaration, and get the compiled template or store it as a named template.
90
+ template: function(name) {
91
+ return jQuery.template(name, this[0]);
92
+ },
93
+
94
+ domManip: function(args, table, callback, options) {
95
+ if (args[0] && jQuery.isArray(args[0])) {
96
+ var dmArgs = jQuery.makeArray(arguments), elems = args[0], elemsLength = elems.length, i = 0, tmplItem;
97
+ while (i < elemsLength && !(tmplItem = jQuery.data(elems[i++], "tmplItem"))) {
98
+ }
99
+ if (tmplItem && cloneIndex) {
100
+ dmArgs[2] = function(fragClone) {
101
+ // Handler called by oldManip when rendered template has been inserted into DOM.
102
+ jQuery.tmpl.afterManip(this, fragClone, callback);
103
+ };
104
+ }
105
+ oldManip.apply(this, dmArgs);
106
+ } else {
107
+ oldManip.apply(this, arguments);
108
+ }
109
+ cloneIndex = 0;
110
+ if (!appendToTmplItems) {
111
+ jQuery.tmpl.complete(newTmplItems);
112
+ }
113
+ return this;
114
+ }
115
+ });
116
+
117
+ jQuery.extend({
118
+ // Return wrapped set of template items, obtained by rendering template against data.
119
+ tmpl: function(tmpl, data, options, parentItem) {
120
+ var ret, topLevel = !parentItem;
121
+ if (topLevel) {
122
+ // This is a top-level tmpl call (not from a nested template using {{tmpl}})
123
+ parentItem = topTmplItem;
124
+ tmpl = jQuery.template[tmpl] || jQuery.template(null, tmpl);
125
+ wrappedItems = {}; // Any wrapped items will be rebuilt, since this is top level
126
+ } else if (!tmpl) {
127
+ // The template item is already associated with DOM - this is a refresh.
128
+ // Re-evaluate rendered template for the parentItem
129
+ tmpl = parentItem.tmpl;
130
+ newTmplItems[parentItem.key] = parentItem;
131
+ parentItem.nodes = [];
132
+ if (parentItem.wrapped) {
133
+ updateWrapped(parentItem, parentItem.wrapped);
134
+ }
135
+ // Rebuild, without creating a new template item
136
+ return jQuery(build(parentItem, null, parentItem.tmpl(jQuery, parentItem)));
137
+ }
138
+ if (!tmpl) {
139
+ return []; // Could throw...
140
+ }
141
+ if (typeof data === "function") {
142
+ data = data.call(parentItem || {});
143
+ }
144
+ if (options && options.wrapped) {
145
+ updateWrapped(options, options.wrapped);
146
+ }
147
+ ret = jQuery.isArray(data) ?
148
+ jQuery.map(data, function(dataItem) {
149
+ return dataItem ? newTmplItem(options, parentItem, tmpl, dataItem) : null;
150
+ }) :
151
+ [ newTmplItem(options, parentItem, tmpl, data) ];
152
+ return topLevel ? jQuery(build(parentItem, null, ret)) : ret;
153
+ },
154
+
155
+ // Return rendered template item for an element.
156
+ tmplItem: function(elem) {
157
+ var tmplItem;
158
+ if (elem instanceof jQuery) {
159
+ elem = elem[0];
160
+ }
161
+ while (elem && elem.nodeType === 1 && !(tmplItem = jQuery.data(elem, "tmplItem")) && (elem = elem.parentNode)) {
162
+ }
163
+ return tmplItem || topTmplItem;
164
+ },
165
+
166
+ // Set:
167
+ // Use $.template( name, tmpl ) to cache a named template,
168
+ // where tmpl is a template string, a script element or a jQuery instance wrapping a script element, etc.
169
+ // Use $( "selector" ).template( name ) to provide access by name to a script block template declaration.
170
+
171
+ // Get:
172
+ // Use $.template( name ) to access a cached template.
173
+ // Also $( selectorToScriptBlock ).template(), or $.template( null, templateString )
174
+ // will return the compiled template, without adding a name reference.
175
+ // If templateString includes at least one HTML tag, $.template( templateString ) is equivalent
176
+ // to $.template( null, templateString )
177
+ template: function(name, tmpl) {
178
+ if (tmpl) {
179
+ // Compile template and associate with name
180
+ if (typeof tmpl === "string") {
181
+ // This is an HTML string being passed directly in.
182
+ tmpl = buildTmplFn(tmpl)
183
+ } else if (tmpl instanceof jQuery) {
184
+ tmpl = tmpl[0] || {};
185
+ }
186
+ if (tmpl.nodeType) {
187
+ // If this is a template block, use cached copy, or generate tmpl function and cache.
188
+ tmpl = jQuery.data(tmpl, "tmpl") || jQuery.data(tmpl, "tmpl", buildTmplFn(tmpl.innerHTML));
189
+ // Issue: In IE, if the container element is not a script block, the innerHTML will remove quotes from attribute values whenever the value does not include white space.
190
+ // This means that foo="${x}" will not work if the value of x includes white space: foo="${x}" -> foo=value of x.
191
+ // To correct this, include space in tag: foo="${ x }" -> foo="value of x"
192
+ }
193
+ return typeof name === "string" ? (jQuery.template[name] = tmpl) : tmpl;
194
+ }
195
+ // Return named compiled template
196
+ return name ? (typeof name !== "string" ? jQuery.template(null, name) :
197
+ (jQuery.template[name] ||
198
+ // If not in map, treat as a selector. (If integrated with core, use quickExpr.exec)
199
+ jQuery.template(null, htmlExpr.test(name) ? name : jQuery(name)))) : null;
200
+ },
201
+
202
+ encode: function(text) {
203
+ // Do HTML encoding replacing < > & and ' and " by corresponding entities.
204
+ return ("" + text).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;");
205
+ }
206
+ });
207
+
208
+ jQuery.extend(jQuery.tmpl, {
209
+ tag: {
210
+ "tmpl": {
211
+ _default: { $2: "null" },
212
+ open: "if($notnull_1){_=_.concat($item.nest($1,$2));}"
213
+ // tmpl target parameter can be of type function, so use $1, not $1a (so not auto detection of functions)
214
+ // This means that {{tmpl foo}} treats foo as a template (which IS a function).
215
+ // Explicit parens can be used if foo is a function that returns a template: {{tmpl foo()}}.
216
+ },
217
+ "wrap": {
218
+ _default: { $2: "null" },
219
+ open: "$item.calls(_,$1,$2);_=[];",
220
+ close: "call=$item.calls();_=call._.concat($item.wrap(call,_));"
221
+ },
222
+ "each": {
223
+ _default: { $2: "$index, $value" },
224
+ open: "if($notnull_1){$.each($1a,function($2){with(this){",
225
+ close: "}});}"
226
+ },
227
+ "if": {
228
+ open: "if(($notnull_1) && $1a){",
229
+ close: "}"
230
+ },
231
+ "else": {
232
+ _default: { $1: "true" },
233
+ open: "}else if(($notnull_1) && $1a){"
234
+ },
235
+ "html": {
236
+ // Unecoded expression evaluation.
237
+ open: "if($notnull_1){_.push($1a);}"
238
+ },
239
+ "=": {
240
+ // Encoded expression evaluation. Abbreviated form is ${}.
241
+ _default: { $1: "$data" },
242
+ open: "if($notnull_1){_.push($.encode($1a));}"
243
+ },
244
+ "!": {
245
+ // Comment tag. Skipped by parser
246
+ open: ""
247
+ }
248
+ },
249
+
250
+ // This stub can be overridden, e.g. in jquery.tmplPlus for providing rendered events
251
+ complete: function(items) {
252
+ newTmplItems = {};
253
+ },
254
+
255
+ // Call this from code which overrides domManip, or equivalent
256
+ // Manage cloning/storing template items etc.
257
+ afterManip: function afterManip(elem, fragClone, callback) {
258
+ // Provides cloned fragment ready for fixup prior to and after insertion into DOM
259
+ var content = fragClone.nodeType === 11 ?
260
+ jQuery.makeArray(fragClone.childNodes) :
261
+ fragClone.nodeType === 1 ? [fragClone] : [];
262
+
263
+ // Return fragment to original caller (e.g. append) for DOM insertion
264
+ callback.call(elem, fragClone);
265
+
266
+ // Fragment has been inserted:- Add inserted nodes to tmplItem data structure. Replace inserted element annotations by jQuery.data.
267
+ storeTmplItems(content);
268
+ cloneIndex++;
269
+ }
270
+ });
271
+
272
+ //========================== Private helper functions, used by code above ==========================
273
+
274
+ function build(tmplItem, nested, content) {
275
+ // Convert hierarchical content into flat string array
276
+ // and finally return array of fragments ready for DOM insertion
277
+ var frag, ret = content ? jQuery.map(content, function(item) {
278
+ return (typeof item === "string") ?
279
+ // Insert template item annotations, to be converted to jQuery.data( "tmplItem" ) when elems are inserted into DOM.
280
+ (tmplItem.key ? item.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g, "$1 " + tmplItmAtt + "=\"" + tmplItem.key + "\" $2") : item) :
281
+ // This is a child template item. Build nested template.
282
+ build(item, tmplItem, item._ctnt);
283
+ }) :
284
+ // If content is not defined, insert tmplItem directly. Not a template item. May be a string, or a string array, e.g. from {{html $item.html()}}.
285
+ tmplItem;
286
+ if (nested) {
287
+ return ret;
288
+ }
289
+
290
+ // top-level template
291
+ ret = ret.join("");
292
+
293
+ // Support templates which have initial or final text nodes, or consist only of text
294
+ // Also support HTML entities within the HTML markup.
295
+ ret.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/, function(all, before, middle, after) {
296
+ frag = jQuery(middle).get();
297
+
298
+ storeTmplItems(frag);
299
+ if (before) {
300
+ frag = unencode(before).concat(frag);
301
+ }
302
+ if (after) {
303
+ frag = frag.concat(unencode(after));
304
+ }
305
+ });
306
+ return frag ? frag : unencode(ret);
307
+ }
308
+
309
+ function unencode(text) {
310
+ // Use createElement, since createTextNode will not render HTML entities correctly
311
+ var el = document.createElement("div");
312
+ el.innerHTML = text;
313
+ return jQuery.makeArray(el.childNodes);
314
+ }
315
+
316
+ // Generate a reusable function that will serve to render a template against data
317
+ function buildTmplFn(markup) {
318
+ return new Function("jQuery", "$item",
319
+ "var $=jQuery,call,_=[],$data=$item.data;" +
320
+
321
+ // Introduce the data as local variables using with(){}
322
+ "with($data){_.push('" +
323
+
324
+ // Convert the template into pure JavaScript
325
+ jQuery.trim(markup)
326
+ .replace(/([\\'])/g, "\\$1")
327
+ .replace(/[\r\t\n]/g, " ")
328
+ .replace(/\$\{([^\}]*)\}/g, "{{= $1}}")
329
+ .replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
330
+ function(all, slash, type, fnargs, target, parens, args) {
331
+ var tag = jQuery.tmpl.tag[ type ], def, expr, exprAutoFnDetect;
332
+ if (!tag) {
333
+ throw "Template command not found: " + type;
334
+ }
335
+ def = tag._default || [];
336
+ if (parens && !/\w$/.test(target)) {
337
+ target += parens;
338
+ parens = "";
339
+ }
340
+ if (target) {
341
+ target = unescape(target);
342
+ args = args ? ("," + unescape(args) + ")") : (parens ? ")" : "");
343
+ // Support for target being things like a.toLowerCase();
344
+ // In that case don't call with template item as 'this' pointer. Just evaluate...
345
+ expr = parens ? (target.indexOf(".") > -1 ? target + unescape(parens) : ("(" + target + ").call($item" + args)) : target;
346
+ exprAutoFnDetect = parens ? expr : "(typeof(" + target + ")==='function'?(" + target + ").call($item):(" + target + "))";
347
+ } else {
348
+ exprAutoFnDetect = expr = def.$1 || "null";
349
+ }
350
+ fnargs = unescape(fnargs);
351
+ return "');" +
352
+ tag[ slash ? "close" : "open" ]
353
+ .split("$notnull_1").join(target ? "typeof(" + target + ")!=='undefined' && (" + target + ")!=null" : "true")
354
+ .split("$1a").join(exprAutoFnDetect)
355
+ .split("$1").join(expr)
356
+ .split("$2").join(fnargs || def.$2 || "") +
357
+ "_.push('";
358
+ }) +
359
+ "');}return _;"
360
+ );
361
+ }
362
+
363
+ function updateWrapped(options, wrapped) {
364
+ // Build the wrapped content.
365
+ options._wrap = build(options, true,
366
+ // Suport imperative scenario in which options.wrapped can be set to a selector or an HTML string.
367
+ jQuery.isArray(wrapped) ? wrapped : [htmlExpr.test(wrapped) ? wrapped : jQuery(wrapped).html()]
368
+ ).join("");
369
+ }
370
+
371
+ function unescape(args) {
372
+ return args ? args.replace(/\\'/g, "'").replace(/\\\\/g, "\\") : null;
373
+ }
374
+
375
+ function outerHtml(elem) {
376
+ var div = document.createElement("div");
377
+ div.appendChild(elem.cloneNode(true));
378
+ return div.innerHTML;
379
+ }
380
+
381
+ // Store template items in jQuery.data(), ensuring a unique tmplItem data data structure for each rendered template instance.
382
+ function storeTmplItems(content) {
383
+ var keySuffix = "_" + cloneIndex, elem, elems, newClonedItems = {}, i, l, m;
384
+ for (i = 0,l = content.length; i < l; i++) {
385
+ if ((elem = content[i]).nodeType !== 1) {
386
+ continue;
387
+ }
388
+ elems = elem.getElementsByTagName("*");
389
+ for (m = elems.length - 1; m >= 0; m--) {
390
+ processItemKey(elems[m]);
391
+ }
392
+ processItemKey(elem);
393
+ }
394
+ function processItemKey(el) {
395
+ var pntKey, pntNode = el, pntItem, tmplItem, key;
396
+ // Ensure that each rendered template inserted into the DOM has its own template item,
397
+ if ((key = el.getAttribute(tmplItmAtt))) {
398
+ while (pntNode.parentNode && (pntNode = pntNode.parentNode).nodeType === 1 && !(pntKey = pntNode.getAttribute(tmplItmAtt))) {
399
+ }
400
+ if (pntKey !== key) {
401
+ // The next ancestor with a _tmplitem expando is on a different key than this one.
402
+ // So this is a top-level element within this template item
403
+ // Set pntNode to the key of the parentNode, or to 0 if pntNode.parentNode is null, or pntNode is a fragment.
404
+ pntNode = pntNode.parentNode ? (pntNode.nodeType === 11 ? 0 : (pntNode.getAttribute(tmplItmAtt) || 0)) : 0;
405
+ if (!(tmplItem = newTmplItems[key])) {
406
+ // The item is for wrapped content, and was copied from the temporary parent wrappedItem.
407
+ tmplItem = wrappedItems[key];
408
+ tmplItem = newTmplItem(tmplItem, newTmplItems[pntNode] || wrappedItems[pntNode]);
409
+ tmplItem.key = ++itemKey;
410
+ newTmplItems[itemKey] = tmplItem;
411
+ }
412
+ if (cloneIndex) {
413
+ cloneTmplItem(key);
414
+ }
415
+ }
416
+ el.removeAttribute(tmplItmAtt);
417
+ } else if (cloneIndex && (tmplItem = jQuery.data(el, "tmplItem"))) {
418
+ // This was a rendered element, cloned during append or appendTo etc.
419
+ // TmplItem stored in jQuery data has already been cloned in cloneCopyEvent. We must replace it with a fresh cloned tmplItem.
420
+ cloneTmplItem(tmplItem.key);
421
+ newTmplItems[tmplItem.key] = tmplItem;
422
+ pntNode = jQuery.data(el.parentNode, "tmplItem");
423
+ pntNode = pntNode ? pntNode.key : 0;
424
+ }
425
+ if (tmplItem) {
426
+ pntItem = tmplItem;
427
+ // Find the template item of the parent element.
428
+ // (Using !=, not !==, since pntItem.key is number, and pntNode may be a string)
429
+ while (pntItem && pntItem.key != pntNode) {
430
+ // Add this element as a top-level node for this rendered template item, as well as for any
431
+ // ancestor items between this item and the item of its parent element
432
+ pntItem.nodes.push(el);
433
+ pntItem = pntItem.parent;
434
+ }
435
+ // Delete content built during rendering - reduce API surface area and memory use, and avoid exposing of stale data after rendering...
436
+ delete tmplItem._ctnt;
437
+ delete tmplItem._wrap;
438
+ // Store template item as jQuery data on the element
439
+ jQuery.data(el, "tmplItem", tmplItem);
440
+ }
441
+ function cloneTmplItem(key) {
442
+ key = key + keySuffix;
443
+ tmplItem = newClonedItems[key] =
444
+ (newClonedItems[key] || newTmplItem(tmplItem, newTmplItems[tmplItem.parent.key + keySuffix] || tmplItem.parent));
445
+ }
446
+ }
447
+ }
448
+
449
+ //---- Helper functions for template item ----
450
+
451
+ function tiCalls(content, tmpl, data, options) {
452
+ if (!content) {
453
+ return stack.pop();
454
+ }
455
+ stack.push({ _: content, tmpl: tmpl, item:this, data: data, options: options });
456
+ }
457
+
458
+ function tiNest(tmpl, data, options) {
459
+ // nested template, using {{tmpl}} tag
460
+ return jQuery.tmpl(jQuery.template(tmpl), data, options, this);
461
+ }
462
+
463
+ function tiWrap(call, wrapped) {
464
+ // nested template, using {{wrap}} tag
465
+ var options = call.options || {};
466
+ options.wrapped = wrapped;
467
+ // Apply the template, which may incorporate wrapped content,
468
+ return jQuery.tmpl(jQuery.template(call.tmpl), call.data, options, call.item);
469
+ }
470
+
471
+ function tiHtml(filter, textOnly) {
472
+ var wrapped = this._wrap;
473
+ return jQuery.map(
474
+ jQuery(jQuery.isArray(wrapped) ? wrapped.join("") : wrapped).filter(filter || "*"),
475
+ function(e) {
476
+ return textOnly ?
477
+ e.innerText || e.textContent :
478
+ e.outerHTML || outerHtml(e);
479
+ });
480
+ }
481
+
482
+ function tiUpdate() {
483
+ var coll = this.nodes;
484
+ jQuery.tmpl(null, null, null, this).insertBefore(coll[0]);
485
+ jQuery(coll).remove();
486
+ }
487
+ })(jQuery);