File tree Expand file tree Collapse file tree 2 files changed +35
-10
lines changed
ajax_select/static/ajax_select/js Expand file tree Collapse file tree 2 files changed +35
-10
lines changed Original file line number Diff line number Diff line change 1+ window . addEventListener ( 'load' , function ( ) {
12
2- ( function ( $ ) {
3- 'use strict' ;
3+ var $ = window . jQuery ;
44
55 $ . fn . autocompleteselect = function ( options ) {
66 return this . each ( function ( ) {
245245 } ) ;
246246 } ) ;
247247
248- } ) ( window . jQuery ) ;
248+ } , { once : true } ) ;
Original file line number Diff line number Diff line change 1- // load jquery and jquery-ui if needed
2- // into window.jQuery
3- if ( typeof window . jQuery === 'undefined' ) {
4- document . write ( '<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"><\/script><script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.js"><\/script><link type="text/css" rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />' ) ;
5- } else if ( typeof window . jQuery . ui === 'undefined' || typeof window . jQuery . ui . autocomplete === 'undefined' ) {
6- document . write ( '<script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.js"><\/script><link type="text/css" rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />' ) ;
7- }
1+ ( function ( w ) {
2+ /**
3+ * load jquery and jquery-ui if needed
4+ */
5+
6+ function not ( thing ) {
7+ return typeof thing === 'undefined' ;
8+ }
9+
10+ function loadJS ( src ) {
11+ var script = document . createElement ( 'script' ) ;
12+ script . src = src ;
13+ document . head . appendChild ( script ) ;
14+ }
15+
16+ function loadCSS ( href ) {
17+ var script = document . createElement ( 'link' ) ;
18+ script . href = href ;
19+ script . type = 'text/css' ;
20+ script . rel = 'stylesheet' ;
21+ document . head . appendChild ( script ) ;
22+ }
23+
24+ if ( not ( w . jQuery ) ) {
25+ loadJS ( '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js' ) ;
26+ }
27+
28+ if ( not ( w . jQuery ) || not ( w . jQuery . ui ) || not ( w . jQuery . ui . autocomplete ) ) {
29+ loadJS ( '//code.jquery.com/ui/1.10.3/jquery-ui.js' ) ;
30+ loadCSS ( '//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css' ) ;
31+ }
32+ } ) ( window ) ;
You can’t perform that action at this time.
0 commit comments