Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Revert MDL-31215 Add the ability to change activity titles using AJAX…

… calls

This *partially* reverts commit 6a14c4f.

Note however parts of that commit were unrelated and haven't been
reverted.
  • Loading branch information...
commit 9d40f585da30d8fb0095e35f817c900e34960137 1 parent 70b36b4
Andrew Nicols authored April 26, 2012 danpoltawski committed April 26, 2012
1  course/lib.php
@@ -4533,7 +4533,6 @@ function include_course_ajax($course, $modules = array(), $config = null) {
4533 4533
             'moveleft',
4534 4534
             'deletechecktype',
4535 4535
             'deletechecktypename',
4536  
-            'edittitle',
4537 4536
             'show',
4538 4537
             'hide',
4539 4538
             'groupsnone',
9  course/rest.php
@@ -43,7 +43,6 @@
43 43
 $sequence   = optional_param('sequence', '', PARAM_SEQUENCE);
44 44
 $visible    = optional_param('visible', 0, PARAM_INT);
45 45
 $pageaction = optional_param('action', '', PARAM_ALPHA); // Used to simulate a DELETE command
46  
-$title      = optional_param('title', '', PARAM_TEXT);
47 46
 
48 47
 $PAGE->set_url('/course/rest.php', array('courseId'=>$courseid,'class'=>$class));
49 48
 
@@ -137,14 +136,6 @@
137 136
 
138 137
                         moveto_module($cm, $section, $beforemod);
139 138
                         break;
140  
-                    case 'updatetitle':
141  
-                        require_capability('moodle/course:manageactivities', $modcontext);
142  
-                        $cm = get_coursemodule_from_id('', $id, 0, false, MUST_EXIST);
143  
-                        $module = new stdClass();
144  
-                        $module->id = $cm->instance;
145  
-                        $module->name = $title;
146  
-                        $DB->update_record($cm->modname, $module);
147  
-                        break;
148 139
                 }
149 140
                 rebuild_course_cache($course->id);
150 141
                 break;
114  course/yui/toolboxes/toolboxes.js
@@ -300,13 +300,6 @@ YUI.add('moodle-course-toolboxes', function(Y) {
300 300
 
301 301
             groups = this.replace_button(toolboxtarget, CSS.COMMANDSPAN + ' ' + CSS.GROUPSVISIBLE, this.toggle_groupmode);
302 302
             groups.setAttribute('groupmode', this.GROUPS_VISIBLE);
303  
-
304  
-            // Add the edit title button
305  
-            Y.one(toolboxtarget).all(CSS.ACTIVITYLI).each(function (target) {
306  
-                if (!target.hasClass(CSS.HASLABEL)) {
307  
-                    this.add_edittitlebutton(target.one(CSS.COMMANDSPAN));
308  
-                }
309  
-            }, this);
310 303
         },
311 304
         move_left : function(e) {
312 305
             this.move_leftright(e, -1, CSS.MOVELEFT);
@@ -480,113 +473,6 @@ YUI.add('moodle-course-toolboxes', function(Y) {
480 473
             anchor.appendChild(newicon);
481 474
             anchor.on('click', this.move_left, this);
482 475
             target.one(CSS.MOVERIGHT).insert(anchor, 'before');
483  
-        },
484  
-        /**
485  
-         * Add the edittitlebutton button
486  
-         *
487  
-         * @param target The encapsulating <li> element
488  
-         */
489  
-        add_edittitlebutton : function(target) {
490  
-            var edit_string = M.util.get_string('edittitle', 'moodle');
491  
-            var newicon = Y.Node.create('<img />')
492  
-                .addClass(CSS.GENERICICONCLASS)
493  
-                .setAttrs({
494  
-                    'src'   : M.util.image_url('t/editstring', 'moodle'),
495  
-                    'title' : edit_string,
496  
-                    'alt'   : edit_string
497  
-                });
498  
-            var anchor = new Y.Node.create('<a />')
499  
-                .setStyle('cursor', 'pointer')
500  
-                .addClass(CSS.EDITTITLECLASS)
501  
-                .set('title', edit_string);
502  
-            anchor.appendChild(newicon);
503  
-            anchor.on('click', this.edit_resource_title, this);
504  
-            target.get('firstChild').insert(anchor, 'before');
505  
-        },
506  
-        /**
507  
-         * Edit the title for the resource
508  
-         */
509  
-        edit_resource_title : function(e) {
510  
-            // Get the element we're working on
511  
-            var element = e.target.ancestor(CSS.ACTIVITYLI);
512  
-            var instancename  = element.one(CSS.INSTANCENAME);
513  
-            var currenttitle = instancename.get('firstChild');
514  
-            var oldtitle = currenttitle.get('data');
515  
-            var editbutton = element.one('a.' + CSS.EDITTITLECLASS + ' img');
516  
-
517  
-            // Disable the current href to prevent redirections when editing
518  
-            var anchor = instancename.ancestor('a');
519  
-            anchor.setAttribute('oldhref', anchor.getAttribute('href'));
520  
-            anchor.removeAttribute('href');
521  
-
522  
-            // Create the editor and submit button
523  
-            var editor = Y.Node.create('<input />')
524  
-                .setAttrs({
525  
-                    'name'  : 'title',
526  
-                    'value' : oldtitle,
527  
-                    'autocomplete' : 'off'
528  
-                });
529  
-            var editform = Y.Node.create('<form />')
530  
-                .setStyle('padding', '0')
531  
-                .setStyle('display', 'inline')
532  
-                .setAttribute('action', '#');
533  
-
534  
-            // Clear the existing content and put the editor in
535  
-            currenttitle.set('data', '');
536  
-            editform.appendChild(editor);
537  
-            instancename.appendChild(editform);
538  
-
539  
-            // Focus and select the editor text
540  
-            editor.focus().select();
541  
-
542  
-            // Handle cancellation of the editor
543  
-            editor.on('blur', function(e) {
544  
-                // Detach the blur event before removing as some actions trigger multiple blurs in
545  
-                // some browser
546  
-                editor.detach('blur');
547  
-                editform.remove();
548  
-
549  
-                // Set the title and anchor back to their previous settings
550  
-                currenttitle.set('data', oldtitle);
551  
-                anchor.setAttribute('href', anchor.getAttribute('oldhref'));
552  
-                anchor.removeAttribute('oldhref');
553  
-            });
554  
-
555  
-            // Handle form submission
556  
-            editform.on('submit', function(e) {
557  
-                // We don't actually want to submit anything
558  
-                e.preventDefault();
559  
-
560  
-                // Detach the handlers to prevent multiple submissions
561  
-                editform.detach('submit');
562  
-                editor.detach('blur');
563  
-
564  
-                // We only accept strings which have valid content
565  
-                var newtitle = Y.Lang.trim(editor.get('value'));
566  
-                if (newtitle != null && newtitle != "" && newtitle != oldtitle) {
567  
-                    var data = {
568  
-                        'class'   : 'resource',
569  
-                        'field'   : 'updatetitle',
570  
-                        'title'   : newtitle,
571  
-                        'id'      : this.get_element_id(element)
572  
-                    };
573  
-                    this.send_request(data, editbutton);
574  
-                    currenttitle.set('data', newtitle);
575  
-                } else {
576  
-                    // Invalid content. Set the title back to it's original contents
577  
-                    currenttitle.set('data', oldtitle);
578  
-                }
579  
-
580  
-                // Add the anchor back
581  
-                editform.remove();
582  
-
583  
-                // We need a timeout here otherwise hitting return to save in some browsers triggers
584  
-                // the anchor
585  
-                setTimeout(function(e) {
586  
-                    anchor.setAttribute('href', anchor.getAttribute('oldhref'));
587  
-                    anchor.removeAttribute('oldhref');
588  
-                }, 500);
589  
-            }, this);
590 476
         }
591 477
     }, {
592 478
         NAME : 'course-resource-toolbox',
1  lang/en/moodle.php
@@ -504,7 +504,6 @@
504 504
 $string['editorshortcutkeys'] = 'Editor shortcut keys';
505 505
 $string['editsettings'] = 'Edit settings';
506 506
 $string['editsummary'] = 'Edit summary';
507  
-$string['edittitle'] = 'Edit title';
508 507
 $string['editthisactivity'] = 'Edit this activity';
509 508
 $string['editthiscategory'] = 'Edit this category';
510 509
 $string['edituser'] = 'Edit user accounts';
BIN  pix/t/editstring.gif

0 notes on commit 9d40f58

Please sign in to comment.
Something went wrong with that request. Please try again.