|
@@ -1632,6 +1632,11 @@ jQuery(document).ready(function(){ |
|
@@ -1632,6 +1632,11 @@ jQuery(document).ready(function(){ |
|
1632
|
|
1632
|
|
|
1633
|
var galleryUrl = $this.$original_element.data('gallery-url');
|
1633
|
var galleryUrl = $this.$original_element.data('gallery-url');
|
|
1634
|
|
1634
|
|
|
|
|
1635
|
+
|
|
|
|
1636
|
+ var modalInitAction = function($modal){
|
|
|
|
1637
|
+
|
|
|
|
1638
|
+ }
|
|
|
|
1639
|
+
|
|
1635
|
jQuery.ajax({
|
1640
|
jQuery.ajax({
|
|
1636
|
type: 'POST',
|
1641
|
type: 'POST',
|
|
1637
|
url: galleryUrl,
|
1642
|
url: galleryUrl,
|
|
@@ -1639,7 +1644,7 @@ jQuery(document).ready(function(){ |
|
@@ -1639,7 +1644,7 @@ jQuery(document).ready(function(){ |
|
1639
|
var $modal = $(data).modal({show:false, keyboard: false, backdrop: 'static'}).on('shown.bs.modal', function () {
|
1644
|
var $modal = $(data).modal({show:false, keyboard: false, backdrop: 'static'}).on('shown.bs.modal', function () {
|
|
1640
|
var lastInsertImageId = undefined;
|
1645
|
var lastInsertImageId = undefined;
|
|
1641
|
|
1646
|
|
|
1642
|
- $modal.find('.gallery-item').click(function(){
|
1647
|
+ $modal.on('click', '.gallery-item', function(){
|
|
1643
|
var img_link = $(this).attr('href');
|
1648
|
var img_link = $(this).attr('href');
|
|
1644
|
var uniqueId = '_' + Math.random().toString(36).substr(2, 9);
|
1649
|
var uniqueId = '_' + Math.random().toString(36).substr(2, 9);
|
|
1645
|
|
1650
|
|
|
@@ -1654,8 +1659,30 @@ jQuery(document).ready(function(){ |
|
@@ -1654,8 +1659,30 @@ jQuery(document).ready(function(){ |
|
1654
|
|
1659
|
|
|
1655
|
return false;
|
1660
|
return false;
|
|
1656
|
});
|
1661
|
});
|
|
|
|
1662
|
+ initImageDragDrop();
|
|
|
|
1663
|
+
|
|
|
|
1664
|
+ $(window).bind('rteimages:update', function(){
|
|
|
|
1665
|
+ var $loader = $('.rte-images-for-choose').prev(),
|
|
|
|
1666
|
+ $images = $('.rte-images-for-choose');
|
|
|
|
1667
|
+
|
|
|
|
1668
|
+ $loader.removeClass('not-visible');
|
|
|
|
1669
|
+ $images.html('');
|
|
|
|
1670
|
+
|
|
|
|
1671
|
+ jQuery.ajax({
|
|
|
|
1672
|
+ type: 'POST',
|
|
|
|
1673
|
+ url: galleryUrl,
|
|
|
|
1674
|
+ success: function (data) {
|
|
|
|
1675
|
+ $('.rte-images-for-choose').replaceWith($(data).find('.rte-images-for-choose'));
|
|
|
|
1676
|
+ $loader.addClass('not-visible');
|
|
|
|
1677
|
+ $('.rte-add-image-back-btn').click();
|
|
|
|
1678
|
+ }
|
|
|
|
1679
|
+ });
|
|
|
|
1680
|
+
|
|
|
|
1681
|
+ });
|
|
|
|
1682
|
+
|
|
1657
|
}).on('hidden.bs.modal', function () {
|
1683
|
}).on('hidden.bs.modal', function () {
|
|
1658
|
$modal.remove();
|
1684
|
$modal.remove();
|
|
|
|
1685
|
+ $(window).unbind('rteimages:update');
|
|
1659
|
});
|
1686
|
});
|
|
1660
|
$modal.modal('show');
|
1687
|
$modal.modal('show');
|
|
1661
|
}
|
1688
|
}
|
|
@@ -1719,6 +1746,22 @@ jQuery(document).ready(function(){ |
|
@@ -1719,6 +1746,22 @@ jQuery(document).ready(function(){ |
|
1719
|
return false;
|
1746
|
return false;
|
|
1720
|
});
|
1747
|
});
|
|
1721
|
|
1748
|
|
|
|
|
1749
|
+ $(document).on('click', '.rte-add-image-btn', function(){
|
|
|
|
1750
|
+ $('.rte-add-image-back-btn').removeClass('not-visible');
|
|
|
|
1751
|
+ $(this).addClass('not-visible');
|
|
|
|
1752
|
+ $('.add-new-images').removeClass('not-visible');
|
|
|
|
1753
|
+ $('.rte-images-for-choose').addClass('not-visible');
|
|
|
|
1754
|
+ return false;
|
|
|
|
1755
|
+ });
|
|
|
|
1756
|
+ $(document).on('click', '.rte-add-image-back-btn', function(){
|
|
|
|
1757
|
+ $('.rte-add-image-back-btn').addClass('not-visible');
|
|
|
|
1758
|
+ $('.rte-add-image-btn').removeClass('not-visible');
|
|
|
|
1759
|
+ $('.add-new-images').addClass('not-visible');
|
|
|
|
1760
|
+ $('.rte-images-for-choose').removeClass('not-visible');
|
|
|
|
1761
|
+ return false;
|
|
|
|
1762
|
+ });
|
|
|
|
1763
|
+
|
|
|
|
1764
|
+
|
|
1722
|
if($('#epiceditor').length > 0){
|
1765
|
if($('#epiceditor').length > 0){
|
|
1723
|
var editor = new EpicEditor().load();
|
1766
|
var editor = new EpicEditor().load();
|
|
1724
|
$('.save-markdown-html').click(function(){
|
1767
|
$('.save-markdown-html').click(function(){
|
|
@@ -1755,117 +1798,120 @@ jQuery(document).ready(function(){ |
|
@@ -1755,117 +1798,120 @@ jQuery(document).ready(function(){ |
|
1755
|
// DRAG and DROP file
|
1798
|
// DRAG and DROP file
|
|
1756
|
var available_file_type = ['image/jpeg', 'image/pjpeg', 'image/png', 'image/gif'];
|
1799
|
var available_file_type = ['image/jpeg', 'image/pjpeg', 'image/png', 'image/gif'];
|
|
1757
|
|
1800
|
|
|
1758
|
- $('.drop-down-upload').each(function(){
|
|
|
|
1759
|
- var dropZone = $(this),
|
|
|
|
1760
|
- $dropWrapper = dropZone.find('.drop'),
|
|
|
|
1761
|
- upload_url = $dropWrapper.data('url'),
|
|
|
|
1762
|
- upload_form_data = $dropWrapper.data('form-data'),
|
|
|
|
1763
|
- upload_host = $dropWrapper.data('host'),
|
|
|
|
1764
|
- file_index = 0;
|
|
|
|
1765
|
-
|
|
|
|
1766
|
-
|
|
|
|
1767
|
- if (typeof(window.FileReader) == 'undefined') {
|
|
|
|
1768
|
- dropZone.html("your browser don't support this function");
|
|
|
|
1769
|
- }else {
|
|
|
|
1770
|
- dropZone[0].ondrop = function (e) {
|
|
|
|
1771
|
- e.preventDefault();
|
|
|
|
1772
|
- $.each(e.dataTransfer.files, function(){
|
|
|
|
1773
|
- var file = this,
|
|
|
|
1774
|
- input_name = "gallery_image[" + file_index + "]",
|
|
|
|
1775
|
- $fileInput = $('<div><input name="' + input_name + 'file" type="file" class="fileupload-field"></div>');
|
|
|
|
1776
|
-
|
|
|
|
1777
|
- file_index = file_index + 1;
|
|
|
|
1778
|
-
|
|
|
|
1779
|
- $fileInput.find('.fileupload-field').data('url', upload_url);
|
|
|
|
1780
|
- $fileInput.find('.fileupload-field').data('form-data', upload_form_data);
|
|
|
|
1781
|
- $fileInput.find('.fileupload-field').data('host', upload_host);
|
1801
|
+ var initImageDragDrop = function(){
|
|
|
|
1802
|
+ $('.drop-down-upload').each(function(){
|
|
|
|
1803
|
+ var dropZone = $(this),
|
|
|
|
1804
|
+ $dropWrapper = dropZone.find('.drop'),
|
|
|
|
1805
|
+ upload_url = $dropWrapper.data('url'),
|
|
|
|
1806
|
+ upload_form_data = $dropWrapper.data('form-data'),
|
|
|
|
1807
|
+ upload_host = $dropWrapper.data('host'),
|
|
|
|
1808
|
+ file_index = 0;
|
|
|
|
1809
|
+
|
|
|
|
1810
|
+
|
|
|
|
1811
|
+ if (typeof(window.FileReader) == 'undefined') {
|
|
|
|
1812
|
+ dropZone.html("your browser don't support this function");
|
|
|
|
1813
|
+ }else {
|
|
|
|
1814
|
+ dropZone[0].ondrop = function (e) {
|
|
|
|
1815
|
+ e.preventDefault();
|
|
|
|
1816
|
+ $.each(e.dataTransfer.files, function(){
|
|
|
|
1817
|
+ var file = this,
|
|
|
|
1818
|
+ input_name = "gallery_image[" + file_index + "]",
|
|
|
|
1819
|
+ $fileInput = $('<div><input name="' + input_name + 'file" type="file" class="fileupload-field"></div>');
|
|
|
|
1820
|
+
|
|
|
|
1821
|
+ file_index = file_index + 1;
|
|
|
|
1822
|
+
|
|
|
|
1823
|
+ $fileInput.find('.fileupload-field').data('url', upload_url);
|
|
|
|
1824
|
+ $fileInput.find('.fileupload-field').data('form-data', upload_form_data);
|
|
|
|
1825
|
+ $fileInput.find('.fileupload-field').data('host', upload_host);
|
|
|
|
1826
|
+
|
|
|
|
1827
|
+
|
|
|
|
1828
|
+ $fileInput.find('.fileupload-field').data('files', [{input_name: input_name + 'file', file: file}]);
|
|
|
|
1829
|
+
|
|
|
|
1830
|
+ var reader = new FileReader();
|
|
|
|
1831
|
+ reader.onload = function (evt) {
|
|
|
|
1832
|
+ var options = {
|
|
|
|
1833
|
+ showUpload:false,
|
|
|
|
1834
|
+ dropZoneEnabled: false,
|
|
|
|
1835
|
+ contentType: true,
|
|
|
|
1836
|
+ initialPreview: ["<img src='"+ evt.target.result +"' class='file-preview-image' alt='' title=''>"]
|
|
|
|
1837
|
+ };
|
|
|
|
1838
|
+
|
|
|
|
1839
|
+ $fileInput.find('.fileupload-field').fileinput(options);
|
|
|
|
1840
|
+
|
|
|
|
1841
|
+ $fileInput.find('.fileupload-field').on('fileclear', function(event) {
|
|
|
|
1842
|
+ if($(this).closest('.new-image-wrapper').length > 0){
|
|
|
|
1843
|
+ $(this).closest('.new-image-wrapper').remove();
|
|
|
|
1844
|
+ }else{
|
|
|
|
1845
|
+ $(this).closest('.file-input').remove();
|
|
|
|
1846
|
+ }
|
|
|
|
1847
|
+ });
|
|
1782
|
|
1848
|
|
|
|
|
1849
|
+ $fileInput.find('.fileupload-field').on('change', function(event) {
|
|
1783
|
|
1850
|
|
|
1784
|
- $fileInput.find('.fileupload-field').data('files', [{input_name: input_name + 'file', file: file}]);
|
1851
|
+ });
|
|
|
|
1852
|
+ if($('#gallery_form form').find('.add-new-field').length > 0){
|
|
|
|
1853
|
+ var template = $('#gallery_form form').find('.add-new-field').data('template');
|
|
|
|
1854
|
+ template = template.replace(/\{name\}/g, input_name);
|
|
|
|
1855
|
+ var $template = $(template);
|
|
|
|
1856
|
+ $template.find('.fileupload-preview').html($fileInput);
|
|
|
|
1857
|
+ $template.find('.file-type').val(file.type);
|
|
|
|
1858
|
+
|
|
|
|
1859
|
+ $template.find('.remove').click(function(){
|
|
|
|
1860
|
+ $(this).closest('.new-image-wrapper').find('.fileinput-remove').trigger('click');
|
|
|
|
1861
|
+ if($('#new_images .card').length == 0){
|
|
|
|
1862
|
+ $('#gallery_form form input:submit').addClass('not-visible');
|
|
|
|
1863
|
+ }
|
|
|
|
1864
|
+ return false;
|
|
|
|
1865
|
+ });
|
|
|
|
1866
|
+ $('#gallery_form form #new_images').append($template);
|
|
1785
|
|
1867
|
|
|
1786
|
- var reader = new FileReader();
|
|
|
|
1787
|
- reader.onload = function (evt) {
|
|
|
|
1788
|
- var options = {
|
|
|
|
1789
|
- showUpload:false,
|
|
|
|
1790
|
- dropZoneEnabled: false,
|
|
|
|
1791
|
- contentType: true,
|
|
|
|
1792
|
- initialPreview: ["<img src='"+ evt.target.result +"' class='file-preview-image' alt='' title=''>"]
|
|
|
|
1793
|
- };
|
|
|
|
1794
|
|
1868
|
|
|
1795
|
- $fileInput.find('.fileupload-field').fileinput(options);
|
|
|
|
1796
|
|
1869
|
|
|
1797
|
- $fileInput.find('.fileupload-field').on('fileclear', function(event) {
|
|
|
|
1798
|
- if($(this).closest('.new-image-wrapper').length > 0){
|
|
|
|
1799
|
- $(this).closest('.new-image-wrapper').remove();
|
1870
|
+ $template.find("input[data-role=tagsinput]").tagsinput({
|
|
|
|
1871
|
+ typeaheadjs: {
|
|
|
|
1872
|
+ name: 'title',
|
|
|
|
1873
|
+ displayKey: 'title',
|
|
|
|
1874
|
+ valueKey: 'title',
|
|
|
|
1875
|
+ source: tagnames.ttAdapter()
|
|
|
|
1876
|
+ }
|
|
|
|
1877
|
+ });
|
|
1800
|
}else{
|
1878
|
}else{
|
|
1801
|
- $(this).closest('.file-input').remove();
|
1879
|
+ $('#gallery_form form #new_images').append($fileInput);
|
|
1802
|
}
|
1880
|
}
|
|
1803
|
- });
|
|
|
|
1804
|
-
|
|
|
|
1805
|
- $fileInput.find('.fileupload-field').on('change', function(event) {
|
|
|
|
1806
|
|
1881
|
|
|
1807
|
- });
|
|
|
|
1808
|
- if($('#gallery_form form').find('.add-new-field').length > 0){
|
|
|
|
1809
|
- var template = $('#gallery_form form').find('.add-new-field').data('template');
|
|
|
|
1810
|
- template = template.replace(/\{name\}/g, input_name);
|
|
|
|
1811
|
- var $template = $(template);
|
|
|
|
1812
|
- $template.find('.fileupload-preview').html($fileInput);
|
|
|
|
1813
|
- $template.find('.file-type').val(file.type);
|
|
|
|
1814
|
-
|
|
|
|
1815
|
- $template.find('.remove').click(function(){
|
|
|
|
1816
|
- $(this).closest('.new-image-wrapper').find('.fileinput-remove').trigger('click');
|
|
|
|
1817
|
- if($('#new_images .card').length == 0){
|
|
|
|
1818
|
- $('#gallery_form form input:submit').addClass('not-visible');
|
|
|
|
1819
|
- }
|
|
|
|
1820
|
- return false;
|
|
|
|
1821
|
- });
|
|
|
|
1822
|
- $('#gallery_form form #new_images').append($template);
|
1882
|
+ $('#gallery_form form input:submit').removeClass('not-visible');
|
|
1823
|
|
1883
|
|
|
|
|
1884
|
+ clearAjaxFileUpload($('#gallery_form'));
|
|
|
|
1885
|
+ initAjaxFileUpload($('#gallery_form'));
|
|
1824
|
|
1886
|
|
|
1825
|
-
|
|
|
|
1826
|
- $template.find("input[data-role=tagsinput]").tagsinput({
|
|
|
|
1827
|
- typeaheadjs: {
|
|
|
|
1828
|
- name: 'title',
|
|
|
|
1829
|
- displayKey: 'title',
|
|
|
|
1830
|
- valueKey: 'title',
|
|
|
|
1831
|
- source: tagnames.ttAdapter()
|
|
|
|
1832
|
- }
|
|
|
|
1833
|
- });
|
|
|
|
1834
|
- }else{
|
|
|
|
1835
|
- $('#gallery_form form #new_images').append($fileInput);
|
|
|
|
1836
|
- }
|
|
|
|
1837
|
-
|
|
|
|
1838
|
- $('#gallery_form form input:submit').removeClass('not-visible');
|
|
|
|
1839
|
-
|
|
|
|
1840
|
- clearAjaxFileUpload($('#gallery_form'));
|
|
|
|
1841
|
- initAjaxFileUpload($('#gallery_form'));
|
|
|
|
1842
|
-
|
|
|
|
1843
|
- };
|
|
|
|
1844
|
- reader.readAsDataURL(file);
|
|
|
|
1845
|
- });
|
1887
|
+ };
|
|
|
|
1888
|
+ reader.readAsDataURL(file);
|
|
|
|
1889
|
+ });
|
|
1846
|
|
1890
|
|
|
1847
|
|
1891
|
|
|
1848
|
|
1892
|
|
|
1849
|
|
1893
|
|
|
1850
|
- };
|
1894
|
+ };
|
|
1851
|
|
1895
|
|
|
1852
|
- dropZone[0].ondragover = function (e) {
|
|
|
|
1853
|
- e.preventDefault();
|
1896
|
+ dropZone[0].ondragover = function (e) {
|
|
|
|
1897
|
+ e.preventDefault();
|
|
1854
|
|
1898
|
|
|
1855
|
- var dataTransfer = e.dataTransfer;
|
|
|
|
1856
|
- dataTransfer.dropEffect = 'copy';
|
|
|
|
1857
|
- //dropZone.addClass('over');
|
|
|
|
1858
|
- };
|
1899
|
+ var dataTransfer = e.dataTransfer;
|
|
|
|
1900
|
+ dataTransfer.dropEffect = 'copy';
|
|
|
|
1901
|
+ //dropZone.addClass('over');
|
|
|
|
1902
|
+ };
|
|
1859
|
|
1903
|
|
|
1860
|
- dropZone[0].ondragleave = function (e) {
|
|
|
|
1861
|
- e.preventDefault();
|
1904
|
+ dropZone[0].ondragleave = function (e) {
|
|
|
|
1905
|
+ e.preventDefault();
|
|
1862
|
|
1906
|
|
|
1863
|
- //dropZone.removeClass('over');
|
|
|
|
1864
|
- };
|
1907
|
+ //dropZone.removeClass('over');
|
|
|
|
1908
|
+ };
|
|
1865
|
|
1909
|
|
|
1866
|
- }
|
1910
|
+ }
|
|
1867
|
|
1911
|
|
|
1868
|
- });
|
1912
|
+ });
|
|
|
|
1913
|
+ }
|
|
|
|
1914
|
+ initImageDragDrop();
|
|
1869
|
|
1915
|
|
|
1870
|
$(document).on('click','.delete-file', function(){
|
1916
|
$(document).on('click','.delete-file', function(){
|
|
1871
|
var $this = $(this),
|
1917
|
var $this = $(this),
|