Best JavaScript code snippet using cypress
telnumber.js
Source:telnumber.js
...291 // ãã¬ãã¥ã¼ç»é¢ã®åæè¨å®292 Preview.load();293 // ã«ãã´ãªç·¨éã®ãã©ãã°ã¢ã³ãããããã®æå¹å294 $(Names.mdlCateTable.addHash()).sortable({295 handle: Names.mdlCateSort.addDot()296 });297298 // ãã¼ã¸é¸æç¨ã®ã¡ãã¥ã¼ãé¸æããæã®å¦ç299 $('.cnt h3').on('mouseenter', function() {300 $(this).next('ul').removeClass(Names.hidden).slideDown('fast');301 }).on('mouseleave', function() {302 $(this).next('ul').slideUp('fast');303 });304305 // åæ表示ã§ç¤¾å
ç¨ãåä»å
¨è¬ã表示ããããã«ãã306 /*Ajaxs.get('html/get/index');*/307 };308309310 // ã¤ãã³ã311 var Events = {312 // åæåæã«ç»é²ããã¤ãã³ã313 add: function() {314 /* ä¸é¨ã®ãã¿ã³ã®åºå® ----------------------------------------------- */315 var $head = $('.cnt-head').first();316 $(window).on('scroll', function() {317 if ($(window).scrollTop() > $('.site-header').first().outerHeight(true)) {318 $head.addClass(Names.fixed);319 } else {320 $head.removeClass(Names.fixed);321 }322 });323324325 /* 表ã®ã¤ãã³ã ----------------------------------------------------- */326 // ããã¼327 var hovers =[328 Names.tblWrap.addDot() + ' tbody tr',329 Names.tblWrap.addDot() + ' tbody th',330 Names.tblWrap.addDot() + ' tbody td'331 ];332 // è¡ã»ã»ã«ã®ããã¼æã«ããã¼ã¯ã©ã¹ã®ä»ä¸333 $(document).on('mouseenter', hovers.join(','), function (e) {334 $(this).addClass(Names.hover);335 }).on('mouseleave', hovers.join(','), function () {336 $(this).removeClass(Names.hover);337 });338 // è¡ã®ããã¼æã«æ ç·ã表示339 // $(document).on('mouseenter', Names.tblWrap.addDot() + ' tbody tr', function () {340 // DataTable.hoverRow(this);341 // });342 // ã»ã«ã®ããã¼æã«è¿½å ãã¿ã³ã表示343 hovers.shift();344 $(document).on('mouseenter.hover', hovers.join(','), function () {345 Cells.addAddBoxBtn(this);346 }).on('mouseleave.hover', hovers.join(','), function () {347 Cells.removeAddBoxBtn();348 });349 // ã»ã«å
ã³ã³ãã³ãã®è¿½å ãã¿ã³ãæ¼ããæã®å¦ç350 $(document).on('click', Names.btnAddBox.addHash(), function() {351 Cells.addBox(this);352 });353354355 /* ã»ã«å
ã³ã³ãã³ãã§ã®å¦ç ---------------------------------------------*/356 // ã»ã«å
ã³ã³ãã³ãã®ãã©ãã°ã¢ã³ãããããå¦ç357 Events.addCellHovers();358 // ã»ã«å
ã®ã³ã³ãã³ããããã¯ç¨ã®ã¤ãã³ã359 Events.addContentsBlock();360361362 /* theadã§ã®å¦ç ---------------------------------------------------*/363 $(document).on('mouseenter', Names.tblWrap.addDot() + 'thead th', function() {364 $(this).append($(Names.btnsPanelThead.addHash()).removeClass(Names.hidden));365 }).on('mouseleave', 'thead th', function() {366 $('body').append($(Names.btnsPanelThead.addHash()).addClass(Names.hidden));367 });368 // ç·¨éãã¿ã³ãæ¼ããæã®å¦ç369 $(Names.btnEditThead.addHash()).on('click', function() {370 Cells.editThead($(this).parents('th').first());371 $('body').append($(Names.btnsPanelThead.addHash()).addClass(Names.hidden));372 });373 // theadã®thãããã«ã¯ãªãã¯ããæã®å¦ç374 $(document).on('dblclick', 'thead th', function() {375 Cells.editThead(this);376 });377 // theadã®thã®ç·¨éããã«ã§åæ ãããã¿ã³ãæ¼ããæã®å¦ç378 $(Names.headEdit.addHash() + '-reflection').on('click', function() {379 Cells.updateThead(this);380 });381 // theadã®thã®ç·¨éããã«ã§ãã£ã³ã»ã«ãã¿ã³ãæ¼ããæã®å¦ç382 $(Names.headEdit.addHash() + '-cancel').on('click', function() {383 Cells.cancelThead(this);384 });385 // ç·¨éããã«ä¸ã®ã¯ãªãã¯ã®æã¯ä½ãããªã386 $(Names.headEdit.addHash()).on('click', function() {387 return false;388 });389 // theadç·¨éããã«ã®ã©ãããã¯ãªãã¯ããæã«éãã390 $(Names.headEdit.addHash() + '-wrap').on('click', function() {391 Cells.cancelThead(this);392 });393394395 /* tfootã§ã®å¦ç ---------------------------------------------------*/396 // tfootã®ã»ã«ãããã«ã¯ãªãã¯ããæã®å¦ç397 Events.addTfoot();398 // tfootãããã©ã¼ã«ã¹ãå¤ããã¨ãã®å¦ç399 $(document).on('blur', 'tfoot textarea', function() {400 Cells.updateTfoot(this);401 });402403404 /* ã»ã«å
ã³ã³ãã³ãã®ç·¨éããã« -------------------------------------------------- */405 // ã»ã«å
ã³ã³ãã³ãç·¨éããã«ãéããæã®å¦ç406 $(EditNames.panel.addHash()).on('hidden.bs.modal', function(e) {407 EditPanel.hide(e);408 });409 // ã»ã«å
ã³ã³ãã³ãã®ç·¨éããã«å
ã®ããã¹ãã¨ãªã¢ãWYSIWYGã¨ãã£ã¿ã«å¤æ410 EditPanel.setWyswyg();411 // ã»ã«å
ã³ã³ãã³ãã®ç·¨éããã«å
ã®ã¤ãã³ã412 Events.addModalEdit();413414415 /* ã³ã³ããã¹ãã¡ãã¥ã¼ ------------------------------------------------- */416 // 表示417 $(document).on('contextmenu', Names.tblWrap.addDot() + ' tbody', function (e) {418 Context.show(this, e);419 // æ¨æºã®ã³ã³ããã¹ãã¡ãã¥ã¼ã®ãã£ã³ã»ã«420 return false;421 });422 // é表示423 $(document).on('click', Names.ctm.addHash(), function () {424 $('tbody').find(Names.hover.addDot()).removeClass(Names.hover);425 $('tbody').find(Names.ctmHover.addDot()).removeClass(Names.ctmHover);426 $('tbody').find(Names.uiSelected.addDot() + Names.hidden.addDot()).removeClass(Names.uiSelected);427 Context.hide(this);428 }).on('contextmenu', Names.ctm.addHash(), function() {429 $(this).trigger('click');430 return false;431 });432 // ã³ã³ããã¹ãã¡ãã¥ã¼å
ã®ã¤ãã³ããç»é²433 Events.addContext();434435436 /* ã«ãã´ãªã®ç·¨éé¢ä¿ã¤ãã³ã ------------------------------------------- */437 // ã«ãã´ãªç·¨éç¨ã¢ã¼ãã«è¡¨ç¤ºæã®å¦ç438 $(Names.mdlCate.addHash()).on('show.bs.modal', function(e) {439 ModalCate.show(this);440 });441 // ã«ãã´ãªç·¨éç¨ã¢ã¼ãã«å
ã®ã¤ãã³ã442 Events.addModalCategory();443444445 /* ååãå
ä¸è¦§é¢ä¿ã¤ãã³ã ------------------------------------------- */446 // ååãå
ä¸è¦§ç¨ã¢ã¼ãã«è¡¨ç¤ºæã®å¦ç447 // $(Names.mdlMenu.addHash()).on('show.bs.modal', function(e) {448 // ModalMenu.show($(this).find('table').first());449 // });450 // ååãä¸è¦§é¸æç¨ã¢ã¼ãã«ç»é¢å
ã®ã¤ãã³ã451 Events.addModalMenu();452453 $('.title').on('mouseenter', function() {454 $(this).children('ul').stop().slideDown();455 }).on('mouseleave', function() {456 $(this).children('ul').stop().slideUp();457 });458459460 /* ãã¬ãã¥ã¼ç»é¢ã§ã®ã¤ãã³ã ------------------------------------------- */461 // éãããã¿ã³ãæ¼ããæã®å¦ç462 $(Names.btnCancel.addHash()).on('click', function() {463 Preview.hide();464 });465 // æ¬çªç°å¢ã«å
¬éãããã¿ã³ãæ¼ããæã®å¦ç466 $(Names.btnPublishing.addHash()).on('click', function() {467 Contents.publishing();468 });469470471 /* ãä¸æ¸ãä¿åããããã¿ã³ã¤ãã³ã ---------------------------------------------- */472 $(Names.btnSave.addHash()).on('click', function() {473 Contents.save();474 });475476 /* ããã¬ãã¥ã¼ããã¿ã³ã¤ãã³ã --- ------------------------------------------- */477 $(Names.btnPreview.addHash()).on('click', function() {478 Preview.show();479 });480 },481 // tfootã¨ãªã¢ã®ã¤ãã³ã482 addTfoot: function() {483 $(document).on('dblclick', 'tfoot td', function() {484 Cells.editTfoot(this);485 });486 },487 removeTfoot: function() {488 $(document).off('dblclick', 'tfoot td');489 },490 // ã³ã³ããã¹ãã¡ãã¥ã¼å
ã®ã¤ãã³ã491 addContext: function() {492 // ã³ã³ããã¹ãã®è¡ã®ä¸ã¸ç§»å493 $(Names.ctmMoveUp.addHash()).on('click', function () {494 if ($(this).hasClass(Names.disabled)) {495 return false;496 }497 DataTable.moveUpRow();498 }).on('mouseenter', function () {499 if (!$(this).hasClass(Names.disabled)) {500 DataTable.hoverUpRow();501 }502 }).on('mouseleave', function () {503 // ã»ãã¬ã¼ã¿ã¨èæ¯ãé表示504 $(Names.showMoveRow.addDot()).removeClass(Names.showMoveRow);505 $(Names.rowSeparator.addHash()).hide();506 });507 // ã³ã³ããã¹ãã®è¡ã®ä¸ã¸ç§»å508 $(Names.ctmMoveDown.addHash()).on('click', function () {509 if ($(this).hasClass(Names.disabled)) {510 return false;511 }512 DataTable.moveDownRow();513 }).on('mouseenter', function () {514 if (!$(this).hasClass(Names.disabled)) {515 DataTable.hoverDownRow();516 }517 }).on('mouseleave', function () {518 // ã»ãã¬ã¼ã¿ã¨èæ¯ãé表示519 $(Names.showMoveRow.addDot()).removeClass(Names.showMoveRow);520 $(Names.rowSeparator.addHash()).hide();521 });522 // ã³ã³ããã¹ãã®ã»ã«ã®çµåã¤ãã³ã523 $(Names.ctmJoinCell.addHash()).on('click', function () {524 if ($(this).hasClass(Names.disabled)) {525 return false;526 }527 DataTable.joinCell();528 });529 // ã³ã³ããã¹ãã®ã»ã«ã®åå²ã¤ãã³ã530 $(Names.ctmSplitCell.addHash()).on('click', function () {531 if ($(this).hasClass(Names.disabled)) {532 return false;533 }534 DataTable.splitCell();535 });536 // ã³ã³ããã¹ãã®ã»ã«ã®ååå²ã¤ãã³ã537 $(Names.ctmSplitCol.addHash()).on('click', function () {538 if ($(this).hasClass(Names.disabled)) {539 return false;540 }541 DataTable.splitCol();542 });543 // ã³ã³ããã¹ãã®è¡ã®è¿½å ã¤ãã³ã544 $(Names.ctmAddRow.addHash()).on('click', function () {545 if ($(this).hasClass(Names.disabled)) {546 return false;547 }548 DataTable.addRow(this);549 }).on('mouseenter', function () {550 if (!$(this).hasClass(Names.disabled)) {551 DataTable.hoverAddRow();552 }553 }).on('mouseleave', function () {554 $(Names.rowSeparator.addHash()).hide();555 });556 // ã³ã³ããã¹ãã®è¡ã®åé¤ã¤ãã³ã557 $(Names.ctmDelRow.addHash()).on('click', function () {558 if ($(this).hasClass(Names.disabled)) {559 return false;560 }561 DataTable.delRow(this);562 }).on('mouseenter', function () {563 DataTable.hoverDelRow();564 }).on('mouseleave', function () {565 $(Names.showDelRow.addDot()).removeClass(Names.showDelRow);566 });567 // 2å表示568 $(Names.ctmTitle2Col.addHash()).on('click', function () {569 if ($(this).hasClass(Names.disabled)) {570 return false;571 }572 DataTable.show2Col();573 });574 // 3å表示575 $(Names.ctmTitle3Col.addHash()).on('click', function () {576 if ($(this).hasClass(Names.disabled)) {577 return false;578 }579 DataTable.show3Col();580 });581 // ããã¿ã¼è¡ã®è¿½å 582 $(Names.ctmAddTfoot.addHash()).on('click', function () {583 if ($(this).hasClass(Names.disabled)) {584 return false;585 }586 DataTable.addTfoot();587 });588 // ããã¿ã¼è¡ã®åé¤589 $(Names.ctmDelTfoot.addHash()).on('click', function () {590 if ($(this).hasClass(Names.disabled)) {591 return false;592 }593 DataTable.removeTfoot();594 });595 },596 // ã»ã«å
ã®ã³ã³ãã³ããããã¯ç¨ã®ã¤ãã³ã597 addContentsBlock: function() {598 // ã»ã«å
ã³ã³ãã³ãã®åé¤ãã¿ã³ãæ¼ããæã®å¦ç599 $(document).on('click', Names.btnDelBox.addHash(), function() {600 var $parentBox = $(this).parents(BoxNames.wrap.addDot()).first();601 if (confirm("åé¤ããã¨å
ã«æ»ãã¾ããã\nåé¤ãã¾ããï¼")) {602 Cells.removeBox($parentBox);603 }604 });605 // ã»ã«å
ã³ã³ãã³ãã®ç·¨éç»é¢è¡¨ç¤ºã®éã®å¦ç606 $(document).on('click', Names.btnEditBox.addHash(), function() {607 EditPanel.show(this);608 }).on('dblclick', BoxNames.wrap.addDot(), function() {609 // ã»ã«å
ã³ã³ãã³ããããã«ã¯ãªãã¯ããæã®å¦ç610 EditPanel.show($(this).children().first());611 });612 },613 // ã»ã«ã®ãããã¯ç·¨éç¨ã¢ã¼ãã«ç»é¢å
ã®ã¤ãã³ã614 addModalEdit: function() {615 // ã»ã«å
ã³ã³ãã³ãã®å
容ãæ´æ°ããæã®å¦ç616 $(document).on('click', EditNames.btnUpdate.addHash(), function() {617 EditPanel.update();618 });619 $(document).on('click', EditNames.btnCancel.addHash(), function() {620 var $editBox = $(EditNames.panel.addHash()).data(Names.dataTargetElm);621 if ($(EditNames.panel.addHash()).data('addState')) {622 $editBox.remove();623 }624 });625 // ç·¨éããã«ã®å¤ãå¤ãã£ãæã®å¦ç626 var changes =[627 EditNames.panel.addHash() + ' input',628 EditNames.panel.addHash() + ' textarea',629 EditNames.panel.addHash() + ' select',630 ];631 $(document).on('change enter.imeEnter', changes.join(','), function() {632 EditPanel.setVal(this);633 });634 // é»è©±çªå·ã®è¿½å 635 $(document).on('click', EditNames.btnPhoneAdd.addHash(), function () {636 EditPanel.addPhone(this);637 });638 // é»è©±çªå·ã®åé¤639 $(document).on('click', EditNames.btnPhoneDel.addDot(), function () {640 EditPanel.delPhone(this);641 });642 // ã¡ã¼ã«ã¢ãã¬ã¹ã®è¿½å 643 $(document).on('click', EditNames.btnMailAdd.addHash(), function () {644 EditPanel.addMail(this);645 });646 // ã¡ã¼ã«ã¢ãã¬ã¹ã®åé¤647 $(document).on('click', EditNames.btnMailDel.addDot(), function () {648 EditPanel.delMail(this);649 });650 // ããã¹ãã¨ãªã¢ã®èª¬ææã®éé651 $(document).on('click', '.edit-note-title', function() {652 $(this).next('.edit-note-wrap').slideToggle('fast');653 });654 // fieldsetã®éé655 $(document).on('click', '.edit-section-title', function() {656 if ($(this).hasClass('close')) {657 $(this).removeClass('close');658 } else {659 $(this).addClass('close');660 }661 $(this).next('fieldset').slideToggle('fast');662 });663664 //æåãé¸æããã¦ãããå¤æ665 var checkSelectionText = function () {666 return getSelection().toString().length > 0;667 };668 var getSelection = function () {669 if (window.getSelection) {670 return window.getSelection();671 } else if (document.getSelection) {672 return document.getSelection();673 } else if (document.selection) {674 return document.selection;675 }676 };677 // å°æåãã¿ã³678 $(document).on('click', '.small', function () {679 if (checkSelectionText()) {680 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()681 .find(EditNames.editBox.addDot() + '-editbox').first();682 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()683 .find(EditNames.editBox.addDot()).first();684 $inputArea.focus();685686 var selection = getSelection();687 var range = selection.getRangeAt(0);688 var font = document.createElement('font');689 font.style.fontSize = 'smaller';690 range.surroundContents(font);691692 $textArea.val($inputArea.html()).trigger('input');693 }694 });695 // 赤åãã¿ã³696 $(document).on('click', '.red', function () {697 if (checkSelectionText()) {698 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()699 .find(EditNames.editBox.addDot() + '-editbox').first();700 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()701 .find(EditNames.editBox.addDot()).first();702 $inputArea.focus();703704 var selection = getSelection();705 var range = selection.getRangeAt(0);706 var font = document.createElement('font');707 font.style.color = 'rgb(204,0,0)';708 range.surroundContents(font);709710 $textArea.val($inputArea.html()).trigger('input');711 }712 });713 // 太åãã¿ã³714 $(document).on('click', '.bold', function () {715 if (checkSelectionText()) {716 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()717 .find(EditNames.editBox.addDot() + '-editbox').first();718 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()719 .find(EditNames.editBox.addDot()).first();720 $inputArea.focus();721722 var selection = getSelection();723 var range = selection.getRangeAt(0);724 var font = document.createElement('font');725 font.style.fontWeight = 'bold';726 range.surroundContents(font);727728 $textArea.val($inputArea.html()).trigger('input');729 }730 });731 var rng;732 // ãªã³ã¯ãã¿ã³733 $(document).on('click', '.link', function () {734 // if (checkSelectionText()) {735 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()736 .find(EditNames.editBox.addDot() + '-editbox').first();737 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()738 .find(EditNames.editBox.addDot()).first();739 $inputArea.focus();740741 var selection = getSelection();742 rng = selection.getRangeAt(0);743744 var $inputPanel = $(this).parents(EditNames.editBox.addDot() + '-wrap').first().find('.edit-link').first();745 $inputPanel.data('state', 'link');746 $inputPanel.find('.edit-link-blank-label').first().show();747 $inputPanel.find('.edit-link-blank').first().prop('checked', false);748 $(this).parent().append($('#modal-back'));749 $('#modal-back').show();750 $inputPanel.show();751 $inputPanel.find('input').first().val('').focus();752 // }753 });754 // ã¡ã¼ã«æ¿å
¥ãã¿ã³755 $(document).on('click', '.mail', function () {756 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()757 .find(EditNames.editBox.addDot() + '-editbox').first();758 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()759 .find(EditNames.editBox.addDot()).first();760 $inputArea.focus();761762 var selection = getSelection();763 rng = selection.getRangeAt(0);764765 var $inputPanel = $(this).parents(EditNames.editBox.addDot() + '-wrap').first().find('.edit-link').first();766 $inputPanel.data('state', 'mail');767 $inputPanel.find('.edit-link-blank-label').first().hide();768 $(this).parent().append($('#modal-back'));769 $('#modal-back').show();770 $inputPanel.show();771 $inputPanel.find('input').first().val('').focus();772 });773 // ãªã³ã¯æ¿å
¥ããã«æ´æ°774 $(document).on('click', '.edit-link-submit', function() {775 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()776 .find(EditNames.editBox.addDot() + '-editbox').first();777 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()778 .find(EditNames.editBox.addDot()).first();779 var $inputPanel = $(this).parents('.edit-link').first();780 var val = $(this).parents('div').first().find('input').first().val();781782 if (val !== '') {783 var a = document.createElement('a');784 var hrefVal = $inputPanel.data('state') === 'link' ? val : 'mailto:' + val;785 a.setAttribute('href', hrefVal);786 if ($inputPanel.find('.edit-link-blank').first().prop('checked')) {787 a.setAttribute('target', '_blank');788 }789 $inputArea.focus();790 if (rng.collapsed) {791 a.innerHTML = val;792 rng.insertNode(a);793 } else {794 try {795 rng.surroundContents(a);796 } catch(e) {797 alert('åãç¯å²ã«ãã§ã«ãªã³ã¯ãæ¿å
¥ããã¦ãã¾ã');798 }799 }800801 $textArea.val($inputArea.html()).trigger('input');802 }803804 $('body').append($('#modal-back'));805 $('#modal-back').hide();806 $(this).parents('.edit-link').first().hide();807 });808 // ãªã³ã¯æ¿å
¥ããã«ãã£ã³ã»ã«809 $(document).on('click', '.edit-link-cancel', function() {810 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()811 .find(EditNames.editBox.addDot() + '-editbox').first();812813 $('body').append($('#modal-back'));814 $('#modal-back').hide();815 $(this).parents('.edit-link').first().hide();816 });817 // èæ¯ãã¯ãªãã¯ããæã«ãªã³ã¯æ¿å
¥ããã«ãéãã818 $('#modal-back').on('click', function() {819 $('body').append($('#modal-back'));820 $('#modal-back').hide();821 $('.edit-link').hide();822 });823 // ã¢ã³ã»ãããã¿ã³824 $(document).on('click', '.reset', function () {825 if (checkSelectionText()) {826 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()827 .find(EditNames.editBox.addDot() + '-editbox').first();828 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()829 .find(EditNames.editBox.addDot()).first();830 $inputArea.focus();831 document.execCommand('removeformat');832 document.execCommand('unlink');833834 $textArea.val($inputArea.html()).trigger('input');835 }836 });837 // ã½ã¼ã¹ã®è¡¨ç¤ºãã¿ã³838 $(document).on('click', '.source', function () {839 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()840 .find(EditNames.editBox.addDot() + '-editbox').first();841 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()842 .find(EditNames.editBox.addDot()).first();843 if ($inputArea.is(':visible')) {844 $(this).parent().children('button').each(function() {845 if (!$(this).hasClass('source')) {846 $(this).addClass('hidden');847 }848 });849 $inputArea.hide();850 $textArea.show().focus();851 $(this).text('ç·¨éã¨ãªã¢ã®è¡¨ç¤º');852 } else {853 $(this).parent().children('button').each(function() {854 if (!$(this).hasClass('source')) {855 $(this).removeClass('hidden');856 }857 });858 var val = $textArea.val();859 // scriptã¨ããæåãåé¤860 val = val.replace(/(<\/?)script/gi, "$1span");861 $textArea.val(val);862 $inputArea.html(val);863 $textArea.hide();864 $inputArea.show().focus();865 $(this).text('ã½ã¼ã¹ã®è¡¨ç¤º');866 }867 });868 },869 // ã«ãã´ãªç·¨éã¢ã¼ãã«å
ã®ã¤ãã³ã870 addModalCategory: function() {871 // ã«ãã´ãªã¼ç·¨éã¢ã¼ãã«ã®è¡ã®ã表示ããåé¤ãã®å¤ãå¤ãã£ãæã®å¦ç872 $(document).on('change', Names.mdlCateEnable.addDot(), function() {873 ModalCate.changeCateEnable(this);874 });875876 // ã«ãã´ãªã®è¿½å ãã¿ã³ãæ¼ããæã®å¦ç877 $(Names.mdlCateBtnAdd.addHash()).on('click', function() {878 ModalCate.addRow();879 });880881 // ã«ãã´ãªã®åæ ãããã¿ã³ãæ¼ããæã®å¦ç882 $(Names.mdlCateBtnRef.addHash()).on('click', function() {883 ModalCate.reflect();884 });885886 // ã«ãã´ãªã®ååã®ããªãã¼ã·ã§ã³å¦ç887 $(document).on('change', Names.mdlCateName.addDot(), function() {888 ModalCate.validateName(this);889 });890891 // ã«ãã´ãªã®idã®ããªãã¼ã·ã§ã³å¦ç892 $(document).on('change', Names.mdlCateId.addDot(), function() {893 ModalCate.validateId(this);894 });895896 // ã«ãã´ãªã®classã®ããªãã¼ã·ã§ã³å¦ç897 $(document).on('change', Names.mdlCateClass.addDot(), function() {898 ModalCate.validateClass(this);899 });900901 // ç·¨éããã«ã®ãã©ãã°å¦ç902 var $modal = $(EditNames.panel.addHash());903 var $dragElm = $modal.find(".modal-header").first();904 var $moveElm = $modal.find(".modal-content").first();905 var moveFlag;906 var offsetTop;907 var offsetLeft;908 // ãã©ãã°ã¯ã©ã¹ã®ä»ä¸909 $dragElm.addClass(Names.drag);910 // ãã¦ã¹ãã¦ã³ããæã«åº§æ¨ãåå¾911 $dragElm.on("mousedown", function (event) {912 moveFlag = true;913 event = (event) || window.event;914 offsetTop = event.clientY - $moveElm.offset().top;915 offsetLeft = event.clientX - $moveElm.offset().left;916 });917 // ãã¦ã¹ã¢ããããæã«ç§»åãã©ã°ãç¡å¹ã«ãã918 $(document).on("mouseup", function () {919 moveFlag = false;920 });921 // ãã¦ã¹ãåããæã«ç§»åãã922 $(document).on("mousemove", function (event) {923 event = (event) || window.event;924 if (moveFlag) {925 $moveElm.offset({926 top: event.clientY - offsetTop,927 left: event.clientX - offsetLeft928 });929 }930 });931 },932 // ååãä¸è¦§ãã¼ã¸ã®é¸æç¨ã¢ã¼ãã«å
ã®ã¤ãã³ã933 addModalMenu: function() {934 // ååãä¸è¦§ã®ãªã¹ããé¸æããæã®å¦ç935 // $(document).on('click', Names.mdlMenu.addHash() + ' li', function() {936 // ModalMenu.liSelect(this);937 // });938 $(document).on('click', Names.mdlMenu.addHash() + ' .title li', function() {939 ModalMenu.liSelect(this);940 ModalMenu.getPage(this);941 });942943 // é¸æãããã¼ã¸ã表示ãããã¿ã³ãæ¼ããæã®å¦ç944 // $(Names.mdlMenuBtnShow.addHash()).on('click', function() {945 // ModalMenu.getPage();946 // });947 },948 /* ã»ã«å
ã³ã³ãã³ãã®ãã©ãã°ã¢ã³ãããããæã®ã¤ãã³ã -------------------------------- */949 // ã¤ãã³ãã®è¿½å 950 addCellHovers: function() {951 // ç·¨éç¨ãã¼ã¸ã表示ããã¦ããã¨ãã¯selectableãæå¹ã«ãã952 if ($(Names.cntBody.addDot()).first().find('table').length > 0) {953 $('tbody').selectable('enable');954 }955 // ã»ã«å
ã³ã³ãã³ãã«ããã¼ããéã«ç§»åãã¼ãæ¿å
¥956 $(document).on('mouseenter', BoxNames.wrap.addDot(), function () {957 $('tbody').selectable('disable');958 if (!isSorting) {959 // 移åãã¼ã®æ¿å
¥960 Cells.addMoveBox(this);961 // ããã¼ã¯ã©ã¹ã®ä»ä¸962 $(this).parents('tbody').first().find(Names.ctmHover.addDot()).removeClass(Names.ctmHover);963 $(this).addClass(Names.hover);964 // ãã©ãã°ã¢ã³ãããããã®æå¹å965 Cells.enableSortableCol(this);966 }967 }).on('mouseleave', BoxNames.wrap.addDot(), function () {968 $('tbody').selectable('enable');969 if (!isSorting) {970 // 移åãã¼ã®åé¤971 Cells.removeMoveBox();972 // ããã¼ã¯ã©ã¹ã®åé¤973 $(this).removeClass(Names.hover);974 // ãã©ãã°ã¢ã³ãããããã®ç¡å¹å975 Cells.disableSortableCol(this);976 }977 });978 },979 // ã¤ãã³ãã®åé¤980 removeCellHovers: function(colClasses) {981 // ãã¼ãã«ã»ã«ã®é¸æãç¡å¹å982 $('tbody').selectable('disable');983 // ã»ã«å
ã®ããã¯ã¹ãããã¼ãããæã®ã¤ãã³ããç¡å¹å984 $(document).off('mouseenter.hover', BoxNames.wrap.addDot());985 }986 };987988// â
ajaxè¨å®ããããã»ã»ã»ã»ã»989990 // ajaxã®åæå¤991 $.ajaxSetup({992 'type' : 'GET',993 'dataType': 'json',994 'cache': false,995 'headers': {996 'Pragma': 'no-cache'997 }998 });999 // ajaxå¦ç1000 var Ajaxs = {1001 get: function(url) {1002 Loading.show();1003 $.ajax({1004 url: url,1005 }).done(function(res) {1006 // ã³ã³ãã³ãã®ã¯ãªã¢1007 Contents.clearBody();1008 // ã¡ãã»ã¼ã¸ã®ããå ´åã¯ãã¤ã¢ãã°ã表示1009 if (res.message) {1010 alert(res.message);1011 }1012 // åãåã£ãã¹ãã¼ã¿ã¹ã«ããç»åã®è¡¨ç¤ºã»é表示1013 if (res.state == 200) {1014 ImgInduction.hide();1015 TopButtons.show();1016 } else {1017 ImgInduction.show();1018 TopButtons.hide();1019 return;1020 }1021 // ã³ã³ãã³ãã®ã»ãã1022 Contents.setBody(res.Data);1023 // ç·¨éãã©ã°ã®ãªã»ãã1024 isEdit = false;1025 }).always(function() {1026 // ãã¼ãã£ã³ã°ã®é表示1027 Loading.hide();1028 });1029 },1030 update: function(url, data) {1031 Loading.show();1032 $.ajax({1033 url: url,1034 type: 'POST',1035 data: data1036 }).done(function(res) {1037 // ã¨ã©ã¼ã®æã¯ã¡ãã»ã¼ã¸ã表示ãã¦çµäºãã1038 if (res.state == 404) {1039 alert(res.message);1040 return;1041 }1042 // ã³ã³ãã³ãã®ã¯ãªã¢1043 Contents.clearBody();1044 // ã³ã³ãã³ãã®åã»ãã1045 Contents.setBody(res.Data, true);1046 // ç·¨éãã©ã°ã®ãªã»ãã1047 isEdit = false;1048 }).always(function() {1049 // ãã¼ãã£ã³ã°ã®é表示1050 Loading.hide();1051 });1052 }1053 };10541055 // ãã¼ãã£ã³ã°1056 var Loading = {1057 // ãã¼ãã£ã³ã°ç»é¢ã®è¡¨ç¤º1058 show: function() {1059 $(Names.mdlLoading.addHash()).removeClass(Names.hidden);1060 },1061 // ãã¼ãã£ã³ã°ç»é¢ã®é表示1062 hide: function() {1063 $(Names.mdlLoading.addHash()).addClass(Names.hidden);1064 }1065 };10661067 // ç»é¢ä¸é¨ã®ãã¿ã³ç¾¤1068 var TopButtons = {1069 // ãã¿ã³ãæå¹å1070 show: function() {1071 $(Names.cntHeadBtns.addHash()).children('button').removeClass(Names.disabled);1072 },1073 // ãã¿ã³ãç¡å¹å1074 hide: function() {1075 $(Names.cntHeadBtns.addHash()).children('button').addClass(Names.disabled);1076 }1077 };10781079 // èªå°ç¨ç»åã®è¡¨ç¤ºã»é表示1080 var ImgInduction ={1081 // èªå°ç¨ç»åã®ãã³ãã¬ã¼ãï¼å®éã«ã¯indexããåå¾ããçºç©ºæåã§OKï¼1082 tmp: '<img id="' + Names.cntBodyEmptyImg + '" src="img/page-select.png">',1083 // indexããèªå°ç»åã¨ã¬ã¡ã³ããã¯ãã¼ã³ãã1084 copy: function() {1085 ImgInduction.tmp = $(Names.cntBodyEmptyImg.addHash()).clone();1086 },1087 // èªå°ç»åã®è¡¨ç¤º1088 show: function() {1089 $(Names.cntBody.addDot()).first().append($(ImgInduction.tmp));1090 },1091 // èªå°ç»åã®é表示1092 hide: function() {1093 $(Names.cntBody.addDot()).find(Names.cntBodyEmptyImg.addHash()).remove();1094 }1095 };10961097 var Contents = {1098 // 表示ãã¦ããã³ã³ãã³ãã®ã¯ãªã¢1099 clearBody: function() {1100 $(Names.cntBody.addDot()).empty();1101 },1102 // ã³ã³ãã³ãã®åã»ãã1103 setBody: function(Data, showSuccess) {1104 $(window).scrollTop(0);1105 // ãã¼ãã«ãã¼ã¿ãæ¿å
¥1106 var $wrap = $('<div></div>').attr('id', Names.cntBodyDataWrap);1107 $wrap.append($(Data.html));1108 $(Names.cntBody.addDot()).first().append($wrap);1109 // ã»ã¬ã¯ã¿ãã«ã®è¨å®1110 DataTable.addSelectEvent();1111 // ã³ã³ãã³ãããã¯ã¹ã®ãã©ãã°ã¢ã³ãããããæå¹å1112 Cells.addSortableCol();1113 // ã¿ã¤ãã«ãæ¿å
¥1114 var title = Data.in_ex == 1 ? '社å
ç¨ã' : 'ã客ãã¾ç¨ã';1115 var dates = '<div class="date-update"><span>ä¸æ¸ãä¿åæ¥æ</span>ï¼' + (Data.updated !== '0000-00-00 00:00:00' ? Data.updated : 'æªä¿å') + '</div>';1116 dates += '<div class="date-release"><span>æçµæ´æ°æ¥æ</span>ï¼' + (Data.released !== '0000-00-00 00:00:00' ? Data.released : 'æªå
¬é') + '</div>';1117 title += Data.title;1118 $(Names.cntBody.addDot()).first()1119 .prepend(1120 $('<div class="note"></div>').text('â»ã»ã«ã®çµåãè¡ã®è¿½å ã移åçã®æä½ã¯ããã¼ãã«ä¸ã§å³ã¯ãªãã¯ã§è¡¨ç¤ºãããã¡ãã¥ã¼ããè¡ã£ã¦ãã ããã')1121 )1122 .prepend(1123 $('<div class="dates"></div>').append($(dates))1124 )1125 .prepend(1126 $('<h2></h2>').text(title)1127 .addClass('h2-default')1128 .append(1129 $('<span></span>').text(Data.name)1130 .attr('id', Names.cntName)1131 .data(Names.dataUpdate, Data.updated)1132 )1133 );1134 // å
¬éãã¦ããªãå ´åã¯ã¢ã©ã¼ãããã«ã表示1135 if (Data.is_release === '0') {1136 $(Names.cntBody.addDot()).first().prepend(1137 $('<div></div>').text('å
¬éããã¦ãã¾ãã').addClass(Names.cntBodyPnlAlert)1138 );1139 $(Names.cntBody.addDot()).first().find('.date-release').first().addClass('alert');1140 } else {1141 // å
¬éããã¦ããå ´åã¯å
¬éæ¸ã¿ãã¼ã¸ã¸ã®ãªã³ã¯ã表示1142 var $h2 = $(Names.cntBody.addDot()).first().find('.h2-default').first();1143 $h2.append(1144 $('<a></a>').addClass('pull-right')1145 .addClass('now-page')1146 .attr('href', $('body').data('href') + '/telnumber/' + Data.name)1147 .attr('target', '_blank')1148 .text('æ¬çªãã¼ã¸ãè¦ã')1149 ).append(1150 $('<a></a>').addClass('pull-right')1151 .addClass('now-page')1152 .addClass('now-page')1153 .attr('href', $('body').data('href') + '/staging/bbnavi/telnumber/' + Data.name)1154 .attr('target', '_blank')1155 .text('Stagingãã¼ã¸ãè¦ã')1156 );1157 // ä¸æä¿åå¾å
¬éããã¦ããªãå ´åã¯ã¢ã©ã¼ãã表示1158 if (Data.updated > Data.released) {1159 var updateStr = 'ä¸æ¸ãä¿åãããã¼ã¿ãStagingç°å¢ã«å
¬éããã¦ãã¾ãã' + '<br>';1160 updateStr += '<span>ä¸æ¸ãä¿åæ¥æ</span>ï¼' + Data.updated + '<br>';1161 updateStr += '<span>æçµæ´æ°æ¥æ</span>ï¼' + Data.released;1162 $(Names.cntBody.addDot()).first().prepend(1163 $('<div></div>').addClass(Names.cntBodyPnlAlert).html(updateStr)1164 );1165 $(Names.cntBody.addDot()).first().find('.date-update').first().addClass('alert');1166 $(Names.cntBody.addDot()).first().find('.date-release').first().addClass('alert');1167 }1168 }1169 // æªä¿åã®å ´åã¯ä¸æ¸ãä¿åæ¥ã®èæ¯ã赤ã«ãã1170 if (Data.updated === '0000-00-00 00:00:00') {1171 $(Names.cntBody.addDot()).first().find('.date-update').first().addClass('alert');1172 }1173 // åé¤ããã¦ããå ´åã¯ã¢ã©ã¼ãã表示1174 if (Data.is_delete === '1') {1175 $(Names.cntBody.addDot()).first().prepend(1176 $('<div></div>').text('åé¤æ¸ã¿ãã¼ã¿ã§ã').addClass(Names.cntBodyPnlAlert)1177 );1178 }1179 // å®äºããã«ã®è¡¨ç¤º1180 if (showSuccess) {1181 // æåããæ¨ãä¼ããããã«ã®è¡¨ç¤º1182 $(Names.cntBody.addDot()).first().prepend(1183 $('<div></div>').text('æ´æ°ãã¾ãã')1184 .addClass(Names.cntBodyPnlSuccess)1185 );1186 // 2ç§å¾ã«æ¶ããããã«ã»ãããã1187 $(Names.cntBodyPnlSuccess.addDot()).fadeOut(2000, function() {$(this).remove();});1188 }1189 },1190 // ä¸æ¸ãä¿åãããã¿ã³ãæ¼ããæã®å¦ç1191 save: function() {1192 // ãã¼ã¸ã®ãªã³ã¯åçã®ã¨ã¬ã¡ã³ã1193 var $elmName = $(Names.cntName.addHash());1194 var url = 'html/save/' + $elmName.text();1195 var data = {1196 html : Contents.createSave(),1197 updated: $elmName.data(Names.dataUpdate)1198 };1199 Ajaxs.update(url, data);1200 },1201 // æ¬çªå
¬éç¨ãã¼ã¸ã®ä½æ1202 publishing: function() {1203 // ãã¼ã¸ã®ãªã³ã¯åçã®ã¨ã¬ã¡ã³ã1204 var $elmName = $(Names.cntName.addHash());1205 var url = 'html/update/' + $elmName.text();1206 var data = {1207 html : Contents.createSave(),1208 publish : Contents.createPublish(),1209 updated: $elmName.data(Names.dataUpdate)1210 };1211 Ajaxs.update(url, data);1212 Preview.hide();1213 },1214 // ä¸æä¿åç¨ã³ã³ãã³ãã®ä½æ1215 createSave: function() {1216 // htmlã³ã³ãã³ãã®ã©ããã¼ãã¯ãã¼ã³1217 var $html = $(Names.cntBodyDataWrap.addHash()).clone();1218 // ä¸è¦ãªã¯ã©ã¹çãåé¤1219 $html = Contents.removeRedundant($html);1220 // ä¸èº«ã®ã¿ãè¿ã1221 return $html.html();1222 },1223 // ãã¬ãã¥ã¼ç¨ã®ã³ã³ãã³ãã®ä½æ1224 createPreview: function($wrap) {1225 var $content = $(Names.cntBodyDataWrap.addHash()).clone();1226 // ä¸è¦ãªã¯ã©ã¹çãåé¤1227 $content = Contents.removeRedundant($content);1228 // ä¸è¦ãªdataå±æ§çãåé¤1229 $content = Contents.removeRedundantData($content);1230 // é表示ã®ã¨ã¬ã¡ã³ããåé¤(colspanã»rowspanããããããªãçºåé¤ããªã)1231 // $content.find(Names.hidden.addDot()).remove();1232 // ä¸ã«ä½ããªãã³ã³ãã³ãã®åé¤1233 $content.find(BoxNames.wrap.addDot()).each(function() {1234 if ($(this).text().trim() === '') {1235 $(this).remove();1236 }1237 });1238 // ãã¼ã¸TOPã¸ã³ã³ãã³ãã®æ¿å
¥1239 var pageName = Contents.getPageName();1240 var $pagetop = $('<p></p>').addClass('topagetop')1241 .append(1242 $('<a></a>').attr('href', 'telnumber/' + pageName)1243 .text('ãã¼ã¸TOPã¸')1244 );1245 $content.find(Names.section.addDot()).append($pagetop);1246 $wrap.empty();1247 // ãã¼ã¸å
ãªã³ã¯ã®æ¿å
¥1248 $wrap.append(Contents.createUl(pageName));1249 // ã³ã³ãã³ããæ¿å
¥ãã1250 $content.find(Names.section.addDot()).each(function() {1251 $wrap.append($(this));1252 });1253 return $wrap;1254 },1255 // æ¬çªå
¬éç¨ã³ã³ãã³ãã®ä½æ1256 createPublish: function() {1257 // æ¬çªç¨ã®ã©ããã³ã³ãã³ã1258 var $publish = $('<div></div>').attr('id', 'mainmenu')1259 .attr('name', 'layoutitem_2')1260 .addClass('layoutitem_a');12611262 // ãã¬ãã¥ã¼ã¨åããã®ãåå¾1263 var $content = Contents.createPreview($publish);1264 // PHPã®ã¿ã°çãæ¿å
¥ãã¦ãµã¼ãã¸éä¿¡ããããããããPHPã®ã¿ã°ãæ¿å
¥ãããã¨ããã¨ã¨ã¹ã±ã¼ããããçº1265 // ä¸èº«ã®ã¿ããµã¼ãã«éä¿¡ãããµã¼ãå´ã§ãã®ä»ã®ã¿ã°ã足ãããã«ãã¦ãã¾ã1266 return $content.html();1267 },1268 // ãã¼ã¸ã®ãã¡ã¤ã«åãåå¾1269 getPageName: function() {1270 var pageName = '';1271 if ($(Names.cntName.addHash()).text() !== 'index') {1272 pageName = $(Names.cntName.addHash()).text();1273 }1274 return pageName;1275 },1276 // ãã¼ã¸å
ãªã³ã¯ã®ä½æ1277 createUl: function(pageName) {1278 pageName = pageName ? pageName + '/#' : '#';1279 var $ul = $('<ul></ul>').attr('id', 'inpage-links');1280 $(Names.cntBody.addDot()).first().find(Names.section.addDot()).each(function() {1281 var href = 'telnumber/' + pageName + $(this).attr('id');1282 $ul.append(1283 $('<li></li>').append(1284 $('<a></a>').attr('href', href)1285 .text($(this).children('h3').text())1286 )1287 );1288 });1289 return $ul;1290 },1291 // ä¸è¦ãªã¯ã©ã¹çã®åé¤ï¼ä¿åç¨ï¼1292 removeRedundant: function($html) {1293 $html.find(Names.hover.addDot()).removeClass(Names.hover);1294 $html.find(Names.ctmHover.addDot()).removeClass(Names.ctmHover);1295 // jQueryUI selectableé¢ä¿ã¯ã©ã¹ã®åé¤1296 $html.find(Names.uiSelecting.addDot()).removeClass(Names.uiSelecting);1297 $html.find(Names.uiSelected.addDot()).removeClass(Names.uiSelected);1298 $html.find(Names.uiSelectee.addDot()).removeClass(Names.uiSelectee);1299 // åé¤äºå®ã®ã¯ã©ã¹ã®åé¤1300 $html.find(Names.showDelRow.addDot()).removeClass(Names.showDelRow);1301 // 移åäºå®ã®ã¯ã©ã¹ã®åé¤1302 $html.find(Names.showMoveRow.addDot()).removeClass(Names.showMoveRow);1303 // ã»ãã¬ã¼ã¿ã®åé¤1304 $html.find(Names.rowSeparator.addHash()).remove();1305 // è¡ã¬ã¤ãã®åé¤1306 $html.find(Names.hoverRowTop.addHash()).remove();1307 $html.find(Names.hoverRowBottom.addHash()).remove();13081309 return $html;1310 },1311 // ä¸è¦ãªdataå±æ§çã®åé¤ï¼å
¬éç¨ï¼1312 removeRedundantData: function($html) {1313 $html.find('[' + BoxNames.receptionWeekday + ']').removeAttr(BoxNames.receptionWeekday);1314 $html.find('[' + BoxNames.receptionSaturday + ']').removeAttr(BoxNames.receptionSaturday);1315 $html.find('[' + BoxNames.receptionSunday + ']').removeAttr(BoxNames.receptionSunday);1316 $html.find('[' + BoxNames.receptionHoliday + ']').removeAttr(BoxNames.receptionHoliday);1317 $html.find('[' + BoxNames.reception365days + ']').removeAttr(BoxNames.reception365days);1318 $html.find('[' + BoxNames.receptionAllowed + ']').removeAttr(BoxNames.receptionAllowed);1319 $html.find('[' + BoxNames.receptionHourFrom + ']').removeAttr(BoxNames.receptionHourFrom);1320 $html.find('[' + BoxNames.receptionTimeFrom + ']').removeAttr(BoxNames.receptionTimeFrom);1321 $html.find('[' + BoxNames.receptionTimeTo + ']').removeAttr(BoxNames.receptionTimeTo);1322 $html.find('[' + BoxNames.receptionLunch + ']').removeAttr(BoxNames.receptionLunch);1323 $html.find('[' + BoxNames.blackOutMay + ']').removeAttr(BoxNames.blackOutMay);1324 $html.find('[' + BoxNames.blackOutEndYear + ']').removeAttr(BoxNames.blackOutEndYear);1325 $html.find('[' + BoxNames.blackOutOther + ']').removeAttr(BoxNames.blackOutOther);13261327 // fontã¿ã°ãspanã«å¤æ´1328 var html = $html.html();1329 html = html.replace(/(<\/?)font/gi, "$1span");1330 return $html.html(html);1331 }1332 };13331334 // ãã¬ãã¥ã¼ç»é¢1335 var Preview = {1336 load: function () {1337 $(Names.cntPreview.addHash() + '-wrap').height(($(window).height() - 60));1338 var frameHeight = $(Names.cntPreview.addHash() + '-wrap').height() -1339 $(Names.cntPreview.addHash() + '-head').outerHeight() - 30;1340 $(Names.cntPreview.addHash() + '-frame-wrap').height(frameHeight - 40);1341 $(Names.cntPreview.addHash() + '-frame').height(frameHeight - 40);1342 },1343 // ãã¬ãã¥ã¼ã®è¡¨ç¤º1344 show: function() {1345 $(Names.cntPreview.addHash() + '-frame').attr('src', '');1346 $(Names.cntPreview.addHash() + '-frame').attr('src', 'preview').load(function() {1347 var $insertContent = $(Names.cntPreview.addHash() + '-frame').contents().find('#mainmenu');1348 // ãã¬ãã¥ã¼ã³ã³ãã³ãã®ä½æ1349 Contents.createPreview($insertContent);1350 // ãã¬ãã¥ã¼ç»é¢ã表示ãã1351 $(Names.cntPreview.addHash()).show();1352 });1353 },1354 // ãã¬ãã¥ã¼ã®é表示1355 hide: function() {1356 $(Names.cntPreview.addHash()).hide();1357 }1358 };1359136013611362 // ãã¼ãã«ã®ã»ã«å
ã®æä½1363 var Cells = {1364 // ã»ã«å
ããã¯ã¹ã®ãã³ãã¬ã¼ã1365 boxTmp: '<div class="' + BoxNames.wrap + '">' +1366 ' <div class="' + BoxNames.center + '"></div>' +1367 ' <div class="' + BoxNames.address + '"></div>' +1368 ' <div class="' + BoxNames.free + '"></div>' +1369 ' <div class="' + BoxNames.wrapPhone + '"></div>' +1370 ' <div class="' + BoxNames.wrapHp + '">' +1371 ' <span class="' + BoxNames.hpPrefix + '"></span>' +1372 ' <span class="' + BoxNames.hpAddress + '"></span>' +1373 ' </div>' +1374 ' <div class="' + BoxNames.wrapMail + '"></div>' +1375 ' <div class="' + BoxNames.wrapReception + '">' +1376 ' <span class="' + BoxNames.receptionTime + '" ' + BoxNames.receptionAllowed + '="1" ' + BoxNames.receptionHourFrom + '="9" ' + BoxNames.receptionTimeFrom + '="0" ' + BoxNames.receptionHourTo + '="17" ' + BoxNames.receptionTimeTo + '="0" ' + BoxNames.receptionLunch + '="false"></span>' +1377 ' <span class="' + BoxNames.receptionDate + '" ' + BoxNames.receptionWeekday + '="false" ' + BoxNames.receptionSaturday + '="false" ' + BoxNames.receptionSunday + '="false" ' + BoxNames.receptionHoliday + '="false" ' + BoxNames.reception365days + '="false"></span>' +1378 ' <span class="' + BoxNames.blackOut + '" ' + BoxNames.blackOutMay + '="false" ' + BoxNames.blackOutEndYear + '="false" ' + BoxNames.blackOutOther + '=""></span>' +1379 ' </div>' +1380 ' <div class="' + BoxNames.other + '"></div>' +1381 '</div>',1382 // é»è©±çªå·ç¨ã®ãã³ãã¬ã¼ã1383 phoneTmp: '<div class="' + BoxNames.phoneGroup + '" ' + BoxNames.phoneOtherDate + '="" ' + BoxNames.phoneOtherNumber + '="" ' + BoxNames.phoneOtherState + '="1"' + BoxNames.phoneDefaultNumber + '="">' +1384 ' <span class="' + BoxNames.phonePrefix + '"></span>' +1385 ' <span class="' + BoxNames.phoneNumber + '"></span>' +1386 ' <span class="' + BoxNames.phoneSuffix + '"></span>' +1387 '</div>',1388 // ã¡ã¼ã«ã¢ãã¬ã¹ç¨ã®ãã³ãã¬ã¼ã1389 mailTmp: '<div class="' + BoxNames.mailGroup + '">' +1390 ' <span class="' + BoxNames.mailPrefix + '"></span>' +1391 ' <span class="' + BoxNames.mailAdress + '"></span>' +1392 '</div>',1393 // ã»ã«å
ã®ã³ã³ãã³ãããã¯ã¹ã®ç§»åå¦ç1394 addSortableCol: function() {1395 var cols = [1396 'col1',1397 'col2',1398 'col3'1399 ];1400 $.each(cols, function(i, col) {1401 $(Names.tblWrap.addDot()).find(col.addDot()).sortable({1402 connectWith: col.addDot(),1403 handle: BoxNames.moveHandle.addHash(),1404 start: function () {1405 isSorting = true;1406 isEdit = true;1407 Events.removeCellHovers();1408 // ä¸è¦ãªã¯ã©ã¹ã®åé¤1409 var $tables = $(Names.tblWrap.addDot());1410 $tables.find(Names.hover.addDot()).removeClass(Names.hover);1411 $tables.find(Names.ctmHover.addDot()).removeClass(Names.ctmHover);1412 $tables.find(Names.uiSelecting.addDot()).removeClass(Names.uiSelecting);1413 $tables.find(Names.uiSelected.addDot()).removeClass(Names.uiSelected);1414 },1415 stop: function () {1416 isSorting = false;1417 Events.addCellHovers();1418 }1419 });1420 });1421 },1422 // è¡ãã¨ã®ã³ã³ãã³ãã®ãã©ãã°ã¢ã³ããããããæå¹å1423 enableSortableCol: function(box) {1424 var $table = $(box).parents(Names.tblWrap.addDot()).first();1425 var $cell = $(box).parents('th,td').first();1426 var cellClass ='';1427 switch (true) {1428 case $cell.hasClass('col1'):1429 cellClass = 'col1';1430 break;1431 case $cell.hasClass('col2'):1432 cellClass = 'col2';1433 break;1434 case $cell.hasClass('col3'):1435 cellClass = 'col3';1436 break;1437 }1438 $(cellClass.addDot()).sortable('enable');1439 // $table.find('th,td').sortable('enable');1440 },1441 // è¡ãã¨ã®ã³ã³ãã³ãã®ãã©ãã°ã¢ã³ããããããç¡å¹å1442 disableSortableCol: function(box) {1443 var $table = $(box).parents(Names.tblWrap.addDot()).first();1444 var $cell = $(box).parents('th,td').first();1445 var cellClass ='';1446 switch (true) {1447 case $cell.hasClass('col1'):1448 cellClass = 'col1';1449 break;1450 case $cell.hasClass('col2'):1451 cellClass = 'col2';1452 break;1453 case $cell.hasClass('col3'):1454 cellClass = 'col3';1455 break;1456 }1457 $(cellClass.addDot()).sortable('disable');1458 // $table.find('th,td').sortable('disable');1459 },1460 // ããã¯ã¹ã®è¿½å ãã¿ã³ã®æ¿å
¥1461 addAddBoxBtn: function(elm) {1462 $(elm).append($(Names.btnAddBox.addHash()).removeClass(Names.hidden));1463 },1464 // ããã¯ã¹ã®è¿½å ãã¿ã³ã®åé¤1465 removeAddBoxBtn: function() {1466 $('body').append($(Names.btnAddBox.addHash()).addClass(Names.hidden));1467 },1468 // ããã¯ã¹ã®ç§»åç¨ã®ãã¼ã表示1469 addMoveBox: function(elm) {1470 $(elm).append($(BoxNames.moveHandle.addHash()).removeClass(Names.hidden));1471 },1472 // ããã¯ã¹ã®ç§»åç¨ã®ãã¼ã®é表示1473 removeMoveBox: function() {1474 $('body').append($(BoxNames.moveHandle.addHash()).addClass(Names.hidden));1475 },1476 // ããã¯ã¹ã®è¿½å å¦ç1477 addBox: function(elm) {1478 var $boxTmp = $(Cells.boxTmp);1479 $boxTmp.find(BoxNames.wrapPhone.addDot()).first().append($(Cells.phoneTmp));1480 $boxTmp.find(BoxNames.wrapMail.addDot()).first().append($(Cells.mailTmp));1481 $(elm).before($boxTmp);1482 // 追å ã¨åæã«ç·¨éç»é¢ã«ãã1483 EditPanel.show($boxTmp.find(BoxNames.wrapPhone.addDot()).first(), true);1484 // ç·¨éãã©ã°ãã»ãã1485 isEdit = true;1486 },1487 // ããã¯ã¹ã®åé¤å¦ç1488 removeBox: function(elm) {1489 // 移åãã¼ã®é¿é£1490 Cells.removeMoveBox();1491 // ããã¯ã¹ã®åé¤1492 $(elm).remove();1493 // ç·¨éãã©ã°ãã»ãã1494 isEdit = true;1495 },1496 // ãããç·¨éæã«éé¿ãã¦ããã¯ã©ã¹ã®ãã£ãã·ã¥1497 cashClass: [],1498 // theadã®ç·¨ééå§1499 editThead: function(elm) {1500 var $elm = $(elm);1501 var thWidth = $elm.width() - 30;1502 var thTop = $elm.offset().top - $(window).scrollTop() + $elm.height() + 10;1503 var thLeft = $elm.offset().left - $(window).scrollLeft();1504 var thTitle = $elm.text();1505 var thClass = $elm.attr('class');1506 var classArr = thClass.split(' ');1507 // éé¿ãã¦ããã¯ã©ã¹ã®ãªã¹ã1508 var delClass = [1509 'col1',1510 'col2',1511 'col3',1512 'ui-sortable',1513 'ui-sortable-disabled'1514 ];1515 // ãã£ãã·ã¥ç¨é
åã®åæå1516 Cells.cashClass = [];1517 // éé¿ãã¦ãããã®ã¨ã表示ãããã®ã«åãåãã1518 for (var i = 0, len = classArr.length; i < len; i++) {1519 if ($.inArray(classArr[i], delClass) > -1) {1520 // éé¿1521 Cells.cashClass.push(classArr[i]);1522 // åé¤1523 delete(classArr[i]);1524 }1525 }1526 $elm.addClass(Names.selected);1527 $(Names.headEdit.addHash() + '-title').val(thTitle);1528 $(Names.headEdit.addHash() + '-class').val(classArr.join(' ').trim());1529 $(Names.headEdit.addHash()).data(Names.dataTargetElm, $elm);1530 $(Names.headEdit.addHash()).css({1531 top: thTop,1532 left: thLeft,1533 width: thWidth1534 });1535 $(Names.headEdit.addHash() + '-wrap').show();1536 },1537 // theadã®ç·¨é確å®1538 updateThead: function(elm) {1539 var $elm = $($(Names.headEdit.addHash()).data(Names.dataTargetElm));1540 $elm.text($(Names.headEdit.addHash() + '-title').val());1541 $elm.attr('class', '');1542 $elm.addClass($(Names.headEdit.addHash() + '-class').val());1543 for (var i = 0, len = Cells.cashClass.length; i < len; i++) {1544 $elm.addClass(Cells.cashClass[i]);1545 }1546 Cells.cancelThead();1547 // ç·¨éãã©ã°ãã»ãã1548 isEdit = true;1549 },1550 // theadã®ç·¨éãã£ã³ã»ã«1551 cancelThead: function(elm) {1552 var pnl = $(Names.headEdit.addHash()).data(Names.dataTargetElm);1553 $(pnl).removeClass(Names.selected);1554 $(Names.headEdit.addHash() + '-wrap').hide();1555 },1556 // tfootã®ç·¨ééå§1557 editTfoot: function(elm) {1558 Events.removeTfoot();1559 var html = $(elm).html() || '';1560 $(elm).empty().addClass('edit');1561 var $textarea = $('<textarea></textarea>');1562 $(elm).append($textarea.val(html.br2nl()));1563 $textarea.trigger('focus');1564 },1565 // tfootã®ç·¨éçµäº1566 updateTfoot: function(elm) {1567 Events.addTfoot();1568 var html = $(elm).val();1569 var $td = $(elm).parents('td').first();1570 $td.empty();1571 $td.removeClass('edit').html(html.nl2br());1572 // ç·¨éãã©ã°ãã»ãã1573 isEdit = true;1574 }1575 };15761577 // ã»ã«ã®ç·¨éããã«ã§ã®å¦ç1578 var EditPanel = {1579 // é»è©±é¨åã®ãã³ãã¬ã¼ã1580 phoneTmp: '<fieldset class="' + EditNames.phoneGroup + '">' +1581 ' <label class="pull-left w-170">' +1582 ' è¦åºã' +1583 ' <input class="' + EditNames.phonePrefix + '" type="text">' +1584 ' </label>' +1585 ' <label class="pull-left w-155 mg-l-5">' +1586 ' çªå·' +1587 ' <input class="' + EditNames.phoneNumber + '" type="text">' +1588 ' </label>' +1589 ' <label class="pull-left w-170 mg-l-5">' +1590 ' å¾ã«ãã³' +1591 ' <input class="' + EditNames.phoneSuffix + '" type="text">' +1592 ' </label>' +1593 ' <label class="pull-left w-170">' +1594 ' <input class="' + EditNames.phoneOtherDate + '" type="text" readonly>' +1595 ' </label>' +1596 ' <div class="pull-left central w-140 mg-b-5" readonly>' +1597 ' <select class="' + EditNames.phoneOtherState + '">' +1598 ' <option value="1">ããã®</option>' +1599 ' <option value="2">ã¾ã§ã®</option>' +1600 ' </select>' +1601 ' é»è©±çªå·' +1602 ' </div>' +1603 ' <label class="pull-left w-140">' +1604 ' <input class="' + EditNames.phoneOtherNumber + '" type="text" placeholder="é»è©±çªå·">' +1605 ' </label>' +1606 ' <button class="btn-del-phone btn btn-danger pull-left mg-l-5" type="button">åé¤</button>' +1607 '</fieldset>',1608 // ã¡ã¼ã«é¨åã®ãã³ãã¬ã¼ã1609 mailTmp: '<fieldset class="' + EditNames.mailGroup + '">' +1610 ' <label class="pull-left w-160">' +1611 ' è¦åºã' +1612 ' <input class="' + EditNames.mailPrefix + '" type="text">' +1613 ' </label>' +1614 ' <label class="pull-left w-285 mg-l-5">' +1615 ' ã¢ãã¬ã¹' +1616 ' <input class="' + EditNames.mailAdress + '" type="text">' +1617 ' </label>' +1618 ' <label class="btn-del-mail-wrap">' +1619 ' ã' +1620 ' <button class="btn-del-mail btn btn-danger pull-left mg-l-5" type="button">åé¤</button>' +1621 ' </label>' +1622 '</fieldset>',1623 // ã»ã«å
ã³ã³ãã³ããããã¯ã®ç·¨éããã«è¡¨ç¤º1624 show: function(elm, state) {1625 var $editBox = $(elm).parents(BoxNames.wrap.addDot()).first();1626 $(EditNames.panel.addHash()).data(Names.dataTargetElm, $editBox);1627 // æ°è¦è¿½å ã§éããããç·¨éã§éãããã®ç¢ºèªç¨ï¼æ°è¦ã®æã¯ãã£ã³ã»ã«ãã¿ã³ã§åé¤ï¼1628 $(EditNames.panel.addHash()).data('addState', state || false);1629 Cells.removeMoveBox();1630 // ããã«ã®é«ããè¨å®1631 var boxHeight = $(window).height() - 150;1632 $(EditNames.panel.addHash() + '-left').height(boxHeight);1633 $(EditNames.panel.addHash() + '-right').height(boxHeight - 40);1634 $(EditNames.panel.addHash() + '-preview-wrap').height(boxHeight - 60);1635 // ãã¬ãã¥ã¼ç»é¢ã¨ç·¨éããã«ã«ãã¼ã¿ãåæ 1636 var $boxData = $editBox.clone().removeClass(BoxNames.wrap);1637 $(EditNames.panel.addHash() + '-preview').empty();1638 $(EditNames.panel.addHash() + '-preview').append($boxData.html());16391640 // ããã«å
ã®ãã¼ã¿ã®åæå1641 EditPanel.reset($(EditNames.panel.addHash()));1642 // èªã¿è¾¼ãã ãã¼ã¿ãããã«ã«åæ 1643 EditPanel.readVal($(EditNames.panel.addHash()));1644 // ã«ã©ã ã«ããç·¨éé
ç®ãå¤æ´ãã1645 EditPanel.setEditItem($(EditNames.panel.addHash()), $editBox);1646 // ã¢ã¼ãã«ã®è¡¨ç¤º1647 $(EditNames.panel.addHash()).modal();1648 console.log("éé");1649 // ã¢ã¼ãã«ã®ãã£ãã·ã¥åé¤1650 /*$(document).on('.btn.btn-warning', '.modal', function(){1651 $(this).removeData('.modal').empty();165216531654 });*/16551656 // ããã«ãæä¸é¨ã«ã¹ã¯ãã¼ã«1657 $(EditNames.panel.addHash() + '-left').scrollTop(0);1658 // å
é ã®ã»ã«ã«ãã©ã¼ã«ã¹ã移å1659 $(EditNames.panel.addHash()).find('input').first().focus();1660 },1661 // ç·¨éããã«ãéããã¨ãã®å¦ç1662 hide: function(e) {1663 var $editBox = $(EditNames.panel.addHash()).data(Names.dataTargetElm);1664 var $targetTable = $editBox.parents('table').first();1665 // ããã¼ã¯ã©ã¹ã®åé¤1666 $targetTable.find(Names.hover.addDot()).removeClass(Names.hover);1667 $targetTable.find(Names.ctmHover.addDot()).removeClass(Names.ctmHover);1668 },1669 // ããã¹ãã¨ãªã¢ãWYSWYGã«å¤æ1670 setWyswyg: function() {1671 $(EditNames.editBox.addDot()).each(function () {1672 var $this = $(this);1673 // ãã¿ã³ãæ¿å
¥ããããã®ã©ãã1674 var $wrap = $('<div></div>').addClass(EditNames.editBox + '-wrap');1675 // ç·¨éã¨ãªã¢ç¨ã®ã©ãã1676 var $editBox = $('<div></div>').addClass(EditNames.editBox + '-editbox');1677 $editBox.data('composition', false);1678 $editBox.prop('contenteditable', true);1679 $editBox.on('keyup cut paste', function () {1680 setTimeout(function () {1681 if (!$this.data('composition')) {1682 $this.val($editBox.html()).trigger('input');1683 }1684 }, 0);1685 }).on('compositionstart', function () {1686 $editBox.data('composition', true);1687 }).on('compositionend', function () {1688 $editBox.data('composition', false);1689 });1690 // ãªã³ã¯æ¿å
¥ç¨ã®ããã¯ã¹1691 var $linkbox = $('<div></div>').addClass('edit-link').css({'display': 'none'});1692 $linkbox.append($('<input>').attr('type', 'text').addClass('edit-link-input'));1693 $linkbox.append(1694 $('<label></label>').html('<input type="checkbox", class="edit-link-blank"> target="_blank"ã«ãã').addClass('edit-link-blank-label')1695 );1696 $linkbox.append($('<button></button>').attr('type', 'button').addClass('edit-link-submit').text('æ´æ°'));1697 $linkbox.append($('<button></button>').attr('type', 'button').addClass('edit-link-cancel').text('ãã£ã³ã»ã«'));1698 // ãã¿ã³ç¾¤1699 var $btns = $('<div></div>').addClass('edit-link-btns')1700 .append(1701 $('<button></button>').attr('type', 'button').addClass('small').text('å°æå')1702 ).append(1703 $('<button></button>').attr('type', 'button').addClass('red').text('赤å')1704 ).append(1705 $('<button></button>').attr('type', 'button').addClass('bold').text('太å')1706 ).append(1707 $('<button></button>').attr('type', 'button').addClass('link').text('ãªã³ã¯')1708 ).append(1709 $('<button></button>').attr('type', 'button').addClass('mail').text('ã¡ã¼ã«')1710 ).append(1711 $('<button></button>').attr('type', 'button').addClass('reset').text('æ¸å¼ã®åæ¶')1712 ).append(1713 $('<button></button>').attr('type', 'button').addClass('source').text('ã½ã¼ã¹ã®è¡¨ç¤º')1714 );17151716 // ã¨ã¬ã¡ã³ãã®å¾ãã«ã©ãããæ¿å
¥1717 $this.after($wrap);1718 // ã©ããã«ãã¿ã³ãæ¿å
¥1719 $wrap.append($btns);1720 // ãªã³ã¯ç·¨éããã«ã表示1721 $wrap.append($linkbox);1722 // ç·¨éããã«ãæ¿å
¥1723 $wrap.append($editBox);1724 // å
¥åã¨ãªã¢ãã©ããã«æ¿å
¥1725 $wrap.append($this);1726 $this.hide();1727 });1728 },1729 // ã»ã«å
ã³ã³ãã³ãã®ç·¨éå
容ã®æ´æ°å¦ç1730 update: function() {1731 var $editBox = $(EditNames.panel.addHash()).data(Names.dataTargetElm);1732 $editBox.empty();1733 $editBox.append($($(EditNames.panel.addHash() + '-preview').html()));1734 $(EditNames.panel.addHash()).modal('hide');1735 // ç·¨éãã©ã°ã®ã»ãã1736 isEdit = true;1737 },1738 // ç·¨éã®ãã£ãæã«ãã¬ãã¥ã¼ã«åæ ãã1739 setVal: function(elm) {1740 var $elm = $(elm);1741 var $preview = $(EditNames.panel.addHash() + '-preview');1742 var val = $elm.val();1743 var $boxElm;1744 var $val;1745 // scriptã¨ããæåãåé¤1746 val = val.replace(/(<\/?)script/gi, "$1span");1747 if ($elm.is('[id="' + EditNames.center + '"]')) {1748 // ã»ã³ã¿å1749 $boxElm = $preview.find(BoxNames.center.addDot()).first();1750 $boxElm.empty();1751 if (val !== '') {1752 $boxElm.html(val.addSumi());1753 }1754 } else if ($elm.is('[id="' + EditNames.address + '"]')) {1755 // ä½æ1756 $boxElm = $preview.find(BoxNames.address.addDot()).first();1757 $boxElm.empty();1758 if (val !== '') {1759 // æåæ°ã確èª1760 $val = $('<div>' + val + '</div>');1761 if ($val.text().length > 200) {1762 // 200æåããå¤ãå ´åã¯åã®å¤ããã®ã¾ã¾ä½¿ç¨1763 val = $elm.data('prevVal');1764 // ããã¹ãã¨ãªã¢ã®å¤ãå
ã«æ»ã1765 $elm.val(val);1766 // å
¥åã¨ãªã¢ã®å¤ãå
ã«æ»ã1767 $elm.parents(EditNames.editBox.addDot() + '-wrap').first()1768 .find(EditNames.editBox.addDot() + '-editbox').first()1769 .html(val);1770 alert('æåæ°ã¯200æå以å
ã§å
¥åãã¦ãã ãã');1771 }1772 $boxElm.html(val);1773 $boxElm.nextAll().each(function() {1774 if ($(this).text().trim() !== '') {1775 $boxElm.append('<br><br>');1776 return false;1777 }1778 });1779 }1780 // ååå¤ã¨ãã¦ã®å¤ãã»ãã1781 $elm.data('prevVal', val);1782 } else if ($elm.is('[id="' + EditNames.hpPrefix + '"]')) {1783 // ãã¼ã ãã¼ã¸ã®æ¥é å¥1784 $boxElm = $preview.find(BoxNames.hpPrefix.addDot()).first();1785 $boxElm.empty();1786 if (val !== '') {1787 $boxElm.html(val.addSumi() + '<br>');1788 }1789 } else if ($elm.is('[id="' + EditNames.hpAddress + '"]')) {1790 // ãã¼ã ãã¼ã¸ã¢ãã¬ã¹1791 $boxElm = $preview.find(BoxNames.hpAddress.addDot()).first();1792 $boxElm.empty();1793 if (val !== '') {1794 $boxElm.append(1795 $('<a></a>').text(val)1796 .attr('href', val)1797 );1798 }1799 } else if ($elm.is('[id="' + EditNames.other + '"]')) {1800 // ãã®ä»é
ç®1801 $boxElm = $preview.find(BoxNames.other.addDot()).first();1802 $boxElm.empty();1803 if (val !== '') {1804 // æåæ°ã確èª1805 $val = $('<div>' + val + '</div>');1806 if ($val.text().length >= 200) {1807 // 200æåããå¤ãå ´åã¯åã®å¤ããã®ã¾ã¾ä½¿ç¨1808 val = $elm.data('prevVal');1809 // ããã¹ãã¨ãªã¢ã®å¤ãå
ã«æ»ã1810 $elm.val(val);1811 // å
¥åã¨ãªã¢ã®å¤ãå
ã«æ»ã1812 $elm.parents(EditNames.editBox.addDot() + '-wrap').first()1813 .find(EditNames.editBox.addDot() + '-editbox').first()1814 .html(val);1815 alert('æåæ°ã¯200æå以å
ã§å
¥åãã¦ãã ãã');1816 }1817 $boxElm.html(val);1818 }1819 // ååå¤ã¨ãã¦ã®å¤ãã»ãã1820 $elm.data('prevVal', val);1821 } else if ($elm.is('[class|="edit-phone"]')) {1822 // é»è©±çªå·é
ç®1823 EditPanel.setPhoneVal();1824 } else if ($elm.is('[class|="edit-mail"]')) {1825 // ã¡ã¼ã«ã¢ãã¬ã¹é
ç®1826 EditPanel.setMailVal();1827 } else if ($elm.is('[id|="rcpd"]')) {1828 // åä»æ¥é
ç®1829 EditPanel.setReceptionDateVal($(elm));1830 } else if ($elm.is('[id|="rcpt"]')) {1831 // åä»æéé
ç®1832 EditPanel.setReceptionTimeVal($(elm));1833 } else if ($elm.is('[id|="bko"]')) {1834 // é¤å¤æ¥é
ç®1835 EditPanel.setReceptionBlackOutVal();1836 }1837 },1838 // æ¥ä»ãæ£ãããã®ãã§ãã¯1839 // é»è©±çªå·ã®å¤ãã»ãã1840 setPhoneVal: function() {1841 var $wrap = $(EditNames.panel.addHash() + '-preview').find(BoxNames.wrapPhone.addDot()).first();1842 $wrap.empty();18431844 $(EditNames.phoneGroup.addDot()).each(function() {1845 var $phoneTmp = $(Cells.phoneTmp);1846 var pre = $(this).find(EditNames.phonePrefix.addDot()).first().val();1847 var num = $(this).find(EditNames.phoneNumber.addDot()).first().val();1848 var suf = $(this).find(EditNames.phoneSuffix.addDot()).first().val();1849 $phoneTmp.find(BoxNames.phonePrefix.addDot()).first().html(pre === ''? '': pre.addSumi() + '<br>');1850 $phoneTmp.find(BoxNames.phoneNumber.addDot()).first().html(num === ''? '': '<em>' + num + '</em>');1851 $phoneTmp.find(BoxNames.phoneSuffix.addDot()).first().html(suf === ''? '': '(' + suf + ')<br>');18521853 var otherState = $(this).find(EditNames.phoneOtherState.addDot()).first().val();1854 var otherDate = $(this).find(EditNames.phoneOtherDate.addDot()).first().val();1855 var otherNum = $(this).find(EditNames.phoneOtherNumber.addDot()).first().val();1856 $phoneTmp.attr(BoxNames.phoneDefaultNumber, num);1857 $phoneTmp.attr(BoxNames.phoneOtherState, otherState);1858 $phoneTmp.attr(BoxNames.phoneOtherDate, otherDate);1859 $phoneTmp.attr(BoxNames.phoneOtherNumber, otherNum);18601861 $wrap.append($phoneTmp);1862 });1863 // é»è©±çªå·ã®ââââå¹´ââæââæ¥ã¾ã§ã®è¡¨ç¤º1864 phoneOther.set();1865 },1866 // ã¡ã¼ã«ã¢ãã¬ã¹ãã»ãã1867 setMailVal: function() {1868 var $wrap = $(EditNames.panel.addHash() + '-preview').find(BoxNames.wrapMail.addDot()).first();1869 $wrap.empty();18701871 $(EditNames.mailGroup.addDot()).each(function() {1872 var $mailTmp = $(Cells.mailTmp);1873 var prefix = $(this).find(EditNames.mailPrefix.addDot()).first().val();1874 var address = $(this).find(EditNames.mailAdress.addDot()).first().val();1875 $mailTmp.find(BoxNames.mailPrefix.addDot()).first().html(prefix === ''? '': prefix.addSumi() + '<br>');1876 $mailTmp.find(BoxNames.mailAdress.addDot()).first().empty();1877 if (address !== '') {1878 $mailTmp.find(BoxNames.mailAdress.addDot()).first().append(1879 $('<a></a>').text(address)1880 .attr('href', 'mailto:' + address)1881 );1882 }18831884 $wrap.append($mailTmp);1885 });1886 },1887 // åä»æ¥ãã»ãã1888 setReceptionDateVal: function($elm) {1889 var $wrap = $(EditNames.panel.addHash() + '-preview').find(BoxNames.receptionDate.addDot()).first();1890 $wrap.empty($wrap);18911892 var str = '';1893 var strArr = [];1894 // var id = $elm.attr('id');1895 if ($(EditNames.reception365days.addHash()).prop('checked')) {1896 strArr.push('å¹´ä¸ç¡ä¼');1897 } else {1898 if ($(EditNames.receptionWeekday.addHash()).prop('checked')) {1899 strArr.push('å¹³æ¥');1900 }1901 if ($(EditNames.receptionSaturday.addHash()).prop('checked')) {1902 strArr.push('åæ');1903 }1904 if ($(EditNames.receptionSunday.addHash()).prop('checked')) {1905 strArr.push('æ¥æ');1906 }1907 if ($(EditNames.receptionHoliday.addHash()).prop('checked')) {1908 strArr.push('ç¥æ¥');1909 }1910 }1911 str = strArr.join('ã»');1912 if (str) {1913 str = 'åä»æ¥ï¼' + str + '<br>';1914 }1915 $wrap.attr(BoxNames.receptionWeekday, $(EditNames.receptionWeekday.addHash()).prop('checked'));1916 $wrap.attr(BoxNames.receptionSaturday, $(EditNames.receptionSaturday.addHash()).prop('checked'));1917 $wrap.attr(BoxNames.receptionSunday, $(EditNames.receptionSunday.addHash()).prop('checked'));1918 $wrap.attr(BoxNames.receptionHoliday, $(EditNames.receptionHoliday.addHash()).prop('checked'));1919 $wrap.attr(BoxNames.reception365days, $(EditNames.reception365days.addHash()).prop('checked'));1920 $wrap.html(str);1921 EditPanel.setReceptionDateCheck();1922 },1923 // åä»æ¥ã®ãã§ãã¯ããã¯ã¹ãã»ãã1924 setReceptionDateCheck: function() {1925 if ($(EditNames.reception365days.addHash()).prop('checked')) {1926 // å¹´ä¸ç¡ä¼ã«ãã§ãã¯ãå
¥ã£ã¦ããã¨ãã®å¦ç1927 $(EditNames.receptionWeekday.addHash()).prop('checked', false).prop('disabled', true);1928 $(EditNames.receptionSaturday.addHash()).prop('checked', false).prop('disabled', true);1929 $(EditNames.receptionSunday.addHash()).prop('checked', false).prop('disabled', true);1930 $(EditNames.receptionHoliday.addHash()).prop('checked', false).prop('disabled', true);1931 } else if ($(EditNames.receptionWeekday.addHash()).prop('checked') &&1932 $(EditNames.receptionSaturday.addHash()).prop('checked') &&1933 $(EditNames.receptionSunday.addHash()).prop('checked') &&1934 $(EditNames.receptionHoliday.addHash()).prop('checked')) {1935 // å¹´ä¸ç¡ä¼ä»¥å¤ã®å
¨ã¦ã«ãã§ãã¯ãå
¥ã£ã¦ããã¨ãã®å¦ç //1936 $(EditNames.reception365days.addHash()).prop('checked', true);1937 EditPanel.setReceptionDateVal();1938 } else {1939 $(EditNames.receptionWeekday.addHash()).prop('disabled', false);1940 $(EditNames.receptionSaturday.addHash()).prop('disabled', false);1941 $(EditNames.receptionSunday.addHash()).prop('disabled', false);1942 $(EditNames.receptionHoliday.addHash()).prop('disabled', false);1943 }1944 },1945 // åä»æéãã»ãã1946 setReceptionTimeVal: function($elm) {1947 var $wrap = $(EditNames.panel.addHash() + '-preview').find(BoxNames.receptionTime.addDot()).first();1948 $wrap.empty();19491950 var str = '';1951 var state = $('[name="' + EditNames.receptionTimeName + '"]:checked').val();19521953 switch (state) {1954 case '2':1955 $(EditNames.receptionHourFrom.addHash()).prop('disabled', false);1956 $(EditNames.receptionTimeFrom.addHash()).prop('disabled', false);1957 $(EditNames.receptionHourTo.addHash()).prop('disabled', false);1958 $(EditNames.receptionTimeTo.addHash()).prop('disabled', false);1959 $(EditNames.receptionLunch.addHash()).prop('disabled', false);1960 str += $(EditNames.receptionHourFrom.addHash()).val() + ':';1961 str += $(EditNames.receptionTimeFrom.addHash()).val().padZero() + 'ï½';1962 str += $(EditNames.receptionHourTo.addHash()).val() + ':';1963 str += $(EditNames.receptionTimeTo.addHash()).val().padZero();1964 if ($(EditNames.receptionLunch.addHash()).prop('checked')) {1965 str += '(12æï½13æãé¤ã)';1966 }1967 break;1968 case '3':1969 str = '24æé';1970 case '1':1971 $(EditNames.receptionHourFrom.addHash()).prop('disabled', true);1972 $(EditNames.receptionTimeFrom.addHash()).prop('disabled', true);1973 $(EditNames.receptionHourTo.addHash()).prop('disabled', true);1974 $(EditNames.receptionTimeTo.addHash()).prop('disabled', true);1975 $(EditNames.receptionLunch.addHash()).prop('disabled', true);1976 break;1977 }1978 $wrap.attr(BoxNames.receptionAllowed, state);1979 $wrap.attr(BoxNames.receptionHourFrom, $(EditNames.receptionHourFrom.addHash()).val());1980 $wrap.attr(BoxNames.receptionTimeFrom, $(EditNames.receptionTimeFrom.addHash()).val());1981 $wrap.attr(BoxNames.receptionHourTo, $(EditNames.receptionHourTo.addHash()).val());1982 $wrap.attr(BoxNames.receptionTimeTo, $(EditNames.receptionTimeTo.addHash()).val());1983 $wrap.attr(BoxNames.receptionLunch, $(EditNames.receptionLunch.addHash()).prop('checked'));1984 if (str) {1985 str = 'åä»æéï¼' + str + '<br>';1986 }1987 $wrap.html(str);1988 },1989 // é¤å¤æ¥ãã»ãã1990 setReceptionBlackOutVal: function() {1991 var $wrap = $(EditNames.panel.addHash() + '-preview').find(BoxNames.blackOut.addDot()).first();1992 $wrap.empty();19931994 var str = '';1995 var strArr = [];1996 if ($(EditNames.blackOutOther.addHash()).val() !== '') {1997 strArr.push($(EditNames.blackOutOther.addHash()).val());1998 }1999 if ($(EditNames.blackOutMay.addHash()).prop('checked')) {2000 strArr.push('5/3ï½5/5');2001 }2002 if ($(EditNames.blackOutEndYear.addHash()).prop('checked')) {2003 strArr.push('å¹´æ«å¹´å§12/29ï½1/3');2004 }2005 $wrap.attr(BoxNames.blackOutOther, $(EditNames.blackOutOther.addHash()).val());2006 $wrap.attr(BoxNames.blackOutMay, $(EditNames.blackOutMay.addHash()).prop('checked'));2007 $wrap.attr(BoxNames.blackOutEndYear, $(EditNames.blackOutEndYear.addHash()).prop('checked'));2008 str = strArr.join('ã»');2009 if (str) {2010 str = '(' + str + 'ãé¤ã)';2011 }2012 $wrap.html(str);2013 },2014 // èªã¿è¾¼ãã ãã¼ã¿ãããã«ã®å
¥åç»é¢ã«ã»ãããã2015 readVal: function($elm) {2016 var $preview = $elm.find(EditNames.panel.addHash() + '-preview');2017 // ã»ã³ã¿å2018 var centerVal = $preview.find(BoxNames.center.addDot()).first().text().trimEx();2019 if (centerVal !== '') {2020 $(EditNames.center.addHash()).val(centerVal);2021 EditPanel.showInputParentSection($(EditNames.center.addHash()));2022 }2023 // ä½æç2024 var addressVal = $preview.find(BoxNames.address.addDot()).first().html();2025 // ååå¤ã¨ãã¦ã®å¤ãã»ãã2026 $(EditNames.address.addHash()).data('prevVal', addressVal);2027 if (addressVal !== '') {2028 $(EditNames.address.addHash()).val(addressVal);2029 $(EditNames.address.addHash()).parents(EditNames.editBox.addDot() + '-wrap').first().find(EditNames.editBox.addDot() + '-editbox').first().html(addressVal);2030 EditPanel.showInputParentSection($(EditNames.address.addHash()));2031 }2032 // é»è©±çªå·2033 $preview.find(BoxNames.phoneGroup.addDot()).each(function(iPhone) {2034 if (iPhone < 1) {2035 EditPanel.showInputParentSection($(EditNames.phoneGroupWrap.addHash()));2036 }2037 var $phoneTmp = $(EditPanel.phoneTmp);2038 var phonePre = $(this).children(BoxNames.phonePrefix.addDot()).first().text().trimEx();2039 var phoneSuf = $(this).children(BoxNames.phoneSuffix.addDot()).first().text().trimEx();2040 $phoneTmp.find(EditNames.phonePrefix.addDot()).first().val(phonePre);2041 $phoneTmp.find(EditNames.phoneSuffix.addDot()).first().val(phoneSuf);20422043 var otherState = $(this).attr(BoxNames.phoneOtherState) || '';2044 var otherDate = $(this).attr(BoxNames.phoneOtherDate) || '';2045 var otherNum = $(this).attr(BoxNames.phoneOtherNumber) || '';2046 var defaultNum = $(this).attr(BoxNames.phoneDefaultNumber) || '';2047 $phoneTmp.find(EditNames.phoneNumber.addDot()).first().val(defaultNum);2048 $phoneTmp.find(EditNames.phoneOtherState.addDot()).first().val(otherState.toInt());2049 $phoneTmp.find(EditNames.phoneOtherDate.addDot()).first().val(otherDate);2050 $phoneTmp.find(EditNames.phoneOtherNumber.addDot()).first().val(otherNum);20512052 $(EditNames.phoneGroupWrap.addHash()).append($phoneTmp);2053 });2054 EditPanel.setPhoneDelBtn();2055 // ãã¼ã ãã¼ã¸ãã¬ãã£ã¯ã¹2056 var hpPreVal = $preview.find(BoxNames.hpPrefix.addDot()).first().text().trimEx();2057 if (hpPreVal !== '') {2058 $(EditNames.hpPrefix.addHash()).val(hpPreVal);2059 EditPanel.showInputParentSection($(EditNames.hpPrefix.addHash()));2060 }2061 // ãã¼ã ãã¼ã¸2062 var hpVal = $preview.find(BoxNames.hpAddress.addDot()).first().children('a').first().text();2063 if (hpVal !== '') {2064 $(EditNames.hpAddress.addHash()).val(hpVal);2065 EditPanel.showInputParentSection($(EditNames.hpAddress.addHash()));2066 }2067 // ã¡ã¼ã«2068 $preview.find(BoxNames.mailGroup.addDot()).each(function(iMail) {2069 var $mailTmp = $(EditPanel.mailTmp);2070 var mailPre = $(this).children(BoxNames.mailPrefix.addDot()).first().text().trimEx();2071 var mailAdrs = $(this).children(BoxNames.mailAdress.addDot()).first().children('a').first().text();2072 $mailTmp.find(EditNames.mailPrefix.addDot()).first().val(mailPre);2073 $mailTmp.find(EditNames.mailAdress.addDot()).first().val(mailAdrs);2074 $(EditNames.mailGroupWrap.addHash()).append($mailTmp);2075 if (iMail < 1 && mailPre !== '' && mailAdrs !== '') {2076 EditPanel.showInputParentSection($(EditNames.mailGroupWrap.addHash()));2077 }2078 });2079 EditPanel.setMailDelBtn();2080 // åä»æé2081 var $brt = $preview.find(BoxNames.receptionTime.addDot()).first();2082 $(EditNames.receptionHourFrom.addHash()).val($brt.attr(BoxNames.receptionHourFrom) || 9);2083 $(EditNames.receptionTimeFrom.addHash()).val($brt.attr(BoxNames.receptionTimeFrom) || 0);2084 $(EditNames.receptionHourTo.addHash()).val($brt.attr(BoxNames.receptionHourTo) || 17);2085 $(EditNames.receptionTimeTo.addHash()).val($brt.attr(BoxNames.receptionTimeTo) || 0);2086 $(EditNames.receptionLunch.addHash()).prop('checked', $brt.attr(BoxNames.receptionLunch) === "true" ? true : false);2087 if ($('input[name="' + EditNames.receptionTimeName + '"]:checked').val() !== '1') {2088 EditPanel.showInputParentSection($(EditNames.receptionHourFrom.addHash()));2089 }2090 $('input[name="' + EditNames.receptionTimeName + '"]').val([$brt.attr(BoxNames.receptionAllowed) || 1]).change();2091 // åä»æ¥2092 var $brd = $preview.find(BoxNames.receptionDate.addDot()).first();2093 $(EditNames.receptionWeekday.addHash()).prop('checked', $brd.attr(BoxNames.receptionWeekday) === "true" ? true : false);2094 $(EditNames.receptionSaturday.addHash()).prop('checked', $brd.attr(BoxNames.receptionSaturday) === "true" ? true : false);2095 $(EditNames.receptionSunday.addHash()).prop('checked', $brd.attr(BoxNames.receptionSunday) === "true" ? true : false);2096 $(EditNames.receptionHoliday.addHash()).prop('checked', $brd.attr(BoxNames.receptionHoliday) === "true" ? true : false);2097 $(EditNames.reception365days.addHash()).prop('checked', $brd.attr(BoxNames.reception365days) === "true" ? true : false);2098 if ($(EditNames.receptionWeekday.addHash()).prop('checked') ||2099 $(EditNames.receptionSaturday.addHash()).prop('checked') ||2100 $(EditNames.receptionSunday.addHash()).prop('checked') ||2101 $(EditNames.receptionHoliday.addHash()).prop('checked') ||2102 $(EditNames.reception365days.addHash()).prop('checked')) {2103 EditPanel.showInputParentSection($(EditNames.receptionWeekday.addHash()));2104 }2105 // åä»ä¼ã¿2106 var $brb = $preview.find(BoxNames.blackOut.addDot()).first();2107 $(EditNames.blackOutMay.addHash()).prop('checked', $brb.attr(BoxNames.blackOutMay) === "true" ? true : false);2108 $(EditNames.blackOutEndYear.addHash()).prop('checked', $brb.attr(BoxNames.blackOutEndYear) === "true" ? true : false);2109 $(EditNames.blackOutOther.addHash()).val($brb.attr(BoxNames.blackOutOther));2110 if ($(EditNames.blackOutMay.addHash()).prop('checked') ||2111 $(EditNames.blackOutEndYear.addHash()).prop('checked') ||2112 $(EditNames.blackOutOther.addHash()).val() !== '') {2113 EditPanel.showInputParentSection($(EditNames.blackOutMay.addHash()));2114 }2115 // ãã®ä»2116 var otherVal = $preview.find(BoxNames.other.addDot()).first().html();2117 // ååå¤ã¨ãã¦ã®å¤ãã»ãã2118 $(EditNames.other.addHash()).data('prevVal', otherVal);2119 if (otherVal !== '') {2120 $(EditNames.other.addHash()).val(otherVal);2121 $(EditNames.other.addHash()).parents(EditNames.editBox.addDot() + '-wrap').first().find(EditNames.editBox.addDot() + '-editbox').first().html(otherVal);2122 EditPanel.showInputParentSection($(EditNames.other.addHash()));2123 }2124 // åä»æ¥ã®ãã§ãã¯ããã¯ã¹ãã»ãããã2125 EditPanel.setReceptionDateVal($elm);2126 // é»è©±ã®æ¥ä»ãã©ã°ã¤ã³ãåæåãã2127 EditPanel.setDatePicker();2128 },2129 // ç·¨éããã«å
é
ç®ã®è¡¨ç¤º2130 showInputParentSection: function($elm) {2131 $elm.parents('.edit-section').first().children('.edit-section-title').first().removeClass('close');2132 $elm.parents('.edit-section').first().children('fieldset').show();2133 },2134 // ç·¨éããã«å
ã®ãã¼ã¿ã®ã¯ãªã¢2135 reset: function($elm) {2136 $elm.find(EditNames.center.addHash()).val('');2137 $elm.find(EditNames.address.addHash()).val('');2138 $elm.find(EditNames.phoneGroup.addDot()).remove();2139 $elm.find(EditNames.hpPrefix.addHash()).val('');2140 $elm.find(EditNames.hpAddress.addHash()).val('');2141 $elm.find(EditNames.hpAddress.addHash()).parents(EditNames.editBox.addDot() + '-wrap').first().find(EditNames.editBox.addDot() + '-editbox').first().html('');2142 $elm.find(EditNames.mailGroup.addDot()).remove();2143 $elm.find(EditNames.receptionWeekday.addHash()).first().prop('checked', false).prop('disabled', false);2144 $elm.find(EditNames.receptionSaturday.addHash()).first().prop('checked', false).prop('disabled', false);2145 $elm.find(EditNames.receptionSunday.addHash()).first().prop('checked', false).prop('disabled', false);2146 $elm.find(EditNames.receptionHoliday.addHash()).first().prop('checked', false).prop('disabled', false);2147 $elm.find(EditNames.reception365days.addHash()).first().prop('checked', false).prop('disabled', false);2148 $elm.find(EditNames.receptionNothing.addHash()).first().prop('checked', true);2149 $elm.find(EditNames.receptionHourFrom.addHash()).val(9).prop('disabled', true);2150 $elm.find(EditNames.receptionTimeFrom.addHash()).val(0).prop('disabled', true);2151 $elm.find(EditNames.receptionHourTo.addHash()).val(17).prop('disabled', true);2152 $elm.find(EditNames.receptionTimeTo.addHash()).val(0).prop('disabled', true);2153 $elm.find(EditNames.receptionLunch.addHash()).first().prop('checked', false);2154 $elm.find(EditNames.blackOutMay.addHash()).first().prop('checked', false);2155 $elm.find(EditNames.blackOutEndYear.addHash()).first().prop('checked', false);2156 $elm.find(EditNames.blackOutOther.addHash()).val('');2157 $elm.find(EditNames.other.addHash()).val('');2158 $elm.find(EditNames.other.addHash()).parents(EditNames.editBox.addDot() + '-wrap').first().find(EditNames.editBox.addDot() + '-editbox').first().html('');21592160 // ããã¹ãã¨ãªã¢ã®å
¥åãç·¨éã¨ãªã¢ã«å¤æ´2161 $(EditNames.editBox.addDot() + '-editbox').hide();2162 $('.source').click();2163 // ç·¨éããã«ã®ãã£ã¼ã«ãããã£ããéãã2164 $elm.find('.edit-section-title').addClass('close');2165 $elm.find('fieldset[id|=field]').hide();2166 },2167 // ç·¨éé
ç®ã®ã»ãã2168 setEditItem: function($edit, $box) {2169 var colClass = '';2170 var $col = $box.parents('th,td').first();2171 if ($col.hasClass('col1')) {2172 colClass = 'col1';2173 } else if ($col.hasClass('col2')) {2174 colClass = 'col2';2175 } else if ($col.hasClass('col3')) {2176 colClass = 'col3';2177 }21782179 if (colClass === 'col1') {2180 $edit.find('.edit-section').addClass(Names.hidden);2181 // ä½æé
ç®ãããã©ã«ãã§ãªã¼ãã³ã«ãã2182 $edit.find(EditNames.fieldAddress.addHash()).prev().removeClass('close');2183 $edit.find(EditNames.fieldAddress.addHash()).show();2184 } else {2185 $edit.find('.edit-section').removeClass(Names.hidden);2186 }2187 // ä½æé
ç®ã®ã¿å
¥åå¯ã¨ãã2188 $edit.find(EditNames.fieldAddress.addHash()).parents('.edit-section').first().removeClass(Names.hidden);2189 },2190 // é»è©±çªå·ã®è¿½å 2191 addPhone: function(elm) {2192 $(EditNames.phoneGroupWrap.addHash()).append($(EditPanel.phoneTmp));2193 EditPanel.setPhoneDelBtn();2194 EditPanel.setDatePicker();2195 },2196 // é»è©±çªå·ã®åé¤2197 delPhone: function(elm) {2198 $(elm).parents('fieldset').first().remove();2199 EditPanel.setPhoneDelBtn();2200 EditPanel.setPhoneVal();2201 },2202 // é»è©±çªå·ã®åé¤ãã¿ã³ã®ã»ãã2203 setPhoneDelBtn: function() {2204 // ä¸æ¦å
¨ã¦ã®ãã¿ã³ã®åé¤2205 $(EditNames.btnPhoneDel.addDot()).remove();2206 // 2å以ä¸ãªãåé¤ãã¿ã³ã®ã»ãã2207 if ($(EditNames.phoneGroup.addDot()).length > 1) {2208 $(EditNames.phoneGroup.addDot()).each(function() {2209 $(this).append(2210 $('<button></button>').text('åé¤')2211 .attr('type', 'button')2212 .addClass('btn-del-phone btn btn-danger pull-left mg-l-5')2213 );2214 });2215 }2216 EditPanel.addChangeEvent();2217 },2218 // ã¡ã¼ã«ã¢ãã¬ã¹ã®è¿½å 2219 addMail: function(elm) {2220 $(EditNames.mailGroupWrap.addHash()).append($(EditPanel.mailTmp));2221 EditPanel.setMailDelBtn();2222 },2223 // ã¡ã¼ã«ã¢ãã¬ã¹ã®åé¤2224 delMail: function(elm) {2225 $(elm).parents('fieldset').first().remove();2226 EditPanel.setMailDelBtn();2227 EditPanel.setMailVal();2228 },2229 // ã¡ã¼ã«ã®åé¤ãã¿ã³ã®ã»ãã2230 setMailDelBtn: function() {2231 // ä¸æ¦å
¨ã¦ã®ãã¿ã³ã®åé¤2232 $(EditNames.btnMailDelWrap.addDot()).remove();2233 // 2å以ä¸ãªãåé¤ãã¿ã³ã®ã»ãã2234 if ($(EditNames.mailGroup.addDot()).length > 1) {2235 $(EditNames.mailGroup.addDot()).each(function() {2236 var $lavel = $('<label></label>').addClass(EditNames.btnMailDelWrap);2237 $lavel.append('ã')2238 .append(2239 $('<button></button>')2240 .text('åé¤')2241 .attr('type', 'button')2242 .addClass('btn-del-mail btn btn-danger pull-left mg-l-5')2243 );2244 $(this).append($lavel);2245 });2246 }2247 EditPanel.addChangeEvent();2248 },2249 // ãªã¢ã«ã¿ã¤ã å
¥åç¨ã®ã¤ãã³ãã®ç»é²2250 addChangeEvent: function() {2251 $(EditNames.panel.addHash() + ' input, ' + EditNames.panel.addHash() + ' textarea').imeEnter();2252 },2253 // ãã¤ãããã«ã¼ã®ã»ãã2254 setDatePicker: function() {2255 $(EditNames.phoneOtherDate.addDot()).datepicker({2256 format: "yyyy-mm-dd",2257 todayBtn: true,2258 clearBtn: true,2259 language: "ja",2260 autoclose: true,2261 todayHighlight: true,2262 orientation: "top auto",2263 beforeShowDay: function (date){2264 date = new UltraDate(date);2265 var holidays = UltraDate.getHolidays(date.getFullYear());2266 var ret = {2267 tooltip: '',2268 classes: ''2269 };2270 var holiday = holidays[date.format(UltraDate.getDefaultFormat())];2271 if (holiday) {2272 ret.tooltip = holiday;2273 ret.classes = 'holiday';2274 }2275 switch (date.getDay()) {2276 case 0:2277 ret.classes += ' sunday';2278 break;2279 case 6:2280 ret.classes += ' saturday';2281 break;2282 }2283 return ret;2284 }2285 });2286 }2287 };22882289 // ãã¼ãã«æä½2290 var DataTable = {2291 dataBlock: '',2292 // ã¿ã¤ãã«è¡ã®ãã³ãã¬ã¼ã2293 tHeadRowTmp:'<tr>' +2294 ' <th class="col1">é¨ç½²å</th>' +2295 ' <th class="col2">å
容</th>' +2296 ' <th class="col3">é»è©±çªå·</th>' +2297 '</tr>',2298 // è¡ã®ãã³ãã¬ã¼ã2299 tBodyRowTmp: '<tr>' +2300 ' <th class="col1 col1_1"></th>' +2301 ' <td class="col1 col1_2 hidden"></td>' +2302 ' <td class="col2 "></td>' +2303 ' <td class="col3"></td>' +2304 '</tr>',23052306 /* ããããã³ã³ããã¹ãã¡ãã¥ã¼ç¨ã®ã¤ãã³ãå¦ç ---------------------------------------------------------------------------- */2307 // è¡ãä¸ç§»å2308 moveUpRow: function() {2309 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2310 var $rows = $tbody.find('tr');2311 var indexs = DataTable.getSelectRowLength($tbody);2312 var $row = $rows.eq(DataTable.getMoveUpRow($tbody, indexs.start));2313 var $moveRows = $tbody.find(Names.showMoveRow.addDot());23142315 for (var i = 0, len = $moveRows.length; i < len; i++) {2316 $row.before($moveRows.eq(i));2317 }2318 },2319 // è¡ãä¸ç§»å2320 moveDownRow: function() {2321 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2322 var indexs = DataTable.getSelectRowLength($tbody);2323 var $rows = $tbody.find('tr');2324 var $row = $rows.eq(DataTable.getMoveDownRow($tbody, indexs.end));2325 var $moveRows = $tbody.find(Names.showMoveRow.addDot());23262327 for (var i = $moveRows.length; i >= 0; i--) {2328 $row.after($moveRows.eq(i));2329 }2330 },2331 // ã»ã«ã®çµå2332 joinCell: function() {2333 // ã³ã³ãã¡ã¼ã ã§çµåããã確èª2334 if (!confirm('çµåå
ã«ãªãã»ã«ä»¥å¤ã®ãã¼ã¿ã¯åé¤ããã¾ããããããã§ããï¼')) {2335 return false;2336 }2337 // 該å½ãã¼ãã«ã®tbody2338 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2339 // é¸æãã¦ããã»ã«ç¾¤2340 var $selectCells = $tbody.find(Names.uiSelected.addDot()).not('tr');2341 // çµåã»ã«ã®è¡æ°2342 var rowspan = 0;2343 var colName = '';2344 // rowspanã®æ°ãæ°ãã2345 $.each(Names.colClasses, function(i, col) {2346 $selectCells.filter(col.addDot()).each(function(index, elm) {2347 rowspan += $(elm).getRowspan();2348 });2349 if (rowspan > 0) {2350 colName = col;2351 // braek2352 return false;2353 }2354 });2355 // æåã®ã»ã«ã«rowspanãã»ãã2356 $selectCells.first().attr('rowspan', rowspan)2357 .removeClass(Names.hidden);2358 // 次ã®ã»ã«ãé¸æããã¦ãããã©ãã確èª2359 var col1_2Select = ($selectCells.first().next().hasClass(Names.uiSelected));2360 // 次ã®ã»ã«ãé¸æããã¦ãã=col1ã¯ã©ã¹ã®ã»ã«ã§è¤æ°åé¸æããã¦ãã2361 if (col1_2Select) {2362 $selectCells.first().next().attr('rowspan', 1)2363 .addClass(Names.hidden);2364 }2365 // è¦ãã¦ããªãã»ã«ãå«ãã¦é表示å¦çã¨rowspanå¦çãè¡ã2366 var $cell = $selectCells.first().parent().find(colName.addDot()).first();2367 for (var i=rowspan; i>1; i--) {2368 $cell = $cell.parent().next().find(colName.addDot()).first();2369 $cell.attr('rowspan', 1)2370 .addClass(Names.hidden);2371 if (col1_2Select) {2372 $cell.next().attr('rowspan', 1)2373 .addClass(Names.hidden);2374 }2375 }23762377 // 空ç½è¡ã®åé¤å¦ç2378 DataTable.removeEmptyRow($tbody);23792380 // colspanã®ã»ãã2381 DataTable.setColspan($tbody);23822383 var $table = $tbody.parents('table').first();2384 $table.find('tfoot').first().find('td').first().attr('colspan', DataTable.getTfootColspan($table));2385 },2386 // ã»ã«ã®åå²2387 splitCell: function() {2388 // é¸æãã¦ããã»ã«ãã«ã¼ã2389 $(Names.uiSelected.addDot()).each(function() {2390 // 該å½è¡2391 var $row = $(this).parent('tr');2392 // rowspanãåå¾2393 var rowspan = $(this).getRowspan();2394 // ååã«ä»ä¸ãããã¯ã©ã¹2395 var colClass = '';2396 // åå²ããã»ã«ãã©ã®åã®ã»ã«ãã確èª2397 for (var col in Names.colClasses) {2398 if ($(this).hasClass(Names.colClasses[col])) {2399 colClass = Names.colClasses[col];2400 break;2401 }2402 }2403 // ã»ã«ã®rowspanãã¯ãªã¢2404 $(this).attr('rowspan', 1);2405 // rowspanã®æ°ã ãè¡ã«ã¿ã°ã追å 2406 for (var i = 0; i < (rowspan - 1); i++) {2407 $row = $row.next();2408 $row.children(colClass.addDot()).removeClass(Names.hidden);2409 }2410 });2411 },2412 // 1åç®ã®ååå²2413 splitCol: function() {2414 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2415 // é¸æãããã»ã«ãã«ã¼ã2416 $tbody.find('th' + Names.uiSelected.addDot()).each(function() {2417 // thã®æ¬¡ã®tdï¼col1_2ï¼ã®hiddenã¯ã©ã¹ãåé¤2418 $(this).next().removeClass(Names.hidden)2419 .addClass(Names.uiSelected)2420 .attr('rowspan', $(this).getRowspan());2421 });2422 DataTable.setColspan($tbody);2423 var $table = $tbody.parents('table').first();2424 $table.find('tfoot').first().find('td').first().attr('colspan', DataTable.getTfootColspan($table));2425 },2426 // è¡ã®è¿½å 2427 addRow: function(elm) {2428 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2429 var $rows = $tbody.find('tr');2430 var $row;2431 // ç¾å¨ããã¼ãã¦ããè¡ãåå¾2432 var $hoverRow = $tbody.find('tr' + Names.ctmHover.addDot()).first();2433 var rowIndex = $rows.index($hoverRow);2434 var $addRow = DataTable.createNewRow();2435 // è¡ã®ã»ã«ç¢ºèª2436 $.each(Names.colClasses, function(i, col) {2437 var hoverRowSpan = $hoverRow.find(col.addDot()).getRowspan();2438 if (!$hoverRow.find(col.addDot()).isShown()) {2439 // ã»ã«ã®é表示2440 $addRow.find(col.addDot()).addClass(Names.hidden);2441 // rowspanã®å¤æ´2442 for (var index = rowIndex; index >= 0; index--) {2443 // åã®è¡ã®rowspanã確èªãã1ãã大ãããã°ãã®è¡ã®rowspanãã1å¼ããå¤ã«è¨å®ãã2444 $row = $rows.eq(index).children(col.addDot()).first();2445 if ($row.getRowspan() > 1) {2446 $row.attr('rowspan', $row.getRowspan() + 1);2447 // ããããä¸ã«ã¯ããã®ã¼ããªã2448 break;2449 }2450 }2451 } else if (hoverRowSpan > 1) {2452 // ã»ã«ã®é表示2453 $addRow.find(col.addDot()).addClass(Names.hidden);2454 $hoverRow.find(col.addDot()).attr('rowspan', hoverRowSpan + 1);2455 }2456 });2457 // colspanã®ç¢ºèª2458 if ($($(Names.ctm.addHash()).data(Names.dataTargetElm)).find('.col1_2').isShown()) {2459 $addRow.find('.col1_1').first().attr('colspan', 2);2460 }2461 // è¡ã®è¿½å 2462 $hoverRow.after($addRow);2463 // ãã©ãã°ã¢ã³ãããããã¤ãã³ãã®è¿½å 2464 Cells.addSortableCol();2465 },2466 // è¡ã®åé¤2467 delRow: function(elm) {2468 if (!confirm('åé¤ããã¨å
ã«æ»ãã¾ãããããããã§ããï¼')) {2469 return false;2470 }24712472 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2473 var $rows = $tbody.find('tr');2474 var $row;2475 var $cell;2476 var $nextCell;2477 var $removeRow = $tbody.find('tr' + Names.ctmHover.addDot()).first();2478 var rowIndex = $rows.index($removeRow);2479 var index = 0;24802481 $.each(Names.colClasses, function(i, col) {2482 // åé¤ããè¡ã®ã»ã«ãåå¾2483 $cell = $removeRow.children(col.addDot()).first();24842485 if (!$cell.isShown()) {2486 // ã»ã«ã表示ããã¦ããªãæï¼rowspanã§ã¾ã¨ãããã¦ããï¼2487 for (index = rowIndex; index >= 0; index--) {2488 // åã®è¡ã®rowspanã確èªãã1ãã大ãããã°ãã®è¡ã®rowspanãã1å¼ããå¤ã«è¨å®ãã2489 $row = $rows.eq(index).children(col.addDot()).first();2490 if ($row.getRowspan() > 1) {2491 $row.attr('rowspan', $row.getRowspan() - 1);2492 // ããããä¸ã«ã¯ããã®ã¼ããªã2493 break;2494 }2495 }2496 } else if ($cell.getRowspan() > 1) {2497 // rowspanãè¨å®ããã¦ããã¨ãã¯æ¬¡ã®è¡ã«ã³ãã¼ãã¦rowspanãä¸ã¤æ¸ãã2498 //2499 // 次ã®è¡ã®ã»ã«ãåå¾2500 $nextCell = $removeRow.next().children(col.addDot()).first();2501 // 次ã®è¡ã®ã»ã«ã®å¾ãã«ã¯ãã¼ã³ãããã®ãæ¿å
¥2502 $nextCell.after($cell.clone().attr('rowspan', $cell.getRowspan() -1));2503 // å
ã®æ¬¡ã®è¡ã®ã»ã«ãåé¤2504 $nextCell.remove();2505 }2506 });25072508 $removeRow.fadeOut('slow', function() {2509 $removeRow.remove();2510 });2511 },2512 // 2è¡è¡¨ç¤º2513 show2Col: function() {2514 var $table = $($(Names.ctm.addHash()).data(Names.dataTargetElm)).parents('table').first();2515 $table.find('.col2').addClass(Names.hidden);2516 DataTable.removeEmptyRow($table.find('tbody').first());2517 $table.find('tfoot').first().find('td').first().attr('colspan', DataTable.getTfootColspan($table));2518 },2519 // 3è¡è¡¨ç¤º2520 show3Col: function() {2521 var $table = $($(Names.ctm.addHash()).data(Names.dataTargetElm)).parents('table').first();2522 var rowspaning = 1;2523 $table.find('.col2').each(function() {2524 // rowspanã1ãã大ããæã¯rowspaningã«å¤ãã»ãããã2525 if ($(this).getRowspan() > 1) {2526 rowspaning = $(this).getRowspan();2527 $(this).removeClass(Names.hidden);2528 }2529 rowspaning -= 1;2530 // rowspaningã1ããå°ããæã¯é表示ã®ã¾ã¾ãããã§ç¡ãæã¯hiddenã¯ã©ã¹ãåé¤2531 if (rowspaning < 1) {2532 $(this).removeClass(Names.hidden);2533 }2534 });2535 $table.find('tfoot').first().find('td').first().attr('colspan', DataTable.getTfootColspan($table));2536 },2537 // ããã¿ã¼è¡ã®è¿½å 2538 addTfoot: function() {2539 var $table = $($(Names.ctm.addHash()).data(Names.dataTargetElm)).parents('table').first();2540 var $td = $('<td></td>').attr('colspan', DataTable.getTfootColspan($table));2541 var $tfoot = $('<tfoot></tfoot>').append(2542 $('<tr></tr>').append($td)2543 );2544 $table.append($tfoot);2545 },2546 // ããã¿ã¼è¡ã®åé¤2547 removeTfoot: function() {2548 var $table = $($(Names.ctm.addHash()).data(Names.dataTargetElm)).parents('table').first();2549 $table.find('tfoot').remove();2550 },2551 /* ããã¾ã§ã³ã³ããã¹ãã¡ãã¥ã¼ç¨ã®ã¤ãã³ãå¦ç ---------------------------------------------------------------------------- */2552 // é¸æãå§ã¾ã£ã¦ããã¨ãã«ã©ã®ã¯ã©ã¹ãå«ãã§ãããã®ç¢ºèªç¨2553 selectStart: '',2554 // ã»ã«ã®é¸æï¼jQueryUIã®selectableï¼2555 addSelectEvent: function() {2556 $('tbody').selectable({2557 filter: 'th, td',2558 // é¸æéå§æã®ã¤ãã³ã2559 start: function() {2560 $(Names.uiSelected.addDot()).removeClass(Names.uiSelected);2561 },2562 // é¸æå®äºæã®ã¤ãã³ã2563 stop: function(e, ui) {2564 // é¸æå®äºæã«å¤ã®ã¯ãªã¢2565 DataTable.selectStart = '';2566 },2567 // é¸æä¸ã®ã¤ãã³ã2568 selecting: function(e, ui) {2569 // æåã«é¸æãå§ããåã®ã¯ã©ã¹ãè¨å®2570 if (!DataTable.selectStart) {2571 switch (true) {2572 case $(ui.selecting).hasClass('col1'):2573 DataTable.selectStart = 'col1';2574 break;2575 case $(ui.selecting).hasClass('col2'):2576 DataTable.selectStart = 'col2';2577 break;2578 case $(ui.selecting).hasClass('col3'):2579 DataTable.selectStart = 'col3';2580 break;2581 }2582 }2583 // åãåã®ãã®ä»¥å¤ã¯é¸æã§ããªãããã«ãã2584 if (!$(ui.selecting).hasClass(DataTable.selectStart)) {2585 $(ui.selecting).removeClass(Names.uiSelecting);2586 }2587 },2588 // é¸æãçµãã£ã¦é¸æä¸ããé¸ææ¸ã¿ã«å¤ããæã®ã¤ãã³ã2589 selected: function(e, ui) {2590 if (!$(ui.selected).hasClass(DataTable.selectStart)) {2591 $(ui.selected).removeClass(Names.uiSelected);2592 }2593 $(Names.hover.addDot()).removeClass(Names.hover);2594 $(ui.selected).parents('tr').first().addClass(Names.hover);2595 }2596 });2597 },2598 // 1åç®ã®colspanãã»ããã»ãªã»ãã2599 setColspan: function($tbody) {2600 // col1_2ã¯ã©ã¹ã®ããå ´åã¯colspanãã»ãã2601 if ($tbody.find('.col1_2').isShown()) {2602 $tbody.prev('thead').find('th').first().attr('colspan', 2);2603 var rowspaning = 0;2604 $tbody.find('.col1_1').each(function() {2605 if ($(this).next().getRowspan() > 1) {2606 rowspaning = $(this).next().getRowspan();2607 }2608 if ($(this).next().isShown()) {2609 $(this).attr('colspan', 1);2610 } else if (rowspaning > 0) {2611 $(this).attr('colspan', 1);2612 } else {2613 $(this).attr('colspan', 2);2614 }2615 rowspaning -= 1;2616 });2617 } else {2618 $tbody.prev('thead').find('th').first().attr('colspan', 1);2619 $tbody.find('.col1_1').attr('colspan', 1);2620 }2621 },2622 // 空è¡ã®åé¤2623 removeEmptyRow: function($tbody) {2624 var $rows = $tbody.find('tr');2625 // 空ç½ã®è¡ã®åé¤å¦ç2626 $rows.each(function() {2627 if (!$(this).isEmptyRow()) {2628 // continu2629 return true;2630 }26312632 var rowIndex = $rows.index(this);2633 rowspan = 0;2634 $.each(Names.colClasses, function(i, colName) {2635 // ã»ã«ã表示ããã¦ããªãæï¼rowspanã§ã¾ã¨ãããã¦ããï¼2636 for (var index = rowIndex; index >= 0; index--) {2637 // åã®è¡ã®rowspanã確èªãã1ãã大ãããã°ãã®è¡ã®rowspanãã1å¼ããå¤ã«è¨å®ãã2638 $prevCell = $rows.eq(index).children(colName.addDot()).first();2639 rowspan = $prevCell.getRowspan();2640 if (rowspan > 1) {2641 $prevCell.attr('rowspan', rowspan - 1);2642 // ããããä¸ã«ã¯ããã®ã¼ããªã2643 break;2644 }2645 }2646 });26472648 // è¡ãåé¤ãã2649 $(this).remove();2650 });2651 },2652 // è¡ãããã¼ããæ2653 hoverRow: function(elm) {2654 // è¡ãè¦ãããããã«è¡ã®ä¸ä¸ãç·ã§æã2655 $(elm).parents(Names.tblWrap).first()2656 .append($(Names.hoverRowTop.addHash()))2657 .append($(Names.hoverRowBottom.addHash()));2658 $(Names.hoverRowTop.addHash()).css({2659 top: $(elm).offset().top - 1,2660 left: $(elm).offset().left,2661 width: $(elm).width() + 'px'2662 }).show();2663 $(Names.hoverRowBottom.addHash()).css({2664 top: $(elm).offset().top + $(elm).height() -1,2665 left: $(elm).offset().left,2666 width: $(elm).width() + 'px'2667 }).show();2668 },2669 // ã³ã³ããã¹ãã¡ãã¥ã¼ã®ãè¡ã®è¿½å ããããã¼ããæã«æ¿å
¥å ´æã®ç·ã表示2670 hoverUpRow: function() {2671 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2672 var $rows = $tbody.find('tr');26732674 var indexs = DataTable.getSelectRowLength($tbody);2675 // indexsã®æåããæå¾ã®è¡ã¾ã§é¸æã¯ã©ã¹ãä»ä¸ãã2676 for (var i = indexs.start, len = indexs.end; i <= len; i++) {2677 $rows.eq(i).addClass(Names.showMoveRow);2678 }2679 // ä¸ã®ç§»åå
ã®è¡ãåå¾ãã2680 var $row = $rows.eq(DataTable.getMoveUpRow($tbody, indexs.start));26812682 // ã»ãã¬ã¼ã¿ãæ¿å
¥ãã¦è¡¨ç¤º2683 $tbody.parents(Names.tblWrap).first().append($(Names.rowSeparator.addHash()));2684 $(Names.rowSeparator.addHash()).css({2685 top: $row.offset().top,2686 left: $row.offset().left,2687 background: '#744199',2688 width: $tbody.width() + 'px'2689 }).show();2690 },2691 // ã³ã³ããã¹ãã¡ãã¥ã¼ã®ãè¡ã®è¿½å ããããã¼ããæã«æ¿å
¥å ´æã®ç·ã表示2692 hoverDownRow: function() {2693 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2694 var $rows = $tbody.find('tr');26952696 // ç¾å¨é¸æããã¦ããè¡ãã移åãããããã¯ãåå¾ãã2697 var indexs = DataTable.getSelectRowLength($tbody);2698 // indexsã®æåããæå¾ã®è¡ã¾ã§é¸æã¯ã©ã¹ãä»ä¸ãã2699 for (var i = indexs.start, len = indexs.end; i <= len; i++) {2700 $rows.eq(i).addClass(Names.showMoveRow);2701 }2702 // ä¸ã®ç§»åå
ã®è¡ãåå¾ãã2703 var $row = $rows.eq(DataTable.getMoveDownRow($tbody, indexs.end));27042705 // ã»ãã¬ã¼ã¿ãæ¿å
¥ãã¦è¡¨ç¤º2706 $tbody.parents(Names.tblWrap).first().append($(Names.rowSeparator.addHash()));2707 $(Names.rowSeparator.addHash()).css({2708 top: $row.offset().top + $row.height(),2709 left: $row.offset().left,2710 background: '#744199',2711 width: $tbody.width() + 'px'2712 }).show();2713 },2714 // ã³ã³ããã¹ãã¡ãã¥ã¼ã®ãè¡ã®è¿½å ããããã¼ããæã«æ¿å
¥å ´æã®ç·ã表示2715 hoverAddRow: function() {2716 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2717 var $row = $tbody.find('tr' + Names.ctmHover.addDot()).first();2718 $tbody.parents(Names.tblWrap).first().append($(Names.rowSeparator.addHash()));2719 $(Names.rowSeparator.addHash()).css({2720 top: $row.offset().top + $row.height(),2721 left: $row.offset().left,2722 background: '#f00',2723 width: $tbody.width() + 'px'2724 }).show();2725 },2726 // ã³ã³ããã¹ãã¡ãã¥ã¼ã®ãè¡ã®åé¤ããããã¼ããæã«åé¤è¡ã®å®éã«åé¤ãããã»ã«ã«åé¤ã¯ã©ã¹ãä»ä¸2727 hoverDelRow: function() {2728 // è¡ãè¦ãããããã«è¡ã®ä¸ã«ããã«ã表示2729 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2730 var $row = $tbody.find('tr' + Names.ctmHover.addDot()).first();2731 $row.children().each(function() {2732 if (!$(this).isShown() || $(this).getRowspan() === 1) {2733 $(this).addClass(Names.showDelRow);2734 }2735 });2736 // ã³ã³ãã³ãã®è¿½å ãã¿ã³ã®éé¿2737 Cells.removeAddBoxBtn();2738 },2739 // 移åããè¡ã®ç¯å²ãåå¾2740 getSelectRowLength: function($tbody) {2741 var $rows = $tbody.find('tr');2742 var ret = {2743 start: 0,2744 end: -12745 };2746 var $selectRow = $tbody.find('tr' + Names.ctmHover.addDot()).first();2747 var selectIndex = $rows.index($selectRow);2748 var i = 0;2749 var len = 0;2750 // æ¤ç´¢ããããåã®åå¾2751 var cols = DataTable.getColClass($tbody);2752 // åãå
¨ã¦è¡¨ç¤ºããã¦ãããã©ããã®å¤å®ç¨é¢æ°2753 var isAllShow = function($row){2754 var ret = true;2755 $.each(cols, function(i, col) {2756 if (!$row.find(col.addDot()).isShown()) {2757 ret = false;2758 return false;2759 }2760 });2761 return ret;2762 };2763 // å
¨ã¦ã®è¡ã表示ããã¦ããã¨ããã¾ã§ããã®ã¼ã2764 for (i = selectIndex; i >= 0; i--) {2765 if (isAllShow($rows.eq(i))) {2766 // ãã¹ã¦ã®åã表示ããã¦ããã¨ãããã¹ã¿ã¼ãã¤ã³ããã¯ã¹ã¨ãã2767 ret.start = i;2768 break;2769 }2770 }27712772 // 次ã®å
¨ã¦ã®è¡ã表示ããã¦ããåã®è¡ãçµããã®è¡ã¨ãã2773 for (i = ret.start + 1, len = $rows.length; i < len; i++) {2774 if (isAllShow($rows.eq(i))) {2775 // ãã¹ã¦ã®åã表示ããã¦ããã¨ãããæçµ2776 ret.end = i - 1;2777 break;2778 }2779 }2780 if (ret.end === -1) {2781 ret.end = $rows.length - 1;2782 }2783 return ret;2784 },2785 // ä¸ã®è¡ã«ç§»åããã¨ãã®ç§»åå
ã®è¡2786 getMoveUpRow: function($tbody, index) {2787 var $rows = $tbody.find('tr');2788 var rowIndex = index - 1;27892790 // æ¤ç´¢ããããåã®åå¾2791 var cols = DataTable.getColClass($tbody);2792 // åãå
¨ã¦è¡¨ç¤ºããã¦ãããã©ããã®å¤å®ç¨é¢æ°2793 var isAllShow = function($row){2794 var ret = true;2795 $.each(cols, function(i, col) {2796 if (!$row.find(col.addDot()).isShown()) {2797 ret = false;2798 return false;2799 }2800 });2801 return ret;2802 };2803 // å
¨ã¦ã®è¡ã表示ããã¦ããã¨ããã¾ã§ããã®ã¼ã2804 for (var i = rowIndex; i >= 0; i--) {2805 if (isAllShow($rows.eq(i))) {2806 // ãã¹ã¦ã®åã表示ããã¦ããã¨ãããã¹ã¿ã¼ãã¤ã³ããã¯ã¹ã¨ãã2807 rowIndex = i;2808 break;2809 }2810 }28112812 return rowIndex;2813 },2814 // ä¸ã®è¡ã«ç§»åããã¨ãã®ç§»åå
ã®è¡2815 getMoveDownRow: function($tbody, index) {2816 var $rows = $tbody.find('tr');2817 var rowIndex = index + 1;28182819 // æ¤ç´¢ããããåã®åå¾2820 var cols = DataTable.getColClass($tbody);2821 var rowspans = {};2822 $.each(cols, function(i, col) {2823 rowspans[col] = 0;2824 });2825 // åã«ã©ã ã®rowspanãåå¥ã«è¨ç®ãããã¹ã¦ã®rowspanãä¸è´ãããã©ããã®ç¢ºèª2826 var matchRowspanNums = function($row){2827 var ret = true;2828 // rowspanã®æ°ãè¨ç®ãã2829 $.each(cols, function(i, col) {2830 if ($row.find(col.addDot()).isShown()) {2831 rowspans[col] += $row.find(col.addDot()).getRowspan();2832 }2833 });2834 loop: for (var keys in rowspans) {2835 for (var key in rowspans) {2836 if (rowspans[keys] !== rowspans[key]) {2837 ret = false;2838 break loop;2839 }2840 }2841 }2842 return ret;2843 };2844 // å
¨ã¦ã®åã®rowspanããããããã¾ã§ã«ã¼ã2845 for (var i = rowIndex, len = $rows.length; i < len; i++) {2846 if (matchRowspanNums($rows.eq(i))) {2847 rowIndex = i;2848 break;2849 }2850 }28512852 return rowIndex;2853 },2854 // 表示ããã¦ããåã®ã¯ã©ã¹ç¾¤ãåå¾2855 getColClass: function($tbody) {2856 var $theadRow = $tbody.parents('table').first()2857 .find('thead').first()2858 .find('tr').first();2859 // æ¤ç´¢ããããåã®åå¾2860 var cols = [];2861 cols.push('col1_1');2862 if ($theadRow.find('.col1').getColspan() > 1) {2863 cols.push('col1_2');2864 }2865 if ($theadRow.find('.col2').isShown()) {2866 cols.push('col2');2867 }2868 cols.push('col3');28692870 return cols;2871 },2872 // tfootç¨ã®colspanãåå¾2873 getTfootColspan: function($table) {2874 var colspan = 0;2875 $table.find('thead').first().find('th').each(function() {2876 if ($(this).isShown()) {2877 colspan += $(this).getColspan();2878 }2879 });2880 return colspan;2881 },2882 createNewRow: function() {2883 var $newRow = $(DataTable.tBodyRowTmp);2884 $newRow.children().each(function() {2885 var $boxTmp = $(Cells.boxTmp);2886 $boxTmp.find(BoxNames.wrapPhone.addDot()).first().append($(Cells.phoneTmp));2887 $boxTmp.find(BoxNames.wrapMail.addDot()).first().append($(Cells.mailTmp));2888 $(this).append($boxTmp);2889 });2890 return $newRow;2891 }2892 };28932894 // ã³ã³ããã¹ãã¡ãã¥ã¼2895 var Context = {2896 // ã³ã³ããã¹ãã¡ãã¥ã¼ã®è¡¨ç¤º2897 show: function(tbody, e) {2898 var $tbody = $(tbody);2899 // ããã¼ã¯ã©ã¹ã®ã¤ãããã®ã«ã³ã³ããã¹ãã¡ãã¥ã¼ç¨ã®ããã¼ãä»ãã2900 // ããã¼è¡ãåºå®ããçº2901 $tbody.find(Names.hover.addDot()).addClass(Names.ctmHover);2902 // ããã¼ä¸ã®ã»ã«ï¼è¡ä»¥å¤ï¼ãåå¾2903 var $cmtHoverCells = $tbody.find(Names.ctmHover.addDot()).filter('th, td');2904 var $cmtHoverRow = $tbody.find(Names.ctmHover.addDot()).filter('tr');2905 // ããã¼ã¯ã©ã¹ã«é¸æã¯ã©ã¹ãç¡ãå ´åã¯ããã¼ãã¦ããã»ã«ãé¸æä¸ã»ã«ã«ãã2906 $cmtHoverCells.each(function(i, cell) {2907 if (!$(this).hasClass(Names.uiSelected)) {2908 $tbody.find(Names.uiSelected.addDot())2909 .removeClass(Names.uiSelected);2910 $(this).addClass(Names.uiSelected);2911 }2912 });2913 // ã³ã³ããã¹ãã«è©²å½tbodyãã»ãã2914 $(Names.ctm.addHash()).data(Names.dataTargetElm, tbody);29152916 /* ããããåã¡ãã¥ã¼ã®è¡¨ç¤ºã»é表示 ---------------------------------------- */2917 var $trs = $tbody.find('tr');2918 var indexs = DataTable.getSelectRowLength($tbody);2919 // â²è¡ãä¸ã«ç§»å ------------------------------------------------------2920 $(Names.ctmMoveUp.addHash()).removeClass(Names.disabled);2921 if (indexs.start === 0) {2922 $(Names.ctmMoveUp.addHash()).addClass(Names.disabled);2923 }29242925 // â¼è¡ãä¸ã«ç§»å ------------------------------------------------------2926 $(Names.ctmMoveDown.addHash()).removeClass(Names.disabled);2927 if (indexs.end === ($trs.length - 1)) {2928 $(Names.ctmMoveDown.addHash()).addClass(Names.disabled);2929 }29302931 // ã»ã«ã®çµå ---------------------------------------------------------2932 if ($trs.find(Names.uiSelected.addDot()).length > 1) {2933 $(Names.ctmJoinCell.addHash()).removeClass(Names.disabled);2934 } else {2935 $(Names.ctmJoinCell.addHash()).addClass(Names.disabled);2936 }2937 // col1_1ã¨col1_2ã®æåã¨æå¾ã®è¡ãããã£ã¦ããªãå ´åã¯ã»ã«ã®çµåè¨å®ãç¡å¹ã«ãã2938 var $selected = $(Names.uiSelected.addDot());2939 if ($selected.filter('.col1_1').length > 0 &&2940 $selected.filter('.col1_2').length > 0) {2941 var col1_1_start = $selected.filter('.col1_1').first().parent().index();2942 var col1_2_start = $selected.filter('.col1_2').first().parent().index();2943 if (col1_1_start !== col1_2_start) {2944 $(Names.ctmJoinCell.addHash()).addClass(Names.disabled);2945 }2946 var col1_1_end = $selected.filter('.col1_1').last().parent().index() +2947 $selected.filter('.col1_1').last().getRowspan();2948 var col1_2_end = $selected.filter('.col1_2').last().parent().index() +2949 $selected.filter('.col1_2').last().getRowspan();2950 if (col1_1_end !== col1_2_end) {2951 $(Names.ctmJoinCell.addHash()).addClass(Names.disabled);2952 }2953 }29542955 // ã»ã«ã®åå² ---------------------------------------------------------2956 $(Names.ctmSplitCell.addHash()).addClass(Names.disabled);2957 $tbody.find(Names.ctmHover.addDot() + ' ' + Names.uiSelected.addDot()).each(function () {2958 var rspan = $(this).getRowspan();2959 if ($(this).getRowspan() > 1) {2960 $(Names.ctmSplitCell.addHash()).removeClass(Names.disabled);2961 return false;2962 }2963 });29642965 // ã»ã«ã®ååå² -------------------------------------------------------2966 $(Names.ctmSplitCol.addHash()).addClass(Names.disabled);2967 $tbody.find('th' + Names.uiSelected.addDot()).each(function() {2968 if ($(this).next().hasClass(Names.hidden)) {2969 $(Names.ctmSplitCol.addHash()).removeClass(Names.disabled);2970 return false;2971 }2972 });29732974 // è¡ã®è¿½å ----------------------------------------------------------2975 var colBool = true;2976 $.each(Names.colClasses, function(i, col) {2977 var $cell = $cmtHoverRow.children(col.addDot());2978 colBool = ($cell.isShown() && $cell.getRowspan() === 1) ? false : true;2979 });2980 if (colBool) {2981 $(Names.ctmAddRow.addHash()).addClass(Names.disabled);2982 } else {2983 $(Names.ctmAddRow.addHash()).removeClass(Names.disabled);2984 }29852986 // è¡ã®åé¤ ----------------------------------------------------------2987 if ($trs.length > 1) {2988 $(Names.ctmDelRow.addHash()).removeClass(Names.disabled);2989 } else {2990 $(Names.ctmDelRow.addHash()).addClass(Names.disabled);2991 }29922993 // 2åã»3å表示 ------------------------------------------------------2994 if ($tbody.find('.col2').isShown()) {2995 $(Names.ctmTitle2Col.addHash()).removeClass(Names.disabled);2996 $(Names.ctmTitle3Col.addHash()).addClass(Names.disabled);2997 } else {2998 $(Names.ctmTitle2Col.addHash()).addClass(Names.disabled);2999 $(Names.ctmTitle3Col.addHash()).removeClass(Names.disabled);3000 }30013002 // ããã¿ã¼è¡ã®è¿½å ã»åé¤ ------------------------------------------------3003 if ($tbody.next('tfoot').length > 0) {3004 $(Names.ctmDelTfoot.addHash()).removeClass(Names.disabled);3005 $(Names.ctmAddTfoot.addHash()).addClass(Names.disabled);3006 } else {3007 $(Names.ctmAddTfoot.addHash()).removeClass(Names.disabled);3008 $(Names.ctmDelTfoot.addHash()).addClass(Names.disabled);3009 }30103011 /* ããã¾ã§åã¡ãã¥ã¼ã®è¡¨ç¤ºã»é表示 ---------------------------------------- */30123013 // ã³ã³ããã¹ãã¡ãã¥ã¼ã表示3014 $(Names.ctm.addHash()).fadeIn('fast');3015 var pageY = e.pageY - $(window).scrollTop();3016 var pageX = e.pageX - $(window).scrollLeft();3017 // ããã£ã³ã°ããã¼ãã¼ãå«ããé«ããåå¾3018 var ulBottom = $(Names.ctm.addHash()).find('ul').outerHeight();3019 // ããã£ã³ã°ããã¼ãã¼ãå«ããå¹
ãåå¾3020 var ulLeft = $(Names.ctm.addHash()).find('ul').outerWidth();3021 // ç»é¢ããé«ããã¯ã¿åºãå ´åã¯ä½ç½®ã調æ´3022 if ($(window).height() < pageY + ulBottom) {3023 pageY -= ulBottom;3024 }3025 // ç»é¢ããå¹
ãã¯ã¿åºãå ´åã¯ä½ç½®ã調æ´3026 if ($(window).width() < pageX + ulLeft) {3027 pageX -= ulLeft;3028 }3029 $(Names.ctm.addHash()).children('ul')3030 .css({3031 top: pageY,3032 left: pageX3033 });3034 },3035 // ã³ã³ããã¹ãã¡ãã¥ã¼ã®é表示3036 hide: function(elm) {3037 $(elm).fadeOut('fast', function () {3038 $($(Names.ctm.addHash()).data(Names.dataTargetElm))3039 .find(Names.ctmHover.addDot())3040 .removeClass(Names.ctmHover)3041 .addClass(Names.hover);3042 });3043 }3044 };30453046 // ãã«ãã´ãªã®ç·¨éãã¢ã¼ãã«ç¨3047 var ModalCate = {3048 // ã«ãã´ãªè¡ã®ãã³ãã¬ã¼ã3049 row: '<tr>' +3050 ' <td class="' + Names.mdlCateSort + '">â</td>' +3051 ' <td><input type="text" class="' + Names.mdlCateName + '"></td>' +3052 ' <td><input type="text" class="' + Names.mdlCateId + '"></td>' +3053 ' <td><input type="text" class="' + Names.mdlCateClass + '"></td>' +3054 ' <td>' +3055 ' <select class="' + Names.mdlCateEnable + '">' +3056 ' <option value="0">-</option>' +3057 ' <option value="1">åé¤</option>' +3058 ' </select>' +3059 ' </td>' +3060 '</tr>',3061 // 表ã«è¿½å ããã¨ãã®ãã³ãã¬ã¼ã3062 sectionTmp: '<div class="tn-section" id="">' +3063 ' <h3>ç·å</h3>' +3064 ' <div class="' + Names.tblWrap + '">' +3065 ' <table>' +3066 ' <thead>' +3067 ' </thead>' +3068 ' <tbody>' +3069 ' </tbody>' +3070 ' </table>' +3071 ' </div>' +3072 '</div>',3073 // ã¢ã¼ãã«ã®è¡¨ç¤º3074 show: function(table) {3075 // ä¸æ¦è¡ã®å
¨åé¤3076 $(Names.mdlCateTable.addHash()).empty();3077 $(Names.cntBody.addDot()).first().find(Names.section.addDot()).each(function() {3078 ModalCate.addRow(3079 $(this).children('h3').text(),3080 $(this).attr('id'),3081 $(this).attr('class')3082 );3083 });3084 },3085 // ã«ãã´ãªã®ã表示ã»åé¤ãã®å¤ãå¤ãã£ãæã®å¦ç3086 changeCateEnable: function(elm) {3087 // ã«ãã´ãªãåé¤ãããã©ããã®å¤ã確èªãã¦ã¯ã©ã¹ãè¨å®ãã3088 if ($(elm).children('option:selected').first().val() === '0') {3089 $(elm).removeClass(Names.mdlCateDel);3090 } else {3091 $(elm).addClass(Names.mdlCateDel);3092 }3093 },3094 // è¡ã®è¿½å å¦ç3095 addRow: function(cateName, cateId, cateClass) {3096 // ã«ãã´ãªä¸è¦§ã®ãã¼ãã«ãé¸æ3097 var $cateTable = $(Names.mdlCateTable.addHash());3098 // 追å ããè¡ã®ãã³ãã¬ã¼ããï½Queryãªãã¸ã§ã¯ãã¨ãã¦åå¾3099 var $row = $(ModalCate.row);3100 // è¡ã®inputè¦ç´ ã«å¤ãè¨å®3101 $row.find(Names.mdlCateName.addDot()).first().val(cateName || '');3102 $row.find(Names.mdlCateId.addDot()).first().val(cateId ? cateId.split('-')[1] : '')3103 .attr(Names.mdlCateNowId, cateId || '');3104 // sectionã¿ã°ã®ä»£ããã«ä»ãã¦ããtn-sectionãåé¤3105 cateClass = cateClass || '';3106 cateClass = cateClass.replace(Names.section, '').trim();3107 $row.find(Names.mdlCateClass.addDot()).first().val(cateClass || '');3108 // æ°è¦è¡ã®æã¯å¿
é ã¨ã©ã¼ãä»ä¸3109 if (!cateName) {3110 $row.find(Names.mdlCateName.addDot())3111 .addClass(Names.mdlCateErrInput)3112 .after($('<div></div>')3113 .text('â»å¿
é é
ç®ã§ã')3114 .addClass(Names.mdlCateErrPnl));3115 }3116 if (!cateId) {3117 $row.find(Names.mdlCateId.addDot())3118 .addClass(Names.mdlCateErrInput)3119 .after($('<div></div>')3120 .text('â»å¿
é é
ç®ã§ã')3121 .addClass(Names.mdlCateErrPnl));3122 }3123 // ãã¼ãã«ã®æå¾ã«è¿½å 3124 $cateTable.append($row);3125 // 追å ããè¡ã®ååã«ãã©ã¼ã«ã¹ã移å3126 $cateTable.find(Names.mdlCateName.addDot()).last().focus();3127 },3128 // ååã®ç¢ºèª3129 validateName: function(elm) {3130 // 空æåã®ç¢ºèª3131 if (ModalCate.validateEmpty(elm)) {3132 return;3133 }3134 // éè¤ãã§ãã¯3135 ModalCate.validateOverlap(Names.mdlCateName);3136 },3137 // idã®ç¢ºèª3138 validateId: function(elm) {3139 // 空æåã®ç¢ºèª3140 if (ModalCate.validateEmpty(elm)) {3141 return;3142 }3143 // å
¥åæå種ã®ãã§ãã¯3144 if ($(elm).val().match(/[^a-zA-Z0-9_-]+/)) {3145 $(elm).addClass(Names.mdlCateErrInput)3146 .after($('<div></div>')3147 .text('â»ä½¿ç¨ã§ããæåã¯è±æ°åã¨ãã¤ãã³ãã¢ã³ãã¼ã¹ã³ã¢ã®ã¿ã§ã')3148 .addClass(Names.mdlCateErrPnl));3149 return;3150 } else if ($(elm).val().match(/^[0-9_-]+/)) {3151 $(elm).addClass(Names.mdlCateErrInput)3152 .after($('<div></div>')3153 .text('â»æ°åã»è¨å·ããå§ã¾ããã®ã¯è¨å®ã§ãã¾ãã')3154 .addClass(Names.mdlCateErrPnl));3155 } else {3156 $(elm).removeClass(Names.mdlCateErrInput)3157 .next(Names.mdlCateErrPnl.addDot()).remove();3158 }3159 // éè¤ãã§ãã¯3160 ModalCate.validateOverlap(Names.mdlCateId);3161 },3162 // idã®ç¢ºèª3163 validateClass: function(elm) {3164 $(elm).removeClass(Names.mdlCateErrInput)3165 .parents('td').first().find(Names.mdlCateErrPnl.addDot()).remove();3166 if ($(elm).val().match(/^[0-9_-]+/)) {3167 $(elm).addClass(Names.mdlCateErrInput)3168 .after($('<div></div>')3169 .text('â»æ°åã»è¨å·ããå§ã¾ããã®ã¯è¨å®ã§ãã¾ãã')3170 .addClass(Names.mdlCateErrPnl));3171 }3172 },3173 // 空ç½ãã©ããã®ç¢ºèª3174 validateEmpty: function(elm) {3175 $(elm).removeClass(Names.mdlCateErrInput)3176 .parents('td').first().find(Names.mdlCateErrPnl.addDot()).remove();3177 if ($(elm).val()) {3178 return false;3179 } else {3180 $(elm).addClass(Names.mdlCateErrInput)3181 .after($('<div></div>')3182 .text('â»å¿
é é
ç®ã§ã')3183 .addClass(Names.mdlCateErrPnl));3184 return true;3185 }3186 },3187 // éè¤ãã§ãã¯3188 validateOverlap: function(col) {3189 var vals = [];3190 var overlaps = [];3191 var i, len;3192 // éè¤ã¨ã©ã¼ãä¸æ¦åæå3193 $(Names.mdlCateTable.addHash()).find(col.addDot()).each(function() {3194 $(this).removeClass(Names.mdlCateErrOverlap);3195 $(this).parents('td').first().find(Names.mdlCateErrOverlap.addDot()).remove();3196 if ($(this).parents('td').first().find(Names.mdlCateErrInput.addDot()).length === 0) {3197 $(this).removeClass(Names.mdlCateErrInput);3198 }3199 });32003201 // åã®å¤ãé
åã«ä¿å3202 $(Names.mdlCateTable.addHash()).find(col.addDot()).each(function() {3203 if ($.inArray($(this).val(), vals) === -1) {3204 vals.push($(this).val());3205 } else {3206 if ($.inArray($(this).val(), overlaps) === -1 && $(this).val() !== '') {3207 overlaps.push($(this).val());3208 }3209 }3210 });3211 for (i = 0, len = overlaps.length; i < len; i++) {3212 $(Names.mdlCateTable.addHash()).find(col.addDot()).each(function() {3213 if ($(this).val() === overlaps[i]) {3214 $(this).addClass(Names.mdlCateErrInput)3215 .addClass(Names.mdlCateErrOverlap)3216 .after(3217 $('<div></div>').text('â»å¤ãéè¤ãã¦ãã¾ã')3218 .addClass(Names.mdlCateErrPnl)3219 .addClass(Names.mdlCateErrOverlap)3220 );3221 }3222 });3223 }3224 },3225 // ãã¼ã¸å
ãªã³ã¯ã®ä½æ3226 createUl: function(pageName) {3227 var $ul = $('<ul></ul>').attr('id', 'inpage-links');3228 $(Names.cntBody.addDot()).first().find(Names.section.addDot()).each(function() {3229 var href = $(this).attr('id');3230 $ul.append(3231 $('<li></li>').append(3232 $('<a></a>').attr('href', href)3233 .text($(this).children('h3').text())3234 )3235 );3236 });3237 return $ul;3238 },3239 // ã«ãã´ãªã®è¡¨ã¸ã®åæ 3240 reflect: function() {3241 // ã¨ã©ã¼ã®åå¨ããå ´åã¯ä½ãããªã3242 if ($(Names.mdlCateTable.addHash()).find(Names.mdlCateErrInput.addDot()).length > 0) {3243 alert('ã¨ã©ã¼ãä¿®æ£ãã¦ãã ãã');3244 return false;3245 }3246 var hasDel = false;3247 var delElm = $(Names.mdlCateTable.addHash()).find('option:selected').each(function() {3248 if ($(this).attr('value') === '1') {3249 hasDel = true;3250 return true;3251 }3252 });32533254 if (hasDel) {3255 if (!confirm("åé¤é
ç®ãããã¾ãã\næ´æ°ãã¦ãããããã§ããï¼")) {3256 return false;3257 }3258 }32593260 // ãã¼ã¸å
ãªã³ã¯3261 var $ul = $('<ul></ul>').attr('id', 'inpage-links');32623263 // ããã«ã®å
¥ãæ¿ã3264 var newArr = [];3265 $(Names.mdlCateTable.addHash()).children('tr').each(function() {3266 if ($(this).find(Names.mdlCateEnable.addDot()).first().val() === '1') {3267 return true;3268 }3269 var nowval = $(this).find(Names.mdlCateId.addDot()).first().attr(Names.mdlCateNowId);3270 var $obj;3271 if (nowval) {3272 $obj = $(nowval.addHash()).clone();3273 } else {3274 $obj = $(ModalCate.sectionTmp);3275 $obj.find('thead').first().append($(DataTable.tHeadRowTmp));3276 $obj.find('tbody').first().append(DataTable.createNewRow());3277 }3278 var id = Names.mdlCateIdPre + $(this).find(Names.mdlCateId.addDot()).first().val();3279 var name = $(this).find(Names.mdlCateName.addDot()).first().val();3280 $obj.attr(Names.mdlCateNowId, Names.mdlCateIdPre + $(this).find(Names.mdlCateId.addDot()).first().val())3281 .attr('id', id)3282 // addClassã«ããªãã®ã¯ç¾å¨ã®ãã®ã¨ã®ç½®ãæããç®çã¨ãã¦ããçº3283 .attr('class', $(this).find(Names.mdlCateClass.addDot()).first().val())3284 .addClass(Names.section)3285 .children('h3').text(name);3286 newArr.push($obj);32873288 $ul.append(3289 $('<li></li>').append(3290 $('<a></a>').attr('href', '#' + id)3291 .text(name)3292 )3293 );3294 });32953296 // ä¸æ¦ãã¼ã¿ã空ã«ãã3297 $(Names.cntBodyDataWrap.addHash()).empty();3298 // ããã²ã¼ã·ã§ã³ã®æ¿å
¥3299 $(Names.cntBodyDataWrap.addHash()).first().append($ul);3300 // æ°è¦ã«æ¿å
¥3301 $.each(newArr, function(i, val) {3302 $(Names.cntBodyDataWrap.addHash()).append(val);3303 });3304 // ç·¨éãã©ã°ãã»ãã3305 isEdit = true;3306 // ãã¼ãã«é¸æã®æå¹å3307 DataTable.addSelectEvent();3308 // ã³ã³ãã³ãããã¯ã¹ã®ãã©ãã°ã¢ã³ãããããæå¹å3309 Cells.addSortableCol();3310 $(Names.mdlCate.addHash()).modal('hide');3311 }3312 };33133314 // ãååãä¸è¦§ãã¢ã¼ãã«ç¨3315 var ModalMenu = {3316 // 表示å¦ç3317 show: function() {3318 // ã¢ã¼ãã«è¡¨ç¤ºæã«é¸æãããªã¹ãã®ã¯ãªã¢ããã¿ã³ã®ç¡å¹åãè¡ã3319 ModalMenu.removeSelect();3320 $(Names.mdlMenuBtnShow.addHash()).addClass(Names.disabled);3321 },3322 // ãªã¹ããé¸æããæã®å¦ç3323 liSelect: function(elm) {3324 // ãªã¹ããã¯ãªãã¯ããéã«é¸æã¯ã©ã¹ã®ä»ä¸ã¨ãã¿ã³ã®æå¹åãè¡ã3325 ModalMenu.removeSelect();3326 $(elm).addClass(Names.selected);3327 $(Names.mdlMenuBtnShow.addHash()).removeClass(Names.disabled);3328 },3329 // é¸æããã¦ãããªã¹ãã®ã¯ãªã¢3330 removeSelect: function() {3331 // é¸æããã¦ãããªã¹ããã¯ãªã¢ãã3332 $(Names.mdlMenu.addHash()).find('li').removeClass(Names.selected);3333 },3334 // é¸æããã¦ãããã¼ã¸ã®åå¾3335 getPage: function(elm) {3336 var $modalMenu = $(Names.mdlMenu.addHash());3337 if (isEdit) {3338 if (!confirm("ç¾å¨è¡¨ç¤ºä¸ã®ãã¼ã¸ã¯ç·¨éããã¦ããããã§ãã\nç·¨éãä¿åããã«ãã¼ã¸ãåå¾ãã¾ããï¼")) {3339 $modalMenu.modal('hide');3340 return;3341 }3342 }3343 // é¸æããã¦ãããªã¹ãã®ãã¼ã¸ãåå¾ãã¦è¡¨ç¤ºãã3344 // var $menuSelect = $modalMenu.find('li' + Names.selected.addDot()).first();3345 var $menuSelect = $(elm);3346 var url = 'html/get/' + $menuSelect.attr(Names.dataMenuName);3347 $modalMenu.modal('hide');3348 Ajaxs.get(url);3349 }3350 };335133523353 // æ¬çªç¨ã®JSã¨åããããã¨ï¼3354 // BoxNamesãªãã¸ã§ã¯ããå¿ããã«ï¼3355 var phoneOther = {3356 // ââââå¹´ââæââæ¥[ããã»ã¾ã§]ã表示ããããã®ãã³ãã¬ã¼ã3357 tmp: '<div class="until-phone">' +3358 ' <span class="' + BoxNames.phoneOtherDateClass + '"></span>' +3359 ' <span>:</span>' +3360 ' <span class="' + BoxNames.phoneOtherNumberClass + '"></span>' +3361 '</div>',3362 set: function() {3363 // æ´æ°ã·ã¹ãã ç¨3364 // $(EditNames.panel.addHash() + '-preview').find('['+ BoxNames.phoneOtherDate +']')3365 //3366 // æ¬çªç¨3367 // $('['+ BoxNames.phoneOtherDate +']')3368 $(EditNames.panel.addHash() + '-preview').find('['+ BoxNames.phoneOtherDate +']').each(function() {3369 var date = $(this).attr(BoxNames.phoneOtherDate) || '1900-01-01';3370 var phoneState = $(this).attr(BoxNames.phoneOtherState);3371 var stateStr = phoneState === '1' ? 'ãã' : 'ã¾ã§';3372 var otherNum = $(this).attr(BoxNames.phoneOtherNumber);3373 var defaultNum = $(this).attr(BoxNames.phoneDefaultNumber);3374 var $boxPhoneNum = $(this).find(BoxNames.phoneNumber.addDot()).first();3375 $boxPhoneNum.empty();3376 $boxPhoneNum.append($('<em></em>').text(defaultNum));33773378 if (phoneOther.validDate(date) && otherNum) {3379 var checkDate = new Date(date);3380 var today = new Date();33813382 if (phoneState === '1') {3383 if (today >= checkDate) {3384 $boxPhoneNum.empty();3385 $boxPhoneNum.append($('<em></em>').text(otherNum));3386 } else {3387 phoneOther.setAfter(this, otherNum, stateStr, checkDate);3388 }3389 } else if (phoneState === '2') {3390 if (today <= checkDate) {3391 phoneOther.setAfter(this, otherNum, stateStr, checkDate);3392 }3393 }3394 }3395 });3396 },3397 setAfter: function(elm, phoneNumber, stateStr, checkDate) {3398 var $div = $(phoneOther.tmp);3399 var viewDate = checkDate.getFullYear() + 'å¹´' +3400 (checkDate.getMonth() + 1) + 'æ' +3401 checkDate.getDate() + 'æ¥' +3402 stateStr;3403 $div.find(BoxNames.phoneOtherDateClass.addDot()).first().text(viewDate);3404 $div.find(BoxNames.phoneOtherNumberClass.addDot()).first().text(phoneNumber);3405 $(elm).append($div);3406 },3407 validDate: function(date) {3408 var dateArr = date.split('-');3409 var y = parseInt(dateArr[0], 10) || 0;3410 var m = parseInt(dateArr[1], 10) || 0;3411 var d = parseInt(dateArr[2], 10) || 0;3412 var dt = new Date(y, m - 1, d);3413 return (dt.getFullYear() === y, dt.getMonth() === m, dt.getDate() === d);3414 }3415 };34163417 // åæåã®å®è¡3418 Init();
...
telnumber_bk20160616.js
Source:telnumber_bk20160616.js
...291 // ãã¬ãã¥ã¼ç»é¢ã®åæè¨å®292 Preview.load();293 // ã«ãã´ãªç·¨éã®ãã©ãã°ã¢ã³ãããããã®æå¹å294 $(Names.mdlCateTable.addHash()).sortable({295 handle: Names.mdlCateSort.addDot()296 });297298 // ãã¼ã¸é¸æç¨ã®ã¡ãã¥ã¼ãé¸æããæã®å¦ç299 $('.cnt h3').on('mouseenter', function() {300 $(this).next('ul').removeClass(Names.hidden).slideDown('fast');301 }).on('mouseleave', function() {302 $(this).next('ul').slideUp('fast');303 });304305 // åæ表示ã§ç¤¾å
ç¨ãåä»å
¨è¬ã表示ããããã«ãã306 Ajaxs.get('html/get/index');307 };308309310 // ã¤ãã³ã311 var Events = {312 // åæåæã«ç»é²ããã¤ãã³ã313 add: function() {314 /* ä¸é¨ã®ãã¿ã³ã®åºå® ----------------------------------------------- */315 var $head = $('.cnt-head').first();316 $(window).on('scroll', function() {317 if ($(window).scrollTop() > $('.site-header').first().outerHeight(true)) {318 $head.addClass(Names.fixed);319 } else {320 $head.removeClass(Names.fixed);321 }322 });323324325 /* 表ã®ã¤ãã³ã ----------------------------------------------------- */326 // ããã¼327 var hovers =[328 Names.tblWrap.addDot() + ' tbody tr',329 Names.tblWrap.addDot() + ' tbody th',330 Names.tblWrap.addDot() + ' tbody td'331 ];332 // è¡ã»ã»ã«ã®ããã¼æã«ããã¼ã¯ã©ã¹ã®ä»ä¸333 $(document).on('mouseenter', hovers.join(','), function (e) {334 $(this).addClass(Names.hover);335 }).on('mouseleave', hovers.join(','), function () {336 $(this).removeClass(Names.hover);337 });338 // è¡ã®ããã¼æã«æ ç·ã表示339 // $(document).on('mouseenter', Names.tblWrap.addDot() + ' tbody tr', function () {340 // DataTable.hoverRow(this);341 // });342 // ã»ã«ã®ããã¼æã«è¿½å ãã¿ã³ã表示343 hovers.shift();344 $(document).on('mouseenter.hover', hovers.join(','), function () {345 Cells.addAddBoxBtn(this);346 }).on('mouseleave.hover', hovers.join(','), function () {347 Cells.removeAddBoxBtn();348 });349 // ã»ã«å
ã³ã³ãã³ãã®è¿½å ãã¿ã³ãæ¼ããæã®å¦ç350 $(document).on('click', Names.btnAddBox.addHash(), function() {351 Cells.addBox(this);352 });353354355 /* ã»ã«å
ã³ã³ãã³ãã§ã®å¦ç ---------------------------------------------*/356 // ã»ã«å
ã³ã³ãã³ãã®ãã©ãã°ã¢ã³ãããããå¦ç357 Events.addCellHovers();358 // ã»ã«å
ã®ã³ã³ãã³ããããã¯ç¨ã®ã¤ãã³ã359 Events.addContentsBlock();360361362 /* theadã§ã®å¦ç ---------------------------------------------------*/363 $(document).on('mouseenter', Names.tblWrap.addDot() + 'thead th', function() {364 $(this).append($(Names.btnsPanelThead.addHash()).removeClass(Names.hidden));365 }).on('mouseleave', 'thead th', function() {366 $('body').append($(Names.btnsPanelThead.addHash()).addClass(Names.hidden));367 });368 // ç·¨éãã¿ã³ãæ¼ããæã®å¦ç369 $(Names.btnEditThead.addHash()).on('click', function() {370 Cells.editThead($(this).parents('th').first());371 $('body').append($(Names.btnsPanelThead.addHash()).addClass(Names.hidden));372 });373 // theadã®thãããã«ã¯ãªãã¯ããæã®å¦ç374 $(document).on('dblclick', 'thead th', function() {375 Cells.editThead(this);376 });377 // theadã®thã®ç·¨éããã«ã§åæ ãããã¿ã³ãæ¼ããæã®å¦ç378 $(Names.headEdit.addHash() + '-reflection').on('click', function() {379 Cells.updateThead(this);380 });381 // theadã®thã®ç·¨éããã«ã§ãã£ã³ã»ã«ãã¿ã³ãæ¼ããæã®å¦ç382 $(Names.headEdit.addHash() + '-cancel').on('click', function() {383 Cells.cancelThead(this);384 });385 // ç·¨éããã«ä¸ã®ã¯ãªãã¯ã®æã¯ä½ãããªã386 $(Names.headEdit.addHash()).on('click', function() {387 return false;388 });389 // theadç·¨éããã«ã®ã©ãããã¯ãªãã¯ããæã«éãã390 $(Names.headEdit.addHash() + '-wrap').on('click', function() {391 Cells.cancelThead(this);392 });393394395 /* tfootã§ã®å¦ç ---------------------------------------------------*/396 // tfootã®ã»ã«ãããã«ã¯ãªãã¯ããæã®å¦ç397 Events.addTfoot();398 // tfootãããã©ã¼ã«ã¹ãå¤ããã¨ãã®å¦ç399 $(document).on('blur', 'tfoot textarea', function() {400 Cells.updateTfoot(this);401 });402403404 /* ã»ã«å
ã³ã³ãã³ãã®ç·¨éããã« -------------------------------------------------- */405 // ã»ã«å
ã³ã³ãã³ãç·¨éããã«ãéããæã®å¦ç406 $(EditNames.panel.addHash()).on('hidden.bs.modal', function(e) {407 EditPanel.hide(e);408 });409 // ã»ã«å
ã³ã³ãã³ãã®ç·¨éããã«å
ã®ããã¹ãã¨ãªã¢ãWYSIWYGã¨ãã£ã¿ã«å¤æ410 EditPanel.setWyswyg();411 // ã»ã«å
ã³ã³ãã³ãã®ç·¨éããã«å
ã®ã¤ãã³ã412 Events.addModalEdit();413414415 /* ã³ã³ããã¹ãã¡ãã¥ã¼ ------------------------------------------------- */416 // 表示417 $(document).on('contextmenu', Names.tblWrap.addDot() + ' tbody', function (e) {418 Context.show(this, e);419 // æ¨æºã®ã³ã³ããã¹ãã¡ãã¥ã¼ã®ãã£ã³ã»ã«420 return false;421 });422 // é表示423 $(document).on('click', Names.ctm.addHash(), function () {424 $('tbody').find(Names.hover.addDot()).removeClass(Names.hover);425 $('tbody').find(Names.ctmHover.addDot()).removeClass(Names.ctmHover);426 $('tbody').find(Names.uiSelected.addDot() + Names.hidden.addDot()).removeClass(Names.uiSelected);427 Context.hide(this);428 }).on('contextmenu', Names.ctm.addHash(), function() {429 $(this).trigger('click');430 return false;431 });432 // ã³ã³ããã¹ãã¡ãã¥ã¼å
ã®ã¤ãã³ããç»é²433 Events.addContext();434435436 /* ã«ãã´ãªã®ç·¨éé¢ä¿ã¤ãã³ã ------------------------------------------- */437 // ã«ãã´ãªç·¨éç¨ã¢ã¼ãã«è¡¨ç¤ºæã®å¦ç438 $(Names.mdlCate.addHash()).on('show.bs.modal', function(e) {439 ModalCate.show(this);440 });441 // ã«ãã´ãªç·¨éç¨ã¢ã¼ãã«å
ã®ã¤ãã³ã442 Events.addModalCategory();443444445 /* ååãå
ä¸è¦§é¢ä¿ã¤ãã³ã ------------------------------------------- */446 // ååãå
ä¸è¦§ç¨ã¢ã¼ãã«è¡¨ç¤ºæã®å¦ç447 // $(Names.mdlMenu.addHash()).on('show.bs.modal', function(e) {448 // ModalMenu.show($(this).find('table').first());449 // });450 // ååãä¸è¦§é¸æç¨ã¢ã¼ãã«ç»é¢å
ã®ã¤ãã³ã451 Events.addModalMenu();452453 $('.title').on('mouseenter', function() {454 $(this).children('ul').stop().slideDown();455 }).on('mouseleave', function() {456 $(this).children('ul').stop().slideUp();457 });458459460 /* ãã¬ãã¥ã¼ç»é¢ã§ã®ã¤ãã³ã ------------------------------------------- */461 // éãããã¿ã³ãæ¼ããæã®å¦ç462 $(Names.btnCancel.addHash()).on('click', function() {463 Preview.hide();464 });465 // æ¬çªç°å¢ã«å
¬éãããã¿ã³ãæ¼ããæã®å¦ç466 $(Names.btnPublishing.addHash()).on('click', function() {467 Contents.publishing();468 });469470471 /* ãä¸æ¸ãä¿åããããã¿ã³ã¤ãã³ã ---------------------------------------------- */472 $(Names.btnSave.addHash()).on('click', function() {473 Contents.save();474 });475476 /* ããã¬ãã¥ã¼ããã¿ã³ã¤ãã³ã --- ------------------------------------------- */477 $(Names.btnPreview.addHash()).on('click', function() {478 Preview.show();479 });480 },481 // tfootã¨ãªã¢ã®ã¤ãã³ã482 addTfoot: function() {483 $(document).on('dblclick', 'tfoot td', function() {484 Cells.editTfoot(this);485 });486 },487 removeTfoot: function() {488 $(document).off('dblclick', 'tfoot td');489 },490 // ã³ã³ããã¹ãã¡ãã¥ã¼å
ã®ã¤ãã³ã491 addContext: function() {492 // ã³ã³ããã¹ãã®è¡ã®ä¸ã¸ç§»å493 $(Names.ctmMoveUp.addHash()).on('click', function () {494 if ($(this).hasClass(Names.disabled)) {495 return false;496 }497 DataTable.moveUpRow();498 }).on('mouseenter', function () {499 if (!$(this).hasClass(Names.disabled)) {500 DataTable.hoverUpRow();501 }502 }).on('mouseleave', function () {503 // ã»ãã¬ã¼ã¿ã¨èæ¯ãé表示504 $(Names.showMoveRow.addDot()).removeClass(Names.showMoveRow);505 $(Names.rowSeparator.addHash()).hide();506 });507 // ã³ã³ããã¹ãã®è¡ã®ä¸ã¸ç§»å508 $(Names.ctmMoveDown.addHash()).on('click', function () {509 if ($(this).hasClass(Names.disabled)) {510 return false;511 }512 DataTable.moveDownRow();513 }).on('mouseenter', function () {514 if (!$(this).hasClass(Names.disabled)) {515 DataTable.hoverDownRow();516 }517 }).on('mouseleave', function () {518 // ã»ãã¬ã¼ã¿ã¨èæ¯ãé表示519 $(Names.showMoveRow.addDot()).removeClass(Names.showMoveRow);520 $(Names.rowSeparator.addHash()).hide();521 });522 // ã³ã³ããã¹ãã®ã»ã«ã®çµåã¤ãã³ã523 $(Names.ctmJoinCell.addHash()).on('click', function () {524 if ($(this).hasClass(Names.disabled)) {525 return false;526 }527 DataTable.joinCell();528 });529 // ã³ã³ããã¹ãã®ã»ã«ã®åå²ã¤ãã³ã530 $(Names.ctmSplitCell.addHash()).on('click', function () {531 if ($(this).hasClass(Names.disabled)) {532 return false;533 }534 DataTable.splitCell();535 });536 // ã³ã³ããã¹ãã®ã»ã«ã®ååå²ã¤ãã³ã537 $(Names.ctmSplitCol.addHash()).on('click', function () {538 if ($(this).hasClass(Names.disabled)) {539 return false;540 }541 DataTable.splitCol();542 });543 // ã³ã³ããã¹ãã®è¡ã®è¿½å ã¤ãã³ã544 $(Names.ctmAddRow.addHash()).on('click', function () {545 if ($(this).hasClass(Names.disabled)) {546 return false;547 }548 DataTable.addRow(this);549 }).on('mouseenter', function () {550 if (!$(this).hasClass(Names.disabled)) {551 DataTable.hoverAddRow();552 }553 }).on('mouseleave', function () {554 $(Names.rowSeparator.addHash()).hide();555 });556 // ã³ã³ããã¹ãã®è¡ã®åé¤ã¤ãã³ã557 $(Names.ctmDelRow.addHash()).on('click', function () {558 if ($(this).hasClass(Names.disabled)) {559 return false;560 }561 DataTable.delRow(this);562 }).on('mouseenter', function () {563 DataTable.hoverDelRow();564 }).on('mouseleave', function () {565 $(Names.showDelRow.addDot()).removeClass(Names.showDelRow);566 });567 // 2å表示568 $(Names.ctmTitle2Col.addHash()).on('click', function () {569 if ($(this).hasClass(Names.disabled)) {570 return false;571 }572 DataTable.show2Col();573 });574 // 3å表示575 $(Names.ctmTitle3Col.addHash()).on('click', function () {576 if ($(this).hasClass(Names.disabled)) {577 return false;578 }579 DataTable.show3Col();580 });581 // ããã¿ã¼è¡ã®è¿½å 582 $(Names.ctmAddTfoot.addHash()).on('click', function () {583 if ($(this).hasClass(Names.disabled)) {584 return false;585 }586 DataTable.addTfoot();587 });588 // ããã¿ã¼è¡ã®åé¤589 $(Names.ctmDelTfoot.addHash()).on('click', function () {590 if ($(this).hasClass(Names.disabled)) {591 return false;592 }593 DataTable.removeTfoot();594 });595 },596 // ã»ã«å
ã®ã³ã³ãã³ããããã¯ç¨ã®ã¤ãã³ã597 addContentsBlock: function() {598 // ã»ã«å
ã³ã³ãã³ãã®åé¤ãã¿ã³ãæ¼ããæã®å¦ç599 $(document).on('click', Names.btnDelBox.addHash(), function() {600 var $parentBox = $(this).parents(BoxNames.wrap.addDot()).first();601 if (confirm("åé¤ããã¨å
ã«æ»ãã¾ããã\nåé¤ãã¾ããï¼")) {602 Cells.removeBox($parentBox);603 }604 });605 // ã»ã«å
ã³ã³ãã³ãã®ç·¨éç»é¢è¡¨ç¤ºã®éã®å¦ç606 $(document).on('click', Names.btnEditBox.addHash(), function() {607 EditPanel.show(this);608 }).on('dblclick', BoxNames.wrap.addDot(), function() {609 // ã»ã«å
ã³ã³ãã³ããããã«ã¯ãªãã¯ããæã®å¦ç610 EditPanel.show($(this).children().first());611 });612 },613 // ã»ã«ã®ãããã¯ç·¨éç¨ã¢ã¼ãã«ç»é¢å
ã®ã¤ãã³ã614 addModalEdit: function() {615 // ã»ã«å
ã³ã³ãã³ãã®å
容ãæ´æ°ããæã®å¦ç616 $(document).on('click', EditNames.btnUpdate.addHash(), function() {617 EditPanel.update();618 });619 $(document).on('click', EditNames.btnCancel.addHash(), function() {620 var $editBox = $(EditNames.panel.addHash()).data(Names.dataTargetElm);621 if ($(EditNames.panel.addHash()).data('addState')) {622 $editBox.remove();623 }624 });625 // ç·¨éããã«ã®å¤ãå¤ãã£ãæã®å¦ç626 var changes =[627 EditNames.panel.addHash() + ' input',628 EditNames.panel.addHash() + ' textarea',629 EditNames.panel.addHash() + ' select',630 ];631 $(document).on('change enter.imeEnter', changes.join(','), function() {632 EditPanel.setVal(this);633 });634 // é»è©±çªå·ã®è¿½å 635 $(document).on('click', EditNames.btnPhoneAdd.addHash(), function () {636 EditPanel.addPhone(this);637 });638 // é»è©±çªå·ã®åé¤639 $(document).on('click', EditNames.btnPhoneDel.addDot(), function () {640 EditPanel.delPhone(this);641 });642 // ã¡ã¼ã«ã¢ãã¬ã¹ã®è¿½å 643 $(document).on('click', EditNames.btnMailAdd.addHash(), function () {644 EditPanel.addMail(this);645 });646 // ã¡ã¼ã«ã¢ãã¬ã¹ã®åé¤647 $(document).on('click', EditNames.btnMailDel.addDot(), function () {648 EditPanel.delMail(this);649 });650 // ããã¹ãã¨ãªã¢ã®èª¬ææã®éé651 $(document).on('click', '.edit-note-title', function() {652 $(this).next('.edit-note-wrap').slideToggle('fast');653 });654 // fieldsetã®éé655 $(document).on('click', '.edit-section-title', function() {656 if ($(this).hasClass('close')) {657 $(this).removeClass('close');658 } else {659 $(this).addClass('close');660 }661 $(this).next('fieldset').slideToggle('fast');662 });663664 //æåãé¸æããã¦ãããå¤æ665 var checkSelectionText = function () {666 return getSelection().toString().length > 0;667 };668 var getSelection = function () {669 if (window.getSelection) {670 return window.getSelection();671 } else if (document.getSelection) {672 return document.getSelection();673 } else if (document.selection) {674 return document.selection;675 }676 };677 // å°æåãã¿ã³678 $(document).on('click', '.small', function () {679 if (checkSelectionText()) {680 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()681 .find(EditNames.editBox.addDot() + '-editbox').first();682 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()683 .find(EditNames.editBox.addDot()).first();684 $inputArea.focus();685686 var selection = getSelection();687 var range = selection.getRangeAt(0);688 var font = document.createElement('font');689 font.style.fontSize = 'smaller';690 range.surroundContents(font);691692 $textArea.val($inputArea.html()).trigger('input');693 }694 });695 // 赤åãã¿ã³696 $(document).on('click', '.red', function () {697 if (checkSelectionText()) {698 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()699 .find(EditNames.editBox.addDot() + '-editbox').first();700 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()701 .find(EditNames.editBox.addDot()).first();702 $inputArea.focus();703704 var selection = getSelection();705 var range = selection.getRangeAt(0);706 var font = document.createElement('font');707 font.style.color = 'rgb(204,0,0)';708 range.surroundContents(font);709710 $textArea.val($inputArea.html()).trigger('input');711 }712 });713 // 太åãã¿ã³714 $(document).on('click', '.bold', function () {715 if (checkSelectionText()) {716 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()717 .find(EditNames.editBox.addDot() + '-editbox').first();718 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()719 .find(EditNames.editBox.addDot()).first();720 $inputArea.focus();721722 var selection = getSelection();723 var range = selection.getRangeAt(0);724 var font = document.createElement('font');725 font.style.fontWeight = 'bold';726 range.surroundContents(font);727728 $textArea.val($inputArea.html()).trigger('input');729 }730 });731 var rng;732 // ãªã³ã¯ãã¿ã³733 $(document).on('click', '.link', function () {734 // if (checkSelectionText()) {735 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()736 .find(EditNames.editBox.addDot() + '-editbox').first();737 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()738 .find(EditNames.editBox.addDot()).first();739 $inputArea.focus();740741 var selection = getSelection();742 rng = selection.getRangeAt(0);743744 var $inputPanel = $(this).parents(EditNames.editBox.addDot() + '-wrap').first().find('.edit-link').first();745 $inputPanel.data('state', 'link');746 $inputPanel.find('.edit-link-blank-label').first().show();747 $inputPanel.find('.edit-link-blank').first().prop('checked', false);748 $(this).parent().append($('#modal-back'));749 $('#modal-back').show();750 $inputPanel.show();751 $inputPanel.find('input').first().val('').focus();752 // }753 });754 // ã¡ã¼ã«æ¿å
¥ãã¿ã³755 $(document).on('click', '.mail', function () {756 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()757 .find(EditNames.editBox.addDot() + '-editbox').first();758 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()759 .find(EditNames.editBox.addDot()).first();760 $inputArea.focus();761762 var selection = getSelection();763 rng = selection.getRangeAt(0);764765 var $inputPanel = $(this).parents(EditNames.editBox.addDot() + '-wrap').first().find('.edit-link').first();766 $inputPanel.data('state', 'mail');767 $inputPanel.find('.edit-link-blank-label').first().hide();768 $(this).parent().append($('#modal-back'));769 $('#modal-back').show();770 $inputPanel.show();771 $inputPanel.find('input').first().val('').focus();772 });773 // ãªã³ã¯æ¿å
¥ããã«æ´æ°774 $(document).on('click', '.edit-link-submit', function() {775 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()776 .find(EditNames.editBox.addDot() + '-editbox').first();777 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()778 .find(EditNames.editBox.addDot()).first();779 var $inputPanel = $(this).parents('.edit-link').first();780 var val = $(this).parents('div').first().find('input').first().val();781782 if (val !== '') {783 var a = document.createElement('a');784 var hrefVal = $inputPanel.data('state') === 'link' ? val : 'mailto:' + val;785 a.setAttribute('href', hrefVal);786 if ($inputPanel.find('.edit-link-blank').first().prop('checked')) {787 a.setAttribute('target', '_blank');788 }789 $inputArea.focus();790 if (rng.collapsed) {791 a.innerHTML = val;792 rng.insertNode(a);793 } else {794 try {795 rng.surroundContents(a);796 } catch(e) {797 alert('åãç¯å²ã«ãã§ã«ãªã³ã¯ãæ¿å
¥ããã¦ãã¾ã');798 }799 }800801 $textArea.val($inputArea.html()).trigger('input');802 }803804 $('body').append($('#modal-back'));805 $('#modal-back').hide();806 $(this).parents('.edit-link').first().hide();807 });808 // ãªã³ã¯æ¿å
¥ããã«ãã£ã³ã»ã«809 $(document).on('click', '.edit-link-cancel', function() {810 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()811 .find(EditNames.editBox.addDot() + '-editbox').first();812813 $('body').append($('#modal-back'));814 $('#modal-back').hide();815 $(this).parents('.edit-link').first().hide();816 });817 // èæ¯ãã¯ãªãã¯ããæã«ãªã³ã¯æ¿å
¥ããã«ãéãã818 $('#modal-back').on('click', function() {819 $('body').append($('#modal-back'));820 $('#modal-back').hide();821 $('.edit-link').hide();822 });823 // ã¢ã³ã»ãããã¿ã³824 $(document).on('click', '.reset', function () {825 if (checkSelectionText()) {826 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()827 .find(EditNames.editBox.addDot() + '-editbox').first();828 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()829 .find(EditNames.editBox.addDot()).first();830 $inputArea.focus();831 document.execCommand('removeformat');832 document.execCommand('unlink');833834 $textArea.val($inputArea.html()).trigger('input');835 }836 });837 // ã½ã¼ã¹ã®è¡¨ç¤ºãã¿ã³838 $(document).on('click', '.source', function () {839 var $inputArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()840 .find(EditNames.editBox.addDot() + '-editbox').first();841 var $textArea = $(this).parents(EditNames.editBox.addDot() + '-wrap').first()842 .find(EditNames.editBox.addDot()).first();843 if ($inputArea.is(':visible')) {844 $(this).parent().children('button').each(function() {845 if (!$(this).hasClass('source')) {846 $(this).addClass('hidden');847 }848 });849 $inputArea.hide();850 $textArea.show().focus();851 $(this).text('ç·¨éã¨ãªã¢ã®è¡¨ç¤º');852 } else {853 $(this).parent().children('button').each(function() {854 if (!$(this).hasClass('source')) {855 $(this).removeClass('hidden');856 }857 });858 var val = $textArea.val();859 // scriptã¨ããæåãåé¤860 val = val.replace(/(<\/?)script/gi, "$1span");861 $textArea.val(val);862 $inputArea.html(val);863 $textArea.hide();864 $inputArea.show().focus();865 $(this).text('ã½ã¼ã¹ã®è¡¨ç¤º');866 }867 });868 },869 // ã«ãã´ãªç·¨éã¢ã¼ãã«å
ã®ã¤ãã³ã870 addModalCategory: function() {871 // ã«ãã´ãªã¼ç·¨éã¢ã¼ãã«ã®è¡ã®ã表示ããåé¤ãã®å¤ãå¤ãã£ãæã®å¦ç872 $(document).on('change', Names.mdlCateEnable.addDot(), function() {873 ModalCate.changeCateEnable(this);874 });875876 // ã«ãã´ãªã®è¿½å ãã¿ã³ãæ¼ããæã®å¦ç877 $(Names.mdlCateBtnAdd.addHash()).on('click', function() {878 ModalCate.addRow();879 });880881 // ã«ãã´ãªã®åæ ãããã¿ã³ãæ¼ããæã®å¦ç882 $(Names.mdlCateBtnRef.addHash()).on('click', function() {883 ModalCate.reflect();884 });885886 // ã«ãã´ãªã®ååã®ããªãã¼ã·ã§ã³å¦ç887 $(document).on('change', Names.mdlCateName.addDot(), function() {888 ModalCate.validateName(this);889 });890891 // ã«ãã´ãªã®idã®ããªãã¼ã·ã§ã³å¦ç892 $(document).on('change', Names.mdlCateId.addDot(), function() {893 ModalCate.validateId(this);894 });895896 // ã«ãã´ãªã®classã®ããªãã¼ã·ã§ã³å¦ç897 $(document).on('change', Names.mdlCateClass.addDot(), function() {898 ModalCate.validateClass(this);899 });900901 // ç·¨éããã«ã®ãã©ãã°å¦ç902 var $modal = $(EditNames.panel.addHash());903 var $dragElm = $modal.find(".modal-header").first();904 var $moveElm = $modal.find(".modal-content").first();905 var moveFlag;906 var offsetTop;907 var offsetLeft;908 // ãã©ãã°ã¯ã©ã¹ã®ä»ä¸909 $dragElm.addClass(Names.drag);910 // ãã¦ã¹ãã¦ã³ããæã«åº§æ¨ãåå¾911 $dragElm.on("mousedown", function (event) {912 moveFlag = true;913 event = (event) || window.event;914 offsetTop = event.clientY - $moveElm.offset().top;915 offsetLeft = event.clientX - $moveElm.offset().left;916 });917 // ãã¦ã¹ã¢ããããæã«ç§»åãã©ã°ãç¡å¹ã«ãã918 $(document).on("mouseup", function () {919 moveFlag = false;920 });921 // ãã¦ã¹ãåããæã«ç§»åãã922 $(document).on("mousemove", function (event) {923 event = (event) || window.event;924 if (moveFlag) {925 $moveElm.offset({926 top: event.clientY - offsetTop,927 left: event.clientX - offsetLeft928 });929 }930 });931 },932 // ååãä¸è¦§ãã¼ã¸ã®é¸æç¨ã¢ã¼ãã«å
ã®ã¤ãã³ã933 addModalMenu: function() {934 // ååãä¸è¦§ã®ãªã¹ããé¸æããæã®å¦ç935 // $(document).on('click', Names.mdlMenu.addHash() + ' li', function() {936 // ModalMenu.liSelect(this);937 // });938 $(document).on('click', Names.mdlMenu.addHash() + ' .title li', function() {939 ModalMenu.liSelect(this);940 ModalMenu.getPage(this);941 });942943 // é¸æãããã¼ã¸ã表示ãããã¿ã³ãæ¼ããæã®å¦ç944 // $(Names.mdlMenuBtnShow.addHash()).on('click', function() {945 // ModalMenu.getPage();946 // });947 },948 /* ã»ã«å
ã³ã³ãã³ãã®ãã©ãã°ã¢ã³ãããããæã®ã¤ãã³ã -------------------------------- */949 // ã¤ãã³ãã®è¿½å 950 addCellHovers: function() {951 // ç·¨éç¨ãã¼ã¸ã表示ããã¦ããã¨ãã¯selectableãæå¹ã«ãã952 if ($(Names.cntBody.addDot()).first().find('table').length > 0) {953 $('tbody').selectable('enable');954 }955 // ã»ã«å
ã³ã³ãã³ãã«ããã¼ããéã«ç§»åãã¼ãæ¿å
¥956 $(document).on('mouseenter', BoxNames.wrap.addDot(), function () {957 $('tbody').selectable('disable');958 if (!isSorting) {959 // 移åãã¼ã®æ¿å
¥960 Cells.addMoveBox(this);961 // ããã¼ã¯ã©ã¹ã®ä»ä¸962 $(this).parents('tbody').first().find(Names.ctmHover.addDot()).removeClass(Names.ctmHover);963 $(this).addClass(Names.hover);964 // ãã©ãã°ã¢ã³ãããããã®æå¹å965 Cells.enableSortableCol(this);966 }967 }).on('mouseleave', BoxNames.wrap.addDot(), function () {968 $('tbody').selectable('enable');969 if (!isSorting) {970 // 移åãã¼ã®åé¤971 Cells.removeMoveBox();972 // ããã¼ã¯ã©ã¹ã®åé¤973 $(this).removeClass(Names.hover);974 // ãã©ãã°ã¢ã³ãããããã®ç¡å¹å975 Cells.disableSortableCol(this);976 }977 });978 },979 // ã¤ãã³ãã®åé¤980 removeCellHovers: function(colClasses) {981 // ãã¼ãã«ã»ã«ã®é¸æãç¡å¹å982 $('tbody').selectable('disable');983 // ã»ã«å
ã®ããã¯ã¹ãããã¼ãããæã®ã¤ãã³ããç¡å¹å984 $(document).off('mouseenter.hover', BoxNames.wrap.addDot());985 }986 };987988989 // ajaxã®åæå¤990 $.ajaxSetup({991 'type' : 'GET',992 'dataType': 'json',993 'cache': false,994 'headers': {995 'Pragma': 'no-cache'996 }997 });998 // ajaxå¦ç999 var Ajaxs = {1000 get: function(url) {1001 Loading.show();1002 $.ajax({1003 url: url,1004 }).done(function(res) {1005 // ã³ã³ãã³ãã®ã¯ãªã¢1006 Contents.clearBody();1007 // ã¡ãã»ã¼ã¸ã®ããå ´åã¯ãã¤ã¢ãã°ã表示1008 if (res.message) {1009 alert(res.message);1010 }1011 // åãåã£ãã¹ãã¼ã¿ã¹ã«ããç»åã®è¡¨ç¤ºã»é表示1012 if (res.state == 200) {1013 ImgInduction.hide();1014 TopButtons.show();1015 } else {1016 ImgInduction.show();1017 TopButtons.hide();1018 return;1019 }1020 // ã³ã³ãã³ãã®ã»ãã1021 Contents.setBody(res.Data);1022 // ç·¨éãã©ã°ã®ãªã»ãã1023 isEdit = false;1024 }).always(function() {1025 // ãã¼ãã£ã³ã°ã®é表示1026 Loading.hide();1027 });1028 },1029 update: function(url, data) {1030 Loading.show();1031 $.ajax({1032 url: url,1033 type: 'POST',1034 data: data1035 }).done(function(res) {1036 // ã¨ã©ã¼ã®æã¯ã¡ãã»ã¼ã¸ã表示ãã¦çµäºãã1037 if (res.state == 404) {1038 alert(res.message);1039 return;1040 }1041 // ã³ã³ãã³ãã®ã¯ãªã¢1042 Contents.clearBody();1043 // ã³ã³ãã³ãã®åã»ãã1044 Contents.setBody(res.Data, true);1045 // ç·¨éãã©ã°ã®ãªã»ãã1046 isEdit = false;1047 }).always(function() {1048 // ãã¼ãã£ã³ã°ã®é表示1049 Loading.hide();1050 });1051 }1052 };10531054 // ãã¼ãã£ã³ã°1055 var Loading = {1056 // ãã¼ãã£ã³ã°ç»é¢ã®è¡¨ç¤º1057 show: function() {1058 $(Names.mdlLoading.addHash()).removeClass(Names.hidden);1059 },1060 // ãã¼ãã£ã³ã°ç»é¢ã®é表示1061 hide: function() {1062 $(Names.mdlLoading.addHash()).addClass(Names.hidden);1063 }1064 };10651066 // ç»é¢ä¸é¨ã®ãã¿ã³ç¾¤1067 var TopButtons = {1068 // ãã¿ã³ãæå¹å1069 show: function() {1070 $(Names.cntHeadBtns.addHash()).children('button').removeClass(Names.disabled);1071 },1072 // ãã¿ã³ãç¡å¹å1073 hide: function() {1074 $(Names.cntHeadBtns.addHash()).children('button').addClass(Names.disabled);1075 }1076 };10771078 // èªå°ç¨ç»åã®è¡¨ç¤ºã»é表示1079 var ImgInduction ={1080 // èªå°ç¨ç»åã®ãã³ãã¬ã¼ãï¼å®éã«ã¯indexããåå¾ããçºç©ºæåã§OKï¼1081 tmp: '<img id="' + Names.cntBodyEmptyImg + '" src="img/page-select.png">',1082 // indexããèªå°ç»åã¨ã¬ã¡ã³ããã¯ãã¼ã³ãã1083 copy: function() {1084 ImgInduction.tmp = $(Names.cntBodyEmptyImg.addHash()).clone();1085 },1086 // èªå°ç»åã®è¡¨ç¤º1087 show: function() {1088 $(Names.cntBody.addDot()).first().append($(ImgInduction.tmp));1089 },1090 // èªå°ç»åã®é表示1091 hide: function() {1092 $(Names.cntBody.addDot()).find(Names.cntBodyEmptyImg.addHash()).remove();1093 }1094 };10951096 var Contents = {1097 // 表示ãã¦ããã³ã³ãã³ãã®ã¯ãªã¢1098 clearBody: function() {1099 $(Names.cntBody.addDot()).empty();1100 },1101 // ã³ã³ãã³ãã®åã»ãã1102 setBody: function(Data, showSuccess) {1103 $(window).scrollTop(0);1104 // ãã¼ãã«ãã¼ã¿ãæ¿å
¥1105 var $wrap = $('<div></div>').attr('id', Names.cntBodyDataWrap);1106 $wrap.append($(Data.html));1107 $(Names.cntBody.addDot()).first().append($wrap);1108 // ã»ã¬ã¯ã¿ãã«ã®è¨å®1109 DataTable.addSelectEvent();1110 // ã³ã³ãã³ãããã¯ã¹ã®ãã©ãã°ã¢ã³ãããããæå¹å1111 Cells.addSortableCol();1112 // ã¿ã¤ãã«ãæ¿å
¥1113 var title = Data.in_ex == 1 ? '社å
ç¨ã' : 'ã客ãã¾ç¨ã';1114 var dates = '<div class="date-update"><span>ä¸æ¸ãä¿åæ¥æ</span>ï¼' + (Data.updated !== '0000-00-00 00:00:00' ? Data.updated : 'æªä¿å') + '</div>';1115 dates += '<div class="date-release"><span>æçµæ´æ°æ¥æ</span>ï¼' + (Data.released !== '0000-00-00 00:00:00' ? Data.released : 'æªå
¬é') + '</div>';1116 title += Data.title;1117 $(Names.cntBody.addDot()).first()1118 .prepend(1119 $('<div class="note"></div>').text('â»ã»ã«ã®çµåãè¡ã®è¿½å ã移åçã®æä½ã¯ããã¼ãã«ä¸ã§å³ã¯ãªãã¯ã§è¡¨ç¤ºãããã¡ãã¥ã¼ããè¡ã£ã¦ãã ããã')1120 )1121 .prepend(1122 $('<div class="dates"></div>').append($(dates))1123 )1124 .prepend(1125 $('<h2></h2>').text(title)1126 .addClass('h2-default')1127 .append(1128 $('<span></span>').text(Data.name)1129 .attr('id', Names.cntName)1130 .data(Names.dataUpdate, Data.updated)1131 )1132 );1133 // å
¬éãã¦ããªãå ´åã¯ã¢ã©ã¼ãããã«ã表示1134 if (Data.is_release === '0') {1135 $(Names.cntBody.addDot()).first().prepend(1136 $('<div></div>').text('å
¬éããã¦ãã¾ãã').addClass(Names.cntBodyPnlAlert)1137 );1138 $(Names.cntBody.addDot()).first().find('.date-release').first().addClass('alert');1139 } else {1140 // å
¬éããã¦ããå ´åã¯å
¬éæ¸ã¿ãã¼ã¸ã¸ã®ãªã³ã¯ã表示1141 var $h2 = $(Names.cntBody.addDot()).first().find('.h2-default').first();1142 $h2.append(1143 $('<a></a>').addClass('pull-right')1144 .addClass('now-page')1145 .attr('href', $('body').data('href') + '/telnumber/' + Data.name)1146 .attr('target', '_blank')1147 .text('æ¬çªãã¼ã¸ãè¦ã')1148 ).append(1149 $('<a></a>').addClass('pull-right')1150 .addClass('now-page')1151 .addClass('now-page')1152 .attr('href', $('body').data('href') + '/staging/bbnavi/telnumber/' + Data.name)1153 .attr('target', '_blank')1154 .text('Stagingãã¼ã¸ãè¦ã')1155 );1156 // ä¸æä¿åå¾å
¬éããã¦ããªãå ´åã¯ã¢ã©ã¼ãã表示1157 if (Data.updated > Data.released) {1158 var updateStr = 'ä¸æ¸ãä¿åãããã¼ã¿ãStagingç°å¢ã«å
¬éããã¦ãã¾ãã' + '<br>';1159 updateStr += '<span>ä¸æ¸ãä¿åæ¥æ</span>ï¼' + Data.updated + '<br>';1160 updateStr += '<span>æçµæ´æ°æ¥æ</span>ï¼' + Data.released;1161 $(Names.cntBody.addDot()).first().prepend(1162 $('<div></div>').addClass(Names.cntBodyPnlAlert).html(updateStr)1163 );1164 $(Names.cntBody.addDot()).first().find('.date-update').first().addClass('alert');1165 $(Names.cntBody.addDot()).first().find('.date-release').first().addClass('alert');1166 }1167 }1168 // æªä¿åã®å ´åã¯ä¸æ¸ãä¿åæ¥ã®èæ¯ã赤ã«ãã1169 if (Data.updated === '0000-00-00 00:00:00') {1170 $(Names.cntBody.addDot()).first().find('.date-update').first().addClass('alert');1171 }1172 // åé¤ããã¦ããå ´åã¯ã¢ã©ã¼ãã表示1173 if (Data.is_delete === '1') {1174 $(Names.cntBody.addDot()).first().prepend(1175 $('<div></div>').text('åé¤æ¸ã¿ãã¼ã¿ã§ã').addClass(Names.cntBodyPnlAlert)1176 );1177 }1178 // å®äºããã«ã®è¡¨ç¤º1179 if (showSuccess) {1180 // æåããæ¨ãä¼ããããã«ã®è¡¨ç¤º1181 $(Names.cntBody.addDot()).first().prepend(1182 $('<div></div>').text('æ´æ°ãã¾ãã')1183 .addClass(Names.cntBodyPnlSuccess)1184 );1185 // 2ç§å¾ã«æ¶ããããã«ã»ãããã1186 $(Names.cntBodyPnlSuccess.addDot()).fadeOut(2000, function() {$(this).remove();});1187 }1188 },1189 // ä¸æ¸ãä¿åãããã¿ã³ãæ¼ããæã®å¦ç1190 save: function() {1191 // ãã¼ã¸ã®ãªã³ã¯åçã®ã¨ã¬ã¡ã³ã1192 var $elmName = $(Names.cntName.addHash());1193 var url = 'html/save/' + $elmName.text();1194 var data = {1195 html : Contents.createSave(),1196 updated: $elmName.data(Names.dataUpdate)1197 };1198 Ajaxs.update(url, data);1199 },1200 // æ¬çªå
¬éç¨ãã¼ã¸ã®ä½æ1201 publishing: function() {1202 // ãã¼ã¸ã®ãªã³ã¯åçã®ã¨ã¬ã¡ã³ã1203 var $elmName = $(Names.cntName.addHash());1204 var url = 'html/update/' + $elmName.text();1205 var data = {1206 html : Contents.createSave(),1207 publish : Contents.createPublish(),1208 updated: $elmName.data(Names.dataUpdate)1209 };1210 Ajaxs.update(url, data);1211 Preview.hide();1212 },1213 // ä¸æä¿åç¨ã³ã³ãã³ãã®ä½æ1214 createSave: function() {1215 // htmlã³ã³ãã³ãã®ã©ããã¼ãã¯ãã¼ã³1216 var $html = $(Names.cntBodyDataWrap.addHash()).clone();1217 // ä¸è¦ãªã¯ã©ã¹çãåé¤1218 $html = Contents.removeRedundant($html);1219 // ä¸èº«ã®ã¿ãè¿ã1220 return $html.html();1221 },1222 // ãã¬ãã¥ã¼ç¨ã®ã³ã³ãã³ãã®ä½æ1223 createPreview: function($wrap) {1224 var $content = $(Names.cntBodyDataWrap.addHash()).clone();1225 // ä¸è¦ãªã¯ã©ã¹çãåé¤1226 $content = Contents.removeRedundant($content);1227 // ä¸è¦ãªdataå±æ§çãåé¤1228 $content = Contents.removeRedundantData($content);1229 // é表示ã®ã¨ã¬ã¡ã³ããåé¤(colspanã»rowspanããããããªãçºåé¤ããªã)1230 // $content.find(Names.hidden.addDot()).remove();1231 // ä¸ã«ä½ããªãã³ã³ãã³ãã®åé¤1232 $content.find(BoxNames.wrap.addDot()).each(function() {1233 if ($(this).text().trim() === '') {1234 $(this).remove();1235 }1236 });1237 // ãã¼ã¸TOPã¸ã³ã³ãã³ãã®æ¿å
¥1238 var pageName = Contents.getPageName();1239 var $pagetop = $('<p></p>').addClass('topagetop')1240 .append(1241 $('<a></a>').attr('href', 'telnumber/' + pageName)1242 .text('ãã¼ã¸TOPã¸')1243 );1244 $content.find(Names.section.addDot()).append($pagetop);1245 $wrap.empty();1246 // ãã¼ã¸å
ãªã³ã¯ã®æ¿å
¥1247 $wrap.append(Contents.createUl(pageName));1248 // ã³ã³ãã³ããæ¿å
¥ãã1249 $content.find(Names.section.addDot()).each(function() {1250 $wrap.append($(this));1251 });1252 return $wrap;1253 },1254 // æ¬çªå
¬éç¨ã³ã³ãã³ãã®ä½æ1255 createPublish: function() {1256 // æ¬çªç¨ã®ã©ããã³ã³ãã³ã1257 var $publish = $('<div></div>').attr('id', 'mainmenu')1258 .attr('name', 'layoutitem_2')1259 .addClass('layoutitem_a');12601261 // ãã¬ãã¥ã¼ã¨åããã®ãåå¾1262 var $content = Contents.createPreview($publish);1263 // PHPã®ã¿ã°çãæ¿å
¥ãã¦ãµã¼ãã¸éä¿¡ããããããããPHPã®ã¿ã°ãæ¿å
¥ãããã¨ããã¨ã¨ã¹ã±ã¼ããããçº1264 // ä¸èº«ã®ã¿ããµã¼ãã«éä¿¡ãããµã¼ãå´ã§ãã®ä»ã®ã¿ã°ã足ãããã«ãã¦ãã¾ã1265 return $content.html();1266 },1267 // ãã¼ã¸ã®ãã¡ã¤ã«åãåå¾1268 getPageName: function() {1269 var pageName = '';1270 if ($(Names.cntName.addHash()).text() !== 'index') {1271 pageName = $(Names.cntName.addHash()).text();1272 }1273 return pageName;1274 },1275 // ãã¼ã¸å
ãªã³ã¯ã®ä½æ1276 createUl: function(pageName) {1277 pageName = pageName ? pageName + '/#' : '#';1278 var $ul = $('<ul></ul>').attr('id', 'inpage-links');1279 $(Names.cntBody.addDot()).first().find(Names.section.addDot()).each(function() {1280 var href = 'telnumber/' + pageName + $(this).attr('id');1281 $ul.append(1282 $('<li></li>').append(1283 $('<a></a>').attr('href', href)1284 .text($(this).children('h3').text())1285 )1286 );1287 });1288 return $ul;1289 },1290 // ä¸è¦ãªã¯ã©ã¹çã®åé¤ï¼ä¿åç¨ï¼1291 removeRedundant: function($html) {1292 $html.find(Names.hover.addDot()).removeClass(Names.hover);1293 $html.find(Names.ctmHover.addDot()).removeClass(Names.ctmHover);1294 // jQueryUI selectableé¢ä¿ã¯ã©ã¹ã®åé¤1295 $html.find(Names.uiSelecting.addDot()).removeClass(Names.uiSelecting);1296 $html.find(Names.uiSelected.addDot()).removeClass(Names.uiSelected);1297 $html.find(Names.uiSelectee.addDot()).removeClass(Names.uiSelectee);1298 // åé¤äºå®ã®ã¯ã©ã¹ã®åé¤1299 $html.find(Names.showDelRow.addDot()).removeClass(Names.showDelRow);1300 // 移åäºå®ã®ã¯ã©ã¹ã®åé¤1301 $html.find(Names.showMoveRow.addDot()).removeClass(Names.showMoveRow);1302 // ã»ãã¬ã¼ã¿ã®åé¤1303 $html.find(Names.rowSeparator.addHash()).remove();1304 // è¡ã¬ã¤ãã®åé¤1305 $html.find(Names.hoverRowTop.addHash()).remove();1306 $html.find(Names.hoverRowBottom.addHash()).remove();13071308 return $html;1309 },1310 // ä¸è¦ãªdataå±æ§çã®åé¤ï¼å
¬éç¨ï¼1311 removeRedundantData: function($html) {1312 $html.find('[' + BoxNames.receptionWeekday + ']').removeAttr(BoxNames.receptionWeekday);1313 $html.find('[' + BoxNames.receptionSaturday + ']').removeAttr(BoxNames.receptionSaturday);1314 $html.find('[' + BoxNames.receptionSunday + ']').removeAttr(BoxNames.receptionSunday);1315 $html.find('[' + BoxNames.receptionHoliday + ']').removeAttr(BoxNames.receptionHoliday);1316 $html.find('[' + BoxNames.reception365days + ']').removeAttr(BoxNames.reception365days);1317 $html.find('[' + BoxNames.receptionAllowed + ']').removeAttr(BoxNames.receptionAllowed);1318 $html.find('[' + BoxNames.receptionHourFrom + ']').removeAttr(BoxNames.receptionHourFrom);1319 $html.find('[' + BoxNames.receptionTimeFrom + ']').removeAttr(BoxNames.receptionTimeFrom);1320 $html.find('[' + BoxNames.receptionTimeTo + ']').removeAttr(BoxNames.receptionTimeTo);1321 $html.find('[' + BoxNames.receptionLunch + ']').removeAttr(BoxNames.receptionLunch);1322 $html.find('[' + BoxNames.blackOutMay + ']').removeAttr(BoxNames.blackOutMay);1323 $html.find('[' + BoxNames.blackOutEndYear + ']').removeAttr(BoxNames.blackOutEndYear);1324 $html.find('[' + BoxNames.blackOutOther + ']').removeAttr(BoxNames.blackOutOther);13251326 // fontã¿ã°ãspanã«å¤æ´1327 var html = $html.html();1328 html = html.replace(/(<\/?)font/gi, "$1span");1329 return $html.html(html);1330 }1331 };13321333 // ãã¬ãã¥ã¼ç»é¢1334 var Preview = {1335 load: function () {1336 $(Names.cntPreview.addHash() + '-wrap').height(($(window).height() - 60));1337 var frameHeight = $(Names.cntPreview.addHash() + '-wrap').height() -1338 $(Names.cntPreview.addHash() + '-head').outerHeight() - 30;1339 $(Names.cntPreview.addHash() + '-frame-wrap').height(frameHeight - 40);1340 $(Names.cntPreview.addHash() + '-frame').height(frameHeight - 40);1341 },1342 // ãã¬ãã¥ã¼ã®è¡¨ç¤º1343 show: function() {1344 $(Names.cntPreview.addHash() + '-frame').attr('src', '');1345 $(Names.cntPreview.addHash() + '-frame').attr('src', 'preview').load(function() {1346 var $insertContent = $(Names.cntPreview.addHash() + '-frame').contents().find('#mainmenu');1347 // ãã¬ãã¥ã¼ã³ã³ãã³ãã®ä½æ1348 Contents.createPreview($insertContent);1349 // ãã¬ãã¥ã¼ç»é¢ã表示ãã1350 $(Names.cntPreview.addHash()).show();1351 });1352 },1353 // ãã¬ãã¥ã¼ã®é表示1354 hide: function() {1355 $(Names.cntPreview.addHash()).hide();1356 }1357 };1358135913601361 // ãã¼ãã«ã®ã»ã«å
ã®æä½1362 var Cells = {1363 // ã»ã«å
ããã¯ã¹ã®ãã³ãã¬ã¼ã1364 boxTmp: '<div class="' + BoxNames.wrap + '">' +1365 ' <div class="' + BoxNames.center + '"></div>' +1366 ' <div class="' + BoxNames.address + '"></div>' +1367 ' <div class="' + BoxNames.free + '"></div>' +1368 ' <div class="' + BoxNames.wrapPhone + '"></div>' +1369 ' <div class="' + BoxNames.wrapHp + '">' +1370 ' <span class="' + BoxNames.hpPrefix + '"></span>' +1371 ' <span class="' + BoxNames.hpAddress + '"></span>' +1372 ' </div>' +1373 ' <div class="' + BoxNames.wrapMail + '"></div>' +1374 ' <div class="' + BoxNames.wrapReception + '">' +1375 ' <span class="' + BoxNames.receptionTime + '" ' + BoxNames.receptionAllowed + '="1" ' + BoxNames.receptionHourFrom + '="9" ' + BoxNames.receptionTimeFrom + '="0" ' + BoxNames.receptionHourTo + '="17" ' + BoxNames.receptionTimeTo + '="0" ' + BoxNames.receptionLunch + '="false"></span>' +1376 ' <span class="' + BoxNames.receptionDate + '" ' + BoxNames.receptionWeekday + '="false" ' + BoxNames.receptionSaturday + '="false" ' + BoxNames.receptionSunday + '="false" ' + BoxNames.receptionHoliday + '="false" ' + BoxNames.reception365days + '="false"></span>' +1377 ' <span class="' + BoxNames.blackOut + '" ' + BoxNames.blackOutMay + '="false" ' + BoxNames.blackOutEndYear + '="false" ' + BoxNames.blackOutOther + '=""></span>' +1378 ' </div>' +1379 ' <div class="' + BoxNames.other + '"></div>' +1380 '</div>',1381 // é»è©±çªå·ç¨ã®ãã³ãã¬ã¼ã1382 phoneTmp: '<div class="' + BoxNames.phoneGroup + '" ' + BoxNames.phoneOtherDate + '="" ' + BoxNames.phoneOtherNumber + '="" ' + BoxNames.phoneOtherState + '="1"' + BoxNames.phoneDefaultNumber + '="">' +1383 ' <span class="' + BoxNames.phonePrefix + '"></span>' +1384 ' <span class="' + BoxNames.phoneNumber + '"></span>' +1385 ' <span class="' + BoxNames.phoneSuffix + '"></span>' +1386 '</div>',1387 // ã¡ã¼ã«ã¢ãã¬ã¹ç¨ã®ãã³ãã¬ã¼ã1388 mailTmp: '<div class="' + BoxNames.mailGroup + '">' +1389 ' <span class="' + BoxNames.mailPrefix + '"></span>' +1390 ' <span class="' + BoxNames.mailAdress + '"></span>' +1391 '</div>',1392 // ã»ã«å
ã®ã³ã³ãã³ãããã¯ã¹ã®ç§»åå¦ç1393 addSortableCol: function() {1394 var cols = [1395 'col1',1396 'col2',1397 'col3'1398 ];1399 $.each(cols, function(i, col) {1400 $(Names.tblWrap.addDot()).find(col.addDot()).sortable({1401 connectWith: col.addDot(),1402 handle: BoxNames.moveHandle.addHash(),1403 start: function () {1404 isSorting = true;1405 isEdit = true;1406 Events.removeCellHovers();1407 // ä¸è¦ãªã¯ã©ã¹ã®åé¤1408 var $tables = $(Names.tblWrap.addDot());1409 $tables.find(Names.hover.addDot()).removeClass(Names.hover);1410 $tables.find(Names.ctmHover.addDot()).removeClass(Names.ctmHover);1411 $tables.find(Names.uiSelecting.addDot()).removeClass(Names.uiSelecting);1412 $tables.find(Names.uiSelected.addDot()).removeClass(Names.uiSelected);1413 },1414 stop: function () {1415 isSorting = false;1416 Events.addCellHovers();1417 }1418 });1419 });1420 },1421 // è¡ãã¨ã®ã³ã³ãã³ãã®ãã©ãã°ã¢ã³ããããããæå¹å1422 enableSortableCol: function(box) {1423 var $table = $(box).parents(Names.tblWrap.addDot()).first();1424 var $cell = $(box).parents('th,td').first();1425 var cellClass ='';1426 switch (true) {1427 case $cell.hasClass('col1'):1428 cellClass = 'col1';1429 break;1430 case $cell.hasClass('col2'):1431 cellClass = 'col2';1432 break;1433 case $cell.hasClass('col3'):1434 cellClass = 'col3';1435 break;1436 }1437 $(cellClass.addDot()).sortable('enable');1438 // $table.find('th,td').sortable('enable');1439 },1440 // è¡ãã¨ã®ã³ã³ãã³ãã®ãã©ãã°ã¢ã³ããããããç¡å¹å1441 disableSortableCol: function(box) {1442 var $table = $(box).parents(Names.tblWrap.addDot()).first();1443 var $cell = $(box).parents('th,td').first();1444 var cellClass ='';1445 switch (true) {1446 case $cell.hasClass('col1'):1447 cellClass = 'col1';1448 break;1449 case $cell.hasClass('col2'):1450 cellClass = 'col2';1451 break;1452 case $cell.hasClass('col3'):1453 cellClass = 'col3';1454 break;1455 }1456 $(cellClass.addDot()).sortable('disable');1457 // $table.find('th,td').sortable('disable');1458 },1459 // ããã¯ã¹ã®è¿½å ãã¿ã³ã®æ¿å
¥1460 addAddBoxBtn: function(elm) {1461 $(elm).append($(Names.btnAddBox.addHash()).removeClass(Names.hidden));1462 },1463 // ããã¯ã¹ã®è¿½å ãã¿ã³ã®åé¤1464 removeAddBoxBtn: function() {1465 $('body').append($(Names.btnAddBox.addHash()).addClass(Names.hidden));1466 },1467 // ããã¯ã¹ã®ç§»åç¨ã®ãã¼ã表示1468 addMoveBox: function(elm) {1469 $(elm).append($(BoxNames.moveHandle.addHash()).removeClass(Names.hidden));1470 },1471 // ããã¯ã¹ã®ç§»åç¨ã®ãã¼ã®é表示1472 removeMoveBox: function() {1473 $('body').append($(BoxNames.moveHandle.addHash()).addClass(Names.hidden));1474 },1475 // ããã¯ã¹ã®è¿½å å¦ç1476 addBox: function(elm) {1477 var $boxTmp = $(Cells.boxTmp);1478 $boxTmp.find(BoxNames.wrapPhone.addDot()).first().append($(Cells.phoneTmp));1479 $boxTmp.find(BoxNames.wrapMail.addDot()).first().append($(Cells.mailTmp));1480 $(elm).before($boxTmp);1481 // 追å ã¨åæã«ç·¨éç»é¢ã«ãã1482 EditPanel.show($boxTmp.find(BoxNames.wrapPhone.addDot()).first(), true);1483 // ç·¨éãã©ã°ãã»ãã1484 isEdit = true;1485 },1486 // ããã¯ã¹ã®åé¤å¦ç1487 removeBox: function(elm) {1488 // 移åãã¼ã®é¿é£1489 Cells.removeMoveBox();1490 // ããã¯ã¹ã®åé¤1491 $(elm).remove();1492 // ç·¨éãã©ã°ãã»ãã1493 isEdit = true;1494 },1495 // ãããç·¨éæã«éé¿ãã¦ããã¯ã©ã¹ã®ãã£ãã·ã¥1496 cashClass: [],1497 // theadã®ç·¨ééå§1498 editThead: function(elm) {1499 var $elm = $(elm);1500 var thWidth = $elm.width() - 30;1501 var thTop = $elm.offset().top - $(window).scrollTop() + $elm.height() + 10;1502 var thLeft = $elm.offset().left - $(window).scrollLeft();1503 var thTitle = $elm.text();1504 var thClass = $elm.attr('class');1505 var classArr = thClass.split(' ');1506 // éé¿ãã¦ããã¯ã©ã¹ã®ãªã¹ã1507 var delClass = [1508 'col1',1509 'col2',1510 'col3',1511 'ui-sortable',1512 'ui-sortable-disabled'1513 ];1514 // ãã£ãã·ã¥ç¨é
åã®åæå1515 Cells.cashClass = [];1516 // éé¿ãã¦ãããã®ã¨ã表示ãããã®ã«åãåãã1517 for (var i = 0, len = classArr.length; i < len; i++) {1518 if ($.inArray(classArr[i], delClass) > -1) {1519 // éé¿1520 Cells.cashClass.push(classArr[i]);1521 // åé¤1522 delete(classArr[i]);1523 }1524 }1525 $elm.addClass(Names.selected);1526 $(Names.headEdit.addHash() + '-title').val(thTitle);1527 $(Names.headEdit.addHash() + '-class').val(classArr.join(' ').trim());1528 $(Names.headEdit.addHash()).data(Names.dataTargetElm, $elm);1529 $(Names.headEdit.addHash()).css({1530 top: thTop,1531 left: thLeft,1532 width: thWidth1533 });1534 $(Names.headEdit.addHash() + '-wrap').show();1535 },1536 // theadã®ç·¨é確å®1537 updateThead: function(elm) {1538 var $elm = $($(Names.headEdit.addHash()).data(Names.dataTargetElm));1539 $elm.text($(Names.headEdit.addHash() + '-title').val());1540 $elm.attr('class', '');1541 $elm.addClass($(Names.headEdit.addHash() + '-class').val());1542 for (var i = 0, len = Cells.cashClass.length; i < len; i++) {1543 $elm.addClass(Cells.cashClass[i]);1544 }1545 Cells.cancelThead();1546 // ç·¨éãã©ã°ãã»ãã1547 isEdit = true;1548 },1549 // theadã®ç·¨éãã£ã³ã»ã«1550 cancelThead: function(elm) {1551 var pnl = $(Names.headEdit.addHash()).data(Names.dataTargetElm);1552 $(pnl).removeClass(Names.selected);1553 $(Names.headEdit.addHash() + '-wrap').hide();1554 },1555 // tfootã®ç·¨ééå§1556 editTfoot: function(elm) {1557 Events.removeTfoot();1558 var html = $(elm).html() || '';1559 $(elm).empty().addClass('edit');1560 var $textarea = $('<textarea></textarea>');1561 $(elm).append($textarea.val(html.br2nl()));1562 $textarea.trigger('focus');1563 },1564 // tfootã®ç·¨éçµäº1565 updateTfoot: function(elm) {1566 Events.addTfoot();1567 var html = $(elm).val();1568 var $td = $(elm).parents('td').first();1569 $td.empty();1570 $td.removeClass('edit').html(html.nl2br());1571 // ç·¨éãã©ã°ãã»ãã1572 isEdit = true;1573 }1574 };15751576 // ã»ã«ã®ç·¨éããã«ã§ã®å¦ç1577 var EditPanel = {1578 // é»è©±é¨åã®ãã³ãã¬ã¼ã1579 phoneTmp: '<fieldset class="' + EditNames.phoneGroup + '">' +1580 ' <label class="pull-left w-170">' +1581 ' è¦åºã' +1582 ' <input class="' + EditNames.phonePrefix + '" type="text">' +1583 ' </label>' +1584 ' <label class="pull-left w-155 mg-l-5">' +1585 ' çªå·' +1586 ' <input class="' + EditNames.phoneNumber + '" type="text">' +1587 ' </label>' +1588 ' <label class="pull-left w-170 mg-l-5">' +1589 ' å¾ã«ãã³' +1590 ' <input class="' + EditNames.phoneSuffix + '" type="text">' +1591 ' </label>' +1592 ' <label class="pull-left w-170">' +1593 ' <input class="' + EditNames.phoneOtherDate + '" type="text" readonly>' +1594 ' </label>' +1595 ' <div class="pull-left central w-140 mg-b-5" readonly>' +1596 ' <select class="' + EditNames.phoneOtherState + '">' +1597 ' <option value="1">ããã®</option>' +1598 ' <option value="2">ã¾ã§ã®</option>' +1599 ' </select>' +1600 ' é»è©±çªå·' +1601 ' </div>' +1602 ' <label class="pull-left w-140">' +1603 ' <input class="' + EditNames.phoneOtherNumber + '" type="text" placeholder="é»è©±çªå·">' +1604 ' </label>' +1605 ' <button class="btn-del-phone btn btn-danger pull-left mg-l-5" type="button">åé¤</button>' +1606 '</fieldset>',1607 // ã¡ã¼ã«é¨åã®ãã³ãã¬ã¼ã1608 mailTmp: '<fieldset class="' + EditNames.mailGroup + '">' +1609 ' <label class="pull-left w-160">' +1610 ' è¦åºã' +1611 ' <input class="' + EditNames.mailPrefix + '" type="text">' +1612 ' </label>' +1613 ' <label class="pull-left w-285 mg-l-5">' +1614 ' ã¢ãã¬ã¹' +1615 ' <input class="' + EditNames.mailAdress + '" type="text">' +1616 ' </label>' +1617 ' <label class="btn-del-mail-wrap">' +1618 ' ã' +1619 ' <button class="btn-del-mail btn btn-danger pull-left mg-l-5" type="button">åé¤</button>' +1620 ' </label>' +1621 '</fieldset>',1622 // ã»ã«å
ã³ã³ãã³ããããã¯ã®ç·¨éããã«è¡¨ç¤º1623 show: function(elm, state) {1624 var $editBox = $(elm).parents(BoxNames.wrap.addDot()).first();1625 $(EditNames.panel.addHash()).data(Names.dataTargetElm, $editBox);1626 // æ°è¦è¿½å ã§éããããç·¨éã§éãããã®ç¢ºèªç¨ï¼æ°è¦ã®æã¯ãã£ã³ã»ã«ãã¿ã³ã§åé¤ï¼1627 $(EditNames.panel.addHash()).data('addState', state || false);1628 Cells.removeMoveBox();1629 // ããã«ã®é«ããè¨å®1630 var boxHeight = $(window).height() - 150;1631 $(EditNames.panel.addHash() + '-left').height(boxHeight);1632 $(EditNames.panel.addHash() + '-right').height(boxHeight - 40);1633 $(EditNames.panel.addHash() + '-preview-wrap').height(boxHeight - 60);1634 // ãã¬ãã¥ã¼ç»é¢ã¨ç·¨éããã«ã«ãã¼ã¿ãåæ 1635 var $boxData = $editBox.clone().removeClass(BoxNames.wrap);1636 $(EditNames.panel.addHash() + '-preview').empty();1637 $(EditNames.panel.addHash() + '-preview').append($boxData.html());16381639 // ããã«å
ã®ãã¼ã¿ã®åæå1640 EditPanel.reset($(EditNames.panel.addHash()));1641 // èªã¿è¾¼ãã ãã¼ã¿ãããã«ã«åæ 1642 EditPanel.readVal($(EditNames.panel.addHash()));1643 // ã«ã©ã ã«ããç·¨éé
ç®ãå¤æ´ãã1644 EditPanel.setEditItem($(EditNames.panel.addHash()), $editBox);1645 // ã¢ã¼ãã«ã®è¡¨ç¤º1646 $(EditNames.panel.addHash()).modal();1647 // ããã«ãæä¸é¨ã«ã¹ã¯ãã¼ã«1648 $(EditNames.panel.addHash() + '-left').scrollTop(0);1649 // å
é ã®ã»ã«ã«ãã©ã¼ã«ã¹ã移å1650 $(EditNames.panel.addHash()).find('input').first().focus();1651 },1652 // ç·¨éããã«ãéããã¨ãã®å¦ç1653 hide: function(e) {1654 var $editBox = $(EditNames.panel.addHash()).data(Names.dataTargetElm);1655 var $targetTable = $editBox.parents('table').first();1656 // ããã¼ã¯ã©ã¹ã®åé¤1657 $targetTable.find(Names.hover.addDot()).removeClass(Names.hover);1658 $targetTable.find(Names.ctmHover.addDot()).removeClass(Names.ctmHover);1659 },1660 // ããã¹ãã¨ãªã¢ãWYSWYGã«å¤æ1661 setWyswyg: function() {1662 $(EditNames.editBox.addDot()).each(function () {1663 var $this = $(this);1664 // ãã¿ã³ãæ¿å
¥ããããã®ã©ãã1665 var $wrap = $('<div></div>').addClass(EditNames.editBox + '-wrap');1666 // ç·¨éã¨ãªã¢ç¨ã®ã©ãã1667 var $editBox = $('<div></div>').addClass(EditNames.editBox + '-editbox');1668 $editBox.data('composition', false);1669 $editBox.prop('contenteditable', true);1670 $editBox.on('keyup cut paste', function () {1671 setTimeout(function () {1672 if (!$this.data('composition')) {1673 $this.val($editBox.html()).trigger('input');1674 }1675 }, 0);1676 }).on('compositionstart', function () {1677 $editBox.data('composition', true);1678 }).on('compositionend', function () {1679 $editBox.data('composition', false);1680 });1681 // ãªã³ã¯æ¿å
¥ç¨ã®ããã¯ã¹1682 var $linkbox = $('<div></div>').addClass('edit-link').css({'display': 'none'});1683 $linkbox.append($('<input>').attr('type', 'text').addClass('edit-link-input'));1684 $linkbox.append(1685 $('<label></label>').html('<input type="checkbox", class="edit-link-blank"> target="_blank"ã«ãã').addClass('edit-link-blank-label')1686 );1687 $linkbox.append($('<button></button>').attr('type', 'button').addClass('edit-link-submit').text('æ´æ°'));1688 $linkbox.append($('<button></button>').attr('type', 'button').addClass('edit-link-cancel').text('ãã£ã³ã»ã«'));1689 // ãã¿ã³ç¾¤1690 var $btns = $('<div></div>').addClass('edit-link-btns')1691 .append(1692 $('<button></button>').attr('type', 'button').addClass('small').text('å°æå')1693 ).append(1694 $('<button></button>').attr('type', 'button').addClass('red').text('赤å')1695 ).append(1696 $('<button></button>').attr('type', 'button').addClass('bold').text('太å')1697 ).append(1698 $('<button></button>').attr('type', 'button').addClass('link').text('ãªã³ã¯')1699 ).append(1700 $('<button></button>').attr('type', 'button').addClass('mail').text('ã¡ã¼ã«')1701 ).append(1702 $('<button></button>').attr('type', 'button').addClass('reset').text('æ¸å¼ã®åæ¶')1703 ).append(1704 $('<button></button>').attr('type', 'button').addClass('source').text('ã½ã¼ã¹ã®è¡¨ç¤º')1705 );17061707 // ã¨ã¬ã¡ã³ãã®å¾ãã«ã©ãããæ¿å
¥1708 $this.after($wrap);1709 // ã©ããã«ãã¿ã³ãæ¿å
¥1710 $wrap.append($btns);1711 // ãªã³ã¯ç·¨éããã«ã表示1712 $wrap.append($linkbox);1713 // ç·¨éããã«ãæ¿å
¥1714 $wrap.append($editBox);1715 // å
¥åã¨ãªã¢ãã©ããã«æ¿å
¥1716 $wrap.append($this);1717 $this.hide();1718 });1719 },1720 // ã»ã«å
ã³ã³ãã³ãã®ç·¨éå
容ã®æ´æ°å¦ç1721 update: function() {1722 var $editBox = $(EditNames.panel.addHash()).data(Names.dataTargetElm);1723 $editBox.empty();1724 $editBox.append($($(EditNames.panel.addHash() + '-preview').html()));1725 $(EditNames.panel.addHash()).modal('hide');1726 // ç·¨éãã©ã°ã®ã»ãã1727 isEdit = true;1728 },1729 // ç·¨éã®ãã£ãæã«ãã¬ãã¥ã¼ã«åæ ãã1730 setVal: function(elm) {1731 var $elm = $(elm);1732 var $preview = $(EditNames.panel.addHash() + '-preview');1733 var val = $elm.val();1734 var $boxElm;1735 var $val;1736 // scriptã¨ããæåãåé¤1737 val = val.replace(/(<\/?)script/gi, "$1span");1738 if ($elm.is('[id="' + EditNames.center + '"]')) {1739 // ã»ã³ã¿å1740 $boxElm = $preview.find(BoxNames.center.addDot()).first();1741 $boxElm.empty();1742 if (val !== '') {1743 $boxElm.html(val.addSumi());1744 }1745 } else if ($elm.is('[id="' + EditNames.address + '"]')) {1746 // ä½æ1747 $boxElm = $preview.find(BoxNames.address.addDot()).first();1748 $boxElm.empty();1749 if (val !== '') {1750 // æåæ°ã確èª1751 $val = $('<div>' + val + '</div>');1752 if ($val.text().length > 200) {1753 // 200æåããå¤ãå ´åã¯åã®å¤ããã®ã¾ã¾ä½¿ç¨1754 val = $elm.data('prevVal');1755 // ããã¹ãã¨ãªã¢ã®å¤ãå
ã«æ»ã1756 $elm.val(val);1757 // å
¥åã¨ãªã¢ã®å¤ãå
ã«æ»ã1758 $elm.parents(EditNames.editBox.addDot() + '-wrap').first()1759 .find(EditNames.editBox.addDot() + '-editbox').first()1760 .html(val);1761 alert('æåæ°ã¯200æå以å
ã§å
¥åãã¦ãã ãã');1762 }1763 $boxElm.html(val);1764 $boxElm.nextAll().each(function() {1765 if ($(this).text().trim() !== '') {1766 $boxElm.append('<br><br>');1767 return false;1768 }1769 });1770 }1771 // ååå¤ã¨ãã¦ã®å¤ãã»ãã1772 $elm.data('prevVal', val);1773 } else if ($elm.is('[id="' + EditNames.hpPrefix + '"]')) {1774 // ãã¼ã ãã¼ã¸ã®æ¥é å¥1775 $boxElm = $preview.find(BoxNames.hpPrefix.addDot()).first();1776 $boxElm.empty();1777 if (val !== '') {1778 $boxElm.html(val.addSumi() + '<br>');1779 }1780 } else if ($elm.is('[id="' + EditNames.hpAddress + '"]')) {1781 // ãã¼ã ãã¼ã¸ã¢ãã¬ã¹1782 $boxElm = $preview.find(BoxNames.hpAddress.addDot()).first();1783 $boxElm.empty();1784 if (val !== '') {1785 $boxElm.append(1786 $('<a></a>').text(val)1787 .attr('href', val)1788 );1789 }1790 } else if ($elm.is('[id="' + EditNames.other + '"]')) {1791 // ãã®ä»é
ç®1792 $boxElm = $preview.find(BoxNames.other.addDot()).first();1793 $boxElm.empty();1794 if (val !== '') {1795 // æåæ°ã確èª1796 $val = $('<div>' + val + '</div>');1797 if ($val.text().length >= 200) {1798 // 200æåããå¤ãå ´åã¯åã®å¤ããã®ã¾ã¾ä½¿ç¨1799 val = $elm.data('prevVal');1800 // ããã¹ãã¨ãªã¢ã®å¤ãå
ã«æ»ã1801 $elm.val(val);1802 // å
¥åã¨ãªã¢ã®å¤ãå
ã«æ»ã1803 $elm.parents(EditNames.editBox.addDot() + '-wrap').first()1804 .find(EditNames.editBox.addDot() + '-editbox').first()1805 .html(val);1806 alert('æåæ°ã¯200æå以å
ã§å
¥åãã¦ãã ãã');1807 }1808 $boxElm.html(val);1809 }1810 // ååå¤ã¨ãã¦ã®å¤ãã»ãã1811 $elm.data('prevVal', val);1812 } else if ($elm.is('[class|="edit-phone"]')) {1813 // é»è©±çªå·é
ç®1814 EditPanel.setPhoneVal();1815 } else if ($elm.is('[class|="edit-mail"]')) {1816 // ã¡ã¼ã«ã¢ãã¬ã¹é
ç®1817 EditPanel.setMailVal();1818 } else if ($elm.is('[id|="rcpd"]')) {1819 // åä»æ¥é
ç®1820 EditPanel.setReceptionDateVal($(elm));1821 } else if ($elm.is('[id|="rcpt"]')) {1822 // åä»æéé
ç®1823 EditPanel.setReceptionTimeVal($(elm));1824 } else if ($elm.is('[id|="bko"]')) {1825 // é¤å¤æ¥é
ç®1826 EditPanel.setReceptionBlackOutVal();1827 }1828 },1829 // æ¥ä»ãæ£ãããã®ãã§ãã¯1830 // é»è©±çªå·ã®å¤ãã»ãã1831 setPhoneVal: function() {1832 var $wrap = $(EditNames.panel.addHash() + '-preview').find(BoxNames.wrapPhone.addDot()).first();1833 $wrap.empty();18341835 $(EditNames.phoneGroup.addDot()).each(function() {1836 var $phoneTmp = $(Cells.phoneTmp);1837 var pre = $(this).find(EditNames.phonePrefix.addDot()).first().val();1838 var num = $(this).find(EditNames.phoneNumber.addDot()).first().val();1839 var suf = $(this).find(EditNames.phoneSuffix.addDot()).first().val();1840 $phoneTmp.find(BoxNames.phonePrefix.addDot()).first().html(pre === ''? '': pre.addSumi() + '<br>');1841 $phoneTmp.find(BoxNames.phoneNumber.addDot()).first().html(num === ''? '': '<em>' + num + '</em>');1842 $phoneTmp.find(BoxNames.phoneSuffix.addDot()).first().html(suf === ''? '': '(' + suf + ')<br>');18431844 var otherState = $(this).find(EditNames.phoneOtherState.addDot()).first().val();1845 var otherDate = $(this).find(EditNames.phoneOtherDate.addDot()).first().val();1846 var otherNum = $(this).find(EditNames.phoneOtherNumber.addDot()).first().val();1847 $phoneTmp.attr(BoxNames.phoneDefaultNumber, num);1848 $phoneTmp.attr(BoxNames.phoneOtherState, otherState);1849 $phoneTmp.attr(BoxNames.phoneOtherDate, otherDate);1850 $phoneTmp.attr(BoxNames.phoneOtherNumber, otherNum);18511852 $wrap.append($phoneTmp);1853 });1854 // é»è©±çªå·ã®ââââå¹´ââæââæ¥ã¾ã§ã®è¡¨ç¤º1855 phoneOther.set();1856 },1857 // ã¡ã¼ã«ã¢ãã¬ã¹ãã»ãã1858 setMailVal: function() {1859 var $wrap = $(EditNames.panel.addHash() + '-preview').find(BoxNames.wrapMail.addDot()).first();1860 $wrap.empty();18611862 $(EditNames.mailGroup.addDot()).each(function() {1863 var $mailTmp = $(Cells.mailTmp);1864 var prefix = $(this).find(EditNames.mailPrefix.addDot()).first().val();1865 var address = $(this).find(EditNames.mailAdress.addDot()).first().val();1866 $mailTmp.find(BoxNames.mailPrefix.addDot()).first().html(prefix === ''? '': prefix.addSumi() + '<br>');1867 $mailTmp.find(BoxNames.mailAdress.addDot()).first().empty();1868 if (address !== '') {1869 $mailTmp.find(BoxNames.mailAdress.addDot()).first().append(1870 $('<a></a>').text(address)1871 .attr('href', 'mailto:' + address)1872 );1873 }18741875 $wrap.append($mailTmp);1876 });1877 },1878 // åä»æ¥ãã»ãã1879 setReceptionDateVal: function($elm) {1880 var $wrap = $(EditNames.panel.addHash() + '-preview').find(BoxNames.receptionDate.addDot()).first();1881 $wrap.empty($wrap);18821883 var str = '';1884 var strArr = [];1885 // var id = $elm.attr('id');1886 if ($(EditNames.reception365days.addHash()).prop('checked')) {1887 strArr.push('å¹´ä¸ç¡ä¼');1888 } else {1889 if ($(EditNames.receptionWeekday.addHash()).prop('checked')) {1890 strArr.push('å¹³æ¥');1891 }1892 if ($(EditNames.receptionSaturday.addHash()).prop('checked')) {1893 strArr.push('åæ');1894 }1895 if ($(EditNames.receptionSunday.addHash()).prop('checked')) {1896 strArr.push('æ¥æ');1897 }1898 if ($(EditNames.receptionHoliday.addHash()).prop('checked')) {1899 strArr.push('ç¥æ¥');1900 }1901 }1902 str = strArr.join('ã»');1903 if (str) {1904 str = 'åä»æ¥ï¼' + str + '<br>';1905 }1906 $wrap.attr(BoxNames.receptionWeekday, $(EditNames.receptionWeekday.addHash()).prop('checked'));1907 $wrap.attr(BoxNames.receptionSaturday, $(EditNames.receptionSaturday.addHash()).prop('checked'));1908 $wrap.attr(BoxNames.receptionSunday, $(EditNames.receptionSunday.addHash()).prop('checked'));1909 $wrap.attr(BoxNames.receptionHoliday, $(EditNames.receptionHoliday.addHash()).prop('checked'));1910 $wrap.attr(BoxNames.reception365days, $(EditNames.reception365days.addHash()).prop('checked'));1911 $wrap.html(str);1912 EditPanel.setReceptionDateCheck();1913 },1914 // åä»æ¥ã®ãã§ãã¯ããã¯ã¹ãã»ãã1915 setReceptionDateCheck: function() {1916 if ($(EditNames.reception365days.addHash()).prop('checked')) {1917 // å¹´ä¸ç¡ä¼ã«ãã§ãã¯ãå
¥ã£ã¦ããã¨ãã®å¦ç1918 $(EditNames.receptionWeekday.addHash()).prop('checked', false).prop('disabled', true);1919 $(EditNames.receptionSaturday.addHash()).prop('checked', false).prop('disabled', true);1920 $(EditNames.receptionSunday.addHash()).prop('checked', false).prop('disabled', true);1921 $(EditNames.receptionHoliday.addHash()).prop('checked', false).prop('disabled', true);1922 } else if ($(EditNames.receptionWeekday.addHash()).prop('checked') &&1923 $(EditNames.receptionSaturday.addHash()).prop('checked') &&1924 $(EditNames.receptionSunday.addHash()).prop('checked') &&1925 $(EditNames.receptionHoliday.addHash()).prop('checked')) {1926 // å¹´ä¸ç¡ä¼ä»¥å¤ã®å
¨ã¦ã«ãã§ãã¯ãå
¥ã£ã¦ããã¨ãã®å¦ç //1927 $(EditNames.reception365days.addHash()).prop('checked', true);1928 EditPanel.setReceptionDateVal();1929 } else {1930 $(EditNames.receptionWeekday.addHash()).prop('disabled', false);1931 $(EditNames.receptionSaturday.addHash()).prop('disabled', false);1932 $(EditNames.receptionSunday.addHash()).prop('disabled', false);1933 $(EditNames.receptionHoliday.addHash()).prop('disabled', false);1934 }1935 },1936 // åä»æéãã»ãã1937 setReceptionTimeVal: function($elm) {1938 var $wrap = $(EditNames.panel.addHash() + '-preview').find(BoxNames.receptionTime.addDot()).first();1939 $wrap.empty();19401941 var str = '';1942 var state = $('[name="' + EditNames.receptionTimeName + '"]:checked').val();19431944 switch (state) {1945 case '2':1946 $(EditNames.receptionHourFrom.addHash()).prop('disabled', false);1947 $(EditNames.receptionTimeFrom.addHash()).prop('disabled', false);1948 $(EditNames.receptionHourTo.addHash()).prop('disabled', false);1949 $(EditNames.receptionTimeTo.addHash()).prop('disabled', false);1950 $(EditNames.receptionLunch.addHash()).prop('disabled', false);1951 str += $(EditNames.receptionHourFrom.addHash()).val() + ':';1952 str += $(EditNames.receptionTimeFrom.addHash()).val().padZero() + 'ï½';1953 str += $(EditNames.receptionHourTo.addHash()).val() + ':';1954 str += $(EditNames.receptionTimeTo.addHash()).val().padZero();1955 if ($(EditNames.receptionLunch.addHash()).prop('checked')) {1956 str += '(12æï½13æãé¤ã)';1957 }1958 break;1959 case '3':1960 str = '24æé';1961 case '1':1962 $(EditNames.receptionHourFrom.addHash()).prop('disabled', true);1963 $(EditNames.receptionTimeFrom.addHash()).prop('disabled', true);1964 $(EditNames.receptionHourTo.addHash()).prop('disabled', true);1965 $(EditNames.receptionTimeTo.addHash()).prop('disabled', true);1966 $(EditNames.receptionLunch.addHash()).prop('disabled', true);1967 break;1968 }1969 $wrap.attr(BoxNames.receptionAllowed, state);1970 $wrap.attr(BoxNames.receptionHourFrom, $(EditNames.receptionHourFrom.addHash()).val());1971 $wrap.attr(BoxNames.receptionTimeFrom, $(EditNames.receptionTimeFrom.addHash()).val());1972 $wrap.attr(BoxNames.receptionHourTo, $(EditNames.receptionHourTo.addHash()).val());1973 $wrap.attr(BoxNames.receptionTimeTo, $(EditNames.receptionTimeTo.addHash()).val());1974 $wrap.attr(BoxNames.receptionLunch, $(EditNames.receptionLunch.addHash()).prop('checked'));1975 if (str) {1976 str = 'åä»æéï¼' + str + '<br>';1977 }1978 $wrap.html(str);1979 },1980 // é¤å¤æ¥ãã»ãã1981 setReceptionBlackOutVal: function() {1982 var $wrap = $(EditNames.panel.addHash() + '-preview').find(BoxNames.blackOut.addDot()).first();1983 $wrap.empty();19841985 var str = '';1986 var strArr = [];1987 if ($(EditNames.blackOutOther.addHash()).val() !== '') {1988 strArr.push($(EditNames.blackOutOther.addHash()).val());1989 }1990 if ($(EditNames.blackOutMay.addHash()).prop('checked')) {1991 strArr.push('5/3ï½5/5');1992 }1993 if ($(EditNames.blackOutEndYear.addHash()).prop('checked')) {1994 strArr.push('å¹´æ«å¹´å§12/29ï½1/3');1995 }1996 $wrap.attr(BoxNames.blackOutOther, $(EditNames.blackOutOther.addHash()).val());1997 $wrap.attr(BoxNames.blackOutMay, $(EditNames.blackOutMay.addHash()).prop('checked'));1998 $wrap.attr(BoxNames.blackOutEndYear, $(EditNames.blackOutEndYear.addHash()).prop('checked'));1999 str = strArr.join('ã»');2000 if (str) {2001 str = '(' + str + 'ãé¤ã)';2002 }2003 $wrap.html(str);2004 },2005 // èªã¿è¾¼ãã ãã¼ã¿ãããã«ã®å
¥åç»é¢ã«ã»ãããã2006 readVal: function($elm) {2007 var $preview = $elm.find(EditNames.panel.addHash() + '-preview');2008 // ã»ã³ã¿å2009 var centerVal = $preview.find(BoxNames.center.addDot()).first().text().trimEx();2010 if (centerVal !== '') {2011 $(EditNames.center.addHash()).val(centerVal);2012 EditPanel.showInputParentSection($(EditNames.center.addHash()));2013 }2014 // ä½æç2015 var addressVal = $preview.find(BoxNames.address.addDot()).first().html();2016 // ååå¤ã¨ãã¦ã®å¤ãã»ãã2017 $(EditNames.address.addHash()).data('prevVal', addressVal);2018 if (addressVal !== '') {2019 $(EditNames.address.addHash()).val(addressVal);2020 $(EditNames.address.addHash()).parents(EditNames.editBox.addDot() + '-wrap').first().find(EditNames.editBox.addDot() + '-editbox').first().html(addressVal);2021 EditPanel.showInputParentSection($(EditNames.address.addHash()));2022 }2023 // é»è©±çªå·2024 $preview.find(BoxNames.phoneGroup.addDot()).each(function(iPhone) {2025 if (iPhone < 1) {2026 EditPanel.showInputParentSection($(EditNames.phoneGroupWrap.addHash()));2027 }2028 var $phoneTmp = $(EditPanel.phoneTmp);2029 var phonePre = $(this).children(BoxNames.phonePrefix.addDot()).first().text().trimEx();2030 var phoneSuf = $(this).children(BoxNames.phoneSuffix.addDot()).first().text().trimEx();2031 $phoneTmp.find(EditNames.phonePrefix.addDot()).first().val(phonePre);2032 $phoneTmp.find(EditNames.phoneSuffix.addDot()).first().val(phoneSuf);20332034 var otherState = $(this).attr(BoxNames.phoneOtherState) || '';2035 var otherDate = $(this).attr(BoxNames.phoneOtherDate) || '';2036 var otherNum = $(this).attr(BoxNames.phoneOtherNumber) || '';2037 var defaultNum = $(this).attr(BoxNames.phoneDefaultNumber) || '';2038 $phoneTmp.find(EditNames.phoneNumber.addDot()).first().val(defaultNum);2039 $phoneTmp.find(EditNames.phoneOtherState.addDot()).first().val(otherState.toInt());2040 $phoneTmp.find(EditNames.phoneOtherDate.addDot()).first().val(otherDate);2041 $phoneTmp.find(EditNames.phoneOtherNumber.addDot()).first().val(otherNum);20422043 $(EditNames.phoneGroupWrap.addHash()).append($phoneTmp);2044 });2045 EditPanel.setPhoneDelBtn();2046 // ãã¼ã ãã¼ã¸ãã¬ãã£ã¯ã¹2047 var hpPreVal = $preview.find(BoxNames.hpPrefix.addDot()).first().text().trimEx();2048 if (hpPreVal !== '') {2049 $(EditNames.hpPrefix.addHash()).val(hpPreVal);2050 EditPanel.showInputParentSection($(EditNames.hpPrefix.addHash()));2051 }2052 // ãã¼ã ãã¼ã¸2053 var hpVal = $preview.find(BoxNames.hpAddress.addDot()).first().children('a').first().text();2054 if (hpVal !== '') {2055 $(EditNames.hpAddress.addHash()).val(hpVal);2056 EditPanel.showInputParentSection($(EditNames.hpAddress.addHash()));2057 }2058 // ã¡ã¼ã«2059 $preview.find(BoxNames.mailGroup.addDot()).each(function(iMail) {2060 var $mailTmp = $(EditPanel.mailTmp);2061 var mailPre = $(this).children(BoxNames.mailPrefix.addDot()).first().text().trimEx();2062 var mailAdrs = $(this).children(BoxNames.mailAdress.addDot()).first().children('a').first().text();2063 $mailTmp.find(EditNames.mailPrefix.addDot()).first().val(mailPre);2064 $mailTmp.find(EditNames.mailAdress.addDot()).first().val(mailAdrs);2065 $(EditNames.mailGroupWrap.addHash()).append($mailTmp);2066 if (iMail < 1 && mailPre !== '' && mailAdrs !== '') {2067 EditPanel.showInputParentSection($(EditNames.mailGroupWrap.addHash()));2068 }2069 });2070 EditPanel.setMailDelBtn();2071 // åä»æé2072 var $brt = $preview.find(BoxNames.receptionTime.addDot()).first();2073 $(EditNames.receptionHourFrom.addHash()).val($brt.attr(BoxNames.receptionHourFrom) || 9);2074 $(EditNames.receptionTimeFrom.addHash()).val($brt.attr(BoxNames.receptionTimeFrom) || 0);2075 $(EditNames.receptionHourTo.addHash()).val($brt.attr(BoxNames.receptionHourTo) || 17);2076 $(EditNames.receptionTimeTo.addHash()).val($brt.attr(BoxNames.receptionTimeTo) || 0);2077 $(EditNames.receptionLunch.addHash()).prop('checked', $brt.attr(BoxNames.receptionLunch) === "true" ? true : false);2078 if ($('input[name="' + EditNames.receptionTimeName + '"]:checked').val() !== '1') {2079 EditPanel.showInputParentSection($(EditNames.receptionHourFrom.addHash()));2080 }2081 $('input[name="' + EditNames.receptionTimeName + '"]').val([$brt.attr(BoxNames.receptionAllowed) || 1]).change();2082 // åä»æ¥2083 var $brd = $preview.find(BoxNames.receptionDate.addDot()).first();2084 $(EditNames.receptionWeekday.addHash()).prop('checked', $brd.attr(BoxNames.receptionWeekday) === "true" ? true : false);2085 $(EditNames.receptionSaturday.addHash()).prop('checked', $brd.attr(BoxNames.receptionSaturday) === "true" ? true : false);2086 $(EditNames.receptionSunday.addHash()).prop('checked', $brd.attr(BoxNames.receptionSunday) === "true" ? true : false);2087 $(EditNames.receptionHoliday.addHash()).prop('checked', $brd.attr(BoxNames.receptionHoliday) === "true" ? true : false);2088 $(EditNames.reception365days.addHash()).prop('checked', $brd.attr(BoxNames.reception365days) === "true" ? true : false);2089 if ($(EditNames.receptionWeekday.addHash()).prop('checked') ||2090 $(EditNames.receptionSaturday.addHash()).prop('checked') ||2091 $(EditNames.receptionSunday.addHash()).prop('checked') ||2092 $(EditNames.receptionHoliday.addHash()).prop('checked') ||2093 $(EditNames.reception365days.addHash()).prop('checked')) {2094 EditPanel.showInputParentSection($(EditNames.receptionWeekday.addHash()));2095 }2096 // åä»ä¼ã¿2097 var $brb = $preview.find(BoxNames.blackOut.addDot()).first();2098 $(EditNames.blackOutMay.addHash()).prop('checked', $brb.attr(BoxNames.blackOutMay) === "true" ? true : false);2099 $(EditNames.blackOutEndYear.addHash()).prop('checked', $brb.attr(BoxNames.blackOutEndYear) === "true" ? true : false);2100 $(EditNames.blackOutOther.addHash()).val($brb.attr(BoxNames.blackOutOther));2101 if ($(EditNames.blackOutMay.addHash()).prop('checked') ||2102 $(EditNames.blackOutEndYear.addHash()).prop('checked') ||2103 $(EditNames.blackOutOther.addHash()).val() !== '') {2104 EditPanel.showInputParentSection($(EditNames.blackOutMay.addHash()));2105 }2106 // ãã®ä»2107 var otherVal = $preview.find(BoxNames.other.addDot()).first().html();2108 // ååå¤ã¨ãã¦ã®å¤ãã»ãã2109 $(EditNames.other.addHash()).data('prevVal', otherVal);2110 if (otherVal !== '') {2111 $(EditNames.other.addHash()).val(otherVal);2112 $(EditNames.other.addHash()).parents(EditNames.editBox.addDot() + '-wrap').first().find(EditNames.editBox.addDot() + '-editbox').first().html(otherVal);2113 EditPanel.showInputParentSection($(EditNames.other.addHash()));2114 }2115 // åä»æ¥ã®ãã§ãã¯ããã¯ã¹ãã»ãããã2116 EditPanel.setReceptionDateVal($elm);2117 // é»è©±ã®æ¥ä»ãã©ã°ã¤ã³ãåæåãã2118 EditPanel.setDatePicker();2119 },2120 // ç·¨éããã«å
é
ç®ã®è¡¨ç¤º2121 showInputParentSection: function($elm) {2122 $elm.parents('.edit-section').first().children('.edit-section-title').first().removeClass('close');2123 $elm.parents('.edit-section').first().children('fieldset').show();2124 },2125 // ç·¨éããã«å
ã®ãã¼ã¿ã®ã¯ãªã¢2126 reset: function($elm) {2127 $elm.find(EditNames.center.addHash()).val('');2128 $elm.find(EditNames.address.addHash()).val('');2129 $elm.find(EditNames.phoneGroup.addDot()).remove();2130 $elm.find(EditNames.hpPrefix.addHash()).val('');2131 $elm.find(EditNames.hpAddress.addHash()).val('');2132 $elm.find(EditNames.hpAddress.addHash()).parents(EditNames.editBox.addDot() + '-wrap').first().find(EditNames.editBox.addDot() + '-editbox').first().html('');2133 $elm.find(EditNames.mailGroup.addDot()).remove();2134 $elm.find(EditNames.receptionWeekday.addHash()).first().prop('checked', false).prop('disabled', false);2135 $elm.find(EditNames.receptionSaturday.addHash()).first().prop('checked', false).prop('disabled', false);2136 $elm.find(EditNames.receptionSunday.addHash()).first().prop('checked', false).prop('disabled', false);2137 $elm.find(EditNames.receptionHoliday.addHash()).first().prop('checked', false).prop('disabled', false);2138 $elm.find(EditNames.reception365days.addHash()).first().prop('checked', false).prop('disabled', false);2139 $elm.find(EditNames.receptionNothing.addHash()).first().prop('checked', true);2140 $elm.find(EditNames.receptionHourFrom.addHash()).val(9).prop('disabled', true);2141 $elm.find(EditNames.receptionTimeFrom.addHash()).val(0).prop('disabled', true);2142 $elm.find(EditNames.receptionHourTo.addHash()).val(17).prop('disabled', true);2143 $elm.find(EditNames.receptionTimeTo.addHash()).val(0).prop('disabled', true);2144 $elm.find(EditNames.receptionLunch.addHash()).first().prop('checked', false);2145 $elm.find(EditNames.blackOutMay.addHash()).first().prop('checked', false);2146 $elm.find(EditNames.blackOutEndYear.addHash()).first().prop('checked', false);2147 $elm.find(EditNames.blackOutOther.addHash()).val('');2148 $elm.find(EditNames.other.addHash()).val('');2149 $elm.find(EditNames.other.addHash()).parents(EditNames.editBox.addDot() + '-wrap').first().find(EditNames.editBox.addDot() + '-editbox').first().html('');21502151 // ããã¹ãã¨ãªã¢ã®å
¥åãç·¨éã¨ãªã¢ã«å¤æ´2152 $(EditNames.editBox.addDot() + '-editbox').hide();2153 $('.source').click();2154 // ç·¨éããã«ã®ãã£ã¼ã«ãããã£ããéãã2155 $elm.find('.edit-section-title').addClass('close');2156 $elm.find('fieldset[id|=field]').hide();2157 },2158 // ç·¨éé
ç®ã®ã»ãã2159 setEditItem: function($edit, $box) {2160 var colClass = '';2161 var $col = $box.parents('th,td').first();2162 if ($col.hasClass('col1')) {2163 colClass = 'col1';2164 } else if ($col.hasClass('col2')) {2165 colClass = 'col2';2166 } else if ($col.hasClass('col3')) {2167 colClass = 'col3';2168 }21692170 if (colClass === 'col1') {2171 $edit.find('.edit-section').addClass(Names.hidden);2172 // ä½æé
ç®ãããã©ã«ãã§ãªã¼ãã³ã«ãã2173 $edit.find(EditNames.fieldAddress.addHash()).prev().removeClass('close');2174 $edit.find(EditNames.fieldAddress.addHash()).show();2175 } else {2176 $edit.find('.edit-section').removeClass(Names.hidden);2177 }2178 // ä½æé
ç®ã®ã¿å
¥åå¯ã¨ãã2179 $edit.find(EditNames.fieldAddress.addHash()).parents('.edit-section').first().removeClass(Names.hidden);2180 },2181 // é»è©±çªå·ã®è¿½å 2182 addPhone: function(elm) {2183 $(EditNames.phoneGroupWrap.addHash()).append($(EditPanel.phoneTmp));2184 EditPanel.setPhoneDelBtn();2185 EditPanel.setDatePicker();2186 },2187 // é»è©±çªå·ã®åé¤2188 delPhone: function(elm) {2189 $(elm).parents('fieldset').first().remove();2190 EditPanel.setPhoneDelBtn();2191 EditPanel.setPhoneVal();2192 },2193 // é»è©±çªå·ã®åé¤ãã¿ã³ã®ã»ãã2194 setPhoneDelBtn: function() {2195 // ä¸æ¦å
¨ã¦ã®ãã¿ã³ã®åé¤2196 $(EditNames.btnPhoneDel.addDot()).remove();2197 // 2å以ä¸ãªãåé¤ãã¿ã³ã®ã»ãã2198 if ($(EditNames.phoneGroup.addDot()).length > 1) {2199 $(EditNames.phoneGroup.addDot()).each(function() {2200 $(this).append(2201 $('<button></button>').text('åé¤')2202 .attr('type', 'button')2203 .addClass('btn-del-phone btn btn-danger pull-left mg-l-5')2204 );2205 });2206 }2207 EditPanel.addChangeEvent();2208 },2209 // ã¡ã¼ã«ã¢ãã¬ã¹ã®è¿½å 2210 addMail: function(elm) {2211 $(EditNames.mailGroupWrap.addHash()).append($(EditPanel.mailTmp));2212 EditPanel.setMailDelBtn();2213 },2214 // ã¡ã¼ã«ã¢ãã¬ã¹ã®åé¤2215 delMail: function(elm) {2216 $(elm).parents('fieldset').first().remove();2217 EditPanel.setMailDelBtn();2218 EditPanel.setMailVal();2219 },2220 // ã¡ã¼ã«ã®åé¤ãã¿ã³ã®ã»ãã2221 setMailDelBtn: function() {2222 // ä¸æ¦å
¨ã¦ã®ãã¿ã³ã®åé¤2223 $(EditNames.btnMailDelWrap.addDot()).remove();2224 // 2å以ä¸ãªãåé¤ãã¿ã³ã®ã»ãã2225 if ($(EditNames.mailGroup.addDot()).length > 1) {2226 $(EditNames.mailGroup.addDot()).each(function() {2227 var $lavel = $('<label></label>').addClass(EditNames.btnMailDelWrap);2228 $lavel.append('ã')2229 .append(2230 $('<button></button>')2231 .text('åé¤')2232 .attr('type', 'button')2233 .addClass('btn-del-mail btn btn-danger pull-left mg-l-5')2234 );2235 $(this).append($lavel);2236 });2237 }2238 EditPanel.addChangeEvent();2239 },2240 // ãªã¢ã«ã¿ã¤ã å
¥åç¨ã®ã¤ãã³ãã®ç»é²2241 addChangeEvent: function() {2242 $(EditNames.panel.addHash() + ' input, ' + EditNames.panel.addHash() + ' textarea').imeEnter();2243 },2244 // ãã¤ãããã«ã¼ã®ã»ãã2245 setDatePicker: function() {2246 $(EditNames.phoneOtherDate.addDot()).datepicker({2247 format: "yyyy-mm-dd",2248 todayBtn: true,2249 clearBtn: true,2250 language: "ja",2251 autoclose: true,2252 todayHighlight: true,2253 orientation: "top auto",2254 beforeShowDay: function (date){2255 date = new UltraDate(date);2256 var holidays = UltraDate.getHolidays(date.getFullYear());2257 var ret = {2258 tooltip: '',2259 classes: ''2260 };2261 var holiday = holidays[date.format(UltraDate.getDefaultFormat())];2262 if (holiday) {2263 ret.tooltip = holiday;2264 ret.classes = 'holiday';2265 }2266 switch (date.getDay()) {2267 case 0:2268 ret.classes += ' sunday';2269 break;2270 case 6:2271 ret.classes += ' saturday';2272 break;2273 }2274 return ret;2275 }2276 });2277 }2278 };22792280 // ãã¼ãã«æä½2281 var DataTable = {2282 dataBlock: '',2283 // ã¿ã¤ãã«è¡ã®ãã³ãã¬ã¼ã2284 tHeadRowTmp:'<tr>' +2285 ' <th class="col1">é¨ç½²å</th>' +2286 ' <th class="col2">å
容</th>' +2287 ' <th class="col3">é»è©±çªå·</th>' +2288 '</tr>',2289 // è¡ã®ãã³ãã¬ã¼ã2290 tBodyRowTmp: '<tr>' +2291 ' <th class="col1 col1_1"></th>' +2292 ' <td class="col1 col1_2 hidden"></td>' +2293 ' <td class="col2 "></td>' +2294 ' <td class="col3"></td>' +2295 '</tr>',22962297 /* ããããã³ã³ããã¹ãã¡ãã¥ã¼ç¨ã®ã¤ãã³ãå¦ç ---------------------------------------------------------------------------- */2298 // è¡ãä¸ç§»å2299 moveUpRow: function() {2300 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2301 var $rows = $tbody.find('tr');2302 var indexs = DataTable.getSelectRowLength($tbody);2303 var $row = $rows.eq(DataTable.getMoveUpRow($tbody, indexs.start));2304 var $moveRows = $tbody.find(Names.showMoveRow.addDot());23052306 for (var i = 0, len = $moveRows.length; i < len; i++) {2307 $row.before($moveRows.eq(i));2308 }2309 },2310 // è¡ãä¸ç§»å2311 moveDownRow: function() {2312 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2313 var indexs = DataTable.getSelectRowLength($tbody);2314 var $rows = $tbody.find('tr');2315 var $row = $rows.eq(DataTable.getMoveDownRow($tbody, indexs.end));2316 var $moveRows = $tbody.find(Names.showMoveRow.addDot());23172318 for (var i = $moveRows.length; i >= 0; i--) {2319 $row.after($moveRows.eq(i));2320 }2321 },2322 // ã»ã«ã®çµå2323 joinCell: function() {2324 // ã³ã³ãã¡ã¼ã ã§çµåããã確èª2325 if (!confirm('çµåå
ã«ãªãã»ã«ä»¥å¤ã®ãã¼ã¿ã¯åé¤ããã¾ããããããã§ããï¼')) {2326 return false;2327 }2328 // 該å½ãã¼ãã«ã®tbody2329 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2330 // é¸æãã¦ããã»ã«ç¾¤2331 var $selectCells = $tbody.find(Names.uiSelected.addDot()).not('tr');2332 // çµåã»ã«ã®è¡æ°2333 var rowspan = 0;2334 var colName = '';2335 // rowspanã®æ°ãæ°ãã2336 $.each(Names.colClasses, function(i, col) {2337 $selectCells.filter(col.addDot()).each(function(index, elm) {2338 rowspan += $(elm).getRowspan();2339 });2340 if (rowspan > 0) {2341 colName = col;2342 // braek2343 return false;2344 }2345 });2346 // æåã®ã»ã«ã«rowspanãã»ãã2347 $selectCells.first().attr('rowspan', rowspan)2348 .removeClass(Names.hidden);2349 // 次ã®ã»ã«ãé¸æããã¦ãããã©ãã確èª2350 var col1_2Select = ($selectCells.first().next().hasClass(Names.uiSelected));2351 // 次ã®ã»ã«ãé¸æããã¦ãã=col1ã¯ã©ã¹ã®ã»ã«ã§è¤æ°åé¸æããã¦ãã2352 if (col1_2Select) {2353 $selectCells.first().next().attr('rowspan', 1)2354 .addClass(Names.hidden);2355 }2356 // è¦ãã¦ããªãã»ã«ãå«ãã¦é表示å¦çã¨rowspanå¦çãè¡ã2357 var $cell = $selectCells.first().parent().find(colName.addDot()).first();2358 for (var i=rowspan; i>1; i--) {2359 $cell = $cell.parent().next().find(colName.addDot()).first();2360 $cell.attr('rowspan', 1)2361 .addClass(Names.hidden);2362 if (col1_2Select) {2363 $cell.next().attr('rowspan', 1)2364 .addClass(Names.hidden);2365 }2366 }23672368 // 空ç½è¡ã®åé¤å¦ç2369 DataTable.removeEmptyRow($tbody);23702371 // colspanã®ã»ãã2372 DataTable.setColspan($tbody);23732374 var $table = $tbody.parents('table').first();2375 $table.find('tfoot').first().find('td').first().attr('colspan', DataTable.getTfootColspan($table));2376 },2377 // ã»ã«ã®åå²2378 splitCell: function() {2379 // é¸æãã¦ããã»ã«ãã«ã¼ã2380 $(Names.uiSelected.addDot()).each(function() {2381 // 該å½è¡2382 var $row = $(this).parent('tr');2383 // rowspanãåå¾2384 var rowspan = $(this).getRowspan();2385 // ååã«ä»ä¸ãããã¯ã©ã¹2386 var colClass = '';2387 // åå²ããã»ã«ãã©ã®åã®ã»ã«ãã確èª2388 for (var col in Names.colClasses) {2389 if ($(this).hasClass(Names.colClasses[col])) {2390 colClass = Names.colClasses[col];2391 break;2392 }2393 }2394 // ã»ã«ã®rowspanãã¯ãªã¢2395 $(this).attr('rowspan', 1);2396 // rowspanã®æ°ã ãè¡ã«ã¿ã°ã追å 2397 for (var i = 0; i < (rowspan - 1); i++) {2398 $row = $row.next();2399 $row.children(colClass.addDot()).removeClass(Names.hidden);2400 }2401 });2402 },2403 // 1åç®ã®ååå²2404 splitCol: function() {2405 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2406 // é¸æãããã»ã«ãã«ã¼ã2407 $tbody.find('th' + Names.uiSelected.addDot()).each(function() {2408 // thã®æ¬¡ã®tdï¼col1_2ï¼ã®hiddenã¯ã©ã¹ãåé¤2409 $(this).next().removeClass(Names.hidden)2410 .addClass(Names.uiSelected)2411 .attr('rowspan', $(this).getRowspan());2412 });2413 DataTable.setColspan($tbody);2414 var $table = $tbody.parents('table').first();2415 $table.find('tfoot').first().find('td').first().attr('colspan', DataTable.getTfootColspan($table));2416 },2417 // è¡ã®è¿½å 2418 addRow: function(elm) {2419 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2420 var $rows = $tbody.find('tr');2421 var $row;2422 // ç¾å¨ããã¼ãã¦ããè¡ãåå¾2423 var $hoverRow = $tbody.find('tr' + Names.ctmHover.addDot()).first();2424 var rowIndex = $rows.index($hoverRow);2425 var $addRow = DataTable.createNewRow();2426 // è¡ã®ã»ã«ç¢ºèª2427 $.each(Names.colClasses, function(i, col) {2428 var hoverRowSpan = $hoverRow.find(col.addDot()).getRowspan();2429 if (!$hoverRow.find(col.addDot()).isShown()) {2430 // ã»ã«ã®é表示2431 $addRow.find(col.addDot()).addClass(Names.hidden);2432 // rowspanã®å¤æ´2433 for (var index = rowIndex; index >= 0; index--) {2434 // åã®è¡ã®rowspanã確èªãã1ãã大ãããã°ãã®è¡ã®rowspanãã1å¼ããå¤ã«è¨å®ãã2435 $row = $rows.eq(index).children(col.addDot()).first();2436 if ($row.getRowspan() > 1) {2437 $row.attr('rowspan', $row.getRowspan() + 1);2438 // ããããä¸ã«ã¯ããã®ã¼ããªã2439 break;2440 }2441 }2442 } else if (hoverRowSpan > 1) {2443 // ã»ã«ã®é表示2444 $addRow.find(col.addDot()).addClass(Names.hidden);2445 $hoverRow.find(col.addDot()).attr('rowspan', hoverRowSpan + 1);2446 }2447 });2448 // colspanã®ç¢ºèª2449 if ($($(Names.ctm.addHash()).data(Names.dataTargetElm)).find('.col1_2').isShown()) {2450 $addRow.find('.col1_1').first().attr('colspan', 2);2451 }2452 // è¡ã®è¿½å 2453 $hoverRow.after($addRow);2454 // ãã©ãã°ã¢ã³ãããããã¤ãã³ãã®è¿½å 2455 Cells.addSortableCol();2456 },2457 // è¡ã®åé¤2458 delRow: function(elm) {2459 if (!confirm('åé¤ããã¨å
ã«æ»ãã¾ãããããããã§ããï¼')) {2460 return false;2461 }24622463 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2464 var $rows = $tbody.find('tr');2465 var $row;2466 var $cell;2467 var $nextCell;2468 var $removeRow = $tbody.find('tr' + Names.ctmHover.addDot()).first();2469 var rowIndex = $rows.index($removeRow);2470 var index = 0;24712472 $.each(Names.colClasses, function(i, col) {2473 // åé¤ããè¡ã®ã»ã«ãåå¾2474 $cell = $removeRow.children(col.addDot()).first();24752476 if (!$cell.isShown()) {2477 // ã»ã«ã表示ããã¦ããªãæï¼rowspanã§ã¾ã¨ãããã¦ããï¼2478 for (index = rowIndex; index >= 0; index--) {2479 // åã®è¡ã®rowspanã確èªãã1ãã大ãããã°ãã®è¡ã®rowspanãã1å¼ããå¤ã«è¨å®ãã2480 $row = $rows.eq(index).children(col.addDot()).first();2481 if ($row.getRowspan() > 1) {2482 $row.attr('rowspan', $row.getRowspan() - 1);2483 // ããããä¸ã«ã¯ããã®ã¼ããªã2484 break;2485 }2486 }2487 } else if ($cell.getRowspan() > 1) {2488 // rowspanãè¨å®ããã¦ããã¨ãã¯æ¬¡ã®è¡ã«ã³ãã¼ãã¦rowspanãä¸ã¤æ¸ãã2489 //2490 // 次ã®è¡ã®ã»ã«ãåå¾2491 $nextCell = $removeRow.next().children(col.addDot()).first();2492 // 次ã®è¡ã®ã»ã«ã®å¾ãã«ã¯ãã¼ã³ãããã®ãæ¿å
¥2493 $nextCell.after($cell.clone().attr('rowspan', $cell.getRowspan() -1));2494 // å
ã®æ¬¡ã®è¡ã®ã»ã«ãåé¤2495 $nextCell.remove();2496 }2497 });24982499 $removeRow.fadeOut('slow', function() {2500 $removeRow.remove();2501 });2502 },2503 // 2è¡è¡¨ç¤º2504 show2Col: function() {2505 var $table = $($(Names.ctm.addHash()).data(Names.dataTargetElm)).parents('table').first();2506 $table.find('.col2').addClass(Names.hidden);2507 DataTable.removeEmptyRow($table.find('tbody').first());2508 $table.find('tfoot').first().find('td').first().attr('colspan', DataTable.getTfootColspan($table));2509 },2510 // 3è¡è¡¨ç¤º2511 show3Col: function() {2512 var $table = $($(Names.ctm.addHash()).data(Names.dataTargetElm)).parents('table').first();2513 var rowspaning = 1;2514 $table.find('.col2').each(function() {2515 // rowspanã1ãã大ããæã¯rowspaningã«å¤ãã»ãããã2516 if ($(this).getRowspan() > 1) {2517 rowspaning = $(this).getRowspan();2518 $(this).removeClass(Names.hidden);2519 }2520 rowspaning -= 1;2521 // rowspaningã1ããå°ããæã¯é表示ã®ã¾ã¾ãããã§ç¡ãæã¯hiddenã¯ã©ã¹ãåé¤2522 if (rowspaning < 1) {2523 $(this).removeClass(Names.hidden);2524 }2525 });2526 $table.find('tfoot').first().find('td').first().attr('colspan', DataTable.getTfootColspan($table));2527 },2528 // ããã¿ã¼è¡ã®è¿½å 2529 addTfoot: function() {2530 var $table = $($(Names.ctm.addHash()).data(Names.dataTargetElm)).parents('table').first();2531 var $td = $('<td></td>').attr('colspan', DataTable.getTfootColspan($table));2532 var $tfoot = $('<tfoot></tfoot>').append(2533 $('<tr></tr>').append($td)2534 );2535 $table.append($tfoot);2536 },2537 // ããã¿ã¼è¡ã®åé¤2538 removeTfoot: function() {2539 var $table = $($(Names.ctm.addHash()).data(Names.dataTargetElm)).parents('table').first();2540 $table.find('tfoot').remove();2541 },2542 /* ããã¾ã§ã³ã³ããã¹ãã¡ãã¥ã¼ç¨ã®ã¤ãã³ãå¦ç ---------------------------------------------------------------------------- */2543 // é¸æãå§ã¾ã£ã¦ããã¨ãã«ã©ã®ã¯ã©ã¹ãå«ãã§ãããã®ç¢ºèªç¨2544 selectStart: '',2545 // ã»ã«ã®é¸æï¼jQueryUIã®selectableï¼2546 addSelectEvent: function() {2547 $('tbody').selectable({2548 filter: 'th, td',2549 // é¸æéå§æã®ã¤ãã³ã2550 start: function() {2551 $(Names.uiSelected.addDot()).removeClass(Names.uiSelected);2552 },2553 // é¸æå®äºæã®ã¤ãã³ã2554 stop: function(e, ui) {2555 // é¸æå®äºæã«å¤ã®ã¯ãªã¢2556 DataTable.selectStart = '';2557 },2558 // é¸æä¸ã®ã¤ãã³ã2559 selecting: function(e, ui) {2560 // æåã«é¸æãå§ããåã®ã¯ã©ã¹ãè¨å®2561 if (!DataTable.selectStart) {2562 switch (true) {2563 case $(ui.selecting).hasClass('col1'):2564 DataTable.selectStart = 'col1';2565 break;2566 case $(ui.selecting).hasClass('col2'):2567 DataTable.selectStart = 'col2';2568 break;2569 case $(ui.selecting).hasClass('col3'):2570 DataTable.selectStart = 'col3';2571 break;2572 }2573 }2574 // åãåã®ãã®ä»¥å¤ã¯é¸æã§ããªãããã«ãã2575 if (!$(ui.selecting).hasClass(DataTable.selectStart)) {2576 $(ui.selecting).removeClass(Names.uiSelecting);2577 }2578 },2579 // é¸æãçµãã£ã¦é¸æä¸ããé¸ææ¸ã¿ã«å¤ããæã®ã¤ãã³ã2580 selected: function(e, ui) {2581 if (!$(ui.selected).hasClass(DataTable.selectStart)) {2582 $(ui.selected).removeClass(Names.uiSelected);2583 }2584 $(Names.hover.addDot()).removeClass(Names.hover);2585 $(ui.selected).parents('tr').first().addClass(Names.hover);2586 }2587 });2588 },2589 // 1åç®ã®colspanãã»ããã»ãªã»ãã2590 setColspan: function($tbody) {2591 // col1_2ã¯ã©ã¹ã®ããå ´åã¯colspanãã»ãã2592 if ($tbody.find('.col1_2').isShown()) {2593 $tbody.prev('thead').find('th').first().attr('colspan', 2);2594 var rowspaning = 0;2595 $tbody.find('.col1_1').each(function() {2596 if ($(this).next().getRowspan() > 1) {2597 rowspaning = $(this).next().getRowspan();2598 }2599 if ($(this).next().isShown()) {2600 $(this).attr('colspan', 1);2601 } else if (rowspaning > 0) {2602 $(this).attr('colspan', 1);2603 } else {2604 $(this).attr('colspan', 2);2605 }2606 rowspaning -= 1;2607 });2608 } else {2609 $tbody.prev('thead').find('th').first().attr('colspan', 1);2610 $tbody.find('.col1_1').attr('colspan', 1);2611 }2612 },2613 // 空è¡ã®åé¤2614 removeEmptyRow: function($tbody) {2615 var $rows = $tbody.find('tr');2616 // 空ç½ã®è¡ã®åé¤å¦ç2617 $rows.each(function() {2618 if (!$(this).isEmptyRow()) {2619 // continu2620 return true;2621 }26222623 var rowIndex = $rows.index(this);2624 rowspan = 0;2625 $.each(Names.colClasses, function(i, colName) {2626 // ã»ã«ã表示ããã¦ããªãæï¼rowspanã§ã¾ã¨ãããã¦ããï¼2627 for (var index = rowIndex; index >= 0; index--) {2628 // åã®è¡ã®rowspanã確èªãã1ãã大ãããã°ãã®è¡ã®rowspanãã1å¼ããå¤ã«è¨å®ãã2629 $prevCell = $rows.eq(index).children(colName.addDot()).first();2630 rowspan = $prevCell.getRowspan();2631 if (rowspan > 1) {2632 $prevCell.attr('rowspan', rowspan - 1);2633 // ããããä¸ã«ã¯ããã®ã¼ããªã2634 break;2635 }2636 }2637 });26382639 // è¡ãåé¤ãã2640 $(this).remove();2641 });2642 },2643 // è¡ãããã¼ããæ2644 hoverRow: function(elm) {2645 // è¡ãè¦ãããããã«è¡ã®ä¸ä¸ãç·ã§æã2646 $(elm).parents(Names.tblWrap).first()2647 .append($(Names.hoverRowTop.addHash()))2648 .append($(Names.hoverRowBottom.addHash()));2649 $(Names.hoverRowTop.addHash()).css({2650 top: $(elm).offset().top - 1,2651 left: $(elm).offset().left,2652 width: $(elm).width() + 'px'2653 }).show();2654 $(Names.hoverRowBottom.addHash()).css({2655 top: $(elm).offset().top + $(elm).height() -1,2656 left: $(elm).offset().left,2657 width: $(elm).width() + 'px'2658 }).show();2659 },2660 // ã³ã³ããã¹ãã¡ãã¥ã¼ã®ãè¡ã®è¿½å ããããã¼ããæã«æ¿å
¥å ´æã®ç·ã表示2661 hoverUpRow: function() {2662 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2663 var $rows = $tbody.find('tr');26642665 var indexs = DataTable.getSelectRowLength($tbody);2666 // indexsã®æåããæå¾ã®è¡ã¾ã§é¸æã¯ã©ã¹ãä»ä¸ãã2667 for (var i = indexs.start, len = indexs.end; i <= len; i++) {2668 $rows.eq(i).addClass(Names.showMoveRow);2669 }2670 // ä¸ã®ç§»åå
ã®è¡ãåå¾ãã2671 var $row = $rows.eq(DataTable.getMoveUpRow($tbody, indexs.start));26722673 // ã»ãã¬ã¼ã¿ãæ¿å
¥ãã¦è¡¨ç¤º2674 $tbody.parents(Names.tblWrap).first().append($(Names.rowSeparator.addHash()));2675 $(Names.rowSeparator.addHash()).css({2676 top: $row.offset().top,2677 left: $row.offset().left,2678 background: '#744199',2679 width: $tbody.width() + 'px'2680 }).show();2681 },2682 // ã³ã³ããã¹ãã¡ãã¥ã¼ã®ãè¡ã®è¿½å ããããã¼ããæã«æ¿å
¥å ´æã®ç·ã表示2683 hoverDownRow: function() {2684 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2685 var $rows = $tbody.find('tr');26862687 // ç¾å¨é¸æããã¦ããè¡ãã移åãããããã¯ãåå¾ãã2688 var indexs = DataTable.getSelectRowLength($tbody);2689 // indexsã®æåããæå¾ã®è¡ã¾ã§é¸æã¯ã©ã¹ãä»ä¸ãã2690 for (var i = indexs.start, len = indexs.end; i <= len; i++) {2691 $rows.eq(i).addClass(Names.showMoveRow);2692 }2693 // ä¸ã®ç§»åå
ã®è¡ãåå¾ãã2694 var $row = $rows.eq(DataTable.getMoveDownRow($tbody, indexs.end));26952696 // ã»ãã¬ã¼ã¿ãæ¿å
¥ãã¦è¡¨ç¤º2697 $tbody.parents(Names.tblWrap).first().append($(Names.rowSeparator.addHash()));2698 $(Names.rowSeparator.addHash()).css({2699 top: $row.offset().top + $row.height(),2700 left: $row.offset().left,2701 background: '#744199',2702 width: $tbody.width() + 'px'2703 }).show();2704 },2705 // ã³ã³ããã¹ãã¡ãã¥ã¼ã®ãè¡ã®è¿½å ããããã¼ããæã«æ¿å
¥å ´æã®ç·ã表示2706 hoverAddRow: function() {2707 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2708 var $row = $tbody.find('tr' + Names.ctmHover.addDot()).first();2709 $tbody.parents(Names.tblWrap).first().append($(Names.rowSeparator.addHash()));2710 $(Names.rowSeparator.addHash()).css({2711 top: $row.offset().top + $row.height(),2712 left: $row.offset().left,2713 background: '#f00',2714 width: $tbody.width() + 'px'2715 }).show();2716 },2717 // ã³ã³ããã¹ãã¡ãã¥ã¼ã®ãè¡ã®åé¤ããããã¼ããæã«åé¤è¡ã®å®éã«åé¤ãããã»ã«ã«åé¤ã¯ã©ã¹ãä»ä¸2718 hoverDelRow: function() {2719 // è¡ãè¦ãããããã«è¡ã®ä¸ã«ããã«ã表示2720 var $tbody = $($(Names.ctm.addHash()).data(Names.dataTargetElm));2721 var $row = $tbody.find('tr' + Names.ctmHover.addDot()).first();2722 $row.children().each(function() {2723 if (!$(this).isShown() || $(this).getRowspan() === 1) {2724 $(this).addClass(Names.showDelRow);2725 }2726 });2727 // ã³ã³ãã³ãã®è¿½å ãã¿ã³ã®éé¿2728 Cells.removeAddBoxBtn();2729 },2730 // 移åããè¡ã®ç¯å²ãåå¾2731 getSelectRowLength: function($tbody) {2732 var $rows = $tbody.find('tr');2733 var ret = {2734 start: 0,2735 end: -12736 };2737 var $selectRow = $tbody.find('tr' + Names.ctmHover.addDot()).first();2738 var selectIndex = $rows.index($selectRow);2739 var i = 0;2740 var len = 0;2741 // æ¤ç´¢ããããåã®åå¾2742 var cols = DataTable.getColClass($tbody);2743 // åãå
¨ã¦è¡¨ç¤ºããã¦ãããã©ããã®å¤å®ç¨é¢æ°2744 var isAllShow = function($row){2745 var ret = true;2746 $.each(cols, function(i, col) {2747 if (!$row.find(col.addDot()).isShown()) {2748 ret = false;2749 return false;2750 }2751 });2752 return ret;2753 };2754 // å
¨ã¦ã®è¡ã表示ããã¦ããã¨ããã¾ã§ããã®ã¼ã2755 for (i = selectIndex; i >= 0; i--) {2756 if (isAllShow($rows.eq(i))) {2757 // ãã¹ã¦ã®åã表示ããã¦ããã¨ãããã¹ã¿ã¼ãã¤ã³ããã¯ã¹ã¨ãã2758 ret.start = i;2759 break;2760 }2761 }27622763 // 次ã®å
¨ã¦ã®è¡ã表示ããã¦ããåã®è¡ãçµããã®è¡ã¨ãã2764 for (i = ret.start + 1, len = $rows.length; i < len; i++) {2765 if (isAllShow($rows.eq(i))) {2766 // ãã¹ã¦ã®åã表示ããã¦ããã¨ãããæçµ2767 ret.end = i - 1;2768 break;2769 }2770 }2771 if (ret.end === -1) {2772 ret.end = $rows.length - 1;2773 }2774 return ret;2775 },2776 // ä¸ã®è¡ã«ç§»åããã¨ãã®ç§»åå
ã®è¡2777 getMoveUpRow: function($tbody, index) {2778 var $rows = $tbody.find('tr');2779 var rowIndex = index - 1;27802781 // æ¤ç´¢ããããåã®åå¾2782 var cols = DataTable.getColClass($tbody);2783 // åãå
¨ã¦è¡¨ç¤ºããã¦ãããã©ããã®å¤å®ç¨é¢æ°2784 var isAllShow = function($row){2785 var ret = true;2786 $.each(cols, function(i, col) {2787 if (!$row.find(col.addDot()).isShown()) {2788 ret = false;2789 return false;2790 }2791 });2792 return ret;2793 };2794 // å
¨ã¦ã®è¡ã表示ããã¦ããã¨ããã¾ã§ããã®ã¼ã2795 for (var i = rowIndex; i >= 0; i--) {2796 if (isAllShow($rows.eq(i))) {2797 // ãã¹ã¦ã®åã表示ããã¦ããã¨ãããã¹ã¿ã¼ãã¤ã³ããã¯ã¹ã¨ãã2798 rowIndex = i;2799 break;2800 }2801 }28022803 return rowIndex;2804 },2805 // ä¸ã®è¡ã«ç§»åããã¨ãã®ç§»åå
ã®è¡2806 getMoveDownRow: function($tbody, index) {2807 var $rows = $tbody.find('tr');2808 var rowIndex = index + 1;28092810 // æ¤ç´¢ããããåã®åå¾2811 var cols = DataTable.getColClass($tbody);2812 var rowspans = {};2813 $.each(cols, function(i, col) {2814 rowspans[col] = 0;2815 });2816 // åã«ã©ã ã®rowspanãåå¥ã«è¨ç®ãããã¹ã¦ã®rowspanãä¸è´ãããã©ããã®ç¢ºèª2817 var matchRowspanNums = function($row){2818 var ret = true;2819 // rowspanã®æ°ãè¨ç®ãã2820 $.each(cols, function(i, col) {2821 if ($row.find(col.addDot()).isShown()) {2822 rowspans[col] += $row.find(col.addDot()).getRowspan();2823 }2824 });2825 loop: for (var keys in rowspans) {2826 for (var key in rowspans) {2827 if (rowspans[keys] !== rowspans[key]) {2828 ret = false;2829 break loop;2830 }2831 }2832 }2833 return ret;2834 };2835 // å
¨ã¦ã®åã®rowspanããããããã¾ã§ã«ã¼ã2836 for (var i = rowIndex, len = $rows.length; i < len; i++) {2837 if (matchRowspanNums($rows.eq(i))) {2838 rowIndex = i;2839 break;2840 }2841 }28422843 return rowIndex;2844 },2845 // 表示ããã¦ããåã®ã¯ã©ã¹ç¾¤ãåå¾2846 getColClass: function($tbody) {2847 var $theadRow = $tbody.parents('table').first()2848 .find('thead').first()2849 .find('tr').first();2850 // æ¤ç´¢ããããåã®åå¾2851 var cols = [];2852 cols.push('col1_1');2853 if ($theadRow.find('.col1').getColspan() > 1) {2854 cols.push('col1_2');2855 }2856 if ($theadRow.find('.col2').isShown()) {2857 cols.push('col2');2858 }2859 cols.push('col3');28602861 return cols;2862 },2863 // tfootç¨ã®colspanãåå¾2864 getTfootColspan: function($table) {2865 var colspan = 0;2866 $table.find('thead').first().find('th').each(function() {2867 if ($(this).isShown()) {2868 colspan += $(this).getColspan();2869 }2870 });2871 return colspan;2872 },2873 createNewRow: function() {2874 var $newRow = $(DataTable.tBodyRowTmp);2875 $newRow.children().each(function() {2876 var $boxTmp = $(Cells.boxTmp);2877 $boxTmp.find(BoxNames.wrapPhone.addDot()).first().append($(Cells.phoneTmp));2878 $boxTmp.find(BoxNames.wrapMail.addDot()).first().append($(Cells.mailTmp));2879 $(this).append($boxTmp);2880 });2881 return $newRow;2882 }2883 };28842885 // ã³ã³ããã¹ãã¡ãã¥ã¼2886 var Context = {2887 // ã³ã³ããã¹ãã¡ãã¥ã¼ã®è¡¨ç¤º2888 show: function(tbody, e) {2889 var $tbody = $(tbody);2890 // ããã¼ã¯ã©ã¹ã®ã¤ãããã®ã«ã³ã³ããã¹ãã¡ãã¥ã¼ç¨ã®ããã¼ãä»ãã2891 // ããã¼è¡ãåºå®ããçº2892 $tbody.find(Names.hover.addDot()).addClass(Names.ctmHover);2893 // ããã¼ä¸ã®ã»ã«ï¼è¡ä»¥å¤ï¼ãåå¾2894 var $cmtHoverCells = $tbody.find(Names.ctmHover.addDot()).filter('th, td');2895 var $cmtHoverRow = $tbody.find(Names.ctmHover.addDot()).filter('tr');2896 // ããã¼ã¯ã©ã¹ã«é¸æã¯ã©ã¹ãç¡ãå ´åã¯ããã¼ãã¦ããã»ã«ãé¸æä¸ã»ã«ã«ãã2897 $cmtHoverCells.each(function(i, cell) {2898 if (!$(this).hasClass(Names.uiSelected)) {2899 $tbody.find(Names.uiSelected.addDot())2900 .removeClass(Names.uiSelected);2901 $(this).addClass(Names.uiSelected);2902 }2903 });2904 // ã³ã³ããã¹ãã«è©²å½tbodyãã»ãã2905 $(Names.ctm.addHash()).data(Names.dataTargetElm, tbody);29062907 /* ããããåã¡ãã¥ã¼ã®è¡¨ç¤ºã»é表示 ---------------------------------------- */2908 var $trs = $tbody.find('tr');2909 var indexs = DataTable.getSelectRowLength($tbody);2910 // â²è¡ãä¸ã«ç§»å ------------------------------------------------------2911 $(Names.ctmMoveUp.addHash()).removeClass(Names.disabled);2912 if (indexs.start === 0) {2913 $(Names.ctmMoveUp.addHash()).addClass(Names.disabled);2914 }29152916 // â¼è¡ãä¸ã«ç§»å ------------------------------------------------------2917 $(Names.ctmMoveDown.addHash()).removeClass(Names.disabled);2918 if (indexs.end === ($trs.length - 1)) {2919 $(Names.ctmMoveDown.addHash()).addClass(Names.disabled);2920 }29212922 // ã»ã«ã®çµå ---------------------------------------------------------2923 if ($trs.find(Names.uiSelected.addDot()).length > 1) {2924 $(Names.ctmJoinCell.addHash()).removeClass(Names.disabled);2925 } else {2926 $(Names.ctmJoinCell.addHash()).addClass(Names.disabled);2927 }2928 // col1_1ã¨col1_2ã®æåã¨æå¾ã®è¡ãããã£ã¦ããªãå ´åã¯ã»ã«ã®çµåè¨å®ãç¡å¹ã«ãã2929 var $selected = $(Names.uiSelected.addDot());2930 if ($selected.filter('.col1_1').length > 0 &&2931 $selected.filter('.col1_2').length > 0) {2932 var col1_1_start = $selected.filter('.col1_1').first().parent().index();2933 var col1_2_start = $selected.filter('.col1_2').first().parent().index();2934 if (col1_1_start !== col1_2_start) {2935 $(Names.ctmJoinCell.addHash()).addClass(Names.disabled);2936 }2937 var col1_1_end = $selected.filter('.col1_1').last().parent().index() +2938 $selected.filter('.col1_1').last().getRowspan();2939 var col1_2_end = $selected.filter('.col1_2').last().parent().index() +2940 $selected.filter('.col1_2').last().getRowspan();2941 if (col1_1_end !== col1_2_end) {2942 $(Names.ctmJoinCell.addHash()).addClass(Names.disabled);2943 }2944 }29452946 // ã»ã«ã®åå² ---------------------------------------------------------2947 $(Names.ctmSplitCell.addHash()).addClass(Names.disabled);2948 $tbody.find(Names.ctmHover.addDot() + ' ' + Names.uiSelected.addDot()).each(function () {2949 var rspan = $(this).getRowspan();2950 if ($(this).getRowspan() > 1) {2951 $(Names.ctmSplitCell.addHash()).removeClass(Names.disabled);2952 return false;2953 }2954 });29552956 // ã»ã«ã®ååå² -------------------------------------------------------2957 $(Names.ctmSplitCol.addHash()).addClass(Names.disabled);2958 $tbody.find('th' + Names.uiSelected.addDot()).each(function() {2959 if ($(this).next().hasClass(Names.hidden)) {2960 $(Names.ctmSplitCol.addHash()).removeClass(Names.disabled);2961 return false;2962 }2963 });29642965 // è¡ã®è¿½å ----------------------------------------------------------2966 var colBool = true;2967 $.each(Names.colClasses, function(i, col) {2968 var $cell = $cmtHoverRow.children(col.addDot());2969 colBool = ($cell.isShown() && $cell.getRowspan() === 1) ? false : true;2970 });2971 if (colBool) {2972 $(Names.ctmAddRow.addHash()).addClass(Names.disabled);2973 } else {2974 $(Names.ctmAddRow.addHash()).removeClass(Names.disabled);2975 }29762977 // è¡ã®åé¤ ----------------------------------------------------------2978 if ($trs.length > 1) {2979 $(Names.ctmDelRow.addHash()).removeClass(Names.disabled);2980 } else {2981 $(Names.ctmDelRow.addHash()).addClass(Names.disabled);2982 }29832984 // 2åã»3å表示 ------------------------------------------------------2985 if ($tbody.find('.col2').isShown()) {2986 $(Names.ctmTitle2Col.addHash()).removeClass(Names.disabled);2987 $(Names.ctmTitle3Col.addHash()).addClass(Names.disabled);2988 } else {2989 $(Names.ctmTitle2Col.addHash()).addClass(Names.disabled);2990 $(Names.ctmTitle3Col.addHash()).removeClass(Names.disabled);2991 }29922993 // ããã¿ã¼è¡ã®è¿½å ã»åé¤ ------------------------------------------------2994 if ($tbody.next('tfoot').length > 0) {2995 $(Names.ctmDelTfoot.addHash()).removeClass(Names.disabled);2996 $(Names.ctmAddTfoot.addHash()).addClass(Names.disabled);2997 } else {2998 $(Names.ctmAddTfoot.addHash()).removeClass(Names.disabled);2999 $(Names.ctmDelTfoot.addHash()).addClass(Names.disabled);3000 }30013002 /* ããã¾ã§åã¡ãã¥ã¼ã®è¡¨ç¤ºã»é表示 ---------------------------------------- */30033004 // ã³ã³ããã¹ãã¡ãã¥ã¼ã表示3005 $(Names.ctm.addHash()).fadeIn('fast');3006 var pageY = e.pageY - $(window).scrollTop();3007 var pageX = e.pageX - $(window).scrollLeft();3008 // ããã£ã³ã°ããã¼ãã¼ãå«ããé«ããåå¾3009 var ulBottom = $(Names.ctm.addHash()).find('ul').outerHeight();3010 // ããã£ã³ã°ããã¼ãã¼ãå«ããå¹
ãåå¾3011 var ulLeft = $(Names.ctm.addHash()).find('ul').outerWidth();3012 // ç»é¢ããé«ããã¯ã¿åºãå ´åã¯ä½ç½®ã調æ´3013 if ($(window).height() < pageY + ulBottom) {3014 pageY -= ulBottom;3015 }3016 // ç»é¢ããå¹
ãã¯ã¿åºãå ´åã¯ä½ç½®ã調æ´3017 if ($(window).width() < pageX + ulLeft) {3018 pageX -= ulLeft;3019 }3020 $(Names.ctm.addHash()).children('ul')3021 .css({3022 top: pageY,3023 left: pageX3024 });3025 },3026 // ã³ã³ããã¹ãã¡ãã¥ã¼ã®é表示3027 hide: function(elm) {3028 $(elm).fadeOut('fast', function () {3029 $($(Names.ctm.addHash()).data(Names.dataTargetElm))3030 .find(Names.ctmHover.addDot())3031 .removeClass(Names.ctmHover)3032 .addClass(Names.hover);3033 });3034 }3035 };30363037 // ãã«ãã´ãªã®ç·¨éãã¢ã¼ãã«ç¨3038 var ModalCate = {3039 // ã«ãã´ãªè¡ã®ãã³ãã¬ã¼ã3040 row: '<tr>' +3041 ' <td class="' + Names.mdlCateSort + '">â</td>' +3042 ' <td><input type="text" class="' + Names.mdlCateName + '"></td>' +3043 ' <td><input type="text" class="' + Names.mdlCateId + '"></td>' +3044 ' <td><input type="text" class="' + Names.mdlCateClass + '"></td>' +3045 ' <td>' +3046 ' <select class="' + Names.mdlCateEnable + '">' +3047 ' <option value="0">-</option>' +3048 ' <option value="1">åé¤</option>' +3049 ' </select>' +3050 ' </td>' +3051 '</tr>',3052 // 表ã«è¿½å ããã¨ãã®ãã³ãã¬ã¼ã3053 sectionTmp: '<div class="tn-section" id="">' +3054 ' <h3>ç·å</h3>' +3055 ' <div class="' + Names.tblWrap + '">' +3056 ' <table>' +3057 ' <thead>' +3058 ' </thead>' +3059 ' <tbody>' +3060 ' </tbody>' +3061 ' </table>' +3062 ' </div>' +3063 '</div>',3064 // ã¢ã¼ãã«ã®è¡¨ç¤º3065 show: function(table) {3066 // ä¸æ¦è¡ã®å
¨åé¤3067 $(Names.mdlCateTable.addHash()).empty();3068 $(Names.cntBody.addDot()).first().find(Names.section.addDot()).each(function() {3069 ModalCate.addRow(3070 $(this).children('h3').text(),3071 $(this).attr('id'),3072 $(this).attr('class')3073 );3074 });3075 },3076 // ã«ãã´ãªã®ã表示ã»åé¤ãã®å¤ãå¤ãã£ãæã®å¦ç3077 changeCateEnable: function(elm) {3078 // ã«ãã´ãªãåé¤ãããã©ããã®å¤ã確èªãã¦ã¯ã©ã¹ãè¨å®ãã3079 if ($(elm).children('option:selected').first().val() === '0') {3080 $(elm).removeClass(Names.mdlCateDel);3081 } else {3082 $(elm).addClass(Names.mdlCateDel);3083 }3084 },3085 // è¡ã®è¿½å å¦ç3086 addRow: function(cateName, cateId, cateClass) {3087 // ã«ãã´ãªä¸è¦§ã®ãã¼ãã«ãé¸æ3088 var $cateTable = $(Names.mdlCateTable.addHash());3089 // 追å ããè¡ã®ãã³ãã¬ã¼ããï½Queryãªãã¸ã§ã¯ãã¨ãã¦åå¾3090 var $row = $(ModalCate.row);3091 // è¡ã®inputè¦ç´ ã«å¤ãè¨å®3092 $row.find(Names.mdlCateName.addDot()).first().val(cateName || '');3093 $row.find(Names.mdlCateId.addDot()).first().val(cateId ? cateId.split('-')[1] : '')3094 .attr(Names.mdlCateNowId, cateId || '');3095 // sectionã¿ã°ã®ä»£ããã«ä»ãã¦ããtn-sectionãåé¤3096 cateClass = cateClass || '';3097 cateClass = cateClass.replace(Names.section, '').trim();3098 $row.find(Names.mdlCateClass.addDot()).first().val(cateClass || '');3099 // æ°è¦è¡ã®æã¯å¿
é ã¨ã©ã¼ãä»ä¸3100 if (!cateName) {3101 $row.find(Names.mdlCateName.addDot())3102 .addClass(Names.mdlCateErrInput)3103 .after($('<div></div>')3104 .text('â»å¿
é é
ç®ã§ã')3105 .addClass(Names.mdlCateErrPnl));3106 }3107 if (!cateId) {3108 $row.find(Names.mdlCateId.addDot())3109 .addClass(Names.mdlCateErrInput)3110 .after($('<div></div>')3111 .text('â»å¿
é é
ç®ã§ã')3112 .addClass(Names.mdlCateErrPnl));3113 }3114 // ãã¼ãã«ã®æå¾ã«è¿½å 3115 $cateTable.append($row);3116 // 追å ããè¡ã®ååã«ãã©ã¼ã«ã¹ã移å3117 $cateTable.find(Names.mdlCateName.addDot()).last().focus();3118 },3119 // ååã®ç¢ºèª3120 validateName: function(elm) {3121 // 空æåã®ç¢ºèª3122 if (ModalCate.validateEmpty(elm)) {3123 return;3124 }3125 // éè¤ãã§ãã¯3126 ModalCate.validateOverlap(Names.mdlCateName);3127 },3128 // idã®ç¢ºèª3129 validateId: function(elm) {3130 // 空æåã®ç¢ºèª3131 if (ModalCate.validateEmpty(elm)) {3132 return;3133 }3134 // å
¥åæå種ã®ãã§ãã¯3135 if ($(elm).val().match(/[^a-zA-Z0-9_-]+/)) {3136 $(elm).addClass(Names.mdlCateErrInput)3137 .after($('<div></div>')3138 .text('â»ä½¿ç¨ã§ããæåã¯è±æ°åã¨ãã¤ãã³ãã¢ã³ãã¼ã¹ã³ã¢ã®ã¿ã§ã')3139 .addClass(Names.mdlCateErrPnl));3140 return;3141 } else if ($(elm).val().match(/^[0-9_-]+/)) {3142 $(elm).addClass(Names.mdlCateErrInput)3143 .after($('<div></div>')3144 .text('â»æ°åã»è¨å·ããå§ã¾ããã®ã¯è¨å®ã§ãã¾ãã')3145 .addClass(Names.mdlCateErrPnl));3146 } else {3147 $(elm).removeClass(Names.mdlCateErrInput)3148 .next(Names.mdlCateErrPnl.addDot()).remove();3149 }3150 // éè¤ãã§ãã¯3151 ModalCate.validateOverlap(Names.mdlCateId);3152 },3153 // idã®ç¢ºèª3154 validateClass: function(elm) {3155 $(elm).removeClass(Names.mdlCateErrInput)3156 .parents('td').first().find(Names.mdlCateErrPnl.addDot()).remove();3157 if ($(elm).val().match(/^[0-9_-]+/)) {3158 $(elm).addClass(Names.mdlCateErrInput)3159 .after($('<div></div>')3160 .text('â»æ°åã»è¨å·ããå§ã¾ããã®ã¯è¨å®ã§ãã¾ãã')3161 .addClass(Names.mdlCateErrPnl));3162 }3163 },3164 // 空ç½ãã©ããã®ç¢ºèª3165 validateEmpty: function(elm) {3166 $(elm).removeClass(Names.mdlCateErrInput)3167 .parents('td').first().find(Names.mdlCateErrPnl.addDot()).remove();3168 if ($(elm).val()) {3169 return false;3170 } else {3171 $(elm).addClass(Names.mdlCateErrInput)3172 .after($('<div></div>')3173 .text('â»å¿
é é
ç®ã§ã')3174 .addClass(Names.mdlCateErrPnl));3175 return true;3176 }3177 },3178 // éè¤ãã§ãã¯3179 validateOverlap: function(col) {3180 var vals = [];3181 var overlaps = [];3182 var i, len;3183 // éè¤ã¨ã©ã¼ãä¸æ¦åæå3184 $(Names.mdlCateTable.addHash()).find(col.addDot()).each(function() {3185 $(this).removeClass(Names.mdlCateErrOverlap);3186 $(this).parents('td').first().find(Names.mdlCateErrOverlap.addDot()).remove();3187 if ($(this).parents('td').first().find(Names.mdlCateErrInput.addDot()).length === 0) {3188 $(this).removeClass(Names.mdlCateErrInput);3189 }3190 });31913192 // åã®å¤ãé
åã«ä¿å3193 $(Names.mdlCateTable.addHash()).find(col.addDot()).each(function() {3194 if ($.inArray($(this).val(), vals) === -1) {3195 vals.push($(this).val());3196 } else {3197 if ($.inArray($(this).val(), overlaps) === -1 && $(this).val() !== '') {3198 overlaps.push($(this).val());3199 }3200 }3201 });3202 for (i = 0, len = overlaps.length; i < len; i++) {3203 $(Names.mdlCateTable.addHash()).find(col.addDot()).each(function() {3204 if ($(this).val() === overlaps[i]) {3205 $(this).addClass(Names.mdlCateErrInput)3206 .addClass(Names.mdlCateErrOverlap)3207 .after(3208 $('<div></div>').text('â»å¤ãéè¤ãã¦ãã¾ã')3209 .addClass(Names.mdlCateErrPnl)3210 .addClass(Names.mdlCateErrOverlap)3211 );3212 }3213 });3214 }3215 },3216 // ãã¼ã¸å
ãªã³ã¯ã®ä½æ3217 createUl: function(pageName) {3218 var $ul = $('<ul></ul>').attr('id', 'inpage-links');3219 $(Names.cntBody.addDot()).first().find(Names.section.addDot()).each(function() {3220 var href = $(this).attr('id');3221 $ul.append(3222 $('<li></li>').append(3223 $('<a></a>').attr('href', href)3224 .text($(this).children('h3').text())3225 )3226 );3227 });3228 return $ul;3229 },3230 // ã«ãã´ãªã®è¡¨ã¸ã®åæ 3231 reflect: function() {3232 // ã¨ã©ã¼ã®åå¨ããå ´åã¯ä½ãããªã3233 if ($(Names.mdlCateTable.addHash()).find(Names.mdlCateErrInput.addDot()).length > 0) {3234 alert('ã¨ã©ã¼ãä¿®æ£ãã¦ãã ãã');3235 return false;3236 }3237 var hasDel = false;3238 var delElm = $(Names.mdlCateTable.addHash()).find('option:selected').each(function() {3239 if ($(this).attr('value') === '1') {3240 hasDel = true;3241 return true;3242 }3243 });32443245 if (hasDel) {3246 if (!confirm("åé¤é
ç®ãããã¾ãã\næ´æ°ãã¦ãããããã§ããï¼")) {3247 return false;3248 }3249 }32503251 // ãã¼ã¸å
ãªã³ã¯3252 var $ul = $('<ul></ul>').attr('id', 'inpage-links');32533254 // ããã«ã®å
¥ãæ¿ã3255 var newArr = [];3256 $(Names.mdlCateTable.addHash()).children('tr').each(function() {3257 if ($(this).find(Names.mdlCateEnable.addDot()).first().val() === '1') {3258 return true;3259 }3260 var nowval = $(this).find(Names.mdlCateId.addDot()).first().attr(Names.mdlCateNowId);3261 var $obj;3262 if (nowval) {3263 $obj = $(nowval.addHash()).clone();3264 } else {3265 $obj = $(ModalCate.sectionTmp);3266 $obj.find('thead').first().append($(DataTable.tHeadRowTmp));3267 $obj.find('tbody').first().append(DataTable.createNewRow());3268 }3269 var id = Names.mdlCateIdPre + $(this).find(Names.mdlCateId.addDot()).first().val();3270 var name = $(this).find(Names.mdlCateName.addDot()).first().val();3271 $obj.attr(Names.mdlCateNowId, Names.mdlCateIdPre + $(this).find(Names.mdlCateId.addDot()).first().val())3272 .attr('id', id)3273 // addClassã«ããªãã®ã¯ç¾å¨ã®ãã®ã¨ã®ç½®ãæããç®çã¨ãã¦ããçº3274 .attr('class', $(this).find(Names.mdlCateClass.addDot()).first().val())3275 .addClass(Names.section)3276 .children('h3').text(name);3277 newArr.push($obj);32783279 $ul.append(3280 $('<li></li>').append(3281 $('<a></a>').attr('href', '#' + id)3282 .text(name)3283 )3284 );3285 });32863287 // ä¸æ¦ãã¼ã¿ã空ã«ãã3288 $(Names.cntBodyDataWrap.addHash()).empty();3289 // ããã²ã¼ã·ã§ã³ã®æ¿å
¥3290 $(Names.cntBodyDataWrap.addHash()).first().append($ul);3291 // æ°è¦ã«æ¿å
¥3292 $.each(newArr, function(i, val) {3293 $(Names.cntBodyDataWrap.addHash()).append(val);3294 });3295 // ç·¨éãã©ã°ãã»ãã3296 isEdit = true;3297 // ãã¼ãã«é¸æã®æå¹å3298 DataTable.addSelectEvent();3299 // ã³ã³ãã³ãããã¯ã¹ã®ãã©ãã°ã¢ã³ãããããæå¹å3300 Cells.addSortableCol();3301 $(Names.mdlCate.addHash()).modal('hide');3302 }3303 };33043305 // ãååãä¸è¦§ãã¢ã¼ãã«ç¨3306 var ModalMenu = {3307 // 表示å¦ç3308 show: function() {3309 // ã¢ã¼ãã«è¡¨ç¤ºæã«é¸æãããªã¹ãã®ã¯ãªã¢ããã¿ã³ã®ç¡å¹åãè¡ã3310 ModalMenu.removeSelect();3311 $(Names.mdlMenuBtnShow.addHash()).addClass(Names.disabled);3312 },3313 // ãªã¹ããé¸æããæã®å¦ç3314 liSelect: function(elm) {3315 // ãªã¹ããã¯ãªãã¯ããéã«é¸æã¯ã©ã¹ã®ä»ä¸ã¨ãã¿ã³ã®æå¹åãè¡ã3316 ModalMenu.removeSelect();3317 $(elm).addClass(Names.selected);3318 $(Names.mdlMenuBtnShow.addHash()).removeClass(Names.disabled);3319 },3320 // é¸æããã¦ãããªã¹ãã®ã¯ãªã¢3321 removeSelect: function() {3322 // é¸æããã¦ãããªã¹ããã¯ãªã¢ãã3323 $(Names.mdlMenu.addHash()).find('li').removeClass(Names.selected);3324 },3325 // é¸æããã¦ãããã¼ã¸ã®åå¾3326 getPage: function(elm) {3327 var $modalMenu = $(Names.mdlMenu.addHash());3328 if (isEdit) {3329 if (!confirm("ç¾å¨è¡¨ç¤ºä¸ã®ãã¼ã¸ã¯ç·¨éããã¦ããããã§ãã\nç·¨éãä¿åããã«ãã¼ã¸ãåå¾ãã¾ããï¼")) {3330 $modalMenu.modal('hide');3331 return;3332 }3333 }3334 // é¸æããã¦ãããªã¹ãã®ãã¼ã¸ãåå¾ãã¦è¡¨ç¤ºãã3335 // var $menuSelect = $modalMenu.find('li' + Names.selected.addDot()).first();3336 var $menuSelect = $(elm);3337 var url = 'html/get/' + $menuSelect.attr(Names.dataMenuName);3338 $modalMenu.modal('hide');3339 Ajaxs.get(url);3340 }3341 };334233433344 // æ¬çªç¨ã®JSã¨åããããã¨ï¼3345 // BoxNamesãªãã¸ã§ã¯ããå¿ããã«ï¼3346 var phoneOther = {3347 // ââââå¹´ââæââæ¥[ããã»ã¾ã§]ã表示ããããã®ãã³ãã¬ã¼ã3348 tmp: '<div class="until-phone">' +3349 ' <span class="' + BoxNames.phoneOtherDateClass + '"></span>' +3350 ' <span>:</span>' +3351 ' <span class="' + BoxNames.phoneOtherNumberClass + '"></span>' +3352 '</div>',3353 set: function() {3354 // æ´æ°ã·ã¹ãã ç¨3355 // $(EditNames.panel.addHash() + '-preview').find('['+ BoxNames.phoneOtherDate +']')3356 //3357 // æ¬çªç¨3358 // $('['+ BoxNames.phoneOtherDate +']')3359 $(EditNames.panel.addHash() + '-preview').find('['+ BoxNames.phoneOtherDate +']').each(function() {3360 var date = $(this).attr(BoxNames.phoneOtherDate) || '1900-01-01';3361 var phoneState = $(this).attr(BoxNames.phoneOtherState);3362 var stateStr = phoneState === '1' ? 'ãã' : 'ã¾ã§';3363 var otherNum = $(this).attr(BoxNames.phoneOtherNumber);3364 var defaultNum = $(this).attr(BoxNames.phoneDefaultNumber);3365 var $boxPhoneNum = $(this).find(BoxNames.phoneNumber.addDot()).first();3366 $boxPhoneNum.empty();3367 $boxPhoneNum.append($('<em></em>').text(defaultNum));33683369 if (phoneOther.validDate(date) && otherNum) {3370 var checkDate = new Date(date);3371 var today = new Date();33723373 if (phoneState === '1') {3374 if (today >= checkDate) {3375 $boxPhoneNum.empty();3376 $boxPhoneNum.append($('<em></em>').text(otherNum));3377 } else {3378 phoneOther.setAfter(this, otherNum, stateStr, checkDate);3379 }3380 } else if (phoneState === '2') {3381 if (today <= checkDate) {3382 phoneOther.setAfter(this, otherNum, stateStr, checkDate);3383 }3384 }3385 }3386 });3387 },3388 setAfter: function(elm, phoneNumber, stateStr, checkDate) {3389 var $div = $(phoneOther.tmp);3390 var viewDate = checkDate.getFullYear() + 'å¹´' +3391 (checkDate.getMonth() + 1) + 'æ' +3392 checkDate.getDate() + 'æ¥' +3393 stateStr;3394 $div.find(BoxNames.phoneOtherDateClass.addDot()).first().text(viewDate);3395 $div.find(BoxNames.phoneOtherNumberClass.addDot()).first().text(phoneNumber);3396 $(elm).append($div);3397 },3398 validDate: function(date) {3399 var dateArr = date.split('-');3400 var y = parseInt(dateArr[0], 10) || 0;3401 var m = parseInt(dateArr[1], 10) || 0;3402 var d = parseInt(dateArr[2], 10) || 0;3403 var dt = new Date(y, m - 1, d);3404 return (dt.getFullYear() === y, dt.getMonth() === m, dt.getDate() === d);3405 }3406 };34073408 // åæåã®å®è¡3409 Init();
...
jquery.popSelect.js
Source:jquery.popSelect.js
...87 var elemPos = this.getPosition(this.$elem);88 this.elemPos = elemPos;89 // Also Add the required css Properties90 this.$elem91 .parent(addDot(classNames.selectWrapper))92 .css({width: this.settings.width || elemPos.width, height: elemPos.height});93 // Append the popover to $elem94 var popUpCode = this.generatePopover(this.$options);95 $this.log(logs.popoverGenerated, popUpCode);96 this.$elem.after(popUpCode);97 // Assign the $popover to the new $elem98 this.$popover = this.$elem.next(addDot(classNames.popoverSelect));99 this.$popover.css({top: 0, left: 0});100 // Append Tagging System to it101 this.$elem.after(createTaggingStr(this.settings.placeholderText, this.$options));102 // Get the Tag Wrapper for later use103 this.$tagWrapper = this.$elem.next(addDot(classNames.tagWrapper));104 this.baseHeight = this.$tagWrapper.height();105 // Get the input106 this.$inputTagField = this.$tagWrapper.find(addDot(classNames.selectTextarea));107 // Hide the popover when blurring the inputTagField108 this.$inputTagField.on(constants.blur, function() {109 $this.$popover.hide();110 });111 // Get the tags in the wrapper112 this.$tags = this.$tagWrapper.find(addDot(classNames.selectTags));113 // Show Popover on click of tags114 this.$tags115 .on(constants.click, this.initializePopover.bind(this));116 // Also Attach to placeHolder Text117 this.$tags.next(addDot(classNames.placeholderText))118 .on(constants.click, this.initializePopover.bind(this));119 // Attach Event Listener to ul list120 this.$tags.on(constants.click, addDot(classNames.popoverClose), function() {121 $this.inputToPopover($(this));122 });123 // Attach List Event Handlers to Li124 this.$popover.find(addDot(classNames.selectList)).on(constants.mousedown, function(e) {125 e.preventDefault();126 }).on(constants.click, constants.li, function() {127 $this.popoverToInput($(this));128 });129 // Finally Hide the Element130 this.$elem.hide();131 // Required for placeholdertext and pre-selected values132 this.checkNumberOfTags();133 // If pre-selected are higher than normal134 this.changeSize();135 // Trigger init event136 this.$elem.trigger('popselect:init');137 if (this.settings.autofocus) {138 this.initializePopover();139 }140 },141 inputToPopover: function($elem) {142 var $li = $elem.parent();143 this.log(logs.closeClicked, $li);144 var val = $li.attr(constants.attrVal);145 var text = $li.attr(constants.attrText);146 // Remove them from input and add it to popover147 this.appendToPopup(val, text);148 $li.remove();149 // Standard Reset Calls150 this.setPlaceholder();151 this.focus();152 // Whether to increase/decrease width153 this.changeSize();154 // Whether to enable / disable popover and Placeholder Text155 this.checkNumberOfTags();156 // Trigger remove event, passing value and text of removed tag157 this.$elem.trigger('popselect:remove', [val, text]);158 },159 enablePopover: function() {160 this.$popover.find(addDot(classNames.selectList) + ' li')161 .removeClass(classNames.popoverDisabled);162 },163 disablePopover: function() {164 this.$popover.find(addDot(classNames.selectList) + ' li')165 .addClass(classNames.popoverDisabled);166 },167 checkNumberOfTags: function() {168 var currentNo = this.$tags.find(addDot(classNames.tag)).length;169 if (currentNo === 0) {170 this.enablePlaceHolderText();171 } else {172 this.disablePlaceHolderText();173 }174 if (this.settings.maxAllowed !== 0) {175 if (this.settings.maxAllowed > currentNo) {176 this.enablePopover();177 } else {178 this.disablePopover();179 }180 }181 this.syncWithSelect();182 },183 popoverToInput: function($elem) {184 var val = $elem.attr(constants.attrVal);185 var text = $elem.text();186 var li = createTagStr(val, text);187 // Remove them from popover and it to input188 this.$tags.append(li);189 $elem.remove();190 // Standard Reset Calls191 this.setPlaceholder();192 this.focus();193 this.popoverShow();194 this.changePosition();195 // Whether to increase/decrease width196 this.changeSize();197 // Enable / Disable Popover198 this.checkNumberOfTags();199 // Trigger add event, passing value and text of added tag200 this.$elem.trigger('popselect:add', [val, text]);201 },202 popoverShow: function() {203 // Change Position as well show popover204 if (this.$popover.find(addDot(classNames.selectList) + ' li').length) {205 this.$popover.show();206 } else {207 this.$popover.hide();208 }209 },210 initializePopover: function() {211 this.popoverShow();212 this.changePosition();213 this.setPlaceholder();214 this.focus();215 },216 enablePlaceHolderText: function() {217 this.$tags.next(addDot(classNames.placeholderText)).show();218 },219 disablePlaceHolderText: function() {220 this.$tags.next(addDot(classNames.placeholderText)).hide();221 },222 focus: function() {223 var $this = this;224 this.$tags.find(addDot(classNames.placeholderInput)).focus();225 this.$tags.find(addDot(classNames.placeholderInput)).on(constants.blur, function() {226 $this.$popover.hide();227 });228 },229 setPlaceholder: function() {230 if (this.$tags.children(addDot(classNames.placeholder)).length) {231 this.$tags.children(addDot(classNames.placeholder)).remove();232 }233 this.$tags.append(createPlaceholderInput());234 this.disableInput();235 },236 disableInput: function() {237 var $this = this;238 this.$tags.find(addDot(classNames.placeholderInput)).keyup(function(e) {239 // Empty the input always240 $(this).val('');241 // For delete key, backspace and Ctrl + x Key242 if (e.which === 8 || e.which === 46 || e.ctrlKey && e.which === 88) {243 $this.removeLastElem();244 }245 });246 },247 changeSize: function() {248 if (this.settings.autoIncrease) {249 var tagWidth = 0;250 var textWidth = this.settings.width || this.elemPos.width;251 this.$tags.find(addDot(classNames.tag)).each(function(i, elem) {252 tagWidth += $(elem).outerWidth() + 20;253 });254 var mHeight = Math.floor(tagWidth / textWidth);255 this.$tags.height((mHeight + 1) * this.baseHeight);256 }257 },258 removeLastElem: function() {259 // Delete the last selected li if present260 var tags = this.$tags.find(addDot(classNames.tag));261 if (tags.length) {262 var $li = $(tags[tags.length - 1]);263 var val = $li.attr(constants.attrVal);264 var text = $li.attr(constants.attrText);265 // Remove them from input and add it to popover266 this.appendToPopup(val, text);267 $li.remove();268 // Standard Reset Calls269 this.changePosition();270 this.setPlaceholder();271 this.focus();272 // Whether to increase/decrease width273 this.changeSize();274 // Enable / Disable Popover275 this.checkNumberOfTags();276 } else {277 this.log(logs.noElem);278 }279 },280 setTitle: function(title) {281 if (this.settings.showTitle) {282 this.$popover.find(addDot(classNames.selectTitle)).text(title);283 }284 },285 getPosition: function($element) {286 $element = $element || this.$element;287 var el = $element[0];288 var isBody = el.tagName === constants.body;289 var elRect = el.getBoundingClientRect();290 if (elRect.width == null) {291 var w = elRect.right - elRect.left;292 var h = elRect.bottom - elRect.top;293 elRect = $.extend({}, elRect, {width: w, height: h});294 }295 var elOffset = isBody ? {top: 0, left: 0} : $element.offset();296 /* jshint ignore:start */297 var scroll = {scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }298 /* jshint ignore:end */299 var outerDims = isBody ? {width: $(window).width(), height: $(window).height()} : null;300 return $.extend({}, elRect, scroll, outerDims, elOffset);301 },302 syncWithSelect: function() {303 var arrValues = this.$tags.find(addDot(classNames.tag)).map(function(i, elem) {304 return $(elem).attr('data-value');305 }).toArray();306 this.$elem.children(constants.option).each(function(i, option) {307 if (arrValues.indexOf($(option).val()) < 0) {308 $(option).removeAttr('selected');309 } else {310 $(option).attr('selected', 'selected');311 }312 });313 },314 appendToPopup: function(val, text) {315 var li = createLiTag(val, text);316 this.$popover.find(addDot(classNames.selectList)).append(li);317 },318 generatePopover: function(options) {319 var list = '';320 for (var i = 0; i < options.length; i++) {321 if (!options[i].selected) {322 list += createLiTag(options[i].val, options[i].text);323 }324 }325 var popoverStr = createPopoverStr(list, this.settings);326 return popoverStr;327 },328 changePosition: function() {329 // It first needs to be placed330 var popPos = this.getPosition(this.$popover);331 var tagPos = this.getPosition(this.$tagWrapper);332 var leftOffset = ((this.settings.width || this.elemPos.width) / 2) - (popPos.width / 2);333 var topOffset;334 if (this.settings.position === 'top') {335 topOffset = -(popPos.height);336 } else {337 topOffset = tagPos.height;338 }339 this.log('popPos.width', popPos.width);340 this.log(logs.posChanged, topOffset, leftOffset);341 this.$popover.css({top: topOffset, left: leftOffset});342 },343 log: function() {344 if (this.settings.debug) {345 console.log.apply(console, arguments);346 }347 }348 });349 /**350 * A quick helper function for creating templates351 * @param {string} s Template String352 * @param {object} d Values to replace for353 * @return {string} Populated template string354 */355 function template(s, d) {356 for (var p in d) {357 s = s.replace(new RegExp('{' + p + '}', 'g'), d[p]);358 }359 return s;360 }361 /**362 * Just adds a dot for easy class selection363 * @param {string} str DOM className364 * @return {string} jQuery selector365 */366 function addDot(str) {367 return '.' + str;368 }369 function createEmptyDiv(x) {370 if (x) {371 return '<div class="{' + x + '}"></div>';372 } else {373 return '<div class="{wrapper}"></div>';374 }375 }376 function createTagsLi(options) {377 var str = '';378 for (var i = 0; i < options.length; i++) {379 if (options[i].selected) {380 str += createTagStr(options[i].val, options[i].text);381 }382 }383 return str;384 }385 function createTaggingStr(text, options) {386 return template('<div class="{tagWrapper}">' +387 '<textarea class="{selectTextarea}"></textarea>' +388 '<ul class="{selectTags}">' +389 '{tags}' +390 '</ul>' +391 '<div class="{placeholderText}">' +392 '{text}' +393 '</div>' +394 '</div>', {395 tags: createTagsLi(options),396 text: text,397 placeholderText: classNames.placeholderText,398 tagWrapper: classNames.tagWrapper,399 selectTextarea: classNames.selectTextarea,400 selectTags: classNames.selectTags401 });402 }403 function createTagStr(val, text) {404 return template('<li class="{tag}" data-value="{val}" data-text="{text}">' +405 '<span class="{popoverClose}">×</span>{text}' +406 '</li>', {407 text: text,408 val: val,409 tag: classNames.tag,410 popoverClose: classNames.popoverClose411 });412 }413 function createLiTag(val, text) {414 return template('<li data-value="{val}" data-text="{text}">{text}</li>', {415 val: val,416 text: text417 });418 }419 function createPlaceholderInput() {420 return template('<li class="{placeholder}">' +421 '<div>' +422 '<input type="text" readonly="true">' +423 '</div>' +424 '</li>', {425 placeholder: classNames.placeholder426 });427 }428 function createPopoverStr(list, settings) {429 return template('<div class="{popoverSelect} {top}">' +430 (settings.showTitle ? '<h3 class="{selectTitle}">{title}</h3>' : '') +431 '<div class="{popoverBody}">' +432 '<ul class="{selectList}">' +433 '{list}' +434 '</ul>' +435 '</div>' +436 '<div class="{arrow}"></div>' +437 '</div>', {438 title: settings.title,439 list: list,440 arrow: classNames.arrow,441 popoverSelect: classNames.popoverSelect,442 popoverBody: classNames.popoverBody,443 selectList: classNames.selectList,444 top: settings.position,445 selectTitle: classNames.selectTitle446 });447 }448 // A really lightweight plugin wrapper around the constructor,449 // preventing against multiple instantiations450 $.fn.popSelect = function(options) {451 if (typeof(options) === 'string') {452 if (options === 'value') {453 return this.next(addDot(classNames.tagWrapper))454 .find(addDot(classNames.tag)).map(function(i, $elem) {455 return $($elem).attr(constants.attrVal);456 });457 } else {458 console.warn(logs.unSupported);459 }460 } else {461 return this.each(function() {462 if (!$.data(this, 'plugin_' + pluginName)) {463 $.data(this, 'plugin_' + pluginName, new Plugin(this, options));464 }465 });466 }467 };468})(jQuery, window, document);
selectarea.js
Source:selectarea.js
...12 url: API + "0",13 method: "GET"14 }).then(function(e) {15 var t = e.data.result[0];16 return selectArea.addDot(e.data.result), a.setData({17 proviceData: e.data.result,18 "selectedProvince.index": 0,19 "selectedProvince.code": t.code,20 "selectedProvince.fullName": t.fullName21 }), (0, _util.Promise)(wx.request, {22 url: API + t.code,23 method: "GET"24 });25 }).then(function(e) {26 var t = e.data.result[0];27 return selectArea.addDot(e.data.result), a.setData({28 cityData: e.data.result,29 "selectedCity.index": 0,30 "selectedCity.code": t.code,31 "selectedCity.fullName": t.fullName32 }), (0, _util.Promise)(wx.request, {33 url: API + t.code,34 method: "GET"35 });36 }).then(function(e) {37 var t = e.data.result[0];38 selectArea.addDot(e.data.result), a.setData({39 districtData: e.data.result,40 "selectedDistrict.index": 0,41 "selectedDistrict.code": t.code,42 "selectedDistrict.fullName": t.fullName43 });44 }).catch(function(e) {45 console.log(e);46 });47 },48 tapProvince: function(t, a) {49 var l = t.currentTarget.dataset;50 (0, _util.Promise)(wx.request, {51 url: API + l.code,52 method: "GET"53 }).then(function(e) {54 return selectArea.addDot(e.data.result), a.setData({55 cityData: e.data.result,56 "selectedProvince.code": l.code,57 "selectedProvince.fullName": l.fullName,58 "selectedCity.code": e.data.result[0].code,59 "selectedCity.fullName": e.data.result[0].fullName60 }), (0, _util.Promise)(wx.request, {61 url: API + e.data.result[0].code,62 method: "GET"63 });64 }).then(function(e) {65 selectArea.addDot(e.data.result), a.setData({66 districtData: e.data.result,67 "selectedProvince.index": t.currentTarget.dataset.index,68 "selectedCity.index": 0,69 "selectedDistrict.index": 0,70 "selectedDistrict.code": e.data.result[0].code,71 "selectedDistrict.fullName": e.data.result[0].fullName72 });73 }).catch(function(e) {74 console.log(e);75 });76 },77 tapCity: function(t, a) {78 var l = t.currentTarget.dataset;79 (0, _util.Promise)(wx.request, {80 url: API + l.code,81 method: "GET"82 }).then(function(e) {83 selectArea.addDot(e.data.result), a.setData({84 districtData: e.data.result,85 "selectedCity.index": t.currentTarget.dataset.index,86 "selectedCity.code": l.code,87 "selectedCity.fullName": l.fullName,88 "selectedDistrict.index": 0,89 "selectedDistrict.code": e.data.result[0].code,90 "selectedDistrict.fullName": e.data.result[0].fullName91 });92 }).catch(function(e) {93 console.log(e);94 });95 },96 tapDistrict: function(e, t) {97 var a = e.currentTarget.dataset;...
Using AI Code Generation
1cy.addDot()2cy.removeDot()3cy.addDot()4cy.removeDot()5Cypress.Commands.add('addDot', () => {6 cy.get('input').type('{.}')7})8Cypress.Commands.add('removeDot', () => {9 cy.get('input').type('{backspace}')10})11Cypress.Commands.add('addDot', () => {12 cy.get('input').type('{.}')13})14Cypress.Commands.add('removeDot', () => {15 cy.get('input').type('{backspace}')16})17declare namespace Cypress {18 interface Chainable {19 * @example cy.addDot()20 addDot(): Chainable<Element>21 * @example cy.removeDot()22 removeDot(): Chainable<Element>23 }24}25declare namespace Cypress {26 interface Chainable {27 * @example cy.addDot()28 addDot(): Chainable<Element>29 * @example cy.removeDot()30 removeDot(): Chainable<Element>31 }32}33declare namespace Cypress {34 interface Chainable {35 * @example cy.addDot()36 addDot(): Chainable<Element>37 * @example cy.removeDot()38 removeDot(): Chainable<Element>39 }40}41declare namespace Cypress {42 interface Chainable {43 * @example cy.addDot()44 addDot(): Chainable<Element>45 * @example cy.removeDot()46 removeDot(): Chainable<Element>47 }48}49declare namespace Cypress {
Using AI Code Generation
1addDot(10, 10);2Cypress.Commands.add('addDot', (x, y) => {3 cy.get('canvas')4 .click(x, y)5 .trigger('mousemove', { x, y })6 .trigger('mousedown', { button: 0 })7 .trigger('mouseup', { force: true });8});
Using AI Code Generation
1cy.addDot(1, 2);2Cypress.Commands.add('addDot', (a, b) => {3 return a + b;4});5Cypress.Commands.add('addDot', (a, b) => {6 return a + b;7});
Using AI Code Generation
1cy.get('.some-selector').addDot();2Cypress.Commands.add('addDot', { prevSubject: 'element' }, $el => {3 $el.val($el.val() + '.');4});5Cypress.Commands.add('addDot', { prevSubject: 'optional' }, $el => {6 $el.val($el.val() + '.');7});8cy.addDot('.some-selector');9I am trying to use the cy.server() and cy.route() commands to mock some api calls. I have a test that is working but I want to add a second test that will use the same mock. For some reason, the second test is not using the mock. Here is the code:10describe('My First Test', function() {11 it('Does not do much!', function() {12 cy.server();13 cy.route({14 });15 cy.get('div').contains('Contact1');16 });17 it('Does not do much!', function() {18 cy.get('div').contains('Contact1');19 });20});21I am trying to use the cy.server() and cy.route() commands to mock some api calls. I have a test that is working but I want to add a second test that will use the same mock. For some reason, the second test is not using the mock. Here is the code:
Using AI Code Generation
1Cypress.addDot = function (x, y) {2 cy.get('svg').click(x, y)3}4describe('Cypress.addDot', () => {5 it('adds a dot', () => {6 Cypress.addDot(100, 200)7 cy.addDot(200, 100)8 })9})10Cypress.addDot = function (x, y) {11 cy.get('svg').click(x, y)12}13cy.addDot = function (x, y) {14 Cypress.addDot(x, y)15}16Cypress.addDot = function (x, y) {17 cy.get('svg').click(x, y)18}19Cypress.Commands.add('addDot', (x, y) => {20 cy.get('svg').click(x, y)21})22cy.addDot(100, 200)23Cypress.Commands.add('addDot', (x, y) => {24 cy.get('svg').click(x, y)25})26cy.addDot(100, 200)27Cypress.Commands.add('addDot', (x, y) => {28 cy.get('svg').click(x, y)29})30cy.addDot(100, 200)31Cypress.Commands.add('addDot', (x, y) => {32 cy.get('svg').click(x, y)33})34cy.addDot(100, 200)35Cypress.Commands.add('addDot', (x, y) => {36 cy.get('svg').click(x, y)37})38cy.addDot(100, 200)39Cypress.Commands.add('addDot', (x, y) => {40 cy.get('svg').click(x, y)41})42cy.addDot(100,
Using AI Code Generation
1cy.get('input').type('text').addDot()2cy.get('input').type('text').addDot()3Cypress.Commands.add('addDot', () => {4 cy.get('input').type('.')5})6Cypress.Commands.add('addDot', () => {7 cy.get('input').type('.')8})9cy.get('input').type('text').addDot()10cy.get('input').type('text').addDot()11Cypress.Commands.add('addDot', () => {12 cy.get('input').type('.')13})14Cypress.Commands.add('addDot', () => {15 cy.get('input').type('.')16})17cy.get('input').type('text').addDot()18cy.get('input').type('text').addDot()19Cypress.Commands.add('addDot', () => {20 cy.get('input').type('.')21})22Cypress.Commands.add('addDot', () => {23 cy.get('input').type('.')24})25cy.get('input').type('text').addDot()26cy.get('input').type('text').addDot()27Cypress.Commands.add('addDot', () => {28 cy.get('input').type('.')29})30Cypress.Commands.add('addDot', () => {31 cy.get('input').type('.')32})33cy.get('input').type('text').addDot()34cy.get('input').type('text').addDot()35Cypress.Commands.add('addDot', () => {36 cy.get('input').type('.')37})38Cypress.Commands.add('addDot', () => {39 cy.get('input').type('.')40})
Using AI Code Generation
1Cypress.Commands.add('addDot', { prevSubject: 'optional' }, (subject, position) => {2 if (subject) {3 cy.wrap(subject).type('{shift}.')4 } else {5 if (position === 'after') {6 cy.get('body').type('{end}{shift}.')7 } else if (position === 'before') {8 cy.get('body').type('{shift}.')9 } else {10 cy.get('body').type('{shift}.')11 }12 }13})14describe('Add dot', () => {15 it('Add dot in the middle of the text', () => {16 cy.get('h1').click()17 cy.get('h1').addDot()18 cy.get('h1').should('have.text', 'Welcome to Cypress.io..')19 })20 it('Add dot after the text', () => {21 cy.get('h1').click()22 cy.get('h1').addDot('after')23 cy.get('h1').should('have.text', 'Welcome to Cypress.io.')24 })25 it('Add dot before the text', () => {26 cy.get('h1').click()27 cy.get('h1').addDot('before')28 cy.get('h1').should('have.text', '.Welcome to Cypress.io')29 })30})31Cypress.Commands.add('addDot', { prevSubject: 'optional' }, (subject, position) => {32 if (subject) {33 cy.wrap(subject).type('{shift}.')34 } else {35 if (position === 'after') {36 cy.get('body').type('{end}{shift}.')37 } else if (position === 'before') {38 cy.get('body').type('{shift}.')39 } else {40 cy.get('body').type('{shift}.')41 }42 }43})
Using AI Code Generation
1cy.get('.selector').addDot({text: 'Hello World'});2cy.get('.selector').addDot({text: 'Hello World'});3cy.get('.selector').then(($el) => {4 cy.wrap($el).addDot({text: 'Hello World'});5});6Cypress.Commands.add('addDot', { prevSubject: 'element' }, (subject, options) => {7 const { text } = options;8 return cy.wrap(subject).invoke('text', `${text}...`);9});10cy.get('.selector').addDot({text: '
Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.
You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!