Merge branch 'MDL-35569-m23' of git://github.com/sammarshallou/moodle into MOODLE_23_STABLE
This commit is contained in:
+5
-2
@@ -435,8 +435,11 @@ if (!$courses) {
|
||||
$movetocategories[$category->id] = get_string('moveselectedcoursesto');
|
||||
echo '<tr><td colspan="3" align="right">';
|
||||
echo html_writer::label(get_string('moveselectedcoursesto'), 'movetoid', false, array('class' => 'accesshide'));
|
||||
echo html_writer::select($movetocategories, 'moveto', $category->id, null, array('id'=>'movetoid'));
|
||||
$PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('movecourses', 'movetoid', false));
|
||||
echo html_writer::select($movetocategories, 'moveto', $category->id, null, array('id'=>'movetoid', 'class' => 'autosubmit'));
|
||||
$PAGE->requires->yui_module('moodle-core-formautosubmit',
|
||||
'M.core.init_formautosubmit',
|
||||
array(array('selectid' => 'movetoid', 'nothing' => $category->id))
|
||||
);
|
||||
echo '<input type="hidden" name="id" value="'.$category->id.'" />';
|
||||
echo '</td></tr>';
|
||||
}
|
||||
|
||||
+5
-2
@@ -375,8 +375,11 @@ if ($courses) {
|
||||
echo "<input type=\"button\" onclick=\"checknone()\" value=\"$strdeselectall\" />\n";
|
||||
// Select box should only show categories in which user has min capability to move course.
|
||||
echo html_writer::label(get_string('moveselectedcoursesto'), 'movetoid', false, array('class' => 'accesshide'));
|
||||
echo html_writer::select($usercatlist, 'moveto', '', array(''=>get_string('moveselectedcoursesto')), array('id'=>'movetoid'));
|
||||
$PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('movecourses', 'movetoid', false));
|
||||
echo html_writer::select($usercatlist, 'moveto', '', array(''=>get_string('moveselectedcoursesto')), array('id'=>'movetoid', 'class' => 'autosubmit'));
|
||||
$PAGE->requires->yui_module('moodle-core-formautosubmit',
|
||||
'M.core.init_formautosubmit',
|
||||
array(array('selectid' => 'movetoid', 'nothing' => false))
|
||||
);
|
||||
echo "</td>\n</tr>\n";
|
||||
echo "</table>\n</form>";
|
||||
|
||||
|
||||
+24
-2
@@ -1336,6 +1336,11 @@ class core_renderer extends renderer_base {
|
||||
$select->attributes['title'] = $select->tooltip;
|
||||
}
|
||||
|
||||
$select->attributes['class'] = 'autosubmit';
|
||||
if ($select->class) {
|
||||
$select->attributes['class'] .= ' ' . $select->class;
|
||||
}
|
||||
|
||||
if ($select->label) {
|
||||
$output .= html_writer::label($select->label, $select->attributes['id'], false, $select->labelattributes);
|
||||
}
|
||||
@@ -1351,7 +1356,10 @@ class core_renderer extends renderer_base {
|
||||
$output .= html_writer::tag('noscript', html_writer::tag('div', $go), array('style'=>'inline'));
|
||||
|
||||
$nothing = empty($select->nothing) ? false : key($select->nothing);
|
||||
$this->page->requires->js_init_call('M.util.init_select_autosubmit', array($select->formid, $select->attributes['id'], $nothing));
|
||||
$this->page->requires->yui_module('moodle-core-formautosubmit',
|
||||
'M.core.init_formautosubmit',
|
||||
array(array('selectid' => $select->attributes['id'], 'nothing' => $nothing))
|
||||
);
|
||||
|
||||
// then div wrapper for xhtml strictness
|
||||
$output = html_writer::tag('div', $output);
|
||||
@@ -1417,6 +1425,17 @@ class core_renderer extends renderer_base {
|
||||
$output .= html_writer::label($select->label, $select->attributes['id'], false, $select->labelattributes);
|
||||
}
|
||||
|
||||
$classes = array();
|
||||
if (!$select->showbutton) {
|
||||
$classes[] = 'autosubmit';
|
||||
}
|
||||
if ($select->class) {
|
||||
$classes[] = $select->class;
|
||||
}
|
||||
if (count($classes)) {
|
||||
$select->attributes['class'] = implode(' ', $classes);
|
||||
}
|
||||
|
||||
if ($select->helpicon instanceof help_icon) {
|
||||
$output .= $this->render($select->helpicon);
|
||||
} else if ($select->helpicon instanceof old_help_icon) {
|
||||
@@ -1474,7 +1493,10 @@ class core_renderer extends renderer_base {
|
||||
$go = html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('go')));
|
||||
$output .= html_writer::tag('noscript', html_writer::tag('div', $go), array('style'=>'inline'));
|
||||
$nothing = empty($select->nothing) ? false : key($select->nothing);
|
||||
$output .= $this->page->requires->js_init_call('M.util.init_url_select', array($select->formid, $select->attributes['id'], $nothing));
|
||||
$this->page->requires->yui_module('moodle-core-formautosubmit',
|
||||
'M.core.init_formautosubmit',
|
||||
array(array('selectid' => $select->attributes['id'], 'nothing' => $nothing))
|
||||
);
|
||||
} else {
|
||||
$output .= html_writer::empty_tag('input', array('type'=>'submit', 'value'=>$select->showbutton));
|
||||
}
|
||||
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
YUI.add('moodle-core-formautosubmit',
|
||||
function(Y) {
|
||||
// The CSS selectors we use
|
||||
var CSS = {
|
||||
AUTOSUBMIT : 'autosubmit'
|
||||
};
|
||||
|
||||
var FORMAUTOSUBMITNAME = 'core-formautosubmit';
|
||||
|
||||
var FORMAUTOSUBMIT = function() {
|
||||
FORMAUTOSUBMIT.superclass.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
// We only want to initialize the module fully once
|
||||
var INITIALIZED = false;
|
||||
|
||||
Y.extend(FORMAUTOSUBMIT, Y.Base, {
|
||||
|
||||
/**
|
||||
* Initialize the module
|
||||
*/
|
||||
initializer : function(config) {
|
||||
// We only apply the delegation once
|
||||
if (!INITIALIZED) {
|
||||
INITIALIZED = true;
|
||||
var applyto = Y.one('body');
|
||||
|
||||
// We don't listen for change events by default as using the keyboard triggers these too.
|
||||
applyto.delegate('key', this.process_changes, 'press:13', 'select.' + CSS.AUTOSUBMIT, this);
|
||||
applyto.delegate('click', this.process_changes, 'select.' + CSS.AUTOSUBMIT, this);
|
||||
|
||||
if (Y.UA.os == 'macintosh' && Y.UA.webkit) {
|
||||
// Macintosh webkit browsers like change events, but non-macintosh webkit browsers don't.
|
||||
applyto.delegate('change', this.process_changes, 'select.' + CSS.AUTOSUBMIT, this);
|
||||
}
|
||||
if (Y.UA.ios) {
|
||||
// IOS doesn't trigger click events because it's touch-based.
|
||||
applyto.delegate('change', this.process_changes, 'select.' + CSS.AUTOSUBMIT, this);
|
||||
}
|
||||
}
|
||||
|
||||
// Assign this select items 'nothing' value and lastindex (current value)
|
||||
var thisselect = Y.one('select#' + this.get('selectid'));
|
||||
thisselect.setData('nothing', this.get('nothing'));
|
||||
thisselect.setData('startindex', thisselect.get('selectedIndex'));
|
||||
},
|
||||
|
||||
/**
|
||||
* Check whether the select element was changed
|
||||
*/
|
||||
check_changed : function(e) {
|
||||
var select = e.target.ancestor('select.' + CSS.AUTOSUBMIT, true);
|
||||
if (!select) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var nothing = select.getData('nothing');
|
||||
var startindex = select.getData('startindex');
|
||||
var currentindex = select.get('selectedIndex');
|
||||
|
||||
var previousindex = select.getAttribute('data-previousindex');
|
||||
select.setAttribute('data-previousindex', currentindex);
|
||||
if (!previousindex) {
|
||||
previousindex = startindex;
|
||||
}
|
||||
|
||||
// Check whether the field has changed, and is not the 'nothing' value
|
||||
if ((nothing===false || select.get('value') != nothing) && startindex != select.get('selectedIndex') && currentindex != previousindex) {
|
||||
return select;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Process any changes
|
||||
*/
|
||||
process_changes : function(e) {
|
||||
var select = this.check_changed(e);
|
||||
if (select) {
|
||||
var form = select.ancestor('form', true);
|
||||
form.submit();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
NAME : FORMAUTOSUBMITNAME,
|
||||
ATTRS : {
|
||||
selectid : {
|
||||
'value' : ''
|
||||
},
|
||||
nothing : {
|
||||
'value' : ''
|
||||
},
|
||||
ignorechangeevent : {
|
||||
'value' : false
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
M.core = M.core || {};
|
||||
M.core.init_formautosubmit = M.core.init_formautosubmit || function(config) {
|
||||
return new FORMAUTOSUBMIT(config);
|
||||
};
|
||||
},
|
||||
'@VERSION@', {
|
||||
requires : ['base', 'event-key']
|
||||
}
|
||||
);
|
||||
+5
-2
@@ -501,8 +501,11 @@ function prepare_choice_show_results($choice, $course, $cm, $allresponses, $forc
|
||||
echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'tablecontainer\');">'.get_string('deselectall').'</a> ';
|
||||
echo ' ';
|
||||
echo html_writer::label(get_string('withselected', 'choice'), 'menuaction');
|
||||
echo html_writer::select(array('delete' => get_string('delete')), 'action', '', array(''=>get_string('withselectedusers')), array('id'=>'menuaction'));
|
||||
$PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('attemptsform', 'menuaction', ''));
|
||||
echo html_writer::select(array('delete' => get_string('delete')), 'action', '', array(''=>get_string('withselectedusers')), array('id'=>'menuaction', 'class' => 'autosubmit'));
|
||||
$PAGE->requires->yui_module('moodle-core-formautosubmit',
|
||||
'M.core.init_formautosubmit',
|
||||
array(array('selectid' => 'menuaction'))
|
||||
);
|
||||
echo '<noscript id="noscriptmenuaction" style="display:inline">';
|
||||
echo '<div>';
|
||||
echo '<input type="submit" value="'.get_string('go').'" /></div></noscript>';
|
||||
|
||||
@@ -187,10 +187,12 @@ if ($courseitemfilter > 0) {
|
||||
|
||||
echo ' '. html_writer::label(get_string('filter_by_course', 'feedback'), 'coursefilterid'). ': ';
|
||||
echo html_writer::select($courses, 'coursefilter', $coursefilter,
|
||||
null, array('id'=>'coursefilterid'));
|
||||
null, array('id'=>'coursefilterid', 'class' => 'autosubmit'));
|
||||
|
||||
$PAGE->requires->js_init_call('M.util.init_select_autosubmit',
|
||||
array('analysis-form', 'coursefilterid', false));
|
||||
$PAGE->requires->yui_module('moodle-core-formautosubmit',
|
||||
'M.core.init_formautosubmit',
|
||||
array(array('selectid' => 'coursefilterid', 'nothing' => false))
|
||||
);
|
||||
}
|
||||
echo '<hr />';
|
||||
$itemnr = 0;
|
||||
|
||||
@@ -315,8 +315,11 @@ if ($action === 'delete') {
|
||||
$checklinks = '<a href="javascript: checkall();">'.get_string('selectall').'</a> / ';
|
||||
$checklinks .= '<a href="javascript: checknone();">'.get_string('deselectall').'</a>';
|
||||
$checklinks .= html_writer::label('action', 'menuaction', false, array('class' => 'accesshide'));
|
||||
$checklinks .= html_writer::select(array('delete' => get_string('deleteselected')), 'action', 0, array(''=>'choosedots'), array('id'=>'actionid'));
|
||||
$PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('theform', 'actionid', ''));
|
||||
$checklinks .= html_writer::select(array('delete' => get_string('deleteselected')), 'action', 0, array(''=>'choosedots'), array('id'=>'actionid', 'class' => 'autosubmit'));
|
||||
$PAGE->requires->yui_module('moodle-core-formautosubmit',
|
||||
'M.core.init_formautosubmit',
|
||||
array(array('selectid' => 'actionid', 'nothing' => false))
|
||||
);
|
||||
echo $OUTPUT->box($checklinks, 'center');
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
@@ -749,6 +749,11 @@ class theme_mymobile_core_renderer extends core_renderer {
|
||||
$select->attributes['title'] = $select->tooltip;
|
||||
}
|
||||
|
||||
$select->attributes['class'] = 'autosubmit';
|
||||
if ($select->class) {
|
||||
$select->attributes['class'] .= ' ' . $select->class;
|
||||
}
|
||||
|
||||
if ($select->label) {
|
||||
$output .= html_writer::label($select->label, $select->attributes['id']);
|
||||
}
|
||||
@@ -767,7 +772,10 @@ class theme_mymobile_core_renderer extends core_renderer {
|
||||
$output .= html_writer::tag('noscript', html_writer::tag('div', $go), array('style' => 'inline'));
|
||||
|
||||
$nothing = empty($select->nothing) ? false : key($select->nothing);
|
||||
$this->page->requires->js_init_call('M.util.init_select_autosubmit', array($select->formid, $select->attributes['id'], $nothing));
|
||||
$this->page->requires->yui_module('moodle-core-formautosubmit',
|
||||
'M.core.init_formautosubmit',
|
||||
array(array('selectid' => $select->attributes['id'], 'nothing' => $nothing))
|
||||
);
|
||||
|
||||
// then div wrapper for xhtml strictness
|
||||
$output = html_writer::tag('div', $output);
|
||||
|
||||
Reference in New Issue
Block a user