From 4cc218b03a95a42440e473207e41f8c09b0ebcea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Tue, 9 Feb 2016 02:24:20 +0800 Subject: [PATCH] UserComment subscription --- botanjs/src/Astro/Blog/Components/Comment.js | 12 ++-- .../src/Astro/Blog/Components/Entry/Blog.css | 4 -- .../src/Astro/Blog/Components/Notification.js | 18 ++--- .../Components/ToggleButton/CommentToggle.css | 6 +- .../Components/ToggleButton/CommentToggle.js | 71 ++++++++++++++----- .../Blog/Components/ToggleButton/_this.css | 11 +-- .../Blog/Components/ToggleButton/_this.js | 19 ++--- botanjs/src/externs/_AstJson_.AJaxGetNotis.js | 2 +- 8 files changed, 93 insertions(+), 50 deletions(-) diff --git a/botanjs/src/Astro/Blog/Components/Comment.js b/botanjs/src/Astro/Blog/Components/Comment.js index bb7b642..cc1bd1e 100644 --- a/botanjs/src/Astro/Blog/Components/Comment.js +++ b/botanjs/src/Astro/Blog/Components/Comment.js @@ -516,10 +516,14 @@ { // Remove capcha new IDOMElement().lootChildren( Dand.id( "recaptcha_field" ) ); - Recaptcha.render( "recaptcha_field", { - "theme": "light" - , "sitekey": Config.siteKey - } ); + try + { + Recaptcha.render( "recaptcha_field", { + "theme": "light" + , "sitekey": Config.siteKey + } ); + } + catch( ex ) { } openCaptcha(); } diff --git a/botanjs/src/Astro/Blog/Components/Entry/Blog.css b/botanjs/src/Astro/Blog/Components/Entry/Blog.css index addcd5b..aad0417 100644 --- a/botanjs/src/Astro/Blog/Components/Entry/Blog.css +++ b/botanjs/src/Astro/Blog/Components/Entry/Blog.css @@ -47,10 +47,6 @@ .b_bodyWrapper a { color: #f15a24; } -.b_notify { background-color: slategrey; } -.b_notify:before { content: 'Follow'; } -.b_notify:after { content: 'Unfollow'; } - .b_edit { background-color: yellowgreen; } diff --git a/botanjs/src/Astro/Blog/Components/Notification.js b/botanjs/src/Astro/Blog/Components/Notification.js index e9fe2c8..2849707 100644 --- a/botanjs/src/Astro/Blog/Components/Notification.js +++ b/botanjs/src/Astro/Blog/Components/Notification.js @@ -98,16 +98,17 @@ for( var i in e.data ) { + var data = e.data[i]; var li , li_s = [ // On/off toggle Dand.wrap( "span", null, "nt_switch" ) - , Dand.wrap( "span", null, "nt_tname", e.data[i].name ) + , Dand.wrap( "span", null, "nt_tname", data.name ) ] - , keys = [ new DataKey( "tid", i ) ] + , keys = [ new DataKey( "tid", data.type ) ] ; - if( e.data[i].hasOwnProperty("count") ) + if( data.hasOwnProperty("count") ) { // type count li_s[2] = Dand.wrap( @@ -115,7 +116,7 @@ , null , "nt_tcount" , e.data[i].count + "" - , new DataKey( "count", e.data[i].count ) + , new DataKey( "count", data.count ) ); // Active keys[ keys.length ] = new IKey( "active", 1 ); @@ -152,6 +153,7 @@ var createContextMenu = function(e) { var items = [], menuShow = false; + var hasNotis = 0 < e.data.length; for( var n in e.data ) { @@ -159,7 +161,7 @@ var data = e.data[n]; // Create items items[ items.length ] = new IKey( - data.message + data.mesg , new EventKey( "m_" + data.id , readNotification.bind( data ) @@ -177,10 +179,10 @@ // showMenu/hideMenu overrides style settings , { "class": "nt_container" - , "showMenu": function(stage, event) + , "showMenu": function( stage, event ) { if( stage.className == "nt_date" ) return; - if( menuShow ) return; + if( !hasNotis || menuShow ) return; bodyStyle.marginLeft = "1em"; bodyStyle.marginRight = "-1em"; bodyStyle.opacity = 0; @@ -194,7 +196,7 @@ menuShow = true; }); } - , "hideMenu": function(stage) + , "hideMenu": function( stage ) { if( stage.className == "nt_date" ) return; if( !menuShow ) return; diff --git a/botanjs/src/Astro/Blog/Components/ToggleButton/CommentToggle.css b/botanjs/src/Astro/Blog/Components/ToggleButton/CommentToggle.css index 1cfd940..e0115c1 100644 --- a/botanjs/src/Astro/Blog/Components/ToggleButton/CommentToggle.css +++ b/botanjs/src/Astro/Blog/Components/ToggleButton/CommentToggle.css @@ -1,3 +1,7 @@ +.b_notify { background-color: #222 !important; } +.b_notify:before { content: 'Mute'; } +.b_notify:after { content: 'Notify'; } + .uc_ntoggle { font-family: custom-sans; vertical-align: top; @@ -36,7 +40,7 @@ .cr_ntoggle:before { content: '..'; - background-color: slategrey; + background-color: orange; } .cr_ntoggle:after { content: '!'; } diff --git a/botanjs/src/Astro/Blog/Components/ToggleButton/CommentToggle.js b/botanjs/src/Astro/Blog/Components/ToggleButton/CommentToggle.js index 4c549a3..4113a63 100644 --- a/botanjs/src/Astro/Blog/Components/ToggleButton/CommentToggle.js +++ b/botanjs/src/Astro/Blog/Components/ToggleButton/CommentToggle.js @@ -1,27 +1,60 @@ -/* (function(){ var ns = __namespace( "Astro.Blog.Components.ToggleButton.CommentToggle" ); - new ToggleButton('toggle_follow', nProcessor, { - enable: { action: 'enable', tid: 3, cid: 1 }, - disable: { action: 'disable', tid: 3, cid: 1 } - }); + var ToggleButton = __import( "Astro.Blog.Components.ToggleButton" ); - new ToggleButton('uc_ntoggle', nProcessor, { - enable: { action: 'enable', tid: 1, cid: 1645 }, - disable: { action: 'disable', tid: 1, cid: 1645 } - }); + /** @type {Dandelion} */ + var Dand = __import( "Dandelion" ); + /** @type {Dandelion.IDOMElement} */ + var IDOMElement = __import( "Dandelion.IDOMElement" ); + /** @type {Astro.Bootstrap} */ + var Bootstrap = __import( "Astro.Bootstrap" ); + /** @type {Astro.Blog.Config} */ + var Conf = __import( "Astro.Blog.Config" ); - new ToggleButton('toggle_publish', '../../../user/ajax-set_article', { - enable: { draft: 0, article_id: 1645 }, - disable: { draft: 1, article_id: 1645 } - }); + /** @type {_AstConf_.CommentToggle} */ + var settings = Conf.get( "CommentToggle" ); - for(var i in commList) { - new ToggleButton('cr_ntoggle_' + commList[i], nProcessor, { - enable: { action: 'enable', tid: 2, cid: commList[i] }, - disable: { action: 'disable', tid: 2, cid: commList[i] } - }); + var CommentToggle = function( id, processor, object ) + { + ToggleButton.call( this, id, processor, object ); + }; + __extends( CommentToggle, ToggleButton ); + + var init = function() + { + for( var i in settings ) + { + var button = settings[i]; + new CommentToggle( button[0], button[1], button[2] ); + } + + /* + new ToggleButton("toggle_follow", "/ajax/get-notis", { + "enable": { "action": "enable", "tid": 4, "cid": aid }, + "disable": { "action": "disable", "tid": 4, "cid": aid } + }); + */ + + /* + new ToggleButton("uc_ntoggle", nProcessor, { + enable: { action: "enable", tid: 1, cid: 1645 }, + disable: { action: "disable", tid: 1, cid: 1645 } + }); + + new ToggleButton("toggle_publish", "../../../user/ajax-set_article", { + enable: { draft: 0, article_id: 1645 }, + disable: { draft: 1, article_id: 1645 } + }); + + for(var i in commList) { + new ToggleButton("cr_ntoggle_" + commList[i], nProcessor, { + enable: { action: "enable", tid: 2, cid: commList[i] }, + disable: { action: "disable", tid: 2, cid: commList[i] } + }); + */ + } + + Bootstrap.regInit( init ); })(); -//*/ diff --git a/botanjs/src/Astro/Blog/Components/ToggleButton/_this.css b/botanjs/src/Astro/Blog/Components/ToggleButton/_this.css index 93265de..c084e6e 100644 --- a/botanjs/src/Astro/Blog/Components/ToggleButton/_this.css +++ b/botanjs/src/Astro/Blog/Components/ToggleButton/_this.css @@ -7,13 +7,15 @@ padding: 0.2em 0.5em; margin: 0.5em 0.2em; - background-color: grey; + background-color: #222; color: white; cursor: default; overflow: hidden; display: inline-block; + + opacity: 0.8; } .btn_toggle > .btn_space { @@ -22,6 +24,7 @@ } .btn_toggle:hover { + opacity: 1; text-decoration: none; } @@ -62,7 +65,7 @@ .btn_toggle:after { content: ''; - background-color: royalblue; + background-color: #4169E1; top: 100%; -webkit-transition: all 750ms cubic-bezier(0.215, 0.610, 0.355, 1.000); @@ -72,11 +75,11 @@ transition: all 500ms cubic-bezier(0.215, 0.610, 0.355, 1.000); /* easeOutCubic */ } -.btn_toggle[active="1"]:after { +.btn_toggle[data-active="1"]:after { top: 0%; } -.btn_toggle[active="1"]:before { +.btn_toggle[data-active="1"]:before { top: -100%; } diff --git a/botanjs/src/Astro/Blog/Components/ToggleButton/_this.js b/botanjs/src/Astro/Blog/Components/ToggleButton/_this.js index a7efe98..5b3b5d8 100644 --- a/botanjs/src/Astro/Blog/Components/ToggleButton/_this.js +++ b/botanjs/src/Astro/Blog/Components/ToggleButton/_this.js @@ -9,37 +9,38 @@ var Bootstrap = __import( "Astro.Bootstrap" ); /** @type {Astro.Blog} */ var config = __import( "Astro.Blog.Config" ); + /** @type {System.utils.DataKey} */ + var DataKey = __import( "System.utils.DataKey" ); var postData = __import( "System.Net.postData" ); var ToggleButton = function ( elem, processor, obj ) { - var stage = Dand.id( elem ); + var stage = Dand.id( elem, true ); if( !stage ) return; var n_toggle = function (args) { - if( stage.getAttribute("active") == 1 ) + if( stage.getDAttribute("active") == 1 ) { - stage.removeAttribute('active'); + stage.setAttribute( new DataKey( "active", 0 ) ); } else { - stage.setAttribute('active', 1); + stage.setAttribute( new DataKey( "active", 1 ) ); } }; var nError = function (args) { - } - ; + }; - IDOMElement(stage).addEventListener( - 'Click' + stage.addEventListener( + "Click" , function (e) { - var _action = stage.getAttribute( "active" ) == 1 + var _action = stage.getDAttribute( "active" ) == 1 ? obj[ "disable" ] : obj[ "enable" ] ; diff --git a/botanjs/src/externs/_AstJson_.AJaxGetNotis.js b/botanjs/src/externs/_AstJson_.AJaxGetNotis.js index 6bf649f..d64ac3b 100644 --- a/botanjs/src/externs/_AstJson_.AJaxGetNotis.js +++ b/botanjs/src/externs/_AstJson_.AJaxGetNotis.js @@ -1,7 +1,7 @@ /** @type {Object} */ _AstJson_.AJaxGetNotis = {}; /** @type {String} */ -_AstJson_.AJaxGetNotis.message; +_AstJson_.AJaxGetNotis.mesg; /** @type {String} */ _AstJson_.AJaxGetNotis.id; /** @type {String} */