]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from 1.7.
authorvyshane <vyshane>
Wed, 22 Nov 2006 07:04:41 +0000 (07:04 +0000)
committervyshane <vyshane>
Wed, 22 Nov 2006 07:04:41 +0000 (07:04 +0000)
lib/ajax/section_classes.js

index e2179cb2c2df067675622d9efb0e31bca102b425..ed0f2088a09a8ba4066ab927ebffe2d791b1964b 100755 (executable)
@@ -540,7 +540,7 @@ resource_class.prototype.init_resource = function(id, group, config, parentObj)
 resource_class.prototype.init_buttons = function() {
 
        var commandContainer = YAHOO.util.Dom.getElementsByClassName('commands',
-                       'span', this.getEl())[0];
+                                                       'span', this.getEl())[0];
 
     if (commandContainer == null) {
         YAHOO.log('Cannot find command container for '+this.getEl().id, 'error');
@@ -596,13 +596,15 @@ resource_class.prototype.init_buttons = function() {
 
        // Add indentation buttons if needed (move left, move right).
        if (moveLeft) {
-               var button = main.mk_button('a', '/t/left.gif', [['title', main.portal.strings['moveleft']]]);
-               YAHOO.util.Event.addListener(button, 'click', this.move_left_button, this, true);
+               var button = main.mk_button('a', '/t/left.gif', [['title', main.portal.strings['moveleft']],
+                                                                ['class', 'editing_moveleft']]);
+               YAHOO.util.Event.addListener(button, 'click', this.indent_left, this, true);
                commandContainer.appendChild(button);
        }
        if (moveRight) {
-               var button = main.mk_button('a', '/t/right.gif', [['title', main.portal.strings['moveright']]]);
-               YAHOO.util.Event.addListener(button, 'click', this.move_right_button, this, true);
+               var button = main.mk_button('a', '/t/right.gif', [['title', main.portal.strings['moveright']],
+                                                                 ['class', 'editing_moveright']]);
+               YAHOO.util.Event.addListener(button, 'click', this.indent_right, this, true);
                commandContainer.appendChild(button);
        }
 
@@ -640,6 +642,70 @@ resource_class.prototype.init_buttons = function() {
 }    
 
 
+resource_class.prototype.indent_left = function() {
+
+       var spacer = YAHOO.util.Dom.getElementsByClassName('spacer',
+                                       'img', this.getEl())[0];
+       if (!spacer) {
+               return;
+       }
+       if (spacer.width > 20) {
+               spacer.width -= 20;
+       } else {
+               // Remove the spacer.
+               resource = this.getEl();
+               resource.removeChild(spacer);
+               
+               // Remove the indent left button as well.
+               var commandContainer = YAHOO.util.Dom.getElementsByClassName('commands',
+                                                               'span', this.getEl())[0];
+               
+               var indentLeftBtn = YAHOO.util.Dom.getElementsByClassName('editing_moveleft',
+                                                               'a', commandContainer)[0];
+
+               commandContainer.removeChild(indentLeftBtn);
+       }
+       return;
+}
+
+
+resource_class.prototype.indent_right = function() {
+
+       var spacer = YAHOO.util.Dom.getElementsByClassName('spacer',
+                                       'img', this.getEl())[0];
+       if (!spacer) {
+               var spacer = document.createElement('img');
+
+               spacer.setAttribute('src', main.portal.strings['pixpath']+'/spacer.gif');
+               spacer.setAttribute('class', 'spacer');
+               spacer.setAttribute('width', '20');
+               spacer.setAttribute('height', '12');
+               
+               var resource = this.getEl();
+               resource.insertBefore(spacer, resource.childNodes[0]);
+       } else {
+               spacer.width += 20;
+       }
+       // Add a indent left button if none is present.
+       var commandContainer = YAHOO.util.Dom.getElementsByClassName('commands',
+                                                       'span', this.getEl())[0];
+
+       var indentLeftBtn = YAHOO.util.Dom.getElementsByClassName('editing_moveleft',
+                                                       'a', commandContainer)[0];
+
+       var indentRightBtn = YAHOO.util.Dom.getElementsByClassName('editing_moveright',
+                                                       'a', commandContainer)[0];
+
+       if (!indentLeftBtn) {
+               var button = main.mk_button('a', '/t/left.gif', [['title', main.portal.strings['moveleft']],
+                                                                                                        ['class', 'editing_moveleft']]);
+               YAHOO.util.Event.addListener(button, 'click', this.indent_left, this, true);
+               commandContainer.insertBefore(button, indentRightBtn);
+       }
+       return true;
+}
+
+
 resource_class.prototype.toggle_hide = function(target, e, superficial, force) {
     if (force != null) {
         if (this.debug) {