Fix demo form, and add a .getWindow method
This commit is contained in:
parent
6be9710a34
commit
f4fd1b68fb
File diff suppressed because one or more lines are too long
|
@ -2,6 +2,13 @@
|
||||||
|
|
||||||
{TOC}
|
{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
|
## JsdeWindow
|
||||||
|
|
||||||
### Member variables
|
### Member variables
|
||||||
|
|
19
index.html
19
index.html
|
@ -24,12 +24,23 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
new JsdeWindow({
|
new JsdeWindow({
|
||||||
x: 20,
|
x: 120,
|
||||||
y: 20,
|
y: 40,
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 300,
|
height: 300,
|
||||||
title: "Whee!"
|
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>
|
</script>
|
||||||
<link href='http://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
|
<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>
|
<span id="id2">733, 85<br>873, 77</span><br><br>
|
||||||
X: <input id="x" value="200" type="text"><br>
|
X: <input id="x" value="200" type="text"><br>
|
||||||
Y: <input id="y" value="250" 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>
|
Contents (HTML): <br>
|
||||||
<textarea id="contents" style="width: 300px; height: 180px;"><strong>ohai!</strong><br>
|
<textarea id="contents" style="width: 300px; height: 180px;"><strong>ohai!</strong><br>
|
||||||
lol<hr>
|
lol<hr>
|
||||||
|
@ -50,7 +61,7 @@ lol<hr>
|
||||||
</textarea><br>
|
</textarea><br>
|
||||||
Width: <input id="w" value="400" type="text"><br>
|
Width: <input id="w" value="400" type="text"><br>
|
||||||
Height: <input id="h" value="300" 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>
|
||||||
<div class="workspace-bar">
|
<div class="workspace-bar">
|
||||||
<span id="workspace-tab-list">
|
<span id="workspace-tab-list">
|
||||||
|
|
7
jsde.js
7
jsde.js
|
@ -12,6 +12,10 @@
|
||||||
.css('user-select', 'text')
|
.css('user-select', 'text')
|
||||||
.off('selectstart');
|
.off('selectstart');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$.fn.getWindow = function() {
|
||||||
|
return this.closest(".window-inner").data("jsde-window");
|
||||||
|
};
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
var next_z_index = 1;
|
var next_z_index = 1;
|
||||||
|
@ -29,7 +33,7 @@ function JsdeWindow(options)
|
||||||
$.extend(this, options);
|
$.extend(this, options);
|
||||||
|
|
||||||
this._outer = $("#jsde_templates .template_window").clone()[0];
|
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];
|
this._title = $(this._outer).children(".window-title")[0];
|
||||||
|
|
||||||
if(typeof options.visible !== "undefined" && options.visible == false)
|
if(typeof options.visible !== "undefined" && options.visible == false)
|
||||||
|
@ -126,6 +130,7 @@ JsdeWindow.prototype.SetSize = function(width, height)
|
||||||
|
|
||||||
JsdeWindow.prototype.SetContents = function(html)
|
JsdeWindow.prototype.SetContents = function(html)
|
||||||
{
|
{
|
||||||
|
console.log("set contents", html, this);
|
||||||
return $(this._inner).html(html);
|
return $(this._inner).html(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue