|
@@ -1602,16 +1602,40 @@ var clearAjaxFileUpload = function(selector){ |
|
@@ -1602,16 +1602,40 @@ var clearAjaxFileUpload = function(selector){ |
|
1602
|
selector.find('.ajax-file-upload-form').unbind('submit');
|
1602
|
selector.find('.ajax-file-upload-form').unbind('submit');
|
|
1603
|
};
|
1603
|
};
|
|
1604
|
|
1604
|
|
|
|
|
1605
|
+var loadTags = function(callback){
|
|
|
|
1606
|
+ $.get('/admin/tags', {}, function(data){
|
|
|
|
1607
|
+ callback(data);
|
|
|
|
1608
|
+ });
|
|
|
|
1609
|
+}
|
|
|
|
1610
|
+
|
|
|
|
1611
|
+
|
|
|
|
1612
|
+var substringMatcher = function(strs) {
|
|
|
|
1613
|
+ return function findMatches(q, cb) {
|
|
|
|
1614
|
+ var matches, substringRegex;
|
|
|
|
1615
|
+
|
|
|
|
1616
|
+ // an array that will be populated with substring matches
|
|
|
|
1617
|
+ matches = [];
|
|
|
|
1618
|
+
|
|
|
|
1619
|
+ // regex used to determine if a string contains the substring `q`
|
|
|
|
1620
|
+ var substrRegex = new RegExp(q, 'i');
|
|
|
|
1621
|
+
|
|
|
|
1622
|
+ // iterate through the pool of strings and for any string that
|
|
|
|
1623
|
+ // contains the substring `q`, add it to the `matches` array
|
|
|
|
1624
|
+ $.each(strs, function(i, str) {
|
|
|
|
1625
|
+ if (substrRegex.test(str.title)) {
|
|
|
|
1626
|
+ matches.push(str);
|
|
|
|
1627
|
+ }
|
|
|
|
1628
|
+ });
|
|
|
|
1629
|
+ cb(matches);
|
|
|
|
1630
|
+ };
|
|
|
|
1631
|
+};
|
|
|
|
1632
|
+
|
|
1605
|
|
1633
|
|
|
1606
|
var tagnames = new Bloodhound({
|
1634
|
var tagnames = new Bloodhound({
|
|
1607
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('title'),
|
1635
|
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('title'),
|
|
1608
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
1636
|
queryTokenizer: Bloodhound.tokenizers.whitespace,
|
|
1609
|
prefetch: {
|
1637
|
prefetch: {
|
|
1610
|
- url: '/admin/tags',
|
|
|
|
1611
|
- filter: function(list) {
|
|
|
|
1612
|
- return $.map(list, function(title) {
|
|
|
|
1613
|
- return { title: title }; });
|
|
|
|
1614
|
- }
|
1638
|
+ url: '/admin/tags'
|
|
1615
|
}
|
1639
|
}
|
|
1616
|
});
|
1640
|
});
|
|
1617
|
tagnames.initialize();
|
1641
|
tagnames.initialize();
|
|
@@ -1947,14 +1971,24 @@ jQuery(document).ready(function(){ |
|
@@ -1947,14 +1971,24 @@ jQuery(document).ready(function(){ |
|
1947
|
|
1971
|
|
|
1948
|
|
1972
|
|
|
1949
|
|
1973
|
|
|
1950
|
- $template.find("input[data-role=tagsinput]").tagsinput({
|
|
|
|
1951
|
- typeaheadjs: {
|
|
|
|
1952
|
- name: 'title',
|
|
|
|
1953
|
- displayKey: 'title',
|
|
|
|
1954
|
- valueKey: 'title',
|
|
|
|
1955
|
- source: tagnames.ttAdapter()
|
|
|
|
1956
|
- }
|
1974
|
+
|
|
|
|
1975
|
+
|
|
|
|
1976
|
+ if($template.find("input[data-role=tagsinput]").length > 0){
|
|
|
|
1977
|
+ loadTags(function(data){
|
|
|
|
1978
|
+ $template.find("input[data-role=tagsinput]").tagsinput({
|
|
|
|
1979
|
+ typeaheadjs: {
|
|
|
|
1980
|
+ name: 'title',
|
|
|
|
1981
|
+ minLength: 0,
|
|
|
|
1982
|
+ displayKey: 'title',
|
|
|
|
1983
|
+ valueKey: 'title',
|
|
|
|
1984
|
+ source: substringMatcher(data),
|
|
|
|
1985
|
+ limit: 1000
|
|
|
|
1986
|
+ },
|
|
|
|
1987
|
+ maxChars: 0
|
|
|
|
1988
|
+ });
|
|
1957
|
});
|
1989
|
});
|
|
|
|
1990
|
+ }
|
|
|
|
1991
|
+
|
|
1958
|
}else{
|
1992
|
}else{
|
|
1959
|
$('#gallery_form form #new_images').append($fileInput);
|
1993
|
$('#gallery_form form #new_images').append($fileInput);
|
|
1960
|
}
|
1994
|
}
|
|
@@ -2049,14 +2083,25 @@ jQuery(document).ready(function(){ |
|
@@ -2049,14 +2083,25 @@ jQuery(document).ready(function(){ |
|
2049
|
|
2083
|
|
|
2050
|
var $modal = $data.modal({show: false, keyboard: false, backdrop: 'static'}).on('shown.bs.modal', function (e) {
|
2084
|
var $modal = $data.modal({show: false, keyboard: false, backdrop: 'static'}).on('shown.bs.modal', function (e) {
|
|
2051
|
var $this = $(this);
|
2085
|
var $this = $(this);
|
|
2052
|
- $this.find("input[data-role=tagsinput]").tagsinput({
|
|
|
|
2053
|
- typeaheadjs: {
|
|
|
|
2054
|
- name: 'title',
|
|
|
|
2055
|
- displayKey: 'title',
|
|
|
|
2056
|
- valueKey: 'title',
|
|
|
|
2057
|
- source: tagnames.ttAdapter()
|
|
|
|
2058
|
- }
|
|
|
|
2059
|
- });
|
2086
|
+
|
|
|
|
2087
|
+
|
|
|
|
2088
|
+ if($this.find("input[data-role=tagsinput]").length > 0){
|
|
|
|
2089
|
+ loadTags(function(data){
|
|
|
|
2090
|
+ $this.find("input[data-role=tagsinput]").tagsinput({
|
|
|
|
2091
|
+ typeaheadjs: {
|
|
|
|
2092
|
+ name: 'title',
|
|
|
|
2093
|
+ minLength: 0,
|
|
|
|
2094
|
+ displayKey: 'title',
|
|
|
|
2095
|
+ valueKey: 'title',
|
|
|
|
2096
|
+ source: substringMatcher(data),
|
|
|
|
2097
|
+ limit: 1000
|
|
|
|
2098
|
+ },
|
|
|
|
2099
|
+ maxChars: 0
|
|
|
|
2100
|
+ });
|
|
|
|
2101
|
+ });
|
|
|
|
2102
|
+ }
|
|
|
|
2103
|
+
|
|
|
|
2104
|
+
|
|
2060
|
$this.find('.filestyle').each(function() {
|
2105
|
$this.find('.filestyle').each(function() {
|
|
2061
|
var $this = $(this), options = {
|
2106
|
var $this = $(this), options = {
|
|
2062
|
'input' : $this.attr('data-input') !== 'false',
|
2107
|
'input' : $this.attr('data-input') !== 'false',
|
|
@@ -2086,6 +2131,7 @@ jQuery(document).ready(function(){ |
|
@@ -2086,6 +2131,7 @@ jQuery(document).ready(function(){ |
|
2086
|
if(data.status == 'ok'){
|
2131
|
if(data.status == 'ok'){
|
|
2087
|
$('.modal').modal('hide');
|
2132
|
$('.modal').modal('hide');
|
|
2088
|
$('#gallery_image_' + data.id).find('.card-img-top').attr('src', data.link);
|
2133
|
$('#gallery_image_' + data.id).find('.card-img-top').attr('src', data.link);
|
|
|
|
2134
|
+ $('#gallery_image_' + data.id).find('.card-title').text(data.title);
|
|
2089
|
}else{
|
2135
|
}else{
|
|
2090
|
$this.find('.error-message').html(data.message);
|
2136
|
$this.find('.error-message').html(data.message);
|
|
2091
|
}
|
2137
|
}
|