Fix demo form, and add a .getWindow method

develop
Sven Slootweg 11 years ago
parent 6be9710a34
commit f4fd1b68fb

File diff suppressed because one or more lines are too long

@ -2,6 +2,13 @@
{TOC}
## jQuery extensions
^ $.getWindow()
Returns the JsdeWindow that the applicable element exists in. Useful to
do things like dynamically updating windows from an AJAX response.
## JsdeWindow
### Member variables

@ -24,12 +24,23 @@
});
new JsdeWindow({
x: 20,
y: 20,
x: 120,
y: 40,
width: 400,
height: 300,
title: "Whee!"
});
$("#demo_button").click(function(event){
new JsdeWindow({
width: parseInt($("#w").val()),
height: parseInt($("#h").val()),
x: parseInt($("#x").val()),
y: parseInt($("#y").val()),
title: $("#title").val(),
contents: $("#contents").val()
});
});
})
</script>
<link href='http://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
@ -42,7 +53,7 @@
<span id="id2">733, 85<br>873, 77</span><br><br>
X: <input id="x" value="200" type="text"><br>
Y: <input id="y" value="250" type="text"><br>
Title: <input id="title" value="200" type="text"><br>
Title: <input id="title" value="Sample title" type="text"><br>
Contents (HTML): <br>
<textarea id="contents" style="width: 300px; height: 180px;">&lt;strong&gt;ohai!&lt;/strong&gt;&lt;br&gt;
lol&lt;hr&gt;
@ -50,7 +61,7 @@ lol&lt;hr&gt;
</textarea><br>
Width: <input id="w" value="400" type="text"><br>
Height: <input id="h" value="300" type="text"><br>
<button onclick="createWindow(parseInt($('#x').val()),parseInt($('#y').val()),$('#title').val(),$('#contents').val(),parseInt($('#w').val()),parseInt($('#h').val())).bringToForeground();">Make new window</button>
<button id="demo_button">Make new window</button>
</div>
<div class="workspace-bar">
<span id="workspace-tab-list">

@ -12,6 +12,10 @@
.css('user-select', 'text')
.off('selectstart');
};
$.fn.getWindow = function() {
return this.closest(".window-inner").data("jsde-window");
};
})(jQuery);
var next_z_index = 1;
@ -29,7 +33,7 @@ function JsdeWindow(options)
$.extend(this, options);
this._outer = $("#jsde_templates .template_window").clone()[0];
this._inner = $(this._outer).children(".window-inner")[0];
this._inner = $(this._outer).find(".window-inner")[0];
this._title = $(this._outer).children(".window-title")[0];
if(typeof options.visible !== "undefined" && options.visible == false)
@ -126,6 +130,7 @@ JsdeWindow.prototype.SetSize = function(width, height)
JsdeWindow.prototype.SetContents = function(html)
{
console.log("set contents", html, this);
return $(this._inner).html(html);
}

Loading…
Cancel
Save