unserver-unify
Version:
76 lines (75 loc) • 2.82 kB
JavaScript
'use strict';
angular.module('bamboo.course').controller('CouserHeaderCtrl', function($scope, $stateParams, CourseApi, CommonService, $timeout, ApiService, $state, $rootScope) {
$rootScope.fullwidthflag = true;
$rootScope.hideHeader = true;
$rootScope.fullwidth = true;
$scope.id = this.id = $stateParams.id;
this.cid = $stateParams.cid;
this.courseid = $stateParams.cid;
this.cs = $stateParams.cs;
var _cs = ApiService.getCheckSum($stateParams.cid);
/* if(this.cs!=_cs){
return CommonService.showError('Invalid Access!');
}*/
var _self = this;
// console.log(_self.id);
ApiService.get('/mvsubjectbrief/' + _self.id).then(function(result) {
// console.log(result);
if (result.data.success) {
_self.mvsubject = result.data.data;
// console.log(_self.mvsubject);
var _states = $state.current.name.split('.');
$scope.tab = _states[_states.length - 1];
if((!_self.mvsubject.contents||_self.mvsubject.contents.length==0)&&(!_self.mvsubject.pages||_self.mvsubject.pages.length==0)){
_self.goto('index.courses.course.section.discuss',_self.id,'discuss');
} else if(!_self.mvsubject.contents||_self.mvsubject.contents.length==0) {
_self.goto('index.courses.course.section.wikiware',_self.id,'wikiware');
}
}
});
// CourseApi.getInfo(_self.id, function(result) {
// _self.mvsubject = result;
// console.log(_self.mvsubject);
// var _states=$state.current.name.split('.');
// $scope.tab=_states[_states.length-1];
// });
ApiService.get('/course/' + _self.cid).then(function(result) {
if (result.data.success) {
_self.course = result.data.data;
// console.log(_self.course);
}
});
var time = new Date();
console.log("-- init ---", time);
this.goto = function(state, id, tab) {
// console.log(_self.id);
// console.log(_self.mvsubject);
console.log("--- goto ---", state);
$state.go(state);
$scope.tab = tab;
}
function destroy() {
$rootScope.$broadcast('header:showfullheader');
console.log('--header destory-- 2');
$rootScope.fullwidthflag = false;
$rootScope.hideHeader = false;
$rootScope.fullwidth = false;
}
$rootScope.$broadcast('header:hidefullheader');
this.contentReady = false;
$timeout(function() {
console.log("-- hide full header --");
$rootScope.fullwidthflag = true;
$rootScope.hideHeader = true;
$rootScope.fullwidth = true;
$rootScope.$broadcast('header:hidefullheader');
_self.contentReady = true;
}, 300);
$scope.$on("$destroy", function() {
console.log('destory-- 1', time);
destroy();
});
this.toggleHeader = function() {
$rootScope.hideHeader = !$rootScope.hideHeader;
}
});