123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var current_fs, next_fs, previous_fs; //fieldsets
- var left, opacity, scale; //fieldset properties which we will animate
- var animating; //flag to prevent quick multi-click glitches
- //设置弹窗宽高
- Fast.config.openArea = ['80%', '80%'];
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'cms/manuscript/index' + location.search,
- add_url: '',
- edit_url: 'cms/manuscript/edit',
- del_url: 'cms/manuscript/del',
- email_url: 'cms/manuscript/email',
- multi_url: 'cms/manuscript/multi',
- table: 'cms_manuscript',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- fixedColumns: true,
- fixedRightNumber: 1,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'user.nickname', title: __('User_id'), operate: 'like'},
- {field: 'title', title: __('Title'), operate: 'like'},
- {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
- {field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
- {field: 'status', title: __('Status'), searchList: Config.site_manuscript_status , formatter: Table.api.formatter.status},
- {
- field: 'operate',
- title: __('Operate'),
- clickToSelect: false,
- table: table,
- events: Table.api.events.operate,
- formatter: function (value, row, index) {
- var that = $.extend({}, this);
- var table = $(this.table).clone(true);
- that.table = table;
- return Table.api.formatter.operate.call(that, value, row, index);
- },
- buttons:[
- {
- name: 'email',
- title: __('Send email'),
- text: __('Send email'),
- classname: 'btn btn-xs btn-info btn-dialog',
- icon: 'fa fa-envelope',
- url: $.fn.bootstrapTable.defaults.extend.email_url,
- },
- {
- name: 'editor',
- classname: 'btn btn-xs btn-primary btn-dialog',
- icon: 'fa fa-user-circle-o',
- title: __('Assign chief'),
- text: __('Assign chief'),
- url: function (row) {
- return 'cms/manuscript/edit_chief?ids=' + row.id;
- },
- callback: function (data) {
- Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- },
- },
- {
- name: 'comments',
- classname: 'btn btn-xs btn-warning btn-dialog',
- icon: 'fa fa-list',
- title: __('Manuscript comments'),
- text: __('Manuscript comments'),
- url: function (row) {
- return 'cms/manuscript/comments?ids=' + row.id;
- },
- callback: function (data) {
- Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
- },
- }
- ]
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- var validName = false;
- //绑定表单事件
- Form.api.bindevent($("form[role=form]"));
- //验证触发
- $("form[role=form]").on('validation', function(e, content){
- var form = this;
- // form 中是否所有字段都验证通过
- if (content.id == 'name') {
- validName = content.isValid;
- }
- });
- var step = 1;
- $(".next").click(function() {
- if(animating) return false;
- animating = true;
- current_fs = $(this).parent().parent();
- next_fs = $(this).parent().parent().next();
- //activate next step on progressbar using the index of next_fs
- $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
- step += 1;
- //show the next fieldset
- next_fs.show();
- //hide the current fieldset with style
- current_fs.animate({opacity: 0}, {
- step: function(now, mx) {
- //as the opacity of current_fs reduces to 0 - stored in "now"
- //1. scale current_fs down to 80%
- scale = 1 - (1 - now) * 0.2;
- //2. bring next_fs from the right(50%)
- left = (now * 50)+"%";
- //3. increase opacity of next_fs to 1 as it moves in
- opacity = 1 - now;
- current_fs.css({
- 'transform': 'scale('+scale+')',
- 'position': 'absolute'
- });
- next_fs.css({'left': left, 'opacity': opacity});
- },
- duration: 800,
- complete: function(){
- current_fs.hide();
- animating = false;
- },
- //this comes from the custom easing plugin
- //easing: 'easeInOutBack'
- });
- });
- $(".previous").click(function() {
- if(animating) return false;
- animating = true;
- current_fs = $(this).parent().parent();
- previous_fs = $(this).parent().parent().prev();
- //de-activate current step on progressbar
- $("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
- step -= 1;
- //show the previous fieldset
- previous_fs.show();
- //hide the current fieldset with style
- current_fs.animate({opacity: 0}, {
- step: function(now, mx) {
- //as the opacity of current_fs reduces to 0 - stored in "now"
- //1. scale previous_fs from 80% to 100%
- scale = 0.8 + (1 - now) * 0.2;
- //2. take current_fs to the right(50%) - from 0%
- left = ((1-now) * 50)+"%";
- //3. increase opacity of previous_fs to 1 as it moves in
- opacity = 1 - now;
- current_fs.css({'left': left});
- previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
- },
- duration: 800,
- complete: function(){
- current_fs.hide();
- animating = false;
- },
- //this comes from the custom easing plugin
- //easing: 'easeInOutBack'
- });
- });
- Controller.api.bindevent();
- },
- edit: function () {
- var validName = false;
- //绑定表单事件
- Form.api.bindevent($("form[role=form]"));
- //验证触发
- $("form[role=form]").on('validation', function(e, content){
- var form = this;
- // form 中是否所有字段都验证通过
- if (content.id == 'name') {
- validName = content.isValid;
- }
- });
- var step = 1;
- $(".next").click(function() {
- if(animating) return false;
- animating = true;
- current_fs = $(this).parent().parent();
- next_fs = $(this).parent().parent().next();
- //activate next step on progressbar using the index of next_fs
- $("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
- step += 1;
- //show the next fieldset
- next_fs.show();
- //hide the current fieldset with style
- current_fs.animate({opacity: 0}, {
- step: function(now, mx) {
- //as the opacity of current_fs reduces to 0 - stored in "now"
- //1. scale current_fs down to 80%
- scale = 1 - (1 - now) * 0.2;
- //2. bring next_fs from the right(50%)
- left = (now * 50)+"%";
- //3. increase opacity of next_fs to 1 as it moves in
- opacity = 1 - now;
- current_fs.css({
- 'transform': 'scale('+scale+')',
- 'position': 'absolute'
- });
- next_fs.css({'left': left, 'opacity': opacity});
- },
- duration: 800,
- complete: function(){
- current_fs.hide();
- animating = false;
- },
- //this comes from the custom easing plugin
- //easing: 'easeInOutBack'
- });
- });
- $(".previous").click(function() {
- if(animating) return false;
- animating = true;
- current_fs = $(this).parent().parent();
- previous_fs = $(this).parent().parent().prev();
- //de-activate current step on progressbar
- $("#progressbar li").eq($("fieldset").index(current_fs)).removeClass("active");
- step -= 1;
- //show the previous fieldset
- previous_fs.show();
- //hide the current fieldset with style
- current_fs.animate({opacity: 0}, {
- step: function(now, mx) {
- //as the opacity of current_fs reduces to 0 - stored in "now"
- //1. scale previous_fs from 80% to 100%
- scale = 0.8 + (1 - now) * 0.2;
- //2. take current_fs to the right(50%) - from 0%
- left = ((1-now) * 50)+"%";
- //3. increase opacity of previous_fs to 1 as it moves in
- opacity = 1 - now;
- current_fs.css({'left': left});
- previous_fs.css({'transform': 'scale('+scale+')', 'opacity': opacity});
- },
- duration: 800,
- complete: function(){
- current_fs.hide();
- animating = false;
- },
- //this comes from the custom easing plugin
- //easing: 'easeInOutBack'
- });
- });
- // 关闭弹窗
- $(document).on('click', '.submit-button', function () {
- Fast.api.close();
- });
- Controller.api.bindevent();
- },
- edit_chief: function () {
- Form.api.bindevent($("form[role=form]"));
- Controller.api.bindevent();
- },
- comments: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'cms/manuscript/comments' + location.search,
- table: 'cms_manuscript_comments',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- fixedColumns: true,
- fixedRightNumber: 1,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'user.nickname', title: __('User_id'), operate: 'like'},
- {field: 'manuscript.title', title: __('Title'), operate: 'like'},
- {field: 'recommendation', title: __('Recommendation'), operate: 'like', formatter: Table.api.formatter.flag},
- {field: 'type', title: __('Type'), searchList: Config.site_type_list},
- {field: 'createtime', title: __('Createtime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
- {
- field: 'operate',
- title: __('Operate'),
- clickToSelect: false,
- table: table,
- events: Table.api.events.operate,
- formatter: function (value, row, index) {
- var that = $.extend({}, this);
- var table = $(this.table).clone(true);
- that.table = table;
- return Table.api.formatter.operate.call(that, value, row, index);
- },
- buttons:[
- {
- name: 'details',
- classname: 'btn btn-xs btn-warning btn-dialog',
- icon: 'fa fa-list',
- title: __('详情'),
- url: function (row) {
- return 'cms/manuscript/comments_detail?ids=' + row.id;
- },
- }
- ]
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- comments_detail: function () {
- Form.api.bindevent($("form[role=form]"));
- // 关闭弹窗
- $(document).on('click', '.btn-close', function () {
- Fast.api.close();
- });
- },
- email: function () {
- Form.api.bindevent($("form[role=form]"));
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- }
- }
- };
- return Controller;
- });
|