jquery.modal.search.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /* ============================================================
  2. * jquery.modal.search.js 搜索页面用地区js
  3. * ============================================================ */
  4. !function($) {
  5. var backdropLayerTpl = '<div class="modal_backdrop fade J_dismiss_modal"></div>';
  6. var htmlLayerTpl = [
  7. '<div class="modal">',
  8. '<div class="modal_dialog">',
  9. '<div class="modal_content pie_about">',
  10. '<div class="modal_header">',
  11. '<span class="title J_modal_title"></span>',
  12. '<span class="max_remind J_modal_max"></span>',
  13. '<a href="javascript:;" class="close J_dismiss_modal"></a>',
  14. '</div>',
  15. '<div class="modal_body">',
  16. '<div class="listed_group" id="J_listed_group">',
  17. '<div class="left_text">已选择:</div>',
  18. '<div class="center_text" id="J_listed_content"></div>',
  19. '<a href="javascript:;" class="right_text" id="J_listed_clear">清空</a>',
  20. '<div class="clear"></div>',
  21. '</div>',
  22. '<div class="J_modal_content"></div>',
  23. '</div>',
  24. '<div class="modal_footer">',
  25. '<div class="res_add_but">',
  26. '<div class="butlist">',
  27. '<div class="btn_blue J_hoverbut btn_100_38 J_btnyes">确 定</div>',
  28. '</div>',
  29. '<div class="butlist">',
  30. '<div class="btn_lightgray J_hoverbut btn_100_38 J_dismiss_modal J_btncancel">取 消</div>',
  31. '</div>',
  32. '<div class="clear"></div>',
  33. '</div>',
  34. '</div>',
  35. '<input type="hidden" class="J_btnload" />',
  36. '</div>',
  37. '</div>',
  38. '</div>'
  39. ].join('');
  40. // 点击显示地区分类
  41. $('#showSearchModal').off().on('click', function() {
  42. var titleValue = $(this).data('title');
  43. var multipleValue = eval($(this).data('multiple'));
  44. var maxNumValue = eval($(this).data('maxnum'));
  45. var widthValue = eval($(this).data('width'));
  46. var isSpell = app_spell;
  47. var htmlCity = '';
  48. var isSubsite = eval(qscms.is_subsite); // 是否是分站
  49. var subsiteLevelNum = eval(qscms.subsite_level);
  50. var subsiteLevel1 = true; // 是否是一级分站
  51. if (!isSubsite) { // 如果不是分站 一级分站始终为false
  52. subsiteLevel1 = false;
  53. } else {
  54. if (subsiteLevelNum > 1) { // 如果是分站,分站级数大于1 则为false
  55. subsiteLevel1 = false;
  56. }
  57. }
  58. var subsiteLevel1Width = 372;
  59. if (isSubsite) {
  60. if (isSpell) { // 拼音
  61. if (!subsiteLevel1) { // 分站是二级
  62. if (QS_city_spell_parent) {
  63. htmlCity += '<div class="modal_body_box modal_body_box3">';
  64. htmlCity += '<div class="left_box">';
  65. htmlCity += '<ul class="list_nav">';
  66. for (var i = 0; i < QS_city_spell_parent.length; i++) {
  67. if (QS_city_spell_parent[i].split(',')) {
  68. var iArray = QS_city_spell_parent[i].split(',');
  69. htmlCity += [
  70. '<li class="J_list_city_parent" data-code="' + iArray[0] + '" data-title="' + iArray[1] + '">',
  71. '<label>' + iArray[1] + '</label>',
  72. '</li>'
  73. ].join('');
  74. };
  75. };
  76. htmlCity += '</ul>';
  77. htmlCity += '</div>';
  78. htmlCity += '<div class="right_box">';
  79. if (QS_city_spell_parent) {
  80. for (var i = 0; i < QS_city_spell_parent.length; i++) {
  81. if (QS_city_spell_parent[i].split(',')) {
  82. var city1Array = QS_city_spell_parent[i].split(',');
  83. if (QS_city_spell[city1Array[0]]) {
  84. if (QS_city_spell[city1Array[0]].split('`')) {
  85. var city11Array = QS_city_spell[city1Array[0]].split('`');
  86. htmlCity += '<ul class="list_nav J_list_city_group">';
  87. htmlCity += [
  88. '<li class="J_list_city J_list_city_nolimit" data-code="' + city1Array[0] + '" data-title="' + city1Array[1] + '">',
  89. '<label>不限</label>',
  90. '</li>'
  91. ].join('');
  92. for (var j = 0; j < city11Array.length; j++) {
  93. if (city11Array[j].split(',')) {
  94. var jArray = city11Array[j].split(',');
  95. htmlCity += [
  96. '<li class="J_list_city" data-code="' + jArray[0] + '" data-title="' + jArray[1] + '">',
  97. '<label>' + jArray[1] + '</label>',
  98. '</li>'
  99. ].join('');
  100. };
  101. };
  102. htmlCity += '</ul>';
  103. }
  104. } else {
  105. htmlCity += '<ul class="list_nav J_list_city_group">';
  106. htmlCity += [
  107. '<li class="J_list_city J_list_city_nolimit" data-code="' + city1Array[0] + '" data-title="' + city1Array[1] + '">',
  108. '<label>不限</label>',
  109. '</li>'
  110. ].join('');
  111. htmlCity += '</ul>';
  112. }
  113. };
  114. }
  115. };
  116. htmlCity += '</div>';
  117. htmlCity += '<div class="clear"></div>';
  118. htmlCity += '</div>';
  119. }
  120. } else { // 分站为一级
  121. if (QS_city_spell_parent) {
  122. htmlCity += '<div class="modal_body_box modal_body_box_site">';
  123. htmlCity += '<ul class="list_nav">';
  124. for (var i = 0; i < QS_city_spell_parent.length; i++) {
  125. if (QS_city_spell_parent[i].split(',')) {
  126. var iArray = QS_city_spell_parent[i].split(',');
  127. htmlCity += [
  128. '<li class="J_list_city_parent" data-code="' + iArray[0] + '" data-title="' + iArray[1] + '">',
  129. '<label>' + iArray[1] + '</label>',
  130. '</li>'
  131. ].join('');
  132. };
  133. };
  134. htmlCity += '</ul>';
  135. htmlCity += '</div>';
  136. }
  137. }
  138. } else {
  139. if (!subsiteLevel1) { // 分站是二级
  140. if (QS_city_parent) {
  141. htmlCity += '<div class="modal_body_box modal_body_box3">';
  142. htmlCity += '<div class="left_box">';
  143. htmlCity += '<ul class="list_nav">';
  144. for (var i = 0; i < QS_city_parent.length; i++) {
  145. if (QS_city_parent[i].split(',')) {
  146. var iArray = QS_city_parent[i].split(',');
  147. htmlCity += [
  148. '<li class="J_list_city_parent" data-code="' + iArray[0] + '" data-title="' + iArray[1] + '">',
  149. '<label>' + iArray[1] + '</label>',
  150. '</li>'
  151. ].join('');
  152. };
  153. };
  154. htmlCity += '</ul>';
  155. htmlCity += '</div>';
  156. htmlCity += '<div class="right_box">';
  157. if (QS_city_parent) {
  158. for (var i = 0; i < QS_city_parent.length; i++) {
  159. if (QS_city_parent[i].split(',')) {
  160. var city1Array = QS_city_parent[i].split(',');
  161. if (QS_city[city1Array[0]]) {
  162. if (QS_city[city1Array[0]].split('`')) {
  163. var city11Array = QS_city[city1Array[0]].split('`');
  164. htmlCity += '<ul class="list_nav J_list_city_group">';
  165. htmlCity += [
  166. '<li class="J_list_city J_list_city_nolimit" data-code="' + city1Array[0] + '" data-title="' + city1Array[1] + '">',
  167. '<label>不限</label>',
  168. '</li>'
  169. ].join('');
  170. for (var j = 0; j < city11Array.length; j++) {
  171. if (city11Array[j].split(',')) {
  172. var jArray = city11Array[j].split(',');
  173. htmlCity += [
  174. '<li class="J_list_city" data-code="' + jArray[0] + '" data-title="' + jArray[1] + '">',
  175. '<label>' + jArray[1] + '</label>',
  176. '</li>'
  177. ].join('');
  178. };
  179. };
  180. htmlCity += '</ul>';
  181. }
  182. } else {
  183. htmlCity += '<ul class="list_nav J_list_city_group">';
  184. htmlCity += [
  185. '<li class="J_list_city J_list_city_nolimit" data-code="' + city1Array[0] + '.0.0" data-title="' + city1Array[1] + '">',
  186. '<label>不限</label>',
  187. '</li>'
  188. ].join('');
  189. htmlCity += '</ul>';
  190. }
  191. };
  192. }
  193. };
  194. htmlCity += '</div>';
  195. htmlCity += '<div class="clear"></div>';
  196. htmlCity += '</div>';
  197. }
  198. } else { // 分站为一级
  199. if (QS_city_parent) {
  200. htmlCity += '<div class="modal_body_box modal_body_box_site">';
  201. htmlCity += '<ul class="list_nav">';
  202. for (var i = 0; i < QS_city_parent.length; i++) {
  203. if (QS_city_parent[i].split(',')) {
  204. var iArray = QS_city_parent[i].split(',');
  205. htmlCity += [
  206. '<li class="J_list_city_parent" data-code="' + iArray[0] + '" data-title="' + iArray[1] + '">',
  207. '<label>' + iArray[1] + '</label>',
  208. '</li>'
  209. ].join('');
  210. };
  211. };
  212. htmlCity += '</ul>';
  213. htmlCity += '</div>';
  214. }
  215. }
  216. }
  217. } else {
  218. if (isSpell) { // 拼音
  219. if (QS_city_spell_parent) {
  220. htmlCity += '<div class="modal_body_box modal_body_box3">';
  221. htmlCity += '<div class="left_box">';
  222. htmlCity += '<ul class="list_nav">';
  223. for (var i = 0; i < QS_city_spell_parent.length; i++) {
  224. if (QS_city_spell_parent[i].split(',')) {
  225. var iArray = QS_city_spell_parent[i].split(',');
  226. htmlCity += [
  227. '<li class="J_list_city_parent" data-code="' + iArray[0] + '" data-title="' + iArray[1] + '">',
  228. '<label>' + iArray[1] + '</label>',
  229. '</li>'
  230. ].join('');
  231. };
  232. };
  233. htmlCity += '</ul>';
  234. htmlCity += '</div>';
  235. htmlCity += '<div class="right_box">';
  236. if (QS_city_spell_parent) {
  237. for (var i = 0; i < QS_city_spell_parent.length; i++) {
  238. if (QS_city_spell_parent[i].split(',')) {
  239. var city1Array = QS_city_spell_parent[i].split(',');
  240. if (QS_city_spell[city1Array[0]]) {
  241. if (QS_city_spell[city1Array[0]].split('`')) {
  242. var city11Array = QS_city_spell[city1Array[0]].split('`');
  243. htmlCity += '<ul class="list_nav J_list_city_group">';
  244. htmlCity += [
  245. '<li class="J_list_city J_list_city_nolimit" data-code="' + city1Array[0] + '" data-title="' + city1Array[1] + '">',
  246. '<label>不限</label>',
  247. '</li>'
  248. ].join('');
  249. for (var j = 0; j < city11Array.length; j++) {
  250. if (city11Array[j].split(',')) {
  251. var jArray = city11Array[j].split(',');
  252. htmlCity += [
  253. '<li class="J_list_city" data-code="' + jArray[0] + '" data-title="' + jArray[1] + '">',
  254. '<label>' + jArray[1] + '</label>',
  255. '</li>'
  256. ].join('');
  257. };
  258. };
  259. htmlCity += '</ul>';
  260. }
  261. } else {
  262. htmlCity += '<ul class="list_nav J_list_city_group">';
  263. htmlCity += [
  264. '<li class="J_list_city J_list_city_nolimit" data-code="' + city1Array[0] + '" data-title="' + city1Array[1] + '">',
  265. '<label>不限</label>',
  266. '</li>'
  267. ].join('');
  268. htmlCity += '</ul>';
  269. }
  270. };
  271. }
  272. };
  273. htmlCity += '</div>';
  274. htmlCity += '<div class="clear"></div>';
  275. htmlCity += '</div>';
  276. }
  277. } else {
  278. if (QS_city_parent) {
  279. htmlCity += '<div class="modal_body_box modal_body_box3">';
  280. htmlCity += '<div class="left_box">';
  281. htmlCity += '<ul class="list_nav">';
  282. for (var i = 0; i < QS_city_parent.length; i++) {
  283. if (QS_city_parent[i].split(',')) {
  284. var iArray = QS_city_parent[i].split(',');
  285. htmlCity += [
  286. '<li class="J_list_city_parent" data-code="' + iArray[0] + '" data-title="' + iArray[1] + '">',
  287. '<label>' + iArray[1] + '</label>',
  288. '</li>'
  289. ].join('');
  290. };
  291. };
  292. htmlCity += '</ul>';
  293. htmlCity += '</div>';
  294. htmlCity += '<div class="right_box">';
  295. if (QS_city_parent) {
  296. for (var i = 0; i < QS_city_parent.length; i++) {
  297. if (QS_city_parent[i].split(',')) {
  298. var city1Array = QS_city_parent[i].split(',');
  299. if (QS_city[city1Array[0]]) {
  300. if (QS_city[city1Array[0]].split('`')) {
  301. var city11Array = QS_city[city1Array[0]].split('`');
  302. htmlCity += '<ul class="list_nav J_list_city_group">';
  303. htmlCity += [
  304. '<li class="J_list_city J_list_city_nolimit" data-code="' + city1Array[0] + '.0.0" data-title="' + city1Array[1] + '">',
  305. '<label>不限</label>',
  306. '</li>'
  307. ].join('');
  308. for (var j = 0; j < city11Array.length; j++) {
  309. if (city11Array[j].split(',')) {
  310. var jArray = city11Array[j].split(',');
  311. htmlCity += [
  312. '<li class="J_list_city" data-code="' + city1Array[0] + '.' + jArray[0] + '.0" data-title="' + jArray[1] + '">',
  313. '<label>' + jArray[1] + '</label>',
  314. '</li>'
  315. ].join('');
  316. };
  317. };
  318. htmlCity += '</ul>';
  319. }
  320. } else {
  321. htmlCity += '<ul class="list_nav J_list_city_group">';
  322. htmlCity += [
  323. '<li class="J_list_city J_list_city_nolimit" data-code="' + city1Array[0] + '.0.0" data-title="' + city1Array[1] + '">',
  324. '<label>不限</label>',
  325. '</li>'
  326. ].join('');
  327. htmlCity += '</ul>';
  328. }
  329. };
  330. }
  331. };
  332. htmlCity += '</div>';
  333. htmlCity += '<div class="clear"></div>';
  334. htmlCity += '</div>';
  335. }
  336. }
  337. }
  338. prepareModal(titleValue, multipleValue, maxNumValue);
  339. $('.J_modal_content').html(htmlCity);
  340. $('.J_btnyes').attr('id', 'J_btnyes_city');
  341. $('.J_modal_content .right_box .list_nav').eq(0).show();
  342. $('.J_list_city_parent').eq(0).addClass('current');
  343. var msWidthValue = widthValue;
  344. if (subsiteLevel1) { // 一级分站宽度
  345. msWidthValue = subsiteLevel1Width;
  346. }
  347. $('.modal_dialog').css({
  348. width: msWidthValue + 'px',
  349. left: ($(window).width() - msWidthValue)/2,
  350. top: ($(window).height() - $('.modal_dialog').outerHeight())/2 + $(document).scrollTop()
  351. });
  352. $('.modal_backdrop').addClass('in');
  353. // 恢复选中
  354. var recoverValue = $('#recoverSearchCityModalCode').val();
  355. if (recoverValue.length) {
  356. if (multipleValue) {
  357. var recoverValueArray = recoverValue.split(',');
  358. if (subsiteLevel1) { // 一级分站
  359. for (var i = 0; i < recoverValueArray.length; i++) {
  360. $('.J_list_city_parent').each(function(index, el) {
  361. if ($(this).data('code') == recoverValueArray[i]) {
  362. $(this).addClass('current');
  363. };
  364. });
  365. };
  366. } else {
  367. for (var i = 0; i < recoverValueArray.length; i++) {
  368. $('.J_list_city').each(function(index, el) {
  369. if ($(this).data('code') == recoverValueArray[i]) {
  370. $(this).addClass('seledted');
  371. };
  372. });
  373. };
  374. }
  375. copyCitySelectedSecond();
  376. } else {
  377. if (subsiteLevel1) { // 一级分站
  378. $('.J_list_city_parent').removeClass('seledted current');
  379. $('.J_list_city_parent').each(function(index, el) {
  380. if ($(this).data('code') == recoverValue) {
  381. $(this).addClass('current');
  382. };
  383. });
  384. } else {
  385. $('.J_list_city').each(function(index, el) {
  386. if ($(this).data('code') == recoverValue) {
  387. $(this).addClass('seledted');
  388. };
  389. });
  390. }
  391. }
  392. // 不是一级分站才需要进行下一步
  393. if (!subsiteLevel1) {
  394. $('.J_list_city_parent').removeClass('seledted current');
  395. var subscriptValue = 0;
  396. $('.J_list_city.seledted').each(function(index, el) {
  397. var thisGroup = $(this).closest('.J_list_city_group');
  398. subscriptValue = $('.J_list_city_group').index(thisGroup);
  399. $('.J_list_city_parent').eq(subscriptValue).addClass('seledted');
  400. });
  401. $('.J_list_city_group').eq(subscriptValue).show().siblings('.J_list_city_group').hide();
  402. }
  403. }
  404. // 一级地区点击
  405. $('.J_list_city_parent').on('click', function() {
  406. $(this).addClass('current').siblings('.J_list_city_parent').removeClass('current');
  407. var subscriptValue = $('.J_list_city_parent').index(this);
  408. $('.J_list_city_group').eq(subscriptValue).show().siblings('.J_list_city_group').hide();
  409. });
  410. // 不限
  411. $('.J_list_city_nolimit').off().on('click', function() {
  412. var thisGroup = $(this).closest('.J_list_city_group');
  413. thisGroup.find('.J_list_city').not('.J_list_city_nolimit').removeClass('seledted');
  414. });
  415. // 二级地区点击
  416. $('.J_list_city').off().on('click', function() {
  417. if ($(this).hasClass('seledted')) {
  418. $(this).removeClass('seledted');
  419. if (multipleValue) {
  420. copyCitySelectedSecond();
  421. };
  422. var thisGroup = $(this).closest('.J_list_city_group');
  423. var subscriptValue = $('.J_list_city_group').index(thisGroup);
  424. if (!thisGroup.find('.seledted').length) {
  425. $('.J_list_city_parent').eq(subscriptValue).removeClass('seledted').addClass('current');
  426. };
  427. } else {
  428. $(this).addClass('seledted');
  429. if (multipleValue) {
  430. if (!$(this).is('.J_list_city_nolimit')) {
  431. var thisGroup = $(this).closest('.J_list_city_group');
  432. thisGroup.find('.J_list_city_nolimit').removeClass('seledted');
  433. };
  434. if ($('.J_list_city.seledted').length > maxNumValue) {
  435. $(this).removeClass('seledted');
  436. disapperTooltip("remind", '最多选择'+ maxNumValue +'个');
  437. return false;
  438. } else {
  439. copyCitySelectedSecond();
  440. }
  441. var thisGroup = $(this).closest('.J_list_city_group');
  442. var subscriptValue = $('.J_list_city_group').index(thisGroup);
  443. $('.J_list_city_parent').eq(subscriptValue).addClass('seledted');
  444. } else {
  445. var code = $(this).data('code');
  446. var title = $(this).data('title');
  447. $('#searchCityModalCode').val(code);
  448. $('#recoverSearchCityModalCode').val(code);
  449. $('#showSearchModal').text(title);
  450. $('#showSearchModal').attr('title', title);
  451. $('.modal_backdrop').remove();
  452. $('.modal').remove();
  453. }
  454. }
  455. });
  456. function copyCitySelectedSecond() {
  457. var htmlListed = '';
  458. $('.J_list_city.seledted').each(function(index, el) {
  459. var listedCode = $(this).data('code');
  460. var listedTitle = $(this).data('title');
  461. htmlListed += [
  462. '<div class="listed_item_parent J_listed_city" data-code="' + listedCode + '" data-title="' + listedTitle + '">',
  463. '<a href="javascript:;" class="listed_item">',
  464. '<span>' + listedTitle + '</span><div class="del"></div>',
  465. '</a>',
  466. '</div>'
  467. ].join('');
  468. });
  469. $('#J_listed_content').html(htmlListed);
  470. $('#J_listed_group').show();
  471. }
  472. $('.J_listed_city').off().on('click', function() {
  473. var listedValue = $(this).data('code');
  474. $('.J_list_city').each(function(index, el) {
  475. if ($(this).data('code') == listedValue) {
  476. $(this).removeClass('seledted');
  477. var thisGroup = $(this).closest('.J_list_city_group');
  478. var subscriptValue = $('.J_list_city_group').index(thisGroup);
  479. if (!thisGroup.find('.seledted').length) {
  480. $('.J_list_city_parent').eq(subscriptValue).removeClass('seledted');
  481. };
  482. };
  483. });
  484. copyCitySelectedSecond();
  485. });
  486. $('#J_listed_clear').on('click', function() {
  487. $('.J_list_city.seledted').each(function(index, el) {
  488. $(this).removeClass('seledted');
  489. });
  490. $('.J_list_city_parent').removeClass('seledted');
  491. copyCitySelectedSecond();
  492. });
  493. // 确定
  494. $('#J_btnyes_city').off().on('click', function() {
  495. var checkedArray = new Array();
  496. if (isSubsite && subsiteLevel1) { // 是分站并且是一级分站
  497. checkedArray = $('.J_list_city_parent.current');
  498. } else {
  499. checkedArray = $('.J_list_city.seledted');
  500. }
  501. var codeArray = new Array();
  502. var titleArray = new Array();
  503. $.each(checkedArray, function(index, val) {
  504. codeArray[index] = $(this).data('code');
  505. titleArray[index] = $(this).data('title');
  506. });
  507. $('#searchCityModalCode').val(codeArray.join(','));
  508. $('#recoverSearchCityModalCode').val(codeArray.join(','));
  509. $('#showSearchModal').text(titleArray.length ? titleArray.join('+') : '请选择');
  510. $('#showSearchModal').attr('title', titleArray.length ? titleArray.join('+') : '请选择');
  511. removeModal();
  512. });
  513. });
  514. function prepareModal(titleValue, multipleValue, maxNumValue) {
  515. var ie = !-[1,];
  516. var ie6 = !-[1,]&&!window.XMLHttpRequest;
  517. $(backdropLayerTpl).appendTo($(document.body));
  518. if (ie6) {
  519. $('.modal_backdrop').css("height", $(document).height());
  520. }
  521. $(htmlLayerTpl).appendTo($(document.body));
  522. $('.J_modal_title').text(titleValue);
  523. if (multipleValue) {
  524. $('.J_modal_max').text('(最多选择'+ maxNumValue +'个)');
  525. };
  526. $(".J_hoverbut").hover(
  527. function() {
  528. $(this).addClass("hover");
  529. },
  530. function() {
  531. $(this).removeClass("hover");
  532. }
  533. );
  534. // 可拖动
  535. var newObj = $('.modal_dialog');
  536. var newTit = newObj.find(".modal_header");
  537. newTit.mousedown(function(e) {
  538. var offset = newObj.offset();
  539. var x = e.pageX - offset.left;
  540. var y = e.pageY - offset.top;
  541. $(document).bind('mousemove', function(ev) {
  542. newObj.bind('selectstart', function() {
  543. return false;
  544. });
  545. var newx = ev.pageX - x;
  546. var newy = ev.pageY - y;
  547. newObj.css({
  548. 'left': newx + "px",
  549. 'top': newy + "px"
  550. });
  551. });
  552. });
  553. $(document).mouseup(function() {
  554. $(this).unbind("mousemove");
  555. })
  556. if (ie) {
  557. if (window.PIE) {
  558. $('.pie_about').each(function() {
  559. PIE.attach(this);
  560. });
  561. }
  562. };
  563. }
  564. $('.J_dismiss_modal').on('click', function() {
  565. removeModal();
  566. });
  567. $(document).on('keydown', function(event) {
  568. if (event.keyCode == 27) {
  569. removeModal();
  570. }
  571. });
  572. function removeModal() {
  573. setTimeout(function() {
  574. $('.modal_backdrop').remove();
  575. $('.modal').remove();
  576. },50)
  577. }
  578. }(window.jQuery);