]> git.wh0rd.org - tt-rss.git/blobdiff - functions.js
rework label editor to use dijit.form validation
[tt-rss.git] / functions.js
index 1c21adf0a96fd70ef257124fe3763da4a7ef5fae..48a9ef230fed360a1fd0a13ad28d2b76cbd44e66 100644 (file)
@@ -1,6 +1,6 @@
 var hotkeys_enabled = true;
 var notify_silent = false;
-var last_progress_point = 0;
+var loading_progress = 0;
 var sanity_check_done = false;
 
 /* add method to remove element from array */
@@ -23,8 +23,6 @@ function exception_error(location, e, ext_info) {
 
        if (!ext_info) ext_info = false;
 
-       disableHotkeys();
-
        try {
 
                if (ext_info) {
@@ -44,14 +42,20 @@ function exception_error(location, e, ext_info) {
                content += "<div><b>Stack trace:</b></div>" +
                        "<textarea readonly=\"1\">" + e.stack + "</textarea>";
 
-               content += "<div style='text-align : center'>" +
-                       "<button onclick=\"closeInfoBox()\">" +
-                       "Close this window" + "</button></div>";
-       
+//             content += "<div style='text-align : center'>" +
+//                     "<button onclick=\"closeInfoBox()\">" +
+//                     "Close this window" + "</button></div>";
+
+               content += "</div>";
+
                // TODO: add code to automatically report errors to tt-rss.org
 
-               Modalbox.show(content, {title: "Unhandled exception", width: 600, 
-                       resizeDuration: 0, transitions: false});
+               var dialog = new dijit.Dialog({
+                       title: "Unhandled exception",
+                       style: "width: 600px",
+                       content: content});
+
+               dialog.show();
 
        } catch (e) {
                alert(msg);
@@ -302,10 +306,28 @@ function toggleSelectListRow(sender) {
        return toggleSelectRow(sender, row);
 }
 
+/* this is for dijit Checkbox */
+function toggleSelectListRow2(sender) {
+       var row = sender.domNode.parentNode;
+       return toggleSelectRow(sender, row);
+}
+
 function tSR(sender, row) {
        return toggleSelectRow(sender, row);
 }
 
+/* this is for dijit Checkbox */
+function toggleSelectRow2(sender, row) {
+
+       if (!row) row = sender.domNode.parentNode.parentNode;
+
+       if (sender.checked && !row.hasClassName('Selected'))
+               row.addClassName('Selected');
+       else
+               row.removeClassName('Selected');
+}
+
+
 function toggleSelectRow(sender, row) {
 
        if (!row) row = sender.parentNode.parentNode;
@@ -318,10 +340,7 @@ function toggleSelectRow(sender, row) {
 
 function checkboxToggleElement(elem, id) {
        if (elem.checked) {
-               Effect.Appear(id, {duration : 0.5, 
-                       afterSetup: function() { 
-                               Modalbox.resizeToContent();
-                       }});
+               Effect.Appear(id, {duration : 0.5});
        } else {
                Effect.Fade(id, {duration : 0.5});
        }
@@ -387,10 +406,12 @@ function closeErrorBox() {
 }
 
 function closeInfoBox(cleanup) {
-
        try {
                enableHotkeys();
-               Modalbox.hide();
+
+               dialog = dijit.byId("infoBox");
+
+               if (dialog)     dialog.hide();
 
        } catch (e) {
                //exception_error("closeInfoBox", e);
@@ -401,7 +422,6 @@ function closeInfoBox(cleanup) {
 
 function displayDlg(id, param, callback) {
 
-       disableHotkeys();
        notify_progress("Loading, please wait...", true);
 
        var query = "?op=dlg&id=" +
@@ -434,6 +454,11 @@ function infobox_submit_callback2(transport) {
 
 function infobox_callback2(transport) {
        try {
+               var dialog = false;
+
+               if (dijit.byId("infoBox")) {
+                       dialog = dijit.byId("infoBox");
+               }
 
                //console.log("infobox_callback2");
                notify('');
@@ -446,7 +471,7 @@ function infobox_callback2(transport) {
 
                        var title = transport.responseXML.getElementsByTagName("title")[0];
                        if (title)
-                               dtitle = title.firstChild.nodeValue;
+                               title = title.firstChild.nodeValue;
 
                        var content = transport.responseXML.getElementsByTagName("content")[0];
                        
@@ -456,10 +481,27 @@ function infobox_callback2(transport) {
                        content = transport.responseText;
                }
 
-               Modalbox.show(content, {title: dtitle, width: 600, 
-                       transitions: true, resizeDuration: 0 });
+               if (!dialog) {
+                       dialog = new dijit.Dialog({
+                               title: title,
+                               id: 'infoBox',
+                               style: "width: 600px",
+                               onCancel: function() {
+                                       return true;
+                               },
+                               onExecute: function() {
+                                       return true;
+                               },
+                               onClose: function() {
+                                       return true;
+                                       },
+                               content: content});
+               } else {
+                       dialog.attr('title', title);
+                       dialog.attr('content', content);
+               }
 
-               disableHotkeys();
+               dialog.show();
 
                notify("");
        } catch (e) {
@@ -550,8 +592,6 @@ function subscribeToFeed() {
        new Ajax.Request("backend.php", {
                parameters: query,
                onComplete: function(transport) { 
-                       //dlg_frefresh_callback(transport); 
-
                        try {
 
                                if (!transport.responseXML) {
@@ -603,10 +643,7 @@ function subscribeToFeed() {
                                                        if (count > 5) count = 5;
                                                        select.size = count;
        
-                                                       Effect.Appear('fadd_feeds_container', {duration : 0.5, 
-                                                               afterSetup: function() { 
-                                                                       Modalbox.resizeToContent()
-                                                               }});
+                                                       Effect.Appear('fadd_feeds_container', {duration : 0.5});
                                                }
                                        });
                                        break;
@@ -842,21 +879,13 @@ function displayHelpInfobox(topic_id) {
 
 function loading_set_progress(p) {
        try {
-               if (p < last_progress_point || !Element.visible("overlay")) return;
-
-               console.log("loading_set_progress : " + p + " (" + last_progress_point + ")");
+               loading_progress += p;
 
-               var o = $("l_progress_i");
+               if (dijit.byId("loading_bar"))
+                       dijit.byId("loading_bar").update({progress: loading_progress});
 
-//             o.style.width = (p * 2) + "px";
-
-               new Effect.Scale(o, p, { 
-                       scaleY : false,
-                       scaleFrom : last_progress_point,
-                       scaleMode: { originalWidth : 200 },
-                       queue: { position: 'end', scope: 'LSP-Q', limit: 3 } }); 
-
-               last_progress_point = p;
+               if (loading_progress >= 90)
+                       remove_splash();
 
        } catch (e) {
                exception_error("loading_set_progress", e);
@@ -864,6 +893,7 @@ function loading_set_progress(p) {
 }
 
 function remove_splash() {
+
        if (Element.visible("overlay")) {
                console.log("about to remove splash, OMG!");
                Element.hide("overlay");