Upgrading base.js to handle data-controllerid on <select/>

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-01-19 12:43:56 -08:00
parent bdfe4f3a16
commit 15ba66b6c2
2 changed files with 17 additions and 12 deletions

View File

@@ -1,13 +1,13 @@
@model Orchard.Core.Common.ViewModels.TextFieldDriverViewModel
<label for="@Html.FieldIdFor(m => m.Text)">@Model.Field.DisplayName</label>
<fieldset>
@if (String.IsNullOrWhiteSpace(Model.Settings.Flavor)) {
@Html.TextBoxFor(m => m.Text, new { @class = "text" })
@Html.ValidationMessageFor(m => m.Text)
}
else {
@Display.Body_Editor(Text: Model.Text, EditorFlavor: Model.Settings.Flavor)
}
<span class="hint">@Model.Settings.Hint</span>
<label for="@Html.FieldIdFor(m => m.Text)">@Model.Field.DisplayName</label>
@if (String.IsNullOrWhiteSpace(Model.Settings.Flavor)) {
@Html.TextBoxFor(m => m.Text, new { @class = "text" })
@Html.ValidationMessageFor(m => m.Text)
}
else {
@Display.Body_Editor(Text: Model.Text, EditorFlavor: Model.Settings.Flavor)
}
<span class="hint">@Model.Settings.Hint</span>
</fieldset>

View File

@@ -137,7 +137,7 @@
var _this = $(this);
var _controllees = $("[data-controllerid=" + _this.attr("id") + "]");
var _controlleesAreHidden = _controllees.is(":hidden");
if (_this.is(":checked")) {
if (_this.is(":checked") || _this.is(":selected")) {
if (_controlleesAreHidden) {
_controllees.hide(); // <- unhook this when the following comment applies
$(_controllees.show()[0]).find("input").focus(); // <- aaaand a slideDown there...eventually
@@ -157,7 +157,7 @@
return;
}
controller.data("isControlling", 1);
if (!controller.is(":checked")) {
if (!controller.is(":checked") && !controller.is(":selected")) {
$("[data-controllerid=" + controller.attr("id") + "]").hide();
}
if (controller.is(":checkbox")) {
@@ -165,6 +165,11 @@
} else if (controller.is(":radio")) {
$("[name=" + controller.attr("name") + "]").click(function () { $("[name=" + $(this).attr("name") + "]").each($(this).toggleWhatYouControl); });
}
else if (controller.is("option")) {
controller.parent().change(function () {
controller.toggleWhatYouControl();
});
}
});
});
// inline form link buttons (form.inline.link button) swapped out for a link that submits said form