]> git.wh0rd.org Git - tt-rss.git/commitdiff
rework label edit dialog
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 19 Nov 2010 09:12:54 +0000 (12:12 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 19 Nov 2010 09:12:54 +0000 (12:12 +0300)
modules/pref-labels.php
prefs.js

index ea1835f87beb20b6b6b18f91e1a0cb04d46522ae..540df97b18286e51348ecf18f166b146bd34fad4 100644 (file)
 
                        $line = db_fetch_assoc($result);
 
+                       print "<form id=\"label_edit_form\" name=\"label_edit_form\"
+                               onsubmit=\"return false;\">";
+
+                       print "<input type=\"hidden\" name=\"id\" value=\"$label_id\">";
+                       print "<input type=\"hidden\" name=\"op\" value=\"pref-labels\">";
+                       print "<input type=\"hidden\" name=\"subop\" value=\"save\">";
+
                        print "<div class=\"dlgSec\">".__("Caption")."</div>";
 
                        print "<div class=\"dlgSecCont\">";
 
-                       print "<span dojoType=\"dijit.InlineEditBox\" style=\"font-size : 18px;\"
-                               width=\"150px\" autoSave=\"false\"
-                               label-id=\"$label_id\">" . $line["caption"] . 
-                               "<script type=\"dojo/method\" event=\"onChange\" args=\"item\">
-                                       var elem = this;
-                                       dojo.xhrPost({
-                                               url: 'backend.php',
-                                               content: {op: 'pref-labels', subop: 'save',
-                                                       value: this.value,
-                                                       id: this.srcNodeRef.getAttribute('label-id')},
-                                                       load: function(response) {
-                                                               elem.attr('value', response);
-                                                               dijit.byId('labelTree').setNameById($label_id, response);
-                                                               updateFilterList();
-                                                       }
-                                       });     
-                               </script>
-                       </span>";
+                       print "<input style=\"font-size : 18px\" name=\"caption\" 
+                               onkeypress=\"return filterCR(event, editLabelSave)\"
+                               value=\"".htmlspecialchars($line['caption'])."\">";
 
                        print "</div>";
-                       print "<div class=\"dlgSec\">" . __("Change colors") . "</div>";
+                       print "<div class=\"dlgSec\">" . __("Colors") . "</div>";
                        print "<div class=\"dlgSecCont\">";
 
                        print "<table cellspacing=\"5\"><th>";
 
-                       print "<tr><td>".__("Foreground color:")."</td><td>".__("Background color:").
+                       print "<tr><td>".__("Foreground:")."</td><td>".__("Background:").
                                "</td></tr>";
 
                        print "</th><tr><td>";
 
+                       $fg_color = $line['fg_color'];
+                       $bg_color = $line['bg_color'];
+
+                       print "<input type=\"hidden\" name=\"fg_color\" value=\"$fg_color\">";
+                       print "<input type=\"hidden\" name=\"bg_color\" value=\"$bg_color\">";
+
                        print "<div dojoType=\"dijit.ColorPalette\">
                                <script type=\"dojo/method\" event=\"onChange\" args=\"fg_color\">
-                                       setLabelColor('$label_id', fg_color, null);
+                                       document.forms['label_edit_form'].fg_color.value = fg_color;
                                </script>
                        </div>";
                        print "</div>";
@@ -61,7 +59,7 @@
 
                        print "<div dojoType=\"dijit.ColorPalette\">
                                <script type=\"dojo/method\" event=\"onChange\" args=\"bg_color\">
-                                       setLabelColor('$label_id', null, bg_color);
+                                       document.forms['label_edit_form'].bg_color.value = bg_color;
                                </script>
                        </div>";
                        print "</div>";
                        print "</td></tr></table>";
                        print "</div>";
 
-                       print "<div class=\"dlgButtons\" style=\"text-align : center\">";
+                       print "</form>";
+
+                       print "<div class=\"dlgButtons\">";
+                       print "<button onclick=\"return editLabelSave()\">".
+                               __('Save')."</button>";
                        print "<button onclick=\"return closeInfoBox()\">".
-                               __('Close this window')."</button>";
+                               __('Cancel')."</button>";
                        print "</div>";
 
                        print "]]></content></dlg>";
                if ($subop == "save") {
 
                        $id = db_escape_string($_REQUEST["id"]);
-                       $caption = db_escape_string(trim($_REQUEST["value"]));
+                       $caption = db_escape_string(trim($_REQUEST["caption"]));
 
                        db_query($link, "BEGIN");
 
index b8b1b49b2830b44168b2d30883765226430c1cef..0c627b21931ce03ee8e1aad187ad7997b0201108 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -1976,3 +1976,30 @@ function editLabel(id, event) {
                exception_error("editLabel", e);
        }
 }
+
+function editLabelSave() {
+       try {
+               var form = document.forms['label_edit_form'];
+
+               var id = form.id.value;
+               var caption = form.caption.value;
+               var fg_color = form.fg_color.value;
+               var bg_color = form.bg_color.value;
+
+               var query = Form.serialize('label_edit_form');
+
+               dijit.byId('labelTree').setNameById(id, caption);
+               setLabelColor(id, fg_color, bg_color);
+
+               closeInfoBox();
+               updateFilterList();
+
+               new Ajax.Request("backend.php", {
+                       parameters: query,
+                       onComplete: function(transport) { 
+                       } });
+
+       } catch (e) {
+               exception_error("editLabelSave", e);
+       }
+}