init.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  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').bind('click', function(evt) {
  14. $("html, body").animate({ scrollTop: 0 }, "normal");
  15. });
  16. var isMobile = false; //initiate as false
  17. // device detection
  18. 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)
  19. || /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))){
  20. isMobile = true;
  21. $('body').addClass('mobile');
  22. }
  23. $(window).scroll(function(){hover_menu()});
  24. $('.l-sort-toolbar .sort-by').click(function(){
  25. $('.context-menu.sort-order').toggle().css({left: $(this).position().left - 10});
  26. });
  27. // CREATE BUTTON
  28. $('.l-sort__create-btn').hover(function(){
  29. $(".l-sort__create-btn").append("<div id='add-icon'></div>");
  30. $(".l-sort__create-btn").append("<div id='tooltip'>"+$('.l-sort__create-btn').attr('title').replace(' ','&nbsp;')+"</div>");
  31. }, function(){
  32. $("#add-icon").remove();
  33. $("#tooltip").remove();
  34. });
  35. // SEARCH BOX
  36. $('.l-sort-toolbar__search, .l-sort-toolbar__search-box .search-input').hover(function(){
  37. clearTimeout(VE.tmp.search_display_interval);
  38. clearTimeout(VE.tmp.search_hover_interval);
  39. VE.tmp.search_display_interval = setTimeout(function(){$('.search-input').addClass('activated');}, 150);
  40. }, function(){
  41. clearTimeout(VE.tmp.search_display_interval);
  42. clearTimeout(VE.tmp.search_hover_interval);
  43. VE.tmp.search_hover_interval = setTimeout(function(){
  44. if(!VE.tmp.search_activated && !$(".search-input").val().length){
  45. $(".search-input").removeClass('activated');
  46. }
  47. }, 600);
  48. });
  49. $('.search-input').focus(function(){
  50. VE.tmp.search_activated = 1;
  51. clearTimeout(VE.tmp.search_hover_interval);
  52. });
  53. $('.search-input').blur(function(){
  54. VE.tmp.search_activated = 0;
  55. clearTimeout(VE.tmp.search_hover_interval);
  56. VE.tmp.search_hover_interval = setTimeout(function(){
  57. if(!$(".search-input").val().length){
  58. $(".search-input").removeClass('activated');
  59. }
  60. }, 600);
  61. });
  62. // TIMER
  63. if($('.movement.left').length){
  64. VE.helpers.refresh_timer.right = $('.movement.right');
  65. VE.helpers.refresh_timer.left = $('.movement.left');
  66. VE.helpers.refresh_timer.start();
  67. $('.pause').click(function(){
  68. VE.helpers.refresh_timer.stop();
  69. $('.pause').addClass('hidden');
  70. $('.play').removeClass('hidden');
  71. $('.refresh-timer').addClass('paused');
  72. });
  73. $('.play').click(function(){
  74. VE.helpers.refresh_timer.start();
  75. $('.pause').removeClass('hidden');
  76. $('.play').addClass('hidden');
  77. $('.refresh-timer').removeClass('paused');
  78. });
  79. }
  80. // SORTING
  81. $('#vstobjects input, #vstobjects select, #vstobjects textarea').change(function(){VE.tmp.form_changed=1});
  82. $('.sort-order span').click(function(){
  83. $('.context-menu.sort-order').toggle();
  84. if($(this).hasClass('active'))
  85. return;
  86. $('.sort-order span').removeClass('active');
  87. $(this).addClass('active');
  88. VE.tmp.sort_par = $(this).parent('li').attr('entity');
  89. VE.tmp.sort_as_int = $(this).parent('li').attr('sort_as_int');
  90. VE.tmp.sort_direction = $(this).hasClass('up')*1 || -1;
  91. $('.l-sort .sort-by span b').html($(this).parent('li').find('.name').html());
  92. $('.l-sort .sort-by i').removeClass('l-icon-up-arrow l-icon-down-arrow');
  93. $(this).hasClass('up') ? $('.l-sort .sort-by i').addClass('l-icon-up-arrow') : $('.l-sort .sort-by i').addClass('l-icon-down-arrow');
  94. $('.units .l-unit').sort(function (a, b) {
  95. if(VE.tmp.sort_as_int)
  96. return parseInt($(a).attr(VE.tmp.sort_par)) >= parseInt($(b).attr(VE.tmp.sort_par)) ? VE.tmp.sort_direction : VE.tmp.sort_direction * -1;
  97. else
  98. return $(a).attr(VE.tmp.sort_par) <= $(b).attr(VE.tmp.sort_par) ? VE.tmp.sort_direction : VE.tmp.sort_direction * -1;
  99. }).appendTo(".l-center.units");
  100. });
  101. // STARS
  102. $('.l-unit .l-icon-star').click(function(){
  103. var l_unit = $(this).parents('.l-unit');
  104. if(l_unit.hasClass('l-unit--starred')){
  105. // removing star
  106. $.ajax({
  107. method: "POST",
  108. url: "/delete/favorite/index.php",
  109. data: { v_section: l_unit.attr('v_section'), v_unit_id: l_unit.attr('v_unit_id') }
  110. });
  111. l_unit.attr({'sort-star': 0});
  112. l_unit.removeClass('l-unit--starred');
  113. }
  114. else{
  115. $.ajax({
  116. method: "POST",
  117. url: "/add/favorite/index.php",
  118. data: { v_unit_id: l_unit.attr('v_unit_id'), v_section: l_unit.attr('v_section') }
  119. });
  120. l_unit.attr({'sort-star': 1});
  121. l_unit.addClass('l-unit--starred');
  122. }
  123. });
  124. // Shortcuts
  125. shortcut.add("Ctrl+Enter", function(){
  126. $('form#vstobjects').submit();
  127. }, {
  128. 'type': 'keydown',
  129. 'propagate': false,
  130. 'disable_in_input': false,
  131. 'target': document
  132. }
  133. );
  134. shortcut.add("Ctrl+Backspace", function(){
  135. if(VE.tmp.form_changed && $('form#vstobjects .button.cancel')[0]){
  136. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', $('form#vstobjects input.cancel').attr('onclick').replace("location.href='", "").replace("'",""));
  137. } else if($('form#vstobjects .button.cancel')[0]){
  138. location.href=$('form#vstobjects input.cancel').attr('onclick').replace("location.href='", "").replace("'","");
  139. } else if($('#vstobjects a.button.cancel')[0]){
  140. location.href=$('#vstobjects a.button.cancel').attr('href');
  141. }
  142. }, {
  143. 'type': 'keydown',
  144. 'propagate': false,
  145. 'disable_in_input': false,
  146. 'target': document
  147. }
  148. );
  149. shortcut.add("f", function(){
  150. $('.search-input').addClass('activated').focus();
  151. }, {
  152. 'type': 'keydown',
  153. 'propagate': false,
  154. 'disable_in_input': true,
  155. 'target': document
  156. }
  157. );
  158. $(window).bind('keypress', function(evt) {
  159. var tag = evt.target.tagName.toLowerCase();
  160. if (evt.charCode == 97 && tag != 'input' && tag != 'textarea' && tag != 'selectbox') {
  161. evt.preventDefault();
  162. if (!evt.ctrlKey && !evt.shiftKey) {
  163. if ($('.l-sort__create-btn')[0]) {
  164. location.href=$('.l-sort__create-btn').attr('href');
  165. }
  166. }
  167. else {
  168. if ($('.l-unit .ch-toggle:eq(0)').attr('checked')) {
  169. $('.l-unit').removeClass('selected');
  170. $('.l-unit .ch-toggle').prop('checked', false);
  171. }
  172. else {
  173. $('.l-unit').addClass('selected');
  174. $('.l-unit .ch-toggle').prop('checked', true);
  175. }
  176. }
  177. }
  178. });
  179. shortcut.add("1", function(){
  180. if(VE.tmp.form_changed){
  181. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', $('.l-stat .l-stat__col:nth-of-type(1) a').attr('href'));
  182. } else {
  183. location.href=$('.l-stat .l-stat__col:nth-of-type(1) a').attr('href');
  184. }
  185. }, {
  186. 'type': 'keydown',
  187. 'propagate': false,
  188. 'disable_in_input': true,
  189. 'target': document
  190. }
  191. );
  192. shortcut.add("2", function(){
  193. if(VE.tmp.form_changed){
  194. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', $('.l-stat .l-stat__col:nth-of-type(2) a').attr('href'));
  195. } else {
  196. location.href=$('.l-stat .l-stat__col:nth-of-type(2) a').attr('href');
  197. }
  198. }, {
  199. 'type': 'keydown',
  200. 'propagate': false,
  201. 'disable_in_input': true,
  202. 'target': document
  203. }
  204. );
  205. shortcut.add("3", function(){
  206. if(VE.tmp.form_changed){
  207. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', $('.l-stat .l-stat__col:nth-of-type(3) a').attr('href'));
  208. } else {
  209. location.href=$('.l-stat .l-stat__col:nth-of-type(3) a').attr('href');
  210. }
  211. }, {
  212. 'type': 'keydown',
  213. 'propagate': false,
  214. 'disable_in_input': true,
  215. 'target': document
  216. }
  217. );
  218. shortcut.add("4", function(){
  219. if(VE.tmp.form_changed){
  220. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', $('.l-stat .l-stat__col:nth-of-type(4) a').attr('href'));
  221. } else {
  222. location.href=$('.l-stat .l-stat__col:nth-of-type(4) a').attr('href');
  223. }
  224. }, {
  225. 'type': 'keydown',
  226. 'propagate': false,
  227. 'disable_in_input': true,
  228. 'target': document
  229. }
  230. );
  231. shortcut.add("5", function(){
  232. if(VE.tmp.form_changed){
  233. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', $('.l-stat .l-stat__col:nth-of-type(5) a').attr('href'));
  234. } else {
  235. location.href=$('.l-stat .l-stat__col:nth-of-type(5) a').attr('href');
  236. }
  237. }, {
  238. 'type': 'keydown',
  239. 'propagate': false,
  240. 'disable_in_input': true,
  241. 'target': document
  242. }
  243. );
  244. shortcut.add("6", function(){
  245. if(VE.tmp.form_changed){
  246. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', $('.l-stat .l-stat__col:nth-of-type(6) a').attr('href'));
  247. } else {
  248. location.href=$('.l-stat .l-stat__col:nth-of-type(6) a').attr('href');
  249. }
  250. }, {
  251. 'type': 'keydown',
  252. 'propagate': false,
  253. 'disable_in_input': true,
  254. 'target': document
  255. }
  256. );
  257. shortcut.add("7", function(){
  258. if(VE.tmp.form_changed){
  259. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect'), '', $('.l-stat .l-stat__col:nth-of-type(7) a').attr('href'));
  260. } else {
  261. location.href=$('.l-stat .l-stat__col:nth-of-type(7) a').attr('href');
  262. }
  263. }, {
  264. 'type': 'keydown',
  265. 'propagate': false,
  266. 'disable_in_input': true,
  267. 'target': document
  268. }
  269. );
  270. shortcut.add("h", function(){
  271. $('.shortcuts').toggle();
  272. }, {
  273. 'type': 'keydown',
  274. 'propagate': false,
  275. 'disable_in_input': true,
  276. 'target': document
  277. }
  278. );
  279. shortcut.add("Esc", function(){
  280. $('.shortcuts').hide();
  281. $('input, checkbox, textarea, select').blur();
  282. }, {
  283. 'type': 'keydown',
  284. 'propagate': false,
  285. 'disable_in_input': false,
  286. 'target': document
  287. }
  288. );
  289. shortcut.add("Left", function(){
  290. VE.navigation.move_focus_left();
  291. }, {
  292. 'type': 'keydown',
  293. 'propagate': false,
  294. 'disable_in_input': true,
  295. 'target': document
  296. }
  297. );
  298. shortcut.add("Right", function(){
  299. VE.navigation.move_focus_right();
  300. }, {
  301. 'type': 'keydown',
  302. 'propagate': false,
  303. 'disable_in_input': true,
  304. 'target': document
  305. }
  306. );
  307. shortcut.add("down", function(){
  308. VE.navigation.move_focus_down();
  309. }, {
  310. 'type': 'keydown',
  311. 'propagate': false,
  312. 'disable_in_input': true,
  313. 'target': document
  314. }
  315. );
  316. shortcut.add("up", function(){
  317. VE.navigation.move_focus_up();
  318. }, {
  319. 'type': 'keydown',
  320. 'propagate': false,
  321. 'disable_in_input': true,
  322. 'target': document
  323. }
  324. );
  325. shortcut.add("l", function(){
  326. var elm = $('.units.active .l-unit.focus .shortcut-l');
  327. if(elm.length){
  328. VE.navigation.shortcut(elm);
  329. }
  330. }, {
  331. 'type': 'keydown',
  332. 'propagate': false,
  333. 'disable_in_input': true,
  334. 'target': document
  335. }
  336. );
  337. shortcut.add("s", function(){
  338. var elm = $('.units.active .l-unit.focus .shortcut-s');
  339. if(elm.length){
  340. VE.navigation.shortcut(elm);
  341. }
  342. }, {
  343. 'type': 'keydown',
  344. 'propagate': false,
  345. 'disable_in_input': true,
  346. 'target': document
  347. }
  348. );
  349. shortcut.add("w", function(){
  350. var elm = $('.units.active .l-unit.focus .shortcut-w');
  351. if(elm.length){
  352. VE.navigation.shortcut(elm);
  353. }
  354. }, {
  355. 'type': 'keydown',
  356. 'propagate': false,
  357. 'disable_in_input': true,
  358. 'target': document
  359. }
  360. );
  361. shortcut.add("d", function(){
  362. var elm = $('.units.active .l-unit.focus .shortcut-d');
  363. if(elm.length){
  364. VE.navigation.shortcut(elm);
  365. }
  366. }, {
  367. 'type': 'keydown',
  368. 'propagate': false,
  369. 'disable_in_input': true,
  370. 'target': document
  371. }
  372. );
  373. shortcut.add("r", function(){
  374. var elm = $('.units.active .l-unit.focus .shortcut-r');
  375. if(elm.length){
  376. VE.navigation.shortcut(elm);
  377. }
  378. }, {
  379. 'type': 'keydown',
  380. 'propagate': false,
  381. 'disable_in_input': true,
  382. 'target': document
  383. }
  384. );
  385. shortcut.add("n", function(){
  386. var elm = $('.units.active .l-unit.focus .shortcut-n');
  387. if(elm.length){
  388. VE.navigation.shortcut(elm);
  389. }
  390. }, {
  391. 'type': 'keydown',
  392. 'propagate': false,
  393. 'disable_in_input': true,
  394. 'target': document
  395. }
  396. );
  397. shortcut.add("u", function(){
  398. var elm = $('.units.active .l-unit.focus .shortcut-u');
  399. if(elm.length){
  400. VE.navigation.shortcut(elm);
  401. }
  402. }, {
  403. 'type': 'keydown',
  404. 'propagate': false,
  405. 'disable_in_input': true,
  406. 'target': document
  407. }
  408. );
  409. shortcut.add("Delete", function(){
  410. var elm = $('.units.active .l-unit.focus .shortcut-delete');
  411. if(elm.length){
  412. VE.navigation.shortcut(elm);
  413. }
  414. }, {
  415. 'type': 'keydown',
  416. 'propagate': false,
  417. 'disable_in_input': true,
  418. 'target': document
  419. }
  420. );
  421. shortcut.add("Enter", function(){
  422. if(VE.tmp.form_changed){
  423. if(!$('.ui-dialog').is(':visible')){
  424. VE.helpers.createConfirmationDialog($('.confirmation-text-redirect')[0], '', $(VE.navigation.state.menu_selector + '.focus a').attr('href'));
  425. } else { // if dialog is opened - submitting confirm box by "enter" shortcut
  426. $('.ui-dialog button.submit').click();
  427. }
  428. } else {
  429. if(!$('.ui-dialog').is(':visible')){
  430. var elm = $('.units.active .l-unit.focus .shortcut-enter');
  431. if(elm.length){
  432. VE.navigation.shortcut(elm);
  433. } else {
  434. VE.navigation.enter_focused();
  435. }
  436. } else { // if dialog is opened - submitting confirm box by "enter" shortcut
  437. $('.ui-dialog button.submit').click();
  438. }
  439. }
  440. }, {
  441. 'type': 'keydown',
  442. 'propagate': false,
  443. 'disable_in_input': true,
  444. 'target': document
  445. }
  446. );
  447. $('.shortcuts .close').click(function(){
  448. $('.shortcuts').hide();
  449. });
  450. $('.to-shortcuts').click(function(){
  451. $('.shortcuts').toggle();
  452. });
  453. $(document).click(function(evt){
  454. //close notification popup
  455. if(!$(evt.target).hasClass('l-profile__notifications') && $(evt.target).parents('ul.notification-container').length == 0){
  456. $('.notification-container').hide();
  457. $('.l-profile__notifications').removeClass('active');
  458. }
  459. });
  460. // focusing on the first input at form
  461. if( location.href.indexOf('lead=') == -1 && !$('.ui-dialog').is(':visible') ){
  462. $('#vstobjects .vst-input:not([disabled]), #vstobjects .vst-list:not([disabled])').first().focus();
  463. }
  464. $('.l-profile__notifications').click(function(){
  465. if(!$('.l-profile__notifications').hasClass('active')){
  466. VE.notifications.get_list();
  467. $('.l-profile__notifications').addClass('active');
  468. left = $('.l-profile__notifications').offset().left - $('.notification-container').outerWidth() + 28;
  469. $('.notification-container').css({left: left+'px'});
  470. } else {
  471. $('.notification-container').hide();
  472. $('.l-profile__notifications').removeClass('active');
  473. }
  474. });
  475. VE.navigation.init();
  476. $('.button').attr('title','ctrl+Enter');
  477. $('.button.cancel').attr('title','ctrl+Backspace');
  478. VE.core.register();
  479. if (location.href.search(/list/) != -1) {
  480. var shift_select_ref = $('body').finderSelect({
  481. children: '.l-unit',
  482. 'onFinish': function(evt) {
  483. var ref = $(evt.target);
  484. $('.l-content').find('.l-unit .ch-toggle').prop('checked', false);
  485. $('.l-content').find('.l-unit.selected .ch-toggle').prop('checked', true);
  486. if ($('.l-content').find('.l-unit.selected').length == $('.l-content').find('.l-unit').length) {
  487. $('.toggle-all').addClass('clicked-on');
  488. }
  489. },
  490. 'toggleAllHook': function() {
  491. if ($('.l-unit').length == $('.ch-toggle:checked').length) {
  492. $('.l-unit.selected').removeClass('selected');
  493. $('.ch-toggle').prop('checked', false);
  494. $('#toggle-all').prop('checked', false);
  495. }
  496. else {
  497. $('.ch-toggle').prop('checked', true);
  498. $('#toggle-all').prop('checked', true);
  499. }
  500. }
  501. });
  502. $('table').on('mousedown', 'td', function(e) {
  503. if (e.ctrlKey) {
  504. e.preventDefault();
  505. }
  506. });
  507. }
  508. //
  509. $('form#objects').bind('submit', function(evt) {
  510. $('.l-unit').find('.ch-toggle').prop('checked', false);
  511. $('.l-unit.selected').find('.ch-toggle').prop('checked', true);
  512. });
  513. });