dev:changes in mynotes with edit option
Showing
9 changed files
with
186 additions
and
29 deletions
... | @@ -2,6 +2,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -2,6 +2,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
2 | var CONFIG; | 2 | var CONFIG; |
3 | var NODES = { | 3 | var NODES = { |
4 | DELETE_ICON: '<span class="delete">❌</span>', | 4 | DELETE_ICON: '<span class="delete">❌</span>', |
5 | EDIT_ICON: '<i class="far fa-edit" id="mynote-edit"></i>', | ||
6 | SAVE_ICON: '<i class="far fa-save" id="mynote-update"></i>', | ||
5 | }; | 7 | }; |
6 | var SELECTORS = { | 8 | var SELECTORS = { |
7 | MYNOTES_BASE: '#mynotes_base', | 9 | MYNOTES_BASE: '#mynotes_base', |
... | @@ -16,6 +18,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -16,6 +18,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
16 | var panel = null; | 18 | var panel = null; |
17 | var initnotes = null; | 19 | var initnotes = null; |
18 | var strdeletenote = M.util.get_string('deletemynotes', 'block_mynotes'); | 20 | var strdeletenote = M.util.get_string('deletemynotes', 'block_mynotes'); |
21 | var streditnote = M.util.get_string('editmynotes', 'block_mynotes'); | ||
22 | // var strupdatenote = M.util.get_string('updatemynotes', 'block_mynotes'); | ||
19 | var getMynotesValidatedUrl = function(baseurl) { | 23 | var getMynotesValidatedUrl = function(baseurl) { |
20 | var a = document.createElement('a'); | 24 | var a = document.createElement('a'); |
21 | a.href = baseurl; | 25 | a.href = baseurl; |
... | @@ -368,7 +372,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -368,7 +372,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
368 | var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab); | 372 | var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab); |
369 | 373 | ||
370 | if (mynotescount > 0) { | 374 | if (mynotescount > 0) { |
371 | noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount); | 375 | noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount+')'); |
372 | } else { | 376 | } else { |
373 | noteinfo.find('.count').html(M.util.get_string('nothingtodisplay', 'block_mynotes')); | 377 | noteinfo.find('.count').html(M.util.get_string('nothingtodisplay', 'block_mynotes')); |
374 | } | 378 | } |
... | @@ -386,21 +390,23 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -386,21 +390,23 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
386 | 390 | ||
387 | $('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove(); | 391 | $('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove(); |
388 | var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>'; | 392 | var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>'; |
393 | var editlink='<a href="#" id="mynote-edit-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-edit" title="' + streditnote + '">' + NODES.EDIT_ICON + '</a>'; | ||
394 | var updatelink='<a href="#" id="mynote-update-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-update" title="Save note">' + NODES.SAVE_ICON + '</a>'; | ||
395 | |||
389 | var notedetail = ''; | 396 | var notedetail = ''; |
390 | |||
391 | if (notes[x].coursename != '') { | 397 | if (notes[x].coursename != '') { |
392 | notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + '</div>'; | 398 | notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + '</div>'; |
393 | } | 399 | } |
394 | 400 | ||
395 | var userdate = '<div class="time">' + notes[x].timecreated + '</div>'; | 401 | var userdate = '<div class="time">' + notes[x].timecreated + '</div>'; |
396 | |||
397 | var mynotestime=''; | 402 | var mynotestime=''; |
398 | if (notes[x].notestime != ''){ | 403 | if (notes[x].notestime != ''){ |
399 | mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>'; | 404 | mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>'; |
400 | 405 | ||
401 | } | 406 | } |
402 | 407 | ||
403 | var note_html = '<div class="content">' + deletelink + notes[x].content + '</div>'; | 408 | var note_html = '<div class="content">' + deletelink + editlink + updatelink + notes[x].content + '</div>'; |
409 | // var note_html = '<div class="content">' + editlink + notes[x].content + '</div>'; | ||
404 | lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + mynotestime +'</li>'; | 410 | lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + mynotestime +'</li>'; |
405 | } | 411 | } |
406 | return lists; | 412 | return lists; |
... | @@ -487,6 +493,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -487,6 +493,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
487 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) { | 493 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) { |
488 | e.preventDefault(); | 494 | e.preventDefault(); |
489 | var nid = $(this).attr('id'); | 495 | var nid = $(this).attr('id'); |
496 | |||
490 | if (nid != '' || nid != 'undefined') { | 497 | if (nid != '' || nid != 'undefined') { |
491 | var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length; | 498 | var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length; |
492 | var id = nid.replace('mynote-delete-' + CONFIG.instanceid + '-', ''); | 499 | var id = nid.replace('mynote-delete-' + CONFIG.instanceid + '-', ''); |
... | @@ -506,6 +513,49 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -506,6 +513,49 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
506 | }); | 513 | }); |
507 | } | 514 | } |
508 | }); | 515 | }); |
516 | //edit option function added one | ||
517 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-edit', 'click', function(e) { | ||
518 | e.preventDefault(); | ||
519 | var nid = $(this).attr('id'); | ||
520 | |||
521 | var mytestid=$(this).attr('id'); | ||
522 | var editid = mytestid.replace('edit-',''); | ||
523 | $('#'+editid+' .content .no-overflow .text_to_html').attr('id','notes_edit_option'); | ||
524 | var vals=document.getElementById('notes_edit_option').contentEditable = true; | ||
525 | document.getElementById('notes_edit_option').focus(); | ||
526 | |||
527 | |||
528 | $( "#"+editid+" #mynote-update" ).click(function() { | ||
529 | var newstring= $("#notes_edit_option").text(); | ||
530 | |||
531 | if (nid != '' || nid != 'undefined') { | ||
532 | var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length; | ||
533 | var id = nid.replace('mynote-edit-' + CONFIG.instanceid + '-', ''); | ||
534 | |||
535 | var arg = { | ||
536 | contextid: CONFIG.contextid, | ||
537 | action: 'edit', | ||
538 | noteid: id, | ||
539 | lastnotecounts: notescount, | ||
540 | newnotes:newstring, | ||
541 | }; | ||
542 | var vals=document.getElementById('notes_edit_option').contentEditable = false; | ||
543 | document.getElementById("notes_edit_option").removeAttribute("id"); | ||
544 | scope.request({ | ||
545 | params: arg, | ||
546 | callback: function(id, ret, args) { | ||
547 | args.scope.addToList(ret); | ||
548 | // $('#mynote-' + CONFIG.instanceid + '-' + ret.noteid).remove(); | ||
549 | args.scope.displayMynotes(); | ||
550 | } | ||
551 | }); | ||
552 | } | ||
553 | |||
554 | }); | ||
555 | |||
556 | |||
557 | |||
558 | });//edit function ends here | ||
509 | }, | 559 | }, |
510 | displayDialogue: function(e) { | 560 | displayDialogue: function(e) { |
511 | 561 | ||
... | @@ -540,7 +590,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -540,7 +590,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
540 | key: 'placeholdercontent', | 590 | key: 'placeholdercontent', |
541 | component: 'block_mynotes' | 591 | component: 'block_mynotes' |
542 | }]).done(function(s) { | 592 | }]).done(function(s) { |
543 | var el = $('<div></div>').append($('<div id="' + CSS.MYNOTES_BASE + '" class="' + CSS.MYNOTES_BASE + '"></div>').append('<div class="inputarea"><div id="addmynote-label-' + CONFIG.instanceid + '">' + s[1] + ' ' + '' + '</div>' + '<div class="textarea"><textarea id="id_mynotecontent-' + CONFIG.instanceid + '" name="mynotecontent" rows="3">' + s[5] + '</textarea></div>' + '<p><br></p>' + '<p class="mdl-align"><input type="submit" id="addmynote_submit"/></p>' + '</div>').append($('<ul class="tabs-menu"></ul>')).append($('<div class="tab"></div>'))); | 593 | var el = $('<div id="tet"></div>').append($('<div id="' + CSS.MYNOTES_BASE + '" class="' + CSS.MYNOTES_BASE + '"></div>').append('<div class="inputarea"><div id="addmynote-label-' + CONFIG.instanceid + '">' + s[1] + ' ' + '' + '</div>' + '<div class="textarea"><textarea id="id_mynotecontent-' + CONFIG.instanceid + '" name="mynotecontent" rows="3">' + s[5] + '</textarea></div>' + '<p class="mdl-align"><input type="submit" id="addmynote_submit"/></p>' + '</div>').append($('<ul class="tabs-menu"></ul>')).append($('<div class="tab"></div>'))); |
544 | el.find('#addmynote_submit').attr('value', s[2]); | 594 | el.find('#addmynote_submit').attr('value', s[2]); |
545 | el.find('#addmynote_cancel').attr('value', s[3]); | 595 | el.find('#addmynote_cancel').attr('value', s[3]); |
546 | var tabsmenu = ''; | 596 | var tabsmenu = ''; | ... | ... |
... | @@ -2,6 +2,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -2,6 +2,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
2 | var CONFIG; | 2 | var CONFIG; |
3 | var NODES = { | 3 | var NODES = { |
4 | DELETE_ICON: '<span class="delete">❌</span>', | 4 | DELETE_ICON: '<span class="delete">❌</span>', |
5 | EDIT_ICON: '<i class="far fa-edit" id="mynote-edit"></i>', | ||
6 | SAVE_ICON: '<i class="far fa-save" id="mynote-update"></i>', | ||
5 | }; | 7 | }; |
6 | var SELECTORS = { | 8 | var SELECTORS = { |
7 | MYNOTES_BASE: '#mynotes_base', | 9 | MYNOTES_BASE: '#mynotes_base', |
... | @@ -16,6 +18,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -16,6 +18,8 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
16 | var panel = null; | 18 | var panel = null; |
17 | var initnotes = null; | 19 | var initnotes = null; |
18 | var strdeletenote = M.util.get_string('deletemynotes', 'block_mynotes'); | 20 | var strdeletenote = M.util.get_string('deletemynotes', 'block_mynotes'); |
21 | var streditnote = M.util.get_string('editmynotes', 'block_mynotes'); | ||
22 | // var strupdatenote = M.util.get_string('updatemynotes', 'block_mynotes'); | ||
19 | var getMynotesValidatedUrl = function(baseurl) { | 23 | var getMynotesValidatedUrl = function(baseurl) { |
20 | var a = document.createElement('a'); | 24 | var a = document.createElement('a'); |
21 | a.href = baseurl; | 25 | a.href = baseurl; |
... | @@ -368,7 +372,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -368,7 +372,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
368 | var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab); | 372 | var noteinfo = $(SELECTORS.MYNOTES_BASE).find(scope.currenttab); |
369 | 373 | ||
370 | if (mynotescount > 0) { | 374 | if (mynotescount > 0) { |
371 | noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount); | 375 | noteinfo.find('.count').html(M.util.get_string('mynotescount', 'block_mynotes') + '' + mynotescount+')'); |
372 | } else { | 376 | } else { |
373 | noteinfo.find('.count').html(M.util.get_string('nothingtodisplay', 'block_mynotes')); | 377 | noteinfo.find('.count').html(M.util.get_string('nothingtodisplay', 'block_mynotes')); |
374 | } | 378 | } |
... | @@ -386,21 +390,23 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -386,21 +390,23 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
386 | 390 | ||
387 | $('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove(); | 391 | $('#mynote-' + CONFIG.instanceid + '-' + notes[x].id).remove(); |
388 | var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>'; | 392 | var deletelink = '<a href="#" id="mynote-delete-' + CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-delete" title="' + strdeletenote + '">' + NODES.DELETE_ICON + '</a>'; |
393 | var editlink='<a href="#" id="mynote-edit-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-edit" title="' + streditnote + '">' + NODES.EDIT_ICON + '</a>'; | ||
394 | var updatelink='<a href="#" id="mynote-update-'+CONFIG.instanceid + '-' + notes[x].id + '" class="mynote-update" title="Save note">' + NODES.SAVE_ICON + '</a>'; | ||
395 | |||
389 | var notedetail = ''; | 396 | var notedetail = ''; |
390 | |||
391 | if (notes[x].coursename != '') { | 397 | if (notes[x].coursename != '') { |
392 | notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + '</div>'; | 398 | notedetail = '<div class="note-detail">' + notes[x].coursename + ' - ' + '</div>'; |
393 | } | 399 | } |
394 | 400 | ||
395 | var userdate = '<div class="time">' + notes[x].timecreated + '</div>'; | 401 | var userdate = '<div class="time">' + notes[x].timecreated + '</div>'; |
396 | |||
397 | var mynotestime=''; | 402 | var mynotestime=''; |
398 | if (notes[x].notestime != ''){ | 403 | if (notes[x].notestime != ''){ |
399 | mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>'; | 404 | mynotestime = '<br><div class="time">' +'video Time :' +notes[x].notestime +' sec'+ '</div>'; |
400 | 405 | ||
401 | } | 406 | } |
402 | 407 | ||
403 | var note_html = '<div class="content">' + deletelink + notes[x].content + '</div>'; | 408 | var note_html = '<div class="content">' + deletelink + editlink + updatelink + notes[x].content + '</div>'; |
409 | // var note_html = '<div class="content">' + editlink + notes[x].content + '</div>'; | ||
404 | lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + mynotestime +'</li>'; | 410 | lists += '<li id="mynote-' + CONFIG.instanceid + '-' + notes[x].id + '" data-itemid="' + notes[x].id + '">' + note_html + notedetail + userdate + mynotestime +'</li>'; |
405 | } | 411 | } |
406 | return lists; | 412 | return lists; |
... | @@ -487,6 +493,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -487,6 +493,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
487 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) { | 493 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-delete', 'click', function(e) { |
488 | e.preventDefault(); | 494 | e.preventDefault(); |
489 | var nid = $(this).attr('id'); | 495 | var nid = $(this).attr('id'); |
496 | |||
490 | if (nid != '' || nid != 'undefined') { | 497 | if (nid != '' || nid != 'undefined') { |
491 | var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length; | 498 | var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length; |
492 | var id = nid.replace('mynote-delete-' + CONFIG.instanceid + '-', ''); | 499 | var id = nid.replace('mynote-delete-' + CONFIG.instanceid + '-', ''); |
... | @@ -506,6 +513,49 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -506,6 +513,49 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
506 | }); | 513 | }); |
507 | } | 514 | } |
508 | }); | 515 | }); |
516 | //edit option function added one | ||
517 | $('body').delegate(SELECTORS.MYNOTES_BASE + ' a.mynote-edit', 'click', function(e) { | ||
518 | e.preventDefault(); | ||
519 | var nid = $(this).attr('id'); | ||
520 | |||
521 | var mytestid=$(this).attr('id'); | ||
522 | var editid = mytestid.replace('edit-',''); | ||
523 | $('#'+editid+' .content .no-overflow .text_to_html').attr('id','notes_edit_option'); | ||
524 | var vals=document.getElementById('notes_edit_option').contentEditable = true; | ||
525 | document.getElementById('notes_edit_option').focus(); | ||
526 | |||
527 | |||
528 | $( "#"+editid+" #mynote-update" ).click(function() { | ||
529 | var newstring= $("#notes_edit_option").text(); | ||
530 | |||
531 | if (nid != '' || nid != 'undefined') { | ||
532 | var notescount = $(SELECTORS.MYNOTES_BASE).find(SELECTORS.MYNOTES_LISTS + '-' + scope.currenttab + ' > li').length; | ||
533 | var id = nid.replace('mynote-edit-' + CONFIG.instanceid + '-', ''); | ||
534 | |||
535 | var arg = { | ||
536 | contextid: CONFIG.contextid, | ||
537 | action: 'edit', | ||
538 | noteid: id, | ||
539 | lastnotecounts: notescount, | ||
540 | newnotes:newstring, | ||
541 | }; | ||
542 | var vals=document.getElementById('notes_edit_option').contentEditable = false; | ||
543 | document.getElementById("notes_edit_option").removeAttribute("id"); | ||
544 | scope.request({ | ||
545 | params: arg, | ||
546 | callback: function(id, ret, args) { | ||
547 | args.scope.addToList(ret); | ||
548 | // $('#mynote-' + CONFIG.instanceid + '-' + ret.noteid).remove(); | ||
549 | args.scope.displayMynotes(); | ||
550 | } | ||
551 | }); | ||
552 | } | ||
553 | |||
554 | }); | ||
555 | |||
556 | |||
557 | |||
558 | });//edit function ends here | ||
509 | }, | 559 | }, |
510 | displayDialogue: function(e) { | 560 | displayDialogue: function(e) { |
511 | 561 | ||
... | @@ -540,7 +590,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f | ... | @@ -540,7 +590,7 @@ define(['jquery', 'core/yui', 'core/str', 'core/config', 'core/notification'], f |
540 | key: 'placeholdercontent', | 590 | key: 'placeholdercontent', |
541 | component: 'block_mynotes' | 591 | component: 'block_mynotes' |
542 | }]).done(function(s) { | 592 | }]).done(function(s) { |
543 | var el = $('<div></div>').append($('<div id="' + CSS.MYNOTES_BASE + '" class="' + CSS.MYNOTES_BASE + '"></div>').append('<div class="inputarea"><div id="addmynote-label-' + CONFIG.instanceid + '">' + s[1] + ' ' + '' + '</div>' + '<div class="textarea"><textarea id="id_mynotecontent-' + CONFIG.instanceid + '" name="mynotecontent" rows="3">' + s[5] + '</textarea></div>' + '<p><br></p>' + '<p class="mdl-align"><input type="submit" id="addmynote_submit"/></p>' + '</div>').append($('<ul class="tabs-menu"></ul>')).append($('<div class="tab"></div>'))); | 593 | var el = $('<div id="tet"></div>').append($('<div id="' + CSS.MYNOTES_BASE + '" class="' + CSS.MYNOTES_BASE + '"></div>').append('<div class="inputarea"><div id="addmynote-label-' + CONFIG.instanceid + '">' + s[1] + ' ' + '' + '</div>' + '<div class="textarea"><textarea id="id_mynotecontent-' + CONFIG.instanceid + '" name="mynotecontent" rows="3">' + s[5] + '</textarea></div>' + '<p class="mdl-align"><input type="submit" id="addmynote_submit"/></p>' + '</div>').append($('<ul class="tabs-menu"></ul>')).append($('<div class="tab"></div>'))); |
544 | el.find('#addmynote_submit').attr('value', s[2]); | 594 | el.find('#addmynote_submit').attr('value', s[2]); |
545 | el.find('#addmynote_cancel').attr('value', s[3]); | 595 | el.find('#addmynote_cancel').attr('value', s[3]); |
546 | var tabsmenu = ''; | 596 | var tabsmenu = ''; | ... | ... |
... | @@ -2,18 +2,20 @@ define(['jquery'], function($) { | ... | @@ -2,18 +2,20 @@ define(['jquery'], function($) { |
2 | 2 | ||
3 | return { | 3 | return { |
4 | init: function() { | 4 | init: function() { |
5 | var url= $(location).attr('href'); | 5 | // tab-mynotes_user |
6 | 6 | ||
7 | $('document').ready(function(){ | 7 | // tab-mynotes_user mynotepencil |
8 | |||
9 | console.log('init function got invoked '); | ||
10 | |||
11 | $('#mynotepencil').click(function(){ | ||
12 | console.log('init function got invoked '); | ||
8 | 13 | ||
9 | if(url.includes('/mod/page/view.php')){ | 14 | }); |
15 | |||
16 | // document.getElementById("panel").style.display = "none"; Nothing to display | ||
10 | 17 | ||
11 | var iframe = document.querySelector('iframe'); | 18 | // $("#tab-mynotes_user").removeAttr("style").hide(); |
12 | |||
13 | var player = new Vimeo.Player(iframe); | ||
14 | |||
15 | } | ||
16 | }); | ||
17 | } | 19 | } |
18 | }; | 20 | }; |
19 | }); | 21 | }); | ... | ... |
... | @@ -103,6 +103,7 @@ class block_mynotes extends block_base { | ... | @@ -103,6 +103,7 @@ class block_mynotes extends block_base { |
103 | */ | 103 | */ |
104 | private function block_mynotes_get_required_javascript() { | 104 | private function block_mynotes_get_required_javascript() { |
105 | global $PAGE, $CFG; | 105 | global $PAGE, $CFG; |
106 | $PAGE->requires->js_call_amd('block_mynotes/script', 'init'); | ||
106 | list($context, $course, $cm) = get_context_info_array($PAGE->context->id); | 107 | list($context, $course, $cm) = get_context_info_array($PAGE->context->id); |
107 | $config = get_config('block_mynotes'); | 108 | $config = get_config('block_mynotes'); |
108 | 109 | ||
... | @@ -121,11 +122,7 @@ class block_mynotes extends block_base { | ... | @@ -121,11 +122,7 @@ class block_mynotes extends block_base { |
121 | ), | 122 | ), |
122 | ); | 123 | ); |
123 | 124 | ||
124 | // $PAGE->requires->string_for_js('charactersleft', 'block_mynotes'); | 125 | $PAGE->requires->js_call_amd('block_mynotes/script', 'init'); |
125 | // $PAGE->requires->js_call_amd('block_mynotes/player', 'init'); | ||
126 | // $PAGE->requires->js('/blocks/mynotes/javascript/player.min.js'); | ||
127 | // $PAGE->requires->js( new moodle_url($CFG->wwwroot . '/blocks/mynotes/javascript/player.min.js') ); | ||
128 | $PAGE->requires->js_call_amd('block_mynotes/script', 'init'); | ||
129 | $PAGE->requires->string_for_js('notmorethan', 'block_mynotes'); | 126 | $PAGE->requires->string_for_js('notmorethan', 'block_mynotes'); |
130 | $PAGE->requires->string_for_js('mynotes', 'block_mynotes'); | 127 | $PAGE->requires->string_for_js('mynotes', 'block_mynotes'); |
131 | $PAGE->requires->string_for_js('showmynotes', 'block_mynotes'); | 128 | $PAGE->requires->string_for_js('showmynotes', 'block_mynotes'); |
... | @@ -133,6 +130,7 @@ class block_mynotes extends block_base { | ... | @@ -133,6 +130,7 @@ class block_mynotes extends block_base { |
133 | $PAGE->requires->string_for_js('save', 'block_mynotes'); | 130 | $PAGE->requires->string_for_js('save', 'block_mynotes'); |
134 | $PAGE->requires->string_for_js('placeholdercontent', 'block_mynotes'); | 131 | $PAGE->requires->string_for_js('placeholdercontent', 'block_mynotes'); |
135 | $PAGE->requires->string_for_js('deletemynotes', 'block_mynotes'); | 132 | $PAGE->requires->string_for_js('deletemynotes', 'block_mynotes'); |
133 | $PAGE->requires->string_for_js('editmynotes', 'block_mynotes');///addition one | ||
136 | $PAGE->requires->string_for_js('mynotescount', 'block_mynotes'); | 134 | $PAGE->requires->string_for_js('mynotescount', 'block_mynotes'); |
137 | $PAGE->requires->string_for_js('previouspage', 'block_mynotes'); | 135 | $PAGE->requires->string_for_js('previouspage', 'block_mynotes'); |
138 | $PAGE->requires->string_for_js('nextpage', 'block_mynotes'); | 136 | $PAGE->requires->string_for_js('nextpage', 'block_mynotes'); | ... | ... |
... | @@ -27,14 +27,17 @@ $string['mynotes:addinstance'] = 'Add a new mynotes block'; | ... | @@ -27,14 +27,17 @@ $string['mynotes:addinstance'] = 'Add a new mynotes block'; |
27 | $string['mynotes:post'] = 'Add a new note'; | 27 | $string['mynotes:post'] = 'Add a new note'; |
28 | $string['mynotes:view'] = 'View own notes'; | 28 | $string['mynotes:view'] = 'View own notes'; |
29 | $string['mynotes:delete'] = 'Delete own notes'; | 29 | $string['mynotes:delete'] = 'Delete own notes'; |
30 | $string['mynotes:edit'] = 'edit own notes'; | ||
30 | $string['pluginname'] = 'My Notes'; | 31 | $string['pluginname'] = 'My Notes'; |
31 | $string['disabledmynotes'] = 'Disabled my notes'; | 32 | $string['disabledmynotes'] = 'Disabled my notes'; |
32 | $string['showmynotes'] = 'Show my notes'; | 33 | $string['showmynotes'] = 'Show my notes'; |
33 | $string['addnotes'] = 'Add notes'; | 34 | $string['addnotes'] = 'Add notes'; |
34 | $string['mynotes'] = 'My notes'; | 35 | $string['mynotes'] = 'My notes'; |
35 | $string['mynotescount'] = 'Total count: '; | 36 | $string['mynotescount'] = 'Notes: ('; |
36 | $string['mynotesrequirelogin'] = 'You must login to add/view your notes'; | 37 | $string['mynotesrequirelogin'] = 'You must login to add/view your notes'; |
37 | $string['deletemynotes'] = 'Delete note'; | 38 | $string['deletemynotes'] = 'Delete note'; |
39 | $string['editmynotes'] = 'Edit note'; | ||
40 | $string['updatemynotes'] = 'Save note'; | ||
38 | $string['site'] = 'Site'; | 41 | $string['site'] = 'Site'; |
39 | $string['course'] = 'Course'; | 42 | $string['course'] = 'Course'; |
40 | $string['mod'] = 'Modules'; | 43 | $string['mod'] = 'Modules'; |
... | @@ -55,8 +58,10 @@ $string['icondisplayposition'] = 'Icon position'; | ... | @@ -55,8 +58,10 @@ $string['icondisplayposition'] = 'Icon position'; |
55 | $string['icondisplayposition_help'] = 'Choose the position for Note-Icon which will used to open popup.'; | 58 | $string['icondisplayposition_help'] = 'Choose the position for Note-Icon which will used to open popup.'; |
56 | $string['mynotesperpage'] = 'Per page'; | 59 | $string['mynotesperpage'] = 'Per page'; |
57 | $string['mynotesperpage_help'] = 'Limit the notes display on per page'; | 60 | $string['mynotesperpage_help'] = 'Limit the notes display on per page'; |
61 | $string['editfailed'] = 'Edit action failed'; | ||
58 | $string['deletefailed'] = 'Delete action failed'; | 62 | $string['deletefailed'] = 'Delete action failed'; |
59 | $string['nopermissiontodelete'] = 'You do not have permission to delete this note'; | 63 | $string['nopermissiontodelete'] = 'You do not have permission to delete this note'; |
64 | $string['nopermissiontoedit'] = 'You do not have permission to edit this note'; | ||
60 | $string['previouspage'] = '<< Previous page'; | 65 | $string['previouspage'] = '<< Previous page'; |
61 | $string['nextpage'] = 'Next page >>'; | 66 | $string['nextpage'] = 'Next page >>'; |
62 | $string['nothingtodisplay'] = 'Nothing to display'; | 67 | $string['nothingtodisplay'] = 'Nothing to display'; | ... | ... |
... | @@ -339,6 +339,28 @@ class block_mynotes_manager { | ... | @@ -339,6 +339,28 @@ class block_mynotes_manager { |
339 | } | 339 | } |
340 | return $DB->delete_records('block_mynotes', array('id' => $mynoteid)); | 340 | return $DB->delete_records('block_mynotes', array('id' => $mynoteid)); |
341 | } | 341 | } |
342 | |||
343 | /** | ||
344 | * Edit a note | ||
345 | * | ||
346 | * @param int $mynoteid | ||
347 | * @return bool | ||
348 | */ | ||
349 | public function edit($mynoteid,$notes) { | ||
350 | global $DB, $USER; | ||
351 | if (!$mynote = $DB->get_record('block_mynotes', array('id' => $mynoteid))) { | ||
352 | throw new mynotes_exception('editfailed', 'block_mynotes'); | ||
353 | } | ||
354 | if ($USER->id != $mynote->userid) { | ||
355 | throw new mynotes_exception('nopermissiontoedit', 'block_mynotes'); | ||
356 | } | ||
357 | $timecreated = time(); | ||
358 | $param = array ($notes,$timecreated,$mynoteid ); | ||
359 | $sql4 = 'update {block_mynotes} set content=? , timecreated=? where id=? '; | ||
360 | return $update_record = $DB->execute ( $sql4, $param ); | ||
361 | |||
362 | } | ||
363 | |||
342 | } | 364 | } |
343 | 365 | ||
344 | /** | 366 | /** | ... | ... |
... | @@ -27,6 +27,7 @@ require_once('../../config.php'); | ... | @@ -27,6 +27,7 @@ require_once('../../config.php'); |
27 | require_once($CFG->dirroot.'/course/lib.php'); | 27 | require_once($CFG->dirroot.'/course/lib.php'); |
28 | require_once($CFG->dirroot . '/blocks/mynotes/lib.php'); | 28 | require_once($CFG->dirroot . '/blocks/mynotes/lib.php'); |
29 | 29 | ||
30 | |||
30 | $contextid = optional_param('contextid', SYSCONTEXTID, PARAM_INT); | 31 | $contextid = optional_param('contextid', SYSCONTEXTID, PARAM_INT); |
31 | $contextarea = optional_param('contextarea', 'site', PARAM_ALPHA); | 32 | $contextarea = optional_param('contextarea', 'site', PARAM_ALPHA); |
32 | $action = optional_param('action', '', PARAM_ALPHA); | 33 | $action = optional_param('action', '', PARAM_ALPHA); |
... | @@ -38,6 +39,7 @@ if ( $contextid == SYSCONTEXTID || $context->contextlevel == CONTEXT_USER) { | ... | @@ -38,6 +39,7 @@ if ( $contextid == SYSCONTEXTID || $context->contextlevel == CONTEXT_USER) { |
38 | $course = get_site(); | 39 | $course = get_site(); |
39 | } | 40 | } |
40 | 41 | ||
42 | $PAGE->requires->js_call_amd('block_mynotes/script', 'init'); | ||
41 | $PAGE->set_url('/blocks/mynotes/mynotes_ajax.php'); | 43 | $PAGE->set_url('/blocks/mynotes/mynotes_ajax.php'); |
42 | 44 | ||
43 | require_course_login($course, true, $cm); | 45 | require_course_login($course, true, $cm); |
... | @@ -89,6 +91,7 @@ switch ($action) { | ... | @@ -89,6 +91,7 @@ switch ($action) { |
89 | } | 91 | } |
90 | die(); | 92 | die(); |
91 | break; | 93 | break; |
94 | |||
92 | case 'get': | 95 | case 'get': |
93 | $manager = new block_mynotes_manager(); | 96 | $manager = new block_mynotes_manager(); |
94 | $options = new stdClass(); | 97 | $options = new stdClass(); |
... | @@ -112,6 +115,30 @@ switch ($action) { | ... | @@ -112,6 +115,30 @@ switch ($action) { |
112 | 115 | ||
113 | die(); | 116 | die(); |
114 | break; | 117 | break; |
118 | |||
119 | case 'edit': | ||
120 | $noteid = required_param('noteid', PARAM_INT); | ||
121 | // $limitfrom = optional_param('lastnotecounts', 0, PARAM_INT); | ||
122 | $notes = required_param('newnotes', PARAM_TEXT); | ||
123 | $manager = new block_mynotes_manager(); | ||
124 | |||
125 | if ($manager->edit($noteid,$notes)) { | ||
126 | $options = new stdClass(); | ||
127 | $options->page = $page; | ||
128 | $options->contextid = $context->id; | ||
129 | $options->contextarea = $contextarea; | ||
130 | $options->courseid = $course->id; | ||
131 | $count = $manager->count_mynotes($options); | ||
132 | |||
133 | if ($limitfrom) { | ||
134 | $options->limitfrom = $limitfrom - 1; | ||
135 | } | ||
136 | $notes = $manager->get_mynotes($options); | ||
137 | echo json_encode(array('notes' => $notes, 'count' => $count)); | ||
138 | } | ||
139 | die(); | ||
140 | break; | ||
141 | |||
115 | case 'delete': | 142 | case 'delete': |
116 | $noteid = required_param('noteid', PARAM_INT); | 143 | $noteid = required_param('noteid', PARAM_INT); |
117 | $limitfrom = optional_param('lastnotecounts', 0, PARAM_INT); | 144 | $limitfrom = optional_param('lastnotecounts', 0, PARAM_INT); |
... | @@ -129,7 +156,6 @@ switch ($action) { | ... | @@ -129,7 +156,6 @@ switch ($action) { |
129 | } | 156 | } |
130 | $notes = $manager->get_mynotes($options); | 157 | $notes = $manager->get_mynotes($options); |
131 | 158 | ||
132 | |||
133 | echo json_encode(array('notes' => $notes, 'count' => $count, 'noteid' => $noteid)); | 159 | echo json_encode(array('notes' => $notes, 'count' => $count, 'noteid' => $noteid)); |
134 | } | 160 | } |
135 | die(); | 161 | die(); | ... | ... |
1 | #mynotes-opener { position: absolute; bottom:0px; background: #443355; width: 25px; height: 25px; } | 1 | #mynotes-opener { position: absolute; bottom:0px; background: #443355; width: 25px; height: 25px; } |
2 | div.mdl-align { min-height: 470px; } | 2 | div.mdl-align { min-height: 470px;} |
3 | #mynote-edit{position: absolute !important;right: 0 !important; margin: 0px 20px !important;} | ||
4 | #mynote-update{position: absolute !important; right: 0 !important; margin:0px 40px !important;} | ||
5 | #notes_edit_option{color: #2310c3 !important;} | ||
6 | .mdl-align { padding:inherit !important; } | ||
3 | .mynotes-pos-inline-text { padding: 10px; margin-left: 35px; cursor: pointer; } | 7 | .mynotes-pos-inline-text { padding: 10px; margin-left: 35px; cursor: pointer; } |
4 | .mynotes-pos-inline, | 8 | .mynotes-pos-inline, |
5 | .mynotes-pos-rb, | 9 | .mynotes-pos-rb, |
... | @@ -45,6 +49,6 @@ div.mdl-align { min-height: 470px; } | ... | @@ -45,6 +49,6 @@ div.mdl-align { min-height: 470px; } |
45 | .mynotes_base .tab .tab-content ul.mynotes_lists li .content { margin-right: 10px; word-wrap: break-word; } | 49 | .mynotes_base .tab .tab-content ul.mynotes_lists li .content { margin-right: 10px; word-wrap: break-word; } |
46 | .mynotes_base .tab .tab-content ul.mynotes_lists li .note-detail { display: inline-block; font-size: 11px; } | 50 | .mynotes_base .tab .tab-content ul.mynotes_lists li .note-detail { display: inline-block; font-size: 11px; } |
47 | .mynotes_base .tab .tab-content ul.mynotes_lists li .time { color: #888; font-style: italic; display: inline-block; margin-left: 5px; font-size: 11px; } | 51 | .mynotes_base .tab .tab-content ul.mynotes_lists li .time { color: #888; font-style: italic; display: inline-block; margin-left: 5px; font-size: 11px; } |
48 | .mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete { position: absolute; right: 0; margin:0 4px; } | 52 | .mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete { position: absolute; right: 0; margin:0 -1px; } |
49 | .mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete span { color: #bbb; } | 53 | .mynotes_base .tab .tab-content ul.mynotes_lists li a.mynote-delete span { color: #bbb; } |
50 | 54 | ... | ... |
... | @@ -23,7 +23,7 @@ | ... | @@ -23,7 +23,7 @@ |
23 | 23 | ||
24 | defined('MOODLE_INTERNAL') || die(); | 24 | defined('MOODLE_INTERNAL') || die(); |
25 | 25 | ||
26 | $plugin->version = 2018011201; // The current plugin version (Date: YYYYMMDDXX) | 26 | $plugin->version = 2018011202; // The current plugin version (Date: YYYYMMDDXX) |
27 | $plugin->requires = 2015050500; // Requires this Moodle version | 27 | $plugin->requires = 2015050500; // Requires this Moodle version |
28 | $plugin->component = 'block_mynotes'; // Full name of the plugin (used for diagnostics) | 28 | $plugin->component = 'block_mynotes'; // Full name of the plugin (used for diagnostics) |
29 | $plugin->release = 'V3.4 r1'; | 29 | $plugin->release = 'V3.4 r1'; | ... | ... |
-
Please register or sign in to post a comment