PageRenderTime 58ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 1ms

/assets/modules/easyadvertising/js/flexigrid.js

https://github.com/good-web-master/modx.evo.custom
JavaScript | 1244 lines | 1209 code | 0 blank | 35 comment | 311 complexity | 1b468ea79d8339efc09de3a808aaa254 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0, MIT, BSD-3-Clause
  1. /*
  2. * Flexigrid for jQuery - v1.1
  3. *
  4. * Copyright (c) 2008 Paulo P. Marinas (code.google.com/p/flexigrid/)
  5. * Dual licensed under the MIT or GPL Version 2 licenses.
  6. * http://jquery.org/license
  7. *
  8. */
  9. (function ($) {
  10. $.addFlex = function (t, p) {
  11. if (t.grid) return false; //return if already exist
  12. p = $.extend({ //apply default properties
  13. height: 200, //default height
  14. width: 'auto', //auto width
  15. striped: true, //apply odd even stripes
  16. novstripe: false,
  17. minwidth: 30, //min width of columns
  18. minheight: 80, //min height of columns
  19. resizable: true, //allow table resizing
  20. url: false, //URL if using data from AJAX
  21. method: 'POST', //data sending method
  22. dataType: 'xml', //type of data for AJAX, either xml or json
  23. errormsg: 'Ошибка подключения',
  24. usepager: false,
  25. nowrap: true,
  26. page: 1, //current page
  27. total: 1, //total pages
  28. useRp: true, //use the results per page select box
  29. rp: 15, //results per page
  30. rpOptions: [10, 20, 50, 100], //allowed per-page values
  31. title: false,
  32. pagestat: 'Показано {from} - {to} из {total} записей',
  33. pagetext: 'Страница',
  34. outof: 'из',
  35. findtext: 'Фильтр',
  36. procmsg: 'Идет обработка...',
  37. query: '',
  38. qtype: '',
  39. nomsg: 'нет записей',
  40. minColToggle: 1, //minimum allowed column to be hidden
  41. showToggleBtn: true, //show or hide column toggle popup
  42. hideOnSubmit: true,
  43. autoload: true,
  44. blockOpacity: 0.5,
  45. preProcess: false,
  46. onDragCol: false,
  47. onToggleCol: false,
  48. onChangeSort: false,
  49. onSuccess: false,
  50. onError: false,
  51. onSubmit: false //using a custom populate function
  52. }, p);
  53. $(t).show() //show if hidden
  54. .attr({
  55. cellPadding: 0,
  56. cellSpacing: 0,
  57. border: 0
  58. }) //remove padding and spacing
  59. .removeAttr('width'); //remove width properties
  60. //create grid class
  61. var g = {
  62. hset: {},
  63. rePosDrag: function () {
  64. var cdleft = 0 - this.hDiv.scrollLeft;
  65. if (this.hDiv.scrollLeft > 0) cdleft -= Math.floor(p.cgwidth / 2);
  66. $(g.cDrag).css({
  67. top: g.hDiv.offsetTop + 1
  68. });
  69. var cdpad = this.cdpad;
  70. $('div', g.cDrag).hide();
  71. $('thead tr:first th:visible', this.hDiv).each(function () {
  72. var n = $('thead tr:first th:visible', g.hDiv).index(this);
  73. var cdpos = parseInt($('div', this).width());
  74. if (cdleft == 0) cdleft -= Math.floor(p.cgwidth / 2);
  75. cdpos = cdpos + cdleft + cdpad;
  76. if (isNaN(cdpos)) {
  77. cdpos = 0;
  78. }
  79. $('div:eq(' + n + ')', g.cDrag).css({
  80. 'left': cdpos + 'px'
  81. }).show();
  82. cdleft = cdpos;
  83. });
  84. },
  85. fixHeight: function (newH) {
  86. newH = false;
  87. if (!newH) newH = $(g.bDiv).height();
  88. var hdHeight = $(this.hDiv).height();
  89. $('div', this.cDrag).each(
  90. function () {
  91. $(this).height(newH + hdHeight);
  92. }
  93. );
  94. var nd = parseInt($(g.nDiv).height());
  95. if (nd > newH) $(g.nDiv).height(newH).width(200);
  96. else $(g.nDiv).height('auto').width('auto');
  97. $(g.block).css({
  98. height: newH,
  99. marginBottom: (newH * -1)
  100. });
  101. var hrH = g.bDiv.offsetTop + newH;
  102. if (p.height != 'auto' && p.resizable) hrH = g.vDiv.offsetTop;
  103. $(g.rDiv).css({
  104. height: hrH
  105. });
  106. },
  107. dragStart: function (dragtype, e, obj) { //default drag function start
  108. if (dragtype == 'colresize') {//column resize
  109. $(g.nDiv).hide();
  110. $(g.nBtn).hide();
  111. var n = $('div', this.cDrag).index(obj);
  112. var ow = $('th:visible div:eq(' + n + ')', this.hDiv).width();
  113. $(obj).addClass('dragging').siblings().hide();
  114. $(obj).prev().addClass('dragging').show();
  115. this.colresize = {
  116. startX: e.pageX,
  117. ol: parseInt(obj.style.left),
  118. ow: ow,
  119. n: n
  120. };
  121. $('body').css('cursor', 'col-resize');
  122. } else if (dragtype == 'vresize') {//table resize
  123. var hgo = false;
  124. $('body').css('cursor', 'row-resize');
  125. if (obj) {
  126. hgo = true;
  127. $('body').css('cursor', 'col-resize');
  128. }
  129. this.vresize = {
  130. h: p.height,
  131. sy: e.pageY,
  132. w: p.width,
  133. sx: e.pageX,
  134. hgo: hgo
  135. };
  136. } else if (dragtype == 'colMove') {//column header drag
  137. $(g.nDiv).hide();
  138. $(g.nBtn).hide();
  139. this.hset = $(this.hDiv).offset();
  140. this.hset.right = this.hset.left + $('table', this.hDiv).width();
  141. this.hset.bottom = this.hset.top + $('table', this.hDiv).height();
  142. this.dcol = obj;
  143. this.dcoln = $('th', this.hDiv).index(obj);
  144. this.colCopy = document.createElement("div");
  145. this.colCopy.className = "colCopy";
  146. this.colCopy.innerHTML = obj.innerHTML;
  147. if ($.browser.msie) {
  148. this.colCopy.className = "colCopy ie";
  149. }
  150. $(this.colCopy).css({
  151. position: 'absolute',
  152. float: 'left',
  153. display: 'none',
  154. textAlign: obj.align
  155. });
  156. $('body').append(this.colCopy);
  157. $(this.cDrag).hide();
  158. }
  159. $('body').noSelect();
  160. },
  161. dragMove: function (e) {
  162. if (this.colresize) {//column resize
  163. var n = this.colresize.n;
  164. var diff = e.pageX - this.colresize.startX;
  165. var nleft = this.colresize.ol + diff;
  166. var nw = this.colresize.ow + diff;
  167. if (nw > p.minwidth) {
  168. $('div:eq(' + n + ')', this.cDrag).css('left', nleft);
  169. this.colresize.nw = nw;
  170. }
  171. } else if (this.vresize) {//table resize
  172. var v = this.vresize;
  173. var y = e.pageY;
  174. var diff = y - v.sy;
  175. if (!p.defwidth) p.defwidth = p.width;
  176. if (p.width != 'auto' && !p.nohresize && v.hgo) {
  177. var x = e.pageX;
  178. var xdiff = x - v.sx;
  179. var newW = v.w + xdiff;
  180. if (newW > p.defwidth) {
  181. this.gDiv.style.width = newW + 'px';
  182. p.width = newW;
  183. }
  184. }
  185. var newH = v.h + diff;
  186. if ((newH > p.minheight || p.height < p.minheight) && !v.hgo) {
  187. this.bDiv.style.height = newH + 'px';
  188. p.height = newH;
  189. this.fixHeight(newH);
  190. }
  191. v = null;
  192. } else if (this.colCopy) {
  193. $(this.dcol).addClass('thMove').removeClass('thOver');
  194. if (e.pageX > this.hset.right || e.pageX < this.hset.left || e.pageY > this.hset.bottom || e.pageY < this.hset.top) {
  195. //this.dragEnd();
  196. $('body').css('cursor', 'move');
  197. } else {
  198. $('body').css('cursor', 'pointer');
  199. }
  200. $(this.colCopy).css({
  201. top: e.pageY + 10,
  202. left: e.pageX + 20,
  203. display: 'block'
  204. });
  205. }
  206. },
  207. dragEnd: function () {
  208. if (this.colresize) {
  209. var n = this.colresize.n;
  210. var nw = this.colresize.nw;
  211. $('th:visible div:eq(' + n + ')', this.hDiv).css('width', nw);
  212. $('tr', this.bDiv).each(
  213. function () {
  214. $('td:visible div:eq(' + n + ')', this).css('width', nw);
  215. }
  216. );
  217. this.hDiv.scrollLeft = this.bDiv.scrollLeft;
  218. $('div:eq(' + n + ')', this.cDrag).siblings().show();
  219. $('.dragging', this.cDrag).removeClass('dragging');
  220. this.rePosDrag();
  221. this.fixHeight();
  222. this.colresize = false;
  223. } else if (this.vresize) {
  224. this.vresize = false;
  225. } else if (this.colCopy) {
  226. $(this.colCopy).remove();
  227. if (this.dcolt != null) {
  228. if (this.dcoln > this.dcolt) $('th:eq(' + this.dcolt + ')', this.hDiv).before(this.dcol);
  229. else $('th:eq(' + this.dcolt + ')', this.hDiv).after(this.dcol);
  230. this.switchCol(this.dcoln, this.dcolt);
  231. $(this.cdropleft).remove();
  232. $(this.cdropright).remove();
  233. this.rePosDrag();
  234. if (p.onDragCol) {
  235. p.onDragCol(this.dcoln, this.dcolt);
  236. }
  237. }
  238. this.dcol = null;
  239. this.hset = null;
  240. this.dcoln = null;
  241. this.dcolt = null;
  242. this.colCopy = null;
  243. $('.thMove', this.hDiv).removeClass('thMove');
  244. $(this.cDrag).show();
  245. }
  246. $('body').css('cursor', 'default');
  247. $('body').noSelect(false);
  248. },
  249. toggleCol: function (cid, visible) {
  250. var ncol = $("th[axis='col" + cid + "']", this.hDiv)[0];
  251. var n = $('thead th', g.hDiv).index(ncol);
  252. var cb = $('input[value=' + cid + ']', g.nDiv)[0];
  253. if (visible == null) {
  254. visible = ncol.hidden;
  255. }
  256. if ($('input:checked', g.nDiv).length < p.minColToggle && !visible) {
  257. return false;
  258. }
  259. if (visible) {
  260. ncol.hidden = false;
  261. $(ncol).show();
  262. cb.checked = true;
  263. } else {
  264. ncol.hidden = true;
  265. $(ncol).hide();
  266. cb.checked = false;
  267. }
  268. $('tbody tr', t).each(
  269. function () {
  270. if (visible) {
  271. $('td:eq(' + n + ')', this).show();
  272. } else {
  273. $('td:eq(' + n + ')', this).hide();
  274. }
  275. }
  276. );
  277. this.rePosDrag();
  278. if (p.onToggleCol) {
  279. p.onToggleCol(cid, visible);
  280. }
  281. return visible;
  282. },
  283. switchCol: function (cdrag, cdrop) { //switch columns
  284. $('tbody tr', t).each(
  285. function () {
  286. if (cdrag > cdrop) $('td:eq(' + cdrop + ')', this).before($('td:eq(' + cdrag + ')', this));
  287. else $('td:eq(' + cdrop + ')', this).after($('td:eq(' + cdrag + ')', this));
  288. }
  289. );
  290. //switch order in nDiv
  291. if (cdrag > cdrop) {
  292. $('tr:eq(' + cdrop + ')', this.nDiv).before($('tr:eq(' + cdrag + ')', this.nDiv));
  293. } else {
  294. $('tr:eq(' + cdrop + ')', this.nDiv).after($('tr:eq(' + cdrag + ')', this.nDiv));
  295. }
  296. if ($.browser.msie && $.browser.version < 7.0) {
  297. $('tr:eq(' + cdrop + ') input', this.nDiv)[0].checked = true;
  298. }
  299. this.hDiv.scrollLeft = this.bDiv.scrollLeft;
  300. },
  301. scroll: function () {
  302. this.hDiv.scrollLeft = this.bDiv.scrollLeft;
  303. this.rePosDrag();
  304. },
  305. addData: function (data) { //parse data
  306. if (p.dataType == 'json') {
  307. data = $.extend({rows: [], page: 0, total: 0}, data);
  308. }
  309. if (p.preProcess) {
  310. data = p.preProcess(data);
  311. }
  312. $('.pReload', this.pDiv).removeClass('loading');
  313. this.loading = false;
  314. if (!data) {
  315. $('.pPageStat', this.pDiv).html(p.errormsg);
  316. return false;
  317. }
  318. if (p.dataType == 'xml') {
  319. p.total = +$('rows total', data).text();
  320. } else {
  321. p.total = data.total;
  322. }
  323. if (p.total == 0) {
  324. $('tr, a, td, div', t).unbind();
  325. $(t).empty();
  326. p.pages = 1;
  327. p.page = 1;
  328. this.buildpager();
  329. $('.pPageStat', this.pDiv).html(p.nomsg);
  330. return false;
  331. }
  332. p.pages = Math.ceil(p.total / p.rp);
  333. if (p.dataType == 'xml') {
  334. p.page = +$('rows page', data).text();
  335. } else {
  336. p.page = data.page;
  337. }
  338. this.buildpager();
  339. //build new body
  340. var tbody = document.createElement('tbody');
  341. if (p.dataType == 'json') {
  342. $.each(data.rows, function (i, row) {
  343. var tr = document.createElement('tr');
  344. if (i % 2 && p.striped) {
  345. tr.className = 'erow';
  346. }
  347. if (row.id) {
  348. tr.id = 'row' + row.id;
  349. }
  350. $('thead tr:first th', g.hDiv).each( //add cell
  351. function () {
  352. var td = document.createElement('td');
  353. var idx = $(this).attr('axis').substr(3);
  354. td.align = this.align;
  355. // If the json elements aren't named (which is typical), use numeric order
  356. if (typeof row.cell[idx] != "undefined") {
  357. td.innerHTML = (row.cell[idx] != null) ? row.cell[idx] : '';//null-check for Opera-browser
  358. } else {
  359. td.innerHTML = row.cell[p.colModel[idx].name];
  360. }
  361. $(td).attr('abbr', $(this).attr('abbr'));
  362. $(tr).append(td);
  363. td = null;
  364. }
  365. );
  366. if ($('thead', this.gDiv).length < 1) {//handle if grid has no headers
  367. for (idx = 0; idx < cell.length; idx++) {
  368. var td = document.createElement('td');
  369. // If the json elements aren't named (which is typical), use numeric order
  370. if (typeof row.cell[idx] != "undefined") {
  371. td.innerHTML = (row.cell[idx] != null) ? row.cell[idx] : '';//null-check for Opera-browser
  372. } else {
  373. td.innerHTML = row.cell[p.colModel[idx].name];
  374. }
  375. $(tr).append(td);
  376. td = null;
  377. }
  378. }
  379. $(tbody).append(tr);
  380. tr = null;
  381. });
  382. } else if (p.dataType == 'xml') {
  383. var i = 1;
  384. $("rows row", data).each(function () {
  385. i++;
  386. var tr = document.createElement('tr');
  387. if (i % 2 && p.striped) {
  388. tr.className = 'erow';
  389. }
  390. var nid = $(this).attr('id');
  391. if (nid) {
  392. tr.id = 'row' + nid;
  393. }
  394. nid = null;
  395. var robj = this;
  396. $('thead tr:first th', g.hDiv).each(function () {
  397. var td = document.createElement('td');
  398. var idx = $(this).attr('axis').substr(3);
  399. td.align = this.align;
  400. td.innerHTML = $("cell:eq(" + idx + ")", robj).text();
  401. $(td).attr('abbr', $(this).attr('abbr'));
  402. $(tr).append(td);
  403. td = null;
  404. });
  405. if ($('thead', this.gDiv).length < 1) {//handle if grid has no headers
  406. $('cell', this).each(function () {
  407. var td = document.createElement('td');
  408. td.innerHTML = $(this).text();
  409. $(tr).append(td);
  410. td = null;
  411. });
  412. }
  413. $(tbody).append(tr);
  414. tr = null;
  415. robj = null;
  416. });
  417. }
  418. $('tr', t).unbind();
  419. $(t).empty();
  420. $(t).append(tbody);
  421. this.addCellProp();
  422. this.addRowProp();
  423. this.rePosDrag();
  424. tbody = null;
  425. data = null;
  426. i = null;
  427. if (p.onSuccess) {
  428. p.onSuccess(this);
  429. }
  430. if (p.hideOnSubmit) {
  431. $(g.block).remove();
  432. }
  433. this.hDiv.scrollLeft = this.bDiv.scrollLeft;
  434. if ($.browser.opera) {
  435. $(t).css('visibility', 'visible');
  436. }
  437. },
  438. changeSort: function (th) { //change sortorder
  439. if (this.loading) {
  440. return true;
  441. }
  442. $(g.nDiv).hide();
  443. $(g.nBtn).hide();
  444. if (p.sortname == $(th).attr('abbr')) {
  445. if (p.sortorder == 'asc') {
  446. p.sortorder = 'desc';
  447. } else {
  448. p.sortorder = 'asc';
  449. }
  450. }
  451. $(th).addClass('sorted').siblings().removeClass('sorted');
  452. $('.sdesc', this.hDiv).removeClass('sdesc');
  453. $('.sasc', this.hDiv).removeClass('sasc');
  454. $('div', th).addClass('s' + p.sortorder);
  455. p.sortname = $(th).attr('abbr');
  456. if (p.onChangeSort) {
  457. p.onChangeSort(p.sortname, p.sortorder);
  458. } else {
  459. this.populate();
  460. }
  461. },
  462. buildpager: function () { //rebuild pager based on new properties
  463. $('.pcontrol input', this.pDiv).val(p.page);
  464. $('.pcontrol span', this.pDiv).html(p.pages);
  465. var r1 = (p.page - 1) * p.rp + 1;
  466. var r2 = r1 + p.rp - 1;
  467. if (p.total < r2) {
  468. r2 = p.total;
  469. }
  470. var stat = p.pagestat;
  471. stat = stat.replace(/{from}/, r1);
  472. stat = stat.replace(/{to}/, r2);
  473. stat = stat.replace(/{total}/, p.total);
  474. $('.pPageStat', this.pDiv).html(stat);
  475. },
  476. populate: function () { //get latest data
  477. if (this.loading) {
  478. return true;
  479. }
  480. if (p.onSubmit) {
  481. var gh = p.onSubmit();
  482. if (!gh) {
  483. return false;
  484. }
  485. }
  486. this.loading = true;
  487. if (!p.url) {
  488. return false;
  489. }
  490. $('.pPageStat', this.pDiv).html(p.procmsg);
  491. $('.pReload', this.pDiv).addClass('loading');
  492. $(g.block).css({
  493. top: g.bDiv.offsetTop
  494. });
  495. if (p.hideOnSubmit) {
  496. $(this.gDiv).prepend(g.block);
  497. }
  498. if ($.browser.opera) {
  499. $(t).css('visibility', 'hidden');
  500. }
  501. if (!p.newp) {
  502. p.newp = 1;
  503. }
  504. if (p.page > p.pages) {
  505. p.page = p.pages;
  506. }
  507. var param = [{
  508. name: 'page',
  509. value: p.newp
  510. }, {
  511. name: 'rp',
  512. value: p.rp
  513. }, {
  514. name: 'sortname',
  515. value: p.sortname
  516. }, {
  517. name: 'sortorder',
  518. value: p.sortorder
  519. }, {
  520. name: 'query',
  521. value: p.query
  522. }, {
  523. name: 'qtype',
  524. value: p.qtype
  525. }];
  526. if (p.params) {
  527. for (var pi = 0; pi < p.params.length; pi++) {
  528. param[param.length] = p.params[pi];
  529. }
  530. }
  531. $.ajax({
  532. type: p.method,
  533. url: p.url,
  534. data: param,
  535. dataType: p.dataType,
  536. success: function (data) {
  537. g.addData(data);
  538. },
  539. error: function (XMLHttpRequest, textStatus, errorThrown) {
  540. try {
  541. if (p.onError) p.onError(XMLHttpRequest, textStatus, errorThrown);
  542. } catch (e) {}
  543. }
  544. });
  545. },
  546. doSearch: function () {
  547. p.query = $('input[name=q]', g.sDiv).val();
  548. p.qtype = $('select[name=qtype]', g.sDiv).val();
  549. p.newp = 1;
  550. this.populate();
  551. },
  552. changePage: function (ctype) { //change page
  553. if (this.loading) {
  554. return true;
  555. }
  556. switch (ctype) {
  557. case 'first':
  558. p.newp = 1;
  559. break;
  560. case 'prev':
  561. if (p.page > 1) {
  562. p.newp = parseInt(p.page) - 1;
  563. }
  564. break;
  565. case 'next':
  566. if (p.page < p.pages) {
  567. p.newp = parseInt(p.page) + 1;
  568. }
  569. break;
  570. case 'last':
  571. p.newp = p.pages;
  572. break;
  573. case 'input':
  574. var nv = parseInt($('.pcontrol input', this.pDiv).val());
  575. if (isNaN(nv)) {
  576. nv = 1;
  577. }
  578. if (nv < 1) {
  579. nv = 1;
  580. } else if (nv > p.pages) {
  581. nv = p.pages;
  582. }
  583. $('.pcontrol input', this.pDiv).val(nv);
  584. p.newp = nv;
  585. break;
  586. }
  587. if (p.newp == p.page) {
  588. return false;
  589. }
  590. if (p.onChangePage) {
  591. p.onChangePage(p.newp);
  592. } else {
  593. this.populate();
  594. }
  595. },
  596. addCellProp: function () {
  597. $('tbody tr td', g.bDiv).each(function () {
  598. var tdDiv = document.createElement('div');
  599. var n = $('td', $(this).parent()).index(this);
  600. var pth = $('th:eq(' + n + ')', g.hDiv).get(0);
  601. if (pth != null) {
  602. if (p.sortname == $(pth).attr('abbr') && p.sortname) {
  603. this.className = 'sorted';
  604. }
  605. $(tdDiv).css({
  606. textAlign: pth.align,
  607. width: $('div:first', pth)[0].style.width
  608. });
  609. if (pth.hidden) {
  610. $(this).css('display', 'none');
  611. }
  612. }
  613. if (p.nowrap == false) {
  614. $(tdDiv).css('white-space', 'normal');
  615. }
  616. if (this.innerHTML == '') {
  617. this.innerHTML = '&nbsp;';
  618. }
  619. tdDiv.innerHTML = this.innerHTML;
  620. var prnt = $(this).parent()[0];
  621. var pid = false;
  622. if (prnt.id) {
  623. pid = prnt.id.substr(3);
  624. }
  625. if (pth != null) {
  626. if (pth.process) pth.process(tdDiv, pid);
  627. }
  628. $(this).empty().append(tdDiv).removeAttr('width'); //wrap content
  629. });
  630. },
  631. getCellDim: function (obj) {// get cell prop for editable event
  632. var ht = parseInt($(obj).height());
  633. var pht = parseInt($(obj).parent().height());
  634. var wt = parseInt(obj.style.width);
  635. var pwt = parseInt($(obj).parent().width());
  636. var top = obj.offsetParent.offsetTop;
  637. var left = obj.offsetParent.offsetLeft;
  638. var pdl = parseInt($(obj).css('paddingLeft'));
  639. var pdt = parseInt($(obj).css('paddingTop'));
  640. return {
  641. ht: ht,
  642. wt: wt,
  643. top: top,
  644. left: left,
  645. pdl: pdl,
  646. pdt: pdt,
  647. pht: pht,
  648. pwt: pwt
  649. };
  650. },
  651. addRowProp: function () {
  652. $('tbody tr', g.bDiv).each(function () {
  653. $(this).click(function (e) {
  654. var obj = (e.target || e.srcElement);
  655. if (obj.href || obj.type) return true;
  656. $(this).toggleClass('trSelected');
  657. if (p.singleSelect) $(this).siblings().removeClass('trSelected');
  658. }).mousedown(function (e) {
  659. if (e.shiftKey) {
  660. $(this).toggleClass('trSelected');
  661. g.multisel = true;
  662. this.focus();
  663. $(g.gDiv).noSelect();
  664. }
  665. }).mouseup(function () {
  666. if (g.multisel) {
  667. g.multisel = false;
  668. $(g.gDiv).noSelect(false);
  669. }
  670. }).hover(function (e) {
  671. if (g.multisel) {
  672. $(this).toggleClass('trSelected');
  673. }
  674. }, function () {});
  675. if ($.browser.msie && $.browser.version < 7.0) {
  676. $(this).hover(function () {
  677. $(this).addClass('trOver');
  678. }, function () {
  679. $(this).removeClass('trOver');
  680. });
  681. }
  682. });
  683. },
  684. pager: 0
  685. };
  686. if (p.colModel) { //create model if any
  687. thead = document.createElement('thead');
  688. var tr = document.createElement('tr');
  689. for (var i = 0; i < p.colModel.length; i++) {
  690. var cm = p.colModel[i];
  691. var th = document.createElement('th');
  692. th.innerHTML = cm.display;
  693. if (cm.name && cm.sortable) {
  694. $(th).attr('abbr', cm.name);
  695. }
  696. $(th).attr('axis', 'col' + i);
  697. if (cm.align) {
  698. th.align = cm.align;
  699. }
  700. if (cm.width) {
  701. $(th).attr('width', cm.width);
  702. }
  703. if ($(cm).attr('hide')) {
  704. th.hidden = true;
  705. }
  706. if (cm.process) {
  707. th.process = cm.process;
  708. }
  709. $(tr).append(th);
  710. }
  711. $(thead).append(tr);
  712. $(t).prepend(thead);
  713. } // end if p.colmodel
  714. //init divs
  715. g.gDiv = document.createElement('div'); //create global container
  716. g.mDiv = document.createElement('div'); //create title container
  717. g.hDiv = document.createElement('div'); //create header container
  718. g.bDiv = document.createElement('div'); //create body container
  719. g.vDiv = document.createElement('div'); //create grip
  720. g.rDiv = document.createElement('div'); //create horizontal resizer
  721. g.cDrag = document.createElement('div'); //create column drag
  722. g.block = document.createElement('div'); //creat blocker
  723. g.nDiv = document.createElement('div'); //create column show/hide popup
  724. g.nBtn = document.createElement('div'); //create column show/hide button
  725. g.iDiv = document.createElement('div'); //create editable layer
  726. g.tDiv = document.createElement('div'); //create toolbar
  727. g.sDiv = document.createElement('div');
  728. g.pDiv = document.createElement('div'); //create pager container
  729. if (!p.usepager) {
  730. g.pDiv.style.display = 'none';
  731. }
  732. g.hTable = document.createElement('table');
  733. g.gDiv.className = 'flexigrid';
  734. if (p.width != 'auto') {
  735. g.gDiv.style.width = p.width + 'px';
  736. }
  737. //add conditional classes
  738. if ($.browser.msie) {
  739. $(g.gDiv).addClass('ie');
  740. }
  741. if (p.novstripe) {
  742. $(g.gDiv).addClass('novstripe');
  743. }
  744. $(t).before(g.gDiv);
  745. $(g.gDiv).append(t);
  746. //set toolbar
  747. if (p.buttons) {
  748. g.tDiv.className = 'tDiv';
  749. var tDiv2 = document.createElement('div');
  750. tDiv2.className = 'tDiv2';
  751. for (var i = 0; i < p.buttons.length; i++) {
  752. var btn = p.buttons[i];
  753. if (!btn.separator) {
  754. var btnDiv = document.createElement('div');
  755. btnDiv.className = 'fbutton';
  756. btnDiv.innerHTML = "<div><span>" + btn.name + "</span></div>";
  757. if (btn.bclass) $('span', btnDiv).addClass(btn.bclass).css({
  758. paddingLeft: 20
  759. });
  760. btnDiv.onpress = btn.onpress;
  761. btnDiv.name = btn.name;
  762. if (btn.onpress) {
  763. $(btnDiv).click(function () {
  764. this.onpress(this.name, g.gDiv);
  765. });
  766. }
  767. $(tDiv2).append(btnDiv);
  768. if ($.browser.msie && $.browser.version < 7.0) {
  769. $(btnDiv).hover(function () {
  770. $(this).addClass('fbOver');
  771. }, function () {
  772. $(this).removeClass('fbOver');
  773. });
  774. }
  775. } else {
  776. $(tDiv2).append("<div class='btnseparator'></div>");
  777. }
  778. }
  779. $(g.tDiv).append(tDiv2);
  780. $(g.tDiv).append("<div style='clear:both'></div>");
  781. $(g.gDiv).prepend(g.tDiv);
  782. }
  783. g.hDiv.className = 'hDiv';
  784. $(t).before(g.hDiv);
  785. g.hTable.cellPadding = 0;
  786. g.hTable.cellSpacing = 0;
  787. $(g.hDiv).append('<div class="hDivBox"></div>');
  788. $('div', g.hDiv).append(g.hTable);
  789. var thead = $("thead:first", t).get(0);
  790. if (thead) $(g.hTable).append(thead);
  791. thead = null;
  792. if (!p.colmodel) var ci = 0;
  793. $('thead tr:first th', g.hDiv).each(function () {
  794. var thdiv = document.createElement('div');
  795. if ($(this).attr('abbr')) {
  796. $(this).click(function (e) {
  797. if (!$(this).hasClass('thOver')) return false;
  798. var obj = (e.target || e.srcElement);
  799. if (obj.href || obj.type) return true;
  800. g.changeSort(this);
  801. });
  802. if ($(this).attr('abbr') == p.sortname) {
  803. this.className = 'sorted';
  804. thdiv.className = 's' + p.sortorder;
  805. }
  806. }
  807. if (this.hidden) {
  808. $(this).hide();
  809. }
  810. if (!p.colmodel) {
  811. $(this).attr('axis', 'col' + ci++);
  812. }
  813. $(thdiv).css({
  814. textAlign: this.align,
  815. width: this.width + 'px'
  816. });
  817. thdiv.innerHTML = this.innerHTML;
  818. $(this).empty().append(thdiv).removeAttr('width').mousedown(function (e) {
  819. g.dragStart('colMove', e, this);
  820. }).hover(function () {
  821. if (!g.colresize && !$(this).hasClass('thMove') && !g.colCopy) {
  822. $(this).addClass('thOver');
  823. }
  824. if ($(this).attr('abbr') != p.sortname && !g.colCopy && !g.colresize && $(this).attr('abbr')) {
  825. $('div', this).addClass('s' + p.sortorder);
  826. } else if ($(this).attr('abbr') == p.sortname && !g.colCopy && !g.colresize && $(this).attr('abbr')) {
  827. var no = (p.sortorder == 'asc') ? 'desc' : 'asc';
  828. $('div', this).removeClass('s' + p.sortorder).addClass('s' + no);
  829. }
  830. if (g.colCopy) {
  831. var n = $('th', g.hDiv).index(this);
  832. if (n == g.dcoln) {
  833. return false;
  834. }
  835. if (n < g.dcoln) {
  836. $(this).append(g.cdropleft);
  837. } else {
  838. $(this).append(g.cdropright);
  839. }
  840. g.dcolt = n;
  841. } else if (!g.colresize) {
  842. var nv = $('th:visible', g.hDiv).index(this);
  843. var onl = parseInt($('div:eq(' + nv + ')', g.cDrag).css('left'));
  844. var nw = jQuery(g.nBtn).outerWidth();
  845. var nl = onl - nw + Math.floor(p.cgwidth / 2);
  846. $(g.nDiv).hide();
  847. $(g.nBtn).hide();
  848. $(g.nBtn).css({
  849. 'left': nl,
  850. top: g.hDiv.offsetTop
  851. }).show();
  852. var ndw = parseInt($(g.nDiv).width());
  853. $(g.nDiv).css({
  854. top: g.bDiv.offsetTop
  855. });
  856. if ((nl + ndw) > $(g.gDiv).width()) {
  857. $(g.nDiv).css('left', onl - ndw + 1);
  858. } else {
  859. $(g.nDiv).css('left', nl);
  860. }
  861. if ($(this).hasClass('sorted')) {
  862. $(g.nBtn).addClass('srtd');
  863. } else {
  864. $(g.nBtn).removeClass('srtd');
  865. }
  866. }
  867. }, function () {
  868. $(this).removeClass('thOver');
  869. if ($(this).attr('abbr') != p.sortname) {
  870. $('div', this).removeClass('s' + p.sortorder);
  871. } else if ($(this).attr('abbr') == p.sortname) {
  872. var no = (p.sortorder == 'asc') ? 'desc' : 'asc';
  873. $('div', this).addClass('s' + p.sortorder).removeClass('s' + no);
  874. }
  875. if (g.colCopy) {
  876. $(g.cdropleft).remove();
  877. $(g.cdropright).remove();
  878. g.dcolt = null;
  879. }
  880. }); //wrap content
  881. });
  882. //set bDiv
  883. g.bDiv.className = 'bDiv';
  884. $(t).before(g.bDiv);
  885. $(g.bDiv).css({
  886. height: (p.height == 'auto') ? 'auto' : p.height + "px"
  887. }).scroll(function (e) {
  888. g.scroll()
  889. }).append(t);
  890. if (p.height == 'auto') {
  891. $('table', g.bDiv).addClass('autoht');
  892. }
  893. //add td & row properties
  894. g.addCellProp();
  895. g.addRowProp();
  896. //set cDrag
  897. var cdcol = $('thead tr:first th:first', g.hDiv).get(0);
  898. if (cdcol != null) {
  899. g.cDrag.className = 'cDrag';
  900. g.cdpad = 0;
  901. g.cdpad += (isNaN(parseInt($('div', cdcol).css('borderLeftWidth'))) ? 0 : parseInt($('div', cdcol).css('borderLeftWidth')));
  902. g.cdpad += (isNaN(parseInt($('div', cdcol).css('borderRightWidth'))) ? 0 : parseInt($('div', cdcol).css('borderRightWidth')));
  903. g.cdpad += (isNaN(parseInt($('div', cdcol).css('paddingLeft'))) ? 0 : parseInt($('div', cdcol).css('paddingLeft')));
  904. g.cdpad += (isNaN(parseInt($('div', cdcol).css('paddingRight'))) ? 0 : parseInt($('div', cdcol).css('paddingRight')));
  905. g.cdpad += (isNaN(parseInt($(cdcol).css('borderLeftWidth'))) ? 0 : parseInt($(cdcol).css('borderLeftWidth')));
  906. g.cdpad += (isNaN(parseInt($(cdcol).css('borderRightWidth'))) ? 0 : parseInt($(cdcol).css('borderRightWidth')));
  907. g.cdpad += (isNaN(parseInt($(cdcol).css('paddingLeft'))) ? 0 : parseInt($(cdcol).css('paddingLeft')));
  908. g.cdpad += (isNaN(parseInt($(cdcol).css('paddingRight'))) ? 0 : parseInt($(cdcol).css('paddingRight')));
  909. $(g.bDiv).before(g.cDrag);
  910. var cdheight = $(g.bDiv).height();
  911. var hdheight = $(g.hDiv).height();
  912. $(g.cDrag).css({
  913. top: -hdheight + 'px'
  914. });
  915. $('thead tr:first th', g.hDiv).each(function () {
  916. var cgDiv = document.createElement('div');
  917. $(g.cDrag).append(cgDiv);
  918. if (!p.cgwidth) {
  919. p.cgwidth = $(cgDiv).width();
  920. }
  921. $(cgDiv).css({
  922. height: cdheight + hdheight
  923. }).mousedown(function (e) {
  924. g.dragStart('colresize', e, this);
  925. });
  926. if ($.browser.msie && $.browser.version < 7.0) {
  927. g.fixHeight($(g.gDiv).height());
  928. $(cgDiv).hover(function () {
  929. g.fixHeight();
  930. $(this).addClass('dragging')
  931. }, function () {
  932. if (!g.colresize) $(this).removeClass('dragging')
  933. });
  934. }
  935. });
  936. }
  937. //add strip
  938. if (p.striped) {
  939. $('tbody tr:odd', g.bDiv).addClass('erow');
  940. }
  941. if (p.resizable && p.height != 'auto') {
  942. g.vDiv.className = 'vGrip';
  943. $(g.vDiv).mousedown(function (e) {
  944. g.dragStart('vresize', e)
  945. }).html('<span></span>');
  946. $(g.bDiv).after(g.vDiv);
  947. }
  948. if (p.resizable && p.width != 'auto' && !p.nohresize) {
  949. g.rDiv.className = 'hGrip';
  950. $(g.rDiv).mousedown(function (e) {
  951. g.dragStart('vresize', e, true);
  952. }).html('<span></span>').css('height', $(g.gDiv).height());
  953. if ($.browser.msie && $.browser.version < 7.0) {
  954. $(g.rDiv).hover(function () {
  955. $(this).addClass('hgOver');
  956. }, function () {
  957. $(this).removeClass('hgOver');
  958. });
  959. }
  960. $(g.gDiv).append(g.rDiv);
  961. }
  962. // add pager
  963. if (p.usepager) {
  964. g.pDiv.className = 'pDiv';
  965. g.pDiv.innerHTML = '<div class="pDiv2"></div>';
  966. $(g.bDiv).after(g.pDiv);
  967. var html = ' <div class="pGroup"> <div class="pFirst pButton"><span></span></div><div class="pPrev pButton"><span></span></div> </div> <div class="btnseparator"></div> <div class="pGroup"><span class="pcontrol">' + p.pagetext + ' <input type="text" size="4" value="1" /> ' + p.outof + ' <span> 1 </span></span></div> <div class="btnseparator"></div> <div class="pGroup"> <div class="pNext pButton"><span></span></div><div class="pLast pButton"><span></span></div> </div> <div class="btnseparator"></div> <div class="pGroup"> <div class="pReload pButton"><span></span></div> </div> <div class="btnseparator"></div> <div class="pGroup"><span class="pPageStat"></span></div>';
  968. $('div', g.pDiv).html(html);
  969. $('.pReload', g.pDiv).click(function () {
  970. g.populate()
  971. });
  972. $('.pFirst', g.pDiv).click(function () {
  973. g.changePage('first')
  974. });
  975. $('.pPrev', g.pDiv).click(function () {
  976. g.changePage('prev')
  977. });
  978. $('.pNext', g.pDiv).click(function () {
  979. g.changePage('next')
  980. });
  981. $('.pLast', g.pDiv).click(function () {
  982. g.changePage('last')
  983. });
  984. $('.pcontrol input', g.pDiv).keydown(function (e) {
  985. if (e.keyCode == 13) g.changePage('input')
  986. });
  987. if ($.browser.msie && $.browser.version < 7) $('.pButton', g.pDiv).hover(function () {
  988. $(this).addClass('pBtnOver');
  989. }, function () {
  990. $(this).removeClass('pBtnOver');
  991. });
  992. if (p.useRp) {
  993. var opt = '',
  994. sel = '';
  995. for (var nx = 0; nx < p.rpOptions.length; nx++) {
  996. if (p.rp == p.rpOptions[nx]) sel = 'selected="selected"';
  997. else sel = '';
  998. opt += "<option value='" + p.rpOptions[nx] + "' " + sel + " >" + p.rpOptions[nx] + "&nbsp;&nbsp;</option>";
  999. }
  1000. $('.pDiv2', g.pDiv).prepend("<div class='pGroup'><select name='rp'>" + opt + "</select></div> <div class='btnseparator'></div>");
  1001. $('select', g.pDiv).change(function () {
  1002. if (p.onRpChange) {
  1003. p.onRpChange(+this.value);
  1004. } else {
  1005. p.newp = 1;
  1006. p.rp = +this.value;
  1007. g.populate();
  1008. }
  1009. });
  1010. }
  1011. //add search button
  1012. if (p.searchitems) {
  1013. $('.pDiv2', g.pDiv).prepend("<div class='pGroup'> <div class='pSearch pButton'><span></span></div> </div> <div class='btnseparator'></div>");
  1014. $('.pSearch', g.pDiv).click(function () {
  1015. $(g.sDiv).slideToggle('fast', function () {
  1016. $('.sDiv:visible input:first', g.gDiv).trigger('focus');
  1017. });
  1018. });
  1019. //add search box
  1020. g.sDiv.className = 'sDiv';
  1021. var sitems = p.searchitems;
  1022. var sopt = '', sel = '';
  1023. for (var s = 0; s < sitems.length; s++) {
  1024. if (p.qtype == '' && sitems[s].isdefault == true) {
  1025. p.qtype = sitems[s].name;
  1026. sel = 'selected="selected"';
  1027. } else {
  1028. sel = '';
  1029. }
  1030. sopt += "<option value='" + sitems[s].name + "' " + sel + " >" + sitems[s].display + "&nbsp;&nbsp;</option>";
  1031. }
  1032. if (p.qtype == '') {
  1033. p.qtype = sitems[0].name;
  1034. }
  1035. $(g.sDiv).append("<div class='sDiv2'>" + p.findtext +
  1036. " <input type='text' value='" + p.query +"' size='30' name='q' class='qsbox' /> "+
  1037. " <select name='qtype'>" + sopt + "</select></div>");
  1038. //Split into separate selectors because of bug in jQuery 1.3.2
  1039. $('input[name=q]', g.sDiv).keydown(function (e) {
  1040. if (e.keyCode == 13) {
  1041. g.doSearch();
  1042. }
  1043. });
  1044. $('select[name=qtype]', g.sDiv).keydown(function (e) {
  1045. if (e.keyCode == 13) {
  1046. g.doSearch();
  1047. }
  1048. });
  1049. $('input[value=Clear]', g.sDiv).click(function () {
  1050. $('input[name=q]', g.sDiv).val('');
  1051. p.query = '';
  1052. g.doSearch();
  1053. });
  1054. $(g.bDiv).after(g.sDiv);
  1055. }
  1056. }
  1057. $(g.pDiv, g.sDiv).append("<div style='clear:both'></div>");
  1058. // add title
  1059. if (p.title) {
  1060. g.mDiv.className = 'mDiv';
  1061. g.mDiv.innerHTML = '<div class="ftitle">' + p.title + '</div>';
  1062. $(g.gDiv).prepend(g.mDiv);
  1063. if (p.showTableToggleBtn) {
  1064. $(g.mDiv).append('<div class="ptogtitle" title="Minimize/Maximize Table"><span></span></div>');
  1065. $('div.ptogtitle', g.mDiv).click(function () {
  1066. $(g.gDiv).toggleClass('hideBody');
  1067. $(this).toggleClass('vsble');
  1068. });
  1069. }
  1070. }
  1071. //setup cdrops
  1072. g.cdropleft = document.createElement('span');
  1073. g.cdropleft.className = 'cdropleft';
  1074. g.cdropright = document.createElement('span');
  1075. g.cdropright.className = 'cdropright';
  1076. //add block
  1077. g.block.className = 'gBlock';
  1078. var gh = $(g.bDiv).height();
  1079. var gtop = g.bDiv.offsetTop;
  1080. $(g.block).css({
  1081. width: g.bDiv.style.width,
  1082. height: gh,
  1083. background: 'white',
  1084. position: 'relative',
  1085. marginBottom: (gh * -1),
  1086. zIndex: 1,
  1087. top: gtop,
  1088. left: '0px'
  1089. });
  1090. $(g.block).fadeTo(0, p.blockOpacity);
  1091. // add column control
  1092. if ($('th', g.hDiv).length) {
  1093. g.nDiv.className = 'nDiv';
  1094. g.nDiv.innerHTML = "<table cellpadding='0' cellspacing='0'><tbody></tbody></table>";
  1095. $(g.nDiv).css({
  1096. marginBottom: (gh * -1),
  1097. display: 'none',
  1098. top: gtop
  1099. }).noSelect();
  1100. var cn = 0;
  1101. $('th div', g.hDiv).each(function () {
  1102. var kcol = $("th[axis='col" + cn + "']", g.hDiv)[0];
  1103. var chk = 'checked="checked"';
  1104. if (kcol.style.display == 'none') {
  1105. chk = '';
  1106. }
  1107. $('tbody', g.nDiv).append('<tr><td class="ndcol1"><input type="checkbox" ' + chk + ' class="togCol" value="' + cn + '" /></td><td class="ndcol2">' + this.innerHTML + '</td></tr>');
  1108. cn++;
  1109. });
  1110. if ($.browser.msie && $.browser.version < 7.0) $('tr', g.nDiv).hover(function () {
  1111. $(this).addClass('ndcolover');
  1112. }, function () {
  1113. $(this).removeClass('ndcolover');
  1114. });
  1115. $('td.ndcol2', g.nDiv).click(function () {
  1116. if ($('input:checked', g.nDiv).length <= p.minColToggle && $(this).prev().find('input')[0].checked) return false;
  1117. return g.toggleCol($(this).prev().find('input').val());
  1118. });
  1119. $('input.togCol', g.nDiv).click(function () {
  1120. if ($('input:checked', g.nDiv).length < p.minColToggle && this.checked == false) return false;
  1121. $(this).parent().next().trigger('click');
  1122. });
  1123. $(g.gDiv).prepend(g.nDiv);
  1124. $(g.nBtn).addClass('nBtn')
  1125. .html('<div></div>')
  1126. .attr('title', 'Спрятать/Показать Колонки')
  1127. .click(function () {
  1128. $(g.nDiv).toggle();
  1129. return true;
  1130. }
  1131. );
  1132. if (p.showToggleBtn) {
  1133. $(g.gDiv).prepend(g.nBtn);
  1134. }
  1135. }
  1136. // add date edit layer
  1137. $(g.iDiv).addClass('iDiv').css({
  1138. display: 'none'
  1139. });
  1140. $(g.bDiv).append(g.iDiv);
  1141. // add flexigrid events
  1142. $(g.bDiv).hover(function () {
  1143. $(g.nDiv).hide();
  1144. $(g.nBtn).hide();
  1145. }, function () {
  1146. if (g.multisel) {
  1147. g.multisel = false;
  1148. }
  1149. });
  1150. $(g.gDiv).hover(function () {}, function () {
  1151. $(g.nDiv).hide();
  1152. $(g.nBtn).hide();
  1153. });
  1154. //add document events
  1155. $(document).mousemove(function (e) {
  1156. g.dragMove(e)
  1157. }).mouseup(function (e) {
  1158. g.dragEnd()
  1159. }).hover(function () {}, function () {
  1160. g.dragEnd()
  1161. });
  1162. //browser adjustments
  1163. if ($.browser.msie && $.browser.version < 7.0) {
  1164. $('.hDiv,.bDiv,.mDiv,.pDiv,.vGrip,.tDiv, .sDiv', g.gDiv).css({
  1165. width: '100%'
  1166. });
  1167. $(g.gDiv).addClass('ie6');
  1168. if (p.width != 'auto') {
  1169. $(g.gDiv).addClass('ie6fullwidthbug');
  1170. }
  1171. }
  1172. g.rePosDrag();
  1173. g.fixHeight();
  1174. //make grid functions accessible
  1175. t.p = p;
  1176. t.grid = g;
  1177. // load data
  1178. if (p.url && p.autoload) {
  1179. g.populate();
  1180. }
  1181. return t;
  1182. };
  1183. var docloaded = false;
  1184. $(document).ready(function () {
  1185. docloaded = true
  1186. });
  1187. $.fn.flexigrid = function (p) {
  1188. return this.each(function () {
  1189. if (!docloaded) {
  1190. $(this).hide();
  1191. var t = this;
  1192. $(document).ready(function () {
  1193. $.addFlex(t, p);
  1194. });
  1195. } else {
  1196. $.addFlex(this, p);
  1197. }
  1198. });
  1199. }; //end flexigrid
  1200. $.fn.flexReload = function (p) { // function to reload grid
  1201. return this.each(function () {
  1202. if (this.grid && this.p.url) this.grid.populate();
  1203. });
  1204. }; //end flexReload
  1205. $.fn.flexOptions = function (p) { //function to update general options
  1206. return this.each(function () {
  1207. if (this.grid) $.extend(this.p, p);
  1208. });
  1209. }; //end flexOptions
  1210. $.fn.flexToggleCol = function (cid, visible) { // function to reload grid
  1211. return this.each(function () {
  1212. if (this.grid) this.grid.toggleCol(cid, visible);
  1213. });
  1214. }; //end flexToggleCol
  1215. $.fn.flexAddData = function (data) { // function to add data to grid
  1216. return this.each(function () {
  1217. if (this.grid) this.grid.addData(data);
  1218. });
  1219. };
  1220. $.fn.noSelect = function (p) { //no select plugin by me :-)
  1221. var prevent = (p == null) ? true : p;
  1222. if (prevent) {
  1223. return this.each(function () {
  1224. if ($.browser.msie || $.browser.safari) $(this).bind('selectstart', function () {
  1225. return false;
  1226. });
  1227. else if ($.browser.mozilla) {
  1228. $(this).css('MozUserSelect', 'none');
  1229. $('body').trigger('focus');
  1230. } else if ($.browser.opera) $(this).bind('mousedown', function () {
  1231. return false;
  1232. });
  1233. else $(this).attr('unselectable', 'on');
  1234. });
  1235. } else {
  1236. return this.each(function () {
  1237. if ($.browser.msie || $.browser.safari) $(this).unbind('selectstart');
  1238. else if ($.browser.mozilla) $(this).css('MozUserSelect', 'inherit');
  1239. else if ($.browser.opera) $(this).unbind('mousedown');
  1240. else $(this).removeAttr('unselectable', 'on');
  1241. });
  1242. }
  1243. }; //end noSelect
  1244. })(jQuery);