gentelella-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +107 -0
  4. data/Rakefile +30 -0
  5. data/assets/javascripts/autosize.js +254 -0
  6. data/assets/javascripts/bootstrap-progressbar.js +168 -0
  7. data/assets/javascripts/bootstrap-wysiwyg.js +306 -0
  8. data/assets/javascripts/data_tables.coffee +12 -0
  9. data/assets/javascripts/data_tables/jquery.data_tables.js +15277 -0
  10. data/assets/javascripts/data_tables/net-bs.bootstrap.js +182 -0
  11. data/assets/javascripts/data_tables/net-buttons-bs.buttons.js +68 -0
  12. data/assets/javascripts/data_tables/net-buttons.buttons.flash.js +1325 -0
  13. data/assets/javascripts/data_tables/net-buttons.buttons.html5.js +1322 -0
  14. data/assets/javascripts/data_tables/net-buttons.buttons.js +1634 -0
  15. data/assets/javascripts/data_tables/net-buttons.buttons.print.js +172 -0
  16. data/assets/javascripts/data_tables/net-fixedheader.js +672 -0
  17. data/assets/javascripts/data_tables/net-keytable.js +883 -0
  18. data/assets/javascripts/data_tables/net-responsive-bs.js +81 -0
  19. data/assets/javascripts/data_tables/net-responsive.js +1232 -0
  20. data/assets/javascripts/data_tables/net-scroller.js +1349 -0
  21. data/assets/javascripts/echarts.js +56282 -0
  22. data/assets/javascripts/echarts.map.world.js +27 -0
  23. data/assets/javascripts/fullcalendar.js +14206 -0
  24. data/assets/javascripts/gauge.coffee +524 -0
  25. data/assets/javascripts/gentelella.coffee +50 -0
  26. data/assets/javascripts/jquery.autocomplete.js +979 -0
  27. data/assets/javascripts/jquery.easypiechart.js +360 -0
  28. data/assets/javascripts/jquery.flot.curvedLines.js +483 -0
  29. data/assets/javascripts/jquery.flot.curved_lines.js +483 -0
  30. data/assets/javascripts/jquery.flot.orderBars.js +201 -0
  31. data/assets/javascripts/jquery.flot.order_bars.js +201 -0
  32. data/assets/javascripts/jquery.flot.spline.js +212 -0
  33. data/assets/javascripts/jquery.hotkeys.js +204 -0
  34. data/assets/javascripts/jquery.mCustomScrollbar.concat.min.js +6 -0
  35. data/assets/javascripts/jquery.mCustomScrollbar.js +2425 -0
  36. data/assets/javascripts/jquery.sparkline.js +3063 -0
  37. data/assets/javascripts/jquery.tagsinput.js +390 -0
  38. data/assets/javascripts/jquery.vmap.js +1281 -0
  39. data/assets/javascripts/jqvmap/maps/continents/jquery.vmap.africa.js +2 -0
  40. data/assets/javascripts/jqvmap/maps/continents/jquery.vmap.asia.js +2 -0
  41. data/assets/javascripts/jqvmap/maps/continents/jquery.vmap.australia.js +2 -0
  42. data/assets/javascripts/jqvmap/maps/continents/jquery.vmap.europe.js +2 -0
  43. data/assets/javascripts/jqvmap/maps/continents/jquery.vmap.north-america.js +2 -0
  44. data/assets/javascripts/jqvmap/maps/continents/jquery.vmap.south-america.js +2 -0
  45. data/assets/javascripts/jqvmap/maps/jquery.vmap.algeria.js +2 -0
  46. data/assets/javascripts/jqvmap/maps/jquery.vmap.argentina.js +1 -0
  47. data/assets/javascripts/jqvmap/maps/jquery.vmap.brazil.js +2 -0
  48. data/assets/javascripts/jqvmap/maps/jquery.vmap.canada.js +2 -0
  49. data/assets/javascripts/jqvmap/maps/jquery.vmap.europe.js +2 -0
  50. data/assets/javascripts/jqvmap/maps/jquery.vmap.france.js +1 -0
  51. data/assets/javascripts/jqvmap/maps/jquery.vmap.germany.js +2 -0
  52. data/assets/javascripts/jqvmap/maps/jquery.vmap.greece.js +1 -0
  53. data/assets/javascripts/jqvmap/maps/jquery.vmap.iran.js +6 -0
  54. data/assets/javascripts/jqvmap/maps/jquery.vmap.iraq.js +1 -0
  55. data/assets/javascripts/jqvmap/maps/jquery.vmap.russia.js +2 -0
  56. data/assets/javascripts/jqvmap/maps/jquery.vmap.tunisia.js +2 -0
  57. data/assets/javascripts/jqvmap/maps/jquery.vmap.turkey.js +11 -0
  58. data/assets/javascripts/jqvmap/maps/jquery.vmap.usa.js +2 -0
  59. data/assets/javascripts/jqvmap/maps/jquery.vmap.world.js +2 -0
  60. data/assets/javascripts/jszip.js +9344 -0
  61. data/assets/javascripts/morris.js +1892 -0
  62. data/assets/javascripts/parsley.js.map +1 -0
  63. data/assets/javascripts/pdfmake.js +68149 -0
  64. data/assets/javascripts/pnotify.buttons.js +8 -0
  65. data/assets/javascripts/pnotify.js +31 -0
  66. data/assets/javascripts/pnotify.nonblock.js +6 -0
  67. data/assets/javascripts/prettify.coffee +29 -0
  68. data/assets/javascripts/prettify/lang-apollo.js +51 -0
  69. data/assets/javascripts/prettify/lang-basic.js +32 -0
  70. data/assets/javascripts/prettify/lang-clj.js +64 -0
  71. data/assets/javascripts/prettify/lang-css.js +159 -0
  72. data/assets/javascripts/prettify/lang-dart.js +88 -0
  73. data/assets/javascripts/prettify/lang-erlang.js +92 -0
  74. data/assets/javascripts/prettify/lang-go.js +58 -0
  75. data/assets/javascripts/prettify/lang-hs.js +101 -0
  76. data/assets/javascripts/prettify/lang-lisp.js +94 -0
  77. data/assets/javascripts/prettify/lang-llvm.js +61 -0
  78. data/assets/javascripts/prettify/lang-lua.js +59 -0
  79. data/assets/javascripts/prettify/lang-matlab.js +180 -0
  80. data/assets/javascripts/prettify/lang-ml.js +56 -0
  81. data/assets/javascripts/prettify/lang-mumps.js +139 -0
  82. data/assets/javascripts/prettify/lang-n.js +65 -0
  83. data/assets/javascripts/prettify/lang-pascal.js +32 -0
  84. data/assets/javascripts/prettify/lang-proto.js +35 -0
  85. data/assets/javascripts/prettify/lang-r.js +57 -0
  86. data/assets/javascripts/prettify/lang-rd.js +47 -0
  87. data/assets/javascripts/prettify/lang-scala.js +54 -0
  88. data/assets/javascripts/prettify/lang-sql.js +58 -0
  89. data/assets/javascripts/prettify/lang-tcl.js +62 -0
  90. data/assets/javascripts/prettify/lang-tex.js +46 -0
  91. data/assets/javascripts/prettify/lang-vb.js +66 -0
  92. data/assets/javascripts/prettify/lang-vhdl.js +34 -0
  93. data/assets/javascripts/prettify/lang-wiki.js +53 -0
  94. data/assets/javascripts/prettify/lang-xq.js +67 -0
  95. data/assets/javascripts/prettify/lang-yaml.js +27 -0
  96. data/assets/javascripts/prettify/prettify.js +1655 -0
  97. data/assets/javascripts/prettify/run_prettify.js +1905 -0
  98. data/assets/javascripts/raphael.js +8330 -0
  99. data/assets/javascripts/skycons.js +730 -0
  100. data/assets/javascripts/starrr.js +98 -0
  101. data/assets/javascripts/vfs_fonts.js +1 -0
  102. data/assets/stylesheets/bootstrap-progressbar-3.3.0-3.x.x.scss +74 -0
  103. data/assets/stylesheets/bootstrap-wysiwyg.css +88 -0
  104. data/assets/stylesheets/data_tables/net-bs.bootstrap.css +185 -0
  105. data/assets/stylesheets/data_tables/net-buttons-bs.buttons.css +102 -0
  106. data/assets/stylesheets/data_tables/net-fixedheader-bs.bootstrap.css +20 -0
  107. data/assets/stylesheets/data_tables/net-responsive-bs.bootstrap.css +181 -0
  108. data/assets/stylesheets/data_tables/net-scroller-bs.bootstrap.css +24 -0
  109. data/assets/stylesheets/fullcalendar.css +1406 -0
  110. data/assets/stylesheets/fullcalendar.print.css +208 -0
  111. data/assets/stylesheets/gentelella.scss +39 -0
  112. data/assets/stylesheets/jquery.mCustomScrollbar.css +1267 -0
  113. data/assets/stylesheets/jqvmap.css +50 -0
  114. data/assets/stylesheets/morris.css +2 -0
  115. data/assets/stylesheets/pnotify.buttons.css +1 -0
  116. data/assets/stylesheets/pnotify.css +1 -0
  117. data/assets/stylesheets/pnotify.nonblock.css +1 -0
  118. data/assets/stylesheets/prettify/prettify.css +52 -0
  119. data/assets/stylesheets/starrr.css +8 -0
  120. data/lib/generators/gentelella/install/USAGE +9 -0
  121. data/lib/generators/gentelella/install/install_generator.rb +14 -0
  122. data/lib/generators/gentelella/install/templates/gentelella-custom.js +5067 -0
  123. data/lib/generators/gentelella/install/templates/gentelella-custom.scss +4241 -0
  124. data/lib/gentelella-rails.rb +58 -0
  125. data/lib/gentelella/engine.rb +15 -0
  126. data/lib/gentelella/version.rb +3 -0
  127. data/lib/tasks/bower.rake +153 -0
  128. data/lib/tasks/gentelella/rails_tasks.rake +4 -0
  129. metadata +409 -0
@@ -0,0 +1,390 @@
1
+ /*
2
+
3
+ jQuery Tags Input Plugin 1.3.3
4
+
5
+ Copyright (c) 2011 XOXCO, Inc
6
+
7
+ Documentation for this plugin lives here:
8
+ http://xoxco.com/clickable/jquery-tags-input
9
+
10
+ Licensed under the MIT license:
11
+ http://www.opensource.org/licenses/mit-license.php
12
+
13
+ ben@xoxco.com
14
+
15
+ */
16
+
17
+ (function($) {
18
+
19
+ var delimiter = new Array();
20
+ var tags_callbacks = new Array();
21
+ $.fn.doAutosize = function(o){
22
+ var minWidth = $(this).data('minwidth'),
23
+ maxWidth = $(this).data('maxwidth'),
24
+ val = '',
25
+ input = $(this),
26
+ testSubject = $('#'+$(this).data('tester_id'));
27
+
28
+ if (val === (val = input.val())) {return;}
29
+
30
+ // Enter new content into testSubject
31
+ var escaped = val.replace(/&/g, '&amp;').replace(/\s/g,' ').replace(/</g, '&lt;').replace(/>/g, '&gt;');
32
+ testSubject.html(escaped);
33
+ // Calculate new width + whether to change
34
+ var testerWidth = testSubject.width(),
35
+ newWidth = (testerWidth + o.comfortZone) >= minWidth ? testerWidth + o.comfortZone : minWidth,
36
+ currentWidth = input.width(),
37
+ isValidWidthChange = (newWidth < currentWidth && newWidth >= minWidth)
38
+ || (newWidth > minWidth && newWidth < maxWidth);
39
+
40
+ // Animate width
41
+ if (isValidWidthChange) {
42
+ input.width(newWidth);
43
+ }
44
+
45
+
46
+ };
47
+ $.fn.resetAutosize = function(options){
48
+ // alert(JSON.stringify(options));
49
+ var minWidth = $(this).data('minwidth') || options.minInputWidth || $(this).width(),
50
+ maxWidth = $(this).data('maxwidth') || options.maxInputWidth || ($(this).closest('.tagsinput').width() - options.inputPadding),
51
+ val = '',
52
+ input = $(this),
53
+ testSubject = $('<tester/>').css({
54
+ position: 'absolute',
55
+ top: -9999,
56
+ left: -9999,
57
+ width: 'auto',
58
+ fontSize: input.css('fontSize'),
59
+ fontFamily: input.css('fontFamily'),
60
+ fontWeight: input.css('fontWeight'),
61
+ letterSpacing: input.css('letterSpacing'),
62
+ whiteSpace: 'nowrap'
63
+ }),
64
+ testerId = $(this).attr('id')+'_autosize_tester';
65
+ if(! $('#'+testerId).length > 0){
66
+ testSubject.attr('id', testerId);
67
+ testSubject.appendTo('body');
68
+ }
69
+
70
+ input.data('minwidth', minWidth);
71
+ input.data('maxwidth', maxWidth);
72
+ input.data('tester_id', testerId);
73
+ input.css('width', minWidth);
74
+ };
75
+
76
+ $.fn.addTag = function(value,options) {
77
+ options = jQuery.extend({focus:false,callback:true},options);
78
+ this.each(function() {
79
+ var id = $(this).attr('id');
80
+
81
+ var tagslist = $(this).val().split(delimiter[id]);
82
+ if (tagslist[0] == '') {
83
+ tagslist = new Array();
84
+ }
85
+
86
+ value = jQuery.trim(value);
87
+
88
+ if (options.unique) {
89
+ var skipTag = $(this).tagExist(value);
90
+ if(skipTag == true) {
91
+ //Marks fake input as not_valid to let styling it
92
+ $('#'+id+'_tag').addClass('not_valid');
93
+ }
94
+ } else {
95
+ var skipTag = false;
96
+ }
97
+
98
+ if (value !='' && skipTag != true) {
99
+ $('<span>').addClass('tag').append(
100
+ $('<span>').text(value).append('&nbsp;&nbsp;'),
101
+ $('<a>', {
102
+ href : '#',
103
+ title : 'Removing tag',
104
+ text : 'x'
105
+ }).click(function () {
106
+ return $('#' + id).removeTag(escape(value));
107
+ })
108
+ ).insertBefore('#' + id + '_addTag');
109
+
110
+ tagslist.push(value);
111
+
112
+ $('#'+id+'_tag').val('');
113
+ if (options.focus) {
114
+ $('#'+id+'_tag').focus();
115
+ } else {
116
+ $('#'+id+'_tag').blur();
117
+ }
118
+
119
+ $.fn.tagsInput.updateTagsField(this,tagslist);
120
+
121
+ if (options.callback && tags_callbacks[id] && tags_callbacks[id]['onAddTag']) {
122
+ var f = tags_callbacks[id]['onAddTag'];
123
+ f.call(this, value);
124
+ }
125
+ if(tags_callbacks[id] && tags_callbacks[id]['onChange'])
126
+ {
127
+ var i = tagslist.length;
128
+ var f = tags_callbacks[id]['onChange'];
129
+ f.call(this, $(this), tagslist[i-1]);
130
+ }
131
+ }
132
+
133
+ });
134
+
135
+ return false;
136
+ };
137
+
138
+ $.fn.removeTag = function(value) {
139
+ value = unescape(value);
140
+ this.each(function() {
141
+ var id = $(this).attr('id');
142
+
143
+ var old = $(this).val().split(delimiter[id]);
144
+
145
+ $('#'+id+'_tagsinput .tag').remove();
146
+ str = '';
147
+ for (i=0; i< old.length; i++) {
148
+ if (old[i]!=value) {
149
+ str = str + delimiter[id] +old[i];
150
+ }
151
+ }
152
+
153
+ $.fn.tagsInput.importTags(this,str);
154
+
155
+ if (tags_callbacks[id] && tags_callbacks[id]['onRemoveTag']) {
156
+ var f = tags_callbacks[id]['onRemoveTag'];
157
+ f.call(this, value);
158
+ }
159
+ });
160
+
161
+ return false;
162
+ };
163
+
164
+ $.fn.tagExist = function(val) {
165
+ var id = $(this).attr('id');
166
+ var tagslist = $(this).val().split(delimiter[id]);
167
+ return (jQuery.inArray(val, tagslist) >= 0); //true when tag exists, false when not
168
+ };
169
+
170
+ // clear all existing tags and import new ones from a string
171
+ $.fn.importTags = function(str) {
172
+ var id = $(this).attr('id');
173
+ $('#'+id+'_tagsinput .tag').remove();
174
+ $.fn.tagsInput.importTags(this,str);
175
+ }
176
+
177
+ $.fn.tagsInput = function(options) {
178
+ var settings = jQuery.extend({
179
+ interactive:true,
180
+ defaultText:'add a tag',
181
+ minChars:0,
182
+ width:'300px',
183
+ height:'100px',
184
+ autocomplete: {selectFirst: false },
185
+ hide:true,
186
+ delimiter: ',',
187
+ unique:true,
188
+ removeWithBackspace:true,
189
+ placeholderColor:'#666666',
190
+ autosize: true,
191
+ comfortZone: 20,
192
+ inputPadding: 6*2
193
+ },options);
194
+
195
+ var uniqueIdCounter = 0;
196
+
197
+ this.each(function() {
198
+ // If we have already initialized the field, do not do it again
199
+ if (typeof $(this).attr('data-tagsinput-init') !== 'undefined') {
200
+ return;
201
+ }
202
+
203
+ // Mark the field as having been initialized
204
+ $(this).attr('data-tagsinput-init', true);
205
+
206
+ if (settings.hide) {
207
+ $(this).hide();
208
+ }
209
+ var id = $(this).attr('id');
210
+ if (!id || delimiter[$(this).attr('id')]) {
211
+ id = $(this).attr('id', 'tags' + new Date().getTime() + (uniqueIdCounter++)).attr('id');
212
+ }
213
+
214
+ var data = jQuery.extend({
215
+ pid:id,
216
+ real_input: '#'+id,
217
+ holder: '#'+id+'_tagsinput',
218
+ input_wrapper: '#'+id+'_addTag',
219
+ fake_input: '#'+id+'_tag'
220
+ },settings);
221
+
222
+ delimiter[id] = data.delimiter;
223
+
224
+ if (settings.onAddTag || settings.onRemoveTag || settings.onChange) {
225
+ tags_callbacks[id] = new Array();
226
+ tags_callbacks[id]['onAddTag'] = settings.onAddTag;
227
+ tags_callbacks[id]['onRemoveTag'] = settings.onRemoveTag;
228
+ tags_callbacks[id]['onChange'] = settings.onChange;
229
+ }
230
+
231
+ var markup = '<div id="'+id+'_tagsinput" class="tagsinput"><div id="'+id+'_addTag">';
232
+
233
+ if (settings.interactive) {
234
+ markup = markup + '<input id="'+id+'_tag" value="" data-default="'+settings.defaultText+'" />';
235
+ }
236
+
237
+ markup = markup + '</div><div class="tags_clear"></div></div>';
238
+
239
+ $(markup).insertAfter(this);
240
+
241
+ $(data.holder).css('width',settings.width);
242
+ $(data.holder).css('min-height',settings.height);
243
+ $(data.holder).css('height',settings.height);
244
+
245
+ if ($(data.real_input).val()!='') {
246
+ $.fn.tagsInput.importTags($(data.real_input),$(data.real_input).val());
247
+ }
248
+ if (settings.interactive) {
249
+ $(data.fake_input).val($(data.fake_input).attr('data-default'));
250
+ $(data.fake_input).css('color',settings.placeholderColor);
251
+ $(data.fake_input).resetAutosize(settings);
252
+
253
+ $(data.holder).bind('click',data,function(event) {
254
+ $(event.data.fake_input).focus();
255
+ });
256
+
257
+ $(data.fake_input).bind('focus',data,function(event) {
258
+ if ($(event.data.fake_input).val()==$(event.data.fake_input).attr('data-default')) {
259
+ $(event.data.fake_input).val('');
260
+ }
261
+ $(event.data.fake_input).css('color','#000000');
262
+ });
263
+
264
+ if (settings.autocomplete_url != undefined) {
265
+ autocomplete_options = {source: settings.autocomplete_url};
266
+ for (attrname in settings.autocomplete) {
267
+ autocomplete_options[attrname] = settings.autocomplete[attrname];
268
+ }
269
+
270
+ if (jQuery.Autocompleter !== undefined) {
271
+ $(data.fake_input).autocomplete(settings.autocomplete_url, settings.autocomplete);
272
+ $(data.fake_input).bind('result',data,function(event,data,formatted) {
273
+ if (data) {
274
+ $('#'+id).addTag(data[0] + "",{focus:true,unique:(settings.unique)});
275
+ }
276
+ });
277
+ } else if (jQuery.ui.autocomplete !== undefined) {
278
+ $(data.fake_input).autocomplete(autocomplete_options);
279
+ $(data.fake_input).bind('autocompleteselect',data,function(event,ui) {
280
+ $(event.data.real_input).addTag(ui.item.value,{focus:true,unique:(settings.unique)});
281
+ return false;
282
+ });
283
+ }
284
+
285
+
286
+ } else {
287
+ // if a user tabs out of the field, create a new tag
288
+ // this is only available if autocomplete is not used.
289
+ $(data.fake_input).bind('blur',data,function(event) {
290
+ var d = $(this).attr('data-default');
291
+ if ($(event.data.fake_input).val()!='' && $(event.data.fake_input).val()!=d) {
292
+ if( (event.data.minChars <= $(event.data.fake_input).val().length) && (!event.data.maxChars || (event.data.maxChars >= $(event.data.fake_input).val().length)) )
293
+ $(event.data.real_input).addTag($(event.data.fake_input).val(),{focus:true,unique:(settings.unique)});
294
+ } else {
295
+ $(event.data.fake_input).val($(event.data.fake_input).attr('data-default'));
296
+ $(event.data.fake_input).css('color',settings.placeholderColor);
297
+ }
298
+ return false;
299
+ });
300
+
301
+ }
302
+ // if user types a default delimiter like comma,semicolon and then create a new tag
303
+ $(data.fake_input).bind('keypress',data,function(event) {
304
+ if (_checkDelimiter(event)) {
305
+ event.preventDefault();
306
+ if( (event.data.minChars <= $(event.data.fake_input).val().length) && (!event.data.maxChars || (event.data.maxChars >= $(event.data.fake_input).val().length)) )
307
+ $(event.data.real_input).addTag($(event.data.fake_input).val(),{focus:true,unique:(settings.unique)});
308
+ $(event.data.fake_input).resetAutosize(settings);
309
+ return false;
310
+ } else if (event.data.autosize) {
311
+ $(event.data.fake_input).doAutosize(settings);
312
+
313
+ }
314
+ });
315
+ //Delete last tag on backspace
316
+ data.removeWithBackspace && $(data.fake_input).bind('keydown', function(event)
317
+ {
318
+ if(event.keyCode == 8 && $(this).val() == '')
319
+ {
320
+ event.preventDefault();
321
+ var last_tag = $(this).closest('.tagsinput').find('.tag:last').text();
322
+ var id = $(this).attr('id').replace(/_tag$/, '');
323
+ last_tag = last_tag.replace(/[\s]+x$/, '');
324
+ $('#' + id).removeTag(escape(last_tag));
325
+ $(this).trigger('focus');
326
+ }
327
+ });
328
+ $(data.fake_input).blur();
329
+
330
+ //Removes the not_valid class when user changes the value of the fake input
331
+ if(data.unique) {
332
+ $(data.fake_input).keydown(function(event){
333
+ if(event.keyCode == 8 || String.fromCharCode(event.which).match(/\w+|[áéíóúÁÉÍÓÚñÑ,/]+/)) {
334
+ $(this).removeClass('not_valid');
335
+ }
336
+ });
337
+ }
338
+ } // if settings.interactive
339
+ });
340
+
341
+ return this;
342
+
343
+ };
344
+
345
+ $.fn.tagsInput.updateTagsField = function(obj,tagslist) {
346
+ var id = $(obj).attr('id');
347
+ $(obj).val(tagslist.join(delimiter[id]));
348
+ };
349
+
350
+ $.fn.tagsInput.importTags = function(obj,val) {
351
+ $(obj).val('');
352
+ var id = $(obj).attr('id');
353
+ var tags = val.split(delimiter[id]);
354
+ for (i=0; i<tags.length; i++) {
355
+ $(obj).addTag(tags[i],{focus:false,callback:false});
356
+ }
357
+ if(tags_callbacks[id] && tags_callbacks[id]['onChange'])
358
+ {
359
+ var f = tags_callbacks[id]['onChange'];
360
+ f.call(obj, obj, tags[i]);
361
+ }
362
+ };
363
+
364
+ /**
365
+ * check delimiter Array
366
+ * @param event
367
+ * @returns {boolean}
368
+ * @private
369
+ */
370
+ var _checkDelimiter = function(event){
371
+ var found = false;
372
+ if (event.which == 13) {
373
+ return true;
374
+ }
375
+
376
+ if (typeof event.data.delimiter === 'string') {
377
+ if (event.which == event.data.delimiter.charCodeAt(0)) {
378
+ found = true;
379
+ }
380
+ } else {
381
+ $.each(event.data.delimiter, function(index, delimiter) {
382
+ if (event.which == delimiter.charCodeAt(0)) {
383
+ found = true;
384
+ }
385
+ });
386
+ }
387
+
388
+ return found;
389
+ }
390
+ })(jQuery);
@@ -0,0 +1,1281 @@
1
+ /*!
2
+ * JQVMap: jQuery Vector Map Library
3
+ * @author JQVMap <me@peterschmalfeldt.com>
4
+ * @version 1.5.1
5
+ * @link http://jqvmap.com
6
+ * @license https://github.com/manifestinteractive/jqvmap/blob/master/LICENSE
7
+ * @builddate 2016/05/18
8
+ */
9
+
10
+ var VectorCanvas = function (width, height, params) {
11
+ this.mode = window.SVGAngle ? 'svg' : 'vml';
12
+ this.params = params;
13
+
14
+ if (this.mode === 'svg') {
15
+ this.createSvgNode = function (nodeName) {
16
+ return document.createElementNS(this.svgns, nodeName);
17
+ };
18
+ } else {
19
+ try {
20
+ if (!document.namespaces.rvml) {
21
+ document.namespaces.add('rvml', 'urn:schemas-microsoft-com:vml');
22
+ }
23
+ this.createVmlNode = function (tagName) {
24
+ return document.createElement('<rvml:' + tagName + ' class="rvml">');
25
+ };
26
+ } catch (e) {
27
+ this.createVmlNode = function (tagName) {
28
+ return document.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');
29
+ };
30
+ }
31
+
32
+ document.createStyleSheet().addRule('.rvml', 'behavior:url(#default#VML)');
33
+ }
34
+
35
+ if (this.mode === 'svg') {
36
+ this.canvas = this.createSvgNode('svg');
37
+ } else {
38
+ this.canvas = this.createVmlNode('group');
39
+ this.canvas.style.position = 'absolute';
40
+ }
41
+
42
+ this.setSize(width, height);
43
+ };
44
+
45
+ VectorCanvas.prototype = {
46
+ svgns: 'http://www.w3.org/2000/svg',
47
+ mode: 'svg',
48
+ width: 0,
49
+ height: 0,
50
+ canvas: null
51
+ };
52
+
53
+ var ColorScale = function (colors, normalizeFunction, minValue, maxValue) {
54
+ if (colors) {
55
+ this.setColors(colors);
56
+ }
57
+ if (normalizeFunction) {
58
+ this.setNormalizeFunction(normalizeFunction);
59
+ }
60
+ if (minValue) {
61
+ this.setMin(minValue);
62
+ }
63
+ if (minValue) {
64
+ this.setMax(maxValue);
65
+ }
66
+ };
67
+
68
+ ColorScale.prototype = {
69
+ colors: []
70
+ };
71
+
72
+ var JQVMap = function (params) {
73
+ params = params || {};
74
+ var map = this;
75
+ var mapData = JQVMap.maps[params.map];
76
+ var mapPins;
77
+
78
+ if( !mapData){
79
+ throw new Error('Invalid "' + params.map + '" map parameter. Please make sure you have loaded this map file in your HTML.');
80
+ }
81
+
82
+ this.selectedRegions = [];
83
+ this.multiSelectRegion = params.multiSelectRegion;
84
+
85
+ this.container = params.container;
86
+
87
+ this.defaultWidth = mapData.width;
88
+ this.defaultHeight = mapData.height;
89
+
90
+ this.color = params.color;
91
+ this.selectedColor = params.selectedColor;
92
+ this.hoverColor = params.hoverColor;
93
+ this.hoverColors = params.hoverColors;
94
+ this.hoverOpacity = params.hoverOpacity;
95
+ this.setBackgroundColor(params.backgroundColor);
96
+
97
+ this.width = params.container.width();
98
+ this.height = params.container.height();
99
+
100
+ this.resize();
101
+
102
+ jQuery(window).resize(function () {
103
+ var newWidth = params.container.width();
104
+ var newHeight = params.container.height();
105
+
106
+ if(newWidth && newHeight){
107
+ map.width = newWidth;
108
+ map.height = newHeight;
109
+ map.resize();
110
+ map.canvas.setSize(map.width, map.height);
111
+ map.applyTransform();
112
+
113
+ var resizeEvent = jQuery.Event('resize.jqvmap');
114
+ jQuery(params.container).trigger(resizeEvent, [newWidth, newHeight]);
115
+
116
+ if(mapPins){
117
+ jQuery('.jqvmap-pin').remove();
118
+ map.pinHandlers = false;
119
+ map.placePins(mapPins.pins, mapPins.mode);
120
+ }
121
+ }
122
+ });
123
+
124
+ this.canvas = new VectorCanvas(this.width, this.height, params);
125
+ params.container.append(this.canvas.canvas);
126
+
127
+ this.makeDraggable();
128
+
129
+ this.rootGroup = this.canvas.createGroup(true);
130
+
131
+ this.index = JQVMap.mapIndex;
132
+ this.label = jQuery('<div/>').addClass('jqvmap-label').appendTo(jQuery('body')).hide();
133
+
134
+ if (params.enableZoom) {
135
+ jQuery('<div/>').addClass('jqvmap-zoomin').text('+').appendTo(params.container);
136
+ jQuery('<div/>').addClass('jqvmap-zoomout').html('&#x2212;').appendTo(params.container);
137
+ }
138
+
139
+ map.countries = [];
140
+
141
+ for (var key in mapData.paths) {
142
+ var path = this.canvas.createPath({
143
+ path: mapData.paths[key].path
144
+ });
145
+
146
+ path.setFill(this.color);
147
+ path.id = map.getCountryId(key);
148
+ map.countries[key] = path;
149
+
150
+ if (this.canvas.mode === 'svg') {
151
+ path.setAttribute('class', 'jqvmap-region');
152
+ } else {
153
+ jQuery(path).addClass('jqvmap-region');
154
+ }
155
+
156
+ jQuery(this.rootGroup).append(path);
157
+ }
158
+
159
+ jQuery(params.container).delegate(this.canvas.mode === 'svg' ? 'path' : 'shape', 'mouseover mouseout', function (e) {
160
+ var containerPath = e.target,
161
+ code = e.target.id.split('_').pop(),
162
+ labelShowEvent = jQuery.Event('labelShow.jqvmap'),
163
+ regionMouseOverEvent = jQuery.Event('regionMouseOver.jqvmap');
164
+
165
+ code = code.toLowerCase();
166
+
167
+ if (e.type === 'mouseover') {
168
+ jQuery(params.container).trigger(regionMouseOverEvent, [code, mapData.paths[code].name]);
169
+ if (!regionMouseOverEvent.isDefaultPrevented()) {
170
+ map.highlight(code, containerPath);
171
+ }
172
+ if (params.showTooltip) {
173
+ map.label.text(mapData.paths[code].name);
174
+ jQuery(params.container).trigger(labelShowEvent, [map.label, code]);
175
+
176
+ if (!labelShowEvent.isDefaultPrevented()) {
177
+ map.label.show();
178
+ map.labelWidth = map.label.width();
179
+ map.labelHeight = map.label.height();
180
+ }
181
+ }
182
+ } else {
183
+ map.unhighlight(code, containerPath);
184
+
185
+ map.label.hide();
186
+ jQuery(params.container).trigger('regionMouseOut.jqvmap', [code, mapData.paths[code].name]);
187
+ }
188
+ });
189
+
190
+ jQuery(params.container).delegate(this.canvas.mode === 'svg' ? 'path' : 'shape', 'click', function (regionClickEvent) {
191
+
192
+ var targetPath = regionClickEvent.target;
193
+ var code = regionClickEvent.target.id.split('_').pop();
194
+ var mapClickEvent = jQuery.Event('regionClick.jqvmap');
195
+
196
+ code = code.toLowerCase();
197
+
198
+ jQuery(params.container).trigger(mapClickEvent, [code, mapData.paths[code].name]);
199
+
200
+ if ( !params.multiSelectRegion && !mapClickEvent.isDefaultPrevented()) {
201
+ for (var keyPath in mapData.paths) {
202
+ map.countries[keyPath].currentFillColor = map.countries[keyPath].getOriginalFill();
203
+ map.countries[keyPath].setFill(map.countries[keyPath].getOriginalFill());
204
+ }
205
+ }
206
+
207
+ if ( !mapClickEvent.isDefaultPrevented()) {
208
+ if (map.isSelected(code)) {
209
+ map.deselect(code, targetPath);
210
+ } else {
211
+ map.select(code, targetPath);
212
+ }
213
+ }
214
+ });
215
+
216
+ if (params.showTooltip) {
217
+ params.container.mousemove(function (e) {
218
+ if (map.label.is(':visible')) {
219
+ var left = e.pageX - 15 - map.labelWidth;
220
+ var top = e.pageY - 15 - map.labelHeight;
221
+
222
+ if(left < 0) {
223
+ left = e.pageX + 15;
224
+ }
225
+ if(top < 0) {
226
+ top = e.pageY + 15;
227
+ }
228
+
229
+ map.label.css({
230
+ left: left,
231
+ top: top
232
+ });
233
+ }
234
+ });
235
+ }
236
+
237
+ this.setColors(params.colors);
238
+
239
+ this.canvas.canvas.appendChild(this.rootGroup);
240
+
241
+ this.applyTransform();
242
+
243
+ this.colorScale = new ColorScale(params.scaleColors, params.normalizeFunction, params.valueMin, params.valueMax);
244
+
245
+ if (params.values) {
246
+ this.values = params.values;
247
+ this.setValues(params.values);
248
+ }
249
+
250
+ if (params.selectedRegions) {
251
+ if (params.selectedRegions instanceof Array) {
252
+ for(var k in params.selectedRegions) {
253
+ this.select(params.selectedRegions[k].toLowerCase());
254
+ }
255
+ } else {
256
+ this.select(params.selectedRegions.toLowerCase());
257
+ }
258
+ }
259
+
260
+ this.bindZoomButtons();
261
+
262
+ if(params.pins) {
263
+ mapPins = {
264
+ pins: params.pins,
265
+ mode: params.pinMode
266
+ };
267
+
268
+ this.pinHandlers = false;
269
+ this.placePins(params.pins, params.pinMode);
270
+ }
271
+
272
+ if(params.showLabels){
273
+ this.pinHandlers = false;
274
+
275
+ var pins = {};
276
+ for (key in map.countries){
277
+ if (typeof map.countries[key] !== 'function') {
278
+ if( !params.pins || !params.pins[key] ){
279
+ pins[key] = key.toUpperCase();
280
+ }
281
+ }
282
+ }
283
+
284
+ mapPins = {
285
+ pins: pins,
286
+ mode: 'content'
287
+ };
288
+
289
+ this.placePins(pins, 'content');
290
+ }
291
+
292
+ JQVMap.mapIndex++;
293
+ };
294
+
295
+ JQVMap.prototype = {
296
+ transX: 0,
297
+ transY: 0,
298
+ scale: 1,
299
+ baseTransX: 0,
300
+ baseTransY: 0,
301
+ baseScale: 1,
302
+ width: 0,
303
+ height: 0,
304
+ countries: {},
305
+ countriesColors: {},
306
+ countriesData: {},
307
+ zoomStep: 1.4,
308
+ zoomMaxStep: 4,
309
+ zoomCurStep: 1
310
+ };
311
+
312
+ JQVMap.xlink = 'http://www.w3.org/1999/xlink';
313
+ JQVMap.mapIndex = 1;
314
+ JQVMap.maps = {};
315
+
316
+ (function(){
317
+
318
+ var apiParams = {
319
+ colors: 1,
320
+ values: 1,
321
+ backgroundColor: 1,
322
+ scaleColors: 1,
323
+ normalizeFunction: 1,
324
+ enableZoom: 1,
325
+ showTooltip: 1,
326
+ borderColor: 1,
327
+ borderWidth: 1,
328
+ borderOpacity: 1,
329
+ selectedRegions: 1,
330
+ multiSelectRegion: 1
331
+ };
332
+
333
+ var apiEvents = {
334
+ onLabelShow: 'labelShow',
335
+ onLoad: 'load',
336
+ onRegionOver: 'regionMouseOver',
337
+ onRegionOut: 'regionMouseOut',
338
+ onRegionClick: 'regionClick',
339
+ onRegionSelect: 'regionSelect',
340
+ onRegionDeselect: 'regionDeselect',
341
+ onResize: 'resize'
342
+ };
343
+
344
+ jQuery.fn.vectorMap = function (options) {
345
+
346
+ var defaultParams = {
347
+ map: 'world_en',
348
+ backgroundColor: '#a5bfdd',
349
+ color: '#f4f3f0',
350
+ hoverColor: '#c9dfaf',
351
+ hoverColors: {},
352
+ selectedColor: '#c9dfaf',
353
+ scaleColors: ['#b6d6ff', '#005ace'],
354
+ normalizeFunction: 'linear',
355
+ enableZoom: true,
356
+ showTooltip: true,
357
+ borderColor: '#818181',
358
+ borderWidth: 1,
359
+ borderOpacity: 0.25,
360
+ selectedRegions: null,
361
+ multiSelectRegion: false
362
+ }, map = this.data('mapObject');
363
+
364
+ if (options === 'addMap') {
365
+ JQVMap.maps[arguments[1]] = arguments[2];
366
+ } else if (options === 'set' && apiParams[arguments[1]]) {
367
+ map['set' + arguments[1].charAt(0).toUpperCase() + arguments[1].substr(1)].apply(map, Array.prototype.slice.call(arguments, 2));
368
+ } else if (typeof options === 'string' &&
369
+ typeof map[options] === 'function') {
370
+ return map[options].apply(map, Array.prototype.slice.call(arguments, 1));
371
+ } else {
372
+ jQuery.extend(defaultParams, options);
373
+ defaultParams.container = this;
374
+ this.css({ position: 'relative', overflow: 'hidden' });
375
+
376
+ map = new JQVMap(defaultParams);
377
+
378
+ this.data('mapObject', map);
379
+
380
+ this.unbind('.jqvmap');
381
+
382
+ for (var e in apiEvents) {
383
+ if (defaultParams[e]) {
384
+ this.bind(apiEvents[e] + '.jqvmap', defaultParams[e]);
385
+ }
386
+ }
387
+
388
+ var loadEvent = jQuery.Event('load.jqvmap');
389
+ jQuery(defaultParams.container).trigger(loadEvent, map);
390
+
391
+ return map;
392
+ }
393
+ };
394
+
395
+ })(jQuery);
396
+
397
+ ColorScale.arrayToRgb = function (ar) {
398
+ var rgb = '#';
399
+ var d;
400
+ for (var i = 0; i < ar.length; i++) {
401
+ d = ar[i].toString(16);
402
+ rgb += d.length === 1 ? '0' + d : d;
403
+ }
404
+ return rgb;
405
+ };
406
+
407
+ ColorScale.prototype.getColor = function (value) {
408
+ if (typeof this.normalize === 'function') {
409
+ value = this.normalize(value);
410
+ }
411
+
412
+ var lengthes = [];
413
+ var fullLength = 0;
414
+ var l;
415
+
416
+ for (var i = 0; i < this.colors.length - 1; i++) {
417
+ l = this.vectorLength(this.vectorSubtract(this.colors[i + 1], this.colors[i]));
418
+ lengthes.push(l);
419
+ fullLength += l;
420
+ }
421
+
422
+ var c = (this.maxValue - this.minValue) / fullLength;
423
+
424
+ for (i = 0; i < lengthes.length; i++) {
425
+ lengthes[i] *= c;
426
+ }
427
+
428
+ i = 0;
429
+ value -= this.minValue;
430
+
431
+ while (value - lengthes[i] >= 0) {
432
+ value -= lengthes[i];
433
+ i++;
434
+ }
435
+
436
+ var color;
437
+ if (i === this.colors.length - 1) {
438
+ color = this.vectorToNum(this.colors[i]).toString(16);
439
+ } else {
440
+ color = (this.vectorToNum(this.vectorAdd(this.colors[i], this.vectorMult(this.vectorSubtract(this.colors[i + 1], this.colors[i]), (value) / (lengthes[i]))))).toString(16);
441
+ }
442
+
443
+ while (color.length < 6) {
444
+ color = '0' + color;
445
+ }
446
+ return '#' + color;
447
+ };
448
+
449
+ ColorScale.rgbToArray = function (rgb) {
450
+ rgb = rgb.substr(1);
451
+ return [parseInt(rgb.substr(0, 2), 16), parseInt(rgb.substr(2, 2), 16), parseInt(rgb.substr(4, 2), 16)];
452
+ };
453
+
454
+ ColorScale.prototype.setColors = function (colors) {
455
+ for (var i = 0; i < colors.length; i++) {
456
+ colors[i] = ColorScale.rgbToArray(colors[i]);
457
+ }
458
+ this.colors = colors;
459
+ };
460
+
461
+ ColorScale.prototype.setMax = function (max) {
462
+ this.clearMaxValue = max;
463
+ if (typeof this.normalize === 'function') {
464
+ this.maxValue = this.normalize(max);
465
+ } else {
466
+ this.maxValue = max;
467
+ }
468
+ };
469
+
470
+ ColorScale.prototype.setMin = function (min) {
471
+ this.clearMinValue = min;
472
+
473
+ if (typeof this.normalize === 'function') {
474
+ this.minValue = this.normalize(min);
475
+ } else {
476
+ this.minValue = min;
477
+ }
478
+ };
479
+
480
+ ColorScale.prototype.setNormalizeFunction = function (f) {
481
+ if (f === 'polynomial') {
482
+ this.normalize = function (value) {
483
+ return Math.pow(value, 0.2);
484
+ };
485
+ } else if (f === 'linear') {
486
+ delete this.normalize;
487
+ } else {
488
+ this.normalize = f;
489
+ }
490
+ this.setMin(this.clearMinValue);
491
+ this.setMax(this.clearMaxValue);
492
+ };
493
+
494
+ ColorScale.prototype.vectorAdd = function (vector1, vector2) {
495
+ var vector = [];
496
+ for (var i = 0; i < vector1.length; i++) {
497
+ vector[i] = vector1[i] + vector2[i];
498
+ }
499
+ return vector;
500
+ };
501
+
502
+ ColorScale.prototype.vectorLength = function (vector) {
503
+ var result = 0;
504
+ for (var i = 0; i < vector.length; i++) {
505
+ result += vector[i] * vector[i];
506
+ }
507
+ return Math.sqrt(result);
508
+ };
509
+
510
+ ColorScale.prototype.vectorMult = function (vector, num) {
511
+ var result = [];
512
+ for (var i = 0; i < vector.length; i++) {
513
+ result[i] = vector[i] * num;
514
+ }
515
+ return result;
516
+ };
517
+
518
+ ColorScale.prototype.vectorSubtract = function (vector1, vector2) {
519
+ var vector = [];
520
+ for (var i = 0; i < vector1.length; i++) {
521
+ vector[i] = vector1[i] - vector2[i];
522
+ }
523
+ return vector;
524
+ };
525
+
526
+ ColorScale.prototype.vectorToNum = function (vector) {
527
+ var num = 0;
528
+ for (var i = 0; i < vector.length; i++) {
529
+ num += Math.round(vector[i]) * Math.pow(256, vector.length - i - 1);
530
+ }
531
+ return num;
532
+ };
533
+
534
+ JQVMap.prototype.applyTransform = function () {
535
+ var maxTransX, maxTransY, minTransX, minTransY;
536
+ if (this.defaultWidth * this.scale <= this.width) {
537
+ maxTransX = (this.width - this.defaultWidth * this.scale) / (2 * this.scale);
538
+ minTransX = (this.width - this.defaultWidth * this.scale) / (2 * this.scale);
539
+ } else {
540
+ maxTransX = 0;
541
+ minTransX = (this.width - this.defaultWidth * this.scale) / this.scale;
542
+ }
543
+
544
+ if (this.defaultHeight * this.scale <= this.height) {
545
+ maxTransY = (this.height - this.defaultHeight * this.scale) / (2 * this.scale);
546
+ minTransY = (this.height - this.defaultHeight * this.scale) / (2 * this.scale);
547
+ } else {
548
+ maxTransY = 0;
549
+ minTransY = (this.height - this.defaultHeight * this.scale) / this.scale;
550
+ }
551
+
552
+ if (this.transY > maxTransY) {
553
+ this.transY = maxTransY;
554
+ } else if (this.transY < minTransY) {
555
+ this.transY = minTransY;
556
+ }
557
+ if (this.transX > maxTransX) {
558
+ this.transX = maxTransX;
559
+ } else if (this.transX < minTransX) {
560
+ this.transX = minTransX;
561
+ }
562
+
563
+ this.canvas.applyTransformParams(this.scale, this.transX, this.transY);
564
+ };
565
+
566
+ JQVMap.prototype.bindZoomButtons = function () {
567
+ var map = this;
568
+ this.container.find('.jqvmap-zoomin').click(function(){
569
+ map.zoomIn();
570
+ });
571
+ this.container.find('.jqvmap-zoomout').click(function(){
572
+ map.zoomOut();
573
+ });
574
+ };
575
+
576
+ JQVMap.prototype.deselect = function (cc, path) {
577
+ cc = cc.toLowerCase();
578
+ path = path || jQuery('#' + this.getCountryId(cc))[0];
579
+
580
+ if (this.isSelected(cc)) {
581
+ this.selectedRegions.splice(this.selectIndex(cc), 1);
582
+
583
+ jQuery(this.container).trigger('regionDeselect.jqvmap', [cc]);
584
+ path.currentFillColor = path.getOriginalFill();
585
+ path.setFill(path.getOriginalFill());
586
+ } else {
587
+ for (var key in this.countries) {
588
+ this.selectedRegions.splice(this.selectedRegions.indexOf(key), 1);
589
+ this.countries[key].currentFillColor = this.color;
590
+ this.countries[key].setFill(this.color);
591
+ }
592
+ }
593
+ };
594
+
595
+ JQVMap.prototype.getCountryId = function (cc) {
596
+ return 'jqvmap' + this.index + '_' + cc;
597
+ };
598
+
599
+ JQVMap.prototype.getPin = function(cc){
600
+ var pinObj = jQuery('#' + this.getPinId(cc));
601
+ return pinObj.html();
602
+ };
603
+
604
+ JQVMap.prototype.getPinId = function (cc) {
605
+ return this.getCountryId(cc) + '_pin';
606
+ };
607
+
608
+ JQVMap.prototype.getPins = function(){
609
+ var pins = this.container.find('.jqvmap-pin');
610
+ var ret = {};
611
+ jQuery.each(pins, function(index, pinObj){
612
+ pinObj = jQuery(pinObj);
613
+ var cc = pinObj.attr('for').toLowerCase();
614
+ var pinContent = pinObj.html();
615
+ ret[cc] = pinContent;
616
+ });
617
+ return JSON.stringify(ret);
618
+ };
619
+
620
+ JQVMap.prototype.highlight = function (cc, path) {
621
+ path = path || jQuery('#' + this.getCountryId(cc))[0];
622
+ if (this.hoverOpacity) {
623
+ path.setOpacity(this.hoverOpacity);
624
+ } else if (this.hoverColors && (cc in this.hoverColors)) {
625
+ path.currentFillColor = path.getFill() + '';
626
+ path.setFill(this.hoverColors[cc]);
627
+ } else if (this.hoverColor) {
628
+ path.currentFillColor = path.getFill() + '';
629
+ path.setFill(this.hoverColor);
630
+ }
631
+ };
632
+
633
+ JQVMap.prototype.isSelected = function(cc) {
634
+ return this.selectIndex(cc) >= 0;
635
+ };
636
+
637
+ JQVMap.prototype.makeDraggable = function () {
638
+ var mouseDown = false;
639
+ var oldPageX, oldPageY;
640
+ var self = this;
641
+
642
+ self.isMoving = false;
643
+ self.isMovingTimeout = false;
644
+
645
+ var lastTouchCount;
646
+ var touchCenterX;
647
+ var touchCenterY;
648
+ var touchStartDistance;
649
+ var touchStartScale;
650
+ var touchX;
651
+ var touchY;
652
+
653
+ this.container.mousemove(function (e) {
654
+
655
+ if (mouseDown) {
656
+ self.transX -= (oldPageX - e.pageX) / self.scale;
657
+ self.transY -= (oldPageY - e.pageY) / self.scale;
658
+
659
+ self.applyTransform();
660
+
661
+ oldPageX = e.pageX;
662
+ oldPageY = e.pageY;
663
+
664
+ self.isMoving = true;
665
+ if (self.isMovingTimeout) {
666
+ clearTimeout(self.isMovingTimeout);
667
+ }
668
+
669
+ self.container.trigger('drag');
670
+ }
671
+
672
+ return false;
673
+
674
+ }).mousedown(function (e) {
675
+
676
+ mouseDown = true;
677
+ oldPageX = e.pageX;
678
+ oldPageY = e.pageY;
679
+
680
+ return false;
681
+
682
+ }).mouseup(function () {
683
+
684
+ mouseDown = false;
685
+
686
+ clearTimeout(self.isMovingTimeout);
687
+ self.isMovingTimeout = setTimeout(function () {
688
+ self.isMoving = false;
689
+ }, 100);
690
+
691
+ return false;
692
+
693
+ }).mouseout(function () {
694
+
695
+ if(mouseDown && self.isMoving){
696
+
697
+ clearTimeout(self.isMovingTimeout);
698
+ self.isMovingTimeout = setTimeout(function () {
699
+ mouseDown = false;
700
+ self.isMoving = false;
701
+ }, 100);
702
+
703
+ return false;
704
+ }
705
+ });
706
+
707
+ jQuery(this.container).bind('touchmove', function (e) {
708
+
709
+ var offset;
710
+ var scale;
711
+ var touches = e.originalEvent.touches;
712
+ var transformXOld;
713
+ var transformYOld;
714
+
715
+ if (touches.length === 1) {
716
+ if (lastTouchCount === 1) {
717
+
718
+ if(touchX === touches[0].pageX && touchY === touches[0].pageY){
719
+ return;
720
+ }
721
+
722
+ transformXOld = self.transX;
723
+ transformYOld = self.transY;
724
+
725
+ self.transX -= (touchX - touches[0].pageX) / self.scale;
726
+ self.transY -= (touchY - touches[0].pageY) / self.scale;
727
+
728
+ self.applyTransform();
729
+
730
+ if (transformXOld !== self.transX || transformYOld !== self.transY) {
731
+ e.preventDefault();
732
+ }
733
+
734
+ self.isMoving = true;
735
+ if (self.isMovingTimeout) {
736
+ clearTimeout(self.isMovingTimeout);
737
+ }
738
+ }
739
+
740
+ touchX = touches[0].pageX;
741
+ touchY = touches[0].pageY;
742
+
743
+ } else if (touches.length === 2) {
744
+
745
+ if (lastTouchCount === 2) {
746
+ scale = Math.sqrt(
747
+ Math.pow(touches[0].pageX - touches[1].pageX, 2) +
748
+ Math.pow(touches[0].pageY - touches[1].pageY, 2)
749
+ ) / touchStartDistance;
750
+
751
+ self.setScale(
752
+ touchStartScale * scale,
753
+ touchCenterX,
754
+ touchCenterY
755
+ );
756
+
757
+ e.preventDefault();
758
+
759
+ } else {
760
+
761
+ offset = jQuery(self.container).offset();
762
+ if (touches[0].pageX > touches[1].pageX) {
763
+ touchCenterX = touches[1].pageX + (touches[0].pageX - touches[1].pageX) / 2;
764
+ } else {
765
+ touchCenterX = touches[0].pageX + (touches[1].pageX - touches[0].pageX) / 2;
766
+ }
767
+
768
+ if (touches[0].pageY > touches[1].pageY) {
769
+ touchCenterY = touches[1].pageY + (touches[0].pageY - touches[1].pageY) / 2;
770
+ } else {
771
+ touchCenterY = touches[0].pageY + (touches[1].pageY - touches[0].pageY) / 2;
772
+ }
773
+
774
+ touchCenterX -= offset.left;
775
+ touchCenterY -= offset.top;
776
+ touchStartScale = self.scale;
777
+
778
+ touchStartDistance = Math.sqrt(
779
+ Math.pow(touches[0].pageX - touches[1].pageX, 2) +
780
+ Math.pow(touches[0].pageY - touches[1].pageY, 2)
781
+ );
782
+ }
783
+ }
784
+
785
+ lastTouchCount = touches.length;
786
+ });
787
+
788
+ jQuery(this.container).bind('touchstart', function () {
789
+ lastTouchCount = 0;
790
+ });
791
+
792
+ jQuery(this.container).bind('touchend', function () {
793
+ lastTouchCount = 0;
794
+ });
795
+ };
796
+
797
+ JQVMap.prototype.placePins = function(pins, pinMode){
798
+ var map = this;
799
+
800
+ if(!pinMode || (pinMode !== 'content' && pinMode !== 'id')) {
801
+ pinMode = 'content';
802
+ }
803
+
804
+ if(pinMode === 'content') {//treat pin as content
805
+ jQuery.each(pins, function(index, pin){
806
+ if(jQuery('#' + map.getCountryId(index)).length === 0){
807
+ return;
808
+ }
809
+
810
+ var pinIndex = map.getPinId(index);
811
+ var $pin = jQuery('#' + pinIndex);
812
+ if($pin.length > 0){
813
+ $pin.remove();
814
+ }
815
+ map.container.append('<div id="' + pinIndex + '" for="' + index + '" class="jqvmap-pin" style="position:absolute">' + pin + '</div>');
816
+ });
817
+ } else { //treat pin as id of an html content
818
+ jQuery.each(pins, function(index, pin){
819
+ if(jQuery('#' + map.getCountryId(index)).length === 0){
820
+ return;
821
+ }
822
+ var pinIndex = map.getPinId(index);
823
+ var $pin = jQuery('#' + pinIndex);
824
+ if($pin.length > 0){
825
+ $pin.remove();
826
+ }
827
+ map.container.append('<div id="' + pinIndex + '" for="' + index + '" class="jqvmap-pin" style="position:absolute"></div>');
828
+ $pin.append(jQuery('#' + pin));
829
+ });
830
+ }
831
+
832
+ this.positionPins();
833
+ if(!this.pinHandlers){
834
+ this.pinHandlers = true;
835
+ var positionFix = function(){
836
+ map.positionPins();
837
+ };
838
+ this.container.bind('zoomIn', positionFix)
839
+ .bind('zoomOut', positionFix)
840
+ .bind('drag', positionFix);
841
+ }
842
+ };
843
+
844
+ JQVMap.prototype.positionPins = function(){
845
+ var map = this;
846
+ var pins = this.container.find('.jqvmap-pin');
847
+ jQuery.each(pins, function(index, pinObj){
848
+ pinObj = jQuery(pinObj);
849
+ var countryId = map.getCountryId(pinObj.attr('for').toLowerCase());
850
+ var countryObj = jQuery('#' + countryId);
851
+
852
+ var bbox = document.getElementById(countryId).getBBox();
853
+ var position = countryObj.position();
854
+
855
+ var scale = map.scale;
856
+
857
+ var left = position.left + (bbox.width / 2) * scale - pinObj.width() / 2,
858
+ top = position.top + (bbox.height / 2) * scale - pinObj.height() / 2;
859
+
860
+ pinObj.css('left', left).css('top', top);
861
+ });
862
+ };
863
+
864
+ JQVMap.prototype.removePin = function(cc) {
865
+ cc = cc.toLowerCase();
866
+ jQuery('#' + this.getPinId(cc)).remove();
867
+ };
868
+
869
+ JQVMap.prototype.removePins = function(){
870
+ this.container.find('.jqvmap-pin').remove();
871
+ };
872
+
873
+ JQVMap.prototype.reset = function () {
874
+ for (var key in this.countries) {
875
+ this.countries[key].setFill(this.color);
876
+ }
877
+ this.scale = this.baseScale;
878
+ this.transX = this.baseTransX;
879
+ this.transY = this.baseTransY;
880
+ this.applyTransform();
881
+ };
882
+
883
+ JQVMap.prototype.resize = function () {
884
+ var curBaseScale = this.baseScale;
885
+ if (this.width / this.height > this.defaultWidth / this.defaultHeight) {
886
+ this.baseScale = this.height / this.defaultHeight;
887
+ this.baseTransX = Math.abs(this.width - this.defaultWidth * this.baseScale) / (2 * this.baseScale);
888
+ } else {
889
+ this.baseScale = this.width / this.defaultWidth;
890
+ this.baseTransY = Math.abs(this.height - this.defaultHeight * this.baseScale) / (2 * this.baseScale);
891
+ }
892
+ this.scale *= this.baseScale / curBaseScale;
893
+ this.transX *= this.baseScale / curBaseScale;
894
+ this.transY *= this.baseScale / curBaseScale;
895
+ };
896
+
897
+ JQVMap.prototype.select = function (cc, path) {
898
+ cc = cc.toLowerCase();
899
+ path = path || jQuery('#' + this.getCountryId(cc))[0];
900
+
901
+ if (!this.isSelected(cc)) {
902
+ if (this.multiSelectRegion) {
903
+ this.selectedRegions.push(cc);
904
+ } else {
905
+ this.selectedRegions = [cc];
906
+ }
907
+
908
+ jQuery(this.container).trigger('regionSelect.jqvmap', [cc]);
909
+ if (this.selectedColor && path) {
910
+ path.currentFillColor = this.selectedColor;
911
+ path.setFill(this.selectedColor);
912
+ }
913
+ }
914
+ };
915
+
916
+ JQVMap.prototype.selectIndex = function (cc) {
917
+ cc = cc.toLowerCase();
918
+ for (var i = 0; i < this.selectedRegions.length; i++) {
919
+ if (cc === this.selectedRegions[i]) {
920
+ return i;
921
+ }
922
+ }
923
+ return -1;
924
+ };
925
+
926
+ JQVMap.prototype.setBackgroundColor = function (backgroundColor) {
927
+ this.container.css('background-color', backgroundColor);
928
+ };
929
+
930
+ JQVMap.prototype.setColors = function (key, color) {
931
+ if (typeof key === 'string') {
932
+ this.countries[key].setFill(color);
933
+ this.countries[key].setAttribute('original', color);
934
+ } else {
935
+ var colors = key;
936
+
937
+ for (var code in colors) {
938
+ if (this.countries[code]) {
939
+ this.countries[code].setFill(colors[code]);
940
+ this.countries[code].setAttribute('original', colors[code]);
941
+ }
942
+ }
943
+ }
944
+ };
945
+
946
+ JQVMap.prototype.setNormalizeFunction = function (f) {
947
+ this.colorScale.setNormalizeFunction(f);
948
+
949
+ if (this.values) {
950
+ this.setValues(this.values);
951
+ }
952
+ };
953
+
954
+ JQVMap.prototype.setScale = function (scale) {
955
+ this.scale = scale;
956
+ this.applyTransform();
957
+ };
958
+
959
+ JQVMap.prototype.setScaleColors = function (colors) {
960
+ this.colorScale.setColors(colors);
961
+
962
+ if (this.values) {
963
+ this.setValues(this.values);
964
+ }
965
+ };
966
+
967
+ JQVMap.prototype.setValues = function (values) {
968
+ var max = 0,
969
+ min = Number.MAX_VALUE,
970
+ val;
971
+
972
+ for (var cc in values) {
973
+ cc = cc.toLowerCase();
974
+ val = parseFloat(values[cc]);
975
+
976
+ if (isNaN(val)) {
977
+ continue;
978
+ }
979
+ if (val > max) {
980
+ max = values[cc];
981
+ }
982
+ if (val < min) {
983
+ min = val;
984
+ }
985
+ }
986
+
987
+ if (min === max) {
988
+ max++;
989
+ }
990
+
991
+ this.colorScale.setMin(min);
992
+ this.colorScale.setMax(max);
993
+
994
+ var colors = {};
995
+ for (cc in values) {
996
+ cc = cc.toLowerCase();
997
+ val = parseFloat(values[cc]);
998
+ colors[cc] = isNaN(val) ? this.color : this.colorScale.getColor(val);
999
+ }
1000
+ this.setColors(colors);
1001
+ this.values = values;
1002
+ };
1003
+
1004
+ JQVMap.prototype.unhighlight = function (cc, path) {
1005
+ cc = cc.toLowerCase();
1006
+ path = path || jQuery('#' + this.getCountryId(cc))[0];
1007
+ path.setOpacity(1);
1008
+ if (path.currentFillColor) {
1009
+ path.setFill(path.currentFillColor);
1010
+ }
1011
+ };
1012
+
1013
+ JQVMap.prototype.zoomIn = function () {
1014
+ var map = this;
1015
+ var sliderDelta = (jQuery('#zoom').innerHeight() - 6 * 2 - 15 * 2 - 3 * 2 - 7 - 6) / (this.zoomMaxStep - this.zoomCurStep);
1016
+
1017
+ if (map.zoomCurStep < map.zoomMaxStep) {
1018
+ map.transX -= (map.width / map.scale - map.width / (map.scale * map.zoomStep)) / 2;
1019
+ map.transY -= (map.height / map.scale - map.height / (map.scale * map.zoomStep)) / 2;
1020
+ map.setScale(map.scale * map.zoomStep);
1021
+ map.zoomCurStep++;
1022
+
1023
+ var $slider = jQuery('#zoomSlider');
1024
+
1025
+ $slider.css('top', parseInt($slider.css('top'), 10) - sliderDelta);
1026
+
1027
+ map.container.trigger('zoomIn');
1028
+ }
1029
+ };
1030
+
1031
+ JQVMap.prototype.zoomOut = function () {
1032
+ var map = this;
1033
+ var sliderDelta = (jQuery('#zoom').innerHeight() - 6 * 2 - 15 * 2 - 3 * 2 - 7 - 6) / (this.zoomMaxStep - this.zoomCurStep);
1034
+
1035
+ if (map.zoomCurStep > 1) {
1036
+ map.transX += (map.width / (map.scale / map.zoomStep) - map.width / map.scale) / 2;
1037
+ map.transY += (map.height / (map.scale / map.zoomStep) - map.height / map.scale) / 2;
1038
+ map.setScale(map.scale / map.zoomStep);
1039
+ map.zoomCurStep--;
1040
+
1041
+ var $slider = jQuery('#zoomSlider');
1042
+
1043
+ $slider.css('top', parseInt($slider.css('top'), 10) + sliderDelta);
1044
+
1045
+ map.container.trigger('zoomOut');
1046
+ }
1047
+ };
1048
+
1049
+ VectorCanvas.prototype.applyTransformParams = function (scale, transX, transY) {
1050
+ if (this.mode === 'svg') {
1051
+ this.rootGroup.setAttribute('transform', 'scale(' + scale + ') translate(' + transX + ', ' + transY + ')');
1052
+ } else {
1053
+ this.rootGroup.coordorigin = (this.width - transX) + ',' + (this.height - transY);
1054
+ this.rootGroup.coordsize = this.width / scale + ',' + this.height / scale;
1055
+ }
1056
+ };
1057
+
1058
+ VectorCanvas.prototype.createGroup = function (isRoot) {
1059
+ var node;
1060
+ if (this.mode === 'svg') {
1061
+ node = this.createSvgNode('g');
1062
+ } else {
1063
+ node = this.createVmlNode('group');
1064
+ node.style.width = this.width + 'px';
1065
+ node.style.height = this.height + 'px';
1066
+ node.style.left = '0px';
1067
+ node.style.top = '0px';
1068
+ node.coordorigin = '0 0';
1069
+ node.coordsize = this.width + ' ' + this.height;
1070
+ }
1071
+
1072
+ if (isRoot) {
1073
+ this.rootGroup = node;
1074
+ }
1075
+ return node;
1076
+ };
1077
+
1078
+ VectorCanvas.prototype.createPath = function (config) {
1079
+ var node;
1080
+ if (this.mode === 'svg') {
1081
+ node = this.createSvgNode('path');
1082
+ node.setAttribute('d', config.path);
1083
+
1084
+ if (this.params.borderColor !== null) {
1085
+ node.setAttribute('stroke', this.params.borderColor);
1086
+ }
1087
+ if (this.params.borderWidth > 0) {
1088
+ node.setAttribute('stroke-width', this.params.borderWidth);
1089
+ node.setAttribute('stroke-linecap', 'round');
1090
+ node.setAttribute('stroke-linejoin', 'round');
1091
+ }
1092
+ if (this.params.borderOpacity > 0) {
1093
+ node.setAttribute('stroke-opacity', this.params.borderOpacity);
1094
+ }
1095
+
1096
+ node.setFill = function (color) {
1097
+ this.setAttribute('fill', color);
1098
+ if (this.getAttribute('original') === null) {
1099
+ this.setAttribute('original', color);
1100
+ }
1101
+ };
1102
+
1103
+ node.getFill = function () {
1104
+ return this.getAttribute('fill');
1105
+ };
1106
+
1107
+ node.getOriginalFill = function () {
1108
+ return this.getAttribute('original');
1109
+ };
1110
+
1111
+ node.setOpacity = function (opacity) {
1112
+ this.setAttribute('fill-opacity', opacity);
1113
+ };
1114
+ } else {
1115
+ node = this.createVmlNode('shape');
1116
+ node.coordorigin = '0 0';
1117
+ node.coordsize = this.width + ' ' + this.height;
1118
+ node.style.width = this.width + 'px';
1119
+ node.style.height = this.height + 'px';
1120
+ node.fillcolor = JQVMap.defaultFillColor;
1121
+ node.stroked = false;
1122
+ node.path = VectorCanvas.pathSvgToVml(config.path);
1123
+
1124
+ var scale = this.createVmlNode('skew');
1125
+ scale.on = true;
1126
+ scale.matrix = '0.01,0,0,0.01,0,0';
1127
+ scale.offset = '0,0';
1128
+
1129
+ node.appendChild(scale);
1130
+
1131
+ var fill = this.createVmlNode('fill');
1132
+ node.appendChild(fill);
1133
+
1134
+ node.setFill = function (color) {
1135
+ this.getElementsByTagName('fill')[0].color = color;
1136
+ if (this.getAttribute('original') === null) {
1137
+ this.setAttribute('original', color);
1138
+ }
1139
+ };
1140
+
1141
+ node.getFill = function () {
1142
+ return this.getElementsByTagName('fill')[0].color;
1143
+ };
1144
+ node.getOriginalFill = function () {
1145
+ return this.getAttribute('original');
1146
+ };
1147
+ node.setOpacity = function (opacity) {
1148
+ this.getElementsByTagName('fill')[0].opacity = parseInt(opacity * 100, 10) + '%';
1149
+ };
1150
+ }
1151
+ return node;
1152
+ };
1153
+
1154
+ VectorCanvas.prototype.pathSvgToVml = function (path) {
1155
+ var result = '';
1156
+ var cx = 0, cy = 0, ctrlx, ctrly;
1157
+
1158
+ return path.replace(/([MmLlHhVvCcSs])((?:-?(?:\d+)?(?:\.\d+)?,?\s?)+)/g, function (segment, letter, coords) {
1159
+ coords = coords.replace(/(\d)-/g, '$1,-').replace(/\s+/g, ',').split(',');
1160
+ if (!coords[0]) {
1161
+ coords.shift();
1162
+ }
1163
+
1164
+ for (var i = 0, l = coords.length; i < l; i++) {
1165
+ coords[i] = Math.round(100 * coords[i]);
1166
+ }
1167
+
1168
+ switch (letter) {
1169
+ case 'm':
1170
+ cx += coords[0];
1171
+ cy += coords[1];
1172
+ result = 't' + coords.join(',');
1173
+ break;
1174
+
1175
+ case 'M':
1176
+ cx = coords[0];
1177
+ cy = coords[1];
1178
+ result = 'm' + coords.join(',');
1179
+ break;
1180
+
1181
+ case 'l':
1182
+ cx += coords[0];
1183
+ cy += coords[1];
1184
+ result = 'r' + coords.join(',');
1185
+ break;
1186
+
1187
+ case 'L':
1188
+ cx = coords[0];
1189
+ cy = coords[1];
1190
+ result = 'l' + coords.join(',');
1191
+ break;
1192
+
1193
+ case 'h':
1194
+ cx += coords[0];
1195
+ result = 'r' + coords[0] + ',0';
1196
+ break;
1197
+
1198
+ case 'H':
1199
+ cx = coords[0];
1200
+ result = 'l' + cx + ',' + cy;
1201
+ break;
1202
+
1203
+ case 'v':
1204
+ cy += coords[0];
1205
+ result = 'r0,' + coords[0];
1206
+ break;
1207
+
1208
+ case 'V':
1209
+ cy = coords[0];
1210
+ result = 'l' + cx + ',' + cy;
1211
+ break;
1212
+
1213
+ case 'c':
1214
+ ctrlx = cx + coords[coords.length - 4];
1215
+ ctrly = cy + coords[coords.length - 3];
1216
+ cx += coords[coords.length - 2];
1217
+ cy += coords[coords.length - 1];
1218
+ result = 'v' + coords.join(',');
1219
+ break;
1220
+
1221
+ case 'C':
1222
+ ctrlx = coords[coords.length - 4];
1223
+ ctrly = coords[coords.length - 3];
1224
+ cx = coords[coords.length - 2];
1225
+ cy = coords[coords.length - 1];
1226
+ result = 'c' + coords.join(',');
1227
+ break;
1228
+
1229
+ case 's':
1230
+ coords.unshift(cy - ctrly);
1231
+ coords.unshift(cx - ctrlx);
1232
+ ctrlx = cx + coords[coords.length - 4];
1233
+ ctrly = cy + coords[coords.length - 3];
1234
+ cx += coords[coords.length - 2];
1235
+ cy += coords[coords.length - 1];
1236
+ result = 'v' + coords.join(',');
1237
+ break;
1238
+
1239
+ case 'S':
1240
+ coords.unshift(cy + cy - ctrly);
1241
+ coords.unshift(cx + cx - ctrlx);
1242
+ ctrlx = coords[coords.length - 4];
1243
+ ctrly = coords[coords.length - 3];
1244
+ cx = coords[coords.length - 2];
1245
+ cy = coords[coords.length - 1];
1246
+ result = 'c' + coords.join(',');
1247
+ break;
1248
+
1249
+ default:
1250
+ break;
1251
+ }
1252
+
1253
+ return result;
1254
+
1255
+ }).replace(/z/g, '');
1256
+ };
1257
+
1258
+ VectorCanvas.prototype.setSize = function (width, height) {
1259
+ if (this.mode === 'svg') {
1260
+ this.canvas.setAttribute('width', width);
1261
+ this.canvas.setAttribute('height', height);
1262
+ } else {
1263
+ this.canvas.style.width = width + 'px';
1264
+ this.canvas.style.height = height + 'px';
1265
+ this.canvas.coordsize = width + ' ' + height;
1266
+ this.canvas.coordorigin = '0 0';
1267
+ if (this.rootGroup) {
1268
+ var paths = this.rootGroup.getElementsByTagName('shape');
1269
+ for (var i = 0, l = paths.length; i < l; i++) {
1270
+ paths[i].coordsize = width + ' ' + height;
1271
+ paths[i].style.width = width + 'px';
1272
+ paths[i].style.height = height + 'px';
1273
+ }
1274
+ this.rootGroup.coordsize = width + ' ' + height;
1275
+ this.rootGroup.style.width = width + 'px';
1276
+ this.rootGroup.style.height = height + 'px';
1277
+ }
1278
+ }
1279
+ this.width = width;
1280
+ this.height = height;
1281
+ };