diff --git a/OurUmbraco.Client/package-lock.json b/OurUmbraco.Client/package-lock.json index 702bc000b0..51c50ee28f 100644 --- a/OurUmbraco.Client/package-lock.json +++ b/OurUmbraco.Client/package-lock.json @@ -7,7 +7,7 @@ "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", + "integrity": "sha1-+PLIh60Qv2f2NPAFtph/7TF5qsg=", "dev": true }, "amdefine": { @@ -55,7 +55,7 @@ "aproba": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", + "integrity": "sha1-aALmJk79GMeQobDVF/DyYnvyyUo=", "dev": true }, "are-we-there-yet": { @@ -36080,7 +36080,7 @@ "normalize-package-data": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", "dev": true, "requires": { "hosted-git-info": "2.5.0", @@ -36092,7 +36092,7 @@ "npmlog": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz", - "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==", + "integrity": "sha1-CKfyqL9zRgR3mp76StXMcXq7lUs=", "dev": true, "requires": { "are-we-there-yet": "1.1.4", @@ -36371,7 +36371,7 @@ "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "integrity": "sha1-LtgVDSShbqhlHm1u8PR8QVjOejY=", "dev": true, "requires": { "glob": "7.1.2" @@ -36700,7 +36700,7 @@ "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", "dev": true, "requires": { "isexe": "2.0.0" @@ -36715,7 +36715,7 @@ "wide-align": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz", - "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==", + "integrity": "sha1-Vx4PGwYEY268DfwhsDObvjE0FxA=", "dev": true, "requires": { "string-width": "1.0.2" diff --git a/OurUmbraco.Client/src/js/app.js b/OurUmbraco.Client/src/js/app.js index 905bfd40b1..7f19bc306d 100644 --- a/OurUmbraco.Client/src/js/app.js +++ b/OurUmbraco.Client/src/js/app.js @@ -7,96 +7,96 @@ _.templateSettings = { jQuery(document).ready(function (){ - // Quick menu - var bodyVar = $('body'), - searchAll = $('.search-all'); - - $( ".user, .close" ).click(function(e) { - e.preventDefault(); - e.stopPropagation(); - bodyVar.toggleClass( "quickmenu" ); - }); - - $('.wrapper').on('click', function () { - bodyVar.removeClass('quickmenu'); - }); - - - // Mobile navigation - $("#toggle").click(function(e) { - e.preventDefault(); - $(".cross").toggleClass("open"); - $("nav").toggleClass("open"); - $("body").toggleClass("navopen"); - }); - - $('.pm-nuget').on('click', '.nuget', function(){ - $(this).focus(); - $(this).select(); - }); - - // Tab - $('.tabs li').click(function(){ - var tab_id = $(this).attr('data-tab'); - - $('.tabs li').removeClass('current'); - $('.tab-content').removeClass('current'); - - $(this).addClass('current'); - $("#"+tab_id).addClass('current'); - }); - - // Click effect - var ink, d, x, y; - $(".button, .inked").click(function(e){ - - if($(this).find(".ink").length === 0){ - $(this).prepend("
"); - } - - ink = $(this).find(".ink"); - ink.removeClass("animate"); - - if(!ink.height() && !ink.width()){ - d = Math.max($(this).outerWidth(), $(this).outerHeight()); - ink.css({height: d, width: d}); - } - - x = e.pageX - $(this).offset().left - ink.width()/2; - y = e.pageY - $(this).offset().top - ink.height()/2; - - ink.css({top: y+'px', left: x+'px'}).addClass("animate"); - }); + // Quick menu + var bodyVar = $('body'), + searchAll = $('.search-all'); + + $( ".user, .close" ).click(function(e) { + e.preventDefault(); + e.stopPropagation(); + bodyVar.toggleClass( "quickmenu" ); }); - var classOnScrollObject = function (selector, className, scrollDistance) { - this.item = $(selector); - this.itemClass = className; - this.scrollDistance = scrollDistance; - this.classApplied = false; - this.scrollContainer = $(window); - this.fromTop = this.scrollContainer.scrollTop(); - }; - - classOnScrollObject.prototype.applyClass = function() { - this.fromTop = this.scrollContainer.scrollTop(); + $('.wrapper').on('click', function () { + bodyVar.removeClass('quickmenu'); + }); + + + // Mobile navigation + $("#toggle").click(function(e) { + e.preventDefault(); + $(".cross").toggleClass("open"); + $("nav").toggleClass("open"); + $("body").toggleClass("navopen"); + }); + + $('.pm-nuget').on('click', '.nuget', function(){ + $(this).focus(); + $(this).select(); + }); + + // Tab + $('.tabs li').click(function(){ + var tab_id = $(this).attr('data-tab'); + + $('.tabs li').removeClass('current'); + $('.tab-content').removeClass('current'); + + $(this).addClass('current'); + $("#"+tab_id).addClass('current'); + }); + + // Click effect + var ink, d, x, y; + $(".button, .inked").click(function(e){ + + if($(this).find(".ink").length === 0){ + $(this).prepend("
"); + } + + ink = $(this).find(".ink"); + ink.removeClass("animate"); + + if(!ink.height() && !ink.width()){ + d = Math.max($(this).outerWidth(), $(this).outerHeight()); + ink.css({height: d, width: d}); + } + + x = e.pageX - $(this).offset().left - ink.width()/2; + y = e.pageY - $(this).offset().top - ink.height()/2; - if (this.fromTop > this.scrollDistance && this.classApplied === false) { - this.classApplied = true; - this.item.addClass(this.itemClass); - } else if (this.fromTop < this.scrollDistance && this.classApplied === true) { - this.classApplied = false; - this.item.removeClass(this.itemClass); - } - }; + ink.css({top: y+'px', left: x+'px'}).addClass("animate"); + }); +}); + +var classOnScrollObject = function (selector, className, scrollDistance) { + this.item = $(selector); + this.itemClass = className; + this.scrollDistance = scrollDistance; + this.classApplied = false; + this.scrollContainer = $(window); + this.fromTop = this.scrollContainer.scrollTop(); +}; + +classOnScrollObject.prototype.applyClass = function() { + this.fromTop = this.scrollContainer.scrollTop(); + + if (this.fromTop > this.scrollDistance && this.classApplied === false) { + this.classApplied = true; + this.item.addClass(this.itemClass); + } else if (this.fromTop < this.scrollDistance && this.classApplied === true) { + this.classApplied = false; + this.item.removeClass(this.itemClass); + } +}; - function classOnScroll (selector, className, scrollDistance) { - var newClassOnScroll = new classOnScrollObject(selector, className, scrollDistance); +function classOnScroll (selector, className, scrollDistance) { + var newClassOnScroll = new classOnScrollObject(selector, className, scrollDistance); - newClassOnScroll.applyClass(); + newClassOnScroll.applyClass(); - newClassOnScroll.scrollContainer.scroll(function () { - newClassOnScroll.applyClass(); - }); + newClassOnScroll.scrollContainer.scroll(function () { + newClassOnScroll.applyClass(); + }); - } \ No newline at end of file +} \ No newline at end of file diff --git a/OurUmbraco.Client/src/js/vendor/whatInput.js b/OurUmbraco.Client/src/js/vendor/whatInput.js new file mode 100644 index 0000000000..a878b72774 --- /dev/null +++ b/OurUmbraco.Client/src/js/vendor/whatInput.js @@ -0,0 +1,7 @@ +/** + * what-input - A global utility for tracking the current input method (mouse, keyboard or touch). + * @version v5.1.0 + * @link https://github.com/ten1seven/what-input + * @license MIT + */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("whatInput",[],t):"object"==typeof exports?exports.whatInput=t():e.whatInput=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t){"use strict";e.exports=function(){if("undefined"==typeof document||"undefined"==typeof window)return{ask:function(){return"initial"},element:function(){return null},ignoreKeys:function(){},registerOnChange:function(){},unRegisterOnChange:function(){}};var e=document.documentElement,t=null,n="initial",o=n;window.sessionStorage&&(window.sessionStorage.getItem("what-input")&&(n=window.sessionStorage.getItem("what-input")),window.sessionStorage.getItem("what-intent")&&(o=window.sessionStorage.getItem("what-intent")));var i=null,r=["input","select","textarea"],s=[],u=[16,17,18,91,93],a={keydown:"keyboard",keyup:"keyboard",mousedown:"mouse",mousemove:"mouse",MSPointerDown:"pointer",MSPointerMove:"pointer",pointerdown:"pointer",pointermove:"pointer",touchstart:"touch"},d=!1,w=!1,c={x:null,y:null},p={2:"touch",3:"touch",4:"mouse"},f=!1;try{var l=Object.defineProperty({},"passive",{get:function(){f=!0}});window.addEventListener("test",null,l)}catch(e){}var m=function(){var e=!!f&&{passive:!0};window.PointerEvent?(window.addEventListener("pointerdown",v),window.addEventListener("pointermove",g)):window.MSPointerEvent?(window.addEventListener("MSPointerDown",v),window.addEventListener("MSPointerMove",g)):(window.addEventListener("mousedown",v),window.addEventListener("mousemove",g),"ontouchstart"in window&&(window.addEventListener("touchstart",L,e),window.addEventListener("touchend",v))),window.addEventListener(x(),g,e),window.addEventListener("keydown",L),window.addEventListener("keyup",L),window.addEventListener("focusin",y),window.addEventListener("focusout",E)},v=function(e){if(!d){var t=e.which,i=a[e.type];"pointer"===i&&(i=S(e));var s="keyboard"===i&&t&&-1===u.indexOf(t)||"mouse"===i||"touch"===i;if(n!==i&&s&&(n=i,window.sessionStorage&&window.sessionStorage.setItem("what-input",n),h("input")),o!==i&&s){var w=document.activeElement;w&&w.nodeName&&-1===r.indexOf(w.nodeName.toLowerCase())&&(o=i,window.sessionStorage&&window.sessionStorage.setItem("what-intent",o),h("intent"))}}},h=function(t){e.setAttribute("data-what"+t,"input"===t?n:o),b(t)},g=function(e){if(k(e),!d&&!w){var t=a[e.type];"pointer"===t&&(t=S(e)),o!==t&&(o=t,window.sessionStorage&&window.sessionStorage.setItem("what-intent",o),h("intent"))}},y=function(n){if(!n.target.nodeName)return void E();t=n.target.nodeName.toLowerCase(),e.setAttribute("data-whatelement",t),n.target.classList&&n.target.classList.length&&e.setAttribute("data-whatclasses",n.target.classList.toString().replace(" ",","))},E=function(){t=null,e.removeAttribute("data-whatelement"),e.removeAttribute("data-whatclasses")},L=function(e){v(e),window.clearTimeout(i),d=!0,i=window.setTimeout(function(){d=!1},100)},S=function(e){return"number"==typeof e.pointerType?p[e.pointerType]:"pen"===e.pointerType?"touch":e.pointerType},x=function(){return"onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll"},b=function(e){for(var t=0,i=s.length;t setTimeout(resolve, 100)); + }, + + bindOnMentionChange: function () { + jQuery('#high-five-mention').keyup(function(e) { + HighFives.selectedMember = false; + HighFives.getMember(e.target.value); + HighFives.selectMemberIfMatches(e.target.value); + }); + }, + bindOnLinkChange: function () { + jQuery('#high-five-url').keyup(_.debounce(HighFives.getUrlTitle, 300)); + }, + bindOnMemberSelect: function() { + jQuery('#high-five-form .suggestions-list button').unbind('click'); + jQuery('#high-five-form .suggestions-list button').click(function(e) { + var id = e.target.getAttribute('data-id'); + HighFives.selectedMember = { + id: e.target.getAttribute('data-id'), + name: e.target.innerHTML + }; + HighFives.selectMember(HighFives.selectedMember); + }); + // unbind from previous versions just in case + }, + + bindOnCategorySelect: function () { + var categorySeleted = jQuery('#high-five-task option:selected').text(); + HighFives.preview.Category = categorySeleted; + HighFives.updatePreviewNode(); + }, + + bindOnSubmitForm: function() { + jQuery('#high-five-form').submit(function(e) { + e.preventDefault(); + if (HighFives.isFormValid()) { + HighFives.submitHighFive(HighFives.selectedMember.id, jQuery('#high-five-task').val(), jQuery('#high-five-url').val(), HighFives.linkTitle, function () { + HighFives.resetForm(); + HighFives.removePreviewNode(); + HighFives.getRecentHighFiveActivity(0, function(response) { + var activity = typeof response == 'string' ? JSON.parse(response): response; + HighFives.updateHighFiveList(activity.HighFives); + HighFives.buildactivityListNode(HighFives.list); + }); + }); + } + }); + }, + + // buildactivityListNode - Builds a list of list items that represent the activity list and adds them to an activity list for users to view. + buildactivityListNode: function () { + var highFives = HighFives.list; + + if (highFives && highFives.length > 0) { + HighFives.activityListNode.innerHTML = ''; + for (var i = 0; i < highFives.length; i++) { + var highFive = highFives[i]; + HighFives.activityListNode.innerHTML += HighFives.createHighFivePanelHtml(highFive); + } + + } + }, + createPreviewNode() { + var preview = document.createElement("ul"); + preview.classList.add("high-five__activity-list"); + preview.classList.add("high-five__activity-list--preview"); + return preview; + }, + updatePreviewNode: function() { + HighFives.previewNode.innerHTML = ''; + var highFive = HighFives.preview; + HighFives.previewNode.innerHTML += '

Preview of your High Five:

'; + HighFives.previewNode.innerHTML += HighFives.createHighFivePanelHtml(highFive); + + if(document.body.contains(HighFives.previewNode) === false) { + HighFives.highFiveActivityNode.prepend(HighFives.previewNode); + } + }, + removePreviewNode: function () { + HighFives.previewNode.remove(); + HighFives.defaultPreview(); + }, + createHighFivePanelHtml(highFive) { + return '
  • ' + + '
    ' + highFive.To + '
    ' + + '
    ' + + '

    ' + highFive.To + '

    ' + + '

    ' + highFive.From + ' High Fived you for ' + highFive.Category +' : ' + highFive.LinkTitle + '' + /*, 2 minutes ago*/ '

    ' + + '
  • '; + }, + + buildSuggestionsList: function () { + var suggestions = HighFives.suggestions; + var list = document.querySelector("#high-five-form .suggestions-list"); + list.innerHTML = ''; + for (var i = 0; i < suggestions.length; i++) { + var suggestion = suggestions[i]; + list.innerHTML += '
  • ' + + '
  • '; + } + HighFives.bindOnMemberSelect(); + }, + + clearSuggestionsList: function () { + jQuery('#high-five-form .suggestions-list button').unbind('click'); + var list = document.querySelector("#high-five-form .suggestions-list"); + list.innerHTML = ''; + }, + + // buildCategoryDropdown - Builds a list of options for the category dropdown. + buildCategoryDropdown: function(categories) { + if (categories && categories.length > 0) { + var dropdown = jQuery('#high-five-task'); + var options = ''; + for (var i = 0; i < categories.length; i++) { + var category = categories[i]; + options += ''; + } + dropdown.html(options); + } + $("#high-five-task").change(function () { + HighFives.bindOnCategorySelect(); + }); + }, + + // checkForNewHighFivesPeriodically - Polls the API endpoint for new high fives periodically + checkForNewHighFivesPeriodically: function (seconds) { + window.setTimeout(function() { + HighFives.getRecentHighFiveActivity(0, function(response) { + var feed = typeof response == 'string' ? JSON.parse(response) : response; + // HighFives.list = HighFives.unionBy(HighFives.list, HighFives.addComplimentsToList(feed.HighFives)).slice(0, 6); + HighFives.updateHighFiveList(feed.HighFives); + HighFives.checkForNewHighFivesPeriodically(30); + }); + }, (seconds * 1000)); + }, + + clearPlaceholder: function (el) { + el.attr("placeholder", ""); + }, + + // doesHaveHighFive - returns true if highFive element exists + doesHaveHighFive: function() { + var highFive = document.querySelector('section[data-high-five]'); + if (highFive && typeof highFive !== 'null' && typeof highFive !== 'undefined') { + return true; + } + return false; + }, + + // getCategories - Get the categories for the high fives. + getCategories: function(onSuccess) { + if (useMockApi) { + onSuccess(ApiMock.getCategories()); + } else { + jQuery.getJSON('/umbraco/api/HighFiveFeedAPI/GetCategories', onSuccess); + } + }, + + getMember: function(member) { + if (member.length > 2) { + if (useMockApi) { + HighFives.suggestions = ApiMock.getUmbracians(); + HighFives.buildSuggestionsList(); + } else { + jQuery.get('/Umbraco/Api/highFiveFeedApi/GetUmbracians?name=' + member, function (umbracians) { + HighFives.suggestions = umbracians; + HighFives.buildSuggestionsList(); + }); + } + } else { + HighFives.clearSuggestionsList(); + } + }, + getUrlTitle: function (event) { + var url = event.target.value || ""; + + if (event.target.validity.valid === true && url.length > 10 && HighFives.prevLinkUrl !== url) { + HighFives.prevLinkUrl = url; + jQuery.get('/Umbraco/Api/highFiveFeedApi/GetTitleTag?url=' + encodeURIComponent(url), function (title) { + HighFives.linkTitle = title; + HighFives.preview.LinkTitle = title; + HighFives.preview.LinkUrl = url; + HighFives.updatePreviewNode(); + }); + } + }, + getCurrentMember: function () { + jQuery.get('/Umbraco/Api/highFiveFeedApi/GetCurrentMember', function (member) { + HighFives.currentMember = member; + HighFives.preview.From = HighFives.currentMember.Username; + }); + + }, + getRandomCompliment: function() { + var compliments = [ + 'Lovely', + 'Woohoo!', + '#h5yr!', + 'Go', + 'Awesome!', + 'Rockstar', + 'Yass!', + 'Most excellent', + 'Excellent!', + 'Supertak!', + 'Cheers!', + 'Wow!', + 'Yahoo!', + 'Yee haw!', + 'Boo ya!', + 'Hoorah!', + 'Huzzah!', + 'Tada!', + 'Yippee!', + 'Squeee!', + 'Yowza!', + 'Damn Skippy!', + 'Hells yeah!', + 'Bingo!', + 'KAPOW!', + 'Bravo!', + 'That\'s magic!', + 'Wizard!', + 'Nailed it!', + 'Well done!', + 'Like a boss!', + 'Congrats!', + 'Go you!', + 'Get you!', + 'Yay!' + ]; + var rnd = Math.floor(Math.random() * compliments.length); + return compliments[rnd]; + }, + + // getRandomUmbracians - Get a random list of Umbracians to use for placeholder. + getRandomUmbracians: function(onSuccess) { + if (useMockApi) { + onSuccess(ApiMock.getRandomUmbracians()); + } else { + jQuery.get('/umbraco/api/HighFiveFeedAPI/getRandomUmbracians', onSuccess); + } + }, + + // getRecentHighFiveActivity - Gets the most recent high fives via API. + getRecentHighFiveActivity: function(page, onSuccess) { + page = typeof page === 'undefined' ? 0 : page; + if (useMockApi) { + onSuccess(ApiMock.getHighFiveFeed()); + } else { + jQuery.get('/umbraco/api/HighFiveFeedAPI/GetHighFiveFeed?page=' + page, onSuccess); + } + }, + + isFormValid: function() { + if (HighFives.selectedMember) { + if (jQuery('#high-five-url').val() !== '') { + if (typeof jQuery('#high-five-task').val() !== 'object') { + return true; + } + } + } + return false; + }, + + printPhrase: function (phrase, el) { + return new Promise(resolve => { + // Clear placeholder before typing next phrase + HighFives.clearPlaceholder(el); + let letters = phrase.split(''); + // For each letter in phrase + letters.reduce( + (promise, letter, index) => promise.then(_ => { + // Resolve promise when all letters are typed + if (index === letters.length - 1) { + // Delay before start next phrase "typing" + setTimeout(resolve, 1000); + } + return HighFives.addToPlaceholder(letter, el); + }), + Promise.resolve() + ); + }); + }, + + printPhrases: function (phrases, el) { + // For each phrase + // wait for phrase to be typed + // before start typing next + phrases.reduce( + (promise, phrase) => promise.then(_ => HighFives.printPhrase(phrase, el)), + Promise.resolve() + ); + }, + + resetForm: function () { + HighFives.selectedMember = false; + HighFives.suggestions = []; + jQuery('#high-five-url').val(''); + jQuery('#high-five-mention').val(''); + HighFives.buildSuggestionsList(); + }, + + // selectMember + selectMember: function (member) { + var list = document.querySelector("#high-five-form .suggestions-list"); + list.innerHTML = ''; + jQuery('#high-five-mention').val(member.name); + HighFives.preview.To = member.name; + + jQuery.get('/Umbraco/Api/highFiveFeedApi/GetMemberAvatar?memberId=' + member.id, function (memberAvatar) { + HighFives.preview.ToAvatarUrl = memberAvatar; + HighFives.updatePreviewNode(); + }); + }, + + // selectMemberIfMatches - If the `value` matches the name of a user in the suggestions list, select them. + selectMemberIfMatches: function(value) { + var suggestions = HighFives.suggestions; + if (suggestions && suggestions.length > 0) { + for (var i = 0; i < suggestions.length; i++) { + var suggestion = suggestions[i]; + if (suggestion.Username.toLowerCase() == value.toLowerCase()) { + HighFives.selectedMember = { + id: suggestion.MemberId, + name: suggestion.Username + }; + HighFives.selectMember(HighFives.selectedMember); + + } + } + } + }, + + // submitHighFive + submitHighFive: function(to, action, url, linkTitle, onSuccess) { + if (useMockApi) { + onSuccess(ApiMock.submitHighFive()); + } else { + jQuery.post('/umbraco/api/HighFiveFeedAPI/SubmitHighFive?toUserId=' + to + '&action=' + action + '&url=' + url + '&linkTitle=' + linkTitle, onSuccess); + } + }, + + shuffle: function(array) { + var currentIndex = array.length, temporaryValue, randomIndex; + + // While there remain elements to shuffle... + while (0 !== currentIndex) { + + // Pick a remaining element... + randomIndex = Math.floor(Math.random() * currentIndex); + currentIndex -= 1; + + // And swap it with the current element. + temporaryValue = array[currentIndex]; + array[currentIndex] = array[randomIndex]; + array[randomIndex] = temporaryValue; + } + + return array; + }, + + unionBy: function(oldArray, newArray) { + for (var n = 0; n < newArray.length; n++) { + var itemToAdd = newArray[n]; + var isUnique = true; + for (var o = 0; o < oldArray.length; o++) { + var oldItem = oldArray[o]; + if (oldItem.Id === itemToAdd.Id) { + isUnique = false; + } + } + if (isUnique) { + oldArray.unshift(itemToAdd); + } + } + return oldArray; + } + }; + + var memberSearch = _.debounce(HighFives.getMember, 300); + + var ApiMock = { + getCategories: function() { + return [ + { "Id": 1, "CategoryText": "A Package" }, + { "Id": 2, "CategoryText": "A Talk" }, + { "Id": 3, "CategoryText": "A Blog Post" }, + { "Id": 4, "CategoryText": "A Meetup" }, + { "Id": 5, "CategoryText": "A Skrift Article" }, + { "Id": 6, "CategoryText": "A Tutorial" }, + { "Id": 7, "CategoryText": "Advice" }, + { "Id": 8, "CategoryText": "A Video" }, + { "Id": 9, "CategoryText": "A PR" } + ]; + }, + getHighFiveFeed: function() { + return { + Count: 100, + PageCount: 10, + CurrentPage: 0, + HighFives: [ + { + Id: '123', + From: 'Name of High Fiver', + To: 'Name of High Fivee', + FromAvatarUrl: '/avatar_of_high_fiver.jpg', + ToAvatarUrl: '/avatar_of_high_fivee.jpg', + Type: 'Blog post', + Url: 'http://optional.url.for.high.five.com' + } + ] + }; + }, + getUmbracians: function() { + return [ + { + MemberId: '123', + Username: 'Fred Johnson', + }, + { + MemberId: '124', + Username: 'Fred Samson', + }, + { + MemberId: '125', + Username: 'Fredina Hartvig' + } + ]; + }, + getRandomUmbracians: function() { + return [ + {MemberId: '0001', Username: "Marcin Zajkowski"}, + {MemberId: '0002', Username: "Callum Whyte"}, + {MemberId: '0003', Username: "Anders Bjerner"}, + {MemberId: '0004', Username: "Emma Garland"}, + {MemberId: '0005', Username: "Lars - Erik Aabech"}, + {MemberId: '0006', Username: "Matt Brailsford"}, + {MemberId: '0007', Username: "Carole Rennie Logan"}, + {MemberId: '0008', Username: "Emma Burstow"}, + {MemberId: '0009', Username: "Lee Kelleher"}, + {MemberId: '0010', Username: "Jeffrey Schoemaker"}, + {MemberId: '0011', Username: "Erica Quessenberry"}, + {MemberId: '0012', Username: "Kyle Weems"}, + {MemberId: '0013', Username: "Mike Masey"}, + {MemberId: '0014', Username: "Niels Hartvig"}, + {MemberId: '0015', Username: "Jeavon Leopold"}, + {MemberId: '0016', Username: "Damiaan Peeters"}, + {MemberId: '0017', Username: "Marc Goodson"}, + {MemberId: '0018', Username: "Mads Rasmussen"}, + {MemberId: '0019', Username: "Shannon Deminick"}, + {MemberId: '0020', Username: "Stéphane Gay"}, + {MemberId: '0021', Username: "Sebastiaan Janssen"}, + {MemberId: '0022', Username: "Jacob Midtgaard - Olesen"}, + {MemberId: '0023', Username: "Ilham Boulghallat"} + ] + }, + submitHighFive: function() { + return {}; + } + }; + + // Init + HighFives.init(); + +})(); \ No newline at end of file diff --git a/OurUmbraco.Site/OurUmbraco.Site.csproj b/OurUmbraco.Site/OurUmbraco.Site.csproj index 8f02dce94c..a7b2e01094 100644 --- a/OurUmbraco.Site/OurUmbraco.Site.csproj +++ b/OurUmbraco.Site/OurUmbraco.Site.csproj @@ -455,6 +455,7 @@ + @@ -4438,7 +4439,7 @@ - True + False True 24292 / diff --git a/OurUmbraco.Site/Views/CommunityHub.cshtml b/OurUmbraco.Site/Views/CommunityHub.cshtml index 7086b47d6b..3e82f2f0d2 100644 --- a/OurUmbraco.Site/Views/CommunityHub.cshtml +++ b/OurUmbraco.Site/Views/CommunityHub.cshtml @@ -1,13 +1,4 @@ -@using OurUmbraco.Our -@inherits OurUmbraco.Our.Models.OurUmbracoTemplatePage +@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ - Layout = "~/Views/CommunityHubPageLayout.cshtml"; - - var featuresService = new UpcomingFeaturesService(); - var allowed = featuresService.MemberHasAccessToFeature(); -} - -@if (allowed) -{ - @Html.Partial("~/Views/Partials/Community/Hub.cshtml") + Layout = null; } \ No newline at end of file diff --git a/OurUmbraco.Site/Views/Partials/Community/Home.cshtml b/OurUmbraco.Site/Views/Partials/Community/Home.cshtml index a4894b30b6..46d17327c1 100644 --- a/OurUmbraco.Site/Views/Partials/Community/Home.cshtml +++ b/OurUmbraco.Site/Views/Partials/Community/Home.cshtml @@ -61,6 +61,7 @@ @if (Members.IsLoggedIn()) { + @HighFiveActivity() @ForumActivity() @Gitter() @Meetups() @@ -78,6 +79,67 @@ else @TwitterSearch() } +@helper HighFiveActivity() + { +
    +
    +
    + +
    +

    Community Activity

    +
    +
    +
    +

    + High Five + + + + +
      +
      +
      + + for at + + +

      +
      +
      +
      + +
        + +
        + + +
        +
        +
        + +} + @helper ForumActivity() {
        diff --git a/OurUmbraco.Site/Views/Partials/Community/Scripts.cshtml b/OurUmbraco.Site/Views/Partials/Community/Scripts.cshtml index 99e43cc4f6..78fecb96bf 100644 --- a/OurUmbraco.Site/Views/Partials/Community/Scripts.cshtml +++ b/OurUmbraco.Site/Views/Partials/Community/Scripts.cshtml @@ -30,6 +30,7 @@ catch (errGitHub) { console.log("Couldn't load latest GitHub contributor activity", errGitHub.message); } - + }); - + + \ No newline at end of file diff --git a/OurUmbraco.Site/Views/Partials/Members/PublicProfile.cshtml b/OurUmbraco.Site/Views/Partials/Members/PublicProfile.cshtml index 6e338cec94..18ef77d1cc 100644 --- a/OurUmbraco.Site/Views/Partials/Members/PublicProfile.cshtml +++ b/OurUmbraco.Site/Views/Partials/Members/PublicProfile.cshtml @@ -6,6 +6,7 @@ @using OurUmbraco.MarketPlace.NodeListing @using OurUmbraco.Our @using OurUmbraco.Our.Extensions +@using OurUmbraco.HighFiveFeed.Services @{ var memberId = Request["id"]; int id = 0; @@ -19,6 +20,8 @@ } else { + var highFiveService = new HighFiveFeedService(); + var highFives = highFiveService.GetHighFiveFeedForMember(member.Id); var ts = new TopicService(ApplicationContext.DatabaseContext); var topics = ts.GetLatestTopicsForMember(member.Id); @@ -38,14 +41,14 @@ contribProjects.Add(Umbraco.TypedContent(contribPackageId)); } } - + var reputationCurrent = member.GetPropertyValue("reputationCurrent"); var nodeListingProvider = new NodeListingProvider(); var votedProjects = nodeListingProvider.GetVotedProjectsForMember(member.Id); var rolesForUser = Roles.GetRolesForUser(member.GetPropertyValue("UserName")); - + var avatarService = new AvatarService(); var avatarPath = avatarService.GetMemberAvatar(member); var img = avatarService.GetImgWithSrcSet(avatarPath, member.Name, 125); @@ -120,206 +123,237 @@ { works at @member.GetPropertyValue("company") } - and has @member.GetPropertyValue("forumPosts") @if (member.ForumPosts() == 0 || member.ForumPosts() > 1){posts}else{post} and @member.GetPropertyValue("reputationCurrent") karma points - - -
        -

        @member.GetPropertyValue("profileText")

        -
        + and has @member.GetPropertyValue("forumPosts") @if (member.ForumPosts() == 0 || member.ForumPosts() > 1) + {posts} + else + {post} and @member.GetPropertyValue("reputationCurrent") karma points + + +
        +

        @member.GetPropertyValue("profileText")

        -
        -
        -
        -

        Activity

        - @foreach (var topic in topics) +
        +
        +
        +
        +

        Activity

        + @foreach (var topic in topics) + { + var cat = Umbraco.TypedContent(topic.ParentId); + // if cat == null then it's been hidden/unpublished (example: v5 forum) + // if this is the case: don't show forum post in list + if (cat != null) { - var cat = Umbraco.TypedContent(topic.ParentId); - // if cat == null then it's been hidden/unpublished (example: v5 forum) - // if this is the case: don't show forum post in list - if (cat != null) - { - var mem = Members.GetById(topic.LatestReplyAuthor) ?? Members.GetById(topic.MemberId); - var memImg = avatarService.GetImgWithSrcSet(mem, mem.Name, 75); - - -
        - @if (projects.Any()) - { -
        -
        - + @if (highFives.HighFives.ToList().Any()) + { +
        +
        +
        +

        High Five Feed

        + @foreach (var highFive in highFives.HighFives.ToList().OrderByDescending(x => x.CreatedDate)) + { +
        +
        + @highFive.From +
        + +
        +
        +

        High Five @highFive.To!!

        +

        + @highFive.From High Fived you for @highFive.Category : @highFive.LinkTitle, @highFive.CreatedDate.ToShortDateString() +

        +
        +
        +
        }
        -
        - } - @if (contribProjects.Any()) - { -
        -
        -
        -

        Packages contributed to

        - @foreach (var project in contribProjects.Where(x => x.GetPropertyValue("projectLive")).OrderByDescending(x => x.CreateDate)) - { - -
        -
        - @if (string.IsNullOrWhiteSpace(project.GetPropertyValue("defaultScreenshotPath").Trim())) - { - - } - else - { - @project.Name - } +
        + } + + @if (projects.Any()) + { +
        + } - @if (votedProjects.Any()) - { - + + if (MemberData != null && MemberData.IsAdmin) + { + var allTopics = ts.GetLatestTopicsForMember(member.Id, false, 1000); -
        -

        Moderator Tools (also known as "with great power comes great responsibility"):


        - @if (member.GetPropertyValue("blocked") == false) +
        +

        Moderator Tools (also known as "with great power comes great responsibility"):


        + @if (member.GetPropertyValue("blocked") == false) + { + Block this member
        + } + else + { + Unblock this member
        + Member is blocked
        + } +

        + @if (reputationCurrent < 71 || rolesForUser.Contains("potentialspam") || rolesForUser.Contains("newaccount")) + { + Approve member (careful now! if you approve this member, EVERYTHING that they posted and is marked as spam will be marked as ham.. )
        + } +

        +

        All threads this member was involved in (created or commented)

        + +
        + } +

        + var currentMember = MemberData != null ? MemberData.Member : null; + if (currentMember != null && currentMember.IsHq()) + { +
        +

        HQ Tools (also known as "with great power comes great responsibility"):


        + @{ + if (rolesForUser.Contains("potentialspam")) { - Unblock this member
        - Member is blocked
        + Member is in role "potentialspam"
        } -

        - @if (reputationCurrent < 71 || rolesForUser.Contains("potentialspam") || rolesForUser.Contains("newaccount")) + if (rolesForUser.Contains("newaccount")) { - Approve member (careful now! if you approve this member, EVERYTHING that they posted and is marked as spam will be marked as ham.. )
        - } -

        -

        All threads this member was involved in (created or commented)

        - -
        - } -

        - var currentMember = MemberData != null ? MemberData.Member : null; - if (currentMember != null && currentMember.IsHq()) - { -
        -

        HQ Tools (also known as "with great power comes great responsibility"):


        - @{ - if (rolesForUser.Contains("potentialspam")) - { - Member is in role "potentialspam"
        - } - if (rolesForUser.Contains("newaccount")) - { - Member is in role "newaccount"
        - } + Member is in role "newaccount"
        } -

        - Delete this member including all their topics and comments
        -
        - } + } +

        + Delete this member including all their topics and comments
        +
        } } +} \ No newline at end of file diff --git a/OurUmbraco.Site/Views/Search.cshtml b/OurUmbraco.Site/Views/Search.cshtml index c1dbef44da..3e82f2f0d2 100644 --- a/OurUmbraco.Site/Views/Search.cshtml +++ b/OurUmbraco.Site/Views/Search.cshtml @@ -1,11 +1,4 @@ -@using OurUmbraco.Our.Models -@inherits UmbracoTemplatePage +@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ - Layout = "~/Views/Master.cshtml"; -} -
        - - @Html.Action("Render", "Search") - - -
        + Layout = null; +} \ No newline at end of file diff --git a/OurUmbraco.Site/Views/Videos.cshtml b/OurUmbraco.Site/Views/Videos.cshtml index 846ee203b1..3e82f2f0d2 100644 --- a/OurUmbraco.Site/Views/Videos.cshtml +++ b/OurUmbraco.Site/Views/Videos.cshtml @@ -1,13 +1,4 @@ -@using OurUmbraco.Our -@inherits OurUmbraco.Our.Models.OurUmbracoTemplatePage +@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ - Layout = "~/Views/Master.cshtml"; - - var featuresService = new UpcomingFeaturesService(); - var allowed = featuresService.MemberHasAccessToFeature(); -} - -@if (allowed) -{ - @Html.Partial("~/Views/Partials/Videos/Home.cshtml") + Layout = null; } \ No newline at end of file diff --git a/OurUmbraco.Site/config/ClientDependency.config b/OurUmbraco.Site/config/ClientDependency.config index 231bc31285..86b8995d84 100644 --- a/OurUmbraco.Site/config/ClientDependency.config +++ b/OurUmbraco.Site/config/ClientDependency.config @@ -10,7 +10,7 @@ NOTES: * Compression/Combination/Minification is not enabled unless debug="false" is specified on the 'compiliation' element in the web.config * A new version will invalidate both client and server cache and create new persisted files --> - +