init.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. $(document).ready(function(){
  2. if($('.body-login')[0]){
  3. $('input').first().focus();
  4. }
  5. $(".submenu-select-dropdown").each(function(){
  6. $(this).wrap("<span class='submenu-select-wrapper'></span>");
  7. $(this).after("<span class='holder'></span>");
  8. });
  9. $(".submenu-select-dropdown").change(function(){
  10. var selectedOption = $(this).find(":selected").text();
  11. $(this).next(".holder").text(selectedOption);
  12. }).trigger('change');
  13. $('.to-top').on('click', function(evt) {
  14. $("html, body").animate({ scrollTop: 0 }, "normal");
  15. });
  16. $('.ui-button').on('click',function(evt){
  17. var action = $(this).data('action');
  18. var id = $(this).data('id');
  19. if(action=='submit' && document.getElementById(id)){
  20. evt.preventDefault();
  21. $(document.getElementById(id)).submit();
  22. }
  23. });
  24. var isMobile = false; //initiate as false
  25. // device detection
  26. if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
  27. || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4))){
  28. isMobile = true;
  29. $('body').addClass('mobile');
  30. }
  31. $(window).scroll(function(){hover_menu()});
  32. $('.l-sort-toolbar .sort-by').click(function(){
  33. $('.context-menu.sort-order').toggle().css({left: $(this).position().left - 0});
  34. });
  35. // CREATE BUTTON
  36. $('.l-sort__create-btn').hover(function(){
  37. $(".l-sort__create-btn").append("<div id='add-icon'></div>");
  38. $(".l-sort__create-btn").append("<div id='tooltip'>"+$('.l-sort__create-btn').attr('title').replace(' ','&nbsp;')+"</div>");
  39. }, function(){
  40. $("#add-icon").remove();
  41. $("#tooltip").remove();
  42. });
  43. // SEARCH BOX
  44. $('.l-sort-toolbar__search, .l-sort-toolbar__search-box .search-input').hover(function(){
  45. clearTimeout(VE.tmp.search_display_interval);
  46. clearTimeout(VE.tmp.search_hover_interval);
  47. VE.tmp.search_display_interval = setTimeout(function(){$('.search-input').addClass('activated');}, 150);
  48. }, function(){
  49. clearTimeout(VE.tmp.search_display_interval);
  50. clearTimeout(VE.tmp.search_hover_interval);
  51. VE.tmp.search_hover_interval = setTimeout(function(){
  52. if(!VE.tmp.search_activated && !$(".search-input").val().length){
  53. $(".search-input").removeClass('activated');
  54. }
  55. }, 600);
  56. });
  57. $('.search-input').focus(function(){
  58. VE.tmp.search_activated = 1;
  59. clearTimeout(VE.tmp.search_hover_interval);
  60. });
  61. $('.search-input').blur(function(){
  62. VE.tmp.search_activated = 0;
  63. clearTimeout(VE.tmp.search_hover_interval);
  64. VE.tmp.search_hover_interval = setTimeout(function(){
  65. if(!$(".search-input").val().length){
  66. $(".search-input").removeClass('activated');
  67. }
  68. }, 600);
  69. });
  70. // TIMER
  71. if($('.movement.left').length){
  72. VE.helpers.refresh_timer.right = $('.movement.right');
  73. VE.helpers.refresh_timer.left = $('.movement.left');
  74. VE.helpers.refresh_timer.start();
  75. $('.pause').click(function(){
  76. VE.helpers.refresh_timer.stop();
  77. $('.pause').addClass('hidden');
  78. $('.play').removeClass('hidden');
  79. $('.refresh-timer').addClass('paused');
  80. });
  81. $('.play').click(function(){
  82. VE.helpers.refresh_timer.start();
  83. $('.pause').removeClass('hidden');
  84. $('.play').addClass('hidden');
  85. $('.refresh-timer').removeClass('paused');
  86. });
  87. }
  88. // SORTING
  89. $('#vstobjects input, #vstobjects select, #vstobjects textarea').change(function(){VE.tmp.form_changed=1});
  90. $('.sort-order span').click(function(){
  91. $('.context-menu.sort-order').toggle();
  92. if($(this).hasClass('active'))
  93. return;
  94. $('.sort-order span').removeClass('active');
  95. $(this).addClass('active');
  96. VE.tmp.sort_par = $(this).parent('li').attr('entity');
  97. VE.tmp.sort_as_int = $(this).parent('li').attr('sort_as_int');
  98. VE.tmp.sort_direction = $(this).hasClass('up')*1 || -1;
  99. $('.l-sort .sort-by span b').html($(this).parent('li').find('.name').html());
  100. $('.l-sort .sort-by i').removeClass('fa-sort-alpha-up fa-sort-alpha-down');
  101. $(this).hasClass('up') ? $('.l-sort .sort-by i').addClass('fa-sort-alpha-up') : $('.l-sort .sort-by i').addClass('fa-sort-alpha-down');
  102. $('.units .l-unit').sort(function (a, b) {
  103. if(VE.tmp.sort_as_int)
  104. return parseInt($(a).attr(VE.tmp.sort_par)) >= parseInt($(b).attr(VE.tmp.sort_par)) ? VE.tmp.sort_direction : VE.tmp.sort_direction * -1;
  105. else
  106. return $(a).attr(VE.tmp.sort_par) <= $(b).attr(VE.tmp.sort_par) ? VE.tmp.sort_direction : VE.tmp.sort_direction * -1;
  107. }).appendTo(".l-center.units");
  108. });
  109. if(document.getElementById('default-sort')){
  110. document.getElementById('default-sort').click();
  111. $('.context-menu.sort-order').toggle();
  112. };
  113. $('#objects').submit( function (e){
  114. if(!e.originalEvent){
  115. return;
  116. }
  117. e.preventDefault();
  118. $('.ch-toggle').each( function (){
  119. if($(this).prop('checked')){
  120. key=this.name;
  121. div=$('<input type="hidden" name="'+key+'[]" value="'+this.value+'"/>');
  122. $('#objects').append(div);
  123. }
  124. });
  125. $('#objects').submit();
  126. return true;
  127. });
  128. // Shortcuts
  129. shortcut.add("Ctrl+Enter", function(){
  130. $('form#vstobjects').submit();
  131. }, {
  132. 'type': 'keydown',
  133. 'propagate': false,
  134. 'disable_in_input': false,
  135. 'target': document
  136. }
  137. );
  138. shortcut.add("Ctrl+Backspace", function(){
  139. var redirect = $('a.ui-button#btn-back').attr('href')
  140. if(VE.tmp.form_changed && redirect){
  141. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', redirect);
  142. } else if($('form#vstobjects .button.cancel')[0]){
  143. location.href=$('form#vstobjects input.cancel').attr('onclick').replace("location.href='", "").replace("'","");
  144. } else if(redirect){
  145. location.href = redirect;
  146. }
  147. }, {
  148. 'type': 'keydown',
  149. 'propagate': false,
  150. 'disable_in_input': false,
  151. 'target': document
  152. }
  153. );
  154. shortcut.add("f", function(){
  155. $('.search-input').addClass('activated').focus();
  156. }, {
  157. 'type': 'keydown',
  158. 'propagate': false,
  159. 'disable_in_input': true,
  160. 'target': document
  161. }
  162. );
  163. $(window).on('keypress', function(evt) {
  164. var tag = evt.target.tagName.toLowerCase();
  165. if (evt.charCode == 97 && tag != 'input' && tag != 'textarea' && tag != 'selectbox') {
  166. evt.preventDefault();
  167. if (!evt.ctrlKey && !evt.shiftKey) {
  168. //if ($('.l-sort__create-btn')[0]) {
  169. if ($('.ui-button#btn-create').length) {
  170. location.href=$('.ui-button#btn-create').attr('href');
  171. }
  172. }
  173. else {
  174. if ($('.l-unit .ch-toggle:eq(0)').attr('checked')) {
  175. $('.l-unit').removeClass('selected');
  176. $('.l-unit .ch-toggle').prop('checked', false);
  177. }
  178. else {
  179. $('.l-unit').addClass('selected');
  180. $('.l-unit .ch-toggle').prop('checked', true);
  181. }
  182. }
  183. }
  184. });
  185. shortcut.add("1", function(){
  186. var target = $('.l-stat .l-stat__col:nth-of-type(1) a')
  187. if(target.length != 1){
  188. return;
  189. }
  190. if(VE.tmp.form_changed){
  191. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', target.attr('href'));
  192. } else {
  193. location.href=target.attr('href');
  194. }
  195. }, {
  196. 'type': 'keydown',
  197. 'propagate': false,
  198. 'disable_in_input': true,
  199. 'target': document
  200. }
  201. );
  202. shortcut.add("2", function(){
  203. var target = $('.l-stat .l-stat__col:nth-of-type(2) a')
  204. if(target.length != 1){
  205. return;
  206. }
  207. if(VE.tmp.form_changed){
  208. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', target.attr('href'));
  209. } else {
  210. location.href=target.attr('href');
  211. }
  212. }, {
  213. 'type': 'keydown',
  214. 'propagate': false,
  215. 'disable_in_input': true,
  216. 'target': document
  217. }
  218. );
  219. shortcut.add("3", function(){
  220. var target = $('.l-stat .l-stat__col:nth-of-type(3) a')
  221. if(target.length != 1){
  222. return;
  223. }
  224. if(VE.tmp.form_changed){
  225. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', target.attr('href'));
  226. } else {
  227. location.href=target.attr('href');
  228. }
  229. }, {
  230. 'type': 'keydown',
  231. 'propagate': false,
  232. 'disable_in_input': true,
  233. 'target': document
  234. }
  235. );
  236. shortcut.add("4", function(){
  237. var target = $('.l-stat .l-stat__col:nth-of-type(4) a')
  238. if(target.length != 1){
  239. return;
  240. }
  241. if(VE.tmp.form_changed){
  242. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', target.attr('href'));
  243. } else {
  244. location.href=target.attr('href');
  245. }
  246. }, {
  247. 'type': 'keydown',
  248. 'propagate': false,
  249. 'disable_in_input': true,
  250. 'target': document
  251. }
  252. );
  253. shortcut.add("5", function(){
  254. var target = $('.l-stat .l-stat__col:nth-of-type(5) a')
  255. if(target.length != 1){
  256. return;
  257. }
  258. if(VE.tmp.form_changed){
  259. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', target.attr('href'));
  260. } else {
  261. location.href=target.attr('href');
  262. }
  263. }, {
  264. 'type': 'keydown',
  265. 'propagate': false,
  266. 'disable_in_input': true,
  267. 'target': document
  268. }
  269. );
  270. shortcut.add("6", function(){
  271. var target = $('.l-stat .l-stat__col:nth-of-type(6) a')
  272. if(target.length != 1){
  273. return;
  274. }
  275. if(VE.tmp.form_changed){
  276. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', target.attr('href'));
  277. } else {
  278. location.href=target.attr('href');
  279. }
  280. }, {
  281. 'type': 'keydown',
  282. 'propagate': false,
  283. 'disable_in_input': true,
  284. 'target': document
  285. }
  286. );
  287. shortcut.add("7", function(){
  288. var target = $('.l-stat .l-stat__col:nth-of-type(7) a')
  289. if(target.length != 1){
  290. return;
  291. }
  292. if(VE.tmp.form_changed){
  293. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', target.attr('href'));
  294. } else {
  295. location.href=target.attr('href');
  296. }
  297. }, {
  298. 'type': 'keydown',
  299. 'propagate': false,
  300. 'disable_in_input': true,
  301. 'target': document
  302. }
  303. );
  304. shortcut.add("h", function(){
  305. $('.shortcuts').toggle();
  306. }, {
  307. 'type': 'keydown',
  308. 'propagate': false,
  309. 'disable_in_input': true,
  310. 'target': document
  311. }
  312. );
  313. shortcut.add("Esc", function(){
  314. $('.shortcuts').hide();
  315. $('input, checkbox, textarea, select').blur();
  316. }, {
  317. 'type': 'keydown',
  318. 'propagate': false,
  319. 'disable_in_input': false,
  320. 'target': document
  321. }
  322. );
  323. shortcut.add("Left", function(){
  324. VE.navigation.move_focus_left();
  325. }, {
  326. 'type': 'keydown',
  327. 'propagate': false,
  328. 'disable_in_input': true,
  329. 'target': document
  330. }
  331. );
  332. shortcut.add("Right", function(){
  333. VE.navigation.move_focus_right();
  334. }, {
  335. 'type': 'keydown',
  336. 'propagate': false,
  337. 'disable_in_input': true,
  338. 'target': document
  339. }
  340. );
  341. shortcut.add("down", function(){
  342. VE.navigation.move_focus_down();
  343. }, {
  344. 'type': 'keydown',
  345. 'propagate': false,
  346. 'disable_in_input': true,
  347. 'target': document
  348. }
  349. );
  350. shortcut.add("up", function(){
  351. VE.navigation.move_focus_up();
  352. }, {
  353. 'type': 'keydown',
  354. 'propagate': false,
  355. 'disable_in_input': true,
  356. 'target': document
  357. }
  358. );
  359. shortcut.add("l", function(){
  360. var elm = $('.units.active .l-unit.focus .shortcut-l');
  361. if(elm.length){
  362. VE.navigation.shortcut(elm);
  363. }
  364. }, {
  365. 'type': 'keydown',
  366. 'propagate': false,
  367. 'disable_in_input': true,
  368. 'target': document
  369. }
  370. );
  371. shortcut.add("s", function(){
  372. var elm = $('.units.active .l-unit.focus .shortcut-s');
  373. if(elm.length){
  374. VE.navigation.shortcut(elm);
  375. }
  376. }, {
  377. 'type': 'keydown',
  378. 'propagate': false,
  379. 'disable_in_input': true,
  380. 'target': document
  381. }
  382. );
  383. shortcut.add("w", function(){
  384. var elm = $('.units.active .l-unit.focus .shortcut-w');
  385. if(elm.length){
  386. VE.navigation.shortcut(elm);
  387. }
  388. }, {
  389. 'type': 'keydown',
  390. 'propagate': false,
  391. 'disable_in_input': true,
  392. 'target': document
  393. }
  394. );
  395. shortcut.add("d", function(){
  396. var elm = $('.units.active .l-unit.focus .shortcut-d');
  397. if(elm.length){
  398. VE.navigation.shortcut(elm);
  399. }
  400. }, {
  401. 'type': 'keydown',
  402. 'propagate': false,
  403. 'disable_in_input': true,
  404. 'target': document
  405. }
  406. );
  407. shortcut.add("r", function(){
  408. var elm = $('.units.active .l-unit.focus .shortcut-r');
  409. if(elm.length){
  410. VE.navigation.shortcut(elm);
  411. }
  412. }, {
  413. 'type': 'keydown',
  414. 'propagate': false,
  415. 'disable_in_input': true,
  416. 'target': document
  417. }
  418. );
  419. shortcut.add("n", function(){
  420. var elm = $('.units.active .l-unit.focus .shortcut-n');
  421. if(elm.length){
  422. VE.navigation.shortcut(elm);
  423. }
  424. }, {
  425. 'type': 'keydown',
  426. 'propagate': false,
  427. 'disable_in_input': true,
  428. 'target': document
  429. }
  430. );
  431. shortcut.add("u", function(){
  432. var elm = $('.units.active .l-unit.focus .shortcut-u');
  433. if(elm.length){
  434. VE.navigation.shortcut(elm);
  435. }
  436. }, {
  437. 'type': 'keydown',
  438. 'propagate': false,
  439. 'disable_in_input': true,
  440. 'target': document
  441. }
  442. );
  443. shortcut.add("Delete", function(){
  444. var elm = $('.units.active .l-unit.focus .shortcut-delete');
  445. if(elm.length){
  446. VE.navigation.shortcut(elm);
  447. }
  448. }, {
  449. 'type': 'keydown',
  450. 'propagate': false,
  451. 'disable_in_input': true,
  452. 'target': document
  453. }
  454. );
  455. shortcut.add("Enter", function(evt){
  456. if (evt.target.tagName == 'INPUT' && evt.target.form.id == 'vstobjects'){
  457. $('form#vstobjects').submit();
  458. }
  459. if(VE.tmp.form_changed){
  460. if(!$('.ui-dialog').is(':visible')){
  461. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect')[0], '', $(VE.navigation.state.menu_selector + '.focus a').attr('href'));
  462. } else { // if dialog is opened - submitting confirm box by "enter" shortcut
  463. $('.ui-dialog button.submit').click();
  464. }
  465. } else {
  466. if(!$('.ui-dialog').is(':visible')){
  467. var elm = $('.units.active .l-unit.focus .shortcut-enter');
  468. if(elm.length){
  469. VE.navigation.shortcut(elm);
  470. } else {
  471. VE.navigation.enter_focused();
  472. }
  473. } else { // if dialog is opened - submitting confirm box by "enter" shortcut
  474. $('.ui-dialog button.submit').click();
  475. }
  476. }
  477. }, {
  478. 'type': 'keydown',
  479. 'propagate': true,
  480. 'disable_in_input': false,
  481. 'target': document
  482. }
  483. );
  484. $('.shortcuts .close').click(function(){
  485. $('.shortcuts').hide();
  486. });
  487. $('.to-shortcuts').click(function(){
  488. $('.shortcuts').toggle();
  489. });
  490. $(document).click(function(evt){
  491. //close notification popup
  492. if(!$(evt.target).hasClass('l-profile__notifications') && $(evt.target).parents('ul.notification-container').length == 0){
  493. $('.notification-container').hide();
  494. $('.l-profile__notifications').removeClass('active');
  495. }
  496. });
  497. // focusing on the first input at form
  498. if( location.href.indexOf('lead=') == -1 && !$('.ui-dialog').is(':visible') ){
  499. $('#vstobjects .vst-input:not([disabled]), #vstobjects .vst-list:not([disabled])').first().focus();
  500. }
  501. $('.l-profile__notifications').click(function(){
  502. if(!$('.l-profile__notifications').hasClass('active')){
  503. VE.notifications.get_list();
  504. $('.l-profile__notifications').addClass('active');
  505. left = $('.l-profile__notifications').offset().left - $('.notification-container').outerWidth() + 22;
  506. $('.notification-container').css({left: left+'px'});
  507. } else {
  508. $('.notification-container').hide();
  509. $('.l-profile__notifications').removeClass('active');
  510. }
  511. });
  512. VE.navigation.init();
  513. $('.button').attr('title','ctrl+Enter');
  514. $('.button.cancel').attr('title','ctrl+Backspace');
  515. VE.core.register();
  516. if (location.href.search(/list/) != -1) {
  517. var shift_select_ref = $('body').finderSelect({
  518. children: '.l-unit',
  519. 'onFinish': function(evt) {
  520. if ($('.l-content').find('.l-unit.selected').length == $('.l-content').find('.l-unit').length) {
  521. $('.toggle-all').addClass('clicked-on');
  522. }
  523. },
  524. 'toggleAllHook': function() {
  525. if ($('.l-unit').length == $('.ch-toggle:checked').length) {
  526. $('.l-unit.selected').removeClass('selected');
  527. $('.ch-toggle').prop('checked', false);
  528. $('#toggle-all').prop('checked', false);
  529. }
  530. else {
  531. $('.ch-toggle').prop('checked', true);
  532. $('#toggle-all').prop('checked', true);
  533. }
  534. }
  535. });
  536. $('table').on('mousedown', 'td', function(e) {
  537. if (e.ctrlKey) {
  538. e.preventDefault();
  539. }
  540. });
  541. }
  542. //
  543. $('form#objects').on('submit', function(evt) {
  544. $('.l-unit').find('.ch-toggle').prop('checked', false);
  545. $('.l-unit.selected').find('.ch-toggle').prop('checked', true);
  546. });
  547. });