]> jfr.im git - irc/quakenet/qwebirc.git/blobdiff - js/ui/embedwizard.js
TODO update, also include more instead of sortables.
[irc/quakenet/qwebirc.git] / js / ui / embedwizard.js
index 987ec7c88f9ab1fabcac012bf7194f7b3a466ab9..65f3447a70a4587f81c39a9f56c902e463f9826e 100644 (file)
@@ -60,10 +60,7 @@ qwebirc.ui.EmbedWizard = new Class({
     exampleRow.appendChild(this.example);
     
     var nextRow = this.newRow();
-    nextRow.setStyle("position", "absolute");
-    nextRow.setStyle("bottom", "0px");
-    nextRow.setStyle("right", "0px");
-    nextRow.setStyle("margin", "3px");
+    nextRow.addClass("wizardcontrols");
     var backBtn = new Element("input");
     backBtn.type = "submit";
     backBtn.value = "< Back";
@@ -90,11 +87,16 @@ qwebirc.ui.EmbedWizard = new Class({
   newRadio: function(parent, text, name, selected) {
     var p = new Element("div");
     parent.appendChild(p);
-      
-    var r = new Element("input");
-    r.type = "radio";
-    r.name = name;
-    
+
+    var r;
+    if(Browser.Engine.trident) {
+      r = document.createElement("<input type=\"radio\" name=\" + escape(name) + \"" + (selected?" checked":"") + "/>");
+    } else {    
+      r = new Element("input");
+      r.type = "radio";
+      r.name = name;
+    }    
+
     if(selected)
       r.checked = true;
       
@@ -104,7 +106,19 @@ qwebirc.ui.EmbedWizard = new Class({
     return r;
   },
   addSteps: function() {
-    var af = function() { this.options.middle.focus(); };
+    var af = function(select) {
+      if(Browser.Engine.trident) {
+        var f = function() {
+          this.focus();
+          if(select)
+            this.select();
+        };
+        f.delay(100, this, []);
+      } else {
+        this.focus();
+        this.select();
+      }
+    };
   
     this.welcome = this.newStep({
       "title": "Welcome!",
@@ -112,13 +126,14 @@ qwebirc.ui.EmbedWizard = new Class({
     });
     
     this.chanBox = new Element("input");
+    this.chanBox.addClass("text");
     this.chans = this.newStep({
       "title": "Set channels",
       "first": "Enter the channels you would like the client to join on startup:",
       "hint": "You can supply multiple channels by seperating them with a comma, e.g.:",
       "example": "#rogue,#eu-mage",
       middle: this.chanBox
-    }).addEvent("show", af);
+    }).addEvent("show", af.bind(this.chanBox));
     
     var customnickDiv = new Element("div");
     this.customnick = this.newStep({
@@ -128,8 +143,8 @@ qwebirc.ui.EmbedWizard = new Class({
       middle: customnickDiv
     });
 
-    this.randnick = this.newRadio(customnickDiv, "Use a random nickname, e.g. qwebirc12883.", "nick", true);
-    this.choosenick = this.newRadio(customnickDiv, "Make the user choose a nickname.", "nick");
+    this.choosenick = this.newRadio(customnickDiv, "Make the user choose a nickname.", "nick", true);
+    this.randnick = this.newRadio(customnickDiv, "Use a random nickname, e.g. qwebirc12883.", "nick");
     this.presetnick = this.newRadio(customnickDiv, "Use a preset nickname of your choice.", "nick");
     
     var promptdiv = new Element("form");
@@ -140,10 +155,11 @@ qwebirc.ui.EmbedWizard = new Class({
       "hint": "You need to display the dialog if you want the user to be able to set their nickname before connecting."
     });
     
-    this.connectdialogr = this.newRadio(promptdiv, "Show the connect dialog.", "prompt", true);
-    var autoconnect = this.newRadio(promptdiv, "Connect without displaying the dialog.", "prompt");
+    var autoconnect = this.newRadio(promptdiv, "Connect without displaying the dialog.", "prompt", true);
+    this.connectdialogr = this.newRadio(promptdiv, "Show the connect dialog.", "prompt");
     
     this.nicknameBox = new Element("input");
+    this.nicknameBox.addClass("text");
     this.nickname = this.newStep({
       "title": "Set nickname",
       "first": "Enter the nickname you would like the client to use by default:",
@@ -156,7 +172,7 @@ qwebirc.ui.EmbedWizard = new Class({
         return true;
       }.bind(this),
       middle: this.nicknameBox
-    }).addEvent("show", af);
+    }).addEvent("show", af.bind(this.nicknameBox));
 
     var codeDiv = new Element("div");
     this.finish = this.newStep({
@@ -166,12 +182,13 @@ qwebirc.ui.EmbedWizard = new Class({
     }).addEvent("show", function() {
       var alink = new Element("a");
       var abox = new Element("input");
-      var url = this.generateURL();
+      abox.addClass("iframetext");
+      var url = this.generateURL(false);
       
       alink.href = url;
       alink.target = "new";
       alink.appendChild(document.createTextNode(url));
-      abox.value = "<iframe src=\"" + url + "\"></iframe>";
+      abox.value = "<iframe src=\"" + url + "\" width=\"647\" height=\"400\"></iframe>";
       
       var mBox = [
         alink,
@@ -187,6 +204,11 @@ qwebirc.ui.EmbedWizard = new Class({
       mBox.forEach(function(x) {
         codeDiv.appendChild(x);
       });
+      
+      af.bind(abox)(true);
+      abox.addEvent("click", function() {
+        this.select();
+      }.bind(abox));
     }.bind(this));
 
     this.updateSteps();
@@ -201,7 +223,8 @@ qwebirc.ui.EmbedWizard = new Class({
       this.steps.push(this.nickname);
       
     this.steps.push(this.chans);
-    if(!this.choosenick.checked)
+    
+    if(this.chanBox.value != "" && !this.choosenick.checked)
       this.steps.push(this.connectdialog);
     
     this.steps.push(this.finish);
@@ -240,20 +263,19 @@ qwebirc.ui.EmbedWizard = new Class({
   generateURL: function() {
     var chans = this.chanBox.value;
     var nick = this.nicknameBox.value;
-    var connectdialog = this.connectdialogr.checked || this.choosenick.checked;
-    
+    var connectdialog = this.connectdialogr.checked && chans != "" && !this.choosenick.checked;
+
     var URL = [];
     if(this.presetnick.checked) {
       URL.push("nick=" + escape(nick));
-    } else if(this.choosenick.checked) {
-      URL.push("nick=");
+    } else if(!this.choosenick.checked) {
+      URL.push("randomnick=1");
     }
     
     if(chans) {
       var d = chans.split(",");
       var d2 = [];
       
-      /* WTB map */
       d.forEach(function(x) {
         if(x.charAt(0) == '#')
           x = x.substring(1);
@@ -267,6 +289,6 @@ qwebirc.ui.EmbedWizard = new Class({
     if(connectdialog)
       URL.push("prompt=1");
 
-    return this.options.baseURL + "?" + URL.join("&");
+    return this.options.baseURL + (URL.length>0?"?":"") + URL.join("&");
   }
 });