[예제] 메모 위젯 소스
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:widget="http://wzdapi.com/widget/">
- <head>
- <meta name="author" content="WzdWorks" />
- <meta name="description" content="심플하게 사용하는 나만의 웹메모장" />
- <meta name="website" content="http://wzdworks.com/" />
- <meta name="apiVersion" content="1.0" />
- <meta name="autoRefresh" content="0" />
- <meta name="maximizable" content="yes" />
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <link rel="icon" type="image/png" href="http://beta.wzd.com/Design/images/widget/icon_memo.png" />
- <script type="text/javascript" src="http://wzdapi.com/widget/emulator.js"></script>
- <title>메모</title>
- <style type="text/css">
- /*<![CDATA[*/
div {- border: 2px solid #ffe487;
- background-color: #ffffcc;
- padding: 8px;
- }
textarea {- border: 0;
- width: 100%;
- height: 100%;
- background: url(/Design/images/widget/memo/memo_line_pattern_yel.png) top center;
- line-height: 20px;
- overflow: auto;
- }
div.modified {- border-color: #F93;
- }
/*]]>*/- </style>
- <script type="text/javascript">
- //<![CDATA[
var Memo = {- timer: 0,
- save: function() {
- var el = UWA.$element(widget.body.getElementsByTagName('textarea')[0]);
- el.parentNode.removeClassName('modified');
- widget.setValue('memo', el.value);
- el.defaultValue = el.value;
- },
- saveFromPopup: function(el) {
- UWA.$element(el.parentNode).removeClassName('modified');
- this.save();
- },
- obj: 0
- };
widget.onLoad = function() {- var el = Memo.obj = UWA.$element(widget.body.getElementsByTagName('textarea')[0]);
- el.defaultValue = el.value = widget.getValue('memo');
- el.onkeyup = function(e) {
- Memo.timer && clearTimeout(Memo.timer);
- if (this.defaultValue != this.value) {
- this.parentNode.addClassName('modified');
- Memo.timer = setTimeout(Memo.save, 999);
- }
- };
- };
widget.onResize = function(w, h) {- var el = widget.body.getElementsByTagName('textarea')[0];
- el.style.width = w - 24 + 'px';
- el.style.height = h - 24 + 'px';
- };
widget.onMaximize = function() {- var popup = widget.createPopup();
- popup.setTitle('메모');
- popup.body.padding = '0 2px 2px';
- popup.body.innerHTML = widget.body.innerHTML;
- popup.onResize = function(w, h) {
- var el = popup.body.getElementsByTagName('textarea')[0];
- el.style.width = w - 24 + 'px';
- el.style.height = h - 24 + 'px';
- };
- popup.body.getElementsByTagName('textarea')[0].onkeyup = function() {
- Memo.timer && clearTimeout(Memo.timer);
- if (this.defaultValue != this.value) {
- Memo.obj.defaultValue = Memo.obj.value = this.value;
- UWA.$element(this.parentNode).addClassName('modified');
- Memo.timer = setTimeout(Memo.saveFromPopup.bind(Memo, this), 999);
- }
- };
- };
//]]>- </script>
- <widget:preferences>
- <widget:preference name="memo" type="hidden" />
- </widget:preferences>
- </head>
- <body style="padding: 0 2px 2px;"><div><textarea rows="5" cols="40"></textarea></div></body>
- </html>
History
Last edited on 09/11/2007 21:08 by pyo
Comments (0)