compass-jquery-plugin 0.3.3.0 → 0.3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +4 -4
- data/VERSION.yml +1 -1
- data/lib/handle_js_files.rb +1 -1
- data/lib/jquery/gridify/grid_column.rb +4 -0
- data/lib/jquery/gridify/grid_options.rb +5 -1
- data/lib/jquery/gridify/grid_view.rb +8 -3
- data/templates/dynatree/jquery.dynatree.js +184 -73
- data/templates/dynatree/jquery.dynatree.min.js +78 -76
- data/templates/emulators/emulators/galaxy.tab.7.7.landscape.png +0 -0
- data/templates/emulators/emulators/{palm.pre.2.landscape.scss → galaxy.tab.7.7.landscape.scss} +7 -7
- data/templates/emulators/emulators/galaxy.tab.7.7.portrait.png +0 -0
- data/templates/emulators/emulators/{palm.pre.2.portrait.scss → galaxy.tab.7.7.portrait.scss} +7 -7
- data/templates/emulators/manifest.rb +4 -4
- data/templates/graphics/config/initializers/graphics.rb +1 -1
- data/templates/graphics/highcharts/dark-blue.js +257 -159
- data/templates/graphics/highcharts/dark-blue.min.js +4 -2
- data/templates/graphics/highcharts/dark-green.js +257 -159
- data/templates/graphics/highcharts/dark-green.min.js +4 -2
- data/templates/graphics/highcharts/gray.js +252 -154
- data/templates/graphics/highcharts/gray.min.js +4 -2
- data/templates/graphics/highcharts/grid.js +84 -84
- data/templates/graphics/highcharts/highslide-full.min.js +3 -3
- data/templates/graphics/highcharts/highslide.js +3391 -0
- data/templates/graphics/highcharts/highslide.min.js +132 -0
- data/templates/graphics/jquery.ganttView.min.js +4 -4
- data/templates/graphics/jquery.highcharts.js +15379 -1071
- data/templates/graphics/jquery.highcharts.min.js +384 -167
- data/templates/graphics/jquery.sparkline.min.js +2 -2
- data/templates/graphics/manifest.rb +2 -0
- data/templates/ical/jquery.ical.min.js +46 -47
- data/templates/jqgrid/i18n/jqgrid/locale-bg.min.js +2 -2
- data/templates/jqgrid/i18n/jqgrid/locale-bg1251.min.js +2 -2
- data/templates/jqgrid/i18n/jqgrid/locale-fi.js +20 -19
- data/templates/jqgrid/i18n/jqgrid/locale-fi.min.js +7 -6
- data/templates/jqgrid/i18n/jqgrid/locale-is.js +28 -28
- data/templates/jqgrid/i18n/jqgrid/locale-is.min.js +6 -6
- data/templates/jqgrid/i18n/jqgrid/locale-th.js +134 -0
- data/templates/jqgrid/i18n/jqgrid/locale-th.min.js +6 -0
- data/templates/jqgrid/jquery.jqGrid.js +674 -598
- data/templates/jqgrid/jquery.jqGrid.min.js +444 -441
- data/templates/jqgrid/jquery/jqGrid.scss +0 -3
- data/templates/jqgrid/manifest.rb +2 -0
- data/templates/jqtouch/jquery.jqtouch.js +201 -156
- data/templates/jqtouch/jquery.jqtouch.min.js +1 -1
- data/templates/jqtouch/jquery/touch/apple.scss +2 -2
- data/templates/jqtouch/jquery/touch/default.scss +2 -2
- data/templates/jquery/amplify.store.js +111 -78
- data/templates/jquery/amplify.store.min.js +6 -6
- data/templates/jquery/history.js +3 -3
- data/templates/jquery/i18n/jquery.ui/datepicker-nl.js +1 -1
- data/templates/jquery/i18n/jquery.ui/datepicker-nl.min.js +1 -1
- data/templates/jquery/jquery-ui.js +1286 -1042
- data/templates/jquery/jquery-ui.min.js +320 -316
- data/templates/jquery/jquery.contextMenu.js +2 -2
- data/templates/jquery/jquery.easing.js +152 -152
- data/templates/jquery/jquery.easing.min.js +7 -7
- data/templates/jquery/jquery.farbtastic.min.js +2 -2
- data/templates/jquery/jquery.form.js +30 -30
- data/templates/jquery/jquery.haml.min.js +5 -5
- data/templates/jquery/jquery.hotkeys.min.js +1 -1
- data/templates/jquery/jquery.js +419 -311
- data/templates/jquery/jquery.layout.js +59 -40
- data/templates/jquery/jquery.min.js +176 -176
- data/templates/jquery/jquery.themeswitchertool.js +37 -37
- data/templates/jquery/jquery.tmpl.js +4 -4
- data/templates/jquery/jquery.tmpl.min.js +9 -9
- data/templates/jquery/jquery.tmplPlus.min.js +3 -3
- data/templates/jquery/jquery.tokeninput.js +613 -490
- data/templates/jquery/jquery.tokeninput.min.js +17 -14
- data/templates/jquery/jquery/ui/_theme.scss +39 -63
- data/templates/jquery/json.js +31 -15
- data/templates/jstree/jquery.jstree.js +415 -410
- data/templates/jstree/jquery.jstree.min.js +134 -133
- data/templates/markitup/jquery.markitup.js +567 -560
- data/templates/markitup/jquery.markitup.min.js +1 -1
- data/templates/markitup/jquery/markitup/sets/default.scss +7 -3
- data/templates/markitup/jquery/markitup/sets/default/list-bullet.png +0 -0
- data/templates/markitup/jquery/markitup/sets/default/list-numeric.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup.scss +3 -10
- data/templates/markitup/jquery/markitup/skins/markitup/bg-container.png +0 -0
- data/templates/markitup/jquery/markitup/skins/markitup/menu.png +0 -0
- data/templates/markitup/jquery/markitup/skins/simple.scss +2 -3
- data/templates/markitup/jquery/markitup/skins/simple/menu.png +0 -0
- data/templates/markitup/manifest.rb +2 -0
- data/templates/markitup/markitup/jquery.markitup.set.default.js +21 -21
- data/templates/markitup/markitup/jquery.markitup.set.default.min.js +3 -2
- data/templates/mobile/jquery.mobile.js +5230 -2846
- data/templates/mobile/jquery.mobile.min.js +192 -46
- data/templates/mobile/jquery/mobile/_base.scss +141 -18
- data/templates/mobile/jquery/mobile/default.scss +263 -66
- data/templates/mobile/jquery/mobile/default/icons-18-black.png +0 -0
- data/templates/mobile/jquery/mobile/default/icons-18-white.png +0 -0
- data/templates/mobile/jquery/mobile/default/icons-36-black.png +0 -0
- data/templates/mobile/jquery/mobile/default/icons-36-white.png +0 -0
- data/templates/mobile/jquery/mobile/valencia.scss +242 -53
- data/templates/mobile/jquery/mobile/valencia/icons-18-black.png +0 -0
- data/templates/mobile/jquery/mobile/valencia/icons-18-white.png +0 -0
- data/templates/mobile/jquery/mobile/valencia/icons-36-black.png +0 -0
- data/templates/mobile/jquery/mobile/valencia/icons-36-white.png +0 -0
- data/templates/tiny_mce/manifest.rb +2 -0
- data/templates/tiny_mce/tiny_mce/langs/de.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/advhr/rule.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/advimage/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/advimage/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/advimage/image.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/advimage/js/image.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/advlink/link.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/advlist/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/advlist/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/autolink/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/autolink/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/autoresize/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/autoresize/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/autosave/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/autosave/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/contextmenu/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/contextmenu/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/emotions/emotions.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/emotions/img/smiley-foot-in-mouth.gif +0 -0
- data/templates/tiny_mce/tiny_mce/plugins/emotions/img/smiley-laughing.gif +0 -0
- data/templates/tiny_mce/tiny_mce/plugins/emotions/img/smiley-sealed.gif +0 -0
- data/templates/tiny_mce/tiny_mce/plugins/emotions/img/smiley-smile.gif +0 -0
- data/templates/tiny_mce/tiny_mce/plugins/emotions/img/smiley-surprised.gif +0 -0
- data/templates/tiny_mce/tiny_mce/plugins/emotions/img/smiley-wink.gif +0 -0
- data/templates/tiny_mce/tiny_mce/plugins/example/dialog.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/example_dependency/editor_plugin.js +1 -0
- data/templates/tiny_mce/tiny_mce/plugins/example_dependency/editor_plugin_src.js +1 -0
- data/templates/tiny_mce/tiny_mce/plugins/fullpage/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/fullpage/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/fullpage/fullpage.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/inlinepopups/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/inlinepopups/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif +0 -0
- data/templates/tiny_mce/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/button.gif +0 -0
- data/templates/tiny_mce/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif +0 -0
- data/templates/tiny_mce/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif +0 -0
- data/templates/tiny_mce/tiny_mce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif +0 -0
- data/templates/tiny_mce/tiny_mce/plugins/inlinepopups/skins/clearlooks2/window.css +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/inlinepopups/template.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/lists/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/lists/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/media/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/media/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/media/js/media.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/media/langs/en_dlg.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/media/media.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/noneditable/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/noneditable/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/paste/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/paste/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/paste/pastetext.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/paste/pasteword.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/preview/example.html +16 -17
- data/templates/tiny_mce/tiny_mce/plugins/preview/preview.html +9 -10
- data/templates/tiny_mce/tiny_mce/plugins/searchreplace/searchreplace.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/spellchecker/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/spellchecker/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/style/js/props.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/style/props.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/tabfocus/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/tabfocus/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/table/cell.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/table/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/table/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/table/js/cell.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/table/js/row.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/table/langs/de_dlg.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/table/langs/en_dlg.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/table/merge_cells.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/table/row.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/table/table.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/template/blank.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/template/template.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/wordcount/editor_plugin.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/wordcount/editor_plugin_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/xhtmlxtras/abbr.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/xhtmlxtras/acronym.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/xhtmlxtras/attributes.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/xhtmlxtras/cite.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/xhtmlxtras/del.htm +1 -1
- data/templates/tiny_mce/tiny_mce/plugins/xhtmlxtras/ins.htm +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/about.htm +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/anchor.htm +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/color_picker.htm +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/editor_template.js +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/editor_template_src.js +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/image.htm +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/img/colorpicker.jpg +0 -0
- data/templates/tiny_mce/tiny_mce/themes/advanced/img/flash.gif +0 -0
- data/templates/tiny_mce/tiny_mce/themes/advanced/img/icons.gif +0 -0
- data/templates/tiny_mce/tiny_mce/themes/advanced/img/quicktime.gif +0 -0
- data/templates/tiny_mce/tiny_mce/themes/advanced/img/shockwave.gif +0 -0
- data/templates/tiny_mce/tiny_mce/themes/advanced/js/image.js +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/langs/de.js +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/link.htm +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/default/content.css +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/default/dialog.css +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/default/img/buttons.png +0 -0
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/default/img/items.gif +0 -0
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/default/img/tabs.gif +0 -0
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/default/ui.css +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/highcontrast/dialog.css +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/highcontrast/ui.css +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/o2k7/content.css +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/o2k7/dialog.css +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/o2k7/img/button_bg.png +0 -0
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_black.png +0 -0
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/o2k7/img/button_bg_silver.png +0 -0
- data/templates/tiny_mce/tiny_mce/themes/advanced/skins/o2k7/ui.css +1 -1
- data/templates/tiny_mce/tiny_mce/themes/advanced/source_editor.htm +1 -1
- data/templates/tiny_mce/tiny_mce/themes/simple/img/icons.gif +0 -0
- data/templates/tiny_mce/tiny_mce/themes/simple/skins/default/ui.css +1 -1
- data/templates/tiny_mce/tiny_mce/themes/simple/skins/o2k7/ui.css +1 -1
- data/templates/tiny_mce/tiny_mce/tiny_mce.js +1 -1
- data/templates/tools/flowplayer.min.js +1 -1
- data/templates/tools/jquery.tools.js +17 -17
- data/templates/tools/jquery.tools.min.js +22 -22
- metadata +17 -9
- data/templates/emulators/emulators/palm.pre.2.landscape.png +0 -0
- data/templates/emulators/emulators/palm.pre.2.portrait.png +0 -0
|
@@ -32,7 +32,7 @@ $.fn.themeswitcher = function(settings) {
|
|
|
32
32
|
}
|
|
33
33
|
return false;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
);
|
|
36
36
|
|
|
37
37
|
//menu events (mouseout didn't work...)
|
|
38
38
|
switcherpane.hover(
|
|
@@ -43,7 +43,7 @@ $.fn.themeswitcher = function(settings) {
|
|
|
43
43
|
$(this).spHide();
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
);
|
|
47
47
|
|
|
48
48
|
//show/hide panel functions
|
|
49
49
|
$.fn.spShow = function() {
|
|
@@ -130,13 +130,13 @@ $.fn.themeswitcher = function(settings) {
|
|
|
130
130
|
$(this).css(button_default);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
|
|
133
|
+
)
|
|
134
134
|
.find('.jquery-ui-themeswitcher-icon').css({
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
135
|
+
'float': 'right',
|
|
136
|
+
width: '16px',
|
|
137
|
+
height: '16px',
|
|
138
|
+
background: 'image_url("jquery/ui/themeSwitcher/icon_color_arrow.gif") 50% 50% no-repeat'
|
|
139
|
+
});
|
|
140
140
|
//pane css
|
|
141
141
|
switcherpane.css({
|
|
142
142
|
position: 'absolute',
|
|
@@ -156,12 +156,12 @@ $.fn.themeswitcher = function(settings) {
|
|
|
156
156
|
width: options.width - 6//minus must match left and right padding
|
|
157
157
|
})
|
|
158
158
|
.find('ul').css({
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
listStyle: 'none',
|
|
160
|
+
margin: '0',
|
|
161
|
+
padding: '0',
|
|
162
|
+
overflow: 'auto',
|
|
163
|
+
height: options.height
|
|
164
|
+
}).end()
|
|
165
165
|
.find('li').hover(
|
|
166
166
|
function() {
|
|
167
167
|
$(this).css({
|
|
@@ -177,32 +177,32 @@ $.fn.themeswitcher = function(settings) {
|
|
|
177
177
|
cursor: 'auto'
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
180
|
+
).css({
|
|
181
|
+
width: options.width - 30,
|
|
182
|
+
height: '',
|
|
183
|
+
padding: '2px',
|
|
184
|
+
margin: '1px',
|
|
185
|
+
border: '1px solid #111',
|
|
186
|
+
'-moz-border-radius': '4px',
|
|
187
|
+
clear: 'left',
|
|
188
|
+
'float': 'left'
|
|
189
|
+
}).end()
|
|
190
190
|
.find('a').css({
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
191
|
+
color: '#aaa',
|
|
192
|
+
textDecoration: 'none',
|
|
193
|
+
'float': 'left',
|
|
194
|
+
width: '100%',
|
|
195
|
+
outline: '0'
|
|
196
|
+
}).end()
|
|
197
197
|
.find('img').css({
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
198
|
+
'float': 'left',
|
|
199
|
+
border: '1px solid #333',
|
|
200
|
+
margin: '0 2px'
|
|
201
|
+
}).end()
|
|
202
202
|
.find('.themeName').css({
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
203
|
+
'float': 'left',
|
|
204
|
+
margin: '3px 0'
|
|
205
|
+
}).end();
|
|
206
206
|
|
|
207
207
|
$(this).append(button);
|
|
208
208
|
$('body').append(switcherpane);
|
|
@@ -317,7 +317,7 @@
|
|
|
317
317
|
// Generate a reusable function that will serve to render a template against data
|
|
318
318
|
function buildTmplFn(markup) {
|
|
319
319
|
return new Function("jQuery", "$item",
|
|
320
|
-
|
|
320
|
+
// Use the variable __ to hold a string array while building the compiled template. (See https://github.com/jquery/jquery-tmpl/issues#issue/10).
|
|
321
321
|
"var $=jQuery,call,__=[],$data=$item.data;" +
|
|
322
322
|
|
|
323
323
|
// Introduce the data as local variables using with(){}
|
|
@@ -359,15 +359,15 @@
|
|
|
359
359
|
"__.push('";
|
|
360
360
|
}) +
|
|
361
361
|
"');}return __;"
|
|
362
|
-
|
|
362
|
+
);
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
function updateWrapped(options, wrapped) {
|
|
366
366
|
// Build the wrapped content.
|
|
367
367
|
options._wrap = build(options, true,
|
|
368
|
-
|
|
368
|
+
// Suport imperative scenario in which options.wrapped can be set to a selector or an HTML string.
|
|
369
369
|
jQuery.isArray(wrapped) ? wrapped : [htmlExpr.test(wrapped) ? wrapped : jQuery(wrapped).html()]
|
|
370
|
-
|
|
370
|
+
).join("");
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
function unescape(args) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
(function(d){function
|
|
1
|
+
(function(d){function n(a,b,e,c){c={data:c||c===0||c===!1?c:b?b.data:{},_wrap:b?b._wrap:null,tmpl:null,parent:b||null,nodes:[],calls:B,nest:C,wrap:D,html:E,update:F};a&&d.extend(c,a,{nodes:[],parent:b});if(e)c.tmpl=e,c._ctnt=c._ctnt||c.tmpl(d,c),c.key=++o,(t.length?p:j)[o]=c;return c}function q(a,b,e){var c,e=e?d.map(e,function(b){return typeof b==="string"?a.key?b.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+m+'="'+a.key+'" $2'):b:q(b,a,b._ctnt)}):a;if(b)return e;e=e.join("");e.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,
|
|
2
2
|
function(b,a,e,i){c=d(e).get();v(c);a&&(c=u(a).concat(c));i&&(c=c.concat(u(i)))});return c?c:u(e)}function u(a){var b=document.createElement("div");b.innerHTML=a;return d.makeArray(b.childNodes)}function w(a){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;with($data){__.push('"+d.trim(a).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
|
|
3
|
-
function(a,e,c,g,h,f,i){a=d.tmpl.tag[c];if(!a)throw"Unknown template tag: "+c;c=a._default||[];f&&!/\w$/.test(h)&&(h+=f,f="");h?(h=
|
|
4
|
-
"');}return __;")}function x(a,b){a._wrap=
|
|
5
|
-
j[
|
|
6
|
-
b,e,this)}function D(a,b){var e=a.options||{};e.wrapped=b;return d.tmpl(d.template(a.tmpl),a.data,e,a.item)}function E(a,b){var e=this._wrap;return d.map(d(d.isArray(e)?e.join(""):e).filter(a||"*"),function(a){if(b)a=a.innerText||a.textContent;else{var d;if(!(d=a.outerHTML))d=document.createElement("div"),d.appendChild(a.cloneNode(!0)),d=d.innerHTML;a=d}return a})}function F(){var a=this.nodes;d.tmpl(null,null,null,this).insertBefore(a[0]);d(a).remove()}var z=d.fn.domManip,
|
|
7
|
-
j={},
|
|
8
|
-
return c}});d.fn.extend({tmpl:function(a,b,e){return d.tmpl(this[0],a,b,e)},tmplItem:function(){return d.tmplItem(this[0])},template:function(a){return d.template(a,this[0])},domManip:function(a,b,e){if(a[0]&&d.isArray(a[0])){for(var
|
|
9
|
-
if(g)c=A,a=d.template[a]||d.template(null,a),
|
|
10
|
-
"string"?b=w(b):b instanceof d&&(b=b[0]||{}),b.nodeType&&(b=d.data(b,"tmpl")||d.data(b,"tmpl",w(b.innerHTML))),typeof a==="string"?d.template[a]=b:b
|
|
3
|
+
function(a,e,c,g,h,f,i){a=d.tmpl.tag[c];if(!a)throw"Unknown template tag: "+c;c=a._default||[];f&&!/\w$/.test(h)&&(h+=f,f="");h?(h=r(h),i=i?","+r(i)+")":f?")":"",i=f?h.indexOf(".")>-1?h+r(f):"("+h+").call($item"+i:h,f=f?i:"(typeof("+h+")==='function'?("+h+").call($item):("+h+"))"):f=i=c.$1||"null";g=r(g);return"');"+a[e?"close":"open"].split("$notnull_1").join(h?"typeof("+h+")!=='undefined' && ("+h+")!=null":"true").split("$1a").join(f).split("$1").join(i).split("$2").join(g||c.$2||"")+"__.push('"})+
|
|
4
|
+
"');}return __;")}function x(a,b){a._wrap=q(a,!0,d.isArray(b)?b:[y.test(b)?b:d(b).html()]).join("")}function r(a){return a?a.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function v(a){function b(a){function b(a){var G;a+=e;G=h[a]=h[a]||n(f,j[f.parent.key+e]||f.parent),f=G}var c,g=a,f,i;if(i=a.getAttribute(m)){for(;g.parentNode&&(g=g.parentNode).nodeType===1&&!(c=g.getAttribute(m)););if(c!==i){g=g.parentNode?g.nodeType===11?0:g.getAttribute(m)||0:0;if(!(f=j[i]))f=p[i],f=n(f,j[g]||p[g]),f.key=++o,
|
|
5
|
+
j[o]=f;k&&b(i)}a.removeAttribute(m)}else if(k&&(f=d.data(a,"tmplItem")))b(f.key),j[f.key]=f,g=(g=d.data(a.parentNode,"tmplItem"))?g.key:0;if(f){for(c=f;c&&c.key!=g;)c.nodes.push(a),c=c.parent;delete f._ctnt;delete f._wrap;d.data(a,"tmplItem",f)}}var e="_"+k,c,g,h={},f,i,l;f=0;for(i=a.length;f<i;f++)if((c=a[f]).nodeType===1){g=c.getElementsByTagName("*");for(l=g.length-1;l>=0;l--)b(g[l]);b(c)}}function B(a,b,d,c){if(!a)return t.pop();t.push({_:a,tmpl:b,item:this,data:d,options:c})}function C(a,b,e){return d.tmpl(d.template(a),
|
|
6
|
+
b,e,this)}function D(a,b){var e=a.options||{};e.wrapped=b;return d.tmpl(d.template(a.tmpl),a.data,e,a.item)}function E(a,b){var e=this._wrap;return d.map(d(d.isArray(e)?e.join(""):e).filter(a||"*"),function(a){if(b)a=a.innerText||a.textContent;else{var d;if(!(d=a.outerHTML))d=document.createElement("div"),d.appendChild(a.cloneNode(!0)),d=d.innerHTML;a=d}return a})}function F(){var a=this.nodes;d.tmpl(null,null,null,this).insertBefore(a[0]);d(a).remove()}var z=d.fn.domManip,m="_tmplitem",y=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
|
|
7
|
+
j={},p={},s,A={key:0,data:{}},o=0,k=0,t=[];d.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){d.fn[a]=function(e){var c=[],e=d(e),g,h,f;g=this.length===1&&this[0].parentNode;s=j||{};if(g&&g.nodeType===11&&g.childNodes.length===1&&e.length===1)e[b](this[0]),c=this;else{h=0;for(f=e.length;h<f;h++)k=h,g=(h>0?this.clone(!0):this).get(),d(e[h])[b](g),c=c.concat(g);k=0;c=this.pushStack(c,a,e.selector)}e=s;s=null;d.tmpl.complete(e);
|
|
8
|
+
return c}});d.fn.extend({tmpl:function(a,b,e){return d.tmpl(this[0],a,b,e)},tmplItem:function(){return d.tmplItem(this[0])},template:function(a){return d.template(a,this[0])},domManip:function(a,b,e,c){if(a[0]&&d.isArray(a[0])){for(var g=d.makeArray(arguments),h=a[0],f=h.length,i=0,l;i<f&&!(l=d.data(h[i++],"tmplItem")););l&&k&&(g[2]=function(a){d.tmpl.afterManip(this,a,e)});z.apply(this,g)}else z.apply(this,arguments);k=0;s||d.tmpl.complete(j);return this}});d.extend({tmpl:function(a,b,e,c){var g=
|
|
9
|
+
!c;if(g)c=A,a=d.template[a]||d.template(null,a),p={};else if(!a)return a=c.tmpl,j[c.key]=c,c.nodes=[],c.wrapped&&x(c,c.wrapped),d(q(c,null,c.tmpl(d,c)));if(!a)return[];typeof b==="function"&&(b=b.call(c||{}));e&&e.wrapped&&x(e,e.wrapped);b=d.isArray(b)?d.map(b,function(b){return b?n(e,c,a,b):null}):[n(e,c,a,b)];return g?d(q(c,null,b)):b},tmplItem:function(a){var b;for(a instanceof d&&(a=a[0]);a&&a.nodeType===1&&!(b=d.data(a,"tmplItem"))&&(a=a.parentNode););return b||A},template:function(a,b){return b?
|
|
10
|
+
(typeof b==="string"?b=w(b):b instanceof d&&(b=b[0]||{}),b.nodeType&&(b=d.data(b,"tmpl")||d.data(b,"tmpl",w(b.innerHTML))),typeof a==="string"?d.template[a]=b:b):a?typeof a!=="string"?d.template(null,a):d.template[a]||d.template(null,y.test(a)?a:d(a)):null},encode:function(a){return(""+a).split("<").join("<").split(">").join(">").split('"').join(""").split("'").join("'")}});d.extend(d.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"},wrap:{_default:{$2:"null"},
|
|
11
11
|
open:"$item.calls(__,$1,$2);__=[];",close:"call=$item.calls();__=call._.concat($item.wrap(call,__));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},html:{open:"if($notnull_1){__.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){__.push($.encode($1a));}"},"!":{open:""}},complete:function(){j={}},afterManip:function(a,
|
|
12
12
|
b,e){var c=b.nodeType===11?d.makeArray(b.childNodes):b.nodeType===1?[b]:[];e.call(a,b);v(c);k++}})})(jQuery);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(b){var
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
(function(b){var j=b.tmpl.complete,h=b.fn.domManip;b.tmpl.complete=function(c){var a;j(c);for(a in c)a=c[a],a.addedTmplItems&&b.inArray(a,a.addedTmplItems)===-1&&a.addedTmplItems.push(a);for(a in c)a=c[a],a.rendered&&a.rendered(a)};b.extend({tmplCmd:function(c,a,d){function e(a,b){for(var c=[],d,f,g=b.length,e,h=0,j=a.length;h<j;){e=a[h++];for(f=0;f<g;)d=b[f++],d.data===e&&c.push(d)}return c}var f=[],g,a=b.isArray(a)?a:[a];switch(c){case "find":return e(a,d);case "replace":a.reverse()}b.each(d?e(a,
|
|
2
|
+
d):a,function(a,e){coll=e.nodes;switch(c){case "update":e.update();break;case "remove":b(coll).remove();d&&d.splice(b.inArray(e,d),1);break;case "replace":g=g?b(coll).insertBefore(g)[0]:b(coll).appendTo(coll[0].parentNode)[0],f.unshift(e)}});return f}});b.fn.extend({domManip:function(c,a,d,e){var f=c[1],g=c[0],i;return c.length>=2&&typeof f==="object"&&!f.nodeType&&!(f instanceof b)?(i=b.makeArray(arguments),i[0]=[b.tmpl(b.template(g),f,c[2],c[3])],i[2]=function(a){b.tmpl.afterManip(this,a,d)},h.apply(this,
|
|
3
|
+
i)):h.apply(this,arguments)}})})(jQuery);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* jQuery Plugin: Tokenizing Autocomplete Text Entry
|
|
3
|
-
* Version 1.
|
|
3
|
+
* Version 1.6.0
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2009 James Smith (http://loopj.com)
|
|
6
6
|
* Licensed jointly under the GPL and MIT licenses,
|
|
@@ -10,29 +10,48 @@
|
|
|
10
10
|
|
|
11
11
|
(function ($) {
|
|
12
12
|
// Default settings
|
|
13
|
-
|
|
13
|
+
var DEFAULT_SETTINGS = {
|
|
14
|
+
// Search settings
|
|
15
|
+
method: "GET",
|
|
16
|
+
queryParam: "q",
|
|
17
|
+
searchDelay: 300,
|
|
18
|
+
minChars: 1,
|
|
19
|
+
propertyToSearch: "name",
|
|
20
|
+
jsonContainer: null,
|
|
21
|
+
contentType: "json",
|
|
22
|
+
|
|
23
|
+
// Prepopulation settings
|
|
24
|
+
prePopulate: null,
|
|
25
|
+
processPrePopulate: false,
|
|
26
|
+
|
|
27
|
+
// Display settings
|
|
14
28
|
hintText: "Type in a search term",
|
|
15
29
|
noResultsText: "No results",
|
|
16
30
|
searchingText: "Searching...",
|
|
17
31
|
deleteText: "×",
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
animateDropdown: true,
|
|
33
|
+
theme: null,
|
|
34
|
+
resultsFormatter: function(item){ return "<li>" + item[this.propertyToSearch]+ "</li>" },
|
|
35
|
+
tokenFormatter: function(item) { return "<li><p>" + item[this.propertyToSearch] + "</p></li>" },
|
|
36
|
+
|
|
37
|
+
// Tokenization settings
|
|
20
38
|
tokenLimit: null,
|
|
21
|
-
jsonContainer: null,
|
|
22
|
-
method: "GET",
|
|
23
|
-
contentType: "json",
|
|
24
|
-
queryParam: "q",
|
|
25
39
|
tokenDelimiter: ",",
|
|
26
40
|
preventDuplicates: false,
|
|
27
|
-
|
|
28
|
-
|
|
41
|
+
tokenValue: "id",
|
|
42
|
+
|
|
43
|
+
// Callbacks
|
|
29
44
|
onResult: null,
|
|
30
45
|
onAdd: null,
|
|
31
|
-
onDelete: null
|
|
32
|
-
|
|
46
|
+
onDelete: null,
|
|
47
|
+
onReady: null,
|
|
48
|
+
|
|
49
|
+
// Other settings
|
|
50
|
+
idPrefix: "token-input-"
|
|
51
|
+
};
|
|
33
52
|
|
|
34
53
|
// Default classes to use when theming
|
|
35
|
-
|
|
54
|
+
var DEFAULT_CLASSES = {
|
|
36
55
|
tokenList: "token-input-list",
|
|
37
56
|
token: "token-input-token",
|
|
38
57
|
tokenDelete: "token-input-delete-token",
|
|
@@ -43,17 +62,17 @@
|
|
|
43
62
|
dropdownItem2: "token-input-dropdown-item2",
|
|
44
63
|
selectedDropdownItem: "token-input-selected-dropdown-item",
|
|
45
64
|
inputToken: "token-input-input-token"
|
|
46
|
-
|
|
65
|
+
};
|
|
47
66
|
|
|
48
67
|
// Input box position "enum"
|
|
49
|
-
|
|
68
|
+
var POSITION = {
|
|
50
69
|
BEFORE: 0,
|
|
51
70
|
AFTER: 1,
|
|
52
71
|
END: 2
|
|
53
|
-
|
|
72
|
+
};
|
|
54
73
|
|
|
55
74
|
// Keys "enum"
|
|
56
|
-
|
|
75
|
+
var KEY = {
|
|
57
76
|
BACKSPACE: 8,
|
|
58
77
|
TAB: 9,
|
|
59
78
|
ENTER: 13,
|
|
@@ -69,55 +88,83 @@
|
|
|
69
88
|
DOWN: 40,
|
|
70
89
|
NUMPAD_ENTER: 108,
|
|
71
90
|
COMMA: 188
|
|
72
|
-
|
|
91
|
+
};
|
|
73
92
|
|
|
93
|
+
// Additional public (exposed) methods
|
|
94
|
+
var methods = {
|
|
95
|
+
init: function(url_or_data_or_function, options) {
|
|
96
|
+
var settings = $.extend({}, DEFAULT_SETTINGS, options || {});
|
|
74
97
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
98
|
+
return this.each(function () {
|
|
99
|
+
$(this).data("tokenInputObject", new $.TokenList(this, url_or_data_or_function, settings));
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
clear: function() {
|
|
103
|
+
this.data("tokenInputObject").clear();
|
|
104
|
+
return this;
|
|
105
|
+
},
|
|
106
|
+
add: function(item) {
|
|
107
|
+
this.data("tokenInputObject").add(item);
|
|
108
|
+
return this;
|
|
109
|
+
},
|
|
110
|
+
remove: function(item) {
|
|
111
|
+
this.data("tokenInputObject").remove(item);
|
|
112
|
+
return this;
|
|
113
|
+
},
|
|
114
|
+
get: function() {
|
|
115
|
+
return this.data("tokenInputObject").getTokens();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
83
118
|
|
|
119
|
+
// Expose the .tokenInput function to jQuery as a plugin
|
|
120
|
+
$.fn.tokenInput = function (method) {
|
|
121
|
+
// Method calling and initialization logic
|
|
122
|
+
if(methods[method]) {
|
|
123
|
+
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
|
124
|
+
} else {
|
|
125
|
+
return methods.init.apply(this, arguments);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
84
128
|
|
|
85
129
|
// TokenList class for each input
|
|
86
|
-
|
|
130
|
+
$.TokenList = function (input, url_or_data, settings) {
|
|
87
131
|
//
|
|
88
132
|
// Initialization
|
|
89
133
|
//
|
|
90
134
|
|
|
91
135
|
// Configure the data source
|
|
92
|
-
if
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
136
|
+
if($.type(url_or_data) === "string" || $.type(url_or_data) === "function") {
|
|
137
|
+
// Set the url to query against
|
|
138
|
+
settings.url = url_or_data;
|
|
139
|
+
|
|
140
|
+
// If the URL is a function, evaluate it here to do our initalization work
|
|
141
|
+
var url = computeURL();
|
|
142
|
+
|
|
143
|
+
// Make a smart guess about cross-domain if it wasn't explicitly specified
|
|
144
|
+
if(settings.crossDomain === undefined) {
|
|
145
|
+
if(url.indexOf("://") === -1) {
|
|
146
|
+
settings.crossDomain = false;
|
|
147
|
+
} else {
|
|
148
|
+
settings.crossDomain = (location.href.split(/\/+/g)[1] !== url.split(/\/+/g)[1]);
|
|
149
|
+
}
|
|
102
150
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
settings.local_data = url_or_data;
|
|
151
|
+
} else if(typeof(url_or_data) === "object") {
|
|
152
|
+
// Set the local data to search through
|
|
153
|
+
settings.local_data = url_or_data;
|
|
107
154
|
}
|
|
108
155
|
|
|
109
156
|
// Build class names
|
|
110
|
-
if
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
} else if
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
157
|
+
if(settings.classes) {
|
|
158
|
+
// Use custom class names
|
|
159
|
+
settings.classes = $.extend({}, DEFAULT_CLASSES, settings.classes);
|
|
160
|
+
} else if(settings.theme) {
|
|
161
|
+
// Use theme-suffixed default class names
|
|
162
|
+
settings.classes = {};
|
|
163
|
+
$.each(DEFAULT_CLASSES, function(key, value) {
|
|
164
|
+
settings.classes[key] = value + "-" + settings.theme;
|
|
165
|
+
});
|
|
119
166
|
} else {
|
|
120
|
-
|
|
167
|
+
settings.classes = DEFAULT_CLASSES;
|
|
121
168
|
}
|
|
122
169
|
|
|
123
170
|
|
|
@@ -136,117 +183,117 @@
|
|
|
136
183
|
|
|
137
184
|
// Create a new text input an attach keyup events
|
|
138
185
|
var input_box = $("<input type=\"text\" autocomplete=\"off\">")
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
})
|
|
147
|
-
.blur(function () {
|
|
148
|
-
hide_dropdown();
|
|
149
|
-
})
|
|
150
|
-
.bind("keyup keydown blur update", resize_input)
|
|
151
|
-
.keydown(function (event) {
|
|
152
|
-
var previous_token;
|
|
153
|
-
var next_token;
|
|
154
|
-
|
|
155
|
-
switch (event.keyCode) {
|
|
156
|
-
case KEY.LEFT:
|
|
157
|
-
case KEY.RIGHT:
|
|
158
|
-
case KEY.UP:
|
|
159
|
-
case KEY.DOWN:
|
|
160
|
-
if (!$(this).val()) {
|
|
161
|
-
previous_token = input_token.prev();
|
|
162
|
-
next_token = input_token.next();
|
|
163
|
-
|
|
164
|
-
if ((previous_token.length && previous_token.get(0) === selected_token) || (next_token.length && next_token.get(0) === selected_token)) {
|
|
165
|
-
// Check if there is a previous/next token and it is selected
|
|
166
|
-
if (event.keyCode === KEY.LEFT || event.keyCode === KEY.UP) {
|
|
167
|
-
deselect_token($(selected_token), POSITION.BEFORE);
|
|
168
|
-
} else {
|
|
169
|
-
deselect_token($(selected_token), POSITION.AFTER);
|
|
170
|
-
}
|
|
171
|
-
} else if ((event.keyCode === KEY.LEFT || event.keyCode === KEY.UP) && previous_token.length) {
|
|
172
|
-
// We are moving left, select the previous token if it exists
|
|
173
|
-
select_token($(previous_token.get(0)));
|
|
174
|
-
} else if ((event.keyCode === KEY.RIGHT || event.keyCode === KEY.DOWN) && next_token.length) {
|
|
175
|
-
// We are moving right, select the next token if it exists
|
|
176
|
-
select_token($(next_token.get(0)));
|
|
177
|
-
}
|
|
178
|
-
} else {
|
|
179
|
-
var dropdown_item = null;
|
|
180
|
-
|
|
181
|
-
if (event.keyCode === KEY.DOWN || event.keyCode === KEY.RIGHT) {
|
|
182
|
-
dropdown_item = $(selected_dropdown_item).next();
|
|
183
|
-
} else {
|
|
184
|
-
dropdown_item = $(selected_dropdown_item).prev();
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (dropdown_item.length) {
|
|
188
|
-
select_dropdown_item(dropdown_item);
|
|
189
|
-
}
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
break;
|
|
193
|
-
|
|
194
|
-
case KEY.BACKSPACE:
|
|
195
|
-
previous_token = input_token.prev();
|
|
196
|
-
|
|
197
|
-
if (!$(this).val().length) {
|
|
198
|
-
if (selected_token) {
|
|
199
|
-
delete_token($(selected_token));
|
|
200
|
-
} else if (previous_token.length) {
|
|
201
|
-
select_token($(previous_token.get(0)));
|
|
186
|
+
.css({
|
|
187
|
+
outline: "none"
|
|
188
|
+
})
|
|
189
|
+
.attr("id", settings.idPrefix + input.id)
|
|
190
|
+
.focus(function () {
|
|
191
|
+
if (settings.tokenLimit === null || settings.tokenLimit !== token_count) {
|
|
192
|
+
show_dropdown_hint();
|
|
202
193
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
} else if ($(this).val().length === 1) {
|
|
194
|
+
})
|
|
195
|
+
.blur(function () {
|
|
206
196
|
hide_dropdown();
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
197
|
+
$(this).val("");
|
|
198
|
+
})
|
|
199
|
+
.bind("keyup keydown blur update", resize_input)
|
|
200
|
+
.keydown(function (event) {
|
|
201
|
+
var previous_token;
|
|
202
|
+
var next_token;
|
|
203
|
+
|
|
204
|
+
switch(event.keyCode) {
|
|
205
|
+
case KEY.LEFT:
|
|
206
|
+
case KEY.RIGHT:
|
|
207
|
+
case KEY.UP:
|
|
208
|
+
case KEY.DOWN:
|
|
209
|
+
if(!$(this).val()) {
|
|
210
|
+
previous_token = input_token.prev();
|
|
211
|
+
next_token = input_token.next();
|
|
212
|
+
|
|
213
|
+
if((previous_token.length && previous_token.get(0) === selected_token) || (next_token.length && next_token.get(0) === selected_token)) {
|
|
214
|
+
// Check if there is a previous/next token and it is selected
|
|
215
|
+
if(event.keyCode === KEY.LEFT || event.keyCode === KEY.UP) {
|
|
216
|
+
deselect_token($(selected_token), POSITION.BEFORE);
|
|
217
|
+
} else {
|
|
218
|
+
deselect_token($(selected_token), POSITION.AFTER);
|
|
219
|
+
}
|
|
220
|
+
} else if((event.keyCode === KEY.LEFT || event.keyCode === KEY.UP) && previous_token.length) {
|
|
221
|
+
// We are moving left, select the previous token if it exists
|
|
222
|
+
select_token($(previous_token.get(0)));
|
|
223
|
+
} else if((event.keyCode === KEY.RIGHT || event.keyCode === KEY.DOWN) && next_token.length) {
|
|
224
|
+
// We are moving right, select the next token if it exists
|
|
225
|
+
select_token($(next_token.get(0)));
|
|
226
|
+
}
|
|
227
|
+
} else {
|
|
228
|
+
var dropdown_item = null;
|
|
229
|
+
|
|
230
|
+
if(event.keyCode === KEY.DOWN || event.keyCode === KEY.RIGHT) {
|
|
231
|
+
dropdown_item = $(selected_dropdown_item).next();
|
|
232
|
+
} else {
|
|
233
|
+
dropdown_item = $(selected_dropdown_item).prev();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if(dropdown_item.length) {
|
|
237
|
+
select_dropdown_item(dropdown_item);
|
|
238
|
+
}
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
break;
|
|
242
|
+
|
|
243
|
+
case KEY.BACKSPACE:
|
|
244
|
+
previous_token = input_token.prev();
|
|
245
|
+
|
|
246
|
+
if(!$(this).val().length) {
|
|
247
|
+
if(selected_token) {
|
|
248
|
+
delete_token($(selected_token));
|
|
249
|
+
hidden_input.change();
|
|
250
|
+
} else if(previous_token.length) {
|
|
251
|
+
select_token($(previous_token.get(0)));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return false;
|
|
255
|
+
} else if($(this).val().length === 1) {
|
|
256
|
+
hide_dropdown();
|
|
257
|
+
} else {
|
|
258
|
+
// set a timeout just long enough to let this function finish.
|
|
259
|
+
setTimeout(function(){do_search();}, 5);
|
|
260
|
+
}
|
|
261
|
+
break;
|
|
262
|
+
|
|
263
|
+
case KEY.TAB:
|
|
264
|
+
case KEY.ENTER:
|
|
265
|
+
case KEY.NUMPAD_ENTER:
|
|
266
|
+
case KEY.COMMA:
|
|
267
|
+
if(selected_dropdown_item) {
|
|
268
|
+
add_token($(selected_dropdown_item).data("tokeninput"));
|
|
269
|
+
hidden_input.change();
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
break;
|
|
273
|
+
|
|
274
|
+
case KEY.ESCAPE:
|
|
275
|
+
hide_dropdown();
|
|
276
|
+
return true;
|
|
277
|
+
|
|
278
|
+
default:
|
|
279
|
+
if(String.fromCharCode(event.which)) {
|
|
280
|
+
// set a timeout just long enough to let this function finish.
|
|
281
|
+
setTimeout(function(){do_search();}, 5);
|
|
282
|
+
}
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
239
286
|
|
|
240
287
|
// Keep a reference to the original input box
|
|
241
288
|
var hidden_input = $(input)
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
289
|
+
.hide()
|
|
290
|
+
.val("")
|
|
291
|
+
.focus(function () {
|
|
292
|
+
input_box.focus();
|
|
293
|
+
})
|
|
294
|
+
.blur(function () {
|
|
295
|
+
input_box.blur();
|
|
296
|
+
});
|
|
250
297
|
|
|
251
298
|
// Keep a reference to the selected token and dropdown item
|
|
252
299
|
var selected_token = null;
|
|
@@ -255,480 +302,556 @@
|
|
|
255
302
|
|
|
256
303
|
// The list to store the token items in
|
|
257
304
|
var token_list = $("<ul />")
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
305
|
+
.addClass(settings.classes.tokenList)
|
|
306
|
+
.click(function (event) {
|
|
307
|
+
var li = $(event.target).closest("li");
|
|
308
|
+
if(li && li.get(0) && $.data(li.get(0), "tokeninput")) {
|
|
309
|
+
toggle_select_token(li);
|
|
310
|
+
} else {
|
|
311
|
+
// Deselect selected token
|
|
312
|
+
if(selected_token) {
|
|
313
|
+
deselect_token($(selected_token), POSITION.END);
|
|
314
|
+
}
|
|
268
315
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
316
|
+
// Focus input box
|
|
317
|
+
input_box.focus();
|
|
318
|
+
}
|
|
319
|
+
})
|
|
320
|
+
.mouseover(function (event) {
|
|
321
|
+
var li = $(event.target).closest("li");
|
|
322
|
+
if(li && selected_token !== this) {
|
|
323
|
+
li.addClass(settings.classes.highlightedToken);
|
|
324
|
+
}
|
|
325
|
+
})
|
|
326
|
+
.mouseout(function (event) {
|
|
327
|
+
var li = $(event.target).closest("li");
|
|
328
|
+
if(li && selected_token !== this) {
|
|
329
|
+
li.removeClass(settings.classes.highlightedToken);
|
|
330
|
+
}
|
|
331
|
+
})
|
|
332
|
+
.insertBefore(hidden_input);
|
|
286
333
|
|
|
287
334
|
// The token holding the input box
|
|
288
335
|
var input_token = $("<li />")
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
336
|
+
.addClass(settings.classes.inputToken)
|
|
337
|
+
.appendTo(token_list)
|
|
338
|
+
.append(input_box);
|
|
292
339
|
|
|
293
340
|
// The list to store the dropdown items in
|
|
294
341
|
var dropdown = $("<div>")
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
342
|
+
.addClass(settings.classes.dropdown)
|
|
343
|
+
.appendTo("body")
|
|
344
|
+
.hide();
|
|
298
345
|
|
|
299
346
|
// Magic element to help us resize the text input
|
|
300
347
|
var input_resizer = $("<tester/>")
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
348
|
+
.insertAfter(input_box)
|
|
349
|
+
.css({
|
|
350
|
+
position: "absolute",
|
|
351
|
+
top: -9999,
|
|
352
|
+
left: -9999,
|
|
353
|
+
width: "auto",
|
|
354
|
+
fontSize: input_box.css("fontSize"),
|
|
355
|
+
fontFamily: input_box.css("fontFamily"),
|
|
356
|
+
fontWeight: input_box.css("fontWeight"),
|
|
357
|
+
letterSpacing: input_box.css("letterSpacing"),
|
|
358
|
+
whiteSpace: "nowrap"
|
|
359
|
+
});
|
|
313
360
|
|
|
314
361
|
// Pre-populate list if items exist
|
|
315
362
|
hidden_input.val("");
|
|
316
|
-
li_data = settings.prePopulate || hidden_input.data("pre");
|
|
317
|
-
if
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
363
|
+
var li_data = settings.prePopulate || hidden_input.data("pre");
|
|
364
|
+
if(settings.processPrePopulate && $.isFunction(settings.onResult)) {
|
|
365
|
+
li_data = settings.onResult.call(hidden_input, li_data);
|
|
366
|
+
}
|
|
367
|
+
if(li_data && li_data.length) {
|
|
368
|
+
$.each(li_data, function (index, value) {
|
|
369
|
+
insert_token(value);
|
|
370
|
+
checkTokenLimit();
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Initialization is done
|
|
375
|
+
if($.isFunction(settings.onReady)) {
|
|
376
|
+
settings.onReady.call();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
//
|
|
380
|
+
// Public functions
|
|
381
|
+
//
|
|
382
|
+
|
|
383
|
+
this.clear = function() {
|
|
384
|
+
token_list.children("li").each(function() {
|
|
385
|
+
if ($(this).children("input").length === 0) {
|
|
386
|
+
delete_token($(this));
|
|
387
|
+
}
|
|
388
|
+
});
|
|
321
389
|
}
|
|
322
390
|
|
|
391
|
+
this.add = function(item) {
|
|
392
|
+
add_token(item);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
this.remove = function(item) {
|
|
396
|
+
token_list.children("li").each(function() {
|
|
397
|
+
if ($(this).children("input").length === 0) {
|
|
398
|
+
var currToken = $(this).data("tokeninput");
|
|
399
|
+
var match = true;
|
|
400
|
+
for (var prop in item) {
|
|
401
|
+
if (item[prop] !== currToken[prop]) {
|
|
402
|
+
match = false;
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (match) {
|
|
407
|
+
delete_token($(this));
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
this.getTokens = function() {
|
|
414
|
+
return saved_tokens;
|
|
415
|
+
}
|
|
323
416
|
|
|
324
417
|
//
|
|
325
418
|
// Private functions
|
|
326
419
|
//
|
|
327
420
|
|
|
421
|
+
function checkTokenLimit() {
|
|
422
|
+
if(settings.tokenLimit !== null && token_count >= settings.tokenLimit) {
|
|
423
|
+
input_box.hide();
|
|
424
|
+
hide_dropdown();
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
328
429
|
function resize_input() {
|
|
329
|
-
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
430
|
+
if(input_val === (input_val = input_box.val())) {return;}
|
|
332
431
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
432
|
+
// Enter new content into resizer and resize input accordingly
|
|
433
|
+
var escaped = input_val.replace(/&/g, '&').replace(/\s/g,' ').replace(/</g, '<').replace(/>/g, '>');
|
|
434
|
+
input_resizer.html(escaped);
|
|
435
|
+
input_box.width(input_resizer.width() + 30);
|
|
337
436
|
}
|
|
338
437
|
|
|
339
438
|
function is_printable_character(keycode) {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
439
|
+
return ((keycode >= 48 && keycode <= 90) || // 0-1a-z
|
|
440
|
+
(keycode >= 96 && keycode <= 111) || // numpad 0-9 + - / * .
|
|
441
|
+
(keycode >= 186 && keycode <= 192) || // ; = , - . / ^
|
|
442
|
+
(keycode >= 219 && keycode <= 222)); // ( \ ) '
|
|
344
443
|
}
|
|
345
444
|
|
|
346
445
|
// Inner function to a token to the list
|
|
347
|
-
function insert_token(
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
446
|
+
function insert_token(item) {
|
|
447
|
+
var this_token = settings.tokenFormatter(item);
|
|
448
|
+
this_token = $(this_token)
|
|
449
|
+
.addClass(settings.classes.token)
|
|
450
|
+
.insertBefore(input_token);
|
|
451
|
+
|
|
452
|
+
// The 'delete token' button
|
|
453
|
+
$("<span>" + settings.deleteText + "</span>")
|
|
454
|
+
.addClass(settings.classes.tokenDelete)
|
|
455
|
+
.appendTo(this_token)
|
|
456
|
+
.click(function () {
|
|
457
|
+
delete_token($(this).parent());
|
|
458
|
+
hidden_input.change();
|
|
459
|
+
return false;
|
|
460
|
+
});
|
|
351
461
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
.click(function () {
|
|
357
|
-
delete_token($(this).parent());
|
|
358
|
-
return false;
|
|
359
|
-
});
|
|
462
|
+
// Store data on the token
|
|
463
|
+
var token_data = {"id": item.id};
|
|
464
|
+
token_data[settings.propertyToSearch] = item[settings.propertyToSearch];
|
|
465
|
+
$.data(this_token.get(0), "tokeninput", item);
|
|
360
466
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
467
|
+
// Save this token for duplicate checking
|
|
468
|
+
saved_tokens = saved_tokens.slice(0,selected_token_index).concat([token_data]).concat(saved_tokens.slice(selected_token_index));
|
|
469
|
+
selected_token_index++;
|
|
364
470
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
selected_token_index++;
|
|
471
|
+
// Update the hidden input
|
|
472
|
+
update_hidden_input(saved_tokens, hidden_input);
|
|
368
473
|
|
|
369
|
-
|
|
370
|
-
var token_ids = $.map(saved_tokens, function (el) {
|
|
371
|
-
return el.id;
|
|
372
|
-
});
|
|
373
|
-
hidden_input.val(token_ids.join(settings.tokenDelimiter));
|
|
474
|
+
token_count += 1;
|
|
374
475
|
|
|
375
|
-
|
|
476
|
+
// Check the token limit
|
|
477
|
+
if(settings.tokenLimit !== null && token_count >= settings.tokenLimit) {
|
|
478
|
+
input_box.hide();
|
|
479
|
+
hide_dropdown();
|
|
480
|
+
}
|
|
376
481
|
|
|
377
|
-
|
|
482
|
+
return this_token;
|
|
378
483
|
}
|
|
379
484
|
|
|
380
485
|
// Add a token to the token list based on user input
|
|
381
|
-
function add_token(item) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
});
|
|
486
|
+
function add_token (item) {
|
|
487
|
+
var callback = settings.onAdd;
|
|
488
|
+
|
|
489
|
+
// See if the token already exists and select it if we don't want duplicates
|
|
490
|
+
if(token_count > 0 && settings.preventDuplicates) {
|
|
491
|
+
var found_existing_token = null;
|
|
492
|
+
token_list.children().each(function () {
|
|
493
|
+
var existing_token = $(this);
|
|
494
|
+
var existing_data = $.data(existing_token.get(0), "tokeninput");
|
|
495
|
+
if(existing_data && existing_data.id === item.id) {
|
|
496
|
+
found_existing_token = existing_token;
|
|
497
|
+
return false;
|
|
498
|
+
}
|
|
499
|
+
});
|
|
396
500
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
501
|
+
if(found_existing_token) {
|
|
502
|
+
select_token(found_existing_token);
|
|
503
|
+
input_token.insertAfter(found_existing_token);
|
|
504
|
+
input_box.focus();
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
402
507
|
}
|
|
403
|
-
}
|
|
404
508
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
input_box.hide();
|
|
411
|
-
hide_dropdown();
|
|
412
|
-
return;
|
|
413
|
-
} else {
|
|
414
|
-
input_box.focus();
|
|
415
|
-
}
|
|
509
|
+
// Insert the new tokens
|
|
510
|
+
if(settings.tokenLimit == null || token_count < settings.tokenLimit) {
|
|
511
|
+
insert_token(item);
|
|
512
|
+
checkTokenLimit();
|
|
513
|
+
}
|
|
416
514
|
|
|
417
|
-
|
|
418
|
-
|
|
515
|
+
// Clear input box
|
|
516
|
+
input_box.val("");
|
|
419
517
|
|
|
420
|
-
|
|
421
|
-
|
|
518
|
+
// Don't show the help dropdown, they've got the idea
|
|
519
|
+
hide_dropdown();
|
|
422
520
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
521
|
+
// Execute the onAdd callback if defined
|
|
522
|
+
if($.isFunction(callback)) {
|
|
523
|
+
callback.call(hidden_input,item);
|
|
524
|
+
}
|
|
427
525
|
}
|
|
428
526
|
|
|
429
527
|
// Select a token in the token list
|
|
430
|
-
function select_token(token) {
|
|
431
|
-
|
|
432
|
-
|
|
528
|
+
function select_token (token) {
|
|
529
|
+
token.addClass(settings.classes.selectedToken);
|
|
530
|
+
selected_token = token.get(0);
|
|
433
531
|
|
|
434
|
-
|
|
435
|
-
|
|
532
|
+
// Hide input box
|
|
533
|
+
input_box.val("");
|
|
436
534
|
|
|
437
|
-
|
|
438
|
-
|
|
535
|
+
// Hide dropdown if it is visible (eg if we clicked to select token)
|
|
536
|
+
hide_dropdown();
|
|
439
537
|
}
|
|
440
538
|
|
|
441
539
|
// Deselect a token in the token list
|
|
442
|
-
function deselect_token(token, position) {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
540
|
+
function deselect_token (token, position) {
|
|
541
|
+
token.removeClass(settings.classes.selectedToken);
|
|
542
|
+
selected_token = null;
|
|
543
|
+
|
|
544
|
+
if(position === POSITION.BEFORE) {
|
|
545
|
+
input_token.insertBefore(token);
|
|
546
|
+
selected_token_index--;
|
|
547
|
+
} else if(position === POSITION.AFTER) {
|
|
548
|
+
input_token.insertAfter(token);
|
|
549
|
+
selected_token_index++;
|
|
550
|
+
} else {
|
|
551
|
+
input_token.appendTo(token_list);
|
|
552
|
+
selected_token_index = token_count;
|
|
553
|
+
}
|
|
456
554
|
|
|
457
|
-
|
|
458
|
-
|
|
555
|
+
// Show the input box and give it focus again
|
|
556
|
+
input_box.focus();
|
|
459
557
|
}
|
|
460
558
|
|
|
461
559
|
// Toggle selection of a token in the token list
|
|
462
560
|
function toggle_select_token(token) {
|
|
463
|
-
|
|
561
|
+
var previous_selected_token = selected_token;
|
|
464
562
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
563
|
+
if(selected_token) {
|
|
564
|
+
deselect_token($(selected_token), POSITION.END);
|
|
565
|
+
}
|
|
468
566
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
567
|
+
if(previous_selected_token === token.get(0)) {
|
|
568
|
+
deselect_token(token, POSITION.END);
|
|
569
|
+
} else {
|
|
570
|
+
select_token(token);
|
|
571
|
+
}
|
|
474
572
|
}
|
|
475
573
|
|
|
476
574
|
// Delete a token from the token list
|
|
477
|
-
function delete_token(token) {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
575
|
+
function delete_token (token) {
|
|
576
|
+
// Remove the id from the saved list
|
|
577
|
+
var token_data = $.data(token.get(0), "tokeninput");
|
|
578
|
+
var callback = settings.onDelete;
|
|
481
579
|
|
|
482
|
-
|
|
483
|
-
|
|
580
|
+
var index = token.prevAll().length;
|
|
581
|
+
if(index > selected_token_index) index--;
|
|
484
582
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
583
|
+
// Delete the token
|
|
584
|
+
token.remove();
|
|
585
|
+
selected_token = null;
|
|
488
586
|
|
|
489
|
-
|
|
490
|
-
|
|
587
|
+
// Show the input box and give it focus again
|
|
588
|
+
input_box.focus();
|
|
491
589
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
590
|
+
// Remove this token from the saved list
|
|
591
|
+
saved_tokens = saved_tokens.slice(0,index).concat(saved_tokens.slice(index+1));
|
|
592
|
+
if(index < selected_token_index) selected_token_index--;
|
|
495
593
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
return el.id;
|
|
499
|
-
});
|
|
500
|
-
hidden_input.val(token_ids.join(settings.tokenDelimiter));
|
|
594
|
+
// Update the hidden input
|
|
595
|
+
update_hidden_input(saved_tokens, hidden_input);
|
|
501
596
|
|
|
502
|
-
|
|
597
|
+
token_count -= 1;
|
|
503
598
|
|
|
504
|
-
|
|
505
|
-
|
|
599
|
+
if(settings.tokenLimit !== null) {
|
|
600
|
+
input_box
|
|
506
601
|
.show()
|
|
507
602
|
.val("")
|
|
508
603
|
.focus();
|
|
509
|
-
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// Execute the onDelete callback if defined
|
|
607
|
+
if($.isFunction(callback)) {
|
|
608
|
+
callback.call(hidden_input,token_data);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// Update the hidden input box value
|
|
613
|
+
function update_hidden_input(saved_tokens, hidden_input) {
|
|
614
|
+
var token_values = $.map(saved_tokens, function (el) {
|
|
615
|
+
return el[settings.tokenValue];
|
|
616
|
+
});
|
|
617
|
+
hidden_input.val(token_values.join(settings.tokenDelimiter));
|
|
510
618
|
|
|
511
|
-
// Execute the onDelete callback if defined
|
|
512
|
-
if ($.isFunction(callback)) {
|
|
513
|
-
callback(token_data);
|
|
514
|
-
}
|
|
515
619
|
}
|
|
516
620
|
|
|
517
621
|
// Hide and clear the results dropdown
|
|
518
|
-
function hide_dropdown() {
|
|
519
|
-
|
|
520
|
-
|
|
622
|
+
function hide_dropdown () {
|
|
623
|
+
dropdown.hide().empty();
|
|
624
|
+
selected_dropdown_item = null;
|
|
521
625
|
}
|
|
522
626
|
|
|
523
627
|
function show_dropdown() {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
628
|
+
dropdown
|
|
629
|
+
.css({
|
|
630
|
+
position: "absolute",
|
|
631
|
+
top: $(token_list).offset().top + $(token_list).outerHeight(),
|
|
632
|
+
left: $(token_list).offset().left,
|
|
633
|
+
zindex: 999
|
|
634
|
+
})
|
|
635
|
+
.show();
|
|
532
636
|
}
|
|
533
637
|
|
|
534
|
-
function show_dropdown_searching() {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
638
|
+
function show_dropdown_searching () {
|
|
639
|
+
if(settings.searchingText) {
|
|
640
|
+
dropdown.html("<p>"+settings.searchingText+"</p>");
|
|
641
|
+
show_dropdown();
|
|
642
|
+
}
|
|
539
643
|
}
|
|
540
644
|
|
|
541
|
-
function show_dropdown_hint() {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
645
|
+
function show_dropdown_hint () {
|
|
646
|
+
if(settings.hintText) {
|
|
647
|
+
dropdown.html("<p>"+settings.hintText+"</p>");
|
|
648
|
+
show_dropdown();
|
|
649
|
+
}
|
|
546
650
|
}
|
|
547
651
|
|
|
548
652
|
// Highlight the query part of the search term
|
|
549
653
|
function highlight_term(value, term) {
|
|
550
|
-
|
|
654
|
+
return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<b>$1</b>");
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
function find_value_and_highlight_term(template, value, term) {
|
|
658
|
+
return template.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + value + ")(?![^<>]*>)(?![^&;]+;)", "g"), highlight_term(value, term));
|
|
551
659
|
}
|
|
552
660
|
|
|
553
661
|
// Populate the results dropdown with some results
|
|
554
|
-
function populate_dropdown(query, results) {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
662
|
+
function populate_dropdown (query, results) {
|
|
663
|
+
if(results && results.length) {
|
|
664
|
+
dropdown.empty();
|
|
665
|
+
var dropdown_ul = $("<ul>")
|
|
558
666
|
.appendTo(dropdown)
|
|
559
667
|
.mouseover(function (event) {
|
|
560
|
-
|
|
561
|
-
|
|
668
|
+
select_dropdown_item($(event.target).closest("li"));
|
|
669
|
+
})
|
|
562
670
|
.mousedown(function (event) {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
671
|
+
add_token($(event.target).closest("li").data("tokeninput"));
|
|
672
|
+
hidden_input.change();
|
|
673
|
+
return false;
|
|
674
|
+
})
|
|
566
675
|
.hide();
|
|
567
676
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
.appendTo(dropdown_ul);
|
|
677
|
+
$.each(results, function(index, value) {
|
|
678
|
+
var this_li = settings.resultsFormatter(value);
|
|
571
679
|
|
|
572
|
-
|
|
573
|
-
this_li.addClass(settings.classes.dropdownItem);
|
|
574
|
-
} else {
|
|
575
|
-
this_li.addClass(settings.classes.dropdownItem2);
|
|
576
|
-
}
|
|
680
|
+
this_li = find_value_and_highlight_term(this_li ,value[settings.propertyToSearch], query);
|
|
577
681
|
|
|
578
|
-
|
|
579
|
-
select_dropdown_item(this_li);
|
|
580
|
-
}
|
|
682
|
+
this_li = $(this_li).appendTo(dropdown_ul);
|
|
581
683
|
|
|
582
|
-
|
|
583
|
-
|
|
684
|
+
if(index % 2) {
|
|
685
|
+
this_li.addClass(settings.classes.dropdownItem);
|
|
686
|
+
} else {
|
|
687
|
+
this_li.addClass(settings.classes.dropdownItem2);
|
|
688
|
+
}
|
|
584
689
|
|
|
585
|
-
|
|
690
|
+
if(index === 0) {
|
|
691
|
+
select_dropdown_item(this_li);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
$.data(this_li.get(0), "tokeninput", value);
|
|
695
|
+
});
|
|
586
696
|
|
|
587
|
-
|
|
588
|
-
|
|
697
|
+
show_dropdown();
|
|
698
|
+
|
|
699
|
+
if(settings.animateDropdown) {
|
|
700
|
+
dropdown_ul.slideDown("fast");
|
|
701
|
+
} else {
|
|
702
|
+
dropdown_ul.show();
|
|
703
|
+
}
|
|
589
704
|
} else {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
dropdown.html("<p>" + settings.noResultsText + "</p>");
|
|
595
|
-
show_dropdown();
|
|
705
|
+
if(settings.noResultsText) {
|
|
706
|
+
dropdown.html("<p>"+settings.noResultsText+"</p>");
|
|
707
|
+
show_dropdown();
|
|
708
|
+
}
|
|
596
709
|
}
|
|
597
|
-
}
|
|
598
710
|
}
|
|
599
711
|
|
|
600
712
|
// Highlight an item in the results dropdown
|
|
601
|
-
function select_dropdown_item(item) {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
713
|
+
function select_dropdown_item (item) {
|
|
714
|
+
if(item) {
|
|
715
|
+
if(selected_dropdown_item) {
|
|
716
|
+
deselect_dropdown_item($(selected_dropdown_item));
|
|
717
|
+
}
|
|
606
718
|
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
719
|
+
item.addClass(settings.classes.selectedDropdownItem);
|
|
720
|
+
selected_dropdown_item = item.get(0);
|
|
721
|
+
}
|
|
610
722
|
}
|
|
611
723
|
|
|
612
724
|
// Remove highlighting from an item in the results dropdown
|
|
613
|
-
function deselect_dropdown_item(item) {
|
|
614
|
-
|
|
615
|
-
|
|
725
|
+
function deselect_dropdown_item (item) {
|
|
726
|
+
item.removeClass(settings.classes.selectedDropdownItem);
|
|
727
|
+
selected_dropdown_item = null;
|
|
616
728
|
}
|
|
617
729
|
|
|
618
730
|
// Do a search and show the "searching" dropdown if the input is longer
|
|
619
731
|
// than settings.minChars
|
|
620
732
|
function do_search() {
|
|
621
|
-
|
|
733
|
+
var query = input_box.val().toLowerCase();
|
|
622
734
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
735
|
+
if(query && query.length) {
|
|
736
|
+
if(selected_token) {
|
|
737
|
+
deselect_token($(selected_token), POSITION.AFTER);
|
|
738
|
+
}
|
|
627
739
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
740
|
+
if(query.length >= settings.minChars) {
|
|
741
|
+
show_dropdown_searching();
|
|
742
|
+
clearTimeout(timeout);
|
|
631
743
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
744
|
+
timeout = setTimeout(function(){
|
|
745
|
+
run_search(query);
|
|
746
|
+
}, settings.searchDelay);
|
|
747
|
+
} else {
|
|
748
|
+
hide_dropdown();
|
|
749
|
+
}
|
|
637
750
|
}
|
|
638
|
-
}
|
|
639
751
|
}
|
|
640
752
|
|
|
641
753
|
// Do the actual search
|
|
642
754
|
function run_search(query) {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
755
|
+
var cache_key = query + computeURL();
|
|
756
|
+
var cached_results = cache.get(cache_key);
|
|
757
|
+
if(cached_results) {
|
|
758
|
+
populate_dropdown(query, cached_results);
|
|
759
|
+
} else {
|
|
760
|
+
// Are we doing an ajax search or local data search?
|
|
761
|
+
if(settings.url) {
|
|
762
|
+
var url = computeURL();
|
|
763
|
+
// Extract exisiting get params
|
|
764
|
+
var ajax_params = {};
|
|
765
|
+
ajax_params.data = {};
|
|
766
|
+
if(url.indexOf("?") > -1) {
|
|
767
|
+
var parts = url.split("?");
|
|
768
|
+
ajax_params.url = parts[0];
|
|
769
|
+
|
|
770
|
+
var param_array = parts[1].split("&");
|
|
771
|
+
$.each(param_array, function (index, value) {
|
|
772
|
+
var kv = value.split("=");
|
|
773
|
+
ajax_params.data[kv[0]] = kv[1];
|
|
774
|
+
});
|
|
775
|
+
} else {
|
|
776
|
+
ajax_params.url = url;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// Prepare the request
|
|
780
|
+
ajax_params.data[settings.queryParam] = query;
|
|
781
|
+
ajax_params.type = settings.method;
|
|
782
|
+
ajax_params.dataType = settings.contentType;
|
|
783
|
+
if(settings.crossDomain) {
|
|
784
|
+
ajax_params.dataType = "jsonp";
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// Attach the success callback
|
|
788
|
+
ajax_params.success = function(results) {
|
|
789
|
+
if($.isFunction(settings.onResult)) {
|
|
790
|
+
results = settings.onResult.call(hidden_input, results);
|
|
791
|
+
}
|
|
792
|
+
cache.add(cache_key, settings.jsonContainer ? results[settings.jsonContainer] : results);
|
|
793
|
+
|
|
794
|
+
// only populate the dropdown if the results are associated with the active search query
|
|
795
|
+
if(input_box.val().toLowerCase() === query) {
|
|
796
|
+
populate_dropdown(query, settings.jsonContainer ? results[settings.jsonContainer] : results);
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
// Make the request
|
|
801
|
+
$.ajax(ajax_params);
|
|
802
|
+
} else if(settings.local_data) {
|
|
803
|
+
// Do the search through local data
|
|
804
|
+
var results = $.grep(settings.local_data, function (row) {
|
|
805
|
+
return row[settings.propertyToSearch].toLowerCase().indexOf(query.toLowerCase()) > -1;
|
|
806
|
+
});
|
|
807
|
+
|
|
808
|
+
if($.isFunction(settings.onResult)) {
|
|
809
|
+
results = settings.onResult.call(hidden_input, results);
|
|
810
|
+
}
|
|
811
|
+
cache.add(cache_key, results);
|
|
812
|
+
populate_dropdown(query, results);
|
|
677
813
|
}
|
|
678
|
-
|
|
814
|
+
}
|
|
815
|
+
}
|
|
679
816
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
// Make the request
|
|
687
|
-
$.ajax(ajax_params);
|
|
688
|
-
} else if (settings.local_data) {
|
|
689
|
-
// Do the search through local data
|
|
690
|
-
var results = $.grep(settings.local_data, function (row) {
|
|
691
|
-
return row.name.toLowerCase().indexOf(query.toLowerCase()) > -1;
|
|
692
|
-
});
|
|
693
|
-
|
|
694
|
-
if ($.isFunction(settings.onResult)) {
|
|
695
|
-
results = settings.onResult.call(this, results);
|
|
696
|
-
}
|
|
697
|
-
cache.add(query, results);
|
|
698
|
-
populate_dropdown(query, results);
|
|
817
|
+
// compute the dynamic URL
|
|
818
|
+
function computeURL() {
|
|
819
|
+
var url = settings.url;
|
|
820
|
+
if(typeof settings.url == 'function') {
|
|
821
|
+
url = settings.url.call();
|
|
699
822
|
}
|
|
700
|
-
|
|
823
|
+
return url;
|
|
701
824
|
}
|
|
702
|
-
|
|
825
|
+
};
|
|
703
826
|
|
|
704
827
|
// Really basic cache for the results
|
|
705
|
-
|
|
828
|
+
$.TokenList.Cache = function (options) {
|
|
706
829
|
var settings = $.extend({
|
|
707
|
-
|
|
830
|
+
max_size: 500
|
|
708
831
|
}, options);
|
|
709
832
|
|
|
710
833
|
var data = {};
|
|
711
834
|
var size = 0;
|
|
712
835
|
|
|
713
836
|
var flush = function () {
|
|
714
|
-
|
|
715
|
-
|
|
837
|
+
data = {};
|
|
838
|
+
size = 0;
|
|
716
839
|
};
|
|
717
840
|
|
|
718
841
|
this.add = function (query, results) {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
842
|
+
if(size > settings.max_size) {
|
|
843
|
+
flush();
|
|
844
|
+
}
|
|
722
845
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
846
|
+
if(!data[query]) {
|
|
847
|
+
size += 1;
|
|
848
|
+
}
|
|
726
849
|
|
|
727
|
-
|
|
850
|
+
data[query] = results;
|
|
728
851
|
};
|
|
729
852
|
|
|
730
853
|
this.get = function (query) {
|
|
731
|
-
|
|
854
|
+
return data[query];
|
|
732
855
|
};
|
|
733
|
-
|
|
856
|
+
};
|
|
734
857
|
}(jQuery));
|