-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
105 additions
and
712 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 0 additions & 97 deletions
97
src/Modules/StatCan.OrchardCore.EmailTemplates/wwwroot/Scripts/vue-multiselect-wrapper.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +0,0 @@ | ||
/* | ||
** NOTE: This file is generated by Gulp and should not be edited directly! | ||
** Any changes made directly to this file will be overwritten next time its asset group is processed by Gulp. | ||
*/ | ||
|
||
function debounce(func, wait, immediate) { | ||
var timeout; | ||
return function () { | ||
var context = this, | ||
args = arguments; | ||
|
||
var later = function later() { | ||
timeout = null; | ||
if (!immediate) func.apply(context, args); | ||
}; | ||
|
||
var callNow = immediate && !timeout; | ||
clearTimeout(timeout); | ||
timeout = setTimeout(later, wait); | ||
if (callNow) func.apply(context, args); | ||
}; | ||
} | ||
|
||
; | ||
|
||
function initVueMultiselect(element) { | ||
// only run script if element exists | ||
if (element) { | ||
var elementId = element.id; | ||
var selectedItems = JSON.parse(element.dataset.selectedItems || "[]"); | ||
|
||
if (selectedItems == null) { | ||
selectedItems = []; | ||
} | ||
|
||
var multiple = JSON.parse(element.dataset.multiple); | ||
var allItems = JSON.parse(element.dataset.allItems || "[]"); | ||
var debouncedSearch = debounce(function (vm, query) { | ||
vm.isLoading = true; | ||
}, 250); | ||
var vueMultiselect = Vue.component('vue-multiselect', window.VueMultiselect.default); | ||
var vm = new Vue({ | ||
el: '#' + elementId, | ||
components: { | ||
'vue-multiselect': vueMultiselect | ||
}, | ||
data: { | ||
value: null, | ||
arrayOfItems: selectedItems, | ||
options: allItems | ||
}, | ||
computed: { | ||
selectedIds: function selectedIds() { | ||
return this.arrayOfItems.map(function (x) { | ||
return x.Value; | ||
}).join(','); | ||
}, | ||
isDisabled: function isDisabled() { | ||
return this.arrayOfItems.length > 0 && !multiple; | ||
} | ||
}, | ||
watch: { | ||
selectedIds: function selectedIds() { | ||
// We add a delay to allow for the <input> to get the actual value | ||
// before the form is submitted | ||
setTimeout(function () { | ||
$(document).trigger('contentpreview:render'); | ||
}, 100); | ||
} | ||
}, | ||
methods: { | ||
onSelect: function onSelect(selectedOption) { | ||
var self = this; | ||
|
||
for (i = 0; i < self.arrayOfItems.length; i++) { | ||
if (self.arrayOfItems[i].Value === selectedOption.Value) { | ||
return; | ||
} | ||
} | ||
|
||
self.arrayOfItems.push(selectedOption); | ||
}, | ||
remove: function remove(item) { | ||
this.arrayOfItems.splice(this.arrayOfItems.indexOf(item), 1); | ||
} | ||
} | ||
}); | ||
/*Hook for other scripts that might want to have access to the view model*/ | ||
|
||
var event = new CustomEvent("vue-multiselect-created", { | ||
detail: { | ||
vm: vm | ||
} | ||
}); | ||
document.querySelector("body").dispatchEvent(event); | ||
} | ||
} | ||
69 changes: 0 additions & 69 deletions
69
src/Modules/StatCan.OrchardCore.GitHub/wwwroot/tokensEditor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +0,0 @@ | ||
/* | ||
** NOTE: This file is generated by Gulp and should not be edited directly! | ||
** Any changes made directly to this file will be overwritten next time its asset group is processed by Gulp. | ||
*/ | ||
|
||
function initializeTokensEditor(elem, data) { | ||
console.log(data); | ||
var store = { | ||
debug: false, | ||
state: { | ||
tokens: data | ||
}, | ||
addToken: function addToken() { | ||
if (this.debug) { | ||
console.log('add token triggered'); | ||
} | ||
|
||
; | ||
this.state.tokens.push({ | ||
name: '', | ||
value: '' | ||
}); | ||
}, | ||
removeToken: function removeToken(index) { | ||
if (this.debug) { | ||
console.log('remove token triggered with', index); | ||
} | ||
|
||
; | ||
this.state.tokens.splice(index, 1); | ||
} | ||
}; | ||
var tokensTable = { | ||
template: '#tokens-table', | ||
props: ['data'], | ||
name: 'tokens-table', | ||
methods: { | ||
add: function add() { | ||
store.addToken(); | ||
}, | ||
remove: function remove(index) { | ||
store.removeToken(index); | ||
}, | ||
getTokensFormattedList: function getTokensFormattedList() { | ||
if (this.debug) { | ||
console.log('getTokensFormattedList triggered'); | ||
} | ||
|
||
; | ||
return JSON.stringify(store.state.tokens.filter(function (x) { | ||
return !IsNullOrWhiteSpace(x.name); | ||
})); | ||
} | ||
} | ||
}; | ||
new Vue({ | ||
components: { | ||
tokensTable: tokensTable | ||
}, | ||
data: { | ||
sharedState: store.state | ||
}, | ||
el: elem | ||
}); | ||
} | ||
|
||
function IsNullOrWhiteSpace(str) { | ||
return str === null || str.match(/^ *$/) !== null; | ||
} | ||
115 changes: 0 additions & 115 deletions
115
src/Modules/StatCan.OrchardCore.LocalizedText/wwwroot/localizedTextEditor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +0,0 @@ | ||
/* | ||
** NOTE: This file is generated by Gulp and should not be edited directly! | ||
** Any changes made directly to this file will be overwritten next time its asset group is processed by Gulp. | ||
*/ | ||
|
||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | ||
|
||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
|
||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
|
||
function initializeLocalizedTextEditor(element, confirmModalOptions) { | ||
var $el = $(element); | ||
var initialData = $el.data('init'); | ||
var cultures = $el.data('cultures'); | ||
|
||
function autoExpand() { | ||
// textareas autoexpand when text changes | ||
this.style.height = 'auto'; | ||
this.style.minHeight = "38px"; | ||
this.style.height = this.scrollHeight + 'px'; | ||
} | ||
|
||
$('.autoexpand-listener').on('input', 'textarea', autoExpand); | ||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { | ||
$('.autoexpand-listener').find("textarea").each(autoExpand); | ||
}); | ||
var parsedData = initialData ? initialData.map(function (i) { | ||
return { | ||
name: i.Name, | ||
localizedItems: i.LocalizedItems.map(function (j) { | ||
return { | ||
culture: j.Culture, | ||
value: j.Value, | ||
isCurrent: cultures.find(function (c) { | ||
return c == j.Culture; | ||
}) | ||
}; | ||
}) | ||
}; | ||
}) : []; // add missing cultures | ||
|
||
parsedData.forEach(function (item) { | ||
cultures.forEach(function (c) { | ||
if (!item.localizedItems.find(function (i) { | ||
return i.culture == c; | ||
})) { | ||
item.localizedItems.push({ | ||
culture: c, | ||
isCurrent: true, | ||
value: '' | ||
}); | ||
} | ||
}); | ||
}); | ||
return new Vue({ | ||
el: element, | ||
data: { | ||
entries: [] | ||
}, | ||
computed: { | ||
value: function value() { | ||
this.entries; | ||
return JSON.stringify(this.entries); | ||
}, | ||
hasEntries: function hasEntries() { | ||
return this.entries.length > 0; | ||
} | ||
}, | ||
created: function created() { | ||
this.entries = parsedData; | ||
}, | ||
mounted: function mounted() { | ||
// expand the textareas on mount | ||
$('.autoexpand-listener').find("textarea").each(autoExpand); | ||
}, | ||
methods: { | ||
add: function add() { | ||
this.entries.push({ | ||
name: '', | ||
localizedItems: cultures === null || cultures === void 0 ? void 0 : cultures.map(function (c) { | ||
return { | ||
culture: c, | ||
isCurrent: true, | ||
value: '' | ||
}; | ||
}) | ||
}); | ||
}, | ||
remove: function remove(index) { | ||
// use the admin confirm dialog before deleting | ||
var that = this; | ||
confirmDialog(_objectSpread(_objectSpread({}, confirmModalOptions), {}, { | ||
callback: function callback(resp) { | ||
if (resp) { | ||
that.entries.splice(index, 1); | ||
} | ||
} | ||
})); | ||
}, | ||
updatePreview: function updatePreview() { | ||
this.$nextTick(function () { | ||
$(document).trigger('contentpreview:render'); | ||
}); | ||
} | ||
}, | ||
watch: { | ||
entries: function entries() { | ||
this.updatePreview(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
; | ||
Oops, something went wrong.