rework label editor to use dijit.form validation
This commit is contained in:
parent
1a709d21d5
commit
48b05a2986
|
@ -6,22 +6,17 @@
|
||||||
if ($subop == "edit") {
|
if ($subop == "edit") {
|
||||||
$label_id = db_escape_string($_REQUEST['id']);
|
$label_id = db_escape_string($_REQUEST['id']);
|
||||||
|
|
||||||
header("Content-Type: text/xml");
|
|
||||||
print "<dlg id=\"$subop\">";
|
|
||||||
print "<title>" . __("Label Editor") . "</title>";
|
|
||||||
print "<content><![CDATA[";
|
|
||||||
|
|
||||||
$result = db_query($link, "SELECT * FROM ttrss_labels2 WHERE
|
$result = db_query($link, "SELECT * FROM ttrss_labels2 WHERE
|
||||||
id = '$label_id' AND owner_uid = " . $_SESSION["uid"]);
|
id = '$label_id' AND owner_uid = " . $_SESSION["uid"]);
|
||||||
|
|
||||||
$line = db_fetch_assoc($result);
|
$line = db_fetch_assoc($result);
|
||||||
|
|
||||||
print "<form id=\"label_edit_form\" name=\"label_edit_form\"
|
# print "<form id=\"label_edit_form\" name=\"label_edit_form\"
|
||||||
onsubmit=\"return false;\">";
|
# onsubmit=\"return false;\">";
|
||||||
|
|
||||||
print "<input type=\"hidden\" name=\"id\" value=\"$label_id\">";
|
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$label_id\">";
|
||||||
print "<input type=\"hidden\" name=\"op\" value=\"pref-labels\">";
|
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-labels\">";
|
||||||
print "<input type=\"hidden\" name=\"subop\" value=\"save\">";
|
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"save\">";
|
||||||
|
|
||||||
print "<div class=\"dlgSec\">".__("Caption")."</div>";
|
print "<div class=\"dlgSec\">".__("Caption")."</div>";
|
||||||
|
|
||||||
|
@ -32,8 +27,9 @@
|
||||||
|
|
||||||
print "<span class=\"labelColorIndicator\" id=\"label-editor-indicator\" style='color : $fg_color; background-color : $bg_color'>α</span>";
|
print "<span class=\"labelColorIndicator\" id=\"label-editor-indicator\" style='color : $fg_color; background-color : $bg_color'>α</span>";
|
||||||
|
|
||||||
print "<input style=\"font-size : 18px\" name=\"caption\"
|
print "<input style=\"font-size : 16px\" name=\"caption\"
|
||||||
onkeypress=\"return filterCR(event, editLabelSave)\"
|
dojoType=\"dijit.form.ValidationTextBox\"
|
||||||
|
required=\"true\"
|
||||||
value=\"".htmlspecialchars($line['caption'])."\">";
|
value=\"".htmlspecialchars($line['caption'])."\">";
|
||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
@ -47,12 +43,16 @@
|
||||||
|
|
||||||
print "<tr><td style='padding-right : 10px'>";
|
print "<tr><td style='padding-right : 10px'>";
|
||||||
|
|
||||||
print "<input type=\"hidden\" name=\"fg_color\" value=\"$fg_color\">";
|
print "<input dojoType=\"dijit.form.TextBox\"
|
||||||
print "<input type=\"hidden\" name=\"bg_color\" value=\"$bg_color\">";
|
style=\"display : none\" id=\"labelEdit_fgColor\"
|
||||||
|
name=\"fg_color\" value=\"$fg_color\">";
|
||||||
|
print "<input dojoType=\"dijit.form.TextBox\"
|
||||||
|
style=\"display : none\" id=\"labelEdit_bgColor\"
|
||||||
|
name=\"bg_color\" value=\"$bg_color\">";
|
||||||
|
|
||||||
print "<div dojoType=\"dijit.ColorPalette\">
|
print "<div dojoType=\"dijit.ColorPalette\">
|
||||||
<script type=\"dojo/method\" event=\"onChange\" args=\"fg_color\">
|
<script type=\"dojo/method\" event=\"onChange\" args=\"fg_color\">
|
||||||
document.forms['label_edit_form'].fg_color.value = fg_color;
|
dijit.byId(\"labelEdit_fgColor\").attr('value', fg_color);
|
||||||
$('label-editor-indicator').setStyle({color: fg_color});
|
$('label-editor-indicator').setStyle({color: fg_color});
|
||||||
</script>
|
</script>
|
||||||
</div>";
|
</div>";
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
|
|
||||||
print "<div dojoType=\"dijit.ColorPalette\">
|
print "<div dojoType=\"dijit.ColorPalette\">
|
||||||
<script type=\"dojo/method\" event=\"onChange\" args=\"bg_color\">
|
<script type=\"dojo/method\" event=\"onChange\" args=\"bg_color\">
|
||||||
document.forms['label_edit_form'].bg_color.value = bg_color;
|
dijit.byId(\"labelEdit_bgColor\").attr('value', bg_color);
|
||||||
$('label-editor-indicator').setStyle({backgroundColor: bg_color});
|
$('label-editor-indicator').setStyle({backgroundColor: bg_color});
|
||||||
</script>
|
</script>
|
||||||
</div>";
|
</div>";
|
||||||
|
@ -71,16 +71,15 @@
|
||||||
print "</td></tr></table>";
|
print "</td></tr></table>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|
||||||
print "</form>";
|
# print "</form>";
|
||||||
|
|
||||||
print "<div class=\"dlgButtons\">";
|
print "<div class=\"dlgButtons\">";
|
||||||
print "<button onclick=\"return editLabelSave()\">".
|
print "<button onclick=\"dijit.byId('labelEditDlg').execute()\">".
|
||||||
__('Save')."</button>";
|
__('Save')."</button>";
|
||||||
print "<button onclick=\"return closeInfoBox()\">".
|
print "<button onclick=\"dijit.byId('labelEditDlg').hide()\">".
|
||||||
__('Cancel')."</button>";
|
__('Cancel')."</button>";
|
||||||
print "</div>";
|
print "</div>";
|
||||||
|
|
||||||
print "]]></content></dlg>";
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
37
prefs.js
37
prefs.js
|
@ -1100,6 +1100,7 @@ function init() {
|
||||||
dojo.require("dijit.Dialog");
|
dojo.require("dijit.Dialog");
|
||||||
dojo.require("dijit.form.Button");
|
dojo.require("dijit.form.Button");
|
||||||
dojo.require("dijit.form.TextBox");
|
dojo.require("dijit.form.TextBox");
|
||||||
|
dojo.require("dijit.form.ValidationTextBox");
|
||||||
dojo.require("dijit.form.RadioButton");
|
dojo.require("dijit.form.RadioButton");
|
||||||
dojo.require("dijit.form.Select");
|
dojo.require("dijit.form.Select");
|
||||||
dojo.require("dijit.Toolbar");
|
dojo.require("dijit.Toolbar");
|
||||||
|
@ -1956,16 +1957,38 @@ function editCat(id, item, event) {
|
||||||
|
|
||||||
function editLabel(id, event) {
|
function editLabel(id, event) {
|
||||||
try {
|
try {
|
||||||
var query = "?op=pref-labels&subop=edit&id=" +
|
var query = "backend.php?op=pref-labels&subop=edit&id=" +
|
||||||
param_escape(id);
|
param_escape(id);
|
||||||
|
|
||||||
notify_progress("Loading, please wait...", true);
|
if (dijit.byId("labelEditDlg"))
|
||||||
|
dijit.byId("labelEditDlg").destroyRecursive();
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
dialog = new dijit.Dialog({
|
||||||
parameters: query,
|
id: "labelEditDlg",
|
||||||
onComplete: function(transport) {
|
title: __("Label Editor"),
|
||||||
infobox_callback2(transport);
|
style: "width: 600px",
|
||||||
} });
|
execute: function() {
|
||||||
|
if (this.validate()) {
|
||||||
|
var caption = this.attr('value').id;
|
||||||
|
var caption = this.attr('value').caption;
|
||||||
|
var fg_color = this.attr('value').fg_color;
|
||||||
|
var bg_color = this.attr('value').bg_color;
|
||||||
|
var query = dojo.objectToQuery(this.attr('value'));
|
||||||
|
|
||||||
|
dijit.byId('labelTree').setNameById(id, caption);
|
||||||
|
setLabelColor(id, fg_color, bg_color);
|
||||||
|
this.hide();
|
||||||
|
|
||||||
|
new Ajax.Request("backend.php", {
|
||||||
|
parameters: query,
|
||||||
|
onComplete: function(transport) {
|
||||||
|
updateFilterList();
|
||||||
|
} });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
href: query});
|
||||||
|
|
||||||
|
dialog.show();
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
exception_error("editLabel", e);
|
exception_error("editLabel", e);
|
||||||
|
|
Loading…
Reference in New Issue