12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805 |
- $(document).ready(function() {
-
-
- var tags;
-
-
- $.fn.bootstrapBtn = $.fn.button.noConflict();
-
-
- document.getElementById("7-5-col-layout").style.MozColumnCount = "5";
- document.getElementById("4-col-layout").style.MozColumnCount = "4";
-
-
- $('.proj_title').keydown(function(event){
- if(event.keyCode == 13) {
- event.preventDefault();
- return false;
- }
- });
-
-
-
-
- var groupOneLayout = $("#7-5-col-layout");
- var groupTwoLayout = $("#4-col-layout");
-
- var field01 = $("#panel_01");
- var field03 = $("#panel_03");
- var field04 = $("#panel_04");
- var field09 = $("#panel_09");
- var field05 = $("#panel_05");
- var field06 = $("#panel_06");
- var field02 = $("#panel_02");
- var field07 = $("#panel_07");
- var field08 = $("#panel_08");
-
- var isRearranged = false;
-
-
- function rearrangeFields() {
- field01.detach();
- field03.detach();
- field04.detach();
- field09.detach();
- field05.detach();
- field06.detach();
- field02.detach();
- field07.detach();
- field08.detach();
-
- groupOneLayout.append(field01);
- groupOneLayout.append(field02);
- groupOneLayout.append(field03);
- groupOneLayout.append(field04);
- groupOneLayout.append(field05);
- groupOneLayout.append(field06);
- groupOneLayout.append(field07);
- groupOneLayout.append(field08);
- groupOneLayout.append(field09);
- }
-
-
- function rearrangeFieldsOriginal() {
- field01.detach();
- field02.detach();
- field03.detach();
- field04.detach();
- field05.detach();
- field06.detach();
- field07.detach();
- field08.detach();
- field09.detach();
-
- groupOneLayout.append(field01);
- groupOneLayout.append(field03);
- groupOneLayout.append(field04);
- groupOneLayout.append(field09);
- groupOneLayout.append(field05);
- groupOneLayout.append(field06);
- groupOneLayout.append(field02);
- groupTwoLayout.append(field07);
- groupTwoLayout.append(field08);
- }
-
-
- if ($(window).width() <= 499) {
- rearrangeFields();
- }
-
-
- $(window).on("resize", function() {
- if (isRearranged === false && $(window).width() <= 499) {
- rearrangeFields();
-
- isRearranged = true;
- }
- else if(isRearranged === true && $(window).width() >= 500) {
- rearrangeFieldsOriginal();
-
- isRearranged = false;
- }
- });
-
-
-
-
- $(window).scroll(function() {
-
- if($(window).width() <= 499) {
-
- var scrollPosition = $(window).scrollTop();
-
- var firstItemPosition = $("div.saved-tags").offset().top;
-
-
- if(scrollPosition >= firstItemPosition) {
- $("div.jump-to").css("display", "block");
- }
- else {
- $("div.jump-to").css("display", "none");
- }
- }
- else {
- $("div.jump-to").css("display", "none");
- }
- });
-
-
- $("div.jump-to-click-area").on("click", function() {
-
- $("div.jump-to div div").slideToggle(300);
-
-
-
-
- $(".jump-to img").toggleClass("jump-to-arrow-90");
- $(".jump-to img").toggleClass("jump-to-arrow-0");
-
- return false;
- });
-
-
- $("div.jump-to ul a").on("click", function() {
-
- var chosenLiIndex = $(this).parent().index();
- var chosenFieldPosition;
- var scrollPositionNew;
-
-
- $("div.jump-to div div").slideToggle(300);
-
-
-
-
- $(".jump-to img").toggleClass("jump-to-arrow-90");
- $(".jump-to img").toggleClass("jump-to-arrow-0");
-
-
-
- if(chosenLiIndex === 0) {
- chosenFieldPosition = $("div.saved-tags").offset().top;
- }
-
- else if(chosenLiIndex >= 1 && chosenLiIndex <= 9) {
- chosenFieldPosition = $("div.field_0" + chosenLiIndex).offset().top;
- }
-
- else {
- chosenFieldPosition = $("div.field_" + chosenLiIndex).offset().top;
- }
-
-
-
- if(chosenLiIndex === 0) {
- scrollPositionNew = chosenFieldPosition - 14;
- }
-
- else {
- scrollPositionNew = chosenFieldPosition - 57;
- }
-
-
- $(window).scrollTop(scrollPositionNew);
-
- return false;
- });
-
-
-
- $("a[data-toggle='tooltip']").tooltip({container: "body"});
-
- $("a[data-toggle='tooltip']").on("click", function() {
- return false;
- });
-
-
-
-
- function removeTags() {
-
- $.ajax({
- type: "POST",
- url: "php/get-tags.php",
- dataType: "JSON",
- data: {
- "username": username
- },
- timeout: 5000,
- success: function(returnData) {
-
- var loopCounter = 0;
- tags = returnData;
-
-
- $("li.added_item div").each(function() {
- var thisDiv = $(this);
-
-
- for(t in tags) {
-
- if(thisDiv.html().indexOf("</a>") != -1) {
-
- var text = thisDiv.html();
- text = thisDiv.text().replace("<a class='tag'>" + tags[loopCounter] + "</a>", tags[loopCounter]);
- thisDiv.html(text);
- }
-
- loopCounter++;
- }
- });
-
- if(tags.length === 0) {
- $("div.saved-tags p").html("You haven't added any tags yet.");
- }
- },
- error: function(xhr) {
- console.log(xhr.statusText);
- }
- });
-
-
- }
-
-
-
-
- function applyTags() {
- var loopCounter = 0;
-
-
-
- $("li.added_item div").each(function() {
-
-
-
- for(t in tags) {
-
-
-
-
-
-
-
-
-
-
- var text = $(this).html();
-
-
- if(text.indexOf(tags[loopCounter]) != -1) {
-
-
-
-
-
-
-
- text = text.replace(tags[loopCounter], "<a class='tag' contenteditable='false'>" + tags[loopCounter] + "</a>");
- $(this).html(text);
- }
-
- loopCounter++;
- }
- });
-
-
- loopCounter = 0;
-
- var savedTags = $("div.saved-tags p");
-
- savedTags.html("");
-
- for(t in tags) {
- if(savedTags.html() === "You haven't added any tags yet.") {
- savedTags.html("");
- }
-
- savedTags.append("<a href='#' class='tag'>" + tags[loopCounter] + "</a>").append(" ");
-
- loopCounter++;
- }
- }
-
-
- function getTags() {
-
- var username = $("input[name='username']").val();
-
-
- $.ajax({
- type: "POST",
- url: "php/get-tags.php",
- dataType: "JSON",
- data: {
- "username": username
- },
- timeout: 5000,
- success: function(returnData) {
- if(returnData.length > 0) {
-
- tags = returnData;
-
-
- returnData.sort(function (a, b) {
- return a.toLowerCase().localeCompare(b.toLowerCase())
- });
-
-
- applyTags();
- showTagWindowOnTagClick();
- }
- },
- error: function(xhr) {
- console.log(xhr.statusText);
- }
- });
- }
-
-
-
- if($("input[name='name']").val() != "") {
- getTags();
- }
-
-
-
-
-
- var textareaHasBeenChanged = false;
- var tag;
- var tagIsNew = false;
- var username = $("input[name='username']").val();
-
-
- function checkIfTagIsNew() {
-
- var tagToAJAX = tag;
-
-
- $.ajax({
- type: "POST",
- url: "php/check-if-tag-exists.php",
- dataType: "text",
- data: {
- "tag": tagToAJAX,
- "username": username
- },
- timeout: 5000,
- success: function(returnData) {
-
- if(returnData === "") {
-
- $("div#tag-window button#delete-tag").css("display", "none");
-
-
- $("div#tag-window h2.similar-tags").css("display", "none");
-
-
- tagIsNew = true;
- }
-
- else {
-
- $("div#tag-window button#delete-tag").css("display", "inline");
-
-
- $("div#tag-window h2.similar-tags").css("display", "block");
- }
- },
- error: function(xhr) {
- console.log(xhr.statusText);
- }
- });
- }
-
-
- function updateRemainingCharacters() {
-
- var length = $("div#tag-window textarea#tag-description").val().length;
- var maxLength = 200;
-
-
-
-
- length = maxLength - length;
-
-
- $("div#tag-window span.chars").text(length);
- }
-
-
- function getDescriptionForSelectedTag() {
-
- var tagToAJAX = tag;
-
-
- $.ajax({
- type: "POST",
- url: "php/get-description-for-selected-tag.php",
- dataType: "text",
- data: {
- "tag": tagToAJAX,
- "username": username
- },
- timeout: 5000,
- success: function(returnData) {
- if(returnData != "") {
-
- $("div#tag-window textarea#tag-description").val(returnData);
-
-
- updateRemainingCharacters();
- }
-
- textareaHasBeenChanged = true;
- },
- error: function(xhr) {
- console.log(xhr.statusText);
- }
- });
- }
-
-
- function getSimilarTags() {
-
- var tagToAJAX = tag;
-
-
- $.ajax({
- type: "POST",
- url: "php/get-similar-tags.php",
- dataType: "JSON",
- data: {
- "tag": tagToAJAX,
- "username": username
- },
- timeout: 5000,
- success: function(returnData) {
-
- $("p.similar-tags-tag").remove();
- $("p.similar-tags-description").remove();
- $("p.similar-tags-username").remove();
-
-
- var htmlToAppend = "";
-
-
- if(returnData.length > 0) {
-
- var index = 0;
-
-
- while(index < returnData.length) {
- htmlToAppend += "<p class='similar-tags-tag'><a class='tag'>" + returnData[index]["tag"] + "</a></p>"
- + "<p class='similar-tags-description'>" + returnData[index]["description"] + "</p>"
- + "<p class='similar-tags-username'>by <a href='#'>" + returnData[index]["username"] + "</a></p>";
-
- index++;
- }
-
-
- $("div#tag-window h2.similar-tags").after(htmlToAppend);
- $("p.similar-tags-description-none").css("display", "none");
-
-
-
-
- }
- else {
-
- if(tagIsNew === false) {
-
- $("p.similar-tags-description-none").css("display", "block");
- }
- }
- },
- error: function(xhr) {
- console.log(xhr.statusText);
- }
- });
- }
-
-
- function closeTagWindow() {
- $("div#shadow").css("display", "none");
- $("div#tag-window").css("display", "none");
- }
-
-
- function showTagWindow() {
-
- $("div#shadow").css("display", "block");
- $("div#tag-window").css("display", "block");
-
-
-
-
-
- checkIfTagIsNew();
-
-
- getDescriptionForSelectedTag();
-
-
- getSimilarTags();
-
-
- updateRemainingCharacters();
-
-
- if($("div#tag-window textarea#tag-description") !== "Please enter a description..." && textareaHasBeenChanged !== true) {
-
- $("div#tag-window span.chars").text("200");
- }
- }
-
-
- $("div#tag-window textarea#tag-description").on("keyup", function() {
-
- updateRemainingCharacters();
- });
-
-
- $("div#tag-window #save-tag").on("click", function() {
-
- var description = $("div#tag-window textarea#tag-description").val();
- var tagToAJAX = tag;
-
-
- if(description != "" && description != "Please enter a description...") {
-
- $.ajax({
- timeout: 5000,
- dataType: "text",
- type: "post",
- data: {
- "tag": tagToAJAX,
- "description": description,
- "username": username
- },
- url: "php/save-tag.php",
- success: function() {
- textareaHasBeenChanged = true;
-
-
- getTags();
- },
- error: function(xhr) {
- console.log(xhr.statusText);
- }
- });
-
-
- closeTagWindow();
- }
-
- tagIsNew = false;
- });
-
-
- $("div#tag-window button.close").on("click", function() {
-
- closeTagWindow();
- });
-
-
- $("div#tag-window #delete-tag").on("click", function() {
-
- var tagToAJAX = tag;
-
-
- $.ajax({
- timeout: 5000,
- dataType: "text",
- type: "post",
- data: {
- "tag": tagToAJAX,
- "username": username
- },
- url: "php/delete-tag.php",
- success: function() {
-
- removeTags();
-
-
- getTags();
- },
- error: function(xhr) {
- console.log(xhr.statusText);
- }
- });
-
-
- closeTagWindow();
- });
-
-
- $("div#tag-window textarea#tag-description").on("focusin", function() {
-
- var description = $("div#tag-window textarea#tag-description").val();
-
-
-
- if(description === "Please enter a description...") {
-
- $("div#tag-window textarea#tag-description").val("");
- }
- });
-
-
- $("div#tag-window textarea#tag-description").on("focusout", function() {
-
- var description = $("div#tag-window textarea#tag-description").val();
-
-
-
- if(description === "") {
-
- $("div#tag-window textarea#tag-description").val("Please enter a description...");
- }
- });
-
-
-
-
-
- function applyTagOnTypeMatch() {
- $("li.added_item div").on("focusin", function() {
-
- $("li.added_item div").on("keyup", function() {
- if(event.which !== 9 &&
- event.which !== 16 &&
- event.which !== 37 &&
- event.which !== 38 &&
- event.which !== 39 &&
- event.which !== 40) {
-
- var bugCounter = 0;
- var loopCounter = 0;
- var tagLinkToSearch;
- var tagLinkHits;
- var tagTextToSearch;
- var tagTextHits;
- var text = $(this).html();
-
-
- if(!bugCounter > 0) {
-
-
-
- for(t in tags) {
- if($(this).html().indexOf(tags[loopCounter]) != -1) {
-
- tagLinkToSearch = text.match(tags[loopCounter] + "</a>");
-
- tagTextToSearch = text.match(tags[loopCounter]);
-
-
- if(tagLinkToSearch !== null) {
-
- tagLinkHits = tagLinkToSearch.length;
- }
- else {
-
- tagLinkHits = 0;
- }
-
-
- if(tagTextToSearch !== null) {
-
- tagTextHits = tagTextToSearch.length;
- }
- else {
-
- tagTextHits = 0;
- }
-
-
-
- if(tagTextHits > tagLinkHits && tagLinkHits === 0) {
-
- text = text.replace(tags[loopCounter], "<a class='tag' contenteditable='false'>" + tags[loopCounter] + "</a>");
- $(this).html(text);
- }
- }
-
- loopCounter++;
- }
- }
- bugCounter++;
- }
- });
- });
- };
-
-
- var maxLength = 100;
-
- $('.card').on('keyup', '.new_item', function() {
- var length = $(this).val().length;
- length = maxLength - length;
-
- $(this).closest('.user-input').find('.chars').text(length);
- });
-
- function limitLengthOnInput() {
-
- $("li.added_item div").on("keypress", function(event) {
-
- var numberOfTags = $(this).children().filter("a").length;
- var textLength = $(this).html().length;
-
-
- $(this).each(function() {
- textLength -= 43 * numberOfTags;
- });
-
- if(textLength === 100) {
- event.preventDefault();
- }
- });
-
-
-
-
-
- }
-
-
-
-
- var selection = "";
-
-
-
- tag = "";
-
-
- document.onselectionchange = function() {
-
- if($("li.added_item div").is(":focus")) {
- selection = window.getSelection().toString();
- tag = selection.trim();
- }
- }
-
-
- $("p.tag-selected-term a").on("click", function() {
-
- if(tag != "") {
-
- showTagWindow();
- }
- else {
-
- $("div#shadow").css("display", "block");
- $("#dialog-select-term").dialog({draggable: false, resizable: false});
-
-
- $(".ui-button-icon-only").html("<button type='button' class='close' aria-label='Close'><span aria-hidden='true'>×</span></button>");
- }
-
-
- return false;
- });
-
-
- $(".dialog").on("dialogclose", function() {
- $("div#shadow").css("display", "none");
- });
-
-
-
- $("li.added_item div").on("focusout", function() {
- selection = "";
- tag = "";
- });
-
-
-
- function showTagWindowOnTagClick() {
- $("a.tag").on("click", function() {
-
- tag = $(this).text();
-
-
- if($("input[name='username']").val() != "") {
-
- showTagWindow();
- }
- else {
-
- $("div#shadow").css("display", "block");
- $("#dialog-log-in").dialog({draggable: false, resizable: false});
-
-
- $(".ui-button-icon-only").html("<button type='button' class='close' aria-label='Close'><span aria-hidden='true'>×</span></button>");
- }
- });
- }
-
-
-
-
-
- $.fn.serializeObject = function() {
- var o = {};
- var a = this.serializeArray();
- $.each(a, function() {
- if (o[this.name]) {
- if (!o[this.name].push) {
- o[this.name] = [o[this.name]];
- }
- o[this.name].push(this.value || '');
- } else {
- o[this.name] = this.value || '';
- }
- });
- return o;
- };
-
-
-
- var fullDate = new Date();
- var twoDigitMonth = fullDate.getMonth() + "";
- if (twoDigitMonth.length == 1) twoDigitMonth = "0" + twoDigitMonth;
- var twoDigitDate = fullDate.getDate() + "";
- if (twoDigitDate.length == 1) twoDigitDate = "0" + twoDigitDate;
-
- var currentDate = fullDate.getFullYear() + "-" + twoDigitMonth + "-" + twoDigitDate;
-
- $('.proj_date').val(currentDate);
-
-
-
- $('.user-profile').on('click', '#logout', function() {
- var url = 'php/logout.php';
- $.post(url, function(data, status) {
- if (data == 200) {
- $('.user-profile').hide();
- window.location.href="https://www.ethicscanvas.org";
- }
- });
- });
-
-
-
-
- if (current_canvas_id !== '') {
-
- var url = 'json/' + current_canvas_id + '.json';
-
-
-
- $.getJSON(url, function(returnedObj) {
-
-
-
- var itemListHTML = '';
-
- $.each(returnedObj, function(key, value) {
-
- if (key === 'field_00[]') {
-
- $('.form-header').find('input.proj_title').val(value[
- 0]);
- $('.form-header').find('input.proj_date').val(value[1]);
-
- }
- else if (key !== 'new_item') {
-
- if ($.type(value) === "array") {
- $.each(value, function(i, itm) {
-
-
- $('.canvas-form').find('.card').filter('.' + key.substr(0, 8)).find('ul.item_list').html('');
-
-
-
- itemListHTML +=
-
- '<li class="added_item"><div class="expandable" name="' + key + '" contenteditable="true">' + itm + '</div><span class="handle glyphicon glyphicon-list"></span><span class="move-up glyphicon glyphicon-chevron-up"></span><span class="move-down glyphicon glyphicon-chevron-down"></span><span class="remove glyphicon glyphicon-remove-circle"></span></li>';
- });
- }
- else {
- itemListHTML +=
-
- '<li class="added_item"><div class="expandable" name="' + key + '" contenteditable="true">' + value + '</div><span class="handle glyphicon glyphicon-list"></span><span class="move-up glyphicon glyphicon-chevron-up"></span><span class="move-down glyphicon glyphicon-chevron-down"></span><span class="remove glyphicon glyphicon-remove-circle"></span></li>';
- }
-
-
-
-
-
- $('.canvas-form').find('.card').filter('.' + key.substr(0, 8)).find('ul.item_list').append(itemListHTML);
-
-
- itemListHTML = '';
-
- }
- });
-
- });
-
-
- getTags();
-
-
- if($(this).parent().parent().parent().prev().prev().children().length > 0) {
- $(this).parent().parent().parent().prev().css("display", "block");
- }
-
-
-
- }
-
-
-
-
- $('.card').on('click', '.intro-toggle', function() {
- var $TogglingText = $($(this).closest('.card').find('.intro'));
- var $Toggler = $($(this).closest('.card').find('.intro-toggle'));
- $TogglingText.toggle('slow', function() {
-
-
- if ($TogglingText.is(':visible')) {
-
- $Toggler.find('.intro-toggle-text').text('Hide description');
-
- $Toggler.find('.intro-toggle-icon').switchClass("glyphicon-plus-sign", "glyphicon-minus-sign", 1000, "easeInOutQuad");
- }
- else {
- $Toggler.find('.intro-toggle-text').text('Show description');
- $Toggler.find('.intro-toggle-icon').switchClass("glyphicon-minus-sign", "glyphicon-plus-sign", 1000, "easeInOutQuad");
-
- }
-
- });
-
- });
-
-
-
-
-
-
-
-
-
-
-
-
-
- $('.card').on('click', 'a.add-idea', function(event) {
-
- event.preventDefault();
-
- $(this).closest('.card').find('.user-input').slideToggle("slow", function() {
-
-
- $(this).closest('.card').find('.new_item').val('');
- $(this).closest('.card').find('.chars').text(maxLength);
- $(this).closest('.card').find('.new_item').focus();
- });
-
- });
-
-
-
-
- $('.card').on('click', '.add_btn', function() {
- var new_item = $(this).closest('.card').find('.new_item').val();
- var new_item_height = $(this).closest('.card').find('.new_item').height();
-
- var fieldItemCount = $(this).closest('.card').find('ul.item_list').find('li').length;
-
- fieldItemCount++;
-
-
-
-
- if (new_item) {
- var field_attr = $(this).closest('.card').find('ul.item_list').attr('id') + '[]';
-
- $(this).closest('.card').find('ul.item_list').append(
-
- '<li class="added_item"><div class="expandable" name="' + field_attr + '" contenteditable="true">' + new_item + '</div><span class="handle glyphicon glyphicon-list"></span><span class="move-up glyphicon glyphicon-chevron-up"></span><span class="move-down glyphicon glyphicon-chevron-down"></span><span class="remove glyphicon glyphicon-remove-circle"></span></li>'
- );
-
-
-
- }
-
- $(this).closest('.card').find('.new_item').val('');
-
- $(this).closest('.card').find('.user-input').hide("fast", function() {
-
- });
-
-
- limitLengthOnInput();
-
-
- applyTagOnTypeMatch();
-
-
- removeTags();
-
-
- getTags();
-
-
- if($(this).parent().parent().prev().prev().children().length > 0) {
- $(this).parent().parent().prev().css("display", "block");
- }
- });
-
-
-
- $('.card').on('keypress', 'textarea[data-limit-rows=true]', function(event) {
- var textarea = $(this);
- var text = textarea.val();
-
-
-
- if (event.which === 13) {
- var new_item = $(this).closest('.card').find('.new_item').val();
- var new_item_height = $(this).closest('.card').find('.new_item').height();
-
- var fieldItemCount = $(this).closest('.card').find('ul.item_list')
- .find('li').length;
-
- fieldItemCount++;
-
-
-
-
- if (new_item) {
- var field_attr = $(this).closest('.card').find('ul.item_list').attr(
- 'id') + '[]';
-
- $(this).closest('.card').find('ul.item_list').append(
-
- '<li class="added_item"><div class="expandable" name="' + field_attr + '" contenteditable="true">' + new_item + '</div><span class="handle glyphicon glyphicon-list"></span><span class="move-up glyphicon glyphicon-chevron-up"></span><span class="move-down glyphicon glyphicon-chevron-down"></span><span class="remove glyphicon glyphicon-remove-circle"></span></li>'
- );
-
-
- }
-
- $(this).closest('.card').find('.new_item').val('');
-
- $(this).closest('.card').find('.user-input').hide("fast", function() {
-
- });
-
-
- limitLengthOnInput();
-
-
- applyTagOnTypeMatch();
-
-
- removeTags();
-
-
- getTags();
-
-
- if($(this).parent().parent().parent().prev().prev().children().length > 0) {
- $(this).parent().parent().parent().prev().css("display", "block");
- }
- }
- });
-
-
-
-
-
- var categoryDestination;
- var categoryLis = $("div#move-window ul").html();
- var categoryOrigin;
- var ideaLi;
- var linkLi;
- var linkText;
-
-
- function removeLinkToOriginCategory(text) {
-
- if(text.substring(6, 7) != "0") {
- categoryOrigin = text.substring(6, 9) - 1;
- }
-
- else {
- categoryOrigin = text.substring(7, 9) - 1;
- }
-
-
- linkLi = $("div#move-window ul li").get(categoryOrigin);
- linkText = $("div#move-window ul a").get(categoryOrigin).innerHTML;
- linkLi.innerHTML = linkText;
- }
-
-
- $('.card').on('click', 'span.handle', function() {
-
- $("div#shadow").css("display", "block");
- $("div#move-window").css("display", "block");
-
-
- ideaLi = $(this).parent();
-
-
- removeLinkToOriginCategory($(this).parent().parent().attr("id"));
- });
-
-
- function closeMoveWindow() {
-
- $("div#shadow").css("display", "none");
- $("div#move-window").css("display", "none");
- }
-
-
- $("div#move-window button.close").on("click", function() {
-
- closeMoveWindow();
- });
-
-
- function moveIdeaOnClick() {
- $("div#move-window ul a").on("click", function() {
-
- if($(this).parent().text().trim().substring(1, 2) != ".") {
- categoryDestination = $(this).parent().text().trim().substring(0, 2);
- }
-
- else {
- categoryDestination = $(this).parent().text().trim().substring(0, 1);
- }
-
-
-
- if(categoryDestination > 9) {
- $("ul#field_" + categoryDestination).append(ideaLi);
-
- }
-
- else {
- $("ul#field_0" + categoryDestination).append(ideaLi);
-
- }
-
-
- closeMoveWindow();
-
-
- if($("div#move-window li").length > $("div#move-window a").length) {
- $("div#move-window ul").children().remove()
- $("div#move-window ul").append(categoryLis);
- moveIdeaOnClick();
- }
-
-
- if($("ul#field_0" + (categoryOrigin + 1)).children().length === 0) {
-
- if((categoryOrigin + 1) > 9) {
- $("ul#field_" + (categoryOrigin + 1)).parent().find("p.tag-selected-term").css("display", "none");
- }
-
- else {
- $("ul#field_0" + (categoryOrigin + 1)).parent().find("p.tag-selected-term").css("display", "none");
- }
- }
-
-
-
- if((categoryOrigin + 1) > 9) {
- $("ul#field_" + categoryDestination).parent().find("p.tag-selected-term").css("display", "block");
- }
-
- else {
- $("ul#field_0" + categoryDestination).parent().find("p.tag-selected-term").css("display", "block");
- }
- });
- }
-
- moveIdeaOnClick();
-
-
-
-
- $('.card').on('click', 'span.move-up', function() {
-
- var ideaLiCurrent = $(this).parent();
- var ideaLiPrevious = $(this).parent().prev();
-
-
- if(ideaLiPrevious.is("li")) {
- ideaLiCurrent.detach();
- ideaLiPrevious.before(ideaLiCurrent);
- }
- });
-
-
-
-
- $('.card').on('click', 'span.move-down', function() {
-
- var ideaLiCurrent = $(this).parent();
- var ideaLiNext = $(this).parent().next();
-
-
- if(ideaLiNext.is("li")) {
- ideaLiCurrent.detach();
- ideaLiNext.after(ideaLiCurrent);
- }
- });
-
-
-
-
-
- $('.card').on('click', 'span.remove', function() {
-
- if($(this).prev().parent().parent().children().length === 1) {
- $(this).prev().parent().parent().next().css("display", "none");
- }
-
-
- $(this).closest('li').remove();
- });
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $('.canvas-form').on('click', '.json_exp', function() {
-
-
-
- var name_save_canvas = $('.form-header').find('.proj_title').val();
- var date_save_canvas = $('.form-header').find('.proj_date').val();
- var save_canvas_obj = {
- 'email_save_canvas': email_save_canvas,
- 'name_save_canvas': name_save_canvas,
- 'date_save_canvas': date_save_canvas
- };
-
- var save_canvas = $.param(save_canvas_obj);
-
- var save_reg_url = "php/save-canvas.php";
-
- $.post(save_reg_url, { save_canvas: save_canvas }, function(data, status) {
-
- var canvas_id = data;
-
-
-
- if (data !== 400 || data !== 401) {
- if ($('.imp-exp-btn ').find(".save-canvas-feedback") !== null) {
- $('.imp-exp-btn ').find(".save-canvas-feedback").remove();
- }
- $('.canvas-form').find('.imp-exp-btn ').append('<div class="save-canvas-feedback"><p><span class="glyphicon glyphicon-ok" aria-hidden="true"></span>Your canvas is saved in your dashbord</p></div>');
-
-
- $('.canvas-form').on("change keyup", '.expandable', function() {
- $('.imp-exp-btn ').find(".save-canvas-feedback").remove();
- });
- } else {
- $('.canvas-form').find('.imp-exp-btn ').append('<div class="save-canvas-feedback-fail"><p>Oh! We could not save your canvas. Please try again or contact us at hello@ethicscanvas.org</p></div>');
- }
-
-
-
-
-
-
-
- var JSONstrObj = JSON.stringify($('.canvas-form').serializeObject());
- var url = "php/canvas.php";
-
-
- $.post(url, {
- JSONstrObj: JSONstrObj,
- canvas_id: canvas_id
- }, function(data, status) {
- console.log(
- 'Response from php when sending the form json object: \n' +
- 'data:' + data + '\n status: ' + status);
- }).fail(function(jqXHR) {
- console.log("Error " + jqXHR.status + ' ' + jqXHR.statustext);
- });
-
- }).fail(function(jqXHR) {
- console.log("Error " + jqXHR.status + ' ' + jqXHR.statustext);
- });
-
-
-
- return false;
- });
-
-
-
- $('.canvas-form').on('click', '.share_canvas', function() {
- $('.share_canvas_email').slideDown(1000, function() {
-
-
- $.post('mpdf/canvas-pdf-save.php', function(data, status) { });
-
- });
- });
-
- $('.canvas-form').on('click', '.share_canvas_send', function() {
-
- var share_email = $('.share_canvas_email').find('input').serialize();
-
- $.post('php/share-canvas.php', {
- share_email: share_email
- }, function(data, status) {
- if (data == 200) {
- $('.canvas-form').find('.imp-exp-btn ').append('<div class="save-canvas-feedback"><p><span class="glyphicon glyphicon-ok" aria-hidden="true"></span>Your canvas has been shared by email</p></div>')
- }
- else {
- $('.canvas-form').find('.imp-exp-btn ').append('<div class="save-canvas-feedback"><p><span class="glyphicon glyphicon-ok" aria-hidden="true"></span>Your canvas could not be shared by email</p></div>')
- }
- });
-
-
-
- $('.share_canvas_email').slideUp();
- });
-
-
-
-
-
-
-
-
- });
|