Showing
24 changed files
with
1056 additions
and
314 deletions
| @@ -1328,7 +1328,7 @@ var csrf_token = $('meta[name=csrf-token]').attr('content'), | @@ -1328,7 +1328,7 @@ var csrf_token = $('meta[name=csrf-token]').attr('content'), | ||
| 1328 | 1328 | ||
| 1329 | $('.delete-row-item').click(function(){ | 1329 | $('.delete-row-item').click(function(){ |
| 1330 | var $this = $(this), | 1330 | var $this = $(this), |
| 1331 | - $tr = $this.closest('tr'), | 1331 | + $tr = $this.closest('tr, li.dd-item'), |
| 1332 | url = $this.attr('href'), | 1332 | url = $this.attr('href'), |
| 1333 | level = $tr.data('level'), | 1333 | level = $tr.data('level'), |
| 1334 | title = "Are you sure?"; | 1334 | title = "Are you sure?"; |
| @@ -1346,7 +1346,7 @@ $('.delete-row-item').click(function(){ | @@ -1346,7 +1346,7 @@ $('.delete-row-item').click(function(){ | ||
| 1346 | dataType: 'json', | 1346 | dataType: 'json', |
| 1347 | success: function(data){ | 1347 | success: function(data){ |
| 1348 | if(data.status == 'ok'){ | 1348 | if(data.status == 'ok'){ |
| 1349 | - $this.closest('tr').fadeOut('hide'); | 1349 | + $this.closest('tr, li.dd-item').fadeOut('hide'); |
| 1350 | if(level != undefined){ | 1350 | if(level != undefined){ |
| 1351 | var $current = $tr.next(); | 1351 | var $current = $tr.next(); |
| 1352 | while($current){ | 1352 | while($current){ |
| @@ -1606,12 +1606,12 @@ jQuery(document).ready(function(){ | @@ -1606,12 +1606,12 @@ jQuery(document).ready(function(){ | ||
| 1606 | trigger: 'manual', | 1606 | trigger: 'manual', |
| 1607 | placement: layer_position | 1607 | placement: layer_position |
| 1608 | }).on('hidden.bs.popover', function () { | 1608 | }).on('hidden.bs.popover', function () { |
| 1609 | - $popover.popover('destroy'); | 1609 | + $popover.popover('dispose'); |
| 1610 | }).popover('show'); | 1610 | }).popover('show'); |
| 1611 | 1611 | ||
| 1612 | $('body').on( 'click', function(e) { | 1612 | $('body').on( 'click', function(e) { |
| 1613 | if($popover.next('.popover')){ | 1613 | if($popover.next('.popover')){ |
| 1614 | - if ( !$popover.next('.popover').has(e.target).length ) {$popover.popover('destroy'); } | 1614 | + if ( !$popover.next('.popover').has(e.target).length ) {$popover.popover('dispose'); } |
| 1615 | } | 1615 | } |
| 1616 | }); | 1616 | }); |
| 1617 | 1617 | ||
| @@ -1853,7 +1853,7 @@ jQuery(document).ready(function(){ | @@ -1853,7 +1853,7 @@ jQuery(document).ready(function(){ | ||
| 1853 | $('.link-add-new-template').on('ajax:success', function(event, data, status, xhr){ | 1853 | $('.link-add-new-template').on('ajax:success', function(event, data, status, xhr){ |
| 1854 | var $this = $(this); | 1854 | var $this = $(this); |
| 1855 | 1855 | ||
| 1856 | - $this.popover('destroy'); | 1856 | + $this.popover('dispose'); |
| 1857 | 1857 | ||
| 1858 | $this.popover({ | 1858 | $this.popover({ |
| 1859 | content: data, | 1859 | content: data, |
| @@ -1863,12 +1863,12 @@ jQuery(document).ready(function(){ | @@ -1863,12 +1863,12 @@ jQuery(document).ready(function(){ | ||
| 1863 | 1863 | ||
| 1864 | $(window).on( 'click', function(e) { | 1864 | $(window).on( 'click', function(e) { |
| 1865 | if($this.next('.popover')){ | 1865 | if($this.next('.popover')){ |
| 1866 | - if ( !$this.next('.popover').has(e.target).length ) {$this.popover('destroy'); } | 1866 | + if ( !$this.next('.popover').has(e.target).length ) {$this.popover('dispose'); } |
| 1867 | } | 1867 | } |
| 1868 | }); | 1868 | }); |
| 1869 | 1869 | ||
| 1870 | $this.next('.popover').find('.cancel-send').click(function(){ | 1870 | $this.next('.popover').find('.cancel-send').click(function(){ |
| 1871 | - $this.popover('destroy'); | 1871 | + $this.popover('dispose'); |
| 1872 | 1872 | ||
| 1873 | return false; | 1873 | return false; |
| 1874 | }); | 1874 | }); |
| @@ -1880,8 +1880,52 @@ jQuery(document).ready(function(){ | @@ -1880,8 +1880,52 @@ jQuery(document).ready(function(){ | ||
| 1880 | }); | 1880 | }); |
| 1881 | }); | 1881 | }); |
| 1882 | 1882 | ||
| 1883 | + $(document).on('ajax:success', '.show-in-layer', function(event, data, status, xhr){ | ||
| 1884 | + var $this = $(this), | ||
| 1885 | + $data = $(data); | ||
| 1886 | + | ||
| 1887 | + var $modal = $data.modal({show: false, keyboard: false, backdrop: 'static'}).on('shown.bs.modal', function (e) { | ||
| 1888 | + var $this = $(this); | ||
| 1889 | + $this.find("input[data-role=tagsinput]").tagsinput({ | ||
| 1890 | + typeaheadjs: { | ||
| 1891 | + name: 'title', | ||
| 1892 | + displayKey: 'title', | ||
| 1893 | + valueKey: 'title', | ||
| 1894 | + source: tagnames.ttAdapter() | ||
| 1895 | + } | ||
| 1896 | + }); | ||
| 1897 | + initAjaxFileUpload($this); | ||
| 1898 | + | ||
| 1899 | + }).on('hidden.bs.modal', function (e) { | ||
| 1900 | + $modal.remove(); | ||
| 1901 | + }); | ||
| 1902 | + $modal.modal('show'); | ||
| 1903 | + }); | ||
| 1904 | + | ||
| 1905 | + $(document).on('ajax:success', '.edit-file-form', function(event, data, status, xhr){ | ||
| 1906 | + if(data.status == 'ok'){ | ||
| 1907 | + $('.modal').modal('hide'); | ||
| 1908 | + $('#gallery_image_' + data.id).find('.card-img-top').attr('src', data.link); | ||
| 1909 | + }else{ | ||
| 1910 | + $this.find('.error-message').html(data.message); | ||
| 1911 | + } | ||
| 1912 | + }); | ||
| 1883 | 1913 | ||
| 1884 | $('.dropdown-toggle').dropdown(); | 1914 | $('.dropdown-toggle').dropdown(); |
| 1915 | + $('.nestable-page-list').nestable({ | ||
| 1916 | + group: 1 | ||
| 1917 | + }).on('change', function(){ | ||
| 1918 | + console.log($('.nestable-page-list').nestable('serialize')); | ||
| 1919 | + }); // activate Nestable for list 2 | ||
| 1920 | + | ||
| 1921 | + $('body').on( 'click', function(e) { | ||
| 1922 | + $('[data-toggle=popover], .popover-link').each(function () { | ||
| 1923 | + // hide any open popovers when the anywhere else in the body is clicked | ||
| 1924 | + if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) { | ||
| 1925 | + $(this).popover('hide'); | ||
| 1926 | + } | ||
| 1927 | + }); | ||
| 1928 | + }); | ||
| 1885 | 1929 | ||
| 1886 | }); | 1930 | }); |
| 1887 | 1931 |
| @@ -64,16 +64,9 @@ jQuery(document).ready(function(){ | @@ -64,16 +64,9 @@ jQuery(document).ready(function(){ | ||
| 64 | html: true, | 64 | html: true, |
| 65 | trigger: 'manual' | 65 | trigger: 'manual' |
| 66 | }).on('hidden.bs.popover', function () { | 66 | }).on('hidden.bs.popover', function () { |
| 67 | - $this.popover('destroy'); | 67 | + $this.popover('dispose'); |
| 68 | }).popover('show'); | 68 | }).popover('show'); |
| 69 | 69 | ||
| 70 | - $('body').on( 'click', function(e) { | ||
| 71 | - if($this.next('.popover')){ | ||
| 72 | - if ( !$this.next('.popover').has(e.target).length ) {$this.popover('destroy'); } | ||
| 73 | - } | ||
| 74 | - }); | ||
| 75 | - | ||
| 76 | - | ||
| 77 | return false; | 70 | return false; |
| 78 | }); | 71 | }); |
| 79 | 72 | ||
| @@ -175,6 +168,8 @@ jQuery(document).ready(function(){ | @@ -175,6 +168,8 @@ jQuery(document).ready(function(){ | ||
| 175 | $('.html-generator').on('click', '.col-operation .col-duplicate, .row-operation .col-duplicate', function(){ | 168 | $('.html-generator').on('click', '.col-operation .col-duplicate, .row-operation .col-duplicate', function(){ |
| 176 | var $this = $(this); | 169 | var $this = $(this); |
| 177 | 170 | ||
| 171 | + $('body').trigger('click'); | ||
| 172 | + | ||
| 178 | if ($this.closest('.row-element-row').length > 0 && $this.closest('.col').length == 0){ | 173 | if ($this.closest('.row-element-row').length > 0 && $this.closest('.col').length == 0){ |
| 179 | var ids = []; | 174 | var ids = []; |
| 180 | var $row = $this.closest('.row-element-row'); | 175 | var $row = $this.closest('.row-element-row'); |
| @@ -436,7 +431,46 @@ jQuery(document).ready(function(){ | @@ -436,7 +431,46 @@ jQuery(document).ready(function(){ | ||
| 436 | return false; | 431 | return false; |
| 437 | }); | 432 | }); |
| 438 | 433 | ||
| 434 | + var showCellAction = function(statusClass){ | ||
| 435 | + var content = '<div class="col-operation">'+ | ||
| 436 | + '<div class="dropdown">' + | ||
| 437 | + '<button class="btn-xs btn-outline-primary dropdown-toggle dropdown-toggle-nocaret" type="button" data-toggle="dropdown" aria-expanded="false">' + | ||
| 438 | + '<span class="dropdown-text"><span class="icon icon-options-vertical"></span></span>' + | ||
| 439 | + '</button>' + | ||
| 440 | + '<ul class="dropdown-menu">' + | ||
| 441 | + '<li class="dropdown-item"><a class="col-disable" href="javascript;void(0);">'+ statusClass +'</a></li>' + | ||
| 442 | + '<li class="dropdown-item"><a class="col-duplicate" href="javascript;void(0);">Duplicate</a></li>' + | ||
| 443 | + '<li class="dropdown-item"><a class="col-content" href="javascript;void(0);">Content</a></li>' + | ||
| 444 | + '<li class="dropdown-item"><a class="col-edit popover-link" href="javascript;void(0);">Edit</a></li>' + | ||
| 445 | + '<li class="dropdown-item"><a class="col-remove" href="javascript;void(0);">Remove</a></li>' + | ||
| 446 | + '</ul>'+ | ||
| 447 | + '</div>' + | ||
| 448 | + '</div>'; | ||
| 449 | + | ||
| 450 | + return content; | ||
| 451 | + }; | ||
| 439 | 452 | ||
| 453 | + var showRowAction = function(statusClass, isBlockElement){ | ||
| 454 | + var content = '<div class="row-operation">'+ | ||
| 455 | + '<div class="dropdown">' + | ||
| 456 | + '<button class="btn-xs btn-outline-primary dropdown-toggle dropdown-toggle-nocaret" type="button" data-toggle="dropdown" aria-expanded="false">' + | ||
| 457 | + '<span class="dropdown-text"><span class="icon icon-options-vertical"></span></span>' + | ||
| 458 | + '</button>' + | ||
| 459 | + '<ul class="dropdown-menu">' + | ||
| 460 | + '<li class="dropdown-item"><a class="col-disable" href="javascript;void(0);">'+ statusClass +'</a></li>' + | ||
| 461 | + '<li class="dropdown-item"><a class="col-duplicate" href="javascript;void(0);">Duplicate</a></li>'; | ||
| 462 | + | ||
| 463 | + if (isBlockElement){ | ||
| 464 | + content += '<li class="dropdown-item"><a class="col-content" href="javascript;void(0);">Content</a></li>'; | ||
| 465 | + } | ||
| 466 | + content += '<li class="dropdown-item"><a class="row-remove" href="javascript;void(0);">Remove</a></li>'; | ||
| 467 | + | ||
| 468 | + content += '</ul>'+ | ||
| 469 | + '</div>' + | ||
| 470 | + '</div>'; | ||
| 471 | + | ||
| 472 | + return content; | ||
| 473 | + } | ||
| 440 | 474 | ||
| 441 | 475 | ||
| 442 | $('.html-generator').each(function(){ | 476 | $('.html-generator').each(function(){ |
| @@ -477,21 +511,15 @@ jQuery(document).ready(function(){ | @@ -477,21 +511,15 @@ jQuery(document).ready(function(){ | ||
| 477 | statusClass = ''; | 511 | statusClass = ''; |
| 478 | 512 | ||
| 479 | if($this.data('status') == 'enabled'){ | 513 | if($this.data('status') == 'enabled'){ |
| 480 | - statusClass = 'glyphicon-eye-open'; | 514 | + statusClass = 'Disable'; |
| 481 | }else{ | 515 | }else{ |
| 482 | - statusClass = 'glyphicon-eye-close'; | 516 | + statusClass = 'Enable'; |
| 483 | } | 517 | } |
| 484 | 518 | ||
| 485 | var innerContent = '<div class="col-inner">' + | 519 | var innerContent = '<div class="col-inner">' + |
| 486 | '<div class="col-html">'+ html +'</div>' + | 520 | '<div class="col-html">'+ html +'</div>' + |
| 487 | - '<div class="col-operation">' + | ||
| 488 | - '<a class="col-disable" href="javascript;void(0);"><i class="glyphicon '+ statusClass +'"></i></a>' + | ||
| 489 | - '<a class="col-duplicate" href="javascript;void(0);"><i class="glyphicon glyphicon-file"></i></a>' + | ||
| 490 | - '<a class="col-content" href="javascript;void(0);"><i class="glyphicon glyphicon-pencil"></i></a>' + | ||
| 491 | - '<a class="col-edit" href="javascript;void(0);"><i class="glyphicon glyphicon-cog"></i></a>' + | ||
| 492 | - '<a class="col-remove" href="javascript;void(0);"><i class="glyphicon glyphicon-trash"></i></a>' + | ||
| 493 | - '</div>' + | ||
| 494 | - '</div>'; | 521 | + '<div class="col-operation">' + showCellAction(statusClass) + '</div>' + |
| 522 | + '</div>'; | ||
| 495 | 523 | ||
| 496 | $(this).html(innerContent); | 524 | $(this).html(innerContent); |
| 497 | }); | 525 | }); |
| @@ -502,23 +530,12 @@ jQuery(document).ready(function(){ | @@ -502,23 +530,12 @@ jQuery(document).ready(function(){ | ||
| 502 | statusClass = ''; | 530 | statusClass = ''; |
| 503 | 531 | ||
| 504 | if($cell.data('status') == 'enabled'){ | 532 | if($cell.data('status') == 'enabled'){ |
| 505 | - statusClass = 'glyphicon-eye-open'; | 533 | + statusClass = 'Disable'; |
| 506 | }else{ | 534 | }else{ |
| 507 | - statusClass = 'glyphicon-eye-close'; | 535 | + statusClass = 'Enable'; |
| 508 | } | 536 | } |
| 509 | 537 | ||
| 510 | - var innerContent = '<div class="row-inner">' + | ||
| 511 | - '<div class="row-operation">' + | ||
| 512 | - '<a class="row-remove" href="javascript;void(0);"><i class="glyphicon glyphicon-trash"></i></a>'; | ||
| 513 | - | ||
| 514 | - innerContent += '<a class="col-disable" href="javascript;void(0);"><i class="glyphicon '+ statusClass +'"></i></a>'; | ||
| 515 | - innerContent += '<a class="col-duplicate" href="javascript;void(0);"><i class="glyphicon glyphicon-file"></i></a>'; | ||
| 516 | - | ||
| 517 | - if($(this).hasClass('row-element-block')) { | ||
| 518 | - innerContent += '<a class="col-content" href="javascript;void(0);"><i class="glyphicon glyphicon-pencil"></i></a>'; | ||
| 519 | - } | ||
| 520 | - innerContent += '</div>' + | ||
| 521 | - '</div>'; | 538 | + var innerContent = '<div class="row-inner">' + showRowAction(statusClass, $(this).hasClass('row-element-block')) + '</div>'; |
| 522 | $(this).prepend(innerContent); | 539 | $(this).prepend(innerContent); |
| 523 | 540 | ||
| 524 | if($(this).hasClass('row-element-row')) { | 541 | if($(this).hasClass('row-element-row')) { |
| @@ -580,14 +597,7 @@ jQuery(document).ready(function(){ | @@ -580,14 +597,7 @@ jQuery(document).ready(function(){ | ||
| 580 | 597 | ||
| 581 | var $newContent = $('<div class="col-md-1 col" data-size="1" data-offset="0" >' + | 598 | var $newContent = $('<div class="col-md-1 col" data-size="1" data-offset="0" >' + |
| 582 | '<div class="col-inner">' + | 599 | '<div class="col-inner">' + |
| 583 | - '<div class="col-html"></div>' + | ||
| 584 | - '<div class="col-operation">' + | ||
| 585 | - '<a class="col-disable" href="javascript;void(0);"><i class="glyphicon glyphicon-eye-open"></i></a>' + | ||
| 586 | - '<a class="col-duplicate" href="javascript;void(0);"><i class="glyphicon glyphicon-file"></i></a>' + | ||
| 587 | - '<a class="col-content" href="javascript;void(0);"><i class="glyphicon glyphicon-pencil"></i></a>' + | ||
| 588 | - '<a class="col-edit" href="javascript;void(0);"><i class="glyphicon glyphicon-cog"></i></a>' + | ||
| 589 | - '<a class="col-remove" href="javascript;void(0);"><i class="glyphicon glyphicon-trash"></i></a>' + | ||
| 590 | - '</div>' + | 600 | + '<div class="col-html"></div>' + showCellAction('Disable') + |
| 591 | '</div>' + | 601 | '</div>' + |
| 592 | '</div>'); | 602 | '</div>'); |
| 593 | 603 | ||
| @@ -631,25 +641,14 @@ jQuery(document).ready(function(){ | @@ -631,25 +641,14 @@ jQuery(document).ready(function(){ | ||
| 631 | if(ui.draggable.hasClass('element-row') || ui.draggable.hasClass('element-block') ) { | 641 | if(ui.draggable.hasClass('element-row') || ui.draggable.hasClass('element-block') ) { |
| 632 | if(ui.draggable.hasClass('element-row')){ | 642 | if(ui.draggable.hasClass('element-row')){ |
| 633 | var $newContent = $('<div class="row-fluid row-element-row">' + | 643 | var $newContent = $('<div class="row-fluid row-element-row">' + |
| 634 | - '<div class="row-inner">' + | ||
| 635 | - '<div class="row-operation">' + | ||
| 636 | - '<a class="col-disable" href="javascript;void(0);"><i class="glyphicon glyphicon-eye-open"></i></a>' + | ||
| 637 | - '<a class="col-duplicate" href="javascript;void(0);"><i class="glyphicon glyphicon-file"></i></a>' + | ||
| 638 | - '<a class="row-remove" href="javascript;void(0);"><i class="glyphicon glyphicon-trash"></i></a>' + | ||
| 639 | - '</div>' + | 644 | + '<div class="row-inner">' + showRowAction('Disable', false) + |
| 640 | '</div>' + | 645 | '</div>' + |
| 641 | '</div>'); | 646 | '</div>'); |
| 642 | } | 647 | } |
| 643 | 648 | ||
| 644 | if(ui.draggable.hasClass('element-block')){ | 649 | if(ui.draggable.hasClass('element-block')){ |
| 645 | var $newContent = $('<div class="row-fluid row-element-block">' + | 650 | var $newContent = $('<div class="row-fluid row-element-block">' + |
| 646 | - '<div class="row-inner">' + | ||
| 647 | - '<div class="row-operation">' + | ||
| 648 | - '<a class="col-disable" href="javascript;void(0);"><i class="glyphicon glyphicon-eye-open"></i></a>' + | ||
| 649 | - '<a class="col-duplicate" href="javascript;void(0);"><i class="glyphicon glyphicon-file"></i></a>' + | ||
| 650 | - '<a class="col-content" href="javascript;void(0);"><i class="glyphicon glyphicon-pencil"></i></a>' + | ||
| 651 | - '<a class="row-remove" href="javascript;void(0);"><i class="glyphicon glyphicon-trash"></i></a>' + | ||
| 652 | - '</div>' + | 651 | + '<div class="row-inner">' + showRowAction('Disable', true) + |
| 653 | '</div>' + | 652 | '</div>' + |
| 654 | '</div>'); | 653 | '</div>'); |
| 655 | var max_id = getNextStructureId(); | 654 | var max_id = getNextStructureId(); |
| 1 | +/*! | ||
| 2 | + * Nestable jQuery Plugin - Copyright (c) 2012 David Bushell - http://dbushell.com/ | ||
| 3 | + * Dual-licensed under the BSD or MIT licenses | ||
| 4 | + */ | ||
| 5 | +;(function($, window, document, undefined) | ||
| 6 | +{ | ||
| 7 | + var hasTouch = 'ontouchstart' in document; | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * Detect CSS pointer-events property | ||
| 11 | + * events are normally disabled on the dragging element to avoid conflicts | ||
| 12 | + * https://github.com/ausi/Feature-detection-technique-for-pointer-events/blob/master/modernizr-pointerevents.js | ||
| 13 | + */ | ||
| 14 | + var hasPointerEvents = (function() | ||
| 15 | + { | ||
| 16 | + var el = document.createElement('div'), | ||
| 17 | + docEl = document.documentElement; | ||
| 18 | + if (!('pointerEvents' in el.style)) { | ||
| 19 | + return false; | ||
| 20 | + } | ||
| 21 | + el.style.pointerEvents = 'auto'; | ||
| 22 | + el.style.pointerEvents = 'x'; | ||
| 23 | + docEl.appendChild(el); | ||
| 24 | + var supports = window.getComputedStyle && window.getComputedStyle(el, '').pointerEvents === 'auto'; | ||
| 25 | + docEl.removeChild(el); | ||
| 26 | + return !!supports; | ||
| 27 | + })(); | ||
| 28 | + | ||
| 29 | + var defaults = { | ||
| 30 | + listNodeName : 'ol', | ||
| 31 | + itemNodeName : 'li', | ||
| 32 | + rootClass : 'dd', | ||
| 33 | + listClass : 'dd-list', | ||
| 34 | + itemClass : 'dd-item', | ||
| 35 | + dragClass : 'dd-dragel', | ||
| 36 | + handleClass : 'dd-handle', | ||
| 37 | + collapsedClass : 'dd-collapsed', | ||
| 38 | + placeClass : 'dd-placeholder', | ||
| 39 | + noDragClass : 'dd-nodrag', | ||
| 40 | + emptyClass : 'dd-empty', | ||
| 41 | + expandBtnHTML : '<button data-action="expand" type="button">Expand</button>', | ||
| 42 | + collapseBtnHTML : '<button data-action="collapse" type="button">Collapse</button>', | ||
| 43 | + group : 0, | ||
| 44 | + maxDepth : 5, | ||
| 45 | + threshold : 20 | ||
| 46 | + }; | ||
| 47 | + | ||
| 48 | + function Plugin(element, options) | ||
| 49 | + { | ||
| 50 | + this.w = $(document); | ||
| 51 | + this.el = $(element); | ||
| 52 | + this.options = $.extend({}, defaults, options); | ||
| 53 | + this.init(); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + Plugin.prototype = { | ||
| 57 | + | ||
| 58 | + init: function() | ||
| 59 | + { | ||
| 60 | + var list = this; | ||
| 61 | + | ||
| 62 | + list.reset(); | ||
| 63 | + | ||
| 64 | + list.el.data('nestable-group', this.options.group); | ||
| 65 | + | ||
| 66 | + list.placeEl = $('<div class="' + list.options.placeClass + '"/>'); | ||
| 67 | + | ||
| 68 | + $.each(this.el.find(list.options.itemNodeName), function(k, el) { | ||
| 69 | + list.setParent($(el)); | ||
| 70 | + }); | ||
| 71 | + | ||
| 72 | + list.el.on('click', 'button', function(e) { | ||
| 73 | + if (list.dragEl) { | ||
| 74 | + return; | ||
| 75 | + } | ||
| 76 | + var target = $(e.currentTarget), | ||
| 77 | + action = target.data('action'), | ||
| 78 | + item = target.parent(list.options.itemNodeName); | ||
| 79 | + if (action === 'collapse') { | ||
| 80 | + list.collapseItem(item); | ||
| 81 | + } | ||
| 82 | + if (action === 'expand') { | ||
| 83 | + list.expandItem(item); | ||
| 84 | + } | ||
| 85 | + }); | ||
| 86 | + | ||
| 87 | + var onStartEvent = function(e) | ||
| 88 | + { | ||
| 89 | + var handle = $(e.target); | ||
| 90 | + if (!handle.hasClass(list.options.handleClass)) { | ||
| 91 | + if (handle.closest('.' + list.options.noDragClass).length) { | ||
| 92 | + return; | ||
| 93 | + } | ||
| 94 | + handle = handle.closest('.' + list.options.handleClass); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + if (!handle.length || list.dragEl) { | ||
| 98 | + return; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + list.isTouch = /^touch/.test(e.type); | ||
| 102 | + if (list.isTouch && e.touches.length !== 1) { | ||
| 103 | + return; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + e.preventDefault(); | ||
| 107 | + list.dragStart(e.touches ? e.touches[0] : e); | ||
| 108 | + }; | ||
| 109 | + | ||
| 110 | + var onMoveEvent = function(e) | ||
| 111 | + { | ||
| 112 | + if (list.dragEl) { | ||
| 113 | + e.preventDefault(); | ||
| 114 | + list.dragMove(e.touches ? e.touches[0] : e); | ||
| 115 | + } | ||
| 116 | + }; | ||
| 117 | + | ||
| 118 | + var onEndEvent = function(e) | ||
| 119 | + { | ||
| 120 | + if (list.dragEl) { | ||
| 121 | + e.preventDefault(); | ||
| 122 | + list.dragStop(e.touches ? e.touches[0] : e); | ||
| 123 | + } | ||
| 124 | + }; | ||
| 125 | + | ||
| 126 | + if (hasTouch) { | ||
| 127 | + list.el[0].addEventListener('touchstart', onStartEvent, false); | ||
| 128 | + window.addEventListener('touchmove', onMoveEvent, false); | ||
| 129 | + window.addEventListener('touchend', onEndEvent, false); | ||
| 130 | + window.addEventListener('touchcancel', onEndEvent, false); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + list.el.on('mousedown', onStartEvent); | ||
| 134 | + list.w.on('mousemove', onMoveEvent); | ||
| 135 | + list.w.on('mouseup', onEndEvent); | ||
| 136 | + | ||
| 137 | + }, | ||
| 138 | + | ||
| 139 | + serialize: function() | ||
| 140 | + { | ||
| 141 | + var data, | ||
| 142 | + depth = 0, | ||
| 143 | + list = this; | ||
| 144 | + step = function(level, depth) | ||
| 145 | + { | ||
| 146 | + var array = [ ], | ||
| 147 | + items = level.children(list.options.itemNodeName); | ||
| 148 | + items.each(function() | ||
| 149 | + { | ||
| 150 | + var li = $(this), | ||
| 151 | + item = $.extend({}, li.data()), | ||
| 152 | + sub = li.children(list.options.listNodeName); | ||
| 153 | + if (sub.length) { | ||
| 154 | + item.children = step(sub, depth + 1); | ||
| 155 | + } | ||
| 156 | + array.push(item); | ||
| 157 | + }); | ||
| 158 | + return array; | ||
| 159 | + }; | ||
| 160 | + data = step(list.el.find(list.options.listNodeName).first(), depth); | ||
| 161 | + return data; | ||
| 162 | + }, | ||
| 163 | + | ||
| 164 | + serialise: function() | ||
| 165 | + { | ||
| 166 | + return this.serialize(); | ||
| 167 | + }, | ||
| 168 | + | ||
| 169 | + reset: function() | ||
| 170 | + { | ||
| 171 | + this.mouse = { | ||
| 172 | + offsetX : 0, | ||
| 173 | + offsetY : 0, | ||
| 174 | + startX : 0, | ||
| 175 | + startY : 0, | ||
| 176 | + lastX : 0, | ||
| 177 | + lastY : 0, | ||
| 178 | + nowX : 0, | ||
| 179 | + nowY : 0, | ||
| 180 | + distX : 0, | ||
| 181 | + distY : 0, | ||
| 182 | + dirAx : 0, | ||
| 183 | + dirX : 0, | ||
| 184 | + dirY : 0, | ||
| 185 | + lastDirX : 0, | ||
| 186 | + lastDirY : 0, | ||
| 187 | + distAxX : 0, | ||
| 188 | + distAxY : 0 | ||
| 189 | + }; | ||
| 190 | + this.isTouch = false; | ||
| 191 | + this.moving = false; | ||
| 192 | + this.dragEl = null; | ||
| 193 | + this.dragRootEl = null; | ||
| 194 | + this.dragDepth = 0; | ||
| 195 | + this.hasNewRoot = false; | ||
| 196 | + this.pointEl = null; | ||
| 197 | + }, | ||
| 198 | + | ||
| 199 | + expandItem: function(li) | ||
| 200 | + { | ||
| 201 | + li.removeClass(this.options.collapsedClass); | ||
| 202 | + li.children('[data-action="expand"]').hide(); | ||
| 203 | + li.children('[data-action="collapse"]').show(); | ||
| 204 | + li.children(this.options.listNodeName).show(); | ||
| 205 | + }, | ||
| 206 | + | ||
| 207 | + collapseItem: function(li) | ||
| 208 | + { | ||
| 209 | + var lists = li.children(this.options.listNodeName); | ||
| 210 | + if (lists.length) { | ||
| 211 | + li.addClass(this.options.collapsedClass); | ||
| 212 | + li.children('[data-action="collapse"]').hide(); | ||
| 213 | + li.children('[data-action="expand"]').show(); | ||
| 214 | + li.children(this.options.listNodeName).hide(); | ||
| 215 | + } | ||
| 216 | + }, | ||
| 217 | + | ||
| 218 | + expandAll: function() | ||
| 219 | + { | ||
| 220 | + var list = this; | ||
| 221 | + list.el.find(list.options.itemNodeName).each(function() { | ||
| 222 | + list.expandItem($(this)); | ||
| 223 | + }); | ||
| 224 | + }, | ||
| 225 | + | ||
| 226 | + collapseAll: function() | ||
| 227 | + { | ||
| 228 | + var list = this; | ||
| 229 | + list.el.find(list.options.itemNodeName).each(function() { | ||
| 230 | + list.collapseItem($(this)); | ||
| 231 | + }); | ||
| 232 | + }, | ||
| 233 | + | ||
| 234 | + setParent: function(li) | ||
| 235 | + { | ||
| 236 | + if (li.children(this.options.listNodeName).length) { | ||
| 237 | + li.prepend($(this.options.expandBtnHTML)); | ||
| 238 | + li.prepend($(this.options.collapseBtnHTML)); | ||
| 239 | + } | ||
| 240 | + li.children('[data-action="expand"]').hide(); | ||
| 241 | + }, | ||
| 242 | + | ||
| 243 | + unsetParent: function(li) | ||
| 244 | + { | ||
| 245 | + li.removeClass(this.options.collapsedClass); | ||
| 246 | + li.children('[data-action]').remove(); | ||
| 247 | + li.children(this.options.listNodeName).remove(); | ||
| 248 | + }, | ||
| 249 | + | ||
| 250 | + dragStart: function(e) | ||
| 251 | + { | ||
| 252 | + var mouse = this.mouse, | ||
| 253 | + target = $(e.target), | ||
| 254 | + dragItem = target.closest(this.options.itemNodeName); | ||
| 255 | + | ||
| 256 | + this.placeEl.css('height', dragItem.height()); | ||
| 257 | + | ||
| 258 | + mouse.offsetX = e.offsetX !== undefined ? e.offsetX : e.pageX - target.offset().left; | ||
| 259 | + mouse.offsetY = e.offsetY !== undefined ? e.offsetY : e.pageY - target.offset().top; | ||
| 260 | + mouse.startX = mouse.lastX = e.pageX; | ||
| 261 | + mouse.startY = mouse.lastY = e.pageY; | ||
| 262 | + | ||
| 263 | + this.dragRootEl = this.el; | ||
| 264 | + | ||
| 265 | + this.dragEl = $(document.createElement(this.options.listNodeName)).addClass(this.options.listClass + ' ' + this.options.dragClass); | ||
| 266 | + this.dragEl.css('width', dragItem.width()); | ||
| 267 | + | ||
| 268 | + dragItem.after(this.placeEl); | ||
| 269 | + dragItem[0].parentNode.removeChild(dragItem[0]); | ||
| 270 | + dragItem.appendTo(this.dragEl); | ||
| 271 | + | ||
| 272 | + $(document.body).append(this.dragEl); | ||
| 273 | + this.dragEl.css({ | ||
| 274 | + 'left' : e.pageX - mouse.offsetX, | ||
| 275 | + 'top' : e.pageY - mouse.offsetY | ||
| 276 | + }); | ||
| 277 | + // total depth of dragging item | ||
| 278 | + var i, depth, | ||
| 279 | + items = this.dragEl.find(this.options.itemNodeName); | ||
| 280 | + for (i = 0; i < items.length; i++) { | ||
| 281 | + depth = $(items[i]).parents(this.options.listNodeName).length; | ||
| 282 | + if (depth > this.dragDepth) { | ||
| 283 | + this.dragDepth = depth; | ||
| 284 | + } | ||
| 285 | + } | ||
| 286 | + }, | ||
| 287 | + | ||
| 288 | + dragStop: function(e) | ||
| 289 | + { | ||
| 290 | + var el = this.dragEl.children(this.options.itemNodeName).first(); | ||
| 291 | + el[0].parentNode.removeChild(el[0]); | ||
| 292 | + this.placeEl.replaceWith(el); | ||
| 293 | + | ||
| 294 | + this.dragEl.remove(); | ||
| 295 | + this.el.trigger('change'); | ||
| 296 | + if (this.hasNewRoot) { | ||
| 297 | + this.dragRootEl.trigger('change'); | ||
| 298 | + } | ||
| 299 | + this.reset(); | ||
| 300 | + }, | ||
| 301 | + | ||
| 302 | + dragMove: function(e) | ||
| 303 | + { | ||
| 304 | + var list, parent, prev, next, depth, | ||
| 305 | + opt = this.options, | ||
| 306 | + mouse = this.mouse; | ||
| 307 | + | ||
| 308 | + this.dragEl.css({ | ||
| 309 | + 'left' : e.pageX - mouse.offsetX, | ||
| 310 | + 'top' : e.pageY - mouse.offsetY | ||
| 311 | + }); | ||
| 312 | + | ||
| 313 | + // mouse position last events | ||
| 314 | + mouse.lastX = mouse.nowX; | ||
| 315 | + mouse.lastY = mouse.nowY; | ||
| 316 | + // mouse position this events | ||
| 317 | + mouse.nowX = e.pageX; | ||
| 318 | + mouse.nowY = e.pageY; | ||
| 319 | + // distance mouse moved between events | ||
| 320 | + mouse.distX = mouse.nowX - mouse.lastX; | ||
| 321 | + mouse.distY = mouse.nowY - mouse.lastY; | ||
| 322 | + // direction mouse was moving | ||
| 323 | + mouse.lastDirX = mouse.dirX; | ||
| 324 | + mouse.lastDirY = mouse.dirY; | ||
| 325 | + // direction mouse is now moving (on both axis) | ||
| 326 | + mouse.dirX = mouse.distX === 0 ? 0 : mouse.distX > 0 ? 1 : -1; | ||
| 327 | + mouse.dirY = mouse.distY === 0 ? 0 : mouse.distY > 0 ? 1 : -1; | ||
| 328 | + // axis mouse is now moving on | ||
| 329 | + var newAx = Math.abs(mouse.distX) > Math.abs(mouse.distY) ? 1 : 0; | ||
| 330 | + | ||
| 331 | + // do nothing on first move | ||
| 332 | + if (!mouse.moving) { | ||
| 333 | + mouse.dirAx = newAx; | ||
| 334 | + mouse.moving = true; | ||
| 335 | + return; | ||
| 336 | + } | ||
| 337 | + | ||
| 338 | + // calc distance moved on this axis (and direction) | ||
| 339 | + if (mouse.dirAx !== newAx) { | ||
| 340 | + mouse.distAxX = 0; | ||
| 341 | + mouse.distAxY = 0; | ||
| 342 | + } else { | ||
| 343 | + mouse.distAxX += Math.abs(mouse.distX); | ||
| 344 | + if (mouse.dirX !== 0 && mouse.dirX !== mouse.lastDirX) { | ||
| 345 | + mouse.distAxX = 0; | ||
| 346 | + } | ||
| 347 | + mouse.distAxY += Math.abs(mouse.distY); | ||
| 348 | + if (mouse.dirY !== 0 && mouse.dirY !== mouse.lastDirY) { | ||
| 349 | + mouse.distAxY = 0; | ||
| 350 | + } | ||
| 351 | + } | ||
| 352 | + mouse.dirAx = newAx; | ||
| 353 | + | ||
| 354 | + /** | ||
| 355 | + * move horizontal | ||
| 356 | + */ | ||
| 357 | + if (mouse.dirAx && mouse.distAxX >= opt.threshold) { | ||
| 358 | + // reset move distance on x-axis for new phase | ||
| 359 | + mouse.distAxX = 0; | ||
| 360 | + prev = this.placeEl.prev(opt.itemNodeName); | ||
| 361 | + // increase horizontal level if previous sibling exists and is not collapsed | ||
| 362 | + if (mouse.distX > 0 && prev.length && !prev.hasClass(opt.collapsedClass)) { | ||
| 363 | + // cannot increase level when item above is collapsed | ||
| 364 | + list = prev.find(opt.listNodeName).last(); | ||
| 365 | + // check if depth limit has reached | ||
| 366 | + depth = this.placeEl.parents(opt.listNodeName).length; | ||
| 367 | + if (depth + this.dragDepth <= opt.maxDepth) { | ||
| 368 | + // create new sub-level if one doesn't exist | ||
| 369 | + if (!list.length) { | ||
| 370 | + list = $('<' + opt.listNodeName + '/>').addClass(opt.listClass); | ||
| 371 | + list.append(this.placeEl); | ||
| 372 | + prev.append(list); | ||
| 373 | + this.setParent(prev); | ||
| 374 | + } else { | ||
| 375 | + // else append to next level up | ||
| 376 | + list = prev.children(opt.listNodeName).last(); | ||
| 377 | + list.append(this.placeEl); | ||
| 378 | + } | ||
| 379 | + } | ||
| 380 | + } | ||
| 381 | + // decrease horizontal level | ||
| 382 | + if (mouse.distX < 0) { | ||
| 383 | + // we can't decrease a level if an item preceeds the current one | ||
| 384 | + next = this.placeEl.next(opt.itemNodeName); | ||
| 385 | + if (!next.length) { | ||
| 386 | + parent = this.placeEl.parent(); | ||
| 387 | + this.placeEl.closest(opt.itemNodeName).after(this.placeEl); | ||
| 388 | + if (!parent.children().length) { | ||
| 389 | + this.unsetParent(parent.parent()); | ||
| 390 | + } | ||
| 391 | + } | ||
| 392 | + } | ||
| 393 | + } | ||
| 394 | + | ||
| 395 | + var isEmpty = false; | ||
| 396 | + | ||
| 397 | + // find list item under cursor | ||
| 398 | + if (!hasPointerEvents) { | ||
| 399 | + this.dragEl[0].style.visibility = 'hidden'; | ||
| 400 | + } | ||
| 401 | + this.pointEl = $(document.elementFromPoint(e.pageX - document.body.scrollLeft, e.pageY - (window.pageYOffset || document.documentElement.scrollTop))); | ||
| 402 | + if (!hasPointerEvents) { | ||
| 403 | + this.dragEl[0].style.visibility = 'visible'; | ||
| 404 | + } | ||
| 405 | + if (this.pointEl.hasClass(opt.handleClass)) { | ||
| 406 | + this.pointEl = this.pointEl.parent(opt.itemNodeName); | ||
| 407 | + } | ||
| 408 | + if (this.pointEl.hasClass(opt.emptyClass)) { | ||
| 409 | + isEmpty = true; | ||
| 410 | + } | ||
| 411 | + else if (!this.pointEl.length || !this.pointEl.hasClass(opt.itemClass)) { | ||
| 412 | + return; | ||
| 413 | + } | ||
| 414 | + | ||
| 415 | + // find parent list of item under cursor | ||
| 416 | + var pointElRoot = this.pointEl.closest('.' + opt.rootClass), | ||
| 417 | + isNewRoot = this.dragRootEl.data('nestable-id') !== pointElRoot.data('nestable-id'); | ||
| 418 | + | ||
| 419 | + /** | ||
| 420 | + * move vertical | ||
| 421 | + */ | ||
| 422 | + if (!mouse.dirAx || isNewRoot || isEmpty) { | ||
| 423 | + // check if groups match if dragging over new root | ||
| 424 | + if (isNewRoot && opt.group !== pointElRoot.data('nestable-group')) { | ||
| 425 | + return; | ||
| 426 | + } | ||
| 427 | + // check depth limit | ||
| 428 | + depth = this.dragDepth - 1 + this.pointEl.parents(opt.listNodeName).length; | ||
| 429 | + if (depth > opt.maxDepth) { | ||
| 430 | + return; | ||
| 431 | + } | ||
| 432 | + var before = e.pageY < (this.pointEl.offset().top + this.pointEl.height() / 2); | ||
| 433 | + parent = this.placeEl.parent(); | ||
| 434 | + // if empty create new list to replace empty placeholder | ||
| 435 | + if (isEmpty) { | ||
| 436 | + list = $(document.createElement(opt.listNodeName)).addClass(opt.listClass); | ||
| 437 | + list.append(this.placeEl); | ||
| 438 | + this.pointEl.replaceWith(list); | ||
| 439 | + } | ||
| 440 | + else if (before) { | ||
| 441 | + this.pointEl.before(this.placeEl); | ||
| 442 | + } | ||
| 443 | + else { | ||
| 444 | + this.pointEl.after(this.placeEl); | ||
| 445 | + } | ||
| 446 | + if (!parent.children().length) { | ||
| 447 | + this.unsetParent(parent.parent()); | ||
| 448 | + } | ||
| 449 | + if (!this.dragRootEl.find(opt.itemNodeName).length) { | ||
| 450 | + this.dragRootEl.append('<div class="' + opt.emptyClass + '"/>'); | ||
| 451 | + } | ||
| 452 | + // parent root list has changed | ||
| 453 | + if (isNewRoot) { | ||
| 454 | + this.dragRootEl = pointElRoot; | ||
| 455 | + this.hasNewRoot = this.el[0] !== this.dragRootEl[0]; | ||
| 456 | + } | ||
| 457 | + } | ||
| 458 | + } | ||
| 459 | + | ||
| 460 | + }; | ||
| 461 | + | ||
| 462 | + $.fn.nestable = function(params) | ||
| 463 | + { | ||
| 464 | + var lists = this, | ||
| 465 | + retval = this; | ||
| 466 | + | ||
| 467 | + lists.each(function() | ||
| 468 | + { | ||
| 469 | + var plugin = $(this).data("nestable"); | ||
| 470 | + | ||
| 471 | + if (!plugin) { | ||
| 472 | + $(this).data("nestable", new Plugin(this, params)); | ||
| 473 | + $(this).data("nestable-id", new Date().getTime()); | ||
| 474 | + } else { | ||
| 475 | + if (typeof params === 'string' && typeof plugin[params] === 'function') { | ||
| 476 | + retval = plugin[params](); | ||
| 477 | + } | ||
| 478 | + } | ||
| 479 | + }); | ||
| 480 | + | ||
| 481 | + return retval || lists; | ||
| 482 | + }; | ||
| 483 | + | ||
| 484 | +})(window.jQuery || window.Zepto, window, document); |
| @@ -5209,6 +5209,7 @@ body .jvectormap-zoomout { | @@ -5209,6 +5209,7 @@ body .jvectormap-zoomout { | ||
| 5209 | 5209 | ||
| 5210 | .html-generator .html-content .row-inner{ | 5210 | .html-generator .html-content .row-inner{ |
| 5211 | position:relative; | 5211 | position:relative; |
| 5212 | + width:100%; | ||
| 5212 | } | 5213 | } |
| 5213 | 5214 | ||
| 5214 | 5215 |
| 1 | +.page-list { | ||
| 2 | + .dd3-content{ | ||
| 3 | + padding: 10px 100px 10px 65px; | ||
| 4 | + } | ||
| 5 | +} | ||
| 6 | + | ||
| 7 | +.dd3-handle.dd3-page-list-handle{ | ||
| 8 | + height: 82px !important; | ||
| 9 | +} | ||
| 10 | + | ||
| 11 | +.dd3-action{ | ||
| 12 | + position: absolute; | ||
| 13 | + top: 0px; | ||
| 14 | + right: 0; | ||
| 15 | + height: 82px; | ||
| 16 | + .dropdown .btn{ | ||
| 17 | + height: 82px; | ||
| 18 | + } | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +.dd-full-width{ | ||
| 22 | + max-width:100% !important; | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +.text-in-one-string{ | ||
| 26 | + white-space: nowrap; | ||
| 27 | + overflow: hidden; | ||
| 28 | + display: block; | ||
| 29 | + text-overflow: ellipsis; | ||
| 30 | + float: none; | ||
| 31 | +} |
| 1 | module Kanjai | 1 | module Kanjai |
| 2 | class Admin::ImagesController < AdminController | 2 | class Admin::ImagesController < AdminController |
| 3 | 3 | ||
| 4 | + before_action :generate_s3_options, only: [:index, :edit] | ||
| 5 | + | ||
| 4 | def index | 6 | def index |
| 5 | - @s3_direct_post = S3_BUCKET.presigned_post(key: "#{Image.get_image_file_path}${filename}", success_action_status: '201', acl: 'public-read') | 7 | + |
| 6 | end | 8 | end |
| 7 | 9 | ||
| 8 | def list | 10 | def list |
| @@ -14,6 +16,20 @@ module Kanjai | @@ -14,6 +16,20 @@ module Kanjai | ||
| 14 | render partial: 'kanjai/admin/images/gallery_exist_images', locals: {collection: collection} | 16 | render partial: 'kanjai/admin/images/gallery_exist_images', locals: {collection: collection} |
| 15 | end | 17 | end |
| 16 | 18 | ||
| 19 | + def edit | ||
| 20 | + @file = Kanjai::Image.find(params[:id]) | ||
| 21 | + render layout: false | ||
| 22 | + end | ||
| 23 | + | ||
| 24 | + def update | ||
| 25 | + @file = Kanjai::Image.find(params[:id]) | ||
| 26 | + if @file.update(permitted_params[:image]) | ||
| 27 | + render json: {status: 'ok', id: @file.id, link: @file.image_link} | ||
| 28 | + else | ||
| 29 | + render json: {status: 'error', message: @file.errors.full_message} | ||
| 30 | + end | ||
| 31 | + end | ||
| 32 | + | ||
| 17 | def update_gallery | 33 | def update_gallery |
| 18 | params[:gallery_image] ||= {} | 34 | params[:gallery_image] ||= {} |
| 19 | params[:gallery_image].each do |key, data| | 35 | params[:gallery_image].each do |key, data| |
| @@ -44,7 +60,14 @@ module Kanjai | @@ -44,7 +60,14 @@ module Kanjai | ||
| 44 | render :layout => false | 60 | render :layout => false |
| 45 | end | 61 | end |
| 46 | 62 | ||
| 63 | + private | ||
| 47 | 64 | ||
| 65 | + def generate_s3_options | ||
| 66 | + @s3_direct_post = S3_BUCKET.presigned_post(key: "#{Image.get_image_file_path}${filename}", success_action_status: '201', acl: 'public-read') | ||
| 67 | + end | ||
| 48 | 68 | ||
| 69 | + def permitted_params | ||
| 70 | + params.permit(:image => [:title, :tag_list, :image_link]) | ||
| 71 | + end | ||
| 49 | end | 72 | end |
| 50 | end | 73 | end |
| @@ -43,6 +43,9 @@ module Kanjai | @@ -43,6 +43,9 @@ module Kanjai | ||
| 43 | def edit | 43 | def edit |
| 44 | @page = Page.find(params[:id]) | 44 | @page = Page.find(params[:id]) |
| 45 | @page_data = @page.page_data.find_by_lang(params[:lang]) | 45 | @page_data = @page.page_data.find_by_lang(params[:lang]) |
| 46 | + | ||
| 47 | + @step = 'general' | ||
| 48 | + | ||
| 46 | if @page_data.nil? | 49 | if @page_data.nil? |
| 47 | @page_data = @page.page_data.new( | 50 | @page_data = @page.page_data.new( |
| 48 | lang: params[:lang] | 51 | lang: params[:lang] |
| @@ -53,6 +56,8 @@ module Kanjai | @@ -53,6 +56,8 @@ module Kanjai | ||
| 53 | 56 | ||
| 54 | def update | 57 | def update |
| 55 | @page = Page.find(params[:id]) | 58 | @page = Page.find(params[:id]) |
| 59 | + @page_data = @page.page_data.find_by_lang(params[:lang]) | ||
| 60 | + @step = 'general' | ||
| 56 | if @page.update(permitted_params[:page]) | 61 | if @page.update(permitted_params[:page]) |
| 57 | 62 | ||
| 58 | if @page.default_private_page | 63 | if @page.default_private_page |
| @@ -194,19 +199,16 @@ module Kanjai | @@ -194,19 +199,16 @@ module Kanjai | ||
| 194 | end | 199 | end |
| 195 | 200 | ||
| 196 | 201 | ||
| 197 | - def meta | ||
| 198 | - @page = Page.find(params[:id]) | ||
| 199 | - @page_data = @page.page_data.find_by_lang(params[:lang]) | ||
| 200 | - end | ||
| 201 | - | ||
| 202 | def meta_update | 202 | def meta_update |
| 203 | @page = Page.find(params[:id]) | 203 | @page = Page.find(params[:id]) |
| 204 | @page_data = @page.page_data.find_by_lang(params[:lang]) | 204 | @page_data = @page.page_data.find_by_lang(params[:lang]) |
| 205 | 205 | ||
| 206 | + @step = 'meta' | ||
| 207 | + | ||
| 206 | if @page_data.update(permitted_params[:page_datum]) | 208 | if @page_data.update(permitted_params[:page_datum]) |
| 207 | redirect_to :action => :index | 209 | redirect_to :action => :index |
| 208 | else | 210 | else |
| 209 | - render :action => :meta, lang: params[:lang] | 211 | + render :action => :edit, lang: params[:lang] |
| 210 | end | 212 | end |
| 211 | 213 | ||
| 212 | end | 214 | end |
| @@ -119,7 +119,7 @@ module Kanjai | @@ -119,7 +119,7 @@ module Kanjai | ||
| 119 | if self.type_content == 'rte_editor' | 119 | if self.type_content == 'rte_editor' |
| 120 | self.text_html.to_s | 120 | self.text_html.to_s |
| 121 | elsif self.type_content == 'plugin' | 121 | elsif self.type_content == 'plugin' |
| 122 | - self.controller_name + '.' + self.action_name | 122 | + self.controller_name.to_s + '.' + self.action_name.to_s |
| 123 | else | 123 | else |
| 124 | self.type_content | 124 | self.type_content |
| 125 | end | 125 | end |
| @@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
| 14 | <span class="dropdown-text"><span class="icon icon-options-vertical"></span></span> | 14 | <span class="dropdown-text"><span class="icon icon-options-vertical"></span></span> |
| 15 | </button> | 15 | </button> |
| 16 | <ul class="dropdown-menu" style="padding-left:0;"> | 16 | <ul class="dropdown-menu" style="padding-left:0;"> |
| 17 | - <li class="dropdown-item"><%= link_to t('action.edit'), edit_admin_image_url(item), class: 'dropdown-item' %></li> | 17 | + <li class="dropdown-item"><%= link_to t('action.edit'), edit_admin_image_url(item), class: 'dropdown-item show-in-layer', remote: true %></li> |
| 18 | <li class="dropdown-item"><%= link_to t('action.delete'), delete_gallery_image_admin_image_path(item), remote: true, :class => 'dropdown-item' %></li> | 18 | <li class="dropdown-item"><%= link_to t('action.delete'), delete_gallery_image_admin_image_path(item), remote: true, :class => 'dropdown-item' %></li> |
| 19 | </ul> | 19 | </ul> |
| 20 | </div> | 20 | </div> |
app/views/kanjai/admin/images/edit.html.erb
0 → 100644
| 1 | +<div class="modal" id="myModal"> | ||
| 2 | + <div class="modal-dialog"> | ||
| 3 | + <div class="modal-content"> | ||
| 4 | + | ||
| 5 | + <!-- Modal Header --> | ||
| 6 | + <div class="modal-header"> | ||
| 7 | + <h4 class="modal-title">Edit File</h4> | ||
| 8 | + <button type="button" class="close" data-dismiss="modal">×</button> | ||
| 9 | + </div> | ||
| 10 | + | ||
| 11 | + <div> | ||
| 12 | + <%= image_tag @file.image_link, class: 'img-fluid', alt: '' %> | ||
| 13 | + </div> | ||
| 14 | + | ||
| 15 | + <!-- Modal body --> | ||
| 16 | + <div class="modal-body"> | ||
| 17 | + <%= form_for @file, url: admin_image_path(@file), html: {class: 'form-horizontal ajax-file-upload-form simple_submit edit-file-form', remote: true, method: 'PUT', novalidate: '', data: {parsley_validate: ''}} do |f| %> | ||
| 18 | + <div class='error-message'></div> | ||
| 19 | + | ||
| 20 | + <fieldset> | ||
| 21 | + <div class="form-group row"> | ||
| 22 | + <label class="col-md-2 col-form-label">Name</label> | ||
| 23 | + <div class="col-md-10"> | ||
| 24 | + <%= f.text_field :title, class: 'form-control' %> | ||
| 25 | + <input class="form-control file-type" type="hidden" name="type" > | ||
| 26 | + </div> | ||
| 27 | + </div> | ||
| 28 | + </fieldset> | ||
| 29 | + | ||
| 30 | + <fieldset> | ||
| 31 | + <div class="form-group row"> | ||
| 32 | + <label class="col-md-2 col-form-label">Tags</label> | ||
| 33 | + <div class="col-md-10"> | ||
| 34 | + <%= f.text_field :tag_list, class: 'form-control', data: {role: 'tagsinput'} %> | ||
| 35 | + </div> | ||
| 36 | + </div> | ||
| 37 | + </fieldset> | ||
| 38 | + | ||
| 39 | + <fieldset> | ||
| 40 | + <div class="form-group row"> | ||
| 41 | + <%= f.label :image_link, 'Image', :class => "col-md-2 col-form-label" %> | ||
| 42 | + <div class="col-md-10"> | ||
| 43 | + <%= f.file_field :image_link, :class => "form-control filestyle", 'data-url' => @s3_direct_post.url, 'data-form-data' => @s3_direct_post.fields.to_json, 'data-host' => URI.parse(@s3_direct_post.url).host , 'data-type' => 'zip', 'data-classbutton' => 'btn btn-secondary', 'data-classinput' => "form-control inline", 'data-icon' => "<span class='fa fa-upload mr-2'></span>" %> | ||
| 44 | + </div> | ||
| 45 | + </div> | ||
| 46 | + </fieldset> | ||
| 47 | + | ||
| 48 | + <div class="card-footer mt-20"> | ||
| 49 | + <div class="clearfix"> | ||
| 50 | + <div class="float-right"> | ||
| 51 | + <%= link_to t('actions.cancel'), '#', class: 'btn btn-secondary', data: {dismiss: 'modal'} %> | ||
| 52 | + <button class="btn btn-primary" type="submit"><%= t('actions.save') %></button> | ||
| 53 | + </div> | ||
| 54 | + </div> | ||
| 55 | + </div> | ||
| 56 | + | ||
| 57 | + <% end %> | ||
| 58 | + </div> | ||
| 59 | + | ||
| 60 | + </div> | ||
| 61 | + </div> | ||
| 62 | +</div> |
| 1 | -<div class="form-group"> | ||
| 2 | - <%= form.label :parent_id, t('activerecord.attributes.page.parent_id'), :class => "col-sm-2 control-label" %> | ||
| 3 | - <div class="col-sm-10"> | ||
| 4 | - <%= form.select :parent_id, @pages.collect{|p| [p[:title], p[:id], :style => "padding-left:#{p[:level]*10}px;"] }, {:include_blank => true}, :class => "form-control" %> | ||
| 5 | - </div> | ||
| 6 | -</div> | ||
| 7 | - | ||
| 8 | -<div class="form-group"> | ||
| 9 | - <%= form.label :title, t('activerecord.attributes.page.title') + '*', :class => "col-sm-2 control-label" %> | ||
| 10 | - <div class="col-sm-10"> | ||
| 11 | - <%= form.text_field :title, :class => "form-control" %> | ||
| 12 | - </div> | ||
| 13 | -</div> | ||
| 14 | - | ||
| 15 | -<div class="form-group"> | ||
| 16 | - <%= form.label :url, t('activerecord.attributes.page.url') + '*', :class => "col-sm-2 control-label" %> | ||
| 17 | - <div class="col-sm-10"> | ||
| 18 | - <%= form.text_field :url, :class => "form-control" %> | ||
| 19 | - </div> | ||
| 20 | -</div> | ||
| 21 | - | ||
| 22 | -<div class="form-group"> | ||
| 23 | - <%= form.label :type_page, t('activerecord.attributes.page.type_page') + '*', :class => "col-sm-2 control-label" %> | ||
| 24 | - <div class="col-sm-10"> | ||
| 25 | - <div class="checkbox"> | ||
| 26 | - <label> | ||
| 27 | - <%= form.radio_button :type_page, 'html' %> | ||
| 28 | - <%= t('admin.pages.type_page.html') %> | ||
| 29 | - </label> | ||
| 30 | - <label> | ||
| 31 | - <%= form.radio_button :type_page, 'markdown' %> | ||
| 32 | - <%= t('admin.pages.type_page.markdown') %> | ||
| 33 | - </label> | ||
| 34 | - </div> | ||
| 35 | - </div> | 1 | +<div role="tabpanel"> |
| 2 | + <!-- Nav tabs--> | ||
| 3 | + <% unless @page.new_record? %> | ||
| 4 | + <ul class="nav nav-tabs" role="tablist"> | ||
| 5 | + <li class="nav-item" role="presentation"><a class="nav-link <%= @step == 'general' ? 'active' : '' %>" href="#general" aria-controls="general" role="tab" data-toggle="tab">General</a></li> | ||
| 6 | + <li class="nav-item" role="presentation"><a class="nav-link <%= @step == 'meta' ? 'active' : '' %>" href="#meta" aria-controls="meta" role="tab" data-toggle="tab">Meta</a></li> | ||
| 7 | + <li class="nav-item" role="presentation"><a class="nav-link" href="#content" aria-controls="content" role="tab" data-toggle="tab">Content</a></li> | ||
| 8 | + </ul><!-- Tab panes--> | ||
| 9 | + <% end %> | ||
| 10 | + <div class="tab-content"> | ||
| 11 | + <div class="tab-pane <%= @step == 'general' || @page.new_record? ? 'active' : '' %>" id="general" role="tabpanel"><%= render partial: 'kanjai/admin/pages/panels/general' %></div> | ||
| 12 | + <% unless @page.new_record? %> | ||
| 13 | + <div class="tab-pane <%= @step == 'meta' ? 'active' : '' %>" id="meta" role="tabpanel"><%= render partial: 'kanjai/admin/pages/panels/meta' %></div> | ||
| 14 | + <div class="tab-pane" id="content" role="tabpanel"><%= render partial: 'kanjai/admin/pages/panels/content' %></div> | ||
| 15 | + <% end %> | ||
| 16 | + </div> | ||
| 36 | </div> | 17 | </div> |
| 1 | +<div class="form-group"> | ||
| 2 | + <%= form.label :parent_id, t('activerecord.attributes.page.parent_id'), :class => "col-sm-2 control-label" %> | ||
| 3 | + <div class="col-sm-10"> | ||
| 4 | + <%= form.select :parent_id, @pages.collect{|p| [p[:title], p[:id], :style => "padding-left:#{p[:level]*10}px;"] }, {:include_blank => true}, :class => "form-control" %> | ||
| 5 | + </div> | ||
| 6 | +</div> | ||
| 7 | + | ||
| 8 | +<div class="form-group"> | ||
| 9 | + <%= form.label :title, t('activerecord.attributes.page.title') + '*', :class => "col-sm-2 control-label" %> | ||
| 10 | + <div class="col-sm-10"> | ||
| 11 | + <%= form.text_field :title, :class => "form-control" %> | ||
| 12 | + </div> | ||
| 13 | +</div> | ||
| 14 | + | ||
| 15 | +<div class="form-group"> | ||
| 16 | + <%= form.label :url, t('activerecord.attributes.page.url') + '*', :class => "col-sm-2 control-label" %> | ||
| 17 | + <div class="col-sm-10"> | ||
| 18 | + <%= form.text_field :url, :class => "form-control" %> | ||
| 19 | + </div> | ||
| 20 | +</div> | ||
| 21 | + | ||
| 22 | +<div class="form-group"> | ||
| 23 | + <%= form.label :type_page, t('activerecord.attributes.page.type_page') + '*', :class => "col-sm-2 control-label" %> | ||
| 24 | + <div class="col-sm-10"> | ||
| 25 | + <div class="checkbox"> | ||
| 26 | + <label> | ||
| 27 | + <%= form.radio_button :type_page, 'html' %> | ||
| 28 | + <%= t('admin.pages.type_page.html') %> | ||
| 29 | + </label> | ||
| 30 | + <label> | ||
| 31 | + <%= form.radio_button :type_page, 'markdown' %> | ||
| 32 | + <%= t('admin.pages.type_page.markdown') %> | ||
| 33 | + </label> | ||
| 34 | + </div> | ||
| 35 | + </div> | ||
| 36 | +</div> |
| 1 | +<% collection.each do |page| %> | ||
| 2 | + <li class="dd-item dd3-item" data-id="<%= page.id %>"> | ||
| 3 | + <div class="dd-handle dd3-handle dd3-page-list-handle"> </div> | ||
| 4 | + <div class="dd3-content"> | ||
| 5 | + <div class="text-in-one-string">Page Name: <%= page.lang_attributes(Kanjai::PageLang.default, :title) %></div> | ||
| 6 | + <div class="text-in-one-string">Template: <%= page.page_template.title if page.page_template %></div> | ||
| 7 | + <div class="text-in-one-string">URL: <%= page.lang_attributes(Kanjai::PageLang.default, :url) %></div> | ||
| 8 | + </div> | ||
| 9 | + <div class="dd3-action"> | ||
| 10 | + <div class="dropdown"> | ||
| 11 | + <button class="btn btn-secondary dropdown-toggle dropdown-toggle-nocaret" type="button" data-toggle="dropdown" aria-expanded="false"> | ||
| 12 | + <span class="dropdown-text"><span class="icon icon-options-vertical"></span></span> | ||
| 13 | + </button> | ||
| 14 | + <ul class="dropdown-menu"> | ||
| 15 | + <li class="dropdown-item"> | ||
| 16 | + <% if page.active? %> | ||
| 17 | + <%= link_to 'Disable', deactivate_admin_page_url(page), class: 'dropdown-item' %> | ||
| 18 | + <% else %> | ||
| 19 | + <%= link_to 'Enable', activate_admin_page_url(page), class: 'dropdown-item' %> | ||
| 20 | + <% end %> | ||
| 21 | + </li> | ||
| 22 | + <% Kanjai::PageLang.all.each do |lang| %> | ||
| 23 | + <li class="dropdown-item"> | ||
| 24 | + <%= link_to "Edit #{lang.code}", edit_admin_page_url(page, :lang => lang.code), class: 'dropdown-item' %> | ||
| 25 | + </li> | ||
| 26 | + <% end %> | ||
| 27 | + <li class="dropdown-item"> | ||
| 28 | + <%= link_to 'Duplicate', clone_admin_page_url(page), class: 'dropdown-item' %> | ||
| 29 | + </li> | ||
| 30 | + <li class="dropdown-item"><%= link_to t('delete_action'), admin_page_url(page), :class => 'delete-row-item dropdown-item' %></li> | ||
| 31 | + </ul> | ||
| 32 | + </div> | ||
| 33 | + </div> | ||
| 34 | + <% if page.children.count > 0 %> | ||
| 35 | + <ol class="dd-list"> | ||
| 36 | + <%= render partial: 'kanjai/admin/pages/page_block', locals: {collection: page.children.order(:position)} %> | ||
| 37 | + </ol> | ||
| 38 | + <% end %> | ||
| 39 | + </li> | ||
| 40 | +<% end %> |
| 1 | <%= fields_for @obj do |form| %> | 1 | <%= fields_for @obj do |form| %> |
| 2 | 2 | ||
| 3 | - <div class="form-group"> | ||
| 4 | - <%= form.label :controller_name, :class => "control-label" %> | ||
| 5 | - <%= form.text_field :controller_name, :class => "form-control" %> | 3 | + <div class="form-group row"> |
| 4 | + <%= form.label :controller_name, :class => "col-md-2 col-form-label" %> | ||
| 5 | + <div class="col-md-10"> | ||
| 6 | + <%= form.text_field :controller_name, :class => "form-control" %> | ||
| 7 | + </div> | ||
| 6 | </div> | 8 | </div> |
| 7 | 9 | ||
| 8 | - <div class="form-group"> | ||
| 9 | - <%= form.label :action_name, :class => "control-label" %> | ||
| 10 | - <%= form.text_field :action_name, :class => "form-control" %> | 10 | + <div class="form-group row"> |
| 11 | + <%= form.label :action_name, :class => "col-md-2 col-form-label" %> | ||
| 12 | + <div class="col-md-10"> | ||
| 13 | + <%= form.text_field :action_name, :class => "form-control" %> | ||
| 14 | + </div> | ||
| 11 | </div> | 15 | </div> |
| 12 | 16 | ||
| 13 | <% end %> | 17 | <% end %> |
| 1 | -<div class="container"> | ||
| 2 | - | ||
| 3 | - <h3><%= t('admin.pages.edit_page', title: @page.lang_attributes(Kanjai::PageLang.default, :title)) %></h3> | ||
| 4 | - | ||
| 5 | - | 1 | +<div class="content-wrapper"> |
| 6 | <div class="row"> | 2 | <div class="row"> |
| 7 | - <div class="col-md-10"> | ||
| 8 | - <%= render :partial => 'kanjai/shared/error_messages', :locals => {:target => @page} %> | ||
| 9 | - | ||
| 10 | - <%= form_for(@page, :url => admin_page_url(@page, :lang => params[:lang]), :html => {:class => "form-horizontal ajax-file-upload-form simple_submit"}) do |form| %> | ||
| 11 | - | ||
| 12 | - <h4><%= t('admin.pages.edit_general_content') %></h4> | ||
| 13 | - <div class="form-group"> | ||
| 14 | - <%= form.label :parent_id, t('activerecord.attributes.page.parent_id'), :class => "col-sm-2 control-label" %> | ||
| 15 | - <div class="col-sm-10"> | ||
| 16 | - <%= form.select :parent_id, @pages.collect{|p| [p[:title], p[:id], :style => "padding-left:#{p[:level]*10}px;"] }, {:include_blank => true}, :class => "form-control" %> | ||
| 17 | - </div> | ||
| 18 | - </div> | ||
| 19 | - | ||
| 20 | - <div class="form-group"> | ||
| 21 | - <%= form.label :page_template_id, t('activerecord.attributes.page.page_template_id'), :class => "col-sm-2 control-label" %> | ||
| 22 | - <div class="col-sm-10"> | ||
| 23 | - <%= form.select :page_template_id, Kanjai::PageTemplate.all.collect{|p| [p[:title], p[:id]] }, {:include_blank => true}, :class => "form-control" %> | ||
| 24 | - </div> | ||
| 25 | - </div> | ||
| 26 | - | ||
| 27 | - <div class="form-group"> | ||
| 28 | - <%= form.label :private_flag, t('activerecord.attributes.page.private_flag'), :class => "col-sm-2 control-label" %> | ||
| 29 | - <div class="col-sm-10"> | ||
| 30 | - <%= form.check_box :private_flag %> | ||
| 31 | - </div> | ||
| 32 | - </div> | ||
| 33 | - | ||
| 34 | - <div class="form-group"> | ||
| 35 | - <%= form.label :default_private_page, t('activerecord.attributes.page.default_private_page'), :class => "col-sm-2 control-label" %> | ||
| 36 | - <div class="col-sm-10"> | ||
| 37 | - <%= form.check_box :default_private_page %> | ||
| 38 | - </div> | ||
| 39 | - </div> | ||
| 40 | - | ||
| 41 | - <div class="form-group"> | ||
| 42 | - <%= form.label :root_page, t('activerecord.attributes.page.root_page'), :class => "col-sm-2 control-label" %> | ||
| 43 | - <div class="col-sm-10"> | ||
| 44 | - <%= form.check_box :root_page %> | ||
| 45 | - </div> | 3 | + <div class="col-xl-12"> |
| 4 | + | ||
| 5 | + | ||
| 6 | + <div class="card card-default"> | ||
| 7 | + <div class="card-header"> | ||
| 8 | + <div class="card-title"><%= t('admin.pages.edit', title: @page.lang_attributes(Kanjai::PageLang.default, :title)) %></div> | ||
| 9 | + </div> | ||
| 10 | + <%= render partial: 'form' %> | ||
| 46 | </div> | 11 | </div> |
| 12 | + | ||
| 47 | 13 | ||
| 48 | - <div class="form-group"> | ||
| 49 | - <%= form.label :show_public_only, t('activerecord.attributes.page.show_public_only'), :class => "col-sm-2 control-label" %> | ||
| 50 | - <div class="col-sm-10"> | ||
| 51 | - <%= form.check_box :show_public_only %> | ||
| 52 | - </div> | ||
| 53 | - </div> | ||
| 54 | - | ||
| 55 | - | ||
| 56 | - <h4><%= t('admin.pages.edit_lang_content', :lang => params[:lang]) %></h4> | ||
| 57 | - <%= form.fields_for :page_data, @page.page_data.where(lang: params[:lang]) do |form2| %> | ||
| 58 | - | ||
| 59 | - | ||
| 60 | - <div class="form-group"> | ||
| 61 | - <%= form2.label :title, t('activerecord.attributes.page.title') + '*', :class => "col-sm-2 control-label" %> | ||
| 62 | - <div class="col-sm-10"> | ||
| 63 | - <%= form2.text_field :title, :class => "form-control" %> | ||
| 64 | - </div> | ||
| 65 | - </div> | ||
| 66 | - | ||
| 67 | - <div class="form-group"> | ||
| 68 | - <%= form2.label :url, t('activerecord.attributes.page.url') + '*', :class => "col-sm-2 control-label" %> | ||
| 69 | - <div class="col-sm-10"> | ||
| 70 | - <%= form2.text_field :url, :class => "form-control" %> | ||
| 71 | - </div> | ||
| 72 | - </div> | ||
| 73 | - <% end %> | ||
| 74 | - | ||
| 75 | - <%= render :partial => 'kanjai/shared/edit_resource_links', locals: {collection_url: admin_pages_url} %> | ||
| 76 | - <% end %> | ||
| 77 | - </div> | ||
| 78 | - | ||
| 79 | - <div class="col-md-2"> | ||
| 80 | - <%= render :partial => 'operation' %> | ||
| 81 | </div> | 14 | </div> |
| 82 | - | ||
| 83 | </div> | 15 | </div> |
| 84 | - | ||
| 85 | - | ||
| 86 | </div> | 16 | </div> |
| 1 | -<div class="container"> | 1 | +<div class="content-wrapper"> |
| 2 | <div class="row"> | 2 | <div class="row"> |
| 3 | - <div class="col-md-8"> | ||
| 4 | - <h1><%= t('admin.pages.page_title') %></h1> | ||
| 5 | - </div> | ||
| 6 | - | ||
| 7 | - <div class="col-md-4 text-right"> | ||
| 8 | - <%= link_to t('admin.pages.add_new'), new_admin_page_url, class: 'btn btn-success' %> | 3 | + <div class="col-xl-12"> |
| 4 | + <!-- START card--> | ||
| 5 | + <div class="card card-default"> | ||
| 6 | + <div class="card-header"> | ||
| 7 | + <div class="row"> | ||
| 8 | + <div class="col-md-8"> | ||
| 9 | + <%= t('admin.pages.page_title') %> | ||
| 10 | + </div> | ||
| 11 | + <div class="col-md-4 text-right"> | ||
| 12 | + <%= link_to t('admin.pages.add_new'), new_admin_page_url, class: 'btn btn-primary' %> | ||
| 13 | + </div> | ||
| 14 | + </div> | ||
| 15 | + </div> | ||
| 16 | + <div class="card-body"> | ||
| 17 | + <div class="table-responsive"> | ||
| 18 | + <div class="nestable-page-list dd dd-full-width page-list"> | ||
| 19 | + <ol class="dd-list"> | ||
| 20 | + <%= render partial: 'kanjai/admin/pages/page_block', locals: {collection: Kanjai::Page.where(parent: nil).order(:position)} %> | ||
| 21 | + </ol> | ||
| 22 | + </div> | ||
| 23 | + </div> | ||
| 24 | + </div> | ||
| 25 | + </div><!-- END card--> | ||
| 9 | </div> | 26 | </div> |
| 10 | </div> | 27 | </div> |
| 11 | - <table class="table"> | ||
| 12 | - <% Kanjai::Page.walk_tree do |page, level| %> | ||
| 13 | - <tr data-level="<%= level %>"> | ||
| 14 | - <td style="padding-left:<%= 10 * level %>px;"><%= page.lang_attributes(Kanjai::PageLang.default, :title) %></td> | ||
| 15 | - <td><%= page.page_template.title if page.page_template %></td> | ||
| 16 | - | ||
| 17 | - <td width="200px;"> | ||
| 18 | - <% if page.active? %> | ||
| 19 | - <%= link_to deactivate_admin_page_url(page), class: 'btn btn-warning' do %> | ||
| 20 | - <i class="fa fa-eye"></i> | ||
| 21 | - <% end %> | ||
| 22 | - <% else %> | ||
| 23 | - <%= link_to activate_admin_page_url(page), class: 'btn btn-info' do %> | ||
| 24 | - <i class="fa fa-eye-slash"></i> | ||
| 25 | - <% end %> | ||
| 26 | - <% end %> | 28 | +</div> |
| 27 | 29 | ||
| 28 | - <%= link_to sort_admin_page_url(page, :direction => 'up'), class: 'btn btn-info' do %> | ||
| 29 | - <i class="fa fa-arrow-up"></i> | ||
| 30 | - <% end %> | ||
| 31 | - <%= link_to sort_admin_page_url(page, :direction => 'down'), class: 'btn btn-info' do %> | ||
| 32 | - <i class="fa fa-arrow-down"></i> | ||
| 33 | - <% end %> | ||
| 34 | - <%= link_to clone_admin_page_url(page), class: 'btn btn-warning' do %> | ||
| 35 | - <i class="fa fa-clone"></i> | ||
| 36 | - <% end %> | ||
| 37 | - <% Kanjai::PageLang.all.each do |lang| %> | ||
| 38 | - <%= link_to "Edit #{lang.code}", edit_admin_page_url(page, :lang => lang.code), class: 'btn btn-success' %> | ||
| 39 | - <% end %> | ||
| 40 | - <%= link_to admin_page_url(page), class: 'delete-row-item btn btn-danger', data: {placeholder: t('admin.pages.delete')} do %> | ||
| 41 | - <i class="fa fa-trash"></i> | ||
| 42 | - <% end %> | ||
| 43 | - </td> | ||
| 44 | - </tr> | ||
| 45 | - <% end %> | ||
| 46 | - </table> | ||
| 47 | 30 | ||
| 48 | -</div> |
| 1 | -<div class="container"> | ||
| 2 | - | ||
| 3 | - <h3><%= t('admin.pages.create_new_page') %></h3> | ||
| 4 | - | ||
| 5 | - | ||
| 6 | - | ||
| 7 | - <%= render :partial => 'kanjai/shared/error_messages', :locals => {:target => @page} %> | ||
| 8 | - | ||
| 9 | - <%= form_for(@page, :url => admin_pages_url, :html => {:class => "form-horizontal ajax-file-upload-form simple_submit"}) do |form| %> | ||
| 10 | - | ||
| 11 | - <div class="form-group"> | ||
| 12 | - <%= form.label :parent_id, t('activerecord.attributes.page.parent_id'), :class => "col-sm-2 control-label" %> | ||
| 13 | - <div class="col-sm-10"> | ||
| 14 | - <%= form.select :parent_id, @pages.collect{|p| [p[:title], p[:id], :style => "padding-left:#{p[:level]*10}px;"] }, {:include_blank => true}, :class => "form-control" %> | ||
| 15 | - </div> | ||
| 16 | - </div> | ||
| 17 | - | ||
| 18 | - <div class="form-group"> | ||
| 19 | - <%= form.label :title, t('activerecord.attributes.page.title'), :class => "col-sm-2 control-label" %> | ||
| 20 | - <div class="col-sm-10"> | ||
| 21 | - <%= form.text_field :title, :class => "form-control" %> | ||
| 22 | - </div> | ||
| 23 | - </div> | ||
| 24 | - | ||
| 25 | - <div class="form-group"> | ||
| 26 | - <%= form.label :page_template_id, t('activerecord.attributes.page.page_template_id'), :class => "col-sm-2 control-label" %> | ||
| 27 | - <div class="col-sm-10"> | ||
| 28 | - <%= form.select :page_template_id, Kanjai::PageTemplate.all.collect{|p| [p[:title], p[:id]] }, {:include_blank => true}, :class => "form-control" %> | ||
| 29 | - </div> | ||
| 30 | - </div> | ||
| 31 | - | ||
| 32 | - | ||
| 33 | - <div class="form-group"> | ||
| 34 | - <%= form.label :private_flag, t('activerecord.attributes.page.private_flag'), :class => "col-sm-2 control-label" %> | ||
| 35 | - <div class="col-sm-10"> | ||
| 36 | - <%= form.check_box :private_flag %> | ||
| 37 | - </div> | ||
| 38 | - </div> | ||
| 39 | - | ||
| 40 | - <div class="form-group"> | ||
| 41 | - <%= form.label :default_private_page, t('activerecord.attributes.page.default_private_page'), :class => "col-sm-2 control-label" %> | ||
| 42 | - <div class="col-sm-10"> | ||
| 43 | - <%= form.check_box :default_private_page %> | ||
| 44 | - </div> | ||
| 45 | - </div> | ||
| 46 | - | ||
| 47 | - <div class="form-group"> | ||
| 48 | - <%= form.label :root_page, t('activerecord.attributes.page.root_page'), :class => "col-sm-2 control-label" %> | ||
| 49 | - <div class="col-sm-10"> | ||
| 50 | - <%= form.check_box :root_page %> | ||
| 51 | - </div> | ||
| 52 | - </div> | ||
| 53 | - | ||
| 54 | - | ||
| 55 | - | ||
| 56 | - <%= render :partial => 'kanjai/shared/new_resource_links', locals: {collection_url: admin_pages_url} %> | ||
| 57 | - <% end %> | ||
| 58 | - | ||
| 59 | - | ||
| 60 | - | ||
| 61 | - | 1 | +<div class="content-wrapper"> |
| 2 | + <div class="row"> | ||
| 3 | + <div class="col-xl-12"> | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + <div class="card card-default"> | ||
| 7 | + <div class="card-header"> | ||
| 8 | + <div class="card-title"><%= t('admin.pages.create_new_page') %></div> | ||
| 9 | + </div> | ||
| 10 | + <%= render partial: 'form' %> | ||
| 11 | + </div> | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + </div> | ||
| 15 | + </div> | ||
| 62 | </div> | 16 | </div> |
| 1 | +<div class="container"> | ||
| 2 | + | ||
| 3 | + <h3><%= t('admin.pages.edit_page', title: @page.lang_attributes(Kanjai::PageLang.default, :title)) %></h3> | ||
| 4 | + | ||
| 5 | + <div class="row"> | ||
| 6 | + <div class="col-md-12 html-generator" data-editor-url="<%= show_editor_admin_page_url(@page_data.page, lang: params[:lang]) %>" data-save_url="<%= save_structure_admin_page_url(@page_data.page, lang: params[:lang]) %>" data-delete_cell_url="<%= delete_content_admin_page_url(@page_data.page, lang: params[:lang]) %>" data-duplicate-url="<%= duplicate_block_admin_page_url(@page_data.page, lang: params[:lang]) %>" > | ||
| 7 | + | ||
| 8 | + <div id="structure_area" > | ||
| 9 | + <div class="html-elements"> | ||
| 10 | + <div class="item label label-default element-row btn btn-primary">Row</div> | ||
| 11 | + <div class="item label label-default element-col btn btn-primary">Col</div> | ||
| 12 | + <div class="item label label-default element-block btn btn-primary">Block</div> | ||
| 13 | + </div> | ||
| 14 | + <div class="html-content container-fluid clearfix"><%= get_html_by_json(@page_data).html_safe %></div> | ||
| 15 | + <div class="html-elements"> | ||
| 16 | + <div class="item label label-default element-row btn btn-primary">Row</div> | ||
| 17 | + <div class="item label label-default element-col btn btn-primary">Col</div> | ||
| 18 | + <div class="item label label-default element-block btn btn-primary">Block</div> | ||
| 19 | + </div> | ||
| 20 | + | ||
| 21 | + <div class="card-footer mt-20"> | ||
| 22 | + <div class="clearfix"> | ||
| 23 | + <div class="float-right"> | ||
| 24 | + <%= link_to t('actions.cancel'), admin_pages_url, class: 'btn btn-secondary' %> | ||
| 25 | + <button class="btn btn-primary save" type="submit"><%= t('actions.save') %></button> | ||
| 26 | + </div> | ||
| 27 | + </div> | ||
| 28 | + </div> | ||
| 29 | + | ||
| 30 | + </div> | ||
| 31 | + <div id="work_area" style="position:relative;display:none;"> | ||
| 32 | + <div class="editor-content" style="min-height:500px;width:800px;"> | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + </div> | ||
| 36 | + <div class="wait-layer" style="position:absolute;top:0;left:0;width:800px;height:500px;background-color:#ffffff;">Please, wait ...</div> | ||
| 37 | + </div> | ||
| 38 | + | ||
| 39 | + </div> | ||
| 40 | + | ||
| 41 | + </div> | ||
| 42 | + | ||
| 43 | + | ||
| 44 | +</div> |
| 1 | +<%= form_for(@page, :url => (@page.new_record? ? admin_pages_url : admin_page_url(@page, :lang => params[:lang])), :html => {:class => "form-horizontal ajax-file-upload-form simple_submit"}) do |form| %> | ||
| 2 | + | ||
| 3 | + <fieldset> | ||
| 4 | + <legend><%= t('admin.pages.edit_general_content') %></legend> | ||
| 5 | + | ||
| 6 | + <% if @page.new_record? %> | ||
| 7 | + <div class="form-group row"> | ||
| 8 | + <%= form.label :title, t('activerecord.attributes.page.title'), :class => "col-md-2 col-form-label" %> | ||
| 9 | + <div class="col-md-10"> | ||
| 10 | + <%= form.text_field :title, :class => "form-control" %> | ||
| 11 | + <%= error_messages(@page, :title) %> | ||
| 12 | + </div> | ||
| 13 | + </div> | ||
| 14 | + <% end %> | ||
| 15 | + | ||
| 16 | + <div class="form-group row mt-2"> | ||
| 17 | + <%= form.label :parent_id, t('activerecord.attributes.page.parent_id'), :class => "col-md-2 col-form-label" %> | ||
| 18 | + <div class="col-md-10"> | ||
| 19 | + <%= form.select :parent_id, @pages.collect{|p| [p[:title], p[:id], :style => "padding-left:#{p[:level]*10}px;"] }, {:include_blank => true}, :class => "form-control #{@page.errors.include?(:parent_id) ? 'parsley-error' : ''}" %> | ||
| 20 | + <%= error_messages(@page, :parent_id) %> | ||
| 21 | + </div> | ||
| 22 | + </div> | ||
| 23 | + | ||
| 24 | + <div class="form-group row mt-2"> | ||
| 25 | + <%= form.label :page_template_id, t('activerecord.attributes.page.page_template_id'), :class => "col-sm-2 control-label" %> | ||
| 26 | + <div class="col-sm-10"> | ||
| 27 | + <%= form.select :page_template_id, Kanjai::PageTemplate.all.collect{|p| [p[:title], p[:id]] }, {:include_blank => true}, :class => "form-control #{@page.errors.include?(:page_template) ? 'parsley-error' : ''}" %> | ||
| 28 | + <%= error_messages(@page, :page_template) %> | ||
| 29 | + </div> | ||
| 30 | + </div> | ||
| 31 | + | ||
| 32 | + <div class="form-group row mt-2"> | ||
| 33 | + <%= form.label :root_page, Kanjai::Page.human_attribute_name(:root_page), class: 'col-md-2 col-form-label' %> | ||
| 34 | + <div class="col-md-10"> | ||
| 35 | + <label class="switch switch-lg"><%= form.check_box :root_page %><span></span></label> | ||
| 36 | + </div> | ||
| 37 | + </div> | ||
| 38 | + | ||
| 39 | + <div class="form-group row mt-2"> | ||
| 40 | + <%= form.label :private_flag, Kanjai::Page.human_attribute_name(:private_flag), class: 'col-md-2 col-form-label' %> | ||
| 41 | + <div class="col-md-10"> | ||
| 42 | + <label class="switch switch-lg"><%= form.check_box :private_flag %><span></span></label> | ||
| 43 | + </div> | ||
| 44 | + </div> | ||
| 45 | + | ||
| 46 | + <div class="form-group row mt-2"> | ||
| 47 | + <%= form.label :default_private_page, Kanjai::Page.human_attribute_name(:default_private_page), class: 'col-md-2 col-form-label' %> | ||
| 48 | + <div class="col-md-10"> | ||
| 49 | + <label class="switch switch-lg"><%= form.check_box :default_private_page %><span></span></label> | ||
| 50 | + </div> | ||
| 51 | + </div> | ||
| 52 | + | ||
| 53 | + <div class="form-group row mt-2"> | ||
| 54 | + <%= form.label :show_public_only, Kanjai::Page.human_attribute_name(:show_public_only), class: 'col-md-2 col-form-label' %> | ||
| 55 | + <div class="col-md-10"> | ||
| 56 | + <label class="switch switch-lg"><%= form.check_box :show_public_only %><span></span></label> | ||
| 57 | + </div> | ||
| 58 | + </div> | ||
| 59 | + </fieldset> | ||
| 60 | + | ||
| 61 | + <% unless @page.new_record? %> | ||
| 62 | + <fieldset> | ||
| 63 | + <legend><%= t('admin.pages.edit_lang_content', :lang => params[:lang]) %></legend> | ||
| 64 | + <%= form.fields_for :page_data, @page.page_data.where(lang: params[:lang]) do |form2| %> | ||
| 65 | + | ||
| 66 | + | ||
| 67 | + <div class="form-group row"> | ||
| 68 | + <%= form2.label :title, t('activerecord.attributes.page.title') + '*', :class => "col-sm-2 col-form-label" %> | ||
| 69 | + <div class="col-sm-10"> | ||
| 70 | + <%= form2.text_field :title, :class => "form-control" %> | ||
| 71 | + </div> | ||
| 72 | + </div> | ||
| 73 | + | ||
| 74 | + <div class="form-group row mt-2"> | ||
| 75 | + <%= form2.label :url, t('activerecord.attributes.page.url') + '*', :class => "col-sm-2 col-form-label" %> | ||
| 76 | + <div class="col-sm-10"> | ||
| 77 | + <%= form2.text_field :url, :class => "form-control" %> | ||
| 78 | + </div> | ||
| 79 | + </div> | ||
| 80 | + <% end %> | ||
| 81 | + </fieldset> | ||
| 82 | + <% end %> | ||
| 83 | + | ||
| 84 | + <div class="card-footer mt-20"> | ||
| 85 | + <div class="clearfix"> | ||
| 86 | + <div class="float-right"> | ||
| 87 | + <%= link_to t('actions.cancel'), admin_pages_url, class: 'btn btn-secondary' %> | ||
| 88 | + <button class="btn btn-primary" type="submit"><%= t('actions.save') %></button> | ||
| 89 | + </div> | ||
| 90 | + </div> | ||
| 91 | + </div> | ||
| 92 | + | ||
| 93 | +<% end %> |
| 1 | +<%= form_for(@page_data, :url => meta_update_admin_page_url(@page_data.page, :lang => params[:lang]), :html => {:class => "form-horizontal", method: 'POST'}) do |form| %> | ||
| 2 | + | ||
| 3 | + | ||
| 4 | + <div class="form-group row"> | ||
| 5 | + <%= form.label :meta_title, Kanjai::PageDatum.human_attribute_name(:meta_title), :class => "col-md-2 col-form-label" %> | ||
| 6 | + <div class="col-md-10"> | ||
| 7 | + <%= form.text_field :meta_title, :class => "form-control #{@page_data.errors.include?(:meta_title) ? 'parsley-error' : ''}" %> | ||
| 8 | + <%= error_messages(@page_data, :meta_title) %> | ||
| 9 | + </div> | ||
| 10 | + </div> | ||
| 11 | + | ||
| 12 | + <div class="form-group row"> | ||
| 13 | + <%= form.label :meta_description, Kanjai::PageDatum.human_attribute_name(:meta_description), :class => "col-md-2 col-form-label" %> | ||
| 14 | + <div class="col-md-10"> | ||
| 15 | + <%= form.text_field :meta_description, :class => "form-control" %> | ||
| 16 | + <%= error_messages(@page_data, :meta_description) %> | ||
| 17 | + </div> | ||
| 18 | + </div> | ||
| 19 | + | ||
| 20 | + <div class="form-group row"> | ||
| 21 | + <%= form.label :meta_keywords, Kanjai::PageDatum.human_attribute_name(:meta_keywords), :class => "col-md-2 col-form-label" %> | ||
| 22 | + <div class="col-md-10"> | ||
| 23 | + <%= form.text_field :meta_keywords, :class => "form-control" %> | ||
| 24 | + <%= error_messages(@page_data, :meta_keywords) %> | ||
| 25 | + </div> | ||
| 26 | + </div> | ||
| 27 | + | ||
| 28 | + <div class="card-footer mt-20"> | ||
| 29 | + <div class="clearfix"> | ||
| 30 | + <div class="float-right"> | ||
| 31 | + <%= link_to t('actions.cancel'), admin_pages_url, class: 'btn btn-secondary' %> | ||
| 32 | + <button class="btn btn-primary" type="submit"><%= t('actions.save') %></button> | ||
| 33 | + </div> | ||
| 34 | + </div> | ||
| 35 | + </div> | ||
| 36 | +<% end %> |
| 1 | <%= form_for(@obj, :url => update_editor_admin_page_url(@page, structure_id: @structure_id, lang: params[:lang]), :remote => true, :html => {:class => "content-form ajax-file-upload-form simple_submit", :method => 'POST'}) do |form| %> | 1 | <%= form_for(@obj, :url => update_editor_admin_page_url(@page, structure_id: @structure_id, lang: params[:lang]), :remote => true, :html => {:class => "content-form ajax-file-upload-form simple_submit", :method => 'POST'}) do |form| %> |
| 2 | <div class="clearfix content-type-wrapper"> | 2 | <div class="clearfix content-type-wrapper"> |
| 3 | - | ||
| 4 | - <div class="form-group"> | ||
| 5 | - <%= form.label :type_content, t('activerecord.attributes.page_content.type_content'), :class => "col-sm-2 control-label" %> | ||
| 6 | - <div class="col-sm-10"> | ||
| 7 | - <%= form.select :type_content, @type_contents, {}, :class => "form-control content-type", 'data-show_content_url' => url_for(:controller => 'kanjai/admin/page_contents', :action => 'show_content_form', :id => @obj.id) %> | ||
| 8 | - </div> | ||
| 9 | - </div> | ||
| 10 | - | ||
| 11 | - | ||
| 12 | - | 3 | + <div class="form-group row"> |
| 4 | + <%= form.label :type_content, t('activerecord.attributes.page_content.type_content'), :class => "col-md-2 col-form-label" %> | ||
| 5 | + <div class="col-md-10"> | ||
| 6 | + <%= form.select :type_content, @type_contents, {}, :class => "form-control content-type", 'data-show_content_url' => url_for(:controller => 'kanjai/admin/page_contents', :action => 'show_content_form', :id => @obj.id) %> | ||
| 7 | + </div> | ||
| 8 | + </div> | ||
| 13 | </div> | 9 | </div> |
| 14 | 10 | ||
| 15 | <div class="clearfix" id="page_content_form"> | 11 | <div class="clearfix" id="page_content_form"> |
| @@ -20,15 +16,16 @@ | @@ -20,15 +16,16 @@ | ||
| 20 | 16 | ||
| 21 | </div> | 17 | </div> |
| 22 | 18 | ||
| 23 | - <div style="padding-top:10px;"> | ||
| 24 | - <div class="form-group"> | ||
| 25 | - <div class="col-sm-offset-2 col-sm-10"> | ||
| 26 | - <%= submit_tag t('actions.create'), :class => 'btn btn-default' %> | ||
| 27 | - <%= link_to t('actions.cancel'), admin_pages_url, :class => "btn btn-cancel-edit-content" %> | 19 | + |
| 20 | + | ||
| 21 | + <div class="card-footer mt-20"> | ||
| 22 | + <div class="clearfix"> | ||
| 23 | + <div class="float-right"> | ||
| 24 | + <%= link_to t('actions.cancel'), admin_pages_url, class: 'btn btn-secondary' %> | ||
| 25 | + <button class="btn btn-primary" type="submit"><%= t('actions.save') %></button> | ||
| 28 | </div> | 26 | </div> |
| 29 | </div> | 27 | </div> |
| 30 | - | ||
| 31 | - </div> | 28 | + </div> |
| 32 | 29 | ||
| 33 | 30 | ||
| 34 | <% end %> | 31 | <% end %> |
| @@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
| 20 | <a href="#" class="btn btn-default save" >Save</a> | 20 | <a href="#" class="btn btn-default save" >Save</a> |
| 21 | </div> | 21 | </div> |
| 22 | <div id="work_area" style="position:relative;display:none;"> | 22 | <div id="work_area" style="position:relative;display:none;"> |
| 23 | - <div class="editor-content" style="height:500px;width:800px;"> | 23 | + <div class="editor-content" style="min-height:500px;width:800px;"> |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | </div> | 26 | </div> |
| @@ -27,7 +27,6 @@ Kanjai::Engine.routes.draw do | @@ -27,7 +27,6 @@ Kanjai::Engine.routes.draw do | ||
| 27 | resources :pages do | 27 | resources :pages do |
| 28 | get :markdown, on: :member | 28 | get :markdown, on: :member |
| 29 | get :html, on: :member | 29 | get :html, on: :member |
| 30 | - get :meta, on: :member | ||
| 31 | get :clone, on: :member | 30 | get :clone, on: :member |
| 32 | post :meta_update, on: :member | 31 | post :meta_update, on: :member |
| 33 | 32 |