示例#1
0
define("bundles/teach-course/components/TeachBanner",["require","exports","module","jquery","react-with-addons","./TotalLearnerBanner","./WeeklyActiveLearnerBanner","./WeeklyNewLearnerBanner","bundles/phoenix/template/models/userIdentity","bundles/teach-course/lib/TeachBannerUtils","css!./__styles__/TeachBanner"],function(require,exports,module){function _defaults(e,a){for(var o=Object.getOwnPropertyNames(a),t=0;t<o.length;t++){var n=o[t],r=Object.getOwnPropertyDescriptor(a,n);r&&r.configurable&&void 0===e[n]&&Object.defineProperty(e,n,r)}return e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):_defaults(t,e))}var c=function(){function defineProperties(r,n){for(var t=0;t<n.length;t++){var e=n[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,e.key,e)}}return function(e,t,n){return t&&defineProperties(e.prototype,t),n&&defineProperties(e,n),e}}(),a=function get(o,c,l){var n=!0;e:for(;n;){var t=o,s=c,i=l;n=!1,null===t&&(t=Function.prototype);var e=Object.getOwnPropertyDescriptor(t,s);if(void 0===e){var r=Object.getPrototypeOf(t);if(null===r)return void 0;o=r,c=s,l=i,n=!0,e=r=void 0;continue e}if("value"in e)return e.value;var a=e.get;if(void 0===a)return void 0;return a.call(i)}},$=require("jquery"),e=require("react-with-addons"),r=require("./TotalLearnerBanner"),o=require("./WeeklyActiveLearnerBanner"),s=require("./WeeklyNewLearnerBanner"),i=require("bundles/phoenix/template/models/userIdentity"),t=require("bundles/teach-course/lib/TeachBannerUtils");require("css!./__styles__/TeachBanner");var n=[{key:"weeklyActiveLearner",component:o},{key:"weeklyNewLearner",component:s},{key:"totalLearner",component:r}],l=function(r){function TeachBanner(){var e=this;_classCallCheck(this,TeachBanner),a(Object.getPrototypeOf(TeachBanner.prototype),"constructor",this).apply(this,arguments),this.state={course:null,membership:null,learnerCounts:{},bannerIndex:-1,dismissed:!1},this.handleDismiss=function(){t.setVisitedTimestamp(),t.recordDismiss(e.getTrackingData()),e.setState({dismissed:!0})},this.handleClick=function(r){r.preventDefault(),r.stopPropagation();var n=$(r.target);n.is("a")||(n=n.closest("a"));var a=n.attr("href");t.recordLinkClick(e.getTrackingData(),function(){window.location.href=a})}}return _inherits(TeachBanner,r),c(TeachBanner,[{key:"componentDidMount",value:function componentDidMount(){var e=this;t.getBannerData().spread(function(r,a,o){var s=Math.round(Math.random()*(n.length-1));e.setState({course:a,membership:r,learnerCounts:o,bannerIndex:s},function(){t.recordShow(e.getTrackingData())})})["catch"](function(){}).done()}},{key:"getTrackingData",value:function getTrackingData(){var e=t.getVisitedTimestamp();return e=e?parseInt(e):0,{course_id:this.state.course.id,user_id:i.get("id"),user_role:this.state.membership.get("courseRole"),last_teach_access_timestamp:e,banner_type:n[this.state.bannerIndex].key}}},{key:"renderBanner",value:function renderBanner(){var t=n[this.state.bannerIndex].component;return e.createElement(t,{course:this.state.course,learnerCounts:this.state.learnerCounts,onClick:this.handleClick})}},{key:"render",value:function render(){if(!this.state.course||this.state.dismissed||!t.shouldShow())return e.createElement("div",null);return e.createElement("div",{className:"rc-TeachBanner bt3-alert bt3-alert-info bt3-alert-dismissable"},e.createElement("div",{className:"c-teach-banner-content"},e.createElement("button",{onClick:this.handleDismiss,className:"bt3-close","data-dismiss":"alert","aria-label":"Close"},e.createElement("span",{"aria-hidden":"true"},"×")),this.renderBanner()))}}]),TeachBanner}(e.Component);module.exports=l});
示例#2
0
define("bundles/teach-course/components/WeeklyNewLearnerBanner",["require","exports","module","react-with-addons","bundles/teach-course/lib/TeachBannerUtils","js/lib/coursera.react-intl"],function(require,exports,module){function _defaults(e,o){for(var a=Object.getOwnPropertyNames(o),r=0;r<a.length;r++){var t=a[r],n=Object.getOwnPropertyDescriptor(o,t);n&&n.configurable&&void 0===e[t]&&Object.defineProperty(e,t,n)}return e}function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _inherits(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(r,e):_defaults(r,e))}var r=function(){function defineProperties(n,t){for(var r=0;r<t.length;r++){var e=t[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(e,r,t){return r&&defineProperties(e.prototype,r),t&&defineProperties(e,t),e}}(),t=function get(a,u,l){var t=!0;e:for(;t;){var r=a,c=u,i=l;t=!1,null===r&&(r=Function.prototype);var e=Object.getOwnPropertyDescriptor(r,c);if(void 0===e){var n=Object.getPrototypeOf(r);if(null===n)return void 0;a=n,u=c,l=i,t=!0,e=n=void 0;continue e}if("value"in e)return e.value;var o=e.get;if(void 0===o)return void 0;return o.call(i)}},e=require("react-with-addons"),n=require("bundles/teach-course/lib/TeachBannerUtils"),o=require("js/lib/coursera.react-intl"),a=o.FormattedNumber,c=function(o){function WeeklyNewLearnerBanner(){_classCallCheck(this,WeeklyNewLearnerBanner),t(Object.getPrototypeOf(WeeklyNewLearnerBanner.prototype),"constructor",this).apply(this,arguments)}return _inherits(WeeklyNewLearnerBanner,o),r(WeeklyNewLearnerBanner,[{key:"render",value:function render(){var r=this.props.course,o=r.name,t="/teach/"+r.slug,c=n.getWeeklyNewLearnerCount(this.props.learnerCounts);return e.createElement("div",{className:"rc-WeeklyNewLearnerBanner"},e.createElement("a",{onClick:this.props.onClick,href:t},e.createElement("strong",{className:"c-teach-banner-learner-count"},e.createElement(a,{value:c})," learners"))," enrolled in ",e.createElement("span",{className:"c-teach-banner-course-name"},o)," in the past week. View more on the ",e.createElement("a",{onClick:this.props.onClick,href:t},e.createElement("strong",null,"Course Dashboard.")))}}],[{key:"propTypes",value:{course:e.PropTypes.object.isRequired,learnerCounts:e.PropTypes.object.isRequired,onClick:e.PropTypes.func.isRequired},enumerable:!0}]),WeeklyNewLearnerBanner}(e.Component);module.exports=c});