123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406 |
- $(function(){
- /*弹层自适应宽高*/
- $('.layer').width($(window).width());
- $('.layer').height($(window).height());
- $(window).resize(function() {
- $('.layer').width($(window).width());
- $('.layer').height($(window).height());
- });
- $("body").delegate(".layer .close","click",function(){
- $(this).closest(".layer").fadeOut(400);
- })
- /*展开关闭菜单栏*/
- $("body").delegate(".product-menu dt","click",function(){
- $(this).toggleClass("on");
- $(this).siblings("dd").slideToggle();
- });
- //班级全选
- $("body").delegate(".chk-class-all","click",function(){
- $(this).closest("dt").siblings("dd").find(".chk-class input").prop("checked",$(this).children("input").prop("checked"))
- chkGradeAll()
- });
- function chkGradeAll(){
- var count = 0;
- for(var i=0;i<$(".add-class-box").find("dt input").length;i++){
- if($(".add-class-box").find("dt input").eq(i).prop("checked") == true){
- count++;
- }
- }
- if(count == $(".add-class-box").find("dt input").length){
- $(".chk-grade-all").find("input").prop("checked",true);
- }else{
- $(".chk-grade-all").find("input").prop("checked",false);
- }
- }
- //班级反选
- $("body").delegate(".chk-class","click",function(){
- var count = 0;
- for(var i=0;i<$(this).closest("dd").find("input").length;i++){
- if($(this).closest("dd").find("input").eq(i).prop("checked") == true){
- count++;
- }
- }
- if(count == $(this).closest("dd").find("input").length){
- $(this).closest("dd").siblings("dt").find("input").prop("checked",true);
- }else{
- $(this).closest("dd").siblings("dt").find("input").prop("checked",false);
- }
- chkGradeAll()
- });
- $("body").delegate(".chk-grade-all","click",function(){
- $(".add-class-box").find("input").prop("checked",$(this).children("input").prop("checked"));
- });
- /*版本选择*/
- // $("body").delegate(".product-menu dd","click",function(){
- // var _this = $(this);
- // read(_this.attr('id'),_this)
- //
- // });
- (function(){
- /*添加版本弹层*/
- var _this = null;
- $(".add-version,.rename-version").click(function(){
- $(".new-name input").val("");
- _this = $(this);
- if($(this).is(".add-version")){
- $(".layer-rename").find(".layer-title").html('新增版本<em class="fr close">×</em>');
- }else if($(this).is(".rename-version")){
- $(".layer-rename").find(".layer-title").html('重命名版本<em class="fr close">×</em>');
- }
- $(".layer-rename").fadeIn(400).find("input").focus();
- })
- /*确定重命名并关闭弹层*/
- $(".layer-rename .ok").click(function(){
- $(this).attr('disabled');
- var name = $(".new-name input").val();
- var subject=$('.add_subject').val();
- if($.trim(name)==''){
- layer.alert('名称不能为空', {icon: 5});
- $('.layer-rename .ok').removeAttr('disabled');
- return false;
- }
- if($.trim(name).length>10){
- layer.alert('名称长度不能超过10', {icon: 5});
- $('.layer-rename .ok').removeAttr('disabled');
- return false;
- }
- if(_this.is(".add-version")){
- //新增
- $.ajax({
- type : 'post',
- url : '/index.php/productset/add',
- data :{psType:tempObj.attr('ps-type'),name:name,subject:subject},
- dataType : 'json',
- success : function (data) {
- $('.layer-rename .ok').removeAttr('disabled');
- if(data.status=='1'){
- $('.layer-rename .ok').closest(".layer").fadeOut();
- layer.alert("新增成功", {icon: 6},function () {
- location.href = '/index.php/productset/index?psId='+data.info;
- });
- }else{
- layer.alert(data.info, {icon: 5});
- }
- },
- error : function () {
- $('.layer-rename .ok').removeAttr('disabled');
- }
- });
- }else if(_this.is(".rename-version")){
- //重命名
- $.ajax({
- type : 'post',
- url : '/index.php/productset/rename',
- data :{psType:tempObj.attr('ps-id'),name:name},
- dataType : 'json',
- success : function (data) {
- $('.layer-rename .ok').removeAttr('disabled');
- if(data.status=='1'){
- $('.layer-rename .ok').closest(".layer").fadeOut();
- tempObj.html(name);
- }else{
- layer.alert(data.info, {icon: 5});
- }
- },
- error : function () {
- $('.layer-rename .ok').removeAttr('disabled');
- }
- });
- }
- })
- })();
- /*删除版本弹层*/
- $(".delete-version").click(function(){
- /*二选其一*/
- layer.msg("确定删除吗", {
- time: 0,
- btn: ['确定', '取消'],
- yes: function(index){
- layer.close(index);
- $.ajax({
- type : 'post',
- url : '/index.php/productset/del',
- data :{psType:tempObj.attr('ps-id')},
- dataType : 'json',
- beforeSend : function () {
- loading("正在删除");
- },
- success : function (data) {
- removeLoading();
- if(data.status=='1'){
- layer.alert("删除成功", {icon: 6},function () {
- location.href = "/index.php/productset";
- });
- }else if(data.status=='2'){
- $(".layer-delete").fadeIn(400);//不能删除显示弹层
- }else{
- layer.alert("删除失败", {icon: 5});
- }
- },
- error: function () {
- removeLoading();
- }
- });
- }
- });
- })
- /*鼠标右键事件*/
- $(document).delegate(".product-menu",'contextmenu', function (e) {
- e.preventDefault();
- });
- //给选择器obj绑定右键事件
- var tempObj = null;
- $(document).delegate(".product-menu dt",'mousedown', function (e) {
- if (e.which == 3 && $(e.target).is("dt")) {
- sTop=$(window).scrollTop();
- $(".product-edit").css({
- "position":"fixed",
- "left":e.pageX+10,
- "top":e.pageY+6-sTop
- });
- tempObj = $(e.target);
- $('.add-version').show();
- $('.delete-version').hide();
- $('.rename-version').hide();
- $(".product-edit").show();
- }
- });
- $(document).delegate(".product-menu a",'mousedown', function (e) {
- if (e.which == 3 && $(e.target).is("a")) {
- sTop=$(window).scrollTop();
- $(".product-edit").css({
- "position":"fixed",
- "left":e.pageX+10,
- "top":e.pageY+6-sTop
- });
- tempObj = $(e.target);
- $('.add-version').hide();
- if($(this).attr('is-default')=='1'){
- $('.delete-version').hide();
- }else{
- $('.delete-version').show();
- }
- $('.rename-version').show();
- $(".product-edit").show();
- }
- });
- /*关闭右键菜单*/
- $("body").click(function(e){
- $(".product-edit").hide();
- })
- /*设置内容*/
- $("body").delegate(".show-btn","click",function(){
- var idx = $(this).closest(".show-content").attr('index-id');
- if($(this).find("span").hasClass("on")){
- $(this).parent().find("input").val(0);
- $(this).find("span").removeClass("on").addClass("off");
- if(idx==11){
- $('#showTz input[value="1"]').removeAttr('disabled');
- $('#showTz input[value="2"]').removeAttr('disabled');
- $('#showTz input[value="1"]').prop("checked",true);
- $('#showTz input[value="2"]').prop("checked",true);
- $('#showJs input[value="1"]').removeAttr('disabled');
- $('#showJs input[value="2"]').removeAttr('disabled');
- $('#showJs input[value="1"]').prop("checked",false);
- $('#showJs input[value="2"]').prop("checked",false);
- }
- }else{
- $(this).parent().find("input").val(1);
- $(this).find("span").removeClass("off").addClass("on");
- if(idx==11){
- $('#showTz input[value="1"]').attr('disabled',true).prop("checked",false);
- $('#showTz input[value="2"]').attr('disabled',true).prop("checked",false);
- $('#showJs input[value="1"]').attr('disabled',true).prop("checked",false);
- $('#showJs input[value="2"]').attr('disabled',true).prop("checked",false);
- }
- }
- preview($(this))
- });
- //版本选择
- $('input[name="show_level"]').change(function () {
- var value = $(this).val();
- if(value == 1){
- $(".level-rule").show();
- }else{
- $(".level-rule").hide();
- }
- if(value == 2){
- $("#showTopKps").show();
- }else{
- $("#showTopKps").hide();
- }
- if(value == 0 || value == 1){
- $("#showTz").show();
- $("#wrongNum").show();
- $("#showJs").show();
- }else{
- $("#showTz").hide();
- $("#wrongNum").hide();
- $("#showJs").hide();
- }
- });
- //选择题组训练个性化学习宝学生层次
- $('input[name^="show_top"]').change(function () {
- var bool = $(this).prop("checked");
- var obj = $(this).parents('label').siblings('label').children('input');
- if(bool){
- obj.attr('disabled',false);
- }else{
- obj.attr('disabled',true);
- }
- });
- /*预览显示内容*/
- function preview(obj){
- obj.closest(".product-setting").find(".show-content").each(function(index,ele){
- var index_img = '.img-'+$(this).attr('index-id');
- if($(this).find(".show-btn span").hasClass("on")){
- $(this).closest(".product-setting").find(index_img).show();
- }else{
- $(this).closest(".product-setting").find(index_img).hide();
- }
- });
- }
- /*删除班级*/
- $("body").delegate(".class-name em","click",function(){
- var classId = $(this).attr('class-id');
- layer.msg("确定删除吗", {
- time: 0,
- btn: ['确定', '取消'],
- yes: function(index){
- layer.close(index);
- $.ajax({
- type : 'post',
- url : '/index.php/productset/delClass',
- data :{classId:classId,psId:$('input[name="ps_id"]').val(),psType:$('#ps_type').val()},
- dataType : 'json',
- beforeSend : function () {
- loading("正在删除");
- },
- success : function (data) {
- if(data.status=='1'){
- location.reload()
- }else{
- removeLoading();
- layer.alert('删除失败', {icon: 5});
- }
- },
- error : function () {
- removeLoading();
- layer.alert("删除失败", {icon: 5});
- }
- });
- }
- });
- });
- $(".show-content em").click(function(){
- $(".product-preview").hide().children("div").hide();
- $(".product-preview").show().animate({
- "width":"157%",
- "padding":"0 10px"
- },300);
- if($('#ps_type').val()=='2' || $('#ps_type').val()=='3'){
- if($(this).attr('index-id')=='7'){
- $(".show-7-2").show();
- }else{
- $(".show-"+$(this).attr('index-id')).show();
- }
- }else{
- $(".show-"+$(this).attr('index-id')).show();
- }
- })
- $(".close-tab").click(function(){
- $(this).closest(".product-preview").animate({
- "width":"0",
- "padding":"0"
- },300)
- // $(this).closest(".product-preview").hide();
- })
- /*预览*/
- $(".preview").click(function(){
- $(this).closest(".product-setting").find(".product-preview").animate({
- "width":"157%",
- "padding":"0 10px"
- },300).children("div").hide();
- // $(this).closest(".product-setting").find(".product-preview").show()
- preview($(this))
- $(this).closest(".product-setting").find(".all-preview").show();
- })
- /*添加班级*/
- $(".add-class").click(function(){
- var obj = $("#class-form .chk-class");
- if(obj.length<=0){
- layer.alert('暂无可选的班级', {icon: 6});
- }else{
- $(".class-box").hide();
- $(".add-class-box").slideDown(400);
- $(".chk-grade-all").show();
- }
- })
- $(".grade-btn a.cancel").click(function(){
- $(".class-box").slideDown(400);
- $(".add-class-box").hide();
- $(".chk-grade-all").hide();
- $(".chk-grade-all").find("input").prop("checked",false);
- $(".add-class-box").find("input").prop("checked",false);
- })
- function loading(words) {
- $(".loading").show().find("p").html(words)
- }
- function removeLoading(){
- $(".loading").hide()
- }
- })
|