From 45b0fe42a979d444d547a5248eb2e9e915aaf16a Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 14 Jan 2007 02:10:24 +0000 Subject: Add "block-content" to allow user comments on block level elements in quickstart docs. --- .gitattributes | 12 + buildscripts/chmbuilder/index.php | 7 + buildscripts/texbuilder/Page2Tex.php | 48 ++- buildscripts/texbuilder/quickstart/build.php | 4 +- .../protected/controls/Comments/CommentBlock.php | 107 +++++++ .../protected/controls/Comments/CommentBlock.tpl | 63 ++++ .../protected/controls/Comments/comments.css | 226 ++++++++++++++ .../protected/controls/Comments/comments.js | 179 +++++++++++ .../protected/controls/Comments/right_back.png | Bin 0 -> 545 bytes .../protected/controls/Comments/right_tag.png | Bin 0 -> 602 bytes .../quickstart/protected/controls/Comments/tag.gif | Bin 0 -> 226 bytes demos/quickstart/protected/controls/Layout.tpl | 2 + .../pages/ActiveControls/ActiveButton.page | 30 +- .../pages/ActiveControls/ActiveCheckBox.page | 6 +- .../ActiveControls/ActiveCustomValidator.page | 6 +- .../protected/pages/ActiveControls/Home.page | 30 +- .../pages/ActiveControls/Introduction.page | 2 +- .../protected/pages/Advanced/Assets.page | 26 +- .../quickstart/protected/pages/Advanced/Auth.page | 38 +-- .../protected/pages/Advanced/Collections.page | 58 ++-- .../quickstart/protected/pages/Advanced/Error.page | 32 +- .../quickstart/protected/pages/Advanced/I18N.page | 146 ++++----- .../protected/pages/Advanced/Logging.page | 26 +- .../protected/pages/Advanced/MasterContent.page | 22 +- .../protected/pages/Advanced/Performance.page | 38 +-- .../pages/Advanced/Samples/I18N/Home.de.page | 2 +- .../pages/Advanced/Samples/I18N/Home.es.page | 2 +- .../pages/Advanced/Samples/I18N/Home.fr.page | 2 +- .../pages/Advanced/Samples/I18N/Home.page | 2 +- .../pages/Advanced/Samples/I18N/Home.pl.page | 2 +- .../pages/Advanced/Samples/I18N/Home.zh.page | 2 +- .../pages/Advanced/Samples/I18N/zh_TW/Home.page | 2 +- .../protected/pages/Advanced/Scripts.page | 104 +++---- .../protected/pages/Advanced/Scripts1.page | 22 +- .../protected/pages/Advanced/Scripts2.page | 80 ++--- .../protected/pages/Advanced/Scripts3.page | 12 +- .../protected/pages/Advanced/Security.page | 38 +-- .../quickstart/protected/pages/Advanced/State.page | 26 +- .../protected/pages/Advanced/Themes.page | 26 +- .../protected/pages/Configurations/AppConfig.page | 14 +- .../protected/pages/Configurations/Overview.page | 4 +- .../protected/pages/Configurations/PageConfig.page | 12 +- .../protected/pages/Configurations/Templates1.page | 44 +-- .../protected/pages/Configurations/Templates2.page | 46 +-- .../protected/pages/Configurations/Templates3.page | 50 +-- .../protected/pages/Configurations/UrlMapping.page | 36 +-- .../protected/pages/Controls/Button.page | 4 +- .../protected/pages/Controls/CheckBox.page | 4 +- .../protected/pages/Controls/ClientScript.page | 21 +- .../protected/pages/Controls/ColorPicker.page | 2 +- .../quickstart/protected/pages/Controls/Data.page | 2 +- .../protected/pages/Controls/DataGrid.page | 68 ++-- .../protected/pages/Controls/DataList.page | 26 +- .../protected/pages/Controls/DatePicker.page | 30 +- .../protected/pages/Controls/Expression.page | 8 +- .../protected/pages/Controls/FileUpload.page | 10 +- .../quickstart/protected/pages/Controls/Head.page | 2 +- .../protected/pages/Controls/HiddenField.page | 4 +- .../protected/pages/Controls/HtmlArea.page | 10 +- .../protected/pages/Controls/HyperLink.page | 2 +- .../quickstart/protected/pages/Controls/Image.page | 2 +- .../protected/pages/Controls/ImageButton.page | 2 +- .../protected/pages/Controls/ImageMap.page | 8 +- .../protected/pages/Controls/InlineFrame.page | 8 +- .../protected/pages/Controls/JavascriptLogger.page | 12 +- .../quickstart/protected/pages/Controls/Label.page | 2 +- .../protected/pages/Controls/LinkButton.page | 2 +- .../quickstart/protected/pages/Controls/List.page | 30 +- .../protected/pages/Controls/Literal.page | 8 +- .../protected/pages/Controls/MultiView.page | 14 +- .../protected/pages/Controls/NewControl.page | 58 ++-- .../protected/pages/Controls/OutputCache.page | 20 +- .../quickstart/protected/pages/Controls/Pager.page | 14 +- .../quickstart/protected/pages/Controls/Panel.page | 2 +- .../protected/pages/Controls/PlaceHolder.page | 2 +- .../protected/pages/Controls/RadioButton.page | 2 +- .../protected/pages/Controls/Repeater.page | 26 +- .../protected/pages/Controls/SafeHtml.page | 6 +- .../protected/pages/Controls/Standard.page | 2 +- .../protected/pages/Controls/Statements.page | 12 +- .../quickstart/protected/pages/Controls/Table.page | 2 +- .../protected/pages/Controls/TextBox.page | 2 +- .../protected/pages/Controls/TextHighlighter.page | 8 +- .../protected/pages/Controls/Validation.page | 72 ++--- .../protected/pages/Controls/Wizard.page | 30 +- .../protected/pages/Database/ActiveRecord.page | 139 ++++----- demos/quickstart/protected/pages/Database/DAO.page | 70 ++--- .../protected/pages/Database/SqlMap.page | 84 ++--- .../protected/pages/Fundamentals/Applications.page | 20 +- .../protected/pages/Fundamentals/Architecture.page | 4 +- .../protected/pages/Fundamentals/Components.page | 52 ++-- .../protected/pages/Fundamentals/Controls.page | 22 +- .../protected/pages/Fundamentals/Hangman.page | 7 +- .../protected/pages/Fundamentals/Modules.page | 20 +- .../protected/pages/Fundamentals/Pages.page | 8 +- .../protected/pages/Fundamentals/Services.page | 16 +- .../protected/pages/GettingStarted/AboutPrado.page | 32 +- .../pages/GettingStarted/CommandLine.page | 26 +- .../protected/pages/GettingStarted/HelloWorld.page | 41 +-- .../pages/GettingStarted/Installation.page | 17 +- .../pages/GettingStarted/Introduction.page | 8 +- .../protected/pages/GettingStarted/Upgrading.page | 31 +- .../protected/pages/Services/SoapService.page | 76 +++-- .../protected/pages/Tutorial/AjaxChat.page | 264 ++++++++-------- .../pages/Tutorial/CurrencyConverter.page | 343 +++++++++++---------- demos/quickstart/themes/PradoSoft/style.css | 19 +- framework/3rdParty/WsdlGen/WsdlGenerator.php | 2 +- framework/I18N/TGlobalizationAutoDetect.php | 10 + framework/Web/Services/TSoapService.php | 2 +- framework/Web/UI/TTemplateManager.php | 8 + .../simple_unit/ActiveRecord/CriteriaTestCase.php | 36 +++ tests/simple_unit/Soap/ContactManager.php | 10 +- tests/simple_unit/Soap/SoapTestCase.php | 91 ++++++ tests/simple_unit/application.xml | 9 + tests/simple_unit/ws.php | 9 + 115 files changed, 2258 insertions(+), 1393 deletions(-) create mode 100644 buildscripts/chmbuilder/index.php create mode 100644 demos/quickstart/protected/controls/Comments/CommentBlock.php create mode 100644 demos/quickstart/protected/controls/Comments/CommentBlock.tpl create mode 100644 demos/quickstart/protected/controls/Comments/comments.css create mode 100644 demos/quickstart/protected/controls/Comments/comments.js create mode 100644 demos/quickstart/protected/controls/Comments/right_back.png create mode 100644 demos/quickstart/protected/controls/Comments/right_tag.png create mode 100644 demos/quickstart/protected/controls/Comments/tag.gif create mode 100644 tests/simple_unit/ActiveRecord/CriteriaTestCase.php create mode 100644 tests/simple_unit/Soap/SoapTestCase.php create mode 100644 tests/simple_unit/application.xml create mode 100644 tests/simple_unit/ws.php diff --git a/.gitattributes b/.gitattributes index 24b923d7..3f081cfb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -348,6 +348,7 @@ buildscripts/chmbuilder/classes/pages/Classes.php -text buildscripts/chmbuilder/classes/pages/MainLayout.php -text buildscripts/chmbuilder/classes/pages/MainLayout.tpl -text buildscripts/chmbuilder/classes/pages/style.css -text +buildscripts/chmbuilder/index.php -text buildscripts/classtree/DWExtension.php -text buildscripts/classtree/DWExtensionReadme.txt -text buildscripts/classtree/build.php -text @@ -812,6 +813,13 @@ demos/quickstart/index2.php -text demos/quickstart/protected/.htaccess -text demos/quickstart/protected/QuickStartGlobalization.php -text demos/quickstart/protected/application.xml -text +demos/quickstart/protected/controls/Comments/CommentBlock.php -text +demos/quickstart/protected/controls/Comments/CommentBlock.tpl -text +demos/quickstart/protected/controls/Comments/comments.css -text +demos/quickstart/protected/controls/Comments/comments.js -text +demos/quickstart/protected/controls/Comments/right_back.png -text +demos/quickstart/protected/controls/Comments/right_tag.png -text +demos/quickstart/protected/controls/Comments/tag.gif -text demos/quickstart/protected/controls/DocLink.php -text demos/quickstart/protected/controls/Layout.php -text demos/quickstart/protected/controls/Layout.tpl -text @@ -2354,6 +2362,7 @@ tests/simple_unit/ActiveRecord/ActiveRecordMySql5TestCase.php -text tests/simple_unit/ActiveRecord/ActiveRecordRegistryTestCase.php -text tests/simple_unit/ActiveRecord/BaseActiveRecordTestCase.php -text tests/simple_unit/ActiveRecord/CountRecordsTestCase.php -text +tests/simple_unit/ActiveRecord/CriteriaTestCase.php -text tests/simple_unit/ActiveRecord/DeleteByPkTestCase.php -text tests/simple_unit/ActiveRecord/FindByPksTestCase.php -text tests/simple_unit/ActiveRecord/FindBySqlTestCase.php -text @@ -2368,6 +2377,7 @@ tests/simple_unit/ActiveRecord/records/SimpleUser.php -text tests/simple_unit/ActiveRecord/records/SqliteUsers.php -text tests/simple_unit/ActiveRecord/records/UserRecord.php -text tests/simple_unit/Soap/ContactManager.php -text +tests/simple_unit/Soap/SoapTestCase.php -text tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php -text tests/simple_unit/SqlMap/BaseCase.php -text tests/simple_unit/SqlMap/CacheTest.php -text @@ -2481,7 +2491,9 @@ tests/simple_unit/SqlMap/scripts/sqlite/database.sql -text tests/simple_unit/SqlMap/sqlite.xml -text tests/simple_unit/SqlMap/sqlite/backup.db -text tests/simple_unit/SqlMap/sqlite/tests.db -text +tests/simple_unit/application.xml -text tests/simple_unit/unit.php -text +tests/simple_unit/ws.php -text tests/test_tools/selenium/core/lib/cssQuery/cssQuery-p.js -text tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-level2.js -text tests/test_tools/selenium/core/lib/cssQuery/src/cssQuery-level3.js -text diff --git a/buildscripts/chmbuilder/index.php b/buildscripts/chmbuilder/index.php new file mode 100644 index 00000000..4330e1a9 --- /dev/null +++ b/buildscripts/chmbuilder/index.php @@ -0,0 +1,7 @@ +run(); + + +?> \ No newline at end of file diff --git a/buildscripts/texbuilder/Page2Tex.php b/buildscripts/texbuilder/Page2Tex.php index 5d9a2b81..2374647c 100644 --- a/buildscripts/texbuilder/Page2Tex.php +++ b/buildscripts/texbuilder/Page2Tex.php @@ -4,6 +4,9 @@ class Page2Tex { private $_current_page; private static $header_count = 0; + private static $p_count=0; + private static $hil_count=0; + private $page_count=0; private $_base; private $_dir; @@ -270,29 +273,66 @@ class Page2Tex } - function set_header_id($content) + function set_header_id($content, $j) { + $this->page_count=$j; $content = preg_replace_callback('/

/', array($this,"h1"), $content); $content = preg_replace_callback('/

/', array($this,"h2"), $content); $content = preg_replace_callback('/

/', array($this,"h3"), $content); + $content = $this->set_block_content_id($content); return $content; } function h1($matches) { - return "

"; + $page = $this->page_count*1000; + return "

"; } function h2($matches) { - return "

"; + $page = $this->page_count*1000; + return "

"; } function h3($matches) { - return "

"; + $page = $this->page_count*1000; + return "

"; + } + + function set_block_content_id($content) + { + $content = preg_replace_callback('/

/', array($this, 'add_p'), $content); + $content = preg_replace_callback('/]+)>/', array($this, 'hil'), $content); + return $content; + } + + function hil($matches) + { + $id = ($this->page_count*10000) + (++self::$hil_count); + if(preg_match('/id="code-\d+"/i', $matches[1])) + { + $code = preg_replace('/id="code-(\d+)"/', 'id="code_$1"', $matches[0]); + //var_dump($code); + return $code; + } + else if(preg_match('/id="[^"]+"/i', $matches[1])) + { + return $matches[0]; + } + else + { + $changes = str_replace('"source"', '"source block-content" id="code-'.$id.'"', $matches[0]); + return $changes; + } } + function add_p($matches) + { + $page = $this->page_count*10000; + return "

"; + } } ?> diff --git a/buildscripts/texbuilder/quickstart/build.php b/buildscripts/texbuilder/quickstart/build.php index b5ee7841..2cee7fee 100644 --- a/buildscripts/texbuilder/quickstart/build.php +++ b/buildscripts/texbuilder/quickstart/build.php @@ -36,9 +36,9 @@ foreach($pages as $chapter => $sections) $current_path = $page; $parser->setCurrentPage($current_path); - //add id to

,

, <3> + //add id to

,

,

and

$tmp_content = $parser->set_header_id(file_get_contents($page),$j++); -// file_put_contents($page, $tmp_content); + file_put_contents($page, $tmp_content); $content .= $parser->get_section_label($section); $file_content = file_get_contents($page); diff --git a/demos/quickstart/protected/controls/Comments/CommentBlock.php b/demos/quickstart/protected/controls/Comments/CommentBlock.php new file mode 100644 index 00000000..63b25c72 --- /dev/null +++ b/demos/quickstart/protected/controls/Comments/CommentBlock.php @@ -0,0 +1,107 @@ +setDbConnection($db); + +class CommentRecord extends TActiveRecord +{ + public $id; + public $username; + public $date_added; + public $page; + public $block_id; + public $content; + + public static $_tablename='qs_comments'; + + public static function finder() + { + return self::getRecordFinder('CommentRecord'); + } +} + +class CommentBlock extends TTemplateControl +{ + private $_page; + + function onLoad($param) + { + if(!$this->Page->IsCallBack) + { + $count = array(); + $data = $this->getCommentData(); + foreach($data as $r) + { + if(!isset($count[$r->block_id])) + $count[$r->block_id]=0; + $count[$r->block_id]++; + } + $js = "var comment_count = ".TJavascript::encode($count).";\n"; + $this->Page->ClientScript->registerBeginScript('count',$js); + $this->comments->dataSource = $data; + $this->comments->dataBind(); + } + } + + function getCommentData() + { + return CommentRecord::finder()->findAllByPage($this->getCurrentPagePath()); + } + + function add_comment($sender, $param) + { + if(!$this->Page->IsValid) + return; + $record = new CommentRecord; + $record->username = $this->username->Text; + $record->date_added = date('Y-m-d h:i:s'); + $record->page = $this->getCurrentPagePath(); + $record->block_id = $this->block_id->Value; + $record->content = $this->content->Text; + $record->save(); + + $this->content->Text = ''; + $this->password->Text = ''; + $cc = $this->Page->CallbackClient; + $cc->appendContent('comment-list', $this->format_message($record)); + $cc->callClientFunction('hide_add_comment'); + $cc->callClientFunction('increment_count_tag', $record->block_id); + if(!$this->Page->IsCallBack) + { + $this->comments->dataSource = $this->getCommentData(); + $this->comments->dataBind(); + } + } + + protected function getCurrentPagePath() + { + if(is_null($this->_page)) + { + $page = str_replace($this->Service->BasePath, '', $this->Page->Template->TemplateFile); + $this->_page = str_replace('\\', '/', $page); + } + return $this->_page; + } + + function validate_credential($sender, $param) + { + $param->IsValid = $this->password->Text == 'Prado'; + } + + protected function format_message($record) + { + $username=htmlspecialchars($record->username); + $content=nl2br(htmlspecialchars($record->content)); + return << + {$username} on {$record->date_added}. +

{$content}
+ +EOD; + } +} \ No newline at end of file diff --git a/demos/quickstart/protected/controls/Comments/CommentBlock.tpl b/demos/quickstart/protected/controls/Comments/CommentBlock.tpl new file mode 100644 index 00000000..831938f2 --- /dev/null +++ b/demos/quickstart/protected/controls/Comments/CommentBlock.tpl @@ -0,0 +1,63 @@ + /> + +

User Comments

+
+ + + Top +
+ + + <%# $this->parent->parent->format_message($this->DataItem) %> + + +
+
+ +
+
+ + (must have 5 or more posts in forum) + +
+ / + + +
+
+
+ + +
+ + +
+ +
+ +
+
+
+ + + > + var hidden_block_id = '<%= $this->block_id->ClientID %>'; + var content_textare_id = '<%= $this->content->ClientID %>'; + diff --git a/demos/quickstart/protected/controls/Comments/comments.css b/demos/quickstart/protected/controls/Comments/comments.css new file mode 100644 index 00000000..fb03951f --- /dev/null +++ b/demos/quickstart/protected/controls/Comments/comments.css @@ -0,0 +1,226 @@ +body +{ + background-image: url(right_back.png); + background-position: right; + background-repeat: repeat-y; +} + +.languages +{ + margin-right: 80px !important; +} + +div#content +{ + padding-right: 75px; +} + +.block-content +{ + border-bottom: 1px dashed white; + border-top: 1px dashed white; + border-right: 1px solid white; + background-color: White; + position: relative; + z-index: 0; + display: block; +} + +div.block-content +{ + margin-top: 0 !important; +} + +.block-hover +{ + border-bottom: 1px dashed #0cf; + border-top: 1px dashed #0cf; + border-right-color: #0cf; + border-right-style: solid; + background-color: #F9FCFF; + padding-right: 9px; + margin-right: -9px; +} + +div.block-hover +{ + border-bottom: 1px dashed #0cf !important; + border-top: 1px dashed #0cf !important; + border-right-color: #0cf !important; + border-right-style: solid !important; + background-color: #F9FCFF !important; + padding-right: 9px !important; + margin-right: -9px !important; +} + +.block-comment-tag +{ + width: 51px; + float: right; + margin-right: -60px; + text-align: center; + color: #6495ED; + font-weight: bold; + cursor: pointer; +} + +.block-comment-tag-ie +{ + width: 60px; + float: right; + margin-right: -69px; + text-align: center; + color: #6495ED; + font-weight: bold; + cursor: pointer; +} + +.block-comment-tag div +{ + padding-top: 4px; + background-image: url(tag.gif); + background-repeat: no-repeat; + height: 26px; +} + +.block-comment-tag-ie div +{ + padding-top: 4px; + background-image: url(tag.gif); + background-repeat: no-repeat; + height: 26px; + background-position: 9px 0px; +} + +#user-comments +{ + border: 1px solid #B3CC8B; + padding: 10px; + background-color: #E5EDD7; +/* position: absolute; + margin-right: 80px; */ + z-index: 100; +} + +#comment-list, #add-comment +{ +/* height: 320px;*/ + background-color: White; + padding: 10px; + clear: both; + border-top: 10px solid white; + margin-top: -3px; +} + +#comment-list +{ +/* overflow: auto;*/ +} + +#comment-nav, #comment-nav li +{ + display: inline; + list-style: none; + margin: 0; + padding: 0; +} + +#comment-nav +{ + display: block; + height: 26px; +} + +#comment-nav li a +{ + float: left; + padding: 0.4em 1.5em; + color: #9BB190; + text-decoration: none; + font-weight: bold; + background-color: #ECF0EA; + margin-right: 5px; +} + +#comment-nav li a.active +{ + color: #556B2F; + background-color: White; +} + +#user-comments .right-tab +{ + text-decoration: none; + padding: 0.4em 1em; + float:right; + color: #556B2F; + background-color: White; + margin-top: -1.95em; +} + +#comment-list .comment +{ + margin-bottom: 2em; +} + +#comment-list .comment span +{ + font-size: 0.85em; + border-bottom: 1px dotted #ccc; + padding: 0.2em; + display: block; +} + +#comment-list .comment div +{ + + padding: 0.5em; +} + +#add-comment label +{ + font-weight: bold; +} +#add-comment .hint +{ + font-size: 0.8em; + font-weight: normal; +} + +#add-comment .username input +{ + width: 180px +} + +#add-comment .content +{ + margin-top: 0.5em; +} + +#add-comment .content textarea +{ + width: 95%; + height: 180px; +} + + +#add-comment .submit +{ + border-top: 1px solid #ccc; + margin-top: 1em; + padding: 1em; +} + +#add-comment .submit input +{ + width: 130px; +} + + +#modal-background +{ + background-color: #556B2F; + position: absolute; + z-index: 0; + filter: Alpha(Opacity=50); +} \ No newline at end of file diff --git a/demos/quickstart/protected/controls/Comments/comments.js b/demos/quickstart/protected/controls/Comments/comments.js new file mode 100644 index 00000000..4e0cdf67 --- /dev/null +++ b/demos/quickstart/protected/controls/Comments/comments.js @@ -0,0 +1,179 @@ +var currentCommentID; + +function show_comment_list() +{ + $('comment-list').show(); + $('add-comment').hide(); + $('show-comment-link').addClassName("active"); + $('add-comment-link').removeClassName("active"); +} + +function show_add_comment() +{ + $('comment-list').hide(); + $('add-comment').show(); + $('show-comment-link').removeClassName("active"); + $('add-comment-link').addClassName("active"); +} + +function hide_add_comment() +{ + $('user-comments').hide(); + $('modal-background').hide(); + $(content_textare_id).value = ''; + $(currentCommentID).style.zIndex = 0; +} + +function show_comments(block) +{ + var id = block.id + currentCommentID = id; + $(hidden_block_id).value = id; + var commentBlock = $('user-comments'); + var pos = Position.cumulativeOffset(block); + var top = pos[1] + block.offsetHeight; + commentBlock.style.top = top+"px"; + commentBlock.style.width = (block.offsetWidth-22)+"px"; + + commentBlock.show(); + var list = $('comment-list'); + var count=0; + for(var i=0, k=list.childNodes.length; i < k; i++) + { + var node = list.childNodes[i]; + if(node.nodeType == 1) //an element node + { + if(node.className.indexOf(id) >= 0) + { + node.style.display="block" + count++; + } + else + node.style.display="none"; + } + } + + list.show(); + if(count > 0) + show_comment_list(); + else + show_add_comment(); + + var background = $('modal-background'); + background.style.top="0px"; + background.style.left="0px"; + background.style.opacity="0.5"; + background.style.width = document.body.offsetWidth+"px"; + background.style.height = document.body.offsetHeight+"px"; + background.show(); + block.style.zIndex = 100; + block.style.paddingRight="9px"; + block.style.marginRight="-9px"; + +} + +function show_block(block) +{ + while(block && block.className.indexOf("block-content") < 0) + block = block.parentNode; + if(block && block.className.indexOf("block-content") >= 0) + { + block.addClassName('block-hover'); + var tag = $('tag-'+block.id); +// if(tag.className.indexOf("tag-shown")<=0) + tag.firstChild.style.visibility="visible" + } +} + +function hide_block(block) +{ + while(block && block.className.indexOf("block-hover") < 0) + block = block.parentNode; + if(block && block.className.indexOf("block-hover") >= 0) + { + block.removeClassName('block-hover'); + var tag = $('tag-'+block.id); + if(tag.className.indexOf("tag-shown")<=0) + tag.firstChild.style.visibility="hidden" + } +} + +function add_comment_tag(el) +{ + var dim = Element.getDimensions(el); + var comments = get_comment_count(el.id); + var style = "height:"+(dim.height > 35 ? dim.height : 35)+"px;"; + var cssClass = dim.height ? "block-comment-tag" : "block-comment-tag-ie"; + var title = "View "+comments+" comments" + var innerStyle=""; + if(comments <= 0) + { + innerStyle = " visibility:hidden;"; + comments = "add"; + title = "Add new comment"; + } + else + cssClass += " tag-shown"; + var id = "tag-"+el.id; + var tag = "
"+comments+"
 
"; + new Insertion.Before(el, tag); + var tag_div = $(id); + Event.observe(tag_div, "mouseover", function(e){ show_block(el); }); + Event.observe(tag_div, "mouseout", function(e){ hide_block(el); }); + Event.observe(tag_div, "click", function(e) { show_comments(el); Event.stop(e); }); +} + +function increment_count_tag(id) +{ + var tag = $('tag-'+id); + if(tag && tag.firstChild) + { + if(tag.className.indexOf("tag-shown") >= 0) + { + var count = Number(tag.firstChild.innerHTML); + tag.firstChild.innerHTML = (++count)+""; + tag.firstChild.style.visibility="visible"; + } + else + { + tag.firstChild.innerHTML = "1"; + tag.addClassName("tag-shown"); + tag.firstChild.style.visibility="visible"; + } + } +} + +function get_comment_count(id) +{ + return comment_count[id] ? comment_count[id] : 0; +} + +//initialize the comment js + +(function() +{ + var userComments = $('user-comments'); + userComments.style.position="absolute"; + userComments.style.marginRight="80px"; + var commentList = $('comment-list'); + commentList.style.height="320px"; + $('add-comment').style.height="320px"; + commentList.style.overflow="auto"; + $('show-comment-link').style.display=""; + $('to-top').hide(); + $('close-comments').show(); + userComments.hide(); + $('comments-header').hide(); + + $$('#content .block-content').each(function(el) + { + Event.observe(el, 'mouseover', function(e){ show_block(Event.element(e)); }); + Event.observe(el, 'mouseout', function(e){ hide_block(Event.element(e)); }); + add_comment_tag(el); + }); + + Event.observe($('show-comment-link'), "click", function(e) { show_comment_list(); Event.stop(e); }); + Event.observe($('add-comment-link'), "click", function(e) { show_add_comment(); Event.stop(e); }); + Event.observe($('close-comments'), "click", function(e) { hide_add_comment(); Event.stop(e); }); + +})(); diff --git a/demos/quickstart/protected/controls/Comments/right_back.png b/demos/quickstart/protected/controls/Comments/right_back.png new file mode 100644 index 00000000..d591e24e Binary files /dev/null and b/demos/quickstart/protected/controls/Comments/right_back.png differ diff --git a/demos/quickstart/protected/controls/Comments/right_tag.png b/demos/quickstart/protected/controls/Comments/right_tag.png new file mode 100644 index 00000000..20adda2f Binary files /dev/null and b/demos/quickstart/protected/controls/Comments/right_tag.png differ diff --git a/demos/quickstart/protected/controls/Comments/tag.gif b/demos/quickstart/protected/controls/Comments/tag.gif new file mode 100644 index 00000000..654b61de Binary files /dev/null and b/demos/quickstart/protected/controls/Comments/tag.gif differ diff --git a/demos/quickstart/protected/controls/Layout.tpl b/demos/quickstart/protected/controls/Layout.tpl index 87013156..5426a221 100644 --- a/demos/quickstart/protected/controls/Layout.tpl +++ b/demos/quickstart/protected/controls/Layout.tpl @@ -42,7 +42,9 @@
+

+
diff --git a/demos/quickstart/protected/pages/ActiveControls/ActiveButton.page b/demos/quickstart/protected/pages/ActiveControls/ActiveButton.page index adf50d22..c80c22dc 100644 --- a/demos/quickstart/protected/pages/ActiveControls/ActiveButton.page +++ b/demos/quickstart/protected/pages/ActiveControls/ActiveButton.page @@ -1,9 +1,9 @@ -

TActiveButton

+

TActiveButton

-

TActiveButton is the active control counter part to +

TActiveButton is the active control counter part to TButton. When a TActiveButton is clicked, rather than a normal post back request a callback request is initiated. The OnCallback event is raised @@ -11,29 +11,29 @@ during a callback request and it is raise after the OnClick event.

-

When the ActiveControl.EnableUpdate property is true, +

When the ActiveControl.EnableUpdate property is true, changing the Text property during a callback request will update the button's caption on the client-side.

-

Since the OnCallback event is raised only during a callback request, +

Since the OnCallback event is raised only during a callback request, the OnCallback event handler can be used to handle logic specifically related to callback requests. The OnClick event handler is raised when ever the button is clicked, even if javascript is disabled.

-

The following example the use of both the OnClick and OnCallback +

The following example the use of both the OnClick and OnCallback events of an TActiveButton.

-

TActiveButton Class Diagram

-

The class diagram for TActiveButton is illustrated in the figure below. +

TActiveButton Class Diagram

+

The class diagram for TActiveButton is illustrated in the figure below. Most active control that can perform callback request have a similar structure.

class="figure" alt="TActiveButton class diagram" title="TActiveButton class diagram" /> -

TActiveButton is an extension of TButton +

TActiveButton is an extension of TButton and implements two additional interfaces ICallbackEventHandler and IActiveControl. The TActiveButton contains an instance of TBaseActiveCallbackControl @@ -41,24 +41,24 @@ available through the ActiveControl property of TActiveButton. The following example set the callback parameter of the TActiveButton when a callback request is dispatched.

- + <com:TActiveButton Text="Click Me" OnCallback="button_callback" ActiveControl.CallbackParameter="value" /> -

In the OnCallback event handler method, the CallbackParameter +

In the OnCallback event handler method, the CallbackParameter is available in the $param object.

- + public function button_callback($sender, $param) { echo $param->CallbackParameter; //outputs "value" } -

Adding Client Side Behaviour

+

Adding Client Side Behaviour

-

With in the ActiveControl property is an instance of +

With in the ActiveControl property is an instance of TCallbackClientSide available as a property ClientSide of TActiveButton. The ClientSide property contains sub-properties, such as RequestTimeOut, @@ -68,7 +68,7 @@ The following example demonstrates the toggling of a "loading" indicator when the client-side is making a callback request.

- + <com:TClientSide PradoScripts="effects" /> Loading... @@ -82,7 +82,7 @@ when the client-side is making a callback request. </com:TActiveButton> -

The example loads the "effects" javascript library using the +

The example loads the "effects" javascript library using the TClientScript component. The ClientSide.OnLoading property value contains javascript statement that uses the "effects" library to show the "Loading..." diff --git a/demos/quickstart/protected/pages/ActiveControls/ActiveCheckBox.page b/demos/quickstart/protected/pages/ActiveControls/ActiveCheckBox.page index d66c48f5..5b34492a 100644 --- a/demos/quickstart/protected/pages/ActiveControls/ActiveCheckBox.page +++ b/demos/quickstart/protected/pages/ActiveControls/ActiveCheckBox.page @@ -1,9 +1,9 @@ -

TActiveCheckBox

+

TActiveCheckBox

-

+

TActiveCheckBox is the active control counter part to TCheckbox. The AutoPostBack property of TActiveCheckBox is set to true by default. @@ -11,7 +11,7 @@ OnCallback event is raise after the OnCheckedChanged event.

-

+

The Text and Checked properties of TActiveCheckBox can be changed during a callback request. The TextAlign property of TActiveCheckBox can not be changed during diff --git a/demos/quickstart/protected/pages/ActiveControls/ActiveCustomValidator.page b/demos/quickstart/protected/pages/ActiveControls/ActiveCustomValidator.page index f97ea40d..d723cbac 100644 --- a/demos/quickstart/protected/pages/ActiveControls/ActiveCustomValidator.page +++ b/demos/quickstart/protected/pages/ActiveControls/ActiveCustomValidator.page @@ -1,15 +1,15 @@ -

TActiveCustomValidator

+

TActiveCustomValidator

-

Performs custom validation using only server-side OnServerValidate +

Performs custom validation using only server-side OnServerValidate validation event. The client-side uses callbacks to raise onServerValidate event. The ClientValidationFunction property is disabled and will throw an exception if trying to set this property.

-

Beware that the onServerValidate may be +

Beware that the onServerValidate may be raised when the control to validate on the client side changes value, that is, the server validation may be called many times. diff --git a/demos/quickstart/protected/pages/ActiveControls/Home.page b/demos/quickstart/protected/pages/ActiveControls/Home.page index 5b8c40a2..289c7c1c 100644 --- a/demos/quickstart/protected/pages/ActiveControls/Home.page +++ b/demos/quickstart/protected/pages/ActiveControls/Home.page @@ -1,7 +1,7 @@ -

Active Controls (AJAX enabled Controls)

-

See the Introduction +

Active Controls (AJAX enabled Controls)

+

See the Introduction for a quick overview of the concept behind active controls (AJAX enabled controls). Most active controls have a property of ActiveControl and @@ -13,14 +13,14 @@ during a callback request. Active controls is reliant on a collection of javascript classes.

-

For a quick demo of active controls, try the +

For a quick demo of active controls, try the TActiveButton control. See also the later part of the Current Converter tutorial for a more indepth example.

-

* the tutorial for this control is not completed yet.

+

* the tutorial for this control is not completed yet.

-

Standard Active Controls

-
    +

    Standard Active Controls

    +
    • TActiveButton represents a click button on a Web page. It can be used to trigger a callback request. @@ -92,8 +92,8 @@ TActiveButton control. See also the later part of the Active List Controls

+