123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form','clipboard'], function ($, undefined, Backend, Table, Form,Clipboard) {
- var Controller = {
- index: function () {
- // 给表单绑定事件
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- var clipboard = new Clipboard('.btn-copy');
- clipboard.on('success', function (e) {
- e.clearSelection();
- Toastr.success('复制成功');
- });
- clipboard.on('error', function (e) {
- e.clearSelection();
- Toastr.error("复制失败");
- });
- Form.api.bindevent($("form[role=form]"), function(data, ret){
- //如果我们需要在提交表单成功后做跳转,可以在此使用location.href="链接";进行跳转
- $("#targetUrl").html(data);
- $(".btn-copy").removeClass("hidden");
- $(".btn-copy").attr("data-clipboard-text", data);
- }, function(data, ret){
- console.log(data);
- console.log(ret);
- return false;
- }, function(success, error){
- //bindevent的第三个参数为提交前的回调
- //如果我们需要在表单提交前做一些数据处理,则可以在此方法处理
- //注意如果我们需要阻止表单,可以在此使用return false;即可
- //如果我们处理完成需要再次提交表单则可以使用submit提交,如下
- Form.api.submit(this, success, error);
- });
- //获取链接:阅读页|最近阅读 (切换TAB)
- $(document).on("click", ".link_type", function () {
- $("#targetUrl").empty();
- var type = $(this).val();
- if (type == 0) {
- $("#targetUrl").html();
- $(".btn-copy").attr("data-clipboard-text", '');
- $(".readgroup").removeAttr("style");
- $(".readgroup input").removeAttr("disabled");
- }
- if (type == 1) {
- $("#targetUrl").html();
- $(".btn-copy").attr("data-clipboard-text", '');
- $(".readgroup").css("display", "none");
- $(".readgroup input").attr("disabled", "disabled");
- }
- })
- }
- }
- };
- return Controller;
- });
|