新建
This commit is contained in:
3
public/assets/js/addons.js
Normal file
3
public/assets/js/addons.js
Normal file
@@ -0,0 +1,3 @@
|
||||
define([], function () {
|
||||
|
||||
});
|
||||
893
public/assets/js/adminlte.js
Normal file
893
public/assets/js/adminlte.js
Normal file
@@ -0,0 +1,893 @@
|
||||
/*! AdminLTE app.js
|
||||
* ================
|
||||
* Main JS application file for AdminLTE v2. This file
|
||||
* should be included in all pages. It controls some layout
|
||||
* options and implements exclusive AdminLTE plugins.
|
||||
*
|
||||
* @Author Almsaeed Studio
|
||||
* @Support <http://www.almsaeedstudio.com>
|
||||
* @Email <abdullah@almsaeedstudio.com>
|
||||
* @version 2.3.8
|
||||
* @license MIT <http://opensource.org/licenses/MIT>
|
||||
*/
|
||||
|
||||
//Make sure jQuery has been loaded before app.js
|
||||
if (typeof jQuery === "undefined") {
|
||||
throw new Error("AdminLTE requires jQuery");
|
||||
}
|
||||
|
||||
/* AdminLTE
|
||||
*
|
||||
* @type Object
|
||||
* @description $.AdminLTE is the main object for the template's app.
|
||||
* It's used for implementing functions and options related
|
||||
* to the template. Keeping everything wrapped in an object
|
||||
* prevents conflict with other plugins and is a better
|
||||
* way to organize our code.
|
||||
*/
|
||||
$.AdminLTE = {};
|
||||
|
||||
/* --------------------
|
||||
* - AdminLTE Options -
|
||||
* --------------------
|
||||
* Modify these options to suit your implementation
|
||||
*/
|
||||
$.AdminLTE.options = {
|
||||
//Add slimscroll to navbar menus
|
||||
//This requires you to load the slimscroll plugin
|
||||
//in every page before app.js
|
||||
navbarMenuSlimscroll: true,
|
||||
navbarMenuSlimscrollWidth: "3px", //The width of the scroll bar
|
||||
navbarMenuHeight: "200px", //The height of the inner menu
|
||||
//General animation speed for JS animated elements such as box collapse/expand and
|
||||
//sidebar treeview slide up/down. This options accepts an integer as milliseconds,
|
||||
//'fast', 'normal', or 'slow'
|
||||
animationSpeed: 300,
|
||||
//Sidebar push menu toggle button selector
|
||||
sidebarToggleSelector: "[data-toggle='offcanvas']",
|
||||
//Activate sidebar push menu
|
||||
sidebarPushMenu: true,
|
||||
//Activate sidebar slimscroll if the fixed layout is set (requires SlimScroll Plugin)
|
||||
sidebarSlimScroll: true,
|
||||
//Enable sidebar expand on hover effect for sidebar mini
|
||||
//This option is forced to true if both the fixed layout and sidebar mini
|
||||
//are used together
|
||||
sidebarExpandOnHover: false,
|
||||
//BoxRefresh Plugin
|
||||
enableBoxRefresh: true,
|
||||
//Bootstrap.js tooltip
|
||||
enableBSToppltip: true,
|
||||
BSTooltipSelector: "[data-toggle='tooltip']",
|
||||
//Enable Fast Click. Fastclick.js creates a more
|
||||
//native touch experience with touch devices. If you
|
||||
//choose to enable the plugin, make sure you load the script
|
||||
//before AdminLTE's app.js
|
||||
enableFastclick: false,
|
||||
//Control Sidebar Tree views
|
||||
enableControlTreeView: true,
|
||||
//Control Sidebar Options
|
||||
enableControlSidebar: true,
|
||||
controlSidebarOptions: {
|
||||
//Which button should trigger the open/close event
|
||||
toggleBtnSelector: "[data-toggle='control-sidebar']",
|
||||
//The sidebar selector
|
||||
selector: ".control-sidebar",
|
||||
//Enable slide over content
|
||||
slide: true
|
||||
},
|
||||
//Box Widget Plugin. Enable this plugin
|
||||
//to allow boxes to be collapsed and/or removed
|
||||
enableBoxWidget: true,
|
||||
//Box Widget plugin options
|
||||
boxWidgetOptions: {
|
||||
boxWidgetIcons: {
|
||||
//Collapse icon
|
||||
collapse: 'fa-minus',
|
||||
//Open icon
|
||||
open: 'fa-plus',
|
||||
//Remove icon
|
||||
remove: 'fa-times'
|
||||
},
|
||||
boxWidgetSelectors: {
|
||||
//Remove button selector
|
||||
remove: '[data-widget="remove"]',
|
||||
//Collapse button selector
|
||||
collapse: '[data-widget="collapse"]'
|
||||
}
|
||||
},
|
||||
//Direct Chat plugin options
|
||||
directChat: {
|
||||
//Enable direct chat by default
|
||||
enable: true,
|
||||
//The button to open and close the chat contacts pane
|
||||
contactToggleSelector: '[data-widget="chat-pane-toggle"]'
|
||||
},
|
||||
//Define the set of colors to use globally around the website
|
||||
colors: {
|
||||
lightBlue: "#3c8dbc",
|
||||
red: "#f56954",
|
||||
green: "#00a65a",
|
||||
aqua: "#00c0ef",
|
||||
yellow: "#f39c12",
|
||||
blue: "#0073b7",
|
||||
navy: "#001F3F",
|
||||
teal: "#39CCCC",
|
||||
olive: "#3D9970",
|
||||
lime: "#01FF70",
|
||||
orange: "#FF851B",
|
||||
fuchsia: "#F012BE",
|
||||
purple: "#8E24AA",
|
||||
maroon: "#D81B60",
|
||||
black: "#222222",
|
||||
gray: "#d2d6de"
|
||||
},
|
||||
//The standard screen sizes that bootstrap uses.
|
||||
//If you change these in the variables.less file, change
|
||||
//them here too.
|
||||
screenSizes: {
|
||||
xs: 480,
|
||||
sm: 768,
|
||||
md: 992,
|
||||
lg: 1200
|
||||
}
|
||||
};
|
||||
|
||||
/* ------------------
|
||||
* - Implementation -
|
||||
* ------------------
|
||||
* The next block of code implements AdminLTE's
|
||||
* functions and plugins as specified by the
|
||||
* options above.
|
||||
*/
|
||||
$(function () {
|
||||
"use strict";
|
||||
|
||||
//Fix for IE page transitions
|
||||
$("body").removeClass("hold-transition");
|
||||
|
||||
//Extend options if external options exist
|
||||
if (typeof AdminLTEOptions !== "undefined") {
|
||||
$.extend(true,
|
||||
$.AdminLTE.options,
|
||||
AdminLTEOptions);
|
||||
}
|
||||
|
||||
if ('ontouchstart' in document.documentElement) {
|
||||
$.AdminLTE.options.sidebarSlimScroll = false;
|
||||
$(".main-sidebar").css({height: ($(window).height() - $(".main-header").height()) + "px", overflow: "scroll"});
|
||||
}
|
||||
|
||||
//Easy access to options
|
||||
var o = $.AdminLTE.options;
|
||||
|
||||
//Set up the object
|
||||
_init();
|
||||
|
||||
//Activate the layout maker
|
||||
$.AdminLTE.layout.activate();
|
||||
|
||||
//Enable sidebar tree view controls
|
||||
if (o.enableControlTreeView) {
|
||||
$.AdminLTE.tree('.sidebar');
|
||||
}
|
||||
|
||||
//Enable control sidebar
|
||||
if (o.enableControlSidebar) {
|
||||
$.AdminLTE.controlSidebar.activate();
|
||||
}
|
||||
|
||||
//Add slimscroll to navbar dropdown
|
||||
if (o.navbarMenuSlimscroll && typeof $.fn.slimscroll != 'undefined') {
|
||||
$(".navbar .menu").slimscroll({
|
||||
height: o.navbarMenuHeight,
|
||||
alwaysVisible: false,
|
||||
size: o.navbarMenuSlimscrollWidth
|
||||
}).css("width", "100%");
|
||||
}
|
||||
|
||||
//Activate sidebar push menu
|
||||
if (o.sidebarPushMenu) {
|
||||
$.AdminLTE.pushMenu.activate(o.sidebarToggleSelector);
|
||||
}
|
||||
|
||||
//Activate Bootstrap tooltip
|
||||
if (o.enableBSToppltip) {
|
||||
$('body').tooltip({
|
||||
selector: o.BSTooltipSelector,
|
||||
container: 'body'
|
||||
});
|
||||
}
|
||||
|
||||
//Activate box widget
|
||||
if (o.enableBoxWidget) {
|
||||
$.AdminLTE.boxWidget.activate();
|
||||
}
|
||||
|
||||
//Activate fast click
|
||||
if (o.enableFastclick && typeof FastClick != 'undefined') {
|
||||
FastClick.attach(document.body);
|
||||
}
|
||||
|
||||
//Activate direct chat widget
|
||||
if (o.directChat.enable) {
|
||||
$(document).on('click', o.directChat.contactToggleSelector, function () {
|
||||
var box = $(this).parents('.direct-chat').first();
|
||||
box.toggleClass('direct-chat-contacts-open');
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* INITIALIZE BUTTON TOGGLE
|
||||
* ------------------------
|
||||
*/
|
||||
$('.btn-group[data-toggle="btn-toggle"]').each(function () {
|
||||
var group = $(this);
|
||||
$(this).find(".btn").on('click', function (e) {
|
||||
group.find(".btn.active").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
/* ----------------------------------
|
||||
* - Initialize the AdminLTE Object -
|
||||
* ----------------------------------
|
||||
* All AdminLTE functions are implemented below.
|
||||
*/
|
||||
function _init() {
|
||||
'use strict';
|
||||
/* Layout
|
||||
* ======
|
||||
* Fixes the layout height in case min-height fails.
|
||||
*
|
||||
* @type Object
|
||||
* @usage $.AdminLTE.layout.activate()
|
||||
* $.AdminLTE.layout.fix()
|
||||
* $.AdminLTE.layout.fixSidebar()
|
||||
*/
|
||||
$.AdminLTE.layout = {
|
||||
activate: function () {
|
||||
var _this = this;
|
||||
//_this.fix();
|
||||
_this.fixSidebar();
|
||||
//$('body, html, .wrapper').css('height', 'auto');
|
||||
$(window, ".wrapper").resize(function () {
|
||||
//_this.fix();
|
||||
_this.fixSidebar();
|
||||
});
|
||||
},
|
||||
fix: function () {
|
||||
// Remove overflow from .wrapper if layout-boxed exists
|
||||
$(".layout-boxed > .wrapper").css('overflow', 'hidden');
|
||||
//Get window height and the wrapper height
|
||||
var footer_height = $('.main-footer').outerHeight() || 0;
|
||||
var neg = $('.main-header').outerHeight() + footer_height;
|
||||
var window_height = $(window).height();
|
||||
var sidebar_height = $(".sidebar").height() || 0;
|
||||
//Set the min-height of the content and sidebar based on the
|
||||
//the height of the document.
|
||||
if ($("body").hasClass("fixed")) {
|
||||
$(".content-wrapper, .right-side").css('min-height', window_height - footer_height);
|
||||
} else {
|
||||
var postSetWidth;
|
||||
if (window_height >= sidebar_height) {
|
||||
$(".content-wrapper, .right-side").css('min-height', window_height - neg);
|
||||
postSetWidth = window_height - neg;
|
||||
} else {
|
||||
$(".content-wrapper, .right-side").css('min-height', sidebar_height);
|
||||
postSetWidth = sidebar_height;
|
||||
}
|
||||
|
||||
//Fix for the control sidebar height
|
||||
var controlSidebar = $($.AdminLTE.options.controlSidebarOptions.selector);
|
||||
if (typeof controlSidebar !== "undefined") {
|
||||
if (controlSidebar.height() > postSetWidth)
|
||||
$(".content-wrapper, .right-side").css('min-height', controlSidebar.height());
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
fixSidebar: function () {
|
||||
//Make sure the body tag has the .fixed class
|
||||
if (!$("body").hasClass("fixed")) {
|
||||
if (typeof $.fn.slimScroll != 'undefined') {
|
||||
$(".sidebar").slimScroll({destroy: true}).height("auto");
|
||||
}
|
||||
return;
|
||||
} else if (typeof $.fn.slimScroll == 'undefined' && window.console) {
|
||||
window.console.error("Error: the fixed layout requires the slimscroll plugin!");
|
||||
}
|
||||
//Enable slimscroll for fixed layout
|
||||
if ($.AdminLTE.options.sidebarSlimScroll) {
|
||||
if (typeof $.fn.slimScroll != 'undefined') {
|
||||
//Destroy if it exists
|
||||
$(".sidebar").slimScroll({destroy: true}).height("auto").css("overflow", "inherit");
|
||||
if (!$("body").hasClass('sidebar-collapse')) {
|
||||
$(".sidebar").off("mousewheel").css("margin-top", 0);
|
||||
$('.sidebar .treeview-menu').off('mousewheel').removeAttr("style");
|
||||
//Add slimscroll
|
||||
$(".sidebar").slimscroll({
|
||||
height: ($(window).height() - $(".main-header").height()) + "px",
|
||||
color: "rgba(0,0,0,0.2)",
|
||||
size: "8px"
|
||||
});
|
||||
$(".sidebar").trigger("mouseover");
|
||||
} else {
|
||||
var sidebarHeight = $(".sidebar").height();
|
||||
var maxHeight = $(window).height() - $(".main-header").height();
|
||||
var overflowHeight = sidebarHeight + $(".main-header").height() - $(window).height();
|
||||
if (overflowHeight > 0) {
|
||||
$(".sidebar").height(maxHeight);
|
||||
$(".sidebar").on("mousewheel", function (e) {
|
||||
e.preventDefault();
|
||||
if (e.originalEvent.pageX < $(".sidebar").width()) {
|
||||
var marginTop = parseInt($(".sidebar").css("margin-top").replace("px", "")) + e.originalEvent.wheelDelta;
|
||||
if (marginTop < 0 && Math.abs(marginTop) > overflowHeight) {
|
||||
marginTop = Math.min(overflowHeight, marginTop);
|
||||
marginTop = -overflowHeight;
|
||||
}
|
||||
marginTop = Math.min(0, marginTop);
|
||||
$(".sidebar").css("margin-top", marginTop);
|
||||
}
|
||||
});
|
||||
$('.sidebar .treeview-menu').on('mousewheel', function (e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* PushMenu()
|
||||
* ==========
|
||||
* Adds the push menu functionality to the sidebar.
|
||||
*
|
||||
* @type Function
|
||||
* @usage: $.AdminLTE.pushMenu("[data-toggle='offcanvas']")
|
||||
*/
|
||||
$.AdminLTE.pushMenu = {
|
||||
activate: function (toggleBtn) {
|
||||
//Get the screen sizes
|
||||
var screenSizes = $.AdminLTE.options.screenSizes;
|
||||
|
||||
//Enable sidebar toggle
|
||||
$(document).on('click', toggleBtn, function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
//Enable sidebar push menu
|
||||
if ($(window).width() > (screenSizes.sm - 1)) {
|
||||
if ($("body").hasClass('sidebar-collapse')) {
|
||||
$("body").removeClass('sidebar-collapse').trigger('expanded.pushMenu');
|
||||
} else {
|
||||
$("body").addClass('sidebar-collapse').trigger('collapsed.pushMenu');
|
||||
}
|
||||
}
|
||||
//Handle sidebar push menu for small screens
|
||||
else {
|
||||
if ($("body").hasClass('sidebar-open')) {
|
||||
$("body").removeClass('sidebar-open').removeClass('sidebar-collapse').trigger('collapsed.pushMenu');
|
||||
} else {
|
||||
$("body").addClass('sidebar-open').trigger('expanded.pushMenu');
|
||||
}
|
||||
}
|
||||
$.AdminLTE.layout.fixSidebar();
|
||||
});
|
||||
|
||||
$(".content-wrapper").click(function () {
|
||||
//Enable hide menu when clicking on the content-wrapper on small screens
|
||||
if ($(window).width() <= (screenSizes.sm - 1) && $("body").hasClass("sidebar-open")) {
|
||||
$("body").removeClass('sidebar-open');
|
||||
}
|
||||
});
|
||||
|
||||
//Enable expand on hover for sidebar mini
|
||||
if ($.AdminLTE.options.sidebarExpandOnHover) {
|
||||
this.expandOnHover();
|
||||
}
|
||||
},
|
||||
expandOnHover: function () {
|
||||
var _this = this;
|
||||
var screenWidth = $.AdminLTE.options.screenSizes.sm - 1;
|
||||
//Expand sidebar on hover
|
||||
$('.main-sidebar').hover(function () {
|
||||
if ($.AdminLTE.options.sidebarExpandOnHover) {
|
||||
if ($('body').hasClass('sidebar-mini')
|
||||
&& $("body").hasClass('sidebar-collapse')
|
||||
&& $(window).width() > screenWidth) {
|
||||
_this.expand();
|
||||
}
|
||||
}
|
||||
}, function () {
|
||||
if ($('body').hasClass('sidebar-mini')
|
||||
&& $('body').hasClass('sidebar-expanded-on-hover')
|
||||
&& $(window).width() > screenWidth) {
|
||||
_this.collapse();
|
||||
}
|
||||
});
|
||||
},
|
||||
expand: function () {
|
||||
$("body").removeClass('sidebar-collapse').addClass('sidebar-expanded-on-hover');
|
||||
$.AdminLTE.layout.fixSidebar();
|
||||
},
|
||||
collapse: function () {
|
||||
if ($('body').hasClass('sidebar-expanded-on-hover')) {
|
||||
$('body').removeClass('sidebar-expanded-on-hover').addClass('sidebar-collapse');
|
||||
// $.AdminLTE.layout.fixSidebar();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* Tree()
|
||||
* ======
|
||||
* Converts the sidebar into a multilevel
|
||||
* tree view menu.
|
||||
*
|
||||
* @type Function
|
||||
* @Usage: $.AdminLTE.tree('.sidebar')
|
||||
*/
|
||||
$.AdminLTE.tree = function (menu) {
|
||||
var _this = this;
|
||||
var animationSpeed = $.AdminLTE.options.animationSpeed;
|
||||
$(document).off('mouseenter', menu + ' .sidebar-menu > li')
|
||||
.on('mouseenter', menu + ' .sidebar-menu > li', function () {
|
||||
var treemenu = $(this).find("> .treeview-menu");
|
||||
if (treemenu.length > 0) {
|
||||
if ($("body").hasClass("sidebar-collapse")) {
|
||||
var liHeight = $(this).height();
|
||||
var headerHeight = $(".main-header").height();
|
||||
var maxBottomHeight = $(window).height() - ($(this).offset().top + headerHeight);
|
||||
var maxTopHeight = $(window).height() - maxBottomHeight - liHeight;
|
||||
var maxHeight = maxBottomHeight;
|
||||
if (maxBottomHeight < 300 || maxTopHeight > maxBottomHeight) {
|
||||
treemenu.css("top", "unset").css("bottom", liHeight);
|
||||
maxHeight = maxTopHeight;
|
||||
}
|
||||
treemenu.css("max-height", maxHeight).css("overflow-y", "auto");
|
||||
} else {
|
||||
treemenu.css("max-height", "inherit").css("overflow-y", "unset");
|
||||
}
|
||||
}
|
||||
});
|
||||
$(document).off('click', menu + ' li a')
|
||||
.on('click', menu + ' li a', function (e) {
|
||||
//Get the clicked link and the next element
|
||||
var $this = $(this);
|
||||
var checkElement = $this.next();
|
||||
//Check if the next element is a menu and is visible
|
||||
if ((checkElement.is('.treeview-menu')) && (checkElement.is(':visible'))) {
|
||||
if ($("body").hasClass("sidebar-collapse") && $this.parent().parent().hasClass("sidebar-menu")) {
|
||||
return false;
|
||||
}
|
||||
//Close the menu
|
||||
checkElement.slideUp(animationSpeed, function () {
|
||||
checkElement.removeClass('menu-open');
|
||||
//Fix the layout in case the sidebar stretches over the height of the window
|
||||
//_this.layout.fix();
|
||||
});
|
||||
// checkElement.parent("li").removeClass("active");
|
||||
checkElement.parent("li").removeClass('treeview-open');
|
||||
}
|
||||
//If the menu is not visible
|
||||
else if ((checkElement.is('.treeview-menu')) && (!checkElement.is(':visible'))) {
|
||||
//Get the parent menu
|
||||
var parent = $this.parents('ul').first();
|
||||
// modified by FastAdmin
|
||||
if ($(".show-submenu", menu).length == 0) {
|
||||
//Close all open menus within the parent
|
||||
var ul = parent.find('ul:visible').slideUp(animationSpeed);
|
||||
//Remove the menu-open class from the parent
|
||||
ul.removeClass('menu-open');
|
||||
parent.find('li.treeview').removeClass("treeview-open");
|
||||
}
|
||||
//Get the parent li
|
||||
var parent_li = $this.parent("li");
|
||||
|
||||
//Open the target menu and add the menu-open class
|
||||
checkElement.slideDown(animationSpeed, function () {
|
||||
//Add the class active to the parent li
|
||||
checkElement.addClass('menu-open');
|
||||
//parent.find('li.active').removeClass('active');
|
||||
//parent_li.addClass('active');
|
||||
//Fix the layout in case the sidebar stretches over the height of the window
|
||||
// _this.layout.fix();
|
||||
});
|
||||
parent_li.addClass('treeview-open');
|
||||
} else {
|
||||
if (!$this.parent().hasClass("active")) {
|
||||
// $this.parent().addClass("active");
|
||||
}
|
||||
// modified by FastAdmin
|
||||
if ($(".show-submenu", menu).length == 0 && $this.parent().parent().hasClass("sidebar-menu")) {
|
||||
$this.parent().siblings().find("ul.menu-open").slideUp();
|
||||
$this.parent().siblings("li.treeview-open").removeClass("treeview-open");
|
||||
}
|
||||
}
|
||||
//if this isn't a link, prevent the page from being redirected
|
||||
if (checkElement.is('.treeview-menu')) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* ControlSidebar
|
||||
* ==============
|
||||
* Adds functionality to the right sidebar
|
||||
*
|
||||
* @type Object
|
||||
* @usage $.AdminLTE.controlSidebar.activate(options)
|
||||
*/
|
||||
$.AdminLTE.controlSidebar = {
|
||||
//instantiate the object
|
||||
activate: function () {
|
||||
//Get the object
|
||||
var _this = this;
|
||||
//Update options
|
||||
var o = $.AdminLTE.options.controlSidebarOptions;
|
||||
//Get the sidebar
|
||||
var sidebar = $(o.selector);
|
||||
//The toggle button
|
||||
var btn = $(o.toggleBtnSelector);
|
||||
|
||||
//Listen to the click event
|
||||
btn.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
//If the sidebar is not open
|
||||
if (!sidebar.hasClass('control-sidebar-open')
|
||||
&& !$('body').hasClass('control-sidebar-open')) {
|
||||
//Open the sidebar
|
||||
_this.open(sidebar, o.slide);
|
||||
} else {
|
||||
_this.close(sidebar, o.slide);
|
||||
}
|
||||
});
|
||||
|
||||
//If the body has a boxed layout, fix the sidebar bg position
|
||||
var bg = $(".control-sidebar-bg");
|
||||
_this._fix(bg);
|
||||
|
||||
//If the body has a fixed layout, make the control sidebar fixed
|
||||
if ($('body').hasClass('fixed')) {
|
||||
_this._fixForFixed(sidebar);
|
||||
} else {
|
||||
//If the content height is less than the sidebar's height, force max height
|
||||
if ($('.content-wrapper, .right-side').height() < sidebar.height()) {
|
||||
_this._fixForContent(sidebar);
|
||||
}
|
||||
}
|
||||
},
|
||||
//Open the control sidebar
|
||||
open: function (sidebar, slide) {
|
||||
//Slide over content
|
||||
if (slide) {
|
||||
sidebar.addClass('control-sidebar-open');
|
||||
} else {
|
||||
//Push the content by adding the open class to the body instead
|
||||
//of the sidebar itself
|
||||
$('body').addClass('control-sidebar-open');
|
||||
}
|
||||
},
|
||||
//Close the control sidebar
|
||||
close: function (sidebar, slide) {
|
||||
if (slide) {
|
||||
sidebar.removeClass('control-sidebar-open');
|
||||
} else {
|
||||
$('body').removeClass('control-sidebar-open');
|
||||
}
|
||||
},
|
||||
_fix: function (sidebar) {
|
||||
var _this = this;
|
||||
if ($("body").hasClass('layout-boxed')) {
|
||||
sidebar.css('position', 'absolute');
|
||||
sidebar.height($(".wrapper").height());
|
||||
if (_this.hasBindedResize) {
|
||||
return;
|
||||
}
|
||||
$(window).resize(function () {
|
||||
_this._fix(sidebar);
|
||||
});
|
||||
_this.hasBindedResize = true;
|
||||
} else {
|
||||
sidebar.css({
|
||||
'position': 'fixed',
|
||||
'height': 'auto'
|
||||
});
|
||||
}
|
||||
},
|
||||
_fixForFixed: function (sidebar) {
|
||||
sidebar.css({
|
||||
'position': 'fixed',
|
||||
'max-height': '100%',
|
||||
'overflow': 'auto',
|
||||
});
|
||||
},
|
||||
_fixForContent: function (sidebar) {
|
||||
$(".content-wrapper, .right-side").css('min-height', sidebar.height());
|
||||
}
|
||||
};
|
||||
|
||||
/* BoxWidget
|
||||
* =========
|
||||
* BoxWidget is a plugin to handle collapsing and
|
||||
* removing boxes from the screen.
|
||||
*
|
||||
* @type Object
|
||||
* @usage $.AdminLTE.boxWidget.activate()
|
||||
* Set all your options in the main $.AdminLTE.options object
|
||||
*/
|
||||
$.AdminLTE.boxWidget = {
|
||||
selectors: $.AdminLTE.options.boxWidgetOptions.boxWidgetSelectors,
|
||||
icons: $.AdminLTE.options.boxWidgetOptions.boxWidgetIcons,
|
||||
animationSpeed: $.AdminLTE.options.animationSpeed,
|
||||
activate: function (_box) {
|
||||
var _this = this;
|
||||
if (!_box) {
|
||||
_box = document; // activate all boxes per default
|
||||
}
|
||||
//Listen for collapse event triggers
|
||||
$(_box).on('click', _this.selectors.collapse, function (e) {
|
||||
e.preventDefault();
|
||||
_this.collapse($(this));
|
||||
});
|
||||
|
||||
//Listen for remove event triggers
|
||||
$(_box).on('click', _this.selectors.remove, function (e) {
|
||||
e.preventDefault();
|
||||
_this.remove($(this));
|
||||
});
|
||||
},
|
||||
collapse: function (element) {
|
||||
var _this = this;
|
||||
//Find the box parent
|
||||
var box = element.parents(".box").first();
|
||||
//Find the body and the footer
|
||||
var box_content = box.find("> .box-body, > .box-footer, > form >.box-body, > form > .box-footer");
|
||||
if (!box.hasClass("collapsed-box")) {
|
||||
//Convert minus into plus
|
||||
element.children(":first")
|
||||
.removeClass(_this.icons.collapse)
|
||||
.addClass(_this.icons.open);
|
||||
//Hide the content
|
||||
box_content.slideUp(_this.animationSpeed, function () {
|
||||
box.addClass("collapsed-box");
|
||||
});
|
||||
} else {
|
||||
//Convert plus into minus
|
||||
element.children(":first")
|
||||
.removeClass(_this.icons.open)
|
||||
.addClass(_this.icons.collapse);
|
||||
//Show the content
|
||||
box_content.slideDown(_this.animationSpeed, function () {
|
||||
box.removeClass("collapsed-box");
|
||||
});
|
||||
}
|
||||
},
|
||||
remove: function (element) {
|
||||
//Find the box parent
|
||||
var box = element.parents(".box").first();
|
||||
box.slideUp(this.animationSpeed);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* ------------------
|
||||
* - Custom Plugins -
|
||||
* ------------------
|
||||
* All custom plugins are defined below.
|
||||
*/
|
||||
|
||||
/*
|
||||
* BOX REFRESH BUTTON
|
||||
* ------------------
|
||||
* This is a custom plugin to use with the component BOX. It allows you to add
|
||||
* a refresh button to the box. It converts the box's state to a loading state.
|
||||
*
|
||||
* @type plugin
|
||||
* @usage $("#box-widget").boxRefresh( options );
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
"use strict";
|
||||
|
||||
$.fn.boxRefresh = function (options) {
|
||||
|
||||
// Render options
|
||||
var settings = $.extend({
|
||||
//Refresh button selector
|
||||
trigger: ".refresh-btn",
|
||||
//File source to be loaded (e.g: ajax/src.php)
|
||||
source: "",
|
||||
//Callbacks
|
||||
onLoadStart: function (box) {
|
||||
return box;
|
||||
}, //Right after the button has been clicked
|
||||
onLoadDone: function (box) {
|
||||
return box;
|
||||
} //When the source has been loaded
|
||||
|
||||
}, options);
|
||||
|
||||
//The overlay
|
||||
var overlay = $('<div class="overlay"><div class="fa fa-refresh fa-spin"></div></div>');
|
||||
|
||||
return this.each(function () {
|
||||
//if a source is specified
|
||||
if (settings.source === "") {
|
||||
if (window.console) {
|
||||
window.console.log("Please specify a source first - boxRefresh()");
|
||||
}
|
||||
return;
|
||||
}
|
||||
//the box
|
||||
var box = $(this);
|
||||
//the button
|
||||
var rBtn = box.find(settings.trigger).first();
|
||||
|
||||
//On trigger click
|
||||
rBtn.on('click', function (e) {
|
||||
e.preventDefault();
|
||||
//Add loading overlay
|
||||
start(box);
|
||||
|
||||
//Perform ajax call
|
||||
box.find(".box-body").load(settings.source, function () {
|
||||
done(box);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function start(box) {
|
||||
//Add overlay and loading img
|
||||
box.append(overlay);
|
||||
|
||||
settings.onLoadStart.call(box);
|
||||
}
|
||||
|
||||
function done(box) {
|
||||
//Remove overlay and loading img
|
||||
box.find(overlay).remove();
|
||||
|
||||
settings.onLoadDone.call(box);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
/*
|
||||
* EXPLICIT BOX CONTROLS
|
||||
* -----------------------
|
||||
* This is a custom plugin to use with the component BOX. It allows you to activate
|
||||
* a box inserted in the DOM after the app.js was loaded, toggle and remove box.
|
||||
*
|
||||
* @type plugin
|
||||
* @usage $("#box-widget").activateBox();
|
||||
* @usage $("#box-widget").toggleBox();
|
||||
* @usage $("#box-widget").removeBox();
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
'use strict';
|
||||
|
||||
$.fn.activateBox = function () {
|
||||
$.AdminLTE.boxWidget.activate(this);
|
||||
};
|
||||
|
||||
$.fn.toggleBox = function () {
|
||||
var button = $($.AdminLTE.boxWidget.selectors.collapse, this);
|
||||
$.AdminLTE.boxWidget.collapse(button);
|
||||
};
|
||||
|
||||
$.fn.removeBox = function () {
|
||||
var button = $($.AdminLTE.boxWidget.selectors.remove, this);
|
||||
$.AdminLTE.boxWidget.remove(button);
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
/*
|
||||
* TODO LIST CUSTOM PLUGIN
|
||||
* -----------------------
|
||||
* This plugin depends on iCheck plugin for checkbox and radio inputs
|
||||
*
|
||||
* @type plugin
|
||||
* @usage $("#todo-widget").todolist( options );
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
'use strict';
|
||||
|
||||
$.fn.todolist = function (options) {
|
||||
// Render options
|
||||
var settings = $.extend({
|
||||
//When the user checks the input
|
||||
onCheck: function (ele) {
|
||||
return ele;
|
||||
},
|
||||
//When the user unchecks the input
|
||||
onUncheck: function (ele) {
|
||||
return ele;
|
||||
}
|
||||
}, options);
|
||||
|
||||
return this.each(function () {
|
||||
|
||||
if (typeof $.fn.iCheck != 'undefined') {
|
||||
$('input', this).on('ifChecked', function () {
|
||||
var ele = $(this).parents("li").first();
|
||||
ele.toggleClass("done");
|
||||
settings.onCheck.call(ele);
|
||||
});
|
||||
|
||||
$('input', this).on('ifUnchecked', function () {
|
||||
var ele = $(this).parents("li").first();
|
||||
ele.toggleClass("done");
|
||||
settings.onUncheck.call(ele);
|
||||
});
|
||||
} else {
|
||||
$('input', this).on('change', function () {
|
||||
var ele = $(this).parents("li").first();
|
||||
ele.toggleClass("done");
|
||||
if ($('input', ele).is(":checked")) {
|
||||
settings.onCheck.call(ele);
|
||||
} else {
|
||||
settings.onUncheck.call(ele);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//set/get form element value
|
||||
$.fn.field = function (name, value) {
|
||||
if (typeof name !== "string")
|
||||
return false;
|
||||
var element = $(this).find("[name='" + name + "']");
|
||||
|
||||
if (typeof value === "undefined" && element.length >= 1) {
|
||||
switch (element.attr("type")) {
|
||||
case "checkbox":
|
||||
var result = new Array();
|
||||
element.each(function (i, val) {
|
||||
if ($(this).is(":checked")) {
|
||||
result.push($(this).val());
|
||||
}
|
||||
});
|
||||
return result;
|
||||
break;
|
||||
case "radio":
|
||||
var result;
|
||||
element.each(function (i, val) {
|
||||
if ($(this).is(":checked")) {
|
||||
result = $(this).val();
|
||||
}
|
||||
});
|
||||
return result;
|
||||
break;
|
||||
default:
|
||||
return element.val();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (element.attr("type")) {
|
||||
case "checkbox":
|
||||
case "radio":
|
||||
value = $.isArray(value) ? value : [value];
|
||||
element.each(function (i) {
|
||||
$(this).prop({
|
||||
checked: $.inArray($(this).val(), value) > -1
|
||||
});
|
||||
});
|
||||
break;
|
||||
case undefined:
|
||||
default:
|
||||
element.val(value);
|
||||
break;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
};
|
||||
}(jQuery));
|
||||
1032
public/assets/js/autocomplete.js
Normal file
1032
public/assets/js/autocomplete.js
Normal file
File diff suppressed because it is too large
Load Diff
3
public/assets/js/backend-init.js
Normal file
3
public/assets/js/backend-init.js
Normal file
@@ -0,0 +1,3 @@
|
||||
define(['backend'], function (Backend) {
|
||||
|
||||
});
|
||||
260
public/assets/js/backend.js
Normal file
260
public/assets/js/backend.js
Normal file
@@ -0,0 +1,260 @@
|
||||
define(['fast', 'template', 'moment'], function (Fast, Template, Moment) {
|
||||
var Backend = {
|
||||
api: {
|
||||
sidebar: function (params) {
|
||||
colorArr = ['red', 'green', 'yellow', 'blue', 'teal', 'orange', 'purple'];
|
||||
$colorNums = colorArr.length;
|
||||
badgeList = {};
|
||||
$.each(params, function (k, v) {
|
||||
$url = Fast.api.fixurl(k);
|
||||
|
||||
if ($.isArray(v)) {
|
||||
$nums = typeof v[0] !== 'undefined' ? v[0] : 0;
|
||||
$color = typeof v[1] !== 'undefined' ? v[1] : colorArr[(!isNaN($nums) ? $nums : $nums.length) % $colorNums];
|
||||
$class = typeof v[2] !== 'undefined' ? v[2] : 'label';
|
||||
} else {
|
||||
$nums = v;
|
||||
$color = colorArr[(!isNaN($nums) ? $nums : $nums.length) % $colorNums];
|
||||
$class = 'label';
|
||||
}
|
||||
//必须nums大于0才显示
|
||||
badgeList[$url] = $nums > 0 ? '<small class="' + $class + ' pull-right bg-' + $color + '">' + $nums + '</small>' : '';
|
||||
});
|
||||
$.each(badgeList, function (k, v) {
|
||||
var anchor = top.window.$("li a[addtabs][url='" + k + "']");
|
||||
if (anchor) {
|
||||
top.window.$(".pull-right-container", anchor).html(v);
|
||||
top.window.$(".nav-addtabs li a[node-id='" + anchor.attr("addtabs") + "'] .pull-right-container").html(v);
|
||||
}
|
||||
});
|
||||
},
|
||||
addtabs: function (url, title, icon) {
|
||||
var dom = "a[url='{url}']"
|
||||
var leftlink = top.window.$(dom.replace(/\{url\}/, url));
|
||||
if (leftlink.length > 0) {
|
||||
leftlink.trigger("click");
|
||||
} else {
|
||||
url = Fast.api.fixurl(url);
|
||||
leftlink = top.window.$(dom.replace(/\{url\}/, url));
|
||||
if (leftlink.length > 0) {
|
||||
var event = leftlink.parent().hasClass("active") ? "dblclick" : "click";
|
||||
leftlink.trigger(event);
|
||||
} else {
|
||||
var baseurl = url.substr(0, url.indexOf("?") > -1 ? url.indexOf("?") : url.length);
|
||||
leftlink = top.window.$(dom.replace(/\{url\}/, baseurl));
|
||||
//能找到相对地址
|
||||
if (leftlink.length > 0) {
|
||||
icon = typeof icon !== 'undefined' ? icon : leftlink.find("i").attr("class");
|
||||
title = typeof title !== 'undefined' ? title : leftlink.find("span:first").text();
|
||||
leftlink.trigger("fa.event.toggleitem");
|
||||
}
|
||||
var navnode = top.window.$(".nav-tabs ul li a[node-url='" + url + "']");
|
||||
if (navnode.length > 0) {
|
||||
navnode.trigger("click");
|
||||
} else {
|
||||
//追加新的tab
|
||||
var id = Math.floor(new Date().valueOf() * Math.random());
|
||||
icon = typeof icon !== 'undefined' ? icon : 'fa fa-circle-o';
|
||||
title = typeof title !== 'undefined' ? title : '';
|
||||
top.window.$("<a />").append('<i class="' + icon + '"></i> <span>' + title + '</span>').prop("href", url).attr({
|
||||
url: url,
|
||||
addtabs: id
|
||||
}).addClass("hide").appendTo(top.window.document.body).trigger("click");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
closetabs: function (url) {
|
||||
if (typeof url === 'undefined') {
|
||||
top.window.$("ul.nav-addtabs li.active .close-tab").trigger("click");
|
||||
} else {
|
||||
var dom = "a[url='{url}']"
|
||||
var navlink = top.window.$(dom.replace(/\{url\}/, url));
|
||||
if (navlink.length === 0) {
|
||||
url = Fast.api.fixurl(url);
|
||||
navlink = top.window.$(dom.replace(/\{url\}/, url));
|
||||
if (navlink.length === 0) {
|
||||
} else {
|
||||
var baseurl = url.substr(0, url.indexOf("?") > -1 ? url.indexOf("?") : url.length);
|
||||
navlink = top.window.$(dom.replace(/\{url\}/, baseurl));
|
||||
//能找到相对地址
|
||||
if (navlink.length === 0) {
|
||||
navlink = top.window.$(".nav-tabs ul li a[node-url='" + url + "']");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (navlink.length > 0 && navlink.attr('addtabs')) {
|
||||
top.window.$("ul.nav-addtabs li#tab_" + navlink.attr('addtabs') + " .close-tab").trigger("click");
|
||||
}
|
||||
}
|
||||
},
|
||||
replaceids: function (elem, url) {
|
||||
//如果有需要替换ids的
|
||||
if (url.indexOf("{ids}") > -1) {
|
||||
var ids = 0;
|
||||
var tableId = $(elem).data("table-id");
|
||||
if (tableId && $("#" + tableId).length > 0 && $("#" + tableId).data("bootstrap.table")) {
|
||||
var Table = require("table");
|
||||
ids = Table.api.selectedids($("#" + tableId)).join(",");
|
||||
}
|
||||
url = url.replace(/\{ids\}/g, ids);
|
||||
}
|
||||
return url;
|
||||
},
|
||||
refreshmenu: function () {
|
||||
top.window.$(".sidebar-menu").trigger("refresh");
|
||||
},
|
||||
gettablecolumnbutton: function (options) {
|
||||
if (typeof options.tableId !== 'undefined' && typeof options.fieldIndex !== 'undefined' && typeof options.buttonIndex !== 'undefined') {
|
||||
var tableOptions = $("#" + options.tableId).bootstrapTable('getOptions');
|
||||
if (tableOptions) {
|
||||
var columnObj = null;
|
||||
$.each(tableOptions.columns, function (i, columns) {
|
||||
$.each(columns, function (j, column) {
|
||||
if (typeof column.fieldIndex !== 'undefined' && column.fieldIndex === options.fieldIndex) {
|
||||
columnObj = column;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (columnObj) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (columnObj) {
|
||||
return columnObj['buttons'][options.buttonIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
},
|
||||
init: function () {
|
||||
//公共代码
|
||||
//添加ios-fix兼容iOS下的iframe
|
||||
if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
|
||||
$("html").addClass("ios-fix");
|
||||
}
|
||||
//配置Toastr的参数
|
||||
Toastr.options.positionClass = Config.controllername === 'index' ? "toast-top-right-index" : "toast-top-right";
|
||||
//点击包含.btn-dialog的元素时弹出dialog
|
||||
$(document).on('click', '.btn-dialog,.dialogit', function (e) {
|
||||
var that = this;
|
||||
var options = $.extend({}, $(that).data() || {});
|
||||
var url = Backend.api.replaceids(that, $(that).data("url") || $(that).attr('href'));
|
||||
var title = $(that).attr("title") || $(that).data("title") || $(that).data('original-title');
|
||||
var button = Backend.api.gettablecolumnbutton(options);
|
||||
if (button && typeof button.callback === 'function') {
|
||||
options.callback = button.callback;
|
||||
}
|
||||
if (typeof options.confirm !== 'undefined') {
|
||||
Layer.confirm(options.confirm, function (index) {
|
||||
Backend.api.open(url, title, options);
|
||||
Layer.close(index);
|
||||
});
|
||||
} else {
|
||||
window[$(that).data("window") || 'self'].Backend.api.open(url, title, options);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
//点击包含.btn-addtabs的元素时新增选项卡
|
||||
$(document).on('click', '.btn-addtabs,.addtabsit', function (e) {
|
||||
var that = this;
|
||||
var options = $.extend({}, $(that).data() || {});
|
||||
var url = Backend.api.replaceids(that, $(that).data("url") || $(that).attr('href'));
|
||||
var title = $(that).attr("title") || $(that).data("title") || $(that).data('original-title');
|
||||
var icon = $(that).attr("icon") || $(that).data("icon");
|
||||
if (typeof options.confirm !== 'undefined') {
|
||||
Layer.confirm(options.confirm, function (index) {
|
||||
Backend.api.addtabs(url, title, icon);
|
||||
Layer.close(index);
|
||||
});
|
||||
} else {
|
||||
Backend.api.addtabs(url, title, icon);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
//点击包含.btn-ajax的元素时发送Ajax请求
|
||||
$(document).on('click', '.btn-ajax,.ajaxit', function (e) {
|
||||
var that = this;
|
||||
var options = $.extend({}, $(that).data() || {});
|
||||
if (typeof options.url === 'undefined' && $(that).attr("href")) {
|
||||
options.url = $(that).attr("href");
|
||||
}
|
||||
options.url = Backend.api.replaceids(this, options.url);
|
||||
var success = typeof options.success === 'function' ? options.success : null;
|
||||
var error = typeof options.error === 'function' ? options.error : null;
|
||||
delete options.success;
|
||||
delete options.error;
|
||||
var button = Backend.api.gettablecolumnbutton(options);
|
||||
if (button) {
|
||||
if (typeof button.success === 'function') {
|
||||
success = button.success;
|
||||
}
|
||||
if (typeof button.error === 'function') {
|
||||
error = button.error;
|
||||
}
|
||||
}
|
||||
//如果未设备成功的回调,设定了自动刷新的情况下自动进行刷新
|
||||
if (!success && typeof options.tableId !== 'undefined' && typeof options.refresh !== 'undefined' && options.refresh) {
|
||||
success = function () {
|
||||
$("#" + options.tableId).bootstrapTable('refresh');
|
||||
}
|
||||
}
|
||||
if (typeof options.confirm !== 'undefined') {
|
||||
Layer.confirm(options.confirm, function (index) {
|
||||
Backend.api.ajax(options, success, error);
|
||||
Layer.close(index);
|
||||
});
|
||||
} else {
|
||||
Backend.api.ajax(options, success, error);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$(document).on('click', '.btn-click,.clickit', function (e) {
|
||||
var that = this;
|
||||
var options = $.extend({}, $(that).data() || {});
|
||||
var row = {};
|
||||
if (typeof options.tableId !== 'undefined') {
|
||||
var index = parseInt(options.rowIndex);
|
||||
var data = $("#" + options.tableId).bootstrapTable('getData');
|
||||
row = typeof data[index] !== 'undefined' ? data[index] : {};
|
||||
}
|
||||
var button = Backend.api.gettablecolumnbutton(options);
|
||||
var click = typeof button.click === 'function' ? button.click : $.noop;
|
||||
|
||||
if (typeof options.confirm !== 'undefined') {
|
||||
Layer.confirm(options.confirm, function (index) {
|
||||
click.apply(that, [options, row, button]);
|
||||
Layer.close(index);
|
||||
});
|
||||
} else {
|
||||
click.apply(that, [options, row, button]);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
//修复含有fixed-footer类的body边距
|
||||
if ($(".fixed-footer").length > 0) {
|
||||
$(document.body).css("padding-bottom", $(".fixed-footer").outerHeight());
|
||||
}
|
||||
//修复不在iframe时layer-footer隐藏的问题
|
||||
if ($(".layer-footer").length > 0 && self === top) {
|
||||
$(".layer-footer").show();
|
||||
}
|
||||
//tooltip和popover
|
||||
if (!('ontouchstart' in document.documentElement)) {
|
||||
$('body').tooltip({selector: '[data-toggle="tooltip"]', trigger: 'hover'});
|
||||
}
|
||||
$('body').popover({selector: '[data-toggle="popover"]'});
|
||||
}
|
||||
};
|
||||
Backend.api = $.extend(Fast.api, Backend.api);
|
||||
//将Template渲染至全局,以便于在子框架中调用
|
||||
window.Template = Template;
|
||||
//将Moment渲染至全局,以便于在子框架中调用
|
||||
window.Moment = Moment;
|
||||
//将Backend渲染至全局,以便于在子框架中调用
|
||||
window.Backend = Backend;
|
||||
|
||||
Backend.init();
|
||||
return Backend;
|
||||
});
|
||||
797
public/assets/js/backend/addon.js
Normal file
797
public/assets/js/backend/addon.js
Normal file
@@ -0,0 +1,797 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie'], function ($, undefined, Backend, Table, Form, Template, undefined) {
|
||||
$.cookie.prototype.defaults = {path: Config.moduleurl};
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: Config.api_url ? Config.api_url + '/addon/index' : "addon/downloaded",
|
||||
add_url: '',
|
||||
edit_url: '',
|
||||
del_url: '',
|
||||
multi_url: ''
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 弹窗自适应宽高
|
||||
var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%'];
|
||||
|
||||
var switch_local = function () {
|
||||
if ($(".btn-switch.active").data("type") != "local") {
|
||||
Layer.confirm(__('Store not available tips'), {
|
||||
title: __('Warmtips'),
|
||||
btn: [__('Switch to the local'), __('Try to reload')]
|
||||
}, function (index) {
|
||||
layer.close(index);
|
||||
$(".panel .nav-tabs").hide();
|
||||
$(".toolbar > *:not(:first)").hide();
|
||||
$(".btn-switch[data-type='local']").trigger("click");
|
||||
}, function (index) {
|
||||
layer.close(index);
|
||||
table.bootstrapTable('refresh');
|
||||
});
|
||||
return false;
|
||||
}
|
||||
};
|
||||
table.on('load-success.bs.table', function (e, json) {
|
||||
if (json && typeof json.category != 'undefined' && $(".nav-category li").length == 2) {
|
||||
$.each(json.category, function (i, j) {
|
||||
$("<li><a href='javascript:;' data-id='" + j.id + "'>" + j.name + "</a></li>").insertBefore($(".nav-category li:last"));
|
||||
});
|
||||
}
|
||||
if (typeof json.rows === 'undefined' && typeof json.code != 'undefined') {
|
||||
switch_local();
|
||||
}
|
||||
});
|
||||
table.on('load-error.bs.table', function (e, status, res) {
|
||||
console.log(e, status, res);
|
||||
switch_local();
|
||||
});
|
||||
table.on('post-body.bs.table', function (e, settings, json, xhr) {
|
||||
var parenttable = table.closest('.bootstrap-table');
|
||||
var d = $(".fixed-table-toolbar", parenttable).find(".search input");
|
||||
d.off("keyup drop blur");
|
||||
d.on("keyup", function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
var that = this;
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
var queryParams = options.queryParams;
|
||||
options.pageNumber = 1;
|
||||
options.queryParams = function (params) {
|
||||
var params = queryParams(params);
|
||||
params.search = $(that).val();
|
||||
return params;
|
||||
};
|
||||
table.bootstrapTable('refresh', {});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Template.helper("Moment", Moment);
|
||||
Template.helper("addons", Config['addons']);
|
||||
|
||||
$("#faupload-addon").data("params", function () {
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
return {
|
||||
uid: userinfo ? userinfo.id : '',
|
||||
token: userinfo ? userinfo.token : '',
|
||||
version: Config.faversion
|
||||
};
|
||||
});
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pageSize: 50,
|
||||
queryParams: function (params) {
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
$.extend(params, {
|
||||
uid: userinfo ? userinfo.id : '',
|
||||
token: userinfo ? userinfo.token : '',
|
||||
domain: Config.domain,
|
||||
version: Config.faversion,
|
||||
sid: Controller.api.sid()
|
||||
});
|
||||
return params;
|
||||
},
|
||||
columns: [
|
||||
[
|
||||
{field: 'id', title: 'ID', operate: false, visible: false},
|
||||
{
|
||||
field: 'home',
|
||||
title: __('Index'),
|
||||
width: '50px',
|
||||
formatter: Controller.api.formatter.home
|
||||
},
|
||||
{field: 'name', title: __('Name'), operate: false, visible: false, width: '120px'},
|
||||
{
|
||||
field: 'title',
|
||||
title: __('Title'),
|
||||
operate: 'LIKE',
|
||||
align: 'left',
|
||||
formatter: Controller.api.formatter.title
|
||||
},
|
||||
{field: 'intro', title: __('Intro'), operate: 'LIKE', align: 'left', class: 'visible-lg'},
|
||||
{
|
||||
field: 'author',
|
||||
title: __('Author'),
|
||||
operate: 'LIKE',
|
||||
width: '100px',
|
||||
formatter: Controller.api.formatter.author
|
||||
},
|
||||
{
|
||||
field: 'price',
|
||||
title: __('Price'),
|
||||
operate: 'LIKE',
|
||||
width: '100px',
|
||||
align: 'center',
|
||||
formatter: Controller.api.formatter.price
|
||||
},
|
||||
{
|
||||
field: 'downloads',
|
||||
title: __('Downloads'),
|
||||
operate: 'LIKE',
|
||||
width: '80px',
|
||||
align: 'center',
|
||||
formatter: Controller.api.formatter.downloads
|
||||
},
|
||||
{
|
||||
field: 'version',
|
||||
title: __('Version'),
|
||||
operate: 'LIKE',
|
||||
width: '80px',
|
||||
align: 'center',
|
||||
formatter: Controller.api.formatter.version
|
||||
},
|
||||
{
|
||||
field: 'toggle',
|
||||
title: __('Status'),
|
||||
width: '80px',
|
||||
formatter: Controller.api.formatter.toggle
|
||||
},
|
||||
{
|
||||
field: 'id',
|
||||
title: __('Operate'),
|
||||
table: table,
|
||||
formatter: Controller.api.formatter.operate,
|
||||
align: 'right'
|
||||
},
|
||||
]
|
||||
],
|
||||
responseHandler: function (res) {
|
||||
$.each(res.rows, function (i, j) {
|
||||
j.addon = typeof Config.addons[j.name] != 'undefined' ? Config.addons[j.name] : null;
|
||||
});
|
||||
return res;
|
||||
},
|
||||
dataType: 'jsonp',
|
||||
templateView: false,
|
||||
clickToSelect: false,
|
||||
search: true,
|
||||
showColumns: false,
|
||||
showToggle: false,
|
||||
showExport: false,
|
||||
showSearch: false,
|
||||
commonSearch: true,
|
||||
searchFormVisible: true,
|
||||
searchFormTemplate: 'searchformtpl',
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
// 离线安装
|
||||
require(['upload'], function (Upload) {
|
||||
Upload.api.upload("#faupload-addon", function (data, ret) {
|
||||
Config['addons'][data.addon.name] = data.addon;
|
||||
var addon = data.addon;
|
||||
var testdata = data.addon.testdata;
|
||||
operate(data.addon.name, 'enable', false, function (data, ret) {
|
||||
Layer.alert(__('Offline installed tips') + (testdata ? __('Testdata tips') : ""), {
|
||||
btn: testdata ? [__('Import testdata'), __('Skip testdata')] : [__('OK')],
|
||||
title: __('Warning'),
|
||||
yes: function (index) {
|
||||
if (testdata) {
|
||||
Fast.api.ajax({
|
||||
url: 'addon/testdata',
|
||||
data: {
|
||||
name: addon.name,
|
||||
version: addon.version,
|
||||
faversion: Config.faversion
|
||||
}
|
||||
}, function (data, ret) {
|
||||
Layer.close(index);
|
||||
});
|
||||
} else {
|
||||
Layer.close(index);
|
||||
}
|
||||
},
|
||||
icon: 1
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}, function (data, ret) {
|
||||
if (ret.msg && ret.msg.match(/(login|登录)/g)) {
|
||||
return Layer.alert(ret.msg, {
|
||||
title: __('Warning'),
|
||||
btn: [__('Login now')],
|
||||
yes: function (index, layero) {
|
||||
$(".btn-userinfo").trigger("click");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 检测是否登录
|
||||
$(document).on("mousedown", "#faupload-addon", function (e) {
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
var uid = userinfo ? userinfo.id : 0;
|
||||
|
||||
if (parseInt(uid) === 0) {
|
||||
$(".btn-userinfo").trigger("click");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 查看插件首页
|
||||
$(document).on("click", ".btn-addonindex", function () {
|
||||
if ($(this).attr("href") == 'javascript:;') {
|
||||
Layer.msg(__('Not installed tips'), {icon: 7});
|
||||
} else if ($(this).closest(".operate").find("a.btn-enable").length > 0) {
|
||||
Layer.msg(__('Not enabled tips'), {icon: 7});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// 切换
|
||||
$(document).on("click", ".btn-switch", function () {
|
||||
$(".btn-switch").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
$("form.form-commonsearch input[name='type']").val($(this).data("type"));
|
||||
var method = $(this).data("type") == 'local' ? 'hideColumn' : 'showColumn';
|
||||
table.bootstrapTable(method, 'price');
|
||||
table.bootstrapTable(method, 'downloads');
|
||||
table.bootstrapTable('refresh', {url: ($(this).data("url") ? $(this).data("url") : $.fn.bootstrapTable.defaults.extend.index_url), pageNumber: 1});
|
||||
return false;
|
||||
});
|
||||
|
||||
// 切换分类
|
||||
$(document).on("click", ".nav-category li a", function () {
|
||||
$(".nav-category li").removeClass("active");
|
||||
$(this).parent().addClass("active");
|
||||
$("form.form-commonsearch input[name='category_id']").val($(this).data("id"));
|
||||
table.bootstrapTable('refresh', {url: $(this).data("url"), pageNumber: 1});
|
||||
return false;
|
||||
});
|
||||
var tables = [];
|
||||
$(document).on("click", "#droptables", function () {
|
||||
if ($(this).prop("checked")) {
|
||||
Fast.api.ajax({
|
||||
url: "addon/get_table_list",
|
||||
async: false,
|
||||
data: {name: $(this).data("name")}
|
||||
}, function (data) {
|
||||
tables = data.tables;
|
||||
return false;
|
||||
});
|
||||
var html;
|
||||
html = tables.length > 0 ? '<div class="alert alert-warning-light droptablestips" style="max-width:480px;max-height:300px;overflow-y: auto;">' + __('The following data tables will be deleted') + ':<br>' + tables.join("<br>") + '</div>'
|
||||
: '<div class="alert alert-warning-light droptablestips">' + __('The Addon did not create a data table') + '</div>';
|
||||
$(html).insertAfter($(this).closest("p"));
|
||||
} else {
|
||||
$(".droptablestips").remove();
|
||||
}
|
||||
$(window).resize();
|
||||
});
|
||||
|
||||
// 会员信息
|
||||
$(document).on("click", ".btn-userinfo", function (e, name, version) {
|
||||
var that = this;
|
||||
var area = [$(window).width() > 800 ? '500px' : '95%', $(window).height() > 600 ? '400px' : '95%'];
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
if (!userinfo) {
|
||||
Fast.api.ajax({
|
||||
url: Config.api_url + '/user/logintpl',
|
||||
type: 'post',
|
||||
loading: false,
|
||||
data: {
|
||||
version: Config.faversion,
|
||||
sid: Controller.api.sid()
|
||||
}
|
||||
}, function (tpldata, ret) {
|
||||
Layer.open({
|
||||
content: Template.render(tpldata, {}),
|
||||
zIndex: 99,
|
||||
area: area,
|
||||
title: __('Login'),
|
||||
resize: false,
|
||||
btn: [__('Login')],
|
||||
yes: function (index, layero) {
|
||||
var data = $("form", layero).serializeArray();
|
||||
data.push({name: "faversion", value: Config.faversion});
|
||||
data.push({name: "sid", value: Controller.api.sid()});
|
||||
Fast.api.ajax({
|
||||
url: Config.api_url + '/user/login',
|
||||
type: 'post',
|
||||
data: data
|
||||
}, function (data, ret) {
|
||||
Controller.api.userinfo.set(data);
|
||||
Layer.closeAll();
|
||||
Layer.alert(ret.msg, {title: __('Warning'), icon: 1});
|
||||
return false;
|
||||
}, function (data, ret) {
|
||||
});
|
||||
},
|
||||
success: function (layero, index) {
|
||||
this.checkEnterKey = function (event) {
|
||||
if (event.keyCode === 13) {
|
||||
$(".layui-layer-btn0").trigger("click");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
$(document).on('keydown', this.checkEnterKey);
|
||||
},
|
||||
end: function () {
|
||||
$(document).off('keydown', this.checkEnterKey);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
Fast.api.ajax({
|
||||
url: Config.api_url + '/user/userinfotpl',
|
||||
type: 'post',
|
||||
data: {
|
||||
uid: userinfo.id,
|
||||
token: userinfo.token,
|
||||
version: Config.faversion,
|
||||
sid: Controller.api.sid()
|
||||
}
|
||||
}, function (tpldata, ret) {
|
||||
Layer.open({
|
||||
content: Template.render(tpldata, userinfo),
|
||||
area: area,
|
||||
title: __('Userinfo'),
|
||||
resize: false,
|
||||
btn: [__('Logout'), __('Close')],
|
||||
yes: function () {
|
||||
Fast.api.ajax({
|
||||
url: Config.api_url + '/user/logout',
|
||||
data: {
|
||||
uid: userinfo.id,
|
||||
token: userinfo.token,
|
||||
version: Config.faversion,
|
||||
sid: Controller.api.sid()
|
||||
}
|
||||
}, function (data, ret) {
|
||||
Controller.api.userinfo.set(null);
|
||||
Layer.closeAll();
|
||||
Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
|
||||
}, function (data, ret) {
|
||||
Controller.api.userinfo.set(null);
|
||||
Layer.closeAll();
|
||||
Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}, function (data) {
|
||||
Controller.api.userinfo.set(null);
|
||||
$(that).trigger('click');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//刷新授权
|
||||
$(document).on("click", ".btn-authorization", function () {
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
if (!userinfo) {
|
||||
$(".btn-userinfo").trigger("click");
|
||||
return false;
|
||||
}
|
||||
Layer.confirm(__('Are you sure you want to refresh authorization?'), {icon: 3, title: __('Warmtips')}, function () {
|
||||
Fast.api.ajax({
|
||||
url: 'addon/authorization',
|
||||
data: {
|
||||
uid: userinfo.id,
|
||||
token: userinfo.token
|
||||
}
|
||||
}, function (data, ret) {
|
||||
$(".btn-refresh").trigger("click");
|
||||
Layer.closeAll();
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
var install = function (name, version, force) {
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
var uid = userinfo ? userinfo.id : 0;
|
||||
var token = userinfo ? userinfo.token : '';
|
||||
Fast.api.ajax({
|
||||
url: 'addon/install',
|
||||
data: {
|
||||
name: name,
|
||||
force: force ? 1 : 0,
|
||||
uid: uid,
|
||||
token: token,
|
||||
version: version,
|
||||
faversion: Config.faversion
|
||||
}
|
||||
}, function (data, ret) {
|
||||
Layer.closeAll();
|
||||
Config['addons'][data.addon.name] = ret.data.addon;
|
||||
operate(data.addon.name, 'enable', false, function () {
|
||||
Layer.alert(__('Online installed tips') + (data.addon.testdata ? __('Testdata tips') : ""), {
|
||||
btn: data.addon.testdata ? [__('Import testdata'), __('Skip testdata')] : [__('OK')],
|
||||
title: __('Warning'),
|
||||
yes: function (index) {
|
||||
if (data.addon.testdata) {
|
||||
Fast.api.ajax({
|
||||
url: 'addon/testdata',
|
||||
data: {
|
||||
name: name,
|
||||
uid: uid,
|
||||
token: token,
|
||||
version: version,
|
||||
faversion: Config.faversion
|
||||
}
|
||||
}, function (data, ret) {
|
||||
Layer.close(index);
|
||||
});
|
||||
} else {
|
||||
Layer.close(index);
|
||||
}
|
||||
},
|
||||
icon: 1
|
||||
});
|
||||
Controller.api.refresh(table, name);
|
||||
});
|
||||
}, function (data, ret) {
|
||||
var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 650 ? '650px' : '95%', $(window).height() > 710 ? '710px' : '95%'];
|
||||
if (ret && ret.code === -2) {
|
||||
//如果登录已经超时,重新提醒登录
|
||||
if (uid && uid != ret.data.uid) {
|
||||
Controller.api.userinfo.set(null);
|
||||
$(".operate[data-name='" + name + "'] .btn-install").trigger("click");
|
||||
return;
|
||||
}
|
||||
top.Fast.api.open(ret.data.payurl, __('Pay now'), {
|
||||
area: area,
|
||||
end: function () {
|
||||
Fast.api.ajax({
|
||||
url: 'addon/isbuy',
|
||||
data: {
|
||||
name: name,
|
||||
force: force ? 1 : 0,
|
||||
uid: uid,
|
||||
token: token,
|
||||
version: version,
|
||||
faversion: Config.faversion
|
||||
}
|
||||
}, function () {
|
||||
top.Layer.alert(__('Pay successful tips'), {
|
||||
btn: [__('Continue installation')],
|
||||
title: __('Warning'),
|
||||
icon: 1,
|
||||
yes: function (index) {
|
||||
top.Layer.close(index);
|
||||
install(name, version);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}, function () {
|
||||
console.log(__('Canceled'));
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (ret && ret.code === -3) {
|
||||
//插件目录发现影响全局的文件
|
||||
Layer.open({
|
||||
content: Template("conflicttpl", ret.data),
|
||||
shade: 0.8,
|
||||
area: area,
|
||||
title: __('Warning'),
|
||||
btn: [__('Continue install'), __('Cancel')],
|
||||
end: function () {
|
||||
|
||||
},
|
||||
yes: function () {
|
||||
install(name, version, true);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
var uninstall = function (name, force, droptables) {
|
||||
Fast.api.ajax({
|
||||
url: 'addon/uninstall',
|
||||
data: {name: name, force: force ? 1 : 0, droptables: droptables ? 1 : 0}
|
||||
}, function (data, ret) {
|
||||
delete Config['addons'][name];
|
||||
Layer.closeAll();
|
||||
Controller.api.refresh(table, name);
|
||||
}, function (data, ret) {
|
||||
if (ret && ret.code === -3) {
|
||||
//插件目录发现影响全局的文件
|
||||
Layer.open({
|
||||
content: Template("conflicttpl", ret.data),
|
||||
shade: 0.8,
|
||||
area: area,
|
||||
title: __('Warning'),
|
||||
btn: [__('Continue uninstall'), __('Cancel')],
|
||||
end: function () {
|
||||
|
||||
},
|
||||
yes: function () {
|
||||
uninstall(name, true, droptables);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
var operate = function (name, action, force, success) {
|
||||
Fast.api.ajax({
|
||||
url: 'addon/state',
|
||||
data: {name: name, action: action, force: force ? 1 : 0}
|
||||
}, function (data, ret) {
|
||||
var addon = Config['addons'][name];
|
||||
addon.state = action === 'enable' ? 1 : 0;
|
||||
Layer.closeAll();
|
||||
if (typeof success === 'function') {
|
||||
success(data, ret);
|
||||
}
|
||||
Controller.api.refresh(table, name);
|
||||
}, function (data, ret) {
|
||||
if (ret && ret.code === -3) {
|
||||
//插件目录发现影响全局的文件
|
||||
Layer.open({
|
||||
content: Template("conflicttpl", ret.data),
|
||||
shade: 0.8,
|
||||
area: area,
|
||||
title: __('Warning'),
|
||||
btn: [__('Continue operate'), __('Cancel')],
|
||||
end: function () {
|
||||
|
||||
},
|
||||
yes: function () {
|
||||
operate(name, action, true, success);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
var upgrade = function (name, version) {
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
var uid = userinfo ? userinfo.id : 0;
|
||||
var token = userinfo ? userinfo.token : '';
|
||||
Fast.api.ajax({
|
||||
url: 'addon/upgrade',
|
||||
data: {name: name, uid: uid, token: token, version: version, faversion: Config.faversion}
|
||||
}, function (data, ret) {
|
||||
Config['addons'][name] = data.addon;
|
||||
Layer.closeAll();
|
||||
Controller.api.refresh(table, name);
|
||||
}, function (data, ret) {
|
||||
Layer.alert(ret.msg, {title: __('Warning')});
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
// 点击安装
|
||||
$(document).on("click", ".btn-install", function () {
|
||||
var that = this;
|
||||
var name = $(this).closest(".operate").data("name");
|
||||
var version = $(this).data("version");
|
||||
|
||||
var userinfo = Controller.api.userinfo.get();
|
||||
var uid = userinfo ? userinfo.id : 0;
|
||||
|
||||
if (parseInt(uid) === 0) {
|
||||
$(".btn-userinfo").trigger("click", name, version);
|
||||
return false;
|
||||
}
|
||||
install(name, version, false);
|
||||
});
|
||||
|
||||
// 点击卸载
|
||||
$(document).on("click", ".btn-uninstall", function () {
|
||||
var name = $(this).closest(".operate").data('name');
|
||||
if (Config['addons'][name].state == 1) {
|
||||
Layer.alert(__('Please disable the add before trying to uninstall'), {icon: 7});
|
||||
return false;
|
||||
}
|
||||
Template.helper("__", __);
|
||||
Layer.confirm(Template("uninstalltpl", {addon: Config['addons'][name]}), {focusBtn: false, title: __("Warning")}, function (index, layero) {
|
||||
uninstall(name, false, $("input[name='droptables']", layero).prop("checked"));
|
||||
});
|
||||
});
|
||||
|
||||
// 点击配置
|
||||
$(document).on("click", ".btn-config", function () {
|
||||
var name = $(this).closest(".operate").data("name");
|
||||
Fast.api.open("addon/config?name=" + name, __('Setting'));
|
||||
});
|
||||
|
||||
// 点击启用/禁用
|
||||
$(document).on("click", ".btn-enable,.btn-disable", function () {
|
||||
var name = $(this).data("name");
|
||||
var action = $(this).data("action");
|
||||
operate(name, action, false);
|
||||
});
|
||||
|
||||
// 点击升级
|
||||
$(document).on("click", ".btn-upgrade", function () {
|
||||
var name = $(this).closest(".operate").data('name');
|
||||
if (Config['addons'][name].state == 1) {
|
||||
Layer.alert(__('Please disable the add before trying to upgrade'), {icon: 7});
|
||||
return false;
|
||||
}
|
||||
var version = $(this).data("version");
|
||||
|
||||
Layer.confirm(__('Upgrade tips', Config['addons'][name].title), function (index, layero) {
|
||||
upgrade(name, version);
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", ".operate .btn-group .dropdown-toggle", function () {
|
||||
$(this).closest(".btn-group").toggleClass("dropup", $(document).height() - $(this).offset().top <= 200);
|
||||
});
|
||||
|
||||
$(document).on("click", ".view-screenshots", function () {
|
||||
var row = Table.api.getrowbyindex(table, parseInt($(this).data("index")));
|
||||
var data = [];
|
||||
$.each(row.screenshots, function (i, j) {
|
||||
data.push({
|
||||
"src": j
|
||||
});
|
||||
});
|
||||
var json = {
|
||||
"title": row.title,
|
||||
"data": data
|
||||
};
|
||||
top.Layer.photos(top.JSON.parse(JSON.stringify({photos: json})));
|
||||
});
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
config: function () {
|
||||
$(document).on("click", ".nav-group li a[data-toggle='tab']", function () {
|
||||
if ($(this).attr("href") == "#all") {
|
||||
$(".tab-pane").addClass("active in");
|
||||
}
|
||||
return;
|
||||
var type = $(this).attr("href").substring(1);
|
||||
if (type == 'all') {
|
||||
$(".table-config tr").show();
|
||||
} else {
|
||||
$(".table-config tr").hide();
|
||||
$(".table-config tr[data-group='" + type + "']").show();
|
||||
}
|
||||
});
|
||||
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
formatter: {
|
||||
title: function (value, row, index) {
|
||||
if ($(".btn-switch.active").data("type") == "local") {
|
||||
// return value;
|
||||
}
|
||||
var title = '<a class="title" href="' + row.url + '" data-toggle="tooltip" title="' + __('View addon home page') + '" target="_blank">' + value + '</a>';
|
||||
if (row.screenshots && row.screenshots.length > 0) {
|
||||
title += ' <a href="javascript:;" data-index="' + index + '" class="view-screenshots text-success" title="' + __('View addon screenshots') + '" data-toggle="tooltip"><i class="fa fa-image"></i></a>';
|
||||
}
|
||||
return title;
|
||||
},
|
||||
operate: function (value, row, index) {
|
||||
return Template("operatetpl", {item: row, index: index});
|
||||
},
|
||||
toggle: function (value, row, index) {
|
||||
if (!row.addon) {
|
||||
return '';
|
||||
}
|
||||
return '<a href="javascript:;" data-toggle="tooltip" title="' + __('Click to toggle status') + '" class="btn btn-toggle btn-' + (row.addon.state == 1 ? "disable" : "enable") + '" data-action="' + (row.addon.state == 1 ? "disable" : "enable") + '" data-name="' + row.name + '"><i class="fa ' + (row.addon.state == 0 ? 'fa-toggle-on fa-rotate-180 text-gray' : 'fa-toggle-on text-success') + ' fa-2x"></i></a>';
|
||||
},
|
||||
author: function (value, row, index) {
|
||||
var url = 'javascript:';
|
||||
if (typeof row.homepage !== 'undefined') {
|
||||
url = row.homepage;
|
||||
} else if (typeof row.qq !== 'undefined' && row.qq) {
|
||||
url = 'https://wpa.qq.com/msgrd?v=3&uin=' + row.qq + '&site=&menu=yes';
|
||||
}
|
||||
return '<a href="' + url + '" target="_blank" data-toggle="tooltip" class="text-primary">' + value + '</a>';
|
||||
},
|
||||
price: function (value, row, index) {
|
||||
if (isNaN(value)) {
|
||||
return value;
|
||||
}
|
||||
return parseFloat(value) == 0 ? '<span class="text-success">' + __('Free') + '</span>' : '<span class="text-danger">¥' + value + '</span>';
|
||||
},
|
||||
downloads: function (value, row, index) {
|
||||
return value;
|
||||
},
|
||||
version: function (value, row, index) {
|
||||
return row.addon && row.addon.version != row.version ? '<a href="' + row.url + '?version=' + row.version + '" target="_blank"><span class="releasetips text-primary" data-toggle="tooltip" title="' + __('New version tips', row.version) + '">' + row.addon.version + '<i></i></span></a>' : row.version;
|
||||
},
|
||||
home: function (value, row, index) {
|
||||
return row.addon && parseInt(row.addon.state) > 0 ? '<a href="' + row.addon.url + '" data-toggle="tooltip" title="' + __('View addon index page') + '" target="_blank"><i class="fa fa-home text-primary"></i></a>' : '<a href="javascript:;"><i class="fa fa-home text-gray"></i></a>';
|
||||
},
|
||||
},
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
},
|
||||
userinfo: {
|
||||
get: function () {
|
||||
if (typeof $.cookie !== 'undefined') {
|
||||
var userinfo = $.cookie('fastadmin_userinfo');
|
||||
} else {
|
||||
var userinfo = sessionStorage.getItem("fastadmin_userinfo");
|
||||
}
|
||||
return userinfo ? JSON.parse(userinfo) : null;
|
||||
},
|
||||
set: function (data) {
|
||||
if (typeof $.cookie !== 'undefined') {
|
||||
if (data) {
|
||||
$.cookie("fastadmin_userinfo", JSON.stringify(data));
|
||||
} else {
|
||||
$.removeCookie("fastadmin_userinfo");
|
||||
}
|
||||
} else {
|
||||
if (data) {
|
||||
sessionStorage.setItem("fastadmin_userinfo", JSON.stringify(data));
|
||||
} else {
|
||||
sessionStorage.removeItem("fastadmin_userinfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
sid: function () {
|
||||
var sid = $.cookie('fastadmin_sid');
|
||||
if (!sid) {
|
||||
sid = Math.random().toString(20).substr(2, 12);
|
||||
$.cookie('fastadmin_sid', sid);
|
||||
}
|
||||
return sid;
|
||||
},
|
||||
refresh: function (table, name) {
|
||||
//刷新左侧边栏
|
||||
Fast.api.refreshmenu();
|
||||
|
||||
//刷新行数据
|
||||
if ($(".operate[data-name='" + name + "']").length > 0) {
|
||||
var tr = $(".operate[data-name='" + name + "']").closest("tr[data-index]");
|
||||
var index = tr.data("index");
|
||||
var row = Table.api.getrowbyindex(table, index);
|
||||
row.addon = typeof Config['addons'][name] !== 'undefined' ? Config['addons'][name] : undefined;
|
||||
table.bootstrapTable("updateRow", {index: index, row: row});
|
||||
} else if ($(".btn-switch.active").data("type") == "local") {
|
||||
$(".btn-refresh").trigger("click");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
62
public/assets/js/backend/auth/admin.js
Normal file
62
public/assets/js/backend/auth/admin.js
Normal file
@@ -0,0 +1,62 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'auth/admin/index',
|
||||
add_url: 'auth/admin/add',
|
||||
edit_url: 'auth/admin/edit',
|
||||
del_url: 'auth/admin/del',
|
||||
multi_url: 'auth/admin/multi',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
//在表格内容渲染完成后回调的事件
|
||||
table.on('post-body.bs.table', function (e, json) {
|
||||
$("tbody tr[data-index]", this).each(function () {
|
||||
if (parseInt($("td:eq(1)", this).text()) == Config.admin.id) {
|
||||
$("input[type=checkbox]", this).prop("disabled", true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true, },
|
||||
{field: 'id', title: 'ID'},
|
||||
{field: 'username', title: __('Username')},
|
||||
{field: 'nickname', title: __('Nickname')},
|
||||
{field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
|
||||
{field: 'email', title: __('Email')},
|
||||
{field: 'mobile', title: __('Mobile')},
|
||||
{field: 'status', title: __("Status"), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
|
||||
{field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
|
||||
if(row.id == Config.admin.id){
|
||||
return '';
|
||||
}
|
||||
return Table.api.formatter.operate.call(this, value, row, index);
|
||||
}}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
},
|
||||
edit: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
65
public/assets/js/backend/auth/adminlog.js
Normal file
65
public/assets/js/backend/auth/adminlog.js
Normal file
@@ -0,0 +1,65 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'auth/adminlog/index',
|
||||
add_url: '',
|
||||
edit_url: '',
|
||||
del_url: 'auth/adminlog/del',
|
||||
multi_url: 'auth/adminlog/multi',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true,},
|
||||
{field: 'id', title: 'ID', operate: false},
|
||||
{field: 'admin_id', title: __('Admin_id'), formatter: Table.api.formatter.search, visible: false},
|
||||
{field: 'username', title: __('Username'), formatter: Table.api.formatter.search},
|
||||
{field: 'title', title: __('Title'), operate: 'LIKE %...%', placeholder: '模糊搜索'},
|
||||
{field: 'url', title: __('Url'), formatter: Table.api.formatter.url},
|
||||
{field: 'ip', title: __('IP'), events: Table.api.events.ip, formatter: Table.api.formatter.search},
|
||||
{field: 'browser', title: __('Browser'), operate: false, formatter: Controller.api.formatter.browser},
|
||||
{field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{
|
||||
field: 'operate', title: __('Operate'), table: table,
|
||||
events: Table.api.events.operate,
|
||||
buttons: [{
|
||||
name: 'detail',
|
||||
text: __('Detail'),
|
||||
icon: 'fa fa-list',
|
||||
classname: 'btn btn-info btn-xs btn-detail btn-dialog',
|
||||
url: 'auth/adminlog/detail'
|
||||
}],
|
||||
formatter: Table.api.formatter.operate
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
},
|
||||
formatter: {
|
||||
browser: function (value, row, index) {
|
||||
return '<a class="btn btn-xs btn-browser">' + row.useragent.split(" ")[0] + '</a>';
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
160
public/assets/js/backend/auth/group.js
Normal file
160
public/assets/js/backend/auth/group.js
Normal file
@@ -0,0 +1,160 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ($, undefined, Backend, Table, Form, undefined) {
|
||||
//读取选中的条目
|
||||
$.jstree.core.prototype.get_all_checked = function (full) {
|
||||
var obj = this.get_selected(), i, j;
|
||||
for (i = 0, j = obj.length; i < j; i++) {
|
||||
obj = obj.concat(this.get_node(obj[i]).parents);
|
||||
}
|
||||
obj = $.grep(obj, function (v, i, a) {
|
||||
return v != '#';
|
||||
});
|
||||
obj = obj.filter(function (itm, i, a) {
|
||||
return i == a.indexOf(itm);
|
||||
});
|
||||
return full ? $.map(obj, $.proxy(function (i) {
|
||||
return this.get_node(i);
|
||||
}, this)) : obj;
|
||||
};
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
"index_url": "auth/group/index",
|
||||
"add_url": "auth/group/add",
|
||||
"edit_url": "auth/group/edit",
|
||||
"del_url": "auth/group/del",
|
||||
"multi_url": "auth/group/multi",
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
//在表格内容渲染完成后回调的事件
|
||||
table.on('post-body.bs.table', function (e, json) {
|
||||
$("tbody tr[data-index]", this).each(function () {
|
||||
if (Config.admin.group_ids.indexOf(parseInt(parseInt($("td:eq(1)", this).text()))) > -1) {
|
||||
$("input[type=checkbox]", this).prop("disabled", true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true,},
|
||||
{field: 'id', title: 'ID'},
|
||||
{field: 'pid', title: __('Parent')},
|
||||
{field: 'name', title: __('Name'), align: 'left', formatter:function (value, row, index) {
|
||||
return value.toString().replace(/(&|&)nbsp;/g, ' ');
|
||||
}
|
||||
},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
|
||||
{
|
||||
field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
|
||||
if (Config.admin.group_ids.indexOf(parseInt(row.id)) > -1) {
|
||||
return '';
|
||||
}
|
||||
return Table.api.formatter.operate.call(this, value, row, index);
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
pagination: false,
|
||||
search: false,
|
||||
commonSearch: false,
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);//当内容渲染完成后
|
||||
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"), null, null, function () {
|
||||
if ($("#treeview").length > 0) {
|
||||
var r = $("#treeview").jstree("get_all_checked");
|
||||
$("input[name='row[rules]']").val(r.join(','));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
//渲染权限节点树
|
||||
//变更级别后需要重建节点树
|
||||
$(document).on("change", "select[name='row[pid]']", function () {
|
||||
var pid = $(this).data("pid");
|
||||
var id = $(this).data("id");
|
||||
if ($(this).val() == id) {
|
||||
$("option[value='" + pid + "']", this).prop("selected", true).change();
|
||||
Backend.api.toastr.error(__('Can not change the parent to self'));
|
||||
return false;
|
||||
}
|
||||
$.ajax({
|
||||
url: "auth/group/roletree",
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {id: id, pid: $(this).val()},
|
||||
success: function (ret) {
|
||||
if (ret.hasOwnProperty("code")) {
|
||||
var data = ret.hasOwnProperty("data") && ret.data != "" ? ret.data : "";
|
||||
if (ret.code === 1) {
|
||||
//销毁已有的节点树
|
||||
$("#treeview").jstree("destroy");
|
||||
Controller.api.rendertree(data);
|
||||
} else {
|
||||
Backend.api.toastr.error(ret.msg);
|
||||
}
|
||||
}
|
||||
}, error: function (e) {
|
||||
Backend.api.toastr.error(e.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
//全选和展开
|
||||
$(document).on("click", "#checkall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "check_all" : "uncheck_all");
|
||||
});
|
||||
$(document).on("click", "#expandall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "open_all" : "close_all");
|
||||
});
|
||||
$("select[name='row[pid]']").trigger("change");
|
||||
},
|
||||
rendertree: function (content) {
|
||||
$("#treeview")
|
||||
.on('redraw.jstree', function (e) {
|
||||
$(".layer-footer").attr("domrefresh", Math.random());
|
||||
})
|
||||
.jstree({
|
||||
"themes": {"stripes": true},
|
||||
"checkbox": {
|
||||
"keep_selected_style": false,
|
||||
},
|
||||
"types": {
|
||||
"root": {
|
||||
"icon": "fa fa-folder-open",
|
||||
},
|
||||
"menu": {
|
||||
"icon": "fa fa-folder-open",
|
||||
},
|
||||
"file": {
|
||||
"icon": "fa fa-file-o",
|
||||
}
|
||||
},
|
||||
"plugins": ["checkbox", "types"],
|
||||
"core": {
|
||||
'check_callback': true,
|
||||
"data": content
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
221
public/assets/js/backend/auth/rule.js
Normal file
221
public/assets/js/backend/auth/rule.js
Normal file
@@ -0,0 +1,221 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
"index_url": "auth/rule/index",
|
||||
"add_url": "auth/rule/add",
|
||||
"edit_url": "auth/rule/edit",
|
||||
"del_url": "auth/rule/del",
|
||||
"multi_url": "auth/rule/multi",
|
||||
"table": "auth_rule"
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
sortName: '',
|
||||
escape: false,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true,},
|
||||
{field: 'id', title: 'ID'},
|
||||
{field: 'title', title: __('Title'), align: 'left', formatter: Controller.api.formatter.title, clickToSelect: !false},
|
||||
{field: 'icon', title: __('Icon'), formatter: Controller.api.formatter.icon},
|
||||
{field: 'name', title: __('Name'), align: 'left', formatter: Controller.api.formatter.name},
|
||||
{field: 'weigh', title: __('Weigh')},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
|
||||
{
|
||||
field: 'ismenu',
|
||||
title: __('Ismenu'),
|
||||
align: 'center',
|
||||
table: table,
|
||||
formatter: Table.api.formatter.toggle
|
||||
},
|
||||
{
|
||||
field: 'operate',
|
||||
title: __('Operate'),
|
||||
table: table,
|
||||
events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate
|
||||
}
|
||||
]
|
||||
],
|
||||
pagination: false,
|
||||
search: false,
|
||||
commonSearch: false,
|
||||
rowAttributes: function (row, index) {
|
||||
return row.pid == 0 ? {} : {style: "display:none"};
|
||||
}
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
var btnSuccessEvent = function (data, ret) {
|
||||
if ($(this).hasClass("btn-change")) {
|
||||
var index = $(this).data("index");
|
||||
var row = Table.api.getrowbyindex(table, index);
|
||||
row.ismenu = $("i.fa.text-gray", this).length > 0 ? 1 : 0;
|
||||
table.bootstrapTable("updateRow", {index: index, row: row});
|
||||
} else if ($(this).hasClass("btn-delone")) {
|
||||
if ($(this).closest("tr[data-index]").find("a.btn-node-sub.disabled").length > 0) {
|
||||
$(this).closest("tr[data-index]").remove();
|
||||
} else {
|
||||
table.bootstrapTable('refresh');
|
||||
}
|
||||
} else if ($(this).hasClass("btn-dragsort")) {
|
||||
table.bootstrapTable('refresh');
|
||||
}
|
||||
Fast.api.refreshmenu();
|
||||
return false;
|
||||
};
|
||||
|
||||
//表格内容渲染前
|
||||
table.on('pre-body.bs.table', function (e, data) {
|
||||
var options = table.bootstrapTable("getOptions");
|
||||
options.escape = true;
|
||||
});
|
||||
|
||||
//当内容渲染完成后
|
||||
table.on('post-body.bs.table', function (e, data) {
|
||||
var options = table.bootstrapTable("getOptions");
|
||||
options.escape = false;
|
||||
|
||||
//点击切换/排序/删除操作后刷新左侧菜单
|
||||
$(".btn-change[data-id],.btn-delone,.btn-dragsort").data("success", btnSuccessEvent);
|
||||
|
||||
});
|
||||
|
||||
table.on('post-body.bs.table', function (e, settings, json, xhr) {
|
||||
//显示隐藏子节点
|
||||
$(">tbody>tr[data-index] > td", this).on('click', "a.btn-node-sub", function () {
|
||||
var status = $(this).data("shown") ? true : false;
|
||||
$("a[data-pid='" + $(this).data("id") + "']").each(function () {
|
||||
$(this).closest("tr").toggle(!status);
|
||||
});
|
||||
if (status) {
|
||||
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
||||
}
|
||||
$(this).data("shown", !status);
|
||||
$("i", this).toggleClass("fa-caret-down").toggleClass("fa-caret-right");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
//隐藏子节点
|
||||
$(document).on("collapse", ".btn-node-sub", function () {
|
||||
if ($("i", this).length > 0) {
|
||||
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
||||
}
|
||||
$("i", this).removeClass("fa-caret-down").addClass("fa-caret-right");
|
||||
$(this).data("shown", false);
|
||||
$(this).closest("tr").toggle(false);
|
||||
});
|
||||
|
||||
//批量删除后的回调
|
||||
$(".toolbar > .btn-del,.toolbar .btn-more~ul>li>a").data("success", function (e) {
|
||||
Fast.api.refreshmenu();
|
||||
});
|
||||
|
||||
//展开隐藏一级
|
||||
$(document.body).on("click", ".btn-toggle", function (e) {
|
||||
$("a[data-id][data-pid][data-pid!=0].disabled").closest("tr").hide();
|
||||
var that = this;
|
||||
var show = $("i", that).hasClass("fa-chevron-down");
|
||||
$("i", that).toggleClass("fa-chevron-down", !show).toggleClass("fa-chevron-up", show);
|
||||
$("a[data-id][data-pid][data-pid!=0]").not('.disabled').closest("tr").toggle(show);
|
||||
$(".btn-node-sub[data-pid=0]").data("shown", show);
|
||||
});
|
||||
|
||||
//展开隐藏全部
|
||||
$(document.body).on("click", ".btn-toggle-all", function (e) {
|
||||
var that = this;
|
||||
var show = $("i", that).hasClass("fa-plus");
|
||||
$("i", that).toggleClass("fa-plus", !show).toggleClass("fa-minus", show);
|
||||
$(".btn-node-sub:not([data-pid=0])").closest("tr").toggle(show);
|
||||
$(".btn-node-sub").data("shown", show);
|
||||
$(".btn-node-sub > i").toggleClass("fa-caret-down", show).toggleClass("fa-caret-right", !show);
|
||||
});
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
formatter: {
|
||||
title: function (value, row, index) {
|
||||
value = value.toString().replace(/(&|&)nbsp;/g, ' ');
|
||||
var caret = row.haschild == 1 || row.ismenu == 1 ? '<i class="fa fa-caret-right"></i>' : '';
|
||||
value = value.indexOf(" ") > -1 ? value.replace(/(.*) /, "$1" + caret) : caret + value;
|
||||
|
||||
value = !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
|
||||
return '<a href="javascript:;" data-id="' + row.id + '" data-pid="' + row.pid + '" class="'
|
||||
+ (row.haschild == 1 || row.ismenu == 1 ? 'text-primary' : 'disabled') + ' btn-node-sub">' + value + '</a>';
|
||||
},
|
||||
name: function (value, row, index) {
|
||||
return !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
|
||||
},
|
||||
icon: function (value, row, index) {
|
||||
return '<span class="' + (!row.ismenu || row.status == 'hidden' ? 'text-muted' : '') + '"><i class="' + value + '"></i></span>';
|
||||
}
|
||||
},
|
||||
bindevent: function () {
|
||||
$(document).on('click', "input[name='row[ismenu]']", function () {
|
||||
var name = $("input[name='row[name]']");
|
||||
var ismenu = $(this).val() == 1;
|
||||
name.prop("placeholder", ismenu ? name.data("placeholder-menu") : name.data("placeholder-node"));
|
||||
$('div[data-type="menu"]').toggleClass("hidden", !ismenu);
|
||||
});
|
||||
$("input[name='row[ismenu]']:checked").trigger("click");
|
||||
|
||||
var iconlist = [];
|
||||
var iconfunc = function () {
|
||||
Layer.open({
|
||||
type: 1,
|
||||
area: ['99%', '98%'], //宽高
|
||||
content: Template('chooseicontpl', {iconlist: iconlist})
|
||||
});
|
||||
};
|
||||
Form.api.bindevent($("form[role=form]"), function (data) {
|
||||
Fast.api.refreshmenu();
|
||||
});
|
||||
$(document).on('change keyup', "#icon", function () {
|
||||
$(this).prev().find("i").prop("class", $(this).val());
|
||||
});
|
||||
$(document).on('click', ".btn-search-icon", function () {
|
||||
if (iconlist.length == 0) {
|
||||
$.get(Config.site.cdnurl + "/assets/libs/font-awesome/less/variables.less", function (ret) {
|
||||
var exp = /fa-var-(.*):/ig;
|
||||
var result;
|
||||
while ((result = exp.exec(ret)) != null) {
|
||||
iconlist.push(result[1]);
|
||||
}
|
||||
iconfunc();
|
||||
});
|
||||
} else {
|
||||
iconfunc();
|
||||
}
|
||||
});
|
||||
$(document).on('click', '#chooseicon ul li', function () {
|
||||
$("input[name='row[icon]']").val('fa fa-' + $(this).data("font")).trigger("change");
|
||||
Layer.closeAll();
|
||||
});
|
||||
$(document).on('keyup', 'input.js-icon-search', function () {
|
||||
$("#chooseicon ul li").show();
|
||||
if ($(this).val() != '') {
|
||||
$("#chooseicon ul li:not([data-font*='" + $(this).val() + "'])").hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
93
public/assets/js/backend/category.js
Normal file
93
public/assets/js/backend/category.js
Normal file
@@ -0,0 +1,93 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'category/index',
|
||||
add_url: 'category/add',
|
||||
edit_url: 'category/edit',
|
||||
del_url: 'category/del',
|
||||
multi_url: 'category/multi',
|
||||
dragsort_url: 'ajax/weigh',
|
||||
table: 'category',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
var tableOptions = {
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'weigh',
|
||||
pagination: false,
|
||||
commonSearch: false,
|
||||
search: false,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'type', title: __('Type'), operate: false, searchList: Config.searchList, formatter: Table.api.formatter.label},
|
||||
{field: 'name', title: __('Name'), align: 'left', formatter:function (value, row, index) {
|
||||
return value.toString().replace(/(&|&)nbsp;/g, ' ');
|
||||
}
|
||||
},
|
||||
{field: 'nickname', title: __('Nickname')},
|
||||
{field: 'flag', title: __('Flag'), formatter: Table.api.formatter.flag},
|
||||
{field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
|
||||
{field: 'weigh', title: __('Weigh')},
|
||||
{field: 'status', title: __('Status'), operate: false, formatter: Table.api.formatter.status},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
};
|
||||
// 初始化表格
|
||||
table.bootstrapTable(tableOptions);
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
//绑定TAB事件
|
||||
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||
// var options = table.bootstrapTable(tableOptions);
|
||||
var typeStr = $(this).attr("href").replace('#', '');
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
options.pageNumber = 1;
|
||||
options.queryParams = function (params) {
|
||||
// params.filter = JSON.stringify({type: typeStr});
|
||||
params.type = typeStr;
|
||||
|
||||
return params;
|
||||
};
|
||||
table.bootstrapTable('refresh', {});
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
//必须默认触发shown.bs.tab事件
|
||||
// $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
|
||||
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
setTimeout(function () {
|
||||
$("#c-type").trigger("change");
|
||||
}, 100);
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
$(document).on("change", "#c-type", function () {
|
||||
$("#c-pid option[data-type='all']").prop("selected", true);
|
||||
$("#c-pid option").removeClass("hide");
|
||||
$("#c-pid option[data-type!='" + $(this).val() + "'][data-type!='all']").addClass("hide");
|
||||
$("#c-pid").data("selectpicker") && $("#c-pid").selectpicker("refresh");
|
||||
});
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
80
public/assets/js/backend/dashboard.js
Normal file
80
public/assets/js/backend/dashboard.js
Normal file
@@ -0,0 +1,80 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echarts-theme', 'template'], function ($, undefined, Backend, Datatable, Table, Echarts, undefined, Template) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 基于准备好的dom,初始化echarts实例
|
||||
var myChart = Echarts.init(document.getElementById('echart'), 'walden');
|
||||
|
||||
// 指定图表的配置项和数据
|
||||
var option = {
|
||||
title: {
|
||||
text: '',
|
||||
subtext: ''
|
||||
},
|
||||
color: [
|
||||
"#18d1b1",
|
||||
"#3fb1e3",
|
||||
"#626c91",
|
||||
"#a0a7e6",
|
||||
"#c4ebad",
|
||||
"#96dee8"
|
||||
],
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
legend: {
|
||||
data: [__('Register user')]
|
||||
},
|
||||
toolbox: {
|
||||
show: false,
|
||||
feature: {
|
||||
magicType: {show: true, type: ['stack', 'tiled']},
|
||||
saveAsImage: {show: true}
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: Config.column
|
||||
},
|
||||
yAxis: {},
|
||||
grid: [{
|
||||
left: 'left',
|
||||
top: 'top',
|
||||
right: '10',
|
||||
bottom: 30
|
||||
}],
|
||||
series: [{
|
||||
name: __('Register user'),
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
areaStyle: {
|
||||
normal: {}
|
||||
},
|
||||
lineStyle: {
|
||||
normal: {
|
||||
width: 1.5
|
||||
}
|
||||
},
|
||||
data: Config.userdata
|
||||
}]
|
||||
};
|
||||
|
||||
// 使用刚指定的配置项和数据显示图表。
|
||||
myChart.setOption(option);
|
||||
|
||||
$(window).resize(function () {
|
||||
myChart.resize();
|
||||
});
|
||||
|
||||
$(document).on("click", ".btn-refresh", function () {
|
||||
setTimeout(function () {
|
||||
myChart.resize();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
return Controller;
|
||||
});
|
||||
261
public/assets/js/backend/general/attachment.js
Normal file
261
public/assets/js/backend/general/attachment.js
Normal file
@@ -0,0 +1,261 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'general/attachment/index',
|
||||
add_url: 'general/attachment/add',
|
||||
edit_url: 'general/attachment/edit',
|
||||
del_url: 'general/attachment/del',
|
||||
multi_url: 'general/attachment/multi',
|
||||
table: 'attachment'
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'category', title: __('Category'), operate: 'in', formatter: Table.api.formatter.label, searchList: Config.categoryList},
|
||||
{field: 'admin_id', title: __('Admin_id'), visible: false, addClass: "selectpage", extend: "data-source='auth/admin/index' data-field='nickname'"},
|
||||
{field: 'user_id', title: __('User_id'), visible: false, addClass: "selectpage", extend: "data-source='user/user/index' data-field='nickname'"},
|
||||
{field: 'preview', title: __('Preview'), formatter: Controller.api.formatter.thumb, operate: false},
|
||||
{field: 'url', title: __('Url'), formatter: Controller.api.formatter.url, visible: false},
|
||||
{field: 'filename', title: __('Filename'), sortable: true, formatter: Controller.api.formatter.filename, operate: 'like'},
|
||||
{
|
||||
field: 'filesize', title: __('Filesize'), operate: 'BETWEEN', sortable: true, formatter: function (value, row, index) {
|
||||
var size = parseFloat(value);
|
||||
var i = Math.floor(Math.log(size) / Math.log(1024));
|
||||
return (size / Math.pow(1024, i)).toFixed(i < 2 ? 0 : 2) * 1 + ' ' + ['B', 'KB', 'MB', 'GB', 'TB'][i];
|
||||
}
|
||||
},
|
||||
{field: 'imagewidth', title: __('Imagewidth'), sortable: true},
|
||||
{field: 'imageheight', title: __('Imageheight'), sortable: true},
|
||||
{field: 'imagetype', title: __('Imagetype'), sortable: true, formatter: Table.api.formatter.search, operate: 'like'},
|
||||
{field: 'storage', title: __('Storage'), formatter: Table.api.formatter.search, operate: 'like'},
|
||||
{field: 'mimetype', title: __('Mimetype'), formatter: Controller.api.formatter.mimetype},
|
||||
{
|
||||
field: 'createtime',
|
||||
title: __('Createtime'),
|
||||
formatter: Table.api.formatter.datetime,
|
||||
operate: 'RANGE',
|
||||
addclass: 'datetimerange',
|
||||
sortable: true,
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
field: 'operate',
|
||||
title: __('Operate'),
|
||||
table: table,
|
||||
events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate
|
||||
}
|
||||
]
|
||||
],
|
||||
});
|
||||
|
||||
// 绑定过滤事件
|
||||
$('.filter-type ul li a', table.closest(".panel-intro")).on('click', function (e) {
|
||||
$(this).closest("ul").find("li").removeClass("active");
|
||||
$(this).closest("li").addClass("active");
|
||||
var field = 'mimetype';
|
||||
var value = $(this).data("value") || '';
|
||||
var object = $("[name='" + field + "']", table.closest(".bootstrap-table").find(".commonsearch-table"));
|
||||
if (object.prop('tagName') == "SELECT") {
|
||||
$("option[value='" + value + "']", object).prop("selected", true);
|
||||
} else {
|
||||
object.val(value);
|
||||
}
|
||||
table.trigger("uncheckbox");
|
||||
table.bootstrapTable('refresh', {pageNumber: 1});
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
// 附件归类
|
||||
$(document).on('click', '.btn-classify', function () {
|
||||
var ids = Table.api.selectedids(table);
|
||||
Layer.open({
|
||||
title: __('Classify'),
|
||||
content: Template("typetpl", {}),
|
||||
btn: [__('OK')],
|
||||
yes: function (index, layero) {
|
||||
var category = $("select[name='category']", layero).val();
|
||||
Fast.api.ajax({
|
||||
url: "general/attachment/classify",
|
||||
type: "post",
|
||||
data: {category: category, ids: ids.join(',')},
|
||||
}, function () {
|
||||
table.bootstrapTable('refresh', {});
|
||||
Layer.close(index);
|
||||
});
|
||||
},
|
||||
success: function (layero, index) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
select: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'general/attachment/select',
|
||||
}
|
||||
});
|
||||
var urlArr = [];
|
||||
var multiple = Backend.api.query('multiple');
|
||||
multiple = multiple == 'true' ? true : false;
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table', function (e, row) {
|
||||
if (e.type == 'check' || e.type == 'uncheck') {
|
||||
row = [row];
|
||||
} else {
|
||||
urlArr = [];
|
||||
}
|
||||
$.each(row, function (i, j) {
|
||||
if (e.type.indexOf("uncheck") > -1) {
|
||||
var index = urlArr.indexOf(j.url);
|
||||
if (index > -1) {
|
||||
urlArr.splice(index, 1);
|
||||
}
|
||||
} else {
|
||||
urlArr.indexOf(j.url) == -1 && urlArr.push(j.url);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
sortName: 'id',
|
||||
showToggle: false,
|
||||
showExport: false,
|
||||
maintainSelected: true,
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: multiple, visible: multiple, operate: false},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'category', title: __('Category'), operate: 'in', formatter: Table.api.formatter.label, searchList: Config.categoryList},
|
||||
{field: 'admin_id', title: __('Admin_id'), formatter: Table.api.formatter.search, visible: false},
|
||||
{field: 'user_id', title: __('User_id'), formatter: Table.api.formatter.search, visible: false},
|
||||
{field: 'url', title: __('Preview'), formatter: Controller.api.formatter.thumb, operate: false},
|
||||
{field: 'filename', title: __('Filename'), sortable: true, formatter: Controller.api.formatter.filename, operate: 'like'},
|
||||
{field: 'imagewidth', title: __('Imagewidth'), operate: false, sortable: true},
|
||||
{field: 'imageheight', title: __('Imageheight'), operate: false, sortable: true},
|
||||
{
|
||||
field: 'mimetype', title: __('Mimetype'), sortable: true, operate: 'LIKE %...%',
|
||||
process: function (value, arg) {
|
||||
return value.replace(/\*/g, '%');
|
||||
},
|
||||
formatter: Controller.api.formatter.mimetype
|
||||
},
|
||||
{field: 'createtime', title: __('Createtime'), width: 120, formatter: Table.api.formatter.datetime, datetimeFormat: 'YYYY-MM-DD', operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{
|
||||
field: 'operate', title: __('Operate'), width: 85, events: {
|
||||
'click .btn-chooseone': function (e, value, row, index) {
|
||||
Fast.api.close({url: row.url, multiple: multiple});
|
||||
},
|
||||
}, formatter: function () {
|
||||
return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 绑定过滤事件
|
||||
$('.filter-type ul li a', table.closest(".panel-intro")).on('click', function (e) {
|
||||
$(this).closest("ul").find("li").removeClass("active");
|
||||
$(this).closest("li").addClass("active");
|
||||
var field = 'mimetype';
|
||||
var value = $(this).data("value") || '';
|
||||
var object = $("[name='" + field + "']", table.closest(".bootstrap-table").find(".commonsearch-table"));
|
||||
if (object.prop('tagName') == "SELECT") {
|
||||
$("option[value='" + value + "']", object).prop("selected", true);
|
||||
} else {
|
||||
object.val(value);
|
||||
}
|
||||
table.trigger("uncheckbox");
|
||||
table.bootstrapTable('refresh', {pageNumber: 1});
|
||||
});
|
||||
|
||||
// 选中多个
|
||||
$(document).on("click", ".btn-choose-multi", function () {
|
||||
Fast.api.close({url: urlArr.join(","), multiple: multiple});
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
require(['upload'], function (Upload) {
|
||||
$("#toolbar .faupload").data("category", function (file) {
|
||||
var category = $("ul.nav-tabs[data-field='category'] li.active a").data("value");
|
||||
return category;
|
||||
});
|
||||
Upload.api.upload($("#toolbar .faupload"), function () {
|
||||
$(".btn-refresh").trigger("click");
|
||||
});
|
||||
});
|
||||
},
|
||||
add: function () {
|
||||
//上传完成后刷新父窗口
|
||||
$(".faupload").data("upload-complete", function (files) {
|
||||
setTimeout(function () {
|
||||
window.parent.$(".btn-refresh").trigger("click");
|
||||
}, 100);
|
||||
});
|
||||
// 获取上传类别
|
||||
$("#faupload-third,#faupload-third-chunking").data("category", function (file) {
|
||||
return $("#category-third").val();
|
||||
});
|
||||
// 获取上传类别
|
||||
$("#faupload-local,#faupload-local-chunking").data("category", function (file) {
|
||||
return $("#category-local").val();
|
||||
});
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
},
|
||||
formatter: {
|
||||
thumb: function (value, row, index) {
|
||||
var html = '';
|
||||
if (row.mimetype.indexOf("image") > -1) {
|
||||
html = '<a href="' + row.fullurl + '" target="_blank"><img src="' + row.fullurl + row.thumb_style + '" alt="" style="max-height:60px;max-width:120px"></a>';
|
||||
} else {
|
||||
html = '<a href="' + row.fullurl + '" target="_blank"><img src="' + Fast.api.fixurl("ajax/icon") + "?suffix=" + row.imagetype + '" alt="" style="max-height:90px;max-width:120px"></a>';
|
||||
}
|
||||
return '<div style="width:120px;margin:0 auto;text-align:center;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">' + html + '</div>';
|
||||
},
|
||||
url: function (value, row, index) {
|
||||
return '<a href="' + row.fullurl + '" target="_blank" class="label bg-green">' + row.url + '</a>';
|
||||
},
|
||||
filename: function (value, row, index) {
|
||||
return '<div style="width:150px;margin:0 auto;text-align:center;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">' + Table.api.formatter.search.call(this, value, row, index) + '</div>';
|
||||
},
|
||||
mimetype: function (value, row, index) {
|
||||
return '<div style="width:80px;margin:0 auto;text-align:center;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">' + Table.api.formatter.search.call(this, value, row, index) + '</div>';
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
140
public/assets/js/backend/general/config.js
Normal file
140
public/assets/js/backend/general/config.js
Normal file
@@ -0,0 +1,140 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
$("form.edit-form").data("validator-options", {
|
||||
display: function (elem) {
|
||||
return $(elem).closest('tr').find("td:first").text();
|
||||
}
|
||||
});
|
||||
Form.api.bindevent($("form.edit-form"));
|
||||
|
||||
//不可见的元素不验证
|
||||
$("form#add-form").data("validator-options", {
|
||||
ignore: ':hidden',
|
||||
rules: {
|
||||
content: function () {
|
||||
return ['radio', 'checkbox', 'select', 'selects'].indexOf($("#add-form select[name='row[type]']").val()) > -1;
|
||||
},
|
||||
extend: function () {
|
||||
return $("#add-form select[name='row[type]']").val() == 'custom';
|
||||
}
|
||||
}
|
||||
});
|
||||
Form.api.bindevent($("form#add-form"), function (ret) {
|
||||
setTimeout(function () {
|
||||
location.reload();
|
||||
}, 1500);
|
||||
});
|
||||
|
||||
//渲染关联显示字段和存储字段
|
||||
var renderselect = function (id, data, defaultvalue) {
|
||||
var html = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
html.push("<option value='" + data[i].name + "' " + (defaultvalue == data[i].name ? "selected" : "") + " data-subtext='" + data[i].title + "'>" + data[i].name + "</option>");
|
||||
}
|
||||
var select = $(id);
|
||||
$(select).html(html.join(""));
|
||||
select.trigger("change");
|
||||
if (select.data("selectpicker")) {
|
||||
select.selectpicker('refresh');
|
||||
}
|
||||
};
|
||||
//关联表切换
|
||||
$(document).on('change', "#c-selectpage-table", function (e, first) {
|
||||
var that = this;
|
||||
Fast.api.ajax({
|
||||
url: "general/config/get_fields_list",
|
||||
data: {table: $(that).val()},
|
||||
}, function (data, ret) {
|
||||
renderselect("#c-selectpage-primarykey", data.fieldList, first ? $("#c-selectpage-primarykey").data("value") : '');
|
||||
renderselect("#c-selectpage-field", data.fieldList, first ? $("#c-selectpage-field").data("value") : '');
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
});
|
||||
//如果编辑模式则渲染已知数据
|
||||
if (['selectpage', 'selectpages'].indexOf($("#c-type").val()) > -1) {
|
||||
$("#c-selectpage-table").trigger("change", true);
|
||||
}
|
||||
|
||||
//切换类型时
|
||||
$(document).on("change", "#c-type", function () {
|
||||
var value = $(this).val();
|
||||
$(".tf").addClass("hidden");
|
||||
$(".tf.tf-" + value).removeClass("hidden");
|
||||
if (["selectpage", "selectpages"].indexOf(value) > -1 && $("#c-selectpage-table option").length == 1) {
|
||||
//异步加载表列表
|
||||
Fast.api.ajax({
|
||||
url: "general/config/get_table_list",
|
||||
}, function (data, ret) {
|
||||
renderselect("#c-selectpage-table", data.tableList);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//切换显示隐藏变量字典列表
|
||||
$(document).on("change", "form#add-form select[name='row[type]']", function (e) {
|
||||
$("#add-content-container").toggleClass("hide", ['select', 'selects', 'checkbox', 'radio'].indexOf($(this).val()) > -1 ? false : true);
|
||||
});
|
||||
|
||||
//选择规则
|
||||
$(document).on("click", ".rulelist > li > a", function () {
|
||||
var ruleArr = $("#rule").val() == '' ? [] : $("#rule").val().split(";");
|
||||
var rule = $(this).data("value");
|
||||
var index = ruleArr.indexOf(rule);
|
||||
if (index > -1) {
|
||||
ruleArr.splice(index, 1);
|
||||
} else {
|
||||
ruleArr.push(rule);
|
||||
}
|
||||
$("#rule").val(ruleArr.join(";"));
|
||||
$(this).parent().toggleClass("active");
|
||||
});
|
||||
|
||||
//添加向发件人发送测试邮件按钮和方法
|
||||
$('input[name="row[mail_from]"]').parent().next().append('<a class="btn btn-info testmail">' + __('Send a test message') + '</a>');
|
||||
$(document).on("click", ".testmail", function () {
|
||||
var that = this;
|
||||
Layer.prompt({title: __('Please input your email'), formType: 0}, function (value, index) {
|
||||
Backend.api.ajax({
|
||||
url: "general/config/emailtest",
|
||||
data: $(that).closest("form").serialize() + "&receiver=" + value
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
//删除配置
|
||||
$(document).on("click", ".btn-delcfg", function () {
|
||||
var that = this;
|
||||
Layer.confirm(__('Are you sure you want to delete this item?'), {
|
||||
icon: 3,
|
||||
title: '提示'
|
||||
}, function (index) {
|
||||
Backend.api.ajax({
|
||||
url: "general/config/del",
|
||||
data: {name: $(that).data("name")}
|
||||
}, function () {
|
||||
$(that).closest("tr").remove();
|
||||
Layer.close(index);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
57
public/assets/js/backend/general/profile.js
Normal file
57
public/assets/js/backend/general/profile.js
Normal file
@@ -0,0 +1,57 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'upload'], function ($, undefined, Backend, Table, Form, Upload) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
search: true,
|
||||
advancedSearch: true,
|
||||
pagination: true,
|
||||
extend: {
|
||||
"index_url": "general/profile/index",
|
||||
"add_url": "",
|
||||
"edit_url": "",
|
||||
"del_url": "",
|
||||
"multi_url": "",
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
columns: [
|
||||
[
|
||||
{field: 'id', title: 'ID'},
|
||||
{field: 'title', title: __('Title')},
|
||||
{field: 'url', title: __('Url'), align: 'left', formatter: Table.api.formatter.url},
|
||||
{field: 'ip', title: __('ip'), formatter:Table.api.formatter.search},
|
||||
{field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
]
|
||||
],
|
||||
commonSearch: false
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);//当内容渲染完成后
|
||||
|
||||
// 给上传按钮添加上传成功事件
|
||||
$("#faupload-avatar").data("upload-success", function (data) {
|
||||
var url = Backend.api.cdnurl(data.url);
|
||||
$(".profile-user-img").prop("src", url);
|
||||
Toastr.success("上传成功!");
|
||||
});
|
||||
|
||||
// 给表单绑定事件
|
||||
Form.api.bindevent($("#update-form"), function () {
|
||||
$("input[name='row[password]']").val('');
|
||||
var url = Backend.api.cdnurl($("#c-avatar").val());
|
||||
top.window.$(".user-panel .image img,.user-menu > a > img,.user-header > img").prop("src", url);
|
||||
return true;
|
||||
});
|
||||
},
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
421
public/assets/js/backend/index.js
Normal file
421
public/assets/js/backend/index.js
Normal file
@@ -0,0 +1,421 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'addtabs', 'adminlte', 'form'], function ($, undefined, Backend, undefined, AdminLTE, Form) {
|
||||
var Controller = {
|
||||
index: function () {
|
||||
//双击重新加载页面
|
||||
$(document).on("dblclick", ".sidebar-menu li > a", function (e) {
|
||||
$("#con_" + $(this).attr("addtabs") + " iframe").attr('src', function (i, val) {
|
||||
return val;
|
||||
});
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
//修复在移除窗口时下拉框不隐藏的BUG
|
||||
$(window).on("blur", function () {
|
||||
$("[data-toggle='dropdown']").parent().removeClass("open");
|
||||
if ($("body").hasClass("sidebar-open")) {
|
||||
$(".sidebar-toggle").trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
//快捷搜索
|
||||
$(".menuresult").width($("form.sidebar-form > .input-group").width());
|
||||
var searchResult = $(".menuresult");
|
||||
$("form.sidebar-form").on("blur", "input[name=q]", function () {
|
||||
searchResult.addClass("hide");
|
||||
}).on("focus", "input[name=q]", function () {
|
||||
if ($("a", searchResult).length > 0) {
|
||||
searchResult.removeClass("hide");
|
||||
}
|
||||
}).on("keyup", "input[name=q]", function () {
|
||||
searchResult.html('');
|
||||
var val = $(this).val();
|
||||
var html = [];
|
||||
if (val != '') {
|
||||
$("ul.sidebar-menu li a[addtabs]:not([href^='javascript:;'])").each(function () {
|
||||
if ($("span:first", this).text().indexOf(val) > -1 || $(this).attr("py").indexOf(val) > -1 || $(this).attr("pinyin").indexOf(val) > -1) {
|
||||
html.push('<a data-url="' + $(this).attr("href") + '" href="javascript:;">' + $("span:first", this).text() + '</a>');
|
||||
if (html.length >= 100) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$(searchResult).append(html.join(""));
|
||||
if (html.length > 0) {
|
||||
searchResult.removeClass("hide");
|
||||
} else {
|
||||
searchResult.addClass("hide");
|
||||
}
|
||||
});
|
||||
//快捷搜索点击事件
|
||||
$("form.sidebar-form").on('mousedown click', '.menuresult a[data-url]', function () {
|
||||
Backend.api.addtabs($(this).data("url"));
|
||||
});
|
||||
|
||||
//切换左侧sidebar显示隐藏
|
||||
$(document).on("click fa.event.toggleitem", ".sidebar-menu li > a", function (e) {
|
||||
var nextul = $(this).next("ul");
|
||||
if (nextul.length == 0 && (!$(this).parent("li").hasClass("treeview") || ($("body").hasClass("multiplenav") && $(this).parent().parent().hasClass("sidebar-menu")))) {
|
||||
$(".sidebar-menu li").not($(this).parents("li")).removeClass("active");
|
||||
}
|
||||
//当外部触发隐藏的a时,触发父辈a的事件
|
||||
if (!$(this).closest("ul").is(":visible")) {
|
||||
//如果不需要左侧的菜单栏联动可以注释下面一行即可
|
||||
$(this).closest("ul").prev().trigger("click");
|
||||
}
|
||||
|
||||
var visible = nextul.is(":visible");
|
||||
if (nextul.length == 0) {
|
||||
$(this).parents("li").addClass("active");
|
||||
$(this).closest(".treeview").addClass("treeview-open");
|
||||
} else {
|
||||
}
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
//清除缓存
|
||||
$(document).on('click', "ul.wipecache li a,a.wipecache", function () {
|
||||
$.ajax({
|
||||
url: 'ajax/wipecache',
|
||||
dataType: 'json',
|
||||
data: {type: $(this).data("type")},
|
||||
cache: false,
|
||||
success: function (ret) {
|
||||
if (ret.hasOwnProperty("code")) {
|
||||
var msg = ret.hasOwnProperty("msg") && ret.msg != "" ? ret.msg : "";
|
||||
if (ret.code === 1) {
|
||||
Toastr.success(msg ? msg : __('Wipe cache completed'));
|
||||
} else {
|
||||
Toastr.error(msg ? msg : __('Wipe cache failed'));
|
||||
}
|
||||
} else {
|
||||
Toastr.error(__('Unknown data format'));
|
||||
}
|
||||
}, error: function () {
|
||||
Toastr.error(__('Network error'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//全屏事件
|
||||
$(document).on('click', "[data-toggle='fullscreen']", function () {
|
||||
var doc = document.documentElement;
|
||||
if ($(document.body).hasClass("full-screen")) {
|
||||
$(document.body).removeClass("full-screen");
|
||||
document.exitFullscreen ? document.exitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen && document.webkitExitFullscreen();
|
||||
} else {
|
||||
$(document.body).addClass("full-screen");
|
||||
doc.requestFullscreen ? doc.requestFullscreen() : doc.mozRequestFullScreen ? doc.mozRequestFullScreen() : doc.webkitRequestFullscreen ? doc.webkitRequestFullscreen() : doc.msRequestFullscreen && doc.msRequestFullscreen();
|
||||
}
|
||||
});
|
||||
|
||||
var multiplenav = $("body").hasClass("multiplenav") > 0 ? true : false;
|
||||
var firstnav = $("#firstnav .nav-addtabs");
|
||||
var nav = multiplenav ? $("#secondnav .nav-addtabs") : firstnav;
|
||||
|
||||
//刷新菜单事件
|
||||
$(document).on('refresh', '.sidebar-menu', function () {
|
||||
Fast.api.ajax({
|
||||
url: 'index/index',
|
||||
data: {action: 'refreshmenu'},
|
||||
loading: false
|
||||
}, function (data) {
|
||||
$(".sidebar-menu li:not([data-rel='external'])").remove();
|
||||
$(".sidebar-menu").prepend(data.menulist);
|
||||
if (multiplenav) {
|
||||
firstnav.html(data.navlist);
|
||||
}
|
||||
$("li[role='presentation'].active a", nav).trigger('click');
|
||||
$(window).trigger("resize");
|
||||
return false;
|
||||
}, function () {
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
if (multiplenav) {
|
||||
firstnav.css("overflow", "inherit");
|
||||
//一级菜单自适应
|
||||
$(window).resize(function () {
|
||||
var siblingsWidth = 0;
|
||||
firstnav.siblings().each(function () {
|
||||
siblingsWidth += $(this).outerWidth();
|
||||
});
|
||||
firstnav.width(firstnav.parent().width() - siblingsWidth);
|
||||
firstnav.refreshAddtabs();
|
||||
});
|
||||
|
||||
//点击顶部第一级菜单栏
|
||||
firstnav.on("click", "li a", function () {
|
||||
$("li", firstnav).removeClass("active");
|
||||
$(this).closest("li").addClass("active");
|
||||
$(".sidebar-menu > li[pid]").addClass("hidden");
|
||||
if ($(this).attr("url") == "javascript:;") {
|
||||
var sonlist = $(".sidebar-menu > li[pid='" + $(this).attr("addtabs") + "']");
|
||||
sonlist.removeClass("hidden");
|
||||
var sidenav;
|
||||
var last_id = $(this).attr("last-id");
|
||||
if (last_id) {
|
||||
sidenav = $(".sidebar-menu > li[pid='" + $(this).attr("addtabs") + "'] a[addtabs='" + last_id + "']");
|
||||
} else {
|
||||
sidenav = $(".sidebar-menu > li[pid='" + $(this).attr("addtabs") + "']:first > a");
|
||||
}
|
||||
if (sidenav) {
|
||||
sidenav.attr("href") != "javascript:;" && sidenav.trigger('click');
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
var mobilenav = $(".mobilenav");
|
||||
$("#firstnav .nav-addtabs li a").each(function () {
|
||||
mobilenav.append($(this).clone().addClass("btn btn-app"));
|
||||
});
|
||||
|
||||
//点击移动端一级菜单
|
||||
mobilenav.on("click", "a", function () {
|
||||
$("a", mobilenav).removeClass("active");
|
||||
$(this).addClass("active");
|
||||
$(".sidebar-menu > li[pid]").addClass("hidden");
|
||||
if ($(this).attr("url") == "javascript:;") {
|
||||
var sonlist = $(".sidebar-menu > li[pid='" + $(this).attr("addtabs") + "']");
|
||||
sonlist.removeClass("hidden");
|
||||
}
|
||||
});
|
||||
|
||||
//点击左侧菜单栏
|
||||
$(document).on('click', '.sidebar-menu li a[addtabs]', function (e) {
|
||||
var parents = $(this).parentsUntil("ul.sidebar-menu", "li");
|
||||
var top = parents[parents.length - 1];
|
||||
var pid = $(top).attr("pid");
|
||||
if (pid) {
|
||||
var obj = $("li a[addtabs=" + pid + "]", firstnav);
|
||||
var last_id = obj.attr("last-id");
|
||||
if (!last_id || last_id != pid) {
|
||||
obj.attr("last-id", $(this).attr("addtabs"));
|
||||
if (!obj.closest("li").hasClass("active")) {
|
||||
obj.trigger("click");
|
||||
}
|
||||
}
|
||||
mobilenav.find("a").removeClass("active");
|
||||
mobilenav.find("a[addtabs='" + pid + "']").addClass("active");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//这一行需要放在点击左侧链接事件之前
|
||||
var addtabs = Config.referer ? sessionStorage.getItem("addtabs") : null;
|
||||
|
||||
//绑定tabs事件,如果需要点击强制刷新iframe,则请将iframeForceRefresh置为true,iframeForceRefreshTable只强制刷新表格
|
||||
nav.addtabs({iframeHeight: "100%", iframeForceRefresh: false, iframeForceRefreshTable: true, nav: nav});
|
||||
|
||||
if ($("ul.sidebar-menu li.active a").length > 0) {
|
||||
$("ul.sidebar-menu li.active a").trigger("click");
|
||||
} else {
|
||||
if (multiplenav) {
|
||||
$("li:first > a", firstnav).trigger("click");
|
||||
} else {
|
||||
$("ul.sidebar-menu li a[url!='javascript:;']:first").trigger("click");
|
||||
}
|
||||
}
|
||||
|
||||
//如果是刷新操作则直接返回刷新前的页面
|
||||
if (Config.referer) {
|
||||
if (Config.referer === $(addtabs).attr("url")) {
|
||||
var active = $("ul.sidebar-menu li a[addtabs=" + $(addtabs).attr("addtabs") + "]");
|
||||
if (multiplenav && active.length == 0) {
|
||||
active = $("ul li a[addtabs='" + $(addtabs).attr("addtabs") + "']");
|
||||
}
|
||||
if (active.length > 0) {
|
||||
active.trigger("click");
|
||||
} else {
|
||||
$(addtabs).appendTo(document.body).addClass("hide").trigger("click");
|
||||
}
|
||||
} else {
|
||||
//刷新页面后跳到到刷新前的页面
|
||||
Backend.api.addtabs(Config.referer);
|
||||
}
|
||||
}
|
||||
|
||||
var createCookie = function (name, value) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));
|
||||
var path = Config.moduleurl;
|
||||
document.cookie = encodeURIComponent(Config.cookie.prefix + name) + "=" + encodeURIComponent(value) + "; path=" + path + "; expires=" + date.toGMTString();
|
||||
};
|
||||
|
||||
var my_skins = [
|
||||
"skin-blue",
|
||||
"skin-black",
|
||||
"skin-red",
|
||||
"skin-yellow",
|
||||
"skin-purple",
|
||||
"skin-green",
|
||||
"skin-blue-light",
|
||||
"skin-black-light",
|
||||
"skin-red-light",
|
||||
"skin-yellow-light",
|
||||
"skin-purple-light",
|
||||
"skin-green-light",
|
||||
"skin-black-blue",
|
||||
"skin-black-purple",
|
||||
"skin-black-red",
|
||||
"skin-black-green",
|
||||
"skin-black-yellow",
|
||||
"skin-black-pink",
|
||||
];
|
||||
|
||||
// 皮肤切换
|
||||
$("[data-skin]").on('click', function (e) {
|
||||
var skin = $(this).data('skin');
|
||||
if (!$("body").hasClass(skin)) {
|
||||
$("body").removeClass(my_skins.join(' ')).addClass(skin);
|
||||
var cssfile = Config.site.cdnurl + "/assets/css/skins/" + skin + ".css";
|
||||
$('head').append('<link rel="stylesheet" href="' + cssfile + '" type="text/css" />');
|
||||
$(".skin-list li.active").removeClass("active");
|
||||
$(".skin-list li a[data-skin='" + skin + "']").parent().addClass("active");
|
||||
createCookie('adminskin', skin);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// 收起菜单栏切换
|
||||
$("[data-layout='sidebar-collapse']").on('click', function () {
|
||||
$(".sidebar-toggle").trigger("click");
|
||||
});
|
||||
|
||||
// 切换子菜单显示和菜单小图标的显示
|
||||
$("[data-menu='show-submenu']").on('click', function () {
|
||||
createCookie('show_submenu', $(this).prop("checked") ? 1 : 0);
|
||||
location.reload();
|
||||
});
|
||||
|
||||
// 右侧控制栏切换
|
||||
$("[data-controlsidebar]").on('click', function () {
|
||||
var cls = $(this).data('controlsidebar');
|
||||
$("body").toggleClass(cls);
|
||||
AdminLTE.layout.fixSidebar();
|
||||
//Fix the problem with right sidebar and layout boxed
|
||||
if (cls == "layout-boxed")
|
||||
AdminLTE.controlSidebar._fix($(".control-sidebar-bg"));
|
||||
if ($('body').hasClass('fixed') && cls == 'fixed') {
|
||||
AdminLTE.pushMenu.expandOnHover();
|
||||
AdminLTE.layout.activate();
|
||||
}
|
||||
AdminLTE.controlSidebar._fix($(".control-sidebar-bg"));
|
||||
AdminLTE.controlSidebar._fix($(".control-sidebar"));
|
||||
var slide = !AdminLTE.options.controlSidebarOptions.slide;
|
||||
AdminLTE.options.controlSidebarOptions.slide = slide;
|
||||
if (!slide)
|
||||
$('.control-sidebar').removeClass('control-sidebar-open');
|
||||
});
|
||||
|
||||
// 右侧控制栏背景切换
|
||||
$("[data-sidebarskin='toggle']").on('click', function () {
|
||||
var sidebar = $(".control-sidebar");
|
||||
if (sidebar.hasClass("control-sidebar-dark")) {
|
||||
sidebar.removeClass("control-sidebar-dark")
|
||||
sidebar.addClass("control-sidebar-light")
|
||||
} else {
|
||||
sidebar.removeClass("control-sidebar-light")
|
||||
sidebar.addClass("control-sidebar-dark")
|
||||
}
|
||||
});
|
||||
|
||||
// 菜单栏展开或收起
|
||||
$("[data-enable='expandOnHover']").on('click', function () {
|
||||
$.AdminLTE.options.sidebarExpandOnHover = $(this).prop("checked") ? 1 : 0;
|
||||
localStorage.setItem('sidebarExpandOnHover', $.AdminLTE.options.sidebarExpandOnHover);
|
||||
AdminLTE.pushMenu.expandOnHover();
|
||||
$.AdminLTE.layout.fixSidebar();
|
||||
});
|
||||
|
||||
// 切换菜单栏
|
||||
$(document).on("click", ".sidebar-toggle", function () {
|
||||
var value = $("body").hasClass("sidebar-collapse") ? 1 : 0;
|
||||
setTimeout(function () {
|
||||
$(window).trigger("resize");
|
||||
}, 300);
|
||||
createCookie('sidebar_collapse', value);
|
||||
});
|
||||
|
||||
// 切换多级菜单
|
||||
$(document).on("click", "[data-config='multiplenav']", function () {
|
||||
var value = $(this).prop("checked") ? 1 : 0;
|
||||
createCookie('multiplenav', value);
|
||||
location.reload();
|
||||
});
|
||||
|
||||
// 切换多选项卡
|
||||
$(document).on("click", "[data-config='multipletab']", function () {
|
||||
var value = $(this).prop("checked") ? 1 : 0;
|
||||
$("body").toggleClass("multipletab", value);
|
||||
createCookie('multipletab', value);
|
||||
});
|
||||
|
||||
// 重设选项
|
||||
if ($('body').hasClass('fixed')) {
|
||||
$("[data-layout='fixed']").attr('checked', 'checked');
|
||||
}
|
||||
if ($('body').hasClass('layout-boxed')) {
|
||||
$("[data-layout='layout-boxed']").attr('checked', 'checked');
|
||||
}
|
||||
if ($('body').hasClass('sidebar-collapse')) {
|
||||
$("[data-layout='sidebar-collapse']").attr('checked', 'checked');
|
||||
}
|
||||
if ($('ul.sidebar-menu').hasClass('show-submenu')) {
|
||||
$("[data-menu='show-submenu']").attr('checked', 'checked');
|
||||
}
|
||||
|
||||
var sidebarExpandOnHover = localStorage.getItem('sidebarExpandOnHover');
|
||||
if (sidebarExpandOnHover == '1') {
|
||||
$("[data-enable='expandOnHover']").trigger("click");
|
||||
}
|
||||
|
||||
$.each(my_skins, function (i, j) {
|
||||
if ($("body").hasClass(j)) {
|
||||
$(".skin-list li a[data-skin='" + j + "']").parent().addClass("active");
|
||||
}
|
||||
});
|
||||
|
||||
$(window).resize();
|
||||
|
||||
},
|
||||
login: function () {
|
||||
var lastlogin = localStorage.getItem("lastlogin");
|
||||
if (lastlogin) {
|
||||
lastlogin = JSON.parse(lastlogin);
|
||||
$("#profile-img").attr("src", Backend.api.cdnurl(lastlogin.avatar));
|
||||
$("#profile-name").val(lastlogin.username);
|
||||
}
|
||||
|
||||
//让错误提示框居中
|
||||
Fast.config.toastr.positionClass = "toast-top-center";
|
||||
|
||||
//本地验证未通过时提示
|
||||
$("#login-form").data("validator-options", {
|
||||
invalid: function (form, errors) {
|
||||
$.each(errors, function (i, j) {
|
||||
Toastr.error(j);
|
||||
});
|
||||
},
|
||||
target: '#errtips'
|
||||
});
|
||||
|
||||
//为表单绑定事件
|
||||
Form.api.bindevent($("#login-form"), function (data) {
|
||||
localStorage.setItem("lastlogin", JSON.stringify({
|
||||
id: data.id,
|
||||
username: data.username,
|
||||
avatar: data.avatar
|
||||
}));
|
||||
location.href = Backend.api.fixurl(data.url);
|
||||
}, function (data) {
|
||||
$("input[name=captcha]").next(".input-group-addon").find("img").trigger("click");
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return Controller;
|
||||
});
|
||||
56
public/assets/js/backend/junka_card.js
Normal file
56
public/assets/js/backend/junka_card.js
Normal file
@@ -0,0 +1,56 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'junka_card/index' + location.search,
|
||||
add_url: 'junka_card/add',
|
||||
// edit_url: 'junka_card/edit',
|
||||
// del_url: 'junka_card/del',
|
||||
multi_url: 'junka_card/multi',
|
||||
import_url: 'junka_card/import',
|
||||
table: 'junka_card',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'card_number', title: __('Card_number'), operate: 'LIKE'},
|
||||
{field: 'card_password', title: __('Card_password'), operate: 'LIKE'},
|
||||
{field: 'card_list_name', title: __('card_type'), operate: 'LIKE'},
|
||||
{field: 'card_price', title: __('card_price'), operate: 'LIKE'},
|
||||
{field: 'status', title: __('Status'), searchList: {1:__('未发货'), 2:'已发货', 3:'已锁定', 4:'锁定失败', 5:'提取中', 6:'锁定中(未到期)'}, formatter: Table.api.formatter.status},
|
||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
// {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
89
public/assets/js/backend/junka_card_log.js
Normal file
89
public/assets/js/backend/junka_card_log.js
Normal file
@@ -0,0 +1,89 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'junka_card_log/index' + location.search,
|
||||
add_url: 'junka_card_log/add',
|
||||
edit_url: 'junka_card_log/edit',
|
||||
del_url: 'junka_card_log/del',
|
||||
multi_url: 'junka_card_log/multi',
|
||||
import_url: 'junka_card_log/import',
|
||||
table: 'junka_card_log',
|
||||
}
|
||||
});
|
||||
|
||||
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: 'store.name', title: __('Store_id')},
|
||||
{field: 'bill_id', title: __('Bill_id'), operate: 'LIKE'},
|
||||
{field: 'bill_time', title: __('Bill_time'), operate: 'LIKE'},
|
||||
{field: 'product_code', title: __('Product_code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'card_price', title: __('Card_price'), operate: 'LIKE'},
|
||||
{field: 'product_num', title: __('Product_num')},
|
||||
{
|
||||
field: 'status',
|
||||
title: __('Status'),
|
||||
searchList: {
|
||||
0:__('购买失败'),
|
||||
1:__('购买成功'),
|
||||
},
|
||||
formatter: Table.api.formatter.status
|
||||
},
|
||||
{field: 'error_msg', title: __('Error'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
{
|
||||
field: 'operate',
|
||||
width: "150px",
|
||||
title: __('Operate'),
|
||||
table: table,
|
||||
events: Table.api.events.operate,
|
||||
buttons: [
|
||||
{
|
||||
name: 'click',
|
||||
title: __('查看卡密'),
|
||||
classname: 'btn btn-xs btn-info btn-click',
|
||||
icon: 'fa fa-leaf',
|
||||
// dropdown: '更多',//如果包含dropdown,将会以下拉列表的形式展示
|
||||
click: function (data, row) {
|
||||
console.log(row);
|
||||
Layer.alert("卡看看i米");
|
||||
}
|
||||
},
|
||||
],
|
||||
formatter: Table.api.formatter.operate
|
||||
},
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
56
public/assets/js/backend/junka_cardlock.js
Normal file
56
public/assets/js/backend/junka_cardlock.js
Normal file
@@ -0,0 +1,56 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'junka_cardlock/index' + location.search,
|
||||
add_url: 'junka_cardlock/add',
|
||||
edit_url: 'junka_cardlock/edit',
|
||||
del_url: 'junka_cardlock/del',
|
||||
multi_url: 'junka_cardlock/multi',
|
||||
import_url: 'junka_cardlock/import',
|
||||
table: 'junka_cardlock',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'bill_id', title: __('Bill_id'), operate: 'LIKE'},
|
||||
{field: 'card_number', title: __('Card_number'), operate: 'LIKE'},
|
||||
{field: 'card_password', title: __('Card_password'), operate: 'LIKE'},
|
||||
{field: 'ret_code', title: __('Ret_code'), operate: 'LIKE'},
|
||||
{field: 'ret_msg', title: __('Ret_msg'), operate: 'LIKE'},
|
||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
56
public/assets/js/backend/junka_cardunlock.js
Normal file
56
public/assets/js/backend/junka_cardunlock.js
Normal file
@@ -0,0 +1,56 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'junka_cardunlock/index' + location.search,
|
||||
add_url: 'junka_cardunlock/add',
|
||||
edit_url: 'junka_cardunlock/edit',
|
||||
del_url: 'junka_cardunlock/del',
|
||||
multi_url: 'junka_cardunlock/multi',
|
||||
import_url: 'junka_cardunlock/import',
|
||||
table: 'junka_cardunlock',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'bill_id', title: __('Bill_id'), operate: 'LIKE'},
|
||||
{field: 'card_number', title: __('Card_number'), operate: 'LIKE'},
|
||||
{field: 'card_password', title: __('Card_password'), operate: 'LIKE'},
|
||||
{field: 'ret_code', title: __('Ret_code'), operate: 'LIKE'},
|
||||
{field: 'ret_msg', title: __('Ret_msg'), operate: 'LIKE'},
|
||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
54
public/assets/js/backend/junka_code.js
Normal file
54
public/assets/js/backend/junka_code.js
Normal file
@@ -0,0 +1,54 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'junka_code/index' + location.search,
|
||||
add_url: 'junka_code/add',
|
||||
edit_url: 'junka_code/edit',
|
||||
del_url: 'junka_code/del',
|
||||
multi_url: 'junka_code/multi',
|
||||
import_url: 'junka_code/import',
|
||||
table: 'junka_code',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
// {checkbox: true},
|
||||
{field: 'list.junka_name', title: __('junka_name'), operate: 'LIKE', table: table},
|
||||
{field: 'name', title: __('name'), operate: 'LIKE', table: table},
|
||||
{field: 'code', title: __('Code'), operate: 'LIKE', table: table},
|
||||
{field: 'par_value', title: __('Par_value'), operate: 'LIKE', table: table},
|
||||
{field: 'price', title: __('price'), operate: 'LIKE', table: table},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
50
public/assets/js/backend/junka_list.js
Normal file
50
public/assets/js/backend/junka_list.js
Normal file
@@ -0,0 +1,50 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'junka_list/index' + location.search,
|
||||
add_url: 'junka_list/add',
|
||||
edit_url: 'junka_list/edit',
|
||||
del_url: 'junka_list/del',
|
||||
multi_url: 'junka_list/multi',
|
||||
import_url: 'junka_list/import',
|
||||
table: 'junka_list',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'junka_id', title: __('Junka_id')},
|
||||
{field: 'junka_name', title: __('Junka_name'), operate: 'LIKE'},
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
188
public/assets/js/backend/junka_purchcard_log.js
Normal file
188
public/assets/js/backend/junka_purchcard_log.js
Normal file
@@ -0,0 +1,188 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'junka_purchcard_log/index' + location.search,
|
||||
add_url: 'junka_purchcard_log/add',
|
||||
// edit_url: 'junka_purchcard_log/edit',
|
||||
del_url: '',
|
||||
multi_url: 'junka_purchcard_log/multi',
|
||||
import_url: 'junka_purchcard_log/import',
|
||||
table: 'junka_purchcard_log',
|
||||
}
|
||||
});
|
||||
|
||||
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: 'store.name', title: __('Store_id')},
|
||||
{field: 'bill_id', title: __('Bill_id'), operate: 'LIKE'},
|
||||
{field: 'bill_time', title: __('Bill_time'), operate: 'LIKE'},
|
||||
// {field: 'card_list_name', title: __('card_type'), operate: 'LIKE'},
|
||||
{field: 'product_code', title: __('Product_code'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 't_price', title: __('Price'), operate: 'LIKE'},
|
||||
{field: 'card_price', title: __('Card_price'), operate: 'LIKE'},
|
||||
{field: 'total_num', title: __('数量')},
|
||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
{field: 'status', title: __('Status'), searchList: {
|
||||
1 : __('购买成功'),
|
||||
0 : __('购买失败'),
|
||||
2 : __('退货中'),
|
||||
3 : __('已退货'),
|
||||
4 : __('拒绝退货'),
|
||||
5 : __('已锁定'),
|
||||
}, formatter: Table.api.formatter.status},
|
||||
{
|
||||
field: 'operate',
|
||||
width: "150px",
|
||||
title: __('Operate'),
|
||||
table: table,
|
||||
events: Table.api.events.operate,
|
||||
buttons: [
|
||||
// {
|
||||
// name: 'savereject',
|
||||
// title: __('去审核'),
|
||||
// text: __('去审核'),
|
||||
// classname: 'btn btn-xs btn-primary btn-dialog',
|
||||
// icon: 'fa',
|
||||
// url: 'junka_reject/examine',
|
||||
// visible:function (data) {
|
||||
// if(data.is_examine == 1) {
|
||||
// return true;
|
||||
// }else {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
{
|
||||
name: 'click',
|
||||
title: __('查看卡密'),
|
||||
text: __('卡密'),
|
||||
classname: 'btn btn-xs btn-info btn-click',
|
||||
icon: '',
|
||||
// dropdown: '更多',//如果包含dropdown,将会以下拉列表的形式展示
|
||||
click: function (data, row) {
|
||||
Layer.alert(row.data);
|
||||
}
|
||||
},
|
||||
// {
|
||||
// name: 'subreject',
|
||||
// title: __('退货'),
|
||||
// text: __('退货'),
|
||||
// classname: 'btn btn-xs btn-success btn-magic btn-ajax',
|
||||
// icon: 'fa',
|
||||
// confirm: '确认退货吗?',
|
||||
// url: 'junka_purchcard_log/subreject',
|
||||
// visible:function (data) {
|
||||
// if(data.is_reject == 1) {
|
||||
// return true;
|
||||
// }else {
|
||||
// return false;
|
||||
// }
|
||||
// },
|
||||
// success: function (data, ret) {
|
||||
// window.parent.location.reload();
|
||||
// //如果需要阻止成功提示,则必须使用return false;
|
||||
// //return false;
|
||||
// },
|
||||
// error: function (data, ret) {
|
||||
// console.log(data, ret);
|
||||
// Layer.alert(ret.msg);
|
||||
// return false;
|
||||
// }
|
||||
// },
|
||||
{
|
||||
name: 'sk',
|
||||
title: __('锁卡'),
|
||||
text: __('锁卡'),
|
||||
classname: 'btn btn-xs btn-success btn-magic btn-ajax',
|
||||
icon: 'fa',
|
||||
confirm: '确认锁卡吗?',
|
||||
url: 'junka_purchcard_log/sk',
|
||||
visible:function (data) {
|
||||
if(data.status == 1 && data.is_suo == 0) {
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
// return true;
|
||||
}
|
||||
},
|
||||
success: function (data, ret) {
|
||||
Layer.msg(ret.msg);
|
||||
// 刷新
|
||||
$("#table").bootstrapTable("refresh","");
|
||||
//如果需要阻止成功提示,则必须使用return false;
|
||||
return false;
|
||||
},
|
||||
error: function (data, ret) {
|
||||
console.log(data, ret);
|
||||
Layer.alert(ret.msg);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'js',
|
||||
title: __('解锁'),
|
||||
text: __('解锁'),
|
||||
classname: 'btn btn-xs btn-primary btn-magic btn-ajax',
|
||||
icon: 'fa',
|
||||
confirm: '确认解锁吗?',
|
||||
url: 'junka_purchcard_log/js',
|
||||
visible:function (data) {
|
||||
if(data.status == 5 || data.is_suo == 1) {
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
// return true;
|
||||
}
|
||||
},
|
||||
success: function (data, ret) {
|
||||
Layer.msg(ret.msg);
|
||||
// 刷新
|
||||
$("#table").bootstrapTable("refresh","");
|
||||
//如果需要阻止成功提示,则必须使用return false;
|
||||
return false;
|
||||
},
|
||||
error: function (data, ret) {
|
||||
console.log(data, ret);
|
||||
Layer.alert(ret.msg);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
],
|
||||
formatter: Table.api.formatter.operate
|
||||
},
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
133
public/assets/js/backend/junka_reject.js
Normal file
133
public/assets/js/backend/junka_reject.js
Normal file
@@ -0,0 +1,133 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'junka_reject/index' + location.search,
|
||||
add_url: 'junka_reject/add',
|
||||
edit_url: 'junka_reject/edit',
|
||||
del_url: 'junka_reject/del',
|
||||
multi_url: 'junka_reject/multi',
|
||||
import_url: 'junka_reject/import',
|
||||
table: 'junka_reject',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'store_id', title: __('Store_id')},
|
||||
{field: 'purchcard_log_id', title: __('Purchcard_log_id')},
|
||||
{field: 'notes', title: __('Notes'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'status', title: __('Status'), searchList: {
|
||||
0:__('未审核'),
|
||||
1:__('通过'),
|
||||
2:__('拒绝'),
|
||||
}, formatter: Table.api.formatter.status
|
||||
},
|
||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
examine: function () {
|
||||
Controller.api.bindevent();
|
||||
// 审核通过
|
||||
$(document).on('click', '#pass_reject', function () {
|
||||
var id = $(this).data('id');
|
||||
Layer.confirm('确认审核通过吗?已付款项将原路返回', {
|
||||
title:'操作提示',
|
||||
icon:0,
|
||||
btn:['确认', '取消']
|
||||
}, function () {
|
||||
loadindex = layer.load(2);
|
||||
$.ajax({
|
||||
'type': 'POST',
|
||||
'url': 'junka_reject/refundedit',
|
||||
data:{
|
||||
id:id,
|
||||
type:1,
|
||||
},
|
||||
success:function (res) {
|
||||
Layer.close(loadindex);
|
||||
if(res.code == 1) {
|
||||
Layer.msg(res.msg, {
|
||||
icon:1,
|
||||
time:1000,
|
||||
},function () {
|
||||
Layer.closeAll();
|
||||
parent.Layer.closeAll();
|
||||
parent.$(".btn-refresh").trigger("click");
|
||||
});
|
||||
}else {
|
||||
Layer.msg(res.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// 审核驳回
|
||||
$(document).on('click', '#no_reject', function () {
|
||||
var id = $(this).data('id');
|
||||
Layer.prompt({
|
||||
formType:0,
|
||||
title:'请输入驳回理由',
|
||||
btn:['确认', '取消'],
|
||||
},function (value) {
|
||||
loadindex = layer.load(2);
|
||||
$.ajax({
|
||||
'type': 'POST',
|
||||
'url': 'junka_reject/refundedit',
|
||||
data:{
|
||||
id:id,
|
||||
type:2,
|
||||
reject:value
|
||||
},
|
||||
success:function (res) {
|
||||
Layer.close(loadindex);
|
||||
if(res.code == 1) {
|
||||
Layer.msg(res.msg, {
|
||||
icon:1,
|
||||
time:1000,
|
||||
},function () {
|
||||
Layer.closeAll();
|
||||
parent.Layer.closeAll();
|
||||
parent.$(".btn-refresh").trigger("click");
|
||||
});
|
||||
}else {
|
||||
Layer.msg(res.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
53
public/assets/js/backend/junka_store.js
Normal file
53
public/assets/js/backend/junka_store.js
Normal file
@@ -0,0 +1,53 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'junka_store/index' + location.search,
|
||||
add_url: 'junka_store/add',
|
||||
edit_url: 'junka_store/edit',
|
||||
// del_url: 'junka_store/del',
|
||||
multi_url: 'junka_store/multi',
|
||||
import_url: 'junka_store/import',
|
||||
table: 'junka_store',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'name', title: __('Name'), operate: 'LIKE', table: table, },
|
||||
{field: 'money', title: __('余额'), operate: 'LIKE', table: table, },
|
||||
{field: 'discount', title: __('折扣'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
57
public/assets/js/backend/junka_store_discount_log.js
Normal file
57
public/assets/js/backend/junka_store_discount_log.js
Normal file
@@ -0,0 +1,57 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'junka_store_discount_log/index' + location.search,
|
||||
add_url: 'junka_store_discount_log/add',
|
||||
edit_url: 'junka_store_discount_log/edit',
|
||||
del_url: 'junka_store_discount_log/del',
|
||||
multi_url: 'junka_store_discount_log/multi',
|
||||
import_url: 'junka_store_discount_log/import',
|
||||
table: 'junka_store_discount_log',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'admin_id', title: __('Admin_id')},
|
||||
{field: 'store_id', title: __('Store_id')},
|
||||
{field: 'before_money', title: __('Before_money'), operate:'BETWEEN'},
|
||||
{field: 'after_money', title: __('After_money'), operate:'BETWEEN'},
|
||||
{field: 'discount', title: __('Discount'), operate:'BETWEEN'},
|
||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
57
public/assets/js/backend/junka_store_money_log.js
Normal file
57
public/assets/js/backend/junka_store_money_log.js
Normal file
@@ -0,0 +1,57 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'junka_store_money_log/index' + location.search,
|
||||
add_url: 'junka_store_money_log/add',
|
||||
// edit_url: 'junka_store_money_log/edit',
|
||||
// del_url: 'junka_store_money_log/del',
|
||||
multi_url: 'junka_store_money_log/multi',
|
||||
import_url: 'junka_store_money_log/import',
|
||||
table: 'junka_store_money_log',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
escape: false,
|
||||
columns: [
|
||||
[
|
||||
// {checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'store.name', title: __('商户')},
|
||||
{field: 'notes', title: __('Notes'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'before_money', title: __('Before_money'), operate:'BETWEEN'},
|
||||
{field: 'type', title: __('Type')},
|
||||
{field: 'after_money', title: __('After_money'), operate:'BETWEEN'},
|
||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
// {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
54
public/assets/js/backend/order.js
Normal file
54
public/assets/js/backend/order.js
Normal file
@@ -0,0 +1,54 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'order/index' + location.search,
|
||||
add_url: 'order/add',
|
||||
edit_url: 'order/edit',
|
||||
del_url: 'order/del',
|
||||
multi_url: 'order/multi',
|
||||
import_url: 'order/import',
|
||||
table: 'order',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'type', title: __('Type')},
|
||||
{field: 'title', title: __('Title'), operate: 'LIKE'},
|
||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
57
public/assets/js/backend/store_money_log.js
Normal file
57
public/assets/js/backend/store_money_log.js
Normal file
@@ -0,0 +1,57 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'store_money_log/index' + location.search,
|
||||
add_url: 'store_money_log/add',
|
||||
edit_url: 'store_money_log/edit',
|
||||
del_url: 'store_money_log/del',
|
||||
multi_url: 'store_money_log/multi',
|
||||
import_url: 'store_money_log/import',
|
||||
table: 'store_money_log',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'store_id', title: __('Store_id')},
|
||||
{field: 'before_money', title: __('Before_money'), operate:'BETWEEN'},
|
||||
{field: 'after_money', title: __('After_money'), operate:'BETWEEN'},
|
||||
{field: 'type', title: __('Type')},
|
||||
{field: 'notes', title: __('Notes'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
114
public/assets/js/backend/user/group.js
Normal file
114
public/assets/js/backend/user/group.js
Normal file
@@ -0,0 +1,114 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ($, undefined, Backend, Table, Form, undefined) {
|
||||
//读取选中的条目
|
||||
$.jstree.core.prototype.get_all_checked = function (full) {
|
||||
var obj = this.get_selected(), i, j;
|
||||
for (i = 0, j = obj.length; i < j; i++) {
|
||||
obj = obj.concat(this.get_node(obj[i]).parents);
|
||||
}
|
||||
obj = $.grep(obj, function (v, i, a) {
|
||||
return v != '#';
|
||||
});
|
||||
obj = obj.filter(function (itm, i, a) {
|
||||
return i == a.indexOf(itm);
|
||||
});
|
||||
return full ? $.map(obj, $.proxy(function (i) {
|
||||
return this.get_node(i);
|
||||
}, this)) : obj;
|
||||
};
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'user/group/index',
|
||||
add_url: 'user/group/add',
|
||||
edit_url: 'user/group/edit',
|
||||
del_url: 'user/group/del',
|
||||
multi_url: 'user/group/multi',
|
||||
table: 'user_group',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'name', title: __('Name')},
|
||||
{field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"), null, null, function () {
|
||||
if ($("#treeview").length > 0) {
|
||||
var r = $("#treeview").jstree("get_all_checked");
|
||||
$("input[name='row[rules]']").val(r.join(','));
|
||||
}
|
||||
return true;
|
||||
});
|
||||
//渲染权限节点树
|
||||
//销毁已有的节点树
|
||||
$("#treeview").jstree("destroy");
|
||||
Controller.api.rendertree(nodeData);
|
||||
//全选和展开
|
||||
$(document).on("click", "#checkall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "check_all" : "uncheck_all");
|
||||
});
|
||||
$(document).on("click", "#expandall", function () {
|
||||
$("#treeview").jstree($(this).prop("checked") ? "open_all" : "close_all");
|
||||
});
|
||||
$("select[name='row[pid]']").trigger("change");
|
||||
},
|
||||
rendertree: function (content) {
|
||||
$("#treeview")
|
||||
.on('redraw.jstree', function (e) {
|
||||
$(".layer-footer").attr("domrefresh", Math.random());
|
||||
})
|
||||
.jstree({
|
||||
"themes": {"stripes": true},
|
||||
"checkbox": {
|
||||
"keep_selected_style": false,
|
||||
},
|
||||
"types": {
|
||||
"root": {
|
||||
"icon": "fa fa-folder-open",
|
||||
},
|
||||
"menu": {
|
||||
"icon": "fa fa-folder-open",
|
||||
},
|
||||
"file": {
|
||||
"icon": "fa fa-file-o",
|
||||
}
|
||||
},
|
||||
"plugins": ["checkbox", "types"],
|
||||
"core": {
|
||||
'check_callback': true,
|
||||
"data": content
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
130
public/assets/js/backend/user/rule.js
Normal file
130
public/assets/js/backend/user/rule.js
Normal file
@@ -0,0 +1,130 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'user/rule/index',
|
||||
add_url: 'user/rule/add',
|
||||
edit_url: 'user/rule/edit',
|
||||
del_url: 'user/rule/del',
|
||||
multi_url: 'user/rule/multi',
|
||||
table: 'user_rule',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'weigh',
|
||||
escape: false,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'pid', title: __('Pid'), visible: false},
|
||||
{field: 'title', title: __('Title'), align: 'left', formatter: Controller.api.formatter.title},
|
||||
{field: 'name', title: __('Name'), align: 'left', formatter: Controller.api.formatter.name},
|
||||
{field: 'remark', title: __('Remark')},
|
||||
// {field: 'ismenu', title: __('Ismenu'), formatter: Table.api.formatter.toggle},
|
||||
{field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true, visible: false},
|
||||
{field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true, visible: false},
|
||||
{field: 'weigh', title: __('Weigh')},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
],
|
||||
pagination: false,
|
||||
search: false,
|
||||
commonSearch: false,
|
||||
rowAttributes: function (row, index) {
|
||||
return row.pid == 0 ? {} : {style: "display:none"};
|
||||
}
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
table.on('post-body.bs.table', function (e, settings, json, xhr) {
|
||||
//显示隐藏子节点
|
||||
$(">tbody>tr[data-index] > td", this).on('click', "a.btn-node-sub", function () {
|
||||
var status = $(this).data("shown") ? true : false;
|
||||
$("a[data-pid='" + $(this).data("id") + "']").each(function () {
|
||||
$(this).closest("tr").toggle(!status);
|
||||
});
|
||||
if (status) {
|
||||
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
||||
}
|
||||
$(this).data("shown", !status);
|
||||
$("i", this).toggleClass("fa-caret-down").toggleClass("fa-caret-right");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
//隐藏子节点
|
||||
$(document).on("collapse", ".btn-node-sub", function () {
|
||||
if ($("i", this).length > 0) {
|
||||
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
||||
}
|
||||
$("i", this).removeClass("fa-caret-down").addClass("fa-caret-right");
|
||||
$(this).data("shown", false);
|
||||
$(this).closest("tr").toggle(false);
|
||||
});
|
||||
|
||||
//展开隐藏一级
|
||||
$(document.body).on("click", ".btn-toggle", function (e) {
|
||||
$("a[data-id][data-pid][data-pid!=0].disabled").closest("tr").hide();
|
||||
var that = this;
|
||||
var show = $("i", that).hasClass("fa-chevron-down");
|
||||
$("i", that).toggleClass("fa-chevron-down", !show).toggleClass("fa-chevron-up", show);
|
||||
$("a[data-id][data-pid][data-pid!=0]").not('.disabled').closest("tr").toggle(show);
|
||||
$(".btn-node-sub[data-pid=0]").data("shown", show);
|
||||
});
|
||||
|
||||
//展开隐藏全部
|
||||
$(document.body).on("click", ".btn-toggle-all", function (e) {
|
||||
var that = this;
|
||||
var show = $("i", that).hasClass("fa-plus");
|
||||
$("i", that).toggleClass("fa-plus", !show).toggleClass("fa-minus", show);
|
||||
$(".btn-node-sub:not([data-pid=0])").closest("tr").toggle(show);
|
||||
$(".btn-node-sub").data("shown", show);
|
||||
$(".btn-node-sub > i").toggleClass("fa-caret-down", show).toggleClass("fa-caret-right", !show);
|
||||
});
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
formatter: {
|
||||
title: function (value, row, index) {
|
||||
value = value.toString().replace(/(&|&)nbsp;/g, ' ');
|
||||
var caret = row.haschild == 1 || row.ismenu == 1 ? '<i class="fa fa-caret-right"></i>' : '';
|
||||
value = value.indexOf(" ") > -1 ? value.replace(/(.*) /, "$1" + caret) : caret + value;
|
||||
|
||||
value = !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
|
||||
return '<a href="javascript:;" data-id="' + row.id + '" data-pid="' + row.pid + '" class="'
|
||||
+ (row.haschild == 1 || row.ismenu == 1 ? 'text-primary' : 'disabled') + ' btn-node-sub">' + value + '</a>';
|
||||
},
|
||||
name: function (value, row, index) {
|
||||
return !row.ismenu || row.status == 'hidden' ? "<span class='text-muted'>" + value + "</span>" : value;
|
||||
},
|
||||
},
|
||||
bindevent: function () {
|
||||
$(document).on('click', "input[name='row[ismenu]']", function () {
|
||||
var name = $("input[name='row[name]']");
|
||||
name.prop("placeholder", $(this).val() == 1 ? name.data("placeholder-menu") : name.data("placeholder-node"));
|
||||
});
|
||||
$("input[name='row[ismenu]']:checked").trigger("click");
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
65
public/assets/js/backend/user/user.js
Normal file
65
public/assets/js/backend/user/user.js
Normal file
@@ -0,0 +1,65 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'user/user/index',
|
||||
add_url: 'user/user/add',
|
||||
edit_url: 'user/user/edit',
|
||||
del_url: 'user/user/del',
|
||||
multi_url: 'user/user/multi',
|
||||
table: 'user',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'user.id',
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id'), sortable: true},
|
||||
{field: 'group.name', title: __('Group')},
|
||||
{field: 'username', title: __('Username'), operate: 'LIKE'},
|
||||
{field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
|
||||
{field: 'email', title: __('Email'), operate: 'LIKE'},
|
||||
{field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
|
||||
{field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
|
||||
{field: 'level', title: __('Level'), operate: 'BETWEEN', sortable: true},
|
||||
{field: 'gender', title: __('Gender'), visible: false, searchList: {1: __('Male'), 0: __('Female')}},
|
||||
{field: 'score', title: __('Score'), operate: 'BETWEEN', sortable: true},
|
||||
{field: 'successions', title: __('Successions'), visible: false, operate: 'BETWEEN', sortable: true},
|
||||
{field: 'maxsuccessions', title: __('Maxsuccessions'), visible: false, operate: 'BETWEEN', sortable: true},
|
||||
{field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'loginip', title: __('Loginip'), formatter: Table.api.formatter.search},
|
||||
{field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{field: 'joinip', title: __('Joinip'), formatter: Table.api.formatter.search},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
404
public/assets/js/bootstrap-table-commonsearch.js
vendored
Normal file
404
public/assets/js/bootstrap-table-commonsearch.js
vendored
Normal file
@@ -0,0 +1,404 @@
|
||||
/**
|
||||
* FastAdmin通用搜索
|
||||
*
|
||||
* @author: pppscn <35696959@qq.com>
|
||||
* @update 2017-05-07 <https://gitee.com/pp/fastadmin>
|
||||
*
|
||||
* @author: Karson <karson@fastadmin.net>
|
||||
* @update 2018-04-05 <https://gitee.com/karson/fastadmin>
|
||||
*/
|
||||
|
||||
!function ($) {
|
||||
'use strict';
|
||||
|
||||
var ColumnsForSearch = [];
|
||||
|
||||
var sprintf = $.fn.bootstrapTable.utils.sprintf;
|
||||
|
||||
var initCommonSearch = function (pColumns, that) {
|
||||
var vFormCommon = createFormCommon(pColumns, that);
|
||||
|
||||
var vModal = sprintf("<div class=\"commonsearch-table %s\">", that.options.searchFormVisible ? "" : "hidden");
|
||||
vModal += vFormCommon;
|
||||
vModal += "</div>";
|
||||
that.$container.prepend($(vModal));
|
||||
that.$commonsearch = $(".commonsearch-table", that.$container);
|
||||
var form = $("form.form-commonsearch", that.$commonsearch);
|
||||
|
||||
require(['form'], function (Form) {
|
||||
Form.api.bindevent(form);
|
||||
form.validator("destroy");
|
||||
});
|
||||
|
||||
// 表单提交
|
||||
form.on("submit", function (event) {
|
||||
event.preventDefault();
|
||||
that.onCommonSearch();
|
||||
return false;
|
||||
});
|
||||
|
||||
// 重置搜索
|
||||
form.on("click", "button[type=reset]", function (event) {
|
||||
form[0].reset();
|
||||
|
||||
setTimeout(function () {
|
||||
that.onCommonSearch();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
var createFormCommon = function (pColumns, that) {
|
||||
// 如果有使用模板则直接返回模板的内容
|
||||
if (that.options.searchFormTemplate) {
|
||||
return Template(that.options.searchFormTemplate, {columns: pColumns, table: that});
|
||||
}
|
||||
var htmlForm = [];
|
||||
htmlForm.push(sprintf('<form class="form-horizontal form-commonsearch" novalidate method="post" action="%s" >', that.options.actionForm));
|
||||
htmlForm.push('<fieldset>');
|
||||
if (that.options.titleForm.length > 0)
|
||||
htmlForm.push(sprintf("<legend>%s</legend>", that.options.titleForm));
|
||||
htmlForm.push('<div class="row">');
|
||||
for (var i in pColumns) {
|
||||
var vObjCol = pColumns[i];
|
||||
if (!vObjCol.checkbox && vObjCol.field !== 'operate' && vObjCol.searchable && vObjCol.operate !== false) {
|
||||
var query = Fast.api.query(vObjCol.field);
|
||||
var operate = Fast.api.query(vObjCol.field + "-operate");
|
||||
|
||||
var renderDefault = that.options.renderDefault && (typeof vObjCol.renderDefault == 'undefined' || vObjCol.renderDefault);
|
||||
vObjCol.defaultValue = renderDefault && query ? query : (typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue);
|
||||
vObjCol.operate = renderDefault && operate ? operate : (typeof vObjCol.operate === 'undefined' ? '=' : vObjCol.operate);
|
||||
ColumnsForSearch.push(vObjCol);
|
||||
|
||||
htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
|
||||
htmlForm.push(sprintf('<label for="%s" class="control-label col-xs-4">%s</label>', vObjCol.field, vObjCol.title));
|
||||
htmlForm.push('<div class="col-xs-8">');
|
||||
|
||||
vObjCol.operate = vObjCol.operate ? vObjCol.operate.toUpperCase() : '=';
|
||||
htmlForm.push(sprintf('<input type="hidden" class="form-control operate" name="%s-operate" data-name="%s" value="%s" readonly>', vObjCol.field, vObjCol.field, vObjCol.operate));
|
||||
|
||||
var addClass = typeof vObjCol.addClass === 'undefined' ? (typeof vObjCol.addclass === 'undefined' ? 'form-control' : 'form-control ' + vObjCol.addclass) : 'form-control ' + vObjCol.addClass;
|
||||
var extend = typeof vObjCol.extend === 'undefined' ? '' : vObjCol.extend;
|
||||
var style = typeof vObjCol.style === 'undefined' ? '' : sprintf('style="%s"', vObjCol.style);
|
||||
extend = typeof vObjCol.data !== 'undefined' && extend == '' ? vObjCol.data : extend;
|
||||
extend = typeof vObjCol.autocomplete !== 'undefined' ? extend + ' autocomplete="' + (vObjCol.autocomplete === false || vObjCol.autocomplete === 'off' ? 'off' : 'on') + '"' : extend;
|
||||
if (vObjCol.searchList) {
|
||||
if (typeof vObjCol.searchList === 'function') {
|
||||
htmlForm.push(vObjCol.searchList.call(this, vObjCol));
|
||||
} else {
|
||||
var optionList = [sprintf('<option value="">%s</option>', that.options.formatCommonChoose())];
|
||||
if (typeof vObjCol.searchList === 'object' && typeof vObjCol.searchList.then === 'function') {
|
||||
(function (vObjCol, that) {
|
||||
$.when(vObjCol.searchList).done(function (ret) {
|
||||
var searchList = [];
|
||||
if (ret.data && ret.data.searchlist && $.isArray(ret.data.searchlist)) {
|
||||
searchList = ret.data.searchlist;
|
||||
} else if (ret.constructor === Array || ret.constructor === Object) {
|
||||
searchList = ret;
|
||||
}
|
||||
var optionList = createOptionList(searchList, vObjCol, that);
|
||||
$("form.form-commonsearch select[name='" + vObjCol.field + "']", that.$container).html(optionList.join('')).trigger("change");
|
||||
});
|
||||
})(vObjCol, that);
|
||||
} else {
|
||||
optionList = createOptionList(vObjCol.searchList, vObjCol, that);
|
||||
}
|
||||
htmlForm.push(sprintf('<select class="%s" name="%s" %s %s>%s</select>', addClass, vObjCol.field, style, extend, optionList.join('')));
|
||||
}
|
||||
} else {
|
||||
var placeholder = typeof vObjCol.placeholder === 'undefined' ? vObjCol.title : vObjCol.placeholder;
|
||||
var type = typeof vObjCol.type === 'undefined' ? 'text' : vObjCol.type;
|
||||
var defaultValue = typeof vObjCol.defaultValue === 'undefined' ? '' : vObjCol.defaultValue;
|
||||
if (/BETWEEN$/.test(vObjCol.operate)) {
|
||||
var defaultValueArr = defaultValue.toString().match(/\|/) ? defaultValue.split('|') : ['', ''];
|
||||
var placeholderArr = placeholder.toString().match(/\|/) ? placeholder.split('|') : [placeholder, placeholder];
|
||||
htmlForm.push('<div class="row row-between">');
|
||||
htmlForm.push(sprintf('<div class="col-xs-6"><input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s-min" data-index="%s" %s %s></div>', type, addClass, vObjCol.field, defaultValueArr[0], placeholderArr[0], vObjCol.field, i, style, extend));
|
||||
htmlForm.push(sprintf('<div class="col-xs-6"><input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s-max" data-index="%s" %s %s></div>', type, addClass, vObjCol.field, defaultValueArr[1], placeholderArr[1], vObjCol.field, i, style, extend));
|
||||
htmlForm.push('</div>');
|
||||
} else {
|
||||
htmlForm.push(sprintf('<input type="%s" class="%s" name="%s" value="%s" placeholder="%s" id="%s" data-index="%s" %s %s>', type, addClass, vObjCol.field, defaultValue, placeholder, vObjCol.field, i, style, extend));
|
||||
}
|
||||
}
|
||||
|
||||
htmlForm.push('</div>');
|
||||
htmlForm.push('</div>');
|
||||
}
|
||||
}
|
||||
htmlForm.push('<div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">');
|
||||
htmlForm.push(createFormBtn(that).join(''));
|
||||
htmlForm.push('</div>');
|
||||
htmlForm.push('</div>');
|
||||
htmlForm.push('</fieldset>');
|
||||
htmlForm.push('</form>');
|
||||
|
||||
return htmlForm.join('');
|
||||
};
|
||||
|
||||
var createFormBtn = function (that) {
|
||||
var htmlBtn = [];
|
||||
var searchSubmit = that.options.formatCommonSubmitButton();
|
||||
var searchReset = that.options.formatCommonResetButton();
|
||||
htmlBtn.push('<div class="col-sm-8 col-xs-offset-4">');
|
||||
htmlBtn.push(sprintf('<button type="submit" class="btn btn-success" formnovalidate>%s</button> ', searchSubmit));
|
||||
htmlBtn.push(sprintf('<button type="reset" class="btn btn-default" >%s</button> ', searchReset));
|
||||
htmlBtn.push('</div>');
|
||||
return htmlBtn;
|
||||
};
|
||||
|
||||
var createOptionList = function (searchList, vObjCol, that) {
|
||||
var isArray = searchList.constructor === Array;
|
||||
var optionList = [];
|
||||
optionList.push(sprintf('<option value="">%s</option>', that.options.formatCommonChoose()));
|
||||
$.each(searchList, function (key, value) {
|
||||
if (value.constructor === Object) {
|
||||
key = value.id;
|
||||
value = value.name;
|
||||
} else {
|
||||
key = isArray ? value : key;
|
||||
}
|
||||
optionList.push(sprintf("<option value='" + key + "' %s>" + value + "</option>", key == vObjCol.defaultValue ? 'selected' : ''));
|
||||
});
|
||||
return optionList;
|
||||
};
|
||||
|
||||
var isSearchAvailble = function (that) {
|
||||
|
||||
//只支持服务端搜索
|
||||
if (!that.options.commonSearch || that.options.sidePagination != 'server' || !that.options.url) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
var getSearchQuery = function (that, removeempty) {
|
||||
var op = {};
|
||||
var filter = {};
|
||||
var value = '';
|
||||
$("form.form-commonsearch .operate", that.$commonsearch).each(function (i) {
|
||||
var name = $(this).data("name");
|
||||
var sym = $(this).is("select") ? $("option:selected", this).val() : $(this).val().toUpperCase();
|
||||
var obj = $("[name='" + name + "']", that.$commonsearch);
|
||||
if (obj.length == 0)
|
||||
return true;
|
||||
var vObjCol = ColumnsForSearch[i];
|
||||
var process = !that.options.searchFormTemplate && vObjCol && typeof vObjCol.process == 'function' ? vObjCol.process : null;
|
||||
if (obj.length > 1) {
|
||||
if (/BETWEEN$/.test(sym)) {
|
||||
var value_begin = $.trim($("[name='" + name + "']:first", that.$commonsearch).val()),
|
||||
value_end = $.trim($("[name='" + name + "']:last", that.$commonsearch).val());
|
||||
if (value_begin.length || value_end.length) {
|
||||
if (process) {
|
||||
value_begin = process(value_begin, 'begin');
|
||||
value_end = process(value_end, 'end');
|
||||
}
|
||||
value = value_begin + ',' + value_end;
|
||||
} else {
|
||||
value = '';
|
||||
}
|
||||
//如果是时间筛选,将operate置为RANGE
|
||||
if ($("[name='" + name + "']:first", that.$commonsearch).hasClass("datetimepicker")) {
|
||||
sym = 'RANGE';
|
||||
}
|
||||
} else {
|
||||
value = $("[name='" + name + "']:checked", that.$commonsearch).val();
|
||||
value = process ? process(value) : value;
|
||||
}
|
||||
} else {
|
||||
value = process ? process(obj.val()) : obj.val();
|
||||
}
|
||||
if (removeempty && (value == '' || value == null || ($.isArray(value) && value.length == 0)) && !sym.match(/null/i)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
op[name] = sym;
|
||||
filter[name] = value;
|
||||
});
|
||||
return {op: op, filter: filter};
|
||||
};
|
||||
|
||||
var getQueryParams = function (params, searchQuery, removeempty) {
|
||||
params.filter = typeof params.filter === 'Object' ? params.filter : (params.filter ? JSON.parse(params.filter) : {});
|
||||
params.op = typeof params.op === 'Object' ? params.op : (params.op ? JSON.parse(params.op) : {});
|
||||
|
||||
params.filter = $.extend({}, params.filter, searchQuery.filter);
|
||||
params.op = $.extend({}, params.op, searchQuery.op);
|
||||
//移除empty的值
|
||||
if (removeempty) {
|
||||
$.each(params.filter, function (i, j) {
|
||||
if ((j == '' || j == null || ($.isArray(j) && j.length == 0)) && !params.op[i].match(/null/i)) {
|
||||
delete params.filter[i];
|
||||
delete params.op[i];
|
||||
}
|
||||
});
|
||||
}
|
||||
params.filter = JSON.stringify(params.filter);
|
||||
params.op = JSON.stringify(params.op);
|
||||
return params;
|
||||
};
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, {
|
||||
commonSearch: false,
|
||||
titleForm: "Common search",
|
||||
actionForm: "",
|
||||
searchFormTemplate: "",
|
||||
searchFormVisible: true,
|
||||
searchClass: 'searchit',
|
||||
showSearch: true,
|
||||
renderDefault: true,
|
||||
onCommonSearch: function (field, text) {
|
||||
return false;
|
||||
},
|
||||
onPostCommonSearch: function (table) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults.icons, {
|
||||
commonSearchIcon: 'glyphicon-search'
|
||||
});
|
||||
|
||||
$.extend($.fn.bootstrapTable.Constructor.EVENTS, {
|
||||
'common-search.bs.table': 'onCommonSearch',
|
||||
'post-common-search.bs.table': 'onPostCommonSearch'
|
||||
});
|
||||
$.extend($.fn.bootstrapTable.locales[$.fn.bootstrapTable.defaults.locale], {
|
||||
formatCommonSearch: function () {
|
||||
return "Common search";
|
||||
},
|
||||
formatCommonSubmitButton: function () {
|
||||
return "Submit";
|
||||
},
|
||||
formatCommonResetButton: function () {
|
||||
return "Reset";
|
||||
},
|
||||
formatCommonCloseButton: function () {
|
||||
return "Close";
|
||||
},
|
||||
formatCommonChoose: function () {
|
||||
return "Choose";
|
||||
}
|
||||
});
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales);
|
||||
|
||||
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
||||
_initHeader = BootstrapTable.prototype.initHeader,
|
||||
_initToolbar = BootstrapTable.prototype.initToolbar,
|
||||
_load = BootstrapTable.prototype.load,
|
||||
_initSearch = BootstrapTable.prototype.initSearch;
|
||||
|
||||
BootstrapTable.prototype.initHeader = function () {
|
||||
_initHeader.apply(this, Array.prototype.slice.apply(arguments));
|
||||
this.$header.find('th[data-field]').each(function (i) {
|
||||
var column = $(this).data();
|
||||
if (typeof column['width'] !== 'undefined' && column['width'].toString().indexOf("%") === -1) {
|
||||
$(".th-inner", this).outerWidth(column['width']);
|
||||
$(this).css("max-width", column['width']);
|
||||
}
|
||||
});
|
||||
this.options.stateField = this.header.stateField;
|
||||
};
|
||||
BootstrapTable.prototype.initToolbar = function () {
|
||||
_initToolbar.apply(this, Array.prototype.slice.apply(arguments));
|
||||
|
||||
if (!isSearchAvailble(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var that = this,
|
||||
html = [];
|
||||
if (that.options.showSearch) {
|
||||
html.push(sprintf('<div class="columns-%s pull-%s" style="margin-top:10px;margin-bottom:10px;">', this.options.buttonsAlign, this.options.buttonsAlign));
|
||||
html.push(sprintf('<button class="btn btn-default%s' + '" type="button" name="commonSearch" title="%s">', that.options.iconSize === undefined ? '' : ' btn-' + that.options.iconSize, that.options.formatCommonSearch()));
|
||||
html.push(sprintf('<i class="%s %s"></i>', that.options.iconsPrefix, that.options.icons.commonSearchIcon))
|
||||
html.push('</button></div>');
|
||||
}
|
||||
if (that.$toolbar.find(".pull-right").length > 0) {
|
||||
$(html.join('')).insertBefore(that.$toolbar.find(".pull-right:first"));
|
||||
} else {
|
||||
that.$toolbar.append(html.join(''));
|
||||
}
|
||||
|
||||
initCommonSearch(that.columns, that);
|
||||
|
||||
that.$toolbar.find('button[name="commonSearch"]')
|
||||
.off('click').on('click', function () {
|
||||
that.$commonsearch.toggleClass("hidden");
|
||||
return;
|
||||
});
|
||||
|
||||
that.$container.on("click", "." + that.options.searchClass, function () {
|
||||
var value = $(this).data("value");
|
||||
var field = $(this).data("field");
|
||||
var ul = that.$container.closest(".panel-intro").find("ul[data-field='" + field + "']");
|
||||
if (ul.length > 0) {
|
||||
$('li a[data-value="' + value + '"][data-toggle="tab"]', ul).trigger('click');
|
||||
return;
|
||||
}
|
||||
var obj = $("form [name='" + field + "']", that.$commonsearch);
|
||||
if (obj.length > 0) {
|
||||
if (obj.is("select")) {
|
||||
$("option[value='" + value + "']", obj).prop("selected", true);
|
||||
} else if (obj.length > 1) {
|
||||
$("form [name='" + field + "'][value='" + value + "']", that.$commonsearch).prop("checked", true);
|
||||
} else {
|
||||
obj.val(value + "");
|
||||
}
|
||||
obj.trigger("change");
|
||||
$("form", that.$commonsearch).trigger("submit");
|
||||
}
|
||||
});
|
||||
var queryParams = that.options.queryParams;
|
||||
//匹配默认搜索值
|
||||
this.options.queryParams = function (params) {
|
||||
return queryParams(getQueryParams(params, getSearchQuery(that, true)));
|
||||
};
|
||||
this.trigger('post-common-search', that);
|
||||
|
||||
};
|
||||
|
||||
BootstrapTable.prototype.onCommonSearch = function () {
|
||||
var searchQuery = getSearchQuery(this);
|
||||
this.trigger('common-search', this, searchQuery);
|
||||
this.options.pageNumber = 1;
|
||||
//this.options.pageSize = $.fn.bootstrapTable.defaults.pageSize;
|
||||
this.refresh({});
|
||||
};
|
||||
|
||||
BootstrapTable.prototype.load = function (data) {
|
||||
_load.apply(this, Array.prototype.slice.apply(arguments));
|
||||
|
||||
if (!isSearchAvailble(this)) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
BootstrapTable.prototype.initSearch = function () {
|
||||
_initSearch.apply(this, Array.prototype.slice.apply(arguments));
|
||||
|
||||
if (!isSearchAvailble(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var that = this;
|
||||
var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial;
|
||||
this.data = fp ? $.grep(this.data, function (item, i) {
|
||||
for (var key in fp) {
|
||||
var fval = fp[key].toLowerCase();
|
||||
var value = item[key];
|
||||
value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header,
|
||||
that.header.formatters[$.inArray(key, that.header.fields)],
|
||||
[value, item, i], value);
|
||||
|
||||
if (!($.inArray(key, that.header.fields) !== -1 &&
|
||||
(typeof value === 'string' || typeof value === 'number') &&
|
||||
(value + '').toLowerCase().indexOf(fval) !== -1)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}) : this.data;
|
||||
};
|
||||
}(jQuery);
|
||||
74
public/assets/js/bootstrap-table-template.js
vendored
Normal file
74
public/assets/js/bootstrap-table-template.js
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* 将BootstrapTable的行使用自定义的模板来渲染
|
||||
*
|
||||
* @author: karson
|
||||
* @version: v0.0.1
|
||||
*
|
||||
* @update 2017-06-24 <http://github.com/karsonzhang/fastadmin>
|
||||
*/
|
||||
|
||||
!function ($) {
|
||||
'use strict';
|
||||
|
||||
$.extend($.fn.bootstrapTable.defaults, {
|
||||
//是否启用模板渲染
|
||||
templateView: false,
|
||||
//数据格式化的模板ID或格式函数
|
||||
templateFormatter: "itemtpl",
|
||||
//添加的父类的class
|
||||
templateParentClass: "row row-flex",
|
||||
//向table添加的class
|
||||
templateTableClass: "table-template",
|
||||
|
||||
});
|
||||
|
||||
var BootstrapTable = $.fn.bootstrapTable.Constructor,
|
||||
_initContainer = BootstrapTable.prototype.initContainer,
|
||||
_initBody = BootstrapTable.prototype.initBody,
|
||||
_initRow = BootstrapTable.prototype.initRow;
|
||||
|
||||
BootstrapTable.prototype.initContainer = function () {
|
||||
_initContainer.apply(this, Array.prototype.slice.apply(arguments));
|
||||
var that = this;
|
||||
if (!that.options.templateView) {
|
||||
return;
|
||||
}
|
||||
that.options.cardView = true;
|
||||
|
||||
};
|
||||
|
||||
BootstrapTable.prototype.initBody = function () {
|
||||
var that = this;
|
||||
$.extend(that.options, {
|
||||
showHeader: !that.options.templateView ? $.fn.bootstrapTable.defaults.showHeader : false,
|
||||
showFooter: !that.options.templateView ? $.fn.bootstrapTable.defaults.showFooter : false,
|
||||
});
|
||||
$(that.$el).toggleClass(that.options.templateTableClass, that.options.templateView);
|
||||
|
||||
_initBody.apply(this, Array.prototype.slice.apply(arguments));
|
||||
|
||||
if (!that.options.templateView) {
|
||||
return;
|
||||
} else {
|
||||
//由于Bootstrap是基于Table的,添加一个父类容器
|
||||
$("> *:not(.no-records-found)", that.$body).wrapAll($("<div />").addClass(that.options.templateParentClass));
|
||||
}
|
||||
};
|
||||
|
||||
BootstrapTable.prototype.initRow = function (item, i, data, parentDom) {
|
||||
var that = this;
|
||||
//如果未启用则使用原生的initRow方法
|
||||
if (!that.options.templateView) {
|
||||
return _initRow.apply(that, Array.prototype.slice.apply(arguments));
|
||||
}
|
||||
var $content = '';
|
||||
if (typeof that.options.templateFormatter === 'function') {
|
||||
$content = that.options.templateFormatter.call(that, item, i, data);
|
||||
} else {
|
||||
var Template = require('template');
|
||||
$content = Template(that.options.templateFormatter, {item: item, i: i, data: data});
|
||||
}
|
||||
return $content;
|
||||
};
|
||||
|
||||
}(jQuery);
|
||||
3851
public/assets/js/dropzone.js
Normal file
3851
public/assets/js/dropzone.js
Normal file
File diff suppressed because it is too large
Load Diff
1
public/assets/js/dropzone.min.js
vendored
Normal file
1
public/assets/js/dropzone.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
511
public/assets/js/echarts-theme.js
Normal file
511
public/assets/js/echarts-theme.js
Normal file
@@ -0,0 +1,511 @@
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['exports', 'echarts'], factory);
|
||||
} else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
|
||||
// CommonJS
|
||||
factory(exports, require('echarts'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory({}, root.echarts);
|
||||
}
|
||||
}(this, function (exports, echarts) {
|
||||
var log = function (msg) {
|
||||
if (typeof console !== 'undefined') {
|
||||
console && console.error && console.error(msg);
|
||||
}
|
||||
};
|
||||
if (!echarts) {
|
||||
log('ECharts is not Loaded');
|
||||
return;
|
||||
}
|
||||
echarts.registerTheme('walden', {
|
||||
"color": [
|
||||
"#3fb1e3",
|
||||
"#6be6c1",
|
||||
"#626c91",
|
||||
"#a0a7e6",
|
||||
"#c4ebad",
|
||||
"#96dee8"
|
||||
],
|
||||
"backgroundColor": "rgba(252,252,252,0)",
|
||||
"textStyle": {},
|
||||
"title": {
|
||||
"textStyle": {
|
||||
"color": "#666666"
|
||||
},
|
||||
"subtextStyle": {
|
||||
"color": "#999999"
|
||||
}
|
||||
},
|
||||
"line": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"borderWidth": "2"
|
||||
}
|
||||
},
|
||||
"lineStyle": {
|
||||
"normal": {
|
||||
"width": "3"
|
||||
}
|
||||
},
|
||||
"symbolSize": "8",
|
||||
"symbol": "emptyCircle",
|
||||
"smooth": false
|
||||
},
|
||||
"radar": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"borderWidth": "2"
|
||||
}
|
||||
},
|
||||
"lineStyle": {
|
||||
"normal": {
|
||||
"width": "3"
|
||||
}
|
||||
},
|
||||
"symbolSize": "8",
|
||||
"symbol": "emptyCircle",
|
||||
"smooth": false
|
||||
},
|
||||
"bar": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"barBorderWidth": 0,
|
||||
"barBorderColor": "#ccc"
|
||||
},
|
||||
"emphasis": {
|
||||
"barBorderWidth": 0,
|
||||
"barBorderColor": "#ccc"
|
||||
}
|
||||
}
|
||||
},
|
||||
"pie": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
},
|
||||
"emphasis": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
}
|
||||
}
|
||||
},
|
||||
"scatter": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
},
|
||||
"emphasis": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
}
|
||||
}
|
||||
},
|
||||
"boxplot": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
},
|
||||
"emphasis": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
}
|
||||
}
|
||||
},
|
||||
"parallel": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
},
|
||||
"emphasis": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sankey": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
},
|
||||
"emphasis": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
}
|
||||
}
|
||||
},
|
||||
"funnel": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
},
|
||||
"emphasis": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
}
|
||||
}
|
||||
},
|
||||
"gauge": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
},
|
||||
"emphasis": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
}
|
||||
}
|
||||
},
|
||||
"candlestick": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"color": "#e6a0d2",
|
||||
"color0": "transparent",
|
||||
"borderColor": "#e6a0d2",
|
||||
"borderColor0": "#3fb1e3",
|
||||
"borderWidth": "2"
|
||||
}
|
||||
}
|
||||
},
|
||||
"graph": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"borderWidth": 0,
|
||||
"borderColor": "#ccc"
|
||||
}
|
||||
},
|
||||
"lineStyle": {
|
||||
"normal": {
|
||||
"width": "1",
|
||||
"color": "#cccccc"
|
||||
}
|
||||
},
|
||||
"symbolSize": "8",
|
||||
"symbol": "emptyCircle",
|
||||
"smooth": false,
|
||||
"color": [
|
||||
"#3fb1e3",
|
||||
"#6be6c1",
|
||||
"#626c91",
|
||||
"#a0a7e6",
|
||||
"#c4ebad",
|
||||
"#96dee8"
|
||||
],
|
||||
"label": {
|
||||
"normal": {
|
||||
"textStyle": {
|
||||
"color": "#ffffff"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"map": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"areaColor": "#eeeeee",
|
||||
"borderColor": "#aaaaaa",
|
||||
"borderWidth": 0.5
|
||||
},
|
||||
"emphasis": {
|
||||
"areaColor": "rgba(63,177,227,0.25)",
|
||||
"borderColor": "#3fb1e3",
|
||||
"borderWidth": 1
|
||||
}
|
||||
},
|
||||
"label": {
|
||||
"normal": {
|
||||
"textStyle": {
|
||||
"color": "#ffffff"
|
||||
}
|
||||
},
|
||||
"emphasis": {
|
||||
"textStyle": {
|
||||
"color": "rgb(63,177,227)"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"geo": {
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"areaColor": "#eeeeee",
|
||||
"borderColor": "#aaaaaa",
|
||||
"borderWidth": 0.5
|
||||
},
|
||||
"emphasis": {
|
||||
"areaColor": "rgba(63,177,227,0.25)",
|
||||
"borderColor": "#3fb1e3",
|
||||
"borderWidth": 1
|
||||
}
|
||||
},
|
||||
"label": {
|
||||
"normal": {
|
||||
"textStyle": {
|
||||
"color": "#ffffff"
|
||||
}
|
||||
},
|
||||
"emphasis": {
|
||||
"textStyle": {
|
||||
"color": "rgb(63,177,227)"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"categoryAxis": {
|
||||
"axisLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "#cccccc"
|
||||
}
|
||||
},
|
||||
"axisTick": {
|
||||
"show": false,
|
||||
"lineStyle": {
|
||||
"color": "#333"
|
||||
}
|
||||
},
|
||||
"axisLabel": {
|
||||
"show": true,
|
||||
"textStyle": {
|
||||
"color": "#999999"
|
||||
}
|
||||
},
|
||||
"splitLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": [
|
||||
"#eeeeee"
|
||||
]
|
||||
}
|
||||
},
|
||||
"splitArea": {
|
||||
"show": false,
|
||||
"areaStyle": {
|
||||
"color": [
|
||||
"rgba(250,250,250,0.05)",
|
||||
"rgba(200,200,200,0.02)"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"valueAxis": {
|
||||
"axisLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "#cccccc"
|
||||
}
|
||||
},
|
||||
"axisTick": {
|
||||
"show": false,
|
||||
"lineStyle": {
|
||||
"color": "#333"
|
||||
}
|
||||
},
|
||||
"axisLabel": {
|
||||
"show": true,
|
||||
"textStyle": {
|
||||
"color": "#999999"
|
||||
}
|
||||
},
|
||||
"splitLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": [
|
||||
"#eeeeee"
|
||||
]
|
||||
}
|
||||
},
|
||||
"splitArea": {
|
||||
"show": false,
|
||||
"areaStyle": {
|
||||
"color": [
|
||||
"rgba(250,250,250,0.05)",
|
||||
"rgba(200,200,200,0.02)"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"logAxis": {
|
||||
"axisLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "#cccccc"
|
||||
}
|
||||
},
|
||||
"axisTick": {
|
||||
"show": false,
|
||||
"lineStyle": {
|
||||
"color": "#333"
|
||||
}
|
||||
},
|
||||
"axisLabel": {
|
||||
"show": true,
|
||||
"textStyle": {
|
||||
"color": "#999999"
|
||||
}
|
||||
},
|
||||
"splitLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": [
|
||||
"#eeeeee"
|
||||
]
|
||||
}
|
||||
},
|
||||
"splitArea": {
|
||||
"show": false,
|
||||
"areaStyle": {
|
||||
"color": [
|
||||
"rgba(250,250,250,0.05)",
|
||||
"rgba(200,200,200,0.02)"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeAxis": {
|
||||
"axisLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": "#cccccc"
|
||||
}
|
||||
},
|
||||
"axisTick": {
|
||||
"show": false,
|
||||
"lineStyle": {
|
||||
"color": "#333"
|
||||
}
|
||||
},
|
||||
"axisLabel": {
|
||||
"show": true,
|
||||
"textStyle": {
|
||||
"color": "#999999"
|
||||
}
|
||||
},
|
||||
"splitLine": {
|
||||
"show": true,
|
||||
"lineStyle": {
|
||||
"color": [
|
||||
"#eeeeee"
|
||||
]
|
||||
}
|
||||
},
|
||||
"splitArea": {
|
||||
"show": false,
|
||||
"areaStyle": {
|
||||
"color": [
|
||||
"rgba(250,250,250,0.05)",
|
||||
"rgba(200,200,200,0.02)"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"toolbox": {
|
||||
"iconStyle": {
|
||||
"normal": {
|
||||
"borderColor": "#999999"
|
||||
},
|
||||
"emphasis": {
|
||||
"borderColor": "#666666"
|
||||
}
|
||||
}
|
||||
},
|
||||
"legend": {
|
||||
"textStyle": {
|
||||
"color": "#999999"
|
||||
}
|
||||
},
|
||||
"tooltip": {
|
||||
"axisPointer": {
|
||||
"lineStyle": {
|
||||
"color": "#cccccc",
|
||||
"width": 1
|
||||
},
|
||||
"crossStyle": {
|
||||
"color": "#cccccc",
|
||||
"width": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeline": {
|
||||
"lineStyle": {
|
||||
"color": "#626c91",
|
||||
"width": 1
|
||||
},
|
||||
"itemStyle": {
|
||||
"normal": {
|
||||
"color": "#626c91",
|
||||
"borderWidth": 1
|
||||
},
|
||||
"emphasis": {
|
||||
"color": "#626c91"
|
||||
}
|
||||
},
|
||||
"controlStyle": {
|
||||
"normal": {
|
||||
"color": "#626c91",
|
||||
"borderColor": "#626c91",
|
||||
"borderWidth": 0.5
|
||||
},
|
||||
"emphasis": {
|
||||
"color": "#626c91",
|
||||
"borderColor": "#626c91",
|
||||
"borderWidth": 0.5
|
||||
}
|
||||
},
|
||||
"checkpointStyle": {
|
||||
"color": "#3fb1e3",
|
||||
"borderColor": "rgba(63,177,227,0.15)"
|
||||
},
|
||||
"label": {
|
||||
"normal": {
|
||||
"textStyle": {
|
||||
"color": "#626c91"
|
||||
}
|
||||
},
|
||||
"emphasis": {
|
||||
"textStyle": {
|
||||
"color": "#626c91"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"visualMap": {
|
||||
"color": [
|
||||
"#2a99c9",
|
||||
"#afe8ff"
|
||||
]
|
||||
},
|
||||
"dataZoom": {
|
||||
"backgroundColor": "rgba(255,255,255,0)",
|
||||
"dataBackgroundColor": "rgba(222,222,222,1)",
|
||||
"fillerColor": "rgba(114,230,212,0.25)",
|
||||
"handleColor": "#cccccc",
|
||||
"handleSize": "100%",
|
||||
"textStyle": {
|
||||
"color": "#999999"
|
||||
}
|
||||
},
|
||||
"markPoint": {
|
||||
"label": {
|
||||
"normal": {
|
||||
"textStyle": {
|
||||
"color": "#ffffff"
|
||||
}
|
||||
},
|
||||
"emphasis": {
|
||||
"textStyle": {
|
||||
"color": "#ffffff"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
22
public/assets/js/echarts.min.js
vendored
Normal file
22
public/assets/js/echarts.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
370
public/assets/js/fast.js
Normal file
370
public/assets/js/fast.js
Normal file
@@ -0,0 +1,370 @@
|
||||
define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefined, Toastr, Layer, Lang) {
|
||||
var Fast = {
|
||||
config: {
|
||||
//toastr默认配置
|
||||
toastr: {
|
||||
"closeButton": true,
|
||||
"debug": false,
|
||||
"newestOnTop": false,
|
||||
"progressBar": false,
|
||||
"positionClass": "toast-top-center",
|
||||
"preventDuplicates": false,
|
||||
"onclick": null,
|
||||
"showDuration": "300",
|
||||
"hideDuration": "1000",
|
||||
"timeOut": "5000",
|
||||
"extendedTimeOut": "1000",
|
||||
"showEasing": "swing",
|
||||
"hideEasing": "linear",
|
||||
"showMethod": "fadeIn",
|
||||
"hideMethod": "fadeOut"
|
||||
}
|
||||
},
|
||||
events: {
|
||||
//请求成功的回调
|
||||
onAjaxSuccess: function (ret, onAjaxSuccess) {
|
||||
var data = typeof ret.data !== 'undefined' ? ret.data : null;
|
||||
var msg = typeof ret.msg !== 'undefined' && ret.msg ? ret.msg : __('Operation completed');
|
||||
|
||||
if (typeof onAjaxSuccess === 'function') {
|
||||
var result = onAjaxSuccess.call(this, data, ret);
|
||||
if (result === false)
|
||||
return;
|
||||
}
|
||||
Toastr.success(msg);
|
||||
},
|
||||
//请求错误的回调
|
||||
onAjaxError: function (ret, onAjaxError) {
|
||||
var data = typeof ret.data !== 'undefined' ? ret.data : null;
|
||||
if (typeof onAjaxError === 'function') {
|
||||
var result = onAjaxError.call(this, data, ret);
|
||||
if (result === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Toastr.error(ret.msg);
|
||||
},
|
||||
//服务器响应数据后
|
||||
onAjaxResponse: function (response) {
|
||||
try {
|
||||
var ret = typeof response === 'object' ? response : JSON.parse(response);
|
||||
if (!ret.hasOwnProperty('code')) {
|
||||
$.extend(ret, {code: -2, msg: response, data: null});
|
||||
}
|
||||
} catch (e) {
|
||||
var ret = {code: -1, msg: e.message, data: null};
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
},
|
||||
api: {
|
||||
//发送Ajax请求
|
||||
ajax: function (options, success, error) {
|
||||
options = typeof options === 'string' ? {url: options} : options;
|
||||
var index;
|
||||
if (typeof options.loading === 'undefined' || options.loading) {
|
||||
index = Layer.load(options.loading || 0);
|
||||
}
|
||||
options = $.extend({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
success: function (ret) {
|
||||
index && Layer.close(index);
|
||||
ret = Fast.events.onAjaxResponse(ret);
|
||||
if (ret.code === 1) {
|
||||
Fast.events.onAjaxSuccess(ret, success);
|
||||
} else {
|
||||
Fast.events.onAjaxError(ret, error);
|
||||
}
|
||||
},
|
||||
error: function (xhr) {
|
||||
index && Layer.close(index);
|
||||
var ret = {code: xhr.status, msg: xhr.statusText, data: null};
|
||||
Fast.events.onAjaxError(ret, error);
|
||||
}
|
||||
}, options);
|
||||
return $.ajax(options);
|
||||
},
|
||||
//修复URL
|
||||
fixurl: function (url) {
|
||||
if (url.substr(0, 1) !== "/") {
|
||||
var r = new RegExp('^(?:[a-z]+:)?//', 'i');
|
||||
if (!r.test(url)) {
|
||||
url = Config.moduleurl + "/" + url;
|
||||
}
|
||||
} else if (url.substr(0, 8) === "/addons/") {
|
||||
url = Config.__PUBLIC__.replace(/(\/*$)/g, "") + url;
|
||||
}
|
||||
return url;
|
||||
},
|
||||
//获取修复后可访问的cdn链接
|
||||
cdnurl: function (url, domain) {
|
||||
var rule = new RegExp("^((?:[a-z]+:)?\\/\\/|data:image\\/)", "i");
|
||||
var cdnurl = Config.upload.cdnurl;
|
||||
if (typeof domain === 'undefined' || domain === true || cdnurl.indexOf("/") === 0) {
|
||||
url = rule.test(url) || (cdnurl && url.indexOf(cdnurl) === 0) ? url : cdnurl + url;
|
||||
}
|
||||
if (domain && !rule.test(url)) {
|
||||
domain = typeof domain === 'string' ? domain : location.origin;
|
||||
url = domain + url;
|
||||
}
|
||||
return url;
|
||||
},
|
||||
//查询Url参数
|
||||
query: function (name, url) {
|
||||
if (!url) {
|
||||
url = window.location.href;
|
||||
}
|
||||
name = name.replace(/[\[\]]/g, "\\$&");
|
||||
var regex = new RegExp("[?&/]" + name + "([=/]([^&#/?]*)|&|#|$)"),
|
||||
results = regex.exec(url);
|
||||
if (!results)
|
||||
return null;
|
||||
if (!results[2])
|
||||
return '';
|
||||
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
||||
},
|
||||
//打开一个弹出窗口
|
||||
open: function (url, title, options) {
|
||||
title = options && options.title ? options.title : (title ? title : "");
|
||||
url = Fast.api.fixurl(url);
|
||||
url = url + (url.indexOf("?") > -1 ? "&" : "?") + "dialog=1";
|
||||
var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%'];
|
||||
options = $.extend({
|
||||
type: 2,
|
||||
title: title,
|
||||
shadeClose: true,
|
||||
shade: false,
|
||||
maxmin: true,
|
||||
moveOut: true,
|
||||
area: area,
|
||||
content: url,
|
||||
zIndex: Layer.zIndex,
|
||||
success: function (layero, index) {
|
||||
var that = this;
|
||||
//存储callback事件
|
||||
$(layero).data("callback", that.callback);
|
||||
//$(layero).removeClass("layui-layer-border");
|
||||
Layer.setTop(layero);
|
||||
try {
|
||||
var frame = Layer.getChildFrame('html', index);
|
||||
var layerfooter = frame.find(".layer-footer");
|
||||
Fast.api.layerfooter(layero, index, that);
|
||||
|
||||
//绑定事件
|
||||
if (layerfooter.length > 0) {
|
||||
// 监听窗口内的元素及属性变化
|
||||
// Firefox和Chrome早期版本中带有前缀
|
||||
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
|
||||
if (MutationObserver) {
|
||||
// 选择目标节点
|
||||
var target = layerfooter[0];
|
||||
// 创建观察者对象
|
||||
var observer = new MutationObserver(function (mutations) {
|
||||
Fast.api.layerfooter(layero, index, that);
|
||||
mutations.forEach(function (mutation) {
|
||||
});
|
||||
});
|
||||
// 配置观察选项:
|
||||
var config = {attributes: true, childList: true, characterData: true, subtree: true}
|
||||
// 传入目标节点和观察选项
|
||||
observer.observe(target, config);
|
||||
// 随后,你还可以停止观察
|
||||
// observer.disconnect();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
if ($(layero).height() > $(window).height()) {
|
||||
//当弹出窗口大于浏览器可视高度时,重定位
|
||||
Layer.style(index, {
|
||||
top: 0,
|
||||
height: $(window).height()
|
||||
});
|
||||
}
|
||||
}
|
||||
}, options ? options : {});
|
||||
if ($(window).width() < 480 || (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").length > 0)) {
|
||||
if (top.$(".tab-pane.active").length > 0) {
|
||||
options.area = [top.$(".tab-pane.active").width() + "px", top.$(".tab-pane.active").height() + "px"];
|
||||
options.offset = [top.$(".tab-pane.active").scrollTop() + "px", "0px"];
|
||||
} else {
|
||||
options.area = [$(window).width() + "px", $(window).height() + "px"];
|
||||
options.offset = ["0px", "0px"];
|
||||
}
|
||||
}
|
||||
return Layer.open(options);
|
||||
},
|
||||
//关闭窗口并回传数据
|
||||
close: function (data) {
|
||||
var index = parent.Layer.getFrameIndex(window.name);
|
||||
var callback = parent.$("#layui-layer" + index).data("callback");
|
||||
//再执行关闭
|
||||
parent.Layer.close(index);
|
||||
//再调用回传函数
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(undefined, data);
|
||||
}
|
||||
},
|
||||
layerfooter: function (layero, index, that) {
|
||||
var frame = Layer.getChildFrame('html', index);
|
||||
var layerfooter = frame.find(".layer-footer");
|
||||
if (layerfooter.length > 0) {
|
||||
$(".layui-layer-footer", layero).remove();
|
||||
var footer = $("<div />").addClass('layui-layer-btn layui-layer-footer');
|
||||
footer.html(layerfooter.html());
|
||||
if ($(".row", footer).length === 0) {
|
||||
$(">", footer).wrapAll("<div class='row'></div>");
|
||||
}
|
||||
footer.insertAfter(layero.find('.layui-layer-content'));
|
||||
//绑定事件
|
||||
footer.on("click", ".btn", function () {
|
||||
if ($(this).hasClass("disabled") || $(this).parent().hasClass("disabled")) {
|
||||
return;
|
||||
}
|
||||
var index = footer.find('.btn').index(this);
|
||||
$(".btn:eq(" + index + ")", layerfooter).trigger("click");
|
||||
});
|
||||
|
||||
var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
|
||||
var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
|
||||
//重设iframe高度
|
||||
$("iframe", layero).height(layero.height() - titHeight - btnHeight);
|
||||
}
|
||||
//修复iOS下弹出窗口的高度和iOS下iframe无法滚动的BUG
|
||||
if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
|
||||
var titHeight = layero.find('.layui-layer-title').outerHeight() || 0;
|
||||
var btnHeight = layero.find('.layui-layer-btn').outerHeight() || 0;
|
||||
$("iframe", layero).parent().css("height", layero.height() - titHeight - btnHeight);
|
||||
$("iframe", layero).css("height", "100%");
|
||||
}
|
||||
},
|
||||
success: function (options, callback) {
|
||||
var type = typeof options === 'function';
|
||||
if (type) {
|
||||
callback = options;
|
||||
}
|
||||
return Layer.msg(__('Operation completed'), $.extend({
|
||||
offset: 0, icon: 1
|
||||
}, type ? {} : options), callback);
|
||||
},
|
||||
error: function (options, callback) {
|
||||
var type = typeof options === 'function';
|
||||
if (type) {
|
||||
callback = options;
|
||||
}
|
||||
return Layer.msg(__('Operation failed'), $.extend({
|
||||
offset: 0, icon: 2
|
||||
}, type ? {} : options), callback);
|
||||
},
|
||||
msg: function (message, url) {
|
||||
var callback = typeof url === 'function' ? url : function () {
|
||||
if (typeof url !== 'undefined' && url) {
|
||||
location.href = url;
|
||||
}
|
||||
};
|
||||
Layer.msg(message, {
|
||||
time: 2000
|
||||
}, callback);
|
||||
},
|
||||
toastr: Toastr,
|
||||
layer: Layer
|
||||
},
|
||||
lang: function () {
|
||||
var args = arguments,
|
||||
string = args[0],
|
||||
i = 1;
|
||||
string = string.toLowerCase();
|
||||
//string = typeof Lang[string] != 'undefined' ? Lang[string] : string;
|
||||
if (typeof Lang !== 'undefined' && typeof Lang[string] !== 'undefined') {
|
||||
if (typeof Lang[string] == 'object')
|
||||
return Lang[string];
|
||||
string = Lang[string];
|
||||
} else if (string.indexOf('.') !== -1 && false) {
|
||||
var arr = string.split('.');
|
||||
var current = Lang[arr[0]];
|
||||
for (var i = 1; i < arr.length; i++) {
|
||||
current = typeof current[arr[i]] != 'undefined' ? current[arr[i]] : '';
|
||||
if (typeof current != 'object')
|
||||
break;
|
||||
}
|
||||
if (typeof current == 'object')
|
||||
return current;
|
||||
string = current;
|
||||
} else {
|
||||
string = args[0];
|
||||
}
|
||||
return string.replace(/%((%)|s|d)/g, function (m) {
|
||||
// m is the matched format, e.g. %s, %d
|
||||
var val = null;
|
||||
if (m[2]) {
|
||||
val = m[2];
|
||||
} else {
|
||||
val = args[i];
|
||||
// A switch statement so that the formatter can be extended. Default is %s
|
||||
switch (m) {
|
||||
case '%d':
|
||||
val = parseFloat(val);
|
||||
if (isNaN(val)) {
|
||||
val = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return val;
|
||||
});
|
||||
},
|
||||
init: function () {
|
||||
// jQuery兼容处理
|
||||
$.fn.extend({
|
||||
size: function () {
|
||||
return $(this).length;
|
||||
}
|
||||
});
|
||||
// 对相对地址进行处理
|
||||
$.ajaxSetup({
|
||||
beforeSend: function (xhr, setting) {
|
||||
setting.url = Fast.api.fixurl(setting.url);
|
||||
}
|
||||
});
|
||||
Layer.config({
|
||||
skin: 'layui-layer-fast'
|
||||
});
|
||||
// 绑定ESC关闭窗口事件
|
||||
$(window).keyup(function (e) {
|
||||
if (e.keyCode == 27) {
|
||||
if ($(".layui-layer").length > 0) {
|
||||
var index = 0;
|
||||
$(".layui-layer").each(function () {
|
||||
index = Math.max(index, parseInt($(this).attr("times")));
|
||||
});
|
||||
if (index) {
|
||||
Layer.close(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//公共代码
|
||||
//配置Toastr的参数
|
||||
Toastr.options = Fast.config.toastr;
|
||||
}
|
||||
};
|
||||
//将Layer暴露到全局中去
|
||||
window.Layer = Layer;
|
||||
//将Toastr暴露到全局中去
|
||||
window.Toastr = Toastr;
|
||||
//将语言方法暴露到全局中去
|
||||
window.__ = Fast.lang;
|
||||
//将Fast渲染至全局
|
||||
window.Fast = Fast;
|
||||
|
||||
//默认初始化执行的代码
|
||||
Fast.init();
|
||||
return Fast;
|
||||
});
|
||||
3
public/assets/js/frontend-init.js
Normal file
3
public/assets/js/frontend-init.js
Normal file
@@ -0,0 +1,3 @@
|
||||
define(['frontend'], function (Frontend) {
|
||||
|
||||
});
|
||||
115
public/assets/js/frontend.js
Normal file
115
public/assets/js/frontend.js
Normal file
@@ -0,0 +1,115 @@
|
||||
define(['fast', 'template', 'moment'], function (Fast, Template, Moment) {
|
||||
var Frontend = {
|
||||
api: Fast.api,
|
||||
init: function () {
|
||||
var si = {};
|
||||
//发送验证码
|
||||
$(document).on("click", ".btn-captcha", function (e) {
|
||||
var type = $(this).data("type") ? $(this).data("type") : 'mobile';
|
||||
var btn = this;
|
||||
Frontend.api.sendcaptcha = function (btn, type, data, callback) {
|
||||
$(btn).addClass("disabled", true).text("发送中...");
|
||||
|
||||
Frontend.api.ajax({url: $(btn).data("url"), data: data}, function (data, ret) {
|
||||
clearInterval(si[type]);
|
||||
var seconds = 60;
|
||||
si[type] = setInterval(function () {
|
||||
seconds--;
|
||||
if (seconds <= 0) {
|
||||
clearInterval(si);
|
||||
$(btn).removeClass("disabled").text("发送验证码");
|
||||
} else {
|
||||
$(btn).addClass("disabled").text(seconds + "秒后可再次发送");
|
||||
}
|
||||
}, 1000);
|
||||
if (typeof callback == 'function') {
|
||||
callback.call(this, data, ret);
|
||||
}
|
||||
}, function () {
|
||||
$(btn).removeClass("disabled").text('发送验证码');
|
||||
});
|
||||
};
|
||||
if (['mobile', 'email'].indexOf(type) > -1) {
|
||||
var element = $(this).data("input-id") ? $("#" + $(this).data("input-id")) : $("input[name='" + type + "']", $(this).closest("form"));
|
||||
var text = type === 'email' ? '邮箱' : '手机号码';
|
||||
if (element.val() === "") {
|
||||
Layer.msg(text + "不能为空!");
|
||||
element.focus();
|
||||
return false;
|
||||
} else if (type === 'mobile' && !element.val().match(/^1[3-9]\d{9}$/)) {
|
||||
Layer.msg("请输入正确的" + text + "!");
|
||||
element.focus();
|
||||
return false;
|
||||
} else if (type === 'email' && !element.val().match(/^[\w\+\-]+(\.[\w\+\-]+)*@[a-z\d\-]+(\.[a-z\d\-]+)*\.([a-z]{2,4})$/)) {
|
||||
Layer.msg("请输入正确的" + text + "!");
|
||||
element.focus();
|
||||
return false;
|
||||
}
|
||||
element.isValid(function (v) {
|
||||
if (v) {
|
||||
var data = {event: $(btn).data("event")};
|
||||
data[type] = element.val();
|
||||
Frontend.api.sendcaptcha(btn, type, data);
|
||||
} else {
|
||||
Layer.msg("请确认已经输入了正确的" + text + "!");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var data = {event: $(btn).data("event")};
|
||||
Frontend.api.sendcaptcha(btn, type, data, function (data, ret) {
|
||||
Layer.open({title: false, area: ["400px", "430px"], content: "<img src='" + data.image + "' width='400' height='400' /><div class='text-center panel-title'>扫一扫关注公众号获取验证码</div>", type: 1});
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
//tooltip和popover
|
||||
if (!('ontouchstart' in document.documentElement)) {
|
||||
$('body').tooltip({selector: '[data-toggle="tooltip"]'});
|
||||
}
|
||||
$('body').popover({selector: '[data-toggle="popover"]'});
|
||||
|
||||
// 手机端左右滑动切换菜单栏
|
||||
if ('ontouchstart' in document.documentElement) {
|
||||
var startX, startY, moveEndX, moveEndY, relativeX, relativeY, element;
|
||||
element = $('body', document);
|
||||
element.on("touchstart", function (e) {
|
||||
startX = e.originalEvent.changedTouches[0].pageX;
|
||||
startY = e.originalEvent.changedTouches[0].pageY;
|
||||
});
|
||||
element.on("touchend", function (e) {
|
||||
moveEndX = e.originalEvent.changedTouches[0].pageX;
|
||||
moveEndY = e.originalEvent.changedTouches[0].pageY;
|
||||
relativeX = moveEndX - startX;
|
||||
relativeY = moveEndY - startY;
|
||||
|
||||
// 判断标准
|
||||
//右滑
|
||||
if (relativeX > 45) {
|
||||
if ((Math.abs(relativeX) - Math.abs(relativeY)) > 50) {
|
||||
element.addClass("sidebar-open");
|
||||
}
|
||||
}
|
||||
//左滑
|
||||
else if (relativeX < -45) {
|
||||
if ((Math.abs(relativeX) - Math.abs(relativeY)) > 50) {
|
||||
element.removeClass("sidebar-open");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$(document).on("click", ".sidebar-toggle", function () {
|
||||
$("body").toggleClass("sidebar-open");
|
||||
});
|
||||
}
|
||||
};
|
||||
Frontend.api = $.extend(Fast.api, Frontend.api);
|
||||
//将Template渲染至全局,以便于在子框架中调用
|
||||
window.Template = Template;
|
||||
//将Moment渲染至全局,以便于在子框架中调用
|
||||
window.Moment = Moment;
|
||||
//将Frontend渲染至全局,以便于在子框架中调用
|
||||
window.Frontend = Frontend;
|
||||
|
||||
Frontend.init();
|
||||
return Frontend;
|
||||
});
|
||||
195
public/assets/js/frontend/user.js
Normal file
195
public/assets/js/frontend/user.js
Normal file
@@ -0,0 +1,195 @@
|
||||
define(['jquery', 'bootstrap', 'frontend', 'form', 'template'], function ($, undefined, Frontend, Form, Template) {
|
||||
var validatoroptions = {
|
||||
invalid: function (form, errors) {
|
||||
$.each(errors, function (i, j) {
|
||||
Layer.msg(j);
|
||||
});
|
||||
}
|
||||
};
|
||||
var Controller = {
|
||||
login: function () {
|
||||
|
||||
//本地验证未通过时提示
|
||||
$("#login-form").data("validator-options", validatoroptions);
|
||||
|
||||
//为表单绑定事件
|
||||
Form.api.bindevent($("#login-form"), function (data, ret) {
|
||||
setTimeout(function () {
|
||||
location.href = ret.url ? ret.url : "/";
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
//忘记密码
|
||||
$(document).on("click", ".btn-forgot", function () {
|
||||
var id = "resetpwdtpl";
|
||||
var content = Template(id, {});
|
||||
Layer.open({
|
||||
type: 1,
|
||||
title: __('Reset password'),
|
||||
area: [$(window).width() < 450 ? ($(window).width() - 10) + "px" : "450px", "355px"],
|
||||
content: content,
|
||||
success: function (layero) {
|
||||
var rule = $("#resetpwd-form input[name='captcha']").data("rule");
|
||||
Form.api.bindevent($("#resetpwd-form", layero), function (data) {
|
||||
Layer.closeAll();
|
||||
});
|
||||
$(layero).on("change", "input[name=type]", function () {
|
||||
var type = $(this).val();
|
||||
$("div.form-group[data-type]").addClass("hide");
|
||||
$("div.form-group[data-type='" + type + "']").removeClass("hide");
|
||||
$('#resetpwd-form').validator("setField", {
|
||||
captcha: rule.replace(/remote\((.*)\)/, "remote(" + $(this).data("check-url") + ", event=resetpwd, " + type + ":#" + type + ")")
|
||||
});
|
||||
$(".btn-captcha").data("url", $(this).data("send-url")).data("type", type);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
register: function () {
|
||||
//本地验证未通过时提示
|
||||
$("#register-form").data("validator-options", validatoroptions);
|
||||
|
||||
//为表单绑定事件
|
||||
Form.api.bindevent($("#register-form"), function (data, ret) {
|
||||
setTimeout(function () {
|
||||
location.href = ret.url ? ret.url : "/";
|
||||
}, 1000);
|
||||
}, function (data) {
|
||||
$("input[name=captcha]").next(".input-group-btn").find("img").trigger("click");
|
||||
});
|
||||
},
|
||||
changepwd: function () {
|
||||
//本地验证未通过时提示
|
||||
$("#changepwd-form").data("validator-options", validatoroptions);
|
||||
|
||||
//为表单绑定事件
|
||||
Form.api.bindevent($("#changepwd-form"), function (data, ret) {
|
||||
setTimeout(function () {
|
||||
location.href = ret.url ? ret.url : "/";
|
||||
}, 1000);
|
||||
});
|
||||
},
|
||||
profile: function () {
|
||||
// 给上传按钮添加上传成功事件
|
||||
$("#faupload-avatar").data("upload-success", function (data) {
|
||||
var url = Fast.api.cdnurl(data.url);
|
||||
$(".profile-user-img").prop("src", url);
|
||||
Toastr.success(__('Uploaded successful'));
|
||||
});
|
||||
Form.api.bindevent($("#profile-form"));
|
||||
$(document).on("click", ".btn-change", function () {
|
||||
var that = this;
|
||||
var id = $(this).data("type") + "tpl";
|
||||
var content = Template(id, {});
|
||||
Layer.open({
|
||||
type: 1,
|
||||
title: "修改",
|
||||
area: [$(window).width() < 450 ? ($(window).width() - 10) + "px" : "450px", "355px"],
|
||||
content: content,
|
||||
success: function (layero) {
|
||||
var form = $("form", layero);
|
||||
Form.api.bindevent(form, function (data) {
|
||||
location.reload();
|
||||
Layer.closeAll();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
attachment: function () {
|
||||
require(['table'], function (Table) {
|
||||
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'user/attachment',
|
||||
}
|
||||
});
|
||||
var urlArr = [];
|
||||
var multiple = Fast.api.query('multiple');
|
||||
multiple = multiple == 'true' ? true : false;
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
table.on('check.bs.table uncheck.bs.table check-all.bs.table uncheck-all.bs.table', function (e, row) {
|
||||
if (e.type == 'check' || e.type == 'uncheck') {
|
||||
row = [row];
|
||||
} else {
|
||||
urlArr = [];
|
||||
}
|
||||
$.each(row, function (i, j) {
|
||||
if (e.type.indexOf("uncheck") > -1) {
|
||||
var index = urlArr.indexOf(j.url);
|
||||
if (index > -1) {
|
||||
urlArr.splice(index, 1);
|
||||
}
|
||||
} else {
|
||||
urlArr.indexOf(j.url) == -1 && urlArr.push(j.url);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
sortName: 'id',
|
||||
showToggle: false,
|
||||
showExport: false,
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: multiple, visible: multiple, operate: false},
|
||||
{field: 'id', title: __('Id'), operate: false},
|
||||
{
|
||||
field: 'url', title: __('Preview'), formatter: function (value, row, index) {
|
||||
var html = '';
|
||||
if (row.mimetype.indexOf("image") > -1) {
|
||||
html = '<a href="' + row.fullurl + '" target="_blank"><img src="' + row.fullurl + row.thumb_style + '" alt="" style="max-height:60px;max-width:120px"></a>';
|
||||
} else {
|
||||
html = '<a href="' + row.fullurl + '" target="_blank"><img src="' + Fast.api.fixurl("ajax/icon") + "?suffix=" + row.imagetype + '" alt="" style="max-height:90px;max-width:120px"></a>';
|
||||
}
|
||||
return '<div style="width:120px;margin:0 auto;text-align:center;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">' + html + '</div>';
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'filename', title: __('Filename'), formatter: function (value, row, index) {
|
||||
return '<div style="width:150px;margin:0 auto;text-align:center;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;">' + Table.api.formatter.search.call(this, value, row, index) + '</div>';
|
||||
}, operate: 'like'
|
||||
},
|
||||
{field: 'imagewidth', title: __('Imagewidth'), operate: false},
|
||||
{field: 'imageheight', title: __('Imageheight'), operate: false},
|
||||
{field: 'mimetype', title: __('Mimetype'), formatter: Table.api.formatter.search},
|
||||
{field: 'createtime', title: __('Createtime'), width: 120, formatter: Table.api.formatter.datetime, datetimeFormat: 'YYYY-MM-DD', operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
||||
{
|
||||
field: 'operate', title: __('Operate'), width: 85, events: {
|
||||
'click .btn-chooseone': function (e, value, row, index) {
|
||||
Fast.api.close({url: row.url, multiple: multiple});
|
||||
},
|
||||
}, formatter: function () {
|
||||
return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 选中多个
|
||||
$(document).on("click", ".btn-choose-multi", function () {
|
||||
Fast.api.close({url: urlArr.join(","), multiple: multiple});
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
require(['upload'], function (Upload) {
|
||||
Upload.api.upload($("#toolbar .faupload"), function () {
|
||||
$(".btn-refresh").trigger("click");
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
322
public/assets/js/html5shiv.js
vendored
Normal file
322
public/assets/js/html5shiv.js
vendored
Normal file
@@ -0,0 +1,322 @@
|
||||
/**
|
||||
* @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
|
||||
*/
|
||||
;(function(window, document) {
|
||||
/*jshint evil:true */
|
||||
/** version */
|
||||
var version = '3.7.2';
|
||||
|
||||
/** Preset options */
|
||||
var options = window.html5 || {};
|
||||
|
||||
/** Used to skip problem elements */
|
||||
var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i;
|
||||
|
||||
/** Not all elements can be cloned in IE **/
|
||||
var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i;
|
||||
|
||||
/** Detect whether the browser supports default html5 styles */
|
||||
var supportsHtml5Styles;
|
||||
|
||||
/** Name of the expando, to work with multiple documents or to re-shiv one document */
|
||||
var expando = '_html5shiv';
|
||||
|
||||
/** The id for the the documents expando */
|
||||
var expanID = 0;
|
||||
|
||||
/** Cached data for each document */
|
||||
var expandoData = {};
|
||||
|
||||
/** Detect whether the browser supports unknown elements */
|
||||
var supportsUnknownElements;
|
||||
|
||||
(function() {
|
||||
try {
|
||||
var a = document.createElement('a');
|
||||
a.innerHTML = '<xyz></xyz>';
|
||||
//if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles
|
||||
supportsHtml5Styles = ('hidden' in a);
|
||||
|
||||
supportsUnknownElements = a.childNodes.length == 1 || (function() {
|
||||
// assign a false positive if unable to shiv
|
||||
(document.createElement)('a');
|
||||
var frag = document.createDocumentFragment();
|
||||
return (
|
||||
typeof frag.cloneNode == 'undefined' ||
|
||||
typeof frag.createDocumentFragment == 'undefined' ||
|
||||
typeof frag.createElement == 'undefined'
|
||||
);
|
||||
}());
|
||||
} catch(e) {
|
||||
// assign a false positive if detection fails => unable to shiv
|
||||
supportsHtml5Styles = true;
|
||||
supportsUnknownElements = true;
|
||||
}
|
||||
|
||||
}());
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Creates a style sheet with the given CSS text and adds it to the document.
|
||||
* @private
|
||||
* @param {Document} ownerDocument The document.
|
||||
* @param {String} cssText The CSS text.
|
||||
* @returns {StyleSheet} The style element.
|
||||
*/
|
||||
function addStyleSheet(ownerDocument, cssText) {
|
||||
var p = ownerDocument.createElement('p'),
|
||||
parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
|
||||
|
||||
p.innerHTML = 'x<style>' + cssText + '</style>';
|
||||
return parent.insertBefore(p.lastChild, parent.firstChild);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of `html5.elements` as an array.
|
||||
* @private
|
||||
* @returns {Array} An array of shived element node names.
|
||||
*/
|
||||
function getElements() {
|
||||
var elements = html5.elements;
|
||||
return typeof elements == 'string' ? elements.split(' ') : elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends the built-in list of html5 elements
|
||||
* @memberOf html5
|
||||
* @param {String|Array} newElements whitespace separated list or array of new element names to shiv
|
||||
* @param {Document} ownerDocument The context document.
|
||||
*/
|
||||
function addElements(newElements, ownerDocument) {
|
||||
var elements = html5.elements;
|
||||
if(typeof elements != 'string'){
|
||||
elements = elements.join(' ');
|
||||
}
|
||||
if(typeof newElements != 'string'){
|
||||
newElements = newElements.join(' ');
|
||||
}
|
||||
html5.elements = elements +' '+ newElements;
|
||||
shivDocument(ownerDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data associated to the given document
|
||||
* @private
|
||||
* @param {Document} ownerDocument The document.
|
||||
* @returns {Object} An object of data.
|
||||
*/
|
||||
function getExpandoData(ownerDocument) {
|
||||
var data = expandoData[ownerDocument[expando]];
|
||||
if (!data) {
|
||||
data = {};
|
||||
expanID++;
|
||||
ownerDocument[expando] = expanID;
|
||||
expandoData[expanID] = data;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a shived element for the given nodeName and document
|
||||
* @memberOf html5
|
||||
* @param {String} nodeName name of the element
|
||||
* @param {Document} ownerDocument The context document.
|
||||
* @returns {Object} The shived element.
|
||||
*/
|
||||
function createElement(nodeName, ownerDocument, data){
|
||||
if (!ownerDocument) {
|
||||
ownerDocument = document;
|
||||
}
|
||||
if(supportsUnknownElements){
|
||||
return ownerDocument.createElement(nodeName);
|
||||
}
|
||||
if (!data) {
|
||||
data = getExpandoData(ownerDocument);
|
||||
}
|
||||
var node;
|
||||
|
||||
if (data.cache[nodeName]) {
|
||||
node = data.cache[nodeName].cloneNode();
|
||||
} else if (saveClones.test(nodeName)) {
|
||||
node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
|
||||
} else {
|
||||
node = data.createElem(nodeName);
|
||||
}
|
||||
|
||||
// Avoid adding some elements to fragments in IE < 9 because
|
||||
// * Attributes like `name` or `type` cannot be set/changed once an element
|
||||
// is inserted into a document/fragment
|
||||
// * Link elements with `src` attributes that are inaccessible, as with
|
||||
// a 403 response, will cause the tab/window to crash
|
||||
// * Script elements appended to fragments will execute when their `src`
|
||||
// or `text` property is set
|
||||
return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a shived DocumentFragment for the given document
|
||||
* @memberOf html5
|
||||
* @param {Document} ownerDocument The context document.
|
||||
* @returns {Object} The shived DocumentFragment.
|
||||
*/
|
||||
function createDocumentFragment(ownerDocument, data){
|
||||
if (!ownerDocument) {
|
||||
ownerDocument = document;
|
||||
}
|
||||
if(supportsUnknownElements){
|
||||
return ownerDocument.createDocumentFragment();
|
||||
}
|
||||
data = data || getExpandoData(ownerDocument);
|
||||
var clone = data.frag.cloneNode(),
|
||||
i = 0,
|
||||
elems = getElements(),
|
||||
l = elems.length;
|
||||
for(;i<l;i++){
|
||||
clone.createElement(elems[i]);
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shivs the `createElement` and `createDocumentFragment` methods of the document.
|
||||
* @private
|
||||
* @param {Document|DocumentFragment} ownerDocument The document.
|
||||
* @param {Object} data of the document.
|
||||
*/
|
||||
function shivMethods(ownerDocument, data) {
|
||||
if (!data.cache) {
|
||||
data.cache = {};
|
||||
data.createElem = ownerDocument.createElement;
|
||||
data.createFrag = ownerDocument.createDocumentFragment;
|
||||
data.frag = data.createFrag();
|
||||
}
|
||||
|
||||
|
||||
ownerDocument.createElement = function(nodeName) {
|
||||
//abort shiv
|
||||
if (!html5.shivMethods) {
|
||||
return data.createElem(nodeName);
|
||||
}
|
||||
return createElement(nodeName, ownerDocument, data);
|
||||
};
|
||||
|
||||
ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +
|
||||
'var n=f.cloneNode(),c=n.createElement;' +
|
||||
'h.shivMethods&&(' +
|
||||
// unroll the `createElement` calls
|
||||
getElements().join().replace(/[\w\-:]+/g, function(nodeName) {
|
||||
data.createElem(nodeName);
|
||||
data.frag.createElement(nodeName);
|
||||
return 'c("' + nodeName + '")';
|
||||
}) +
|
||||
');return n}'
|
||||
)(html5, data.frag);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Shivs the given document.
|
||||
* @memberOf html5
|
||||
* @param {Document} ownerDocument The document to shiv.
|
||||
* @returns {Document} The shived document.
|
||||
*/
|
||||
function shivDocument(ownerDocument) {
|
||||
if (!ownerDocument) {
|
||||
ownerDocument = document;
|
||||
}
|
||||
var data = getExpandoData(ownerDocument);
|
||||
|
||||
if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) {
|
||||
data.hasCSS = !!addStyleSheet(ownerDocument,
|
||||
// corrects block display not defined in IE6/7/8/9
|
||||
'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' +
|
||||
// adds styling not present in IE6/7/8/9
|
||||
'mark{background:#FF0;color:#000}' +
|
||||
// hides non-rendered elements
|
||||
'template{display:none}'
|
||||
);
|
||||
}
|
||||
if (!supportsUnknownElements) {
|
||||
shivMethods(ownerDocument, data);
|
||||
}
|
||||
return ownerDocument;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The `html5` object is exposed so that more elements can be shived and
|
||||
* existing shiving can be detected on iframes.
|
||||
* @type Object
|
||||
* @example
|
||||
*
|
||||
* // options can be changed before the script is included
|
||||
* html5 = { 'elements': 'mark section', 'shivCSS': false, 'shivMethods': false };
|
||||
*/
|
||||
var html5 = {
|
||||
|
||||
/**
|
||||
* An array or space separated string of node names of the elements to shiv.
|
||||
* @memberOf html5
|
||||
* @type Array|String
|
||||
*/
|
||||
'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video',
|
||||
|
||||
/**
|
||||
* current version of html5shiv
|
||||
*/
|
||||
'version': version,
|
||||
|
||||
/**
|
||||
* A flag to indicate that the HTML5 style sheet should be inserted.
|
||||
* @memberOf html5
|
||||
* @type Boolean
|
||||
*/
|
||||
'shivCSS': (options.shivCSS !== false),
|
||||
|
||||
/**
|
||||
* Is equal to true if a browser supports creating unknown/HTML5 elements
|
||||
* @memberOf html5
|
||||
* @type boolean
|
||||
*/
|
||||
'supportsUnknownElements': supportsUnknownElements,
|
||||
|
||||
/**
|
||||
* A flag to indicate that the document's `createElement` and `createDocumentFragment`
|
||||
* methods should be overwritten.
|
||||
* @memberOf html5
|
||||
* @type Boolean
|
||||
*/
|
||||
'shivMethods': (options.shivMethods !== false),
|
||||
|
||||
/**
|
||||
* A string to describe the type of `html5` object ("default" or "default print").
|
||||
* @memberOf html5
|
||||
* @type String
|
||||
*/
|
||||
'type': 'default',
|
||||
|
||||
// shivs the document according to the specified `html5` object options
|
||||
'shivDocument': shivDocument,
|
||||
|
||||
//creates a shived element
|
||||
createElement: createElement,
|
||||
|
||||
//creates a shived documentFragment
|
||||
createDocumentFragment: createDocumentFragment,
|
||||
|
||||
//extends list of elements
|
||||
addElements: addElements
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
// expose html5
|
||||
window.html5 = html5;
|
||||
|
||||
// shiv the document
|
||||
shivDocument(document);
|
||||
|
||||
}(this, document));
|
||||
6
public/assets/js/jquery.drag.min.js
vendored
Normal file
6
public/assets/js/jquery.drag.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
6
public/assets/js/jquery.drop.min.js
vendored
Normal file
6
public/assets/js/jquery.drop.min.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* jquery.event.drop - v 2.2
|
||||
* Copyright (c) 2010 Three Dub Media - http://threedubmedia.com
|
||||
* Open Source MIT License - http://threedubmedia.com/code/license
|
||||
*/
|
||||
;(function(d){d.fn.drop=function(i,e,h){var g=typeof i=="string"?i:"",f=d.isFunction(i)?i:d.isFunction(e)?e:null;if(g.indexOf("drop")!==0){g="drop"+g}h=(i==f?e:h)||{};return f?this.bind(g,h,f):this.trigger(g)};d.drop=function(e){e=e||{};b.multi=e.multi===true?Infinity:e.multi===false?1:!isNaN(e.multi)?e.multi:b.multi;b.delay=e.delay||b.delay;b.tolerance=d.isFunction(e.tolerance)?e.tolerance:e.tolerance===null?null:b.tolerance;b.mode=e.mode||b.mode||"intersect"};var c=d.event,a=c.special,b=d.event.special.drop={multi:1,delay:20,mode:"overlap",targets:[],datakey:"dropdata",noBubble:true,add:function(f){var e=d.data(this,b.datakey);e.related+=1},remove:function(){d.data(this,b.datakey).related-=1},setup:function(){if(d.data(this,b.datakey)){return}var e={related:0,active:[],anyactive:0,winner:0,location:{}};d.data(this,b.datakey,e);b.targets.push(this);return false},teardown:function(){var f=d.data(this,b.datakey)||{};if(f.related){return}d.removeData(this,b.datakey);var e=this;b.targets=d.grep(b.targets,function(g){return(g!==e)})},handler:function(g,e){var f,h;if(!e){return}switch(g.type){case"mousedown":case"touchstart":h=d(b.targets);if(typeof e.drop=="string"){h=h.filter(e.drop)}h.each(function(){var i=d.data(this,b.datakey);i.active=[];i.anyactive=0;i.winner=0});e.droppable=h;a.drag.hijack(g,"dropinit",e);break;case"mousemove":case"touchmove":b.event=g;if(!b.timer){b.tolerate(e)}break;case"mouseup":case"touchend":b.timer=clearTimeout(b.timer);if(e.propagates){a.drag.hijack(g,"drop",e);a.drag.hijack(g,"dropend",e)}break}},locate:function(k,h){var l=d.data(k,b.datakey),g=d(k),i=g.offset()||{},e=g.outerHeight(),j=g.outerWidth(),f={elem:k,width:j,height:e,top:i.top,left:i.left,right:i.left+j,bottom:i.top+e};if(l){l.location=f;l.index=h;l.elem=k}return f},contains:function(e,f){return((f[0]||f.left)>=e.left&&(f[0]||f.right)<=e.right&&(f[1]||f.top)>=e.top&&(f[1]||f.bottom)<=e.bottom)},modes:{intersect:function(f,e,g){return this.contains(g,[f.pageX,f.pageY])?1000000000:this.modes.overlap.apply(this,arguments)},overlap:function(f,e,g){return Math.max(0,Math.min(g.bottom,e.bottom)-Math.max(g.top,e.top))*Math.max(0,Math.min(g.right,e.right)-Math.max(g.left,e.left))},fit:function(f,e,g){return this.contains(g,e)?1:0},middle:function(f,e,g){return this.contains(g,[e.left+e.width*0.5,e.top+e.height*0.5])?1:0}},sort:function(f,e){return(e.winner-f.winner)||(f.index-e.index)},tolerate:function(q){var k,e,n,j,l,m,g,p=0,f,h=q.interactions.length,r=[b.event.pageX,b.event.pageY],o=b.tolerance||b.modes[b.mode];do{if(f=q.interactions[p]){if(!f){return}f.drop=[];l=[];m=f.droppable.length;if(o){n=b.locate(f.proxy)}k=0;do{if(g=f.droppable[k]){j=d.data(g,b.datakey);e=j.location;if(!e){continue}j.winner=o?o.call(b,b.event,n,e):b.contains(e,r)?1:0;l.push(j)}}while(++k<m);l.sort(b.sort);k=0;do{if(j=l[k]){if(j.winner&&f.drop.length<b.multi){if(!j.active[p]&&!j.anyactive){if(a.drag.hijack(b.event,"dropstart",q,p,j.elem)[0]!==false){j.active[p]=1;j.anyactive+=1}else{j.winner=0}}if(j.winner){f.drop.push(j.elem)}}else{if(j.active[p]&&j.anyactive==1){a.drag.hijack(b.event,"dropend",q,p,j.elem);j.active[p]=0;j.anyactive-=1}}}}while(++k<m)}}while(++p<h);if(b.last&&r[0]==b.last.pageX&&r[1]==b.last.pageY){delete b.timer}else{b.timer=setTimeout(function(){b.tolerate(q)},b.delay)}b.last=b.event}};a.dropinit=a.dropstart=a.dropend=b})(jQuery);
|
||||
160
public/assets/js/require-backend.js
Normal file
160
public/assets/js/require-backend.js
Normal file
@@ -0,0 +1,160 @@
|
||||
require.config({
|
||||
urlArgs: "v=" + requirejs.s.contexts._.config.config.site.version,
|
||||
packages: [{
|
||||
name: 'moment',
|
||||
location: '../libs/moment',
|
||||
main: 'moment'
|
||||
}],
|
||||
//在打包压缩时将会把include中的模块合并到主文件中
|
||||
include: ['css', 'layer', 'toastr', 'fast', 'backend', 'backend-init', 'table', 'form', 'dragsort', 'addtabs', 'selectpage', 'bootstrap-daterangepicker'],
|
||||
paths: {
|
||||
'lang': "empty:",
|
||||
'form': 'require-form',
|
||||
'table': 'require-table',
|
||||
'upload': 'require-upload',
|
||||
'dropzone': 'dropzone.min',
|
||||
'echarts': 'echarts.min',
|
||||
'echarts-theme': 'echarts-theme',
|
||||
'adminlte': 'adminlte',
|
||||
'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch',
|
||||
'bootstrap-table-template': 'bootstrap-table-template',
|
||||
//
|
||||
// 以下的包从bower的libs目录加载
|
||||
'jquery': '../libs/jquery/dist/jquery.min',
|
||||
'bootstrap': '../libs/bootstrap/dist/js/bootstrap.min',
|
||||
'bootstrap-datetimepicker': '../libs/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min',
|
||||
'bootstrap-daterangepicker': '../libs/bootstrap-daterangepicker/daterangepicker',
|
||||
'bootstrap-select': '../libs/bootstrap-select/dist/js/bootstrap-select.min',
|
||||
'bootstrap-select-lang': '../libs/bootstrap-select/dist/js/i18n/defaults-zh_CN',
|
||||
'bootstrap-table': '../libs/bootstrap-table/dist/bootstrap-table.min',
|
||||
'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min',
|
||||
'bootstrap-table-fixed-columns': '../libs/bootstrap-table/dist/extensions/fixed-columns/bootstrap-table-fixed-columns',
|
||||
'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile',
|
||||
'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN',
|
||||
'bootstrap-table-jumpto': '../libs/bootstrap-table/dist/extensions/page-jumpto/bootstrap-table-jumpto',
|
||||
'bootstrap-slider': '../libs/bootstrap-slider/bootstrap-slider',
|
||||
'tableexport': '../libs/tableExport.jquery.plugin/tableExport.min',
|
||||
'dragsort': '../libs/fastadmin-dragsort/jquery.dragsort',
|
||||
'sortable': '../libs/Sortable/Sortable.min',
|
||||
'addtabs': '../libs/fastadmin-addtabs/jquery.addtabs',
|
||||
'slimscroll': '../libs/jquery-slimscroll/jquery.slimscroll',
|
||||
'validator': '../libs/nice-validator/dist/jquery.validator',
|
||||
'validator-lang': '../libs/nice-validator/dist/local/zh-CN',
|
||||
'toastr': '../libs/toastr/toastr',
|
||||
'jstree': '../libs/jstree/dist/jstree.min',
|
||||
'layer': '../libs/fastadmin-layer/dist/layer',
|
||||
'cookie': '../libs/jquery.cookie/jquery.cookie',
|
||||
'cxselect': '../libs/fastadmin-cxselect/js/jquery.cxselect',
|
||||
'template': '../libs/art-template/dist/template-native',
|
||||
'selectpage': '../libs/fastadmin-selectpage/selectpage',
|
||||
'citypicker': '../libs/fastadmin-citypicker/dist/js/city-picker.min',
|
||||
'citypicker-data': '../libs/fastadmin-citypicker/dist/js/city-picker.data',
|
||||
},
|
||||
// shim依赖配置
|
||||
shim: {
|
||||
'addons': ['backend'],
|
||||
'bootstrap': ['jquery'],
|
||||
'bootstrap-table': {
|
||||
deps: ['bootstrap'],
|
||||
exports: '$.fn.bootstrapTable'
|
||||
},
|
||||
'bootstrap-table-lang': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-export': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-fixed-columns': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-mobile': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-advancedsearch': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-commonsearch': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-template': {
|
||||
deps: ['bootstrap-table', 'template'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-jumpto': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'tableexport': {
|
||||
deps: ['jquery'],
|
||||
exports: '$.fn.extend'
|
||||
},
|
||||
'slimscroll': {
|
||||
deps: ['jquery'],
|
||||
exports: '$.fn.extend'
|
||||
},
|
||||
'adminlte': {
|
||||
deps: ['bootstrap', 'slimscroll'],
|
||||
exports: '$.AdminLTE'
|
||||
},
|
||||
'bootstrap-daterangepicker': [
|
||||
'moment/locale/zh-cn'
|
||||
],
|
||||
'bootstrap-datetimepicker': [
|
||||
'moment/locale/zh-cn',
|
||||
],
|
||||
'bootstrap-select-lang': ['bootstrap-select'],
|
||||
'jstree': ['css!../libs/jstree/dist/themes/default/style.css'],
|
||||
'validator-lang': ['validator'],
|
||||
'citypicker': ['citypicker-data', 'css!../libs/fastadmin-citypicker/dist/css/city-picker.css']
|
||||
},
|
||||
baseUrl: requirejs.s.contexts._.config.config.site.cdnurl + '/assets/js/', //资源基础路径
|
||||
map: {
|
||||
'*': {
|
||||
'css': '../libs/require-css/css.min'
|
||||
}
|
||||
},
|
||||
waitSeconds: 60,
|
||||
charset: 'utf-8' // 文件编码
|
||||
});
|
||||
|
||||
require(['jquery', 'bootstrap'], function ($, undefined) {
|
||||
//初始配置
|
||||
var Config = requirejs.s.contexts._.config.config;
|
||||
//将Config渲染到全局
|
||||
window.Config = Config;
|
||||
// 配置语言包的路径
|
||||
var paths = {};
|
||||
paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername + '&lang=' + Config.language + '&v=' + Config.site.version;
|
||||
// 避免目录冲突
|
||||
paths['backend/'] = 'backend/';
|
||||
require.config({paths: paths});
|
||||
|
||||
// 初始化
|
||||
$(function () {
|
||||
require(['fast'], function (Fast) {
|
||||
require(['backend', 'backend-init', 'addons'], function (Backend, undefined, Addons) {
|
||||
//加载相应模块
|
||||
if (Config.jsname) {
|
||||
require([Config.jsname], function (Controller) {
|
||||
if (Controller.hasOwnProperty(Config.actionname)) {
|
||||
Controller[Config.actionname]();
|
||||
} else {
|
||||
if (Controller.hasOwnProperty("_empty")) {
|
||||
Controller._empty();
|
||||
}
|
||||
}
|
||||
}, function (e) {
|
||||
console.error(e);
|
||||
// 这里可捕获模块加载的错误
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
17
public/assets/js/require-backend.min.js
vendored
Normal file
17
public/assets/js/require-backend.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/assets/js/require-css.min.js
vendored
Normal file
1
public/assets/js/require-css.min.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
define(function(){if("undefined"==typeof window)return{load:function(e,t,n){n()}};var e=document.getElementsByTagName("head")[0],t=window.navigator.userAgent.match(/Trident\/([^ ;]*)|AppleWebKit\/([^ ;]*)|Opera\/([^ ;]*)|rv\:([^ ;]*)(.*?)Gecko\/([^ ;]*)|MSIE\s([^ ;]*)|AndroidWebKit\/([^ ;]*)/)||0,n=!1,r=!0;t[1]||t[7]?n=parseInt(t[1])<6||parseInt(t[7])<=9:t[2]||t[8]?r=!1:t[4]&&(n=parseInt(t[4])<18);var o={};o.pluginBuilder="./css-builder";var a,i,s,l=function(){a=document.createElement("style"),e.appendChild(a),i=a.styleSheet||a.sheet},u=0,d=[],c=function(e){u++,32==u&&(l(),u=0),i.addImport(e),a.onload=function(){f()}},f=function(){s();var e=d.shift();return e?(s=e[1],void c(e[0])):void(s=null)},h=function(e,t){if(i&&i.addImport||l(),i&&i.addImport)s?d.push([e,t]):(c(e),s=t);else{a.textContent='@import "'+e+'";';var n=setInterval(function(){try{a.sheet.cssRules,clearInterval(n),t()}catch(e){}},10)}},p=function(t,n){var o=document.createElement("link");if(o.type="text/css",o.rel="stylesheet",r)o.onload=function(){o.onload=function(){},setTimeout(n,7)};else var a=setInterval(function(){for(var e=0;e<document.styleSheets.length;e++){var t=document.styleSheets[e];if(t.href==o.href)return clearInterval(a),n()}},10);o.href=t,e.appendChild(o)};return o.normalize=function(e,t){return".css"==e.substr(e.length-4,4)&&(e=e.substr(0,e.length-4)),t(e)},o.load=function(e,t,r){(n?h:p)(t.toUrl(e+".css"),r)},o});
|
||||
723
public/assets/js/require-form.js
Normal file
723
public/assets/js/require-form.js
Normal file
@@ -0,0 +1,723 @@
|
||||
define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], function ($, undefined, Upload, Validator, undefined) {
|
||||
var Form = {
|
||||
config: {
|
||||
fieldlisttpl: '<dd class="form-inline"><input type="text" name="<%=name%>[<%=index%>][key]" class="form-control" value="<%=key%>" placeholder="<%=options.keyPlaceholder||\'\'%>" size="10" /> <input type="text" name="<%=name%>[<%=index%>][value]" class="form-control" value="<%=value%>" placeholder="<%=options.valuePlaceholder||\'\'%>" /> <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span></dd>'
|
||||
},
|
||||
events: {
|
||||
validator: function (form, success, error, submit) {
|
||||
if (!form.is("form"))
|
||||
return;
|
||||
//绑定表单事件
|
||||
form.validator($.extend({
|
||||
rules: {
|
||||
username: [/^\w{3,30}$/, __('Username must be 3 to 30 characters')],
|
||||
password: [/^[\S]{6,30}$/, __('Password must be 6 to 30 characters')]
|
||||
},
|
||||
validClass: 'has-success',
|
||||
invalidClass: 'has-error',
|
||||
bindClassTo: '.form-group',
|
||||
formClass: 'n-default n-bootstrap',
|
||||
msgClass: 'n-right',
|
||||
stopOnError: true,
|
||||
display: function (elem) {
|
||||
return $(elem).closest('.form-group').find(".control-label").text().replace(/\:/, '');
|
||||
},
|
||||
dataFilter: function (data) {
|
||||
if (data.code === 1) {
|
||||
return data.msg ? {"ok": data.msg} : '';
|
||||
} else {
|
||||
return data.msg;
|
||||
}
|
||||
},
|
||||
target: function (input) {
|
||||
var target = $(input).data("target");
|
||||
if (target && $(target).length > 0) {
|
||||
return $(target);
|
||||
}
|
||||
var $formitem = $(input).closest('.form-group'),
|
||||
$msgbox = $formitem.find('span.msg-box');
|
||||
if (!$msgbox.length) {
|
||||
return [];
|
||||
}
|
||||
return $msgbox;
|
||||
},
|
||||
valid: function (ret) {
|
||||
var that = this, submitBtn = $(".layer-footer [type=submit]", form);
|
||||
that.holdSubmit(true);
|
||||
submitBtn.addClass("disabled");
|
||||
//验证通过提交表单
|
||||
var submitResult = Form.api.submit($(ret), function (data, ret) {
|
||||
that.holdSubmit(false);
|
||||
submitBtn.removeClass("disabled");
|
||||
if (false === $(this).triggerHandler("success.form", [data, ret])) {
|
||||
return false;
|
||||
}
|
||||
if (typeof success === 'function') {
|
||||
if (false === success.call($(this), data, ret)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//提示及关闭当前窗口
|
||||
var msg = ret.hasOwnProperty("msg") && ret.msg !== "" ? ret.msg : __('Operation completed');
|
||||
parent.Toastr.success(msg);
|
||||
parent.$(".btn-refresh").trigger("click");
|
||||
if (window.name) {
|
||||
var index = parent.Layer.getFrameIndex(window.name);
|
||||
parent.Layer.close(index);
|
||||
}
|
||||
return false;
|
||||
}, function (data, ret) {
|
||||
that.holdSubmit(false);
|
||||
if (false === $(this).triggerHandler("error.form", [data, ret])) {
|
||||
return false;
|
||||
}
|
||||
submitBtn.removeClass("disabled");
|
||||
if (typeof error === 'function') {
|
||||
if (false === error.call($(this), data, ret)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}, submit);
|
||||
//如果提交失败则释放锁定
|
||||
if (!submitResult) {
|
||||
that.holdSubmit(false);
|
||||
submitBtn.removeClass("disabled");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}, form.data("validator-options") || {}));
|
||||
|
||||
//移除提交按钮的disabled类
|
||||
$(".layer-footer [type=submit],.fixed-footer [type=submit],.normal-footer [type=submit]", form).removeClass("disabled");
|
||||
//自定义关闭按钮事件
|
||||
form.on("click", ".layer-close", function () {
|
||||
var index = parent.Layer.getFrameIndex(window.name);
|
||||
parent.Layer.close(index);
|
||||
return false;
|
||||
});
|
||||
},
|
||||
selectpicker: function (form) {
|
||||
//绑定select元素事件
|
||||
if ($(".selectpicker", form).length > 0) {
|
||||
require(['bootstrap-select', 'bootstrap-select-lang'], function () {
|
||||
$('.selectpicker', form).selectpicker();
|
||||
$(form).on("reset", function () {
|
||||
setTimeout(function () {
|
||||
$('.selectpicker').selectpicker('refresh').trigger("change");
|
||||
}, 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
selectpage: function (form) {
|
||||
//绑定selectpage元素事件
|
||||
if ($(".selectpage", form).length > 0) {
|
||||
require(['selectpage'], function () {
|
||||
$('.selectpage', form).selectPage({
|
||||
eAjaxSuccess: function (data) {
|
||||
data.list = typeof data.rows !== 'undefined' ? data.rows : (typeof data.list !== 'undefined' ? data.list : []);
|
||||
data.totalRow = typeof data.total !== 'undefined' ? data.total : (typeof data.totalRow !== 'undefined' ? data.totalRow : data.list.length);
|
||||
return data;
|
||||
}
|
||||
});
|
||||
});
|
||||
//给隐藏的元素添加上validate验证触发事件
|
||||
$(document).on("change", ".sp_hidden", function () {
|
||||
$(this).trigger("validate");
|
||||
});
|
||||
$(document).on("change", ".sp_input", function () {
|
||||
$(this).closest(".sp_container").find(".sp_hidden").trigger("change");
|
||||
});
|
||||
$(form).on("reset", function () {
|
||||
setTimeout(function () {
|
||||
$(".selectpage", form).each(function () {
|
||||
var selectpage = $(this).data("selectPageObject");
|
||||
selectpage.elem.hidden.val($(this).val());
|
||||
$(this).selectPageRefresh();
|
||||
});
|
||||
}, 1);
|
||||
});
|
||||
}
|
||||
},
|
||||
cxselect: function (form) {
|
||||
//绑定cxselect元素事件
|
||||
if ($("[data-toggle='cxselect']", form).length > 0) {
|
||||
require(['cxselect'], function () {
|
||||
$.cxSelect.defaults.jsonName = 'name';
|
||||
$.cxSelect.defaults.jsonValue = 'value';
|
||||
$.cxSelect.defaults.jsonSpace = 'data';
|
||||
$("[data-toggle='cxselect']", form).cxSelect();
|
||||
});
|
||||
}
|
||||
},
|
||||
citypicker: function (form) {
|
||||
//绑定城市远程插件
|
||||
if ($("[data-toggle='city-picker']", form).length > 0) {
|
||||
require(['citypicker'], function () {
|
||||
$(form).on("reset", function () {
|
||||
setTimeout(function () {
|
||||
$("[data-toggle='city-picker']").citypicker('refresh');
|
||||
}, 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
datetimepicker: function (form) {
|
||||
//绑定日期时间元素事件
|
||||
if ($(".datetimepicker", form).length > 0) {
|
||||
require(['bootstrap-datetimepicker'], function () {
|
||||
var options = {
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
icons: {
|
||||
time: 'fa fa-clock-o',
|
||||
date: 'fa fa-calendar',
|
||||
up: 'fa fa-chevron-up',
|
||||
down: 'fa fa-chevron-down',
|
||||
previous: 'fa fa-chevron-left',
|
||||
next: 'fa fa-chevron-right',
|
||||
today: 'fa fa-history',
|
||||
clear: 'fa fa-trash',
|
||||
close: 'fa fa-remove'
|
||||
},
|
||||
showTodayButton: true,
|
||||
showClose: true
|
||||
};
|
||||
$('.datetimepicker', form).parent().css('position', 'relative');
|
||||
$('.datetimepicker', form).datetimepicker(options).on('dp.change', function (e) {
|
||||
$(this, document).trigger("changed");
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
daterangepicker: function (form) {
|
||||
//绑定日期时间元素事件
|
||||
if ($(".datetimerange", form).length > 0) {
|
||||
require(['bootstrap-daterangepicker'], function () {
|
||||
var ranges = {};
|
||||
ranges[__('Today')] = [Moment().startOf('day'), Moment().endOf('day')];
|
||||
ranges[__('Yesterday')] = [Moment().subtract(1, 'days').startOf('day'), Moment().subtract(1, 'days').endOf('day')];
|
||||
ranges[__('Last 7 Days')] = [Moment().subtract(6, 'days').startOf('day'), Moment().endOf('day')];
|
||||
ranges[__('Last 30 Days')] = [Moment().subtract(29, 'days').startOf('day'), Moment().endOf('day')];
|
||||
ranges[__('This Month')] = [Moment().startOf('month'), Moment().endOf('month')];
|
||||
ranges[__('Last Month')] = [Moment().subtract(1, 'month').startOf('month'), Moment().subtract(1, 'month').endOf('month')];
|
||||
var options = {
|
||||
timePicker: false,
|
||||
autoUpdateInput: false,
|
||||
timePickerSeconds: true,
|
||||
timePicker24Hour: true,
|
||||
autoApply: true,
|
||||
locale: {
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
customRangeLabel: __("Custom Range"),
|
||||
applyLabel: __("Apply"),
|
||||
cancelLabel: __("Clear"),
|
||||
},
|
||||
ranges: ranges,
|
||||
};
|
||||
var origincallback = function (start, end) {
|
||||
$(this.element).val(start.format(this.locale.format) + " - " + end.format(this.locale.format));
|
||||
$(this.element).trigger('blur');
|
||||
};
|
||||
$(".datetimerange", form).each(function () {
|
||||
var callback = typeof $(this).data('callback') == 'function' ? $(this).data('callback') : origincallback;
|
||||
$(this).on('apply.daterangepicker', function (ev, picker) {
|
||||
callback.call(picker, picker.startDate, picker.endDate);
|
||||
});
|
||||
$(this).on('cancel.daterangepicker', function (ev, picker) {
|
||||
$(this).val('').trigger('blur');
|
||||
});
|
||||
$(this).daterangepicker($.extend(true, options, $(this).data() || {}, $(this).data("daterangepicker-options") || {}));
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 绑定上传事件
|
||||
* @param form
|
||||
* @deprecated Use faupload instead.
|
||||
*/
|
||||
plupload: function (form) {
|
||||
Form.events.faupload(form);
|
||||
},
|
||||
/**
|
||||
* 绑定上传事件
|
||||
* @param form
|
||||
*/
|
||||
faupload: function (form) {
|
||||
//绑定上传元素事件
|
||||
if ($(".plupload,.faupload", form).length > 0) {
|
||||
Upload.api.upload($(".plupload,.faupload", form));
|
||||
}
|
||||
},
|
||||
faselect: function (form) {
|
||||
//绑定fachoose选择附件事件
|
||||
if ($(".faselect,.fachoose", form).length > 0) {
|
||||
$(".faselect,.fachoose", form).off('click').on('click', function () {
|
||||
var that = this;
|
||||
var multiple = $(this).data("multiple") ? $(this).data("multiple") : false;
|
||||
var mimetype = $(this).data("mimetype") ? $(this).data("mimetype") : '';
|
||||
var admin_id = $(this).data("admin-id") ? $(this).data("admin-id") : '';
|
||||
var user_id = $(this).data("user-id") ? $(this).data("user-id") : '';
|
||||
mimetype = mimetype.replace(/\/\*/ig, '/');
|
||||
var url = $(this).data("url") ? $(this).data("url") : (typeof Backend !== 'undefined' ? "general/attachment/select" : "user/attachment");
|
||||
parent.Fast.api.open(url + "?element_id=" + $(this).attr("id") + "&multiple=" + multiple + "&mimetype=" + mimetype + "&admin_id=" + admin_id + "&user_id=" + user_id, __('Choose'), {
|
||||
callback: function (data) {
|
||||
var button = $("#" + $(that).attr("id"));
|
||||
var maxcount = $(button).data("maxcount");
|
||||
var input_id = $(button).data("input-id") ? $(button).data("input-id") : "";
|
||||
maxcount = typeof maxcount !== "undefined" ? maxcount : 0;
|
||||
if (input_id && data.multiple) {
|
||||
var urlArr = [];
|
||||
var inputObj = $("#" + input_id);
|
||||
var value = $.trim(inputObj.val());
|
||||
if (value !== "") {
|
||||
urlArr.push(inputObj.val());
|
||||
}
|
||||
var nums = value === '' ? 0 : value.split(/\,/).length;
|
||||
var files = data.url !== "" ? data.url.split(/\,/) : [];
|
||||
$.each(files, function (i, j) {
|
||||
var url = Config.upload.fullmode ? Fast.api.cdnurl(j) : j;
|
||||
urlArr.push(url);
|
||||
});
|
||||
if (maxcount > 0) {
|
||||
var remains = maxcount - nums;
|
||||
if (files.length > remains) {
|
||||
Toastr.error(__('You can choose up to %d file%s', remains));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var result = urlArr.join(",");
|
||||
inputObj.val(result).trigger("change").trigger("validate");
|
||||
} else {
|
||||
var url = Config.upload.fullmode ? Fast.api.cdnurl(data.url) : data.url;
|
||||
$("#" + input_id).val(url).trigger("change").trigger("validate");
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
},
|
||||
fieldlist: function (form) {
|
||||
//绑定fieldlist
|
||||
if ($(".fieldlist", form).length > 0) {
|
||||
require(['dragsort', 'template'], function (undefined, Template) {
|
||||
//刷新隐藏textarea的值
|
||||
var refresh = function (container) {
|
||||
var data = {};
|
||||
var name = container.data("name");
|
||||
var textarea = $("textarea[name='" + name + "']", form);
|
||||
var template = container.data("template");
|
||||
$.each($("input,select,textarea", container).serializeArray(), function (i, j) {
|
||||
var reg = /\[(\w+)\]\[(\w+)\]$/g;
|
||||
var match = reg.exec(j.name);
|
||||
if (!match)
|
||||
return true;
|
||||
match[1] = "x" + parseInt(match[1]);
|
||||
if (typeof data[match[1]] == 'undefined') {
|
||||
data[match[1]] = {};
|
||||
}
|
||||
data[match[1]][match[2]] = j.value;
|
||||
});
|
||||
var result = template ? [] : {};
|
||||
$.each(data, function (i, j) {
|
||||
if (j) {
|
||||
if (!template) {
|
||||
if (j.key != '') {
|
||||
result[j.key] = j.value;
|
||||
}
|
||||
} else {
|
||||
result.push(j);
|
||||
}
|
||||
}
|
||||
});
|
||||
textarea.val(JSON.stringify(result));
|
||||
};
|
||||
//追加一行数据
|
||||
var append = function (container, row, initial) {
|
||||
var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
|
||||
var index = container.data("index");
|
||||
var name = container.data("name");
|
||||
var template = container.data("template");
|
||||
var data = container.data();
|
||||
index = index ? parseInt(index) : 0;
|
||||
container.data("index", index + 1);
|
||||
row = row ? row : {};
|
||||
row = typeof row.key === 'undefined' || typeof row.value === 'undefined' ? {key: '', value: row} : row;
|
||||
var options = container.data("fieldlist-options") || {};
|
||||
var vars = {index: index, name: name, data: data, options: options, key: row.key, value: row.value, row: row.value};
|
||||
var html = template ? Template(template, vars) : Template.render(Form.config.fieldlisttpl, vars);
|
||||
var obj = $(html);
|
||||
if ((options.deleteBtn === false || options.removeBtn === false) && initial)
|
||||
obj.find(".btn-remove").remove();
|
||||
if (options.dragsortBtn === false && initial)
|
||||
obj.find(".btn-dragsort").remove();
|
||||
if ((options.readonlyKey === true || options.disableKey === true) && initial) {
|
||||
obj.find("input[name$='[key]']").prop("readonly", true);
|
||||
}
|
||||
obj.attr("fieldlist-item", true);
|
||||
obj.insertAfter($(tagName + "[fieldlist-item]", container).length > 0 ? $(tagName + "[fieldlist-item]:last", container) : $(tagName + ":first", container));
|
||||
if ($(".btn-append,.append", container).length > 0) {
|
||||
//兼容旧版本事件
|
||||
$(".btn-append,.append", container).trigger("fa.event.appendfieldlist", obj);
|
||||
} else {
|
||||
//新版本事件
|
||||
container.trigger("fa.event.appendfieldlist", obj);
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
var fieldlist = $(".fieldlist", form);
|
||||
//表单重置
|
||||
form.on("reset", function () {
|
||||
setTimeout(function () {
|
||||
fieldlist.trigger("fa.event.refreshfieldlist");
|
||||
});
|
||||
});
|
||||
//监听文本框改变事件
|
||||
$(document).on('change keyup changed', ".fieldlist input,.fieldlist textarea,.fieldlist select", function () {
|
||||
var container = $(this).closest(".fieldlist");
|
||||
refresh(container);
|
||||
});
|
||||
//追加控制(点击按钮)
|
||||
fieldlist.on("click", ".btn-append,.append", function (e, row) {
|
||||
var container = $(this).closest(".fieldlist");
|
||||
append(container, row);
|
||||
// refresh(container);
|
||||
});
|
||||
//移除控制(点击按钮)
|
||||
fieldlist.on("click", ".btn-remove", function () {
|
||||
var container = $(this).closest(".fieldlist");
|
||||
var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
|
||||
$(this).closest(tagName).remove();
|
||||
refresh(container);
|
||||
});
|
||||
//追加控制(通过事件)
|
||||
fieldlist.on("fa.event.appendtofieldlist", function (e, row) {
|
||||
var container = $(this);
|
||||
append(container, row);
|
||||
refresh(container);
|
||||
});
|
||||
//根据textarea内容重新渲染
|
||||
fieldlist.on("fa.event.refreshfieldlist", function () {
|
||||
var container = $(this);
|
||||
var textarea = $("textarea[name='" + container.data("name") + "']", form);
|
||||
//先清空已有的数据
|
||||
$("[fieldlist-item]", container).remove();
|
||||
var json = {};
|
||||
try {
|
||||
json = JSON.parse(textarea.val());
|
||||
} catch (e) {
|
||||
}
|
||||
$.each(json, function (i, j) {
|
||||
append(container, {key: i, value: j}, true);
|
||||
});
|
||||
});
|
||||
//拖拽排序
|
||||
fieldlist.each(function () {
|
||||
var container = $(this);
|
||||
var tagName = container.data("tag") || (container.is("table") ? "tr" : "dd");
|
||||
container.dragsort({
|
||||
itemSelector: tagName,
|
||||
dragSelector: ".btn-dragsort",
|
||||
dragEnd: function () {
|
||||
refresh(container);
|
||||
},
|
||||
placeHolderTemplate: $("<" + tagName + "/>")
|
||||
});
|
||||
if (typeof container.data("options") === 'object' && container.data("options").appendBtn === false) {
|
||||
$(".btn-append,.append", container).hide();
|
||||
}
|
||||
$("textarea[name='" + container.data("name") + "']", form).on("fa.event.refreshfieldlist", function () {
|
||||
//兼容旧版本事件
|
||||
$(this).closest(".fieldlist").trigger("fa.event.refreshfieldlist");
|
||||
});
|
||||
});
|
||||
fieldlist.trigger("fa.event.refreshfieldlist");
|
||||
});
|
||||
}
|
||||
},
|
||||
switcher: function (form) {
|
||||
form.on("click", "[data-toggle='switcher']", function () {
|
||||
if ($(this).hasClass("disabled")) {
|
||||
return false;
|
||||
}
|
||||
var switcher = $.proxy(function () {
|
||||
var input = $(this).prev("input");
|
||||
input = $(this).data("input-id") ? $("#" + $(this).data("input-id")) : input;
|
||||
if (input.length > 0) {
|
||||
var yes = $(this).data("yes");
|
||||
var no = $(this).data("no");
|
||||
if (input.val() == yes) {
|
||||
input.val(no);
|
||||
$("i", this).addClass("fa-flip-horizontal text-gray");
|
||||
} else {
|
||||
input.val(yes);
|
||||
$("i", this).removeClass("fa-flip-horizontal text-gray");
|
||||
}
|
||||
input.trigger('change');
|
||||
}
|
||||
}, this);
|
||||
if (typeof $(this).data("confirm") !== 'undefined') {
|
||||
Layer.confirm($(this).data("confirm"), function (index) {
|
||||
switcher();
|
||||
Layer.close(index);
|
||||
});
|
||||
} else {
|
||||
switcher();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
},
|
||||
bindevent: function (form) {
|
||||
|
||||
},
|
||||
slider: function (form) {
|
||||
if ($(".slider", form).length > 0) {
|
||||
require(['bootstrap-slider'], function () {
|
||||
$('.slider').removeClass('hidden').css('width', function (index, value) {
|
||||
return $(this).parents('.form-control').width();
|
||||
}).slider().on('slide', function (ev) {
|
||||
var data = $(this).data();
|
||||
if (typeof data.unit !== 'undefined') {
|
||||
$(this).parents('.form-control').siblings('.value').text(ev.value + data.unit);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
tagsinput: function (form) {
|
||||
if ($("[data-role='tagsinput']", form).length > 0) {
|
||||
require(['tagsinput', 'autocomplete'], function () {
|
||||
$("[data-role='tagsinput']").tagsinput();
|
||||
form.on("reset", function () {
|
||||
setTimeout(function () {
|
||||
$("[data-role='tagsinput']").tagsinput('reset');
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
autocomplete: function (form) {
|
||||
if ($("[data-role='autocomplete']", form).length > 0) {
|
||||
require(['autocomplete'], function () {
|
||||
$("[data-role='autocomplete']").autocomplete();
|
||||
});
|
||||
}
|
||||
},
|
||||
favisible: function (form) {
|
||||
if ($("[data-favisible]", form).length == 0) {
|
||||
return;
|
||||
}
|
||||
var checkCondition = function (condition) {
|
||||
var conditionArr = condition.split(/&&/);
|
||||
var success = 0;
|
||||
var baseregex = /^([a-z0-9\_]+)([>|<|=|\!]=?)(.*)$/i, strregex = /^('|")(.*)('|")$/, regregex = /^regex:(.*)$/;
|
||||
// @formatter:off
|
||||
var operator_result = {
|
||||
'>': function (a, b) {
|
||||
return a > b;
|
||||
},
|
||||
'>=': function (a, b) {
|
||||
return a >= b;
|
||||
},
|
||||
'<': function (a, b) {
|
||||
return a < b;
|
||||
},
|
||||
'<=': function (a, b) {
|
||||
return a <= b;
|
||||
},
|
||||
'==': function (a, b) {
|
||||
return a == b;
|
||||
},
|
||||
'!=': function (a, b) {
|
||||
return a != b;
|
||||
},
|
||||
'in': function (a, b) {
|
||||
return b.split(/\,/).indexOf(a) > -1;
|
||||
},
|
||||
'regex': function (a, b) {
|
||||
var regParts = b.match(/^\/(.*?)\/([gim]*)$/);
|
||||
var regexp = regParts ? new RegExp(regParts[1], regParts[2]) : new RegExp(b);
|
||||
return regexp.test(a);
|
||||
}
|
||||
};
|
||||
// @formatter:on
|
||||
var dataArr = form.serializeArray(), dataObj = {}, fieldName, fieldValue;
|
||||
$(dataArr).each(function (i, field) {
|
||||
fieldName = field.name;
|
||||
fieldValue = field.value;
|
||||
fieldName = fieldName.substr(-2) === '[]' ? fieldName.substr(0, fieldName.length - 2) : fieldName;
|
||||
dataObj[fieldName] = typeof dataObj[fieldName] !== 'undefined' ? [dataObj[fieldName], fieldValue].join(',') : fieldValue;
|
||||
});
|
||||
|
||||
$.each(conditionArr, function (i, item) {
|
||||
var basematches = baseregex.exec(item);
|
||||
if (basematches) {
|
||||
var name = basematches[1], operator = basematches[2], value = basematches[3].toString();
|
||||
if (operator === '=') {
|
||||
var strmatches = strregex.exec(value);
|
||||
operator = strmatches ? '==' : 'in';
|
||||
value = strmatches ? strmatches[2] : value;
|
||||
}
|
||||
var regmatches = regregex.exec(value);
|
||||
if (regmatches) {
|
||||
operator = 'regex';
|
||||
value = regmatches[1];
|
||||
}
|
||||
var chkname = "row[" + name + "]";
|
||||
if (typeof dataObj[chkname] === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
var objvalue = dataObj[chkname];
|
||||
if ($.isArray(objvalue)) {
|
||||
objvalue = dataObj[chkname].join(",");
|
||||
}
|
||||
if (['>', '>=', '<', '<='].indexOf(operator) > -1) {
|
||||
objvalue = parseFloat(objvalue);
|
||||
value = parseFloat(value);
|
||||
}
|
||||
var result = operator_result[operator](objvalue, value);
|
||||
success += (result ? 1 : 0);
|
||||
}
|
||||
});
|
||||
return success === conditionArr.length;
|
||||
};
|
||||
form.on("keyup change click configchange", "input,select", function () {
|
||||
$("[data-favisible][data-favisible!='']", form).each(function () {
|
||||
var visible = $(this).data("favisible");
|
||||
var groupArr = visible.split(/\|\|/);
|
||||
var success = 0;
|
||||
$.each(groupArr, function (i, j) {
|
||||
if (checkCondition(j)) {
|
||||
success++;
|
||||
}
|
||||
});
|
||||
if (success > 0) {
|
||||
$(this).removeClass("hidden");
|
||||
} else {
|
||||
$(this).addClass("hidden");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//追加上忽略元素
|
||||
setTimeout(function () {
|
||||
form.data('validator').options.ignore += ((form.data('validator').options.ignore ? ',' : '') + '[data-favisible] :hidden,[data-favisible]:hidden');
|
||||
}, 0);
|
||||
|
||||
$("input,select", form).trigger("configchange");
|
||||
}
|
||||
},
|
||||
api: {
|
||||
submit: function (form, success, error, submit) {
|
||||
if (form.length === 0) {
|
||||
Toastr.error("表单未初始化完成,无法提交");
|
||||
return false;
|
||||
}
|
||||
if (typeof submit === 'function') {
|
||||
if (false === submit.call(form, success, error)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var type = form.attr("method") ? form.attr("method").toUpperCase() : 'GET';
|
||||
type = type && (type === 'GET' || type === 'POST') ? type : 'GET';
|
||||
url = form.attr("action");
|
||||
url = url ? url : location.href;
|
||||
//修复当存在多选项元素时提交的BUG
|
||||
var params = {};
|
||||
var multipleList = $("[name$='[]']", form);
|
||||
if (multipleList.length > 0) {
|
||||
var postFields = form.serializeArray().map(function (obj) {
|
||||
return $(obj).prop("name");
|
||||
});
|
||||
$.each(multipleList, function (i, j) {
|
||||
if (postFields.indexOf($(this).prop("name")) < 0) {
|
||||
params[$(this).prop("name")] = '';
|
||||
}
|
||||
});
|
||||
}
|
||||
//调用Ajax请求方法
|
||||
Fast.api.ajax({
|
||||
type: type,
|
||||
url: url,
|
||||
data: form.serialize() + (Object.keys(params).length > 0 ? '&' + $.param(params) : ''),
|
||||
dataType: 'json',
|
||||
complete: function (xhr) {
|
||||
var token = xhr.getResponseHeader('__token__');
|
||||
if (token) {
|
||||
$("input[name='__token__']").val(token);
|
||||
}
|
||||
}
|
||||
}, function (data, ret) {
|
||||
$('.form-group', form).removeClass('has-feedback has-success has-error');
|
||||
if (data && typeof data === 'object') {
|
||||
//刷新客户端token
|
||||
if (typeof data.token !== 'undefined') {
|
||||
$("input[name='__token__']").val(data.token);
|
||||
}
|
||||
//调用客户端事件
|
||||
if (typeof data.callback !== 'undefined' && typeof data.callback === 'function') {
|
||||
data.callback.call(form, data);
|
||||
}
|
||||
}
|
||||
if (typeof success === 'function') {
|
||||
if (false === success.call(form, data, ret)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}, function (data, ret) {
|
||||
if (data && typeof data === 'object' && typeof data.token !== 'undefined') {
|
||||
$("input[name='__token__']").val(data.token);
|
||||
}
|
||||
if (typeof error === 'function') {
|
||||
if (false === error.call(form, data, ret)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
},
|
||||
bindevent: function (form, success, error, submit) {
|
||||
|
||||
form = typeof form === 'object' ? form : $(form);
|
||||
|
||||
var events = Form.events;
|
||||
|
||||
events.bindevent(form);
|
||||
|
||||
events.validator(form, success, error, submit);
|
||||
|
||||
events.selectpicker(form);
|
||||
|
||||
events.daterangepicker(form);
|
||||
|
||||
events.selectpage(form);
|
||||
|
||||
events.cxselect(form);
|
||||
|
||||
events.citypicker(form);
|
||||
|
||||
events.datetimepicker(form);
|
||||
|
||||
events.faupload(form);
|
||||
|
||||
events.faselect(form);
|
||||
|
||||
events.fieldlist(form);
|
||||
|
||||
events.slider(form);
|
||||
|
||||
events.switcher(form);
|
||||
|
||||
events.tagsinput(form);
|
||||
|
||||
events.autocomplete(form);
|
||||
|
||||
events.favisible(form);
|
||||
},
|
||||
custom: {}
|
||||
},
|
||||
};
|
||||
return Form;
|
||||
});
|
||||
153
public/assets/js/require-frontend.js
Normal file
153
public/assets/js/require-frontend.js
Normal file
@@ -0,0 +1,153 @@
|
||||
require.config({
|
||||
urlArgs: "v=" + requirejs.s.contexts._.config.config.site.version,
|
||||
packages: [{
|
||||
name: 'moment',
|
||||
location: '../libs/moment',
|
||||
main: 'moment'
|
||||
}],
|
||||
//在打包压缩时将会把include中的模块合并到主文件中
|
||||
include: ['css', 'layer', 'toastr', 'fast', 'frontend', 'frontend-init', 'table', 'form', 'dragsort', 'selectpage'],
|
||||
paths: {
|
||||
'lang': "empty:",
|
||||
'form': 'require-form',
|
||||
'table': 'require-table',
|
||||
'upload': 'require-upload',
|
||||
'dropzone': 'dropzone.min',
|
||||
'echarts': 'echarts.min',
|
||||
'echarts-theme': 'echarts-theme',
|
||||
'adminlte': 'adminlte',
|
||||
'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch',
|
||||
'bootstrap-table-template': 'bootstrap-table-template',
|
||||
//
|
||||
// 以下的包从bower的libs目录加载
|
||||
'jquery': '../libs/jquery/dist/jquery.min',
|
||||
'bootstrap': '../libs/bootstrap/dist/js/bootstrap.min',
|
||||
'bootstrap-datetimepicker': '../libs/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min',
|
||||
'bootstrap-daterangepicker': '../libs/bootstrap-daterangepicker/daterangepicker',
|
||||
'bootstrap-select': '../libs/bootstrap-select/dist/js/bootstrap-select.min',
|
||||
'bootstrap-select-lang': '../libs/bootstrap-select/dist/js/i18n/defaults-zh_CN',
|
||||
'bootstrap-table': '../libs/bootstrap-table/dist/bootstrap-table.min',
|
||||
'bootstrap-table-export': '../libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min',
|
||||
'bootstrap-table-fixed-columns': '../libs/bootstrap-table/dist/extensions/fixed-columns/bootstrap-table-fixed-columns',
|
||||
'bootstrap-table-mobile': '../libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile',
|
||||
'bootstrap-table-lang': '../libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN',
|
||||
'bootstrap-table-jumpto': '../libs/bootstrap-table/dist/extensions/page-jumpto/bootstrap-table-jumpto',
|
||||
'tableexport': '../libs/tableExport.jquery.plugin/tableExport.min',
|
||||
'dragsort': '../libs/fastadmin-dragsort/jquery.dragsort',
|
||||
'sortable': '../libs/Sortable/Sortable.min',
|
||||
'addtabs': '../libs/fastadmin-addtabs/jquery.addtabs',
|
||||
'slimscroll': '../libs/jquery-slimscroll/jquery.slimscroll',
|
||||
'validator': '../libs/nice-validator/dist/jquery.validator',
|
||||
'validator-lang': '../libs/nice-validator/dist/local/zh-CN',
|
||||
'toastr': '../libs/toastr/toastr',
|
||||
'jstree': '../libs/jstree/dist/jstree.min',
|
||||
'layer': '../libs/fastadmin-layer/dist/layer',
|
||||
'cookie': '../libs/jquery.cookie/jquery.cookie',
|
||||
'cxselect': '../libs/fastadmin-cxselect/js/jquery.cxselect',
|
||||
'template': '../libs/art-template/dist/template-native',
|
||||
'selectpage': '../libs/fastadmin-selectpage/selectpage',
|
||||
'citypicker': '../libs/fastadmin-citypicker/dist/js/city-picker.min',
|
||||
'citypicker-data': '../libs/fastadmin-citypicker/dist/js/city-picker.data'
|
||||
},
|
||||
// shim依赖配置
|
||||
shim: {
|
||||
'addons': ['frontend'],
|
||||
'bootstrap': ['jquery'],
|
||||
'bootstrap-table': {
|
||||
deps: ['bootstrap'],
|
||||
exports: '$.fn.bootstrapTable'
|
||||
},
|
||||
'bootstrap-table-lang': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-export': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-fixed-columns': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-mobile': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-advancedsearch': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-commonsearch': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-template': {
|
||||
deps: ['bootstrap-table', 'template'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-jumpto': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'tableexport': {
|
||||
deps: ['jquery'],
|
||||
exports: '$.fn.extend'
|
||||
},
|
||||
'slimscroll': {
|
||||
deps: ['jquery'],
|
||||
exports: '$.fn.extend'
|
||||
},
|
||||
'adminlte': {
|
||||
deps: ['bootstrap', 'slimscroll'],
|
||||
exports: '$.AdminLTE'
|
||||
},
|
||||
'bootstrap-daterangepicker': [
|
||||
'moment/locale/zh-cn'
|
||||
],
|
||||
'bootstrap-datetimepicker': [
|
||||
'moment/locale/zh-cn',
|
||||
],
|
||||
'bootstrap-select-lang': ['bootstrap-select'],
|
||||
'jstree': ['css!../libs/jstree/dist/themes/default/style.css'],
|
||||
'validator-lang': ['validator'],
|
||||
'citypicker': ['citypicker-data', 'css!../libs/fastadmin-citypicker/dist/css/city-picker.css']
|
||||
},
|
||||
baseUrl: requirejs.s.contexts._.config.config.site.cdnurl + '/assets/js/', //资源基础路径
|
||||
map: {
|
||||
'*': {
|
||||
'css': '../libs/require-css/css.min'
|
||||
}
|
||||
},
|
||||
waitSeconds: 60,
|
||||
charset: 'utf-8' // 文件编码
|
||||
});
|
||||
|
||||
require(['jquery', 'bootstrap'], function ($, undefined) {
|
||||
//初始配置
|
||||
var Config = requirejs.s.contexts._.config.config;
|
||||
//将Config渲染到全局
|
||||
window.Config = Config;
|
||||
// 配置语言包的路径
|
||||
var paths = {};
|
||||
paths['lang'] = Config.moduleurl + '/ajax/lang?callback=define&controllername=' + Config.controllername + '&lang=' + Config.language + '&v=' + Config.site.version;
|
||||
// 避免目录冲突
|
||||
paths['frontend/'] = 'frontend/';
|
||||
require.config({paths: paths});
|
||||
|
||||
// 初始化
|
||||
$(function () {
|
||||
require(['fast'], function (Fast) {
|
||||
require(['frontend', 'frontend-init', 'addons'], function (Frontend, Addons) {
|
||||
//加载相应模块
|
||||
if (Config.jsname) {
|
||||
require([Config.jsname], function (Controller) {
|
||||
Controller[Config.actionname] != undefined && Controller[Config.actionname]();
|
||||
}, function (e) {
|
||||
console.error(e);
|
||||
// 这里可捕获模块加载的错误
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
15
public/assets/js/require-frontend.min.js
vendored
Normal file
15
public/assets/js/require-frontend.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1076
public/assets/js/require-table.js
Normal file
1076
public/assets/js/require-table.js
Normal file
File diff suppressed because it is too large
Load Diff
465
public/assets/js/require-upload.js
Normal file
465
public/assets/js/require-upload.js
Normal file
@@ -0,0 +1,465 @@
|
||||
define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined, Dropzone, Template) {
|
||||
var Upload = {
|
||||
list: {},
|
||||
options: {},
|
||||
config: {
|
||||
container: document.body,
|
||||
classname: '.plupload:not([initialized]),.faupload:not([initialized])',
|
||||
previewtpl: '<li class="col-xs-3"><a href="<%=fullurl%>" data-url="<%=url%>" target="_blank" class="thumbnail"><img src="<%=fullurl%>" onerror="this.src=\'' + Fast.api.fixurl("ajax/icon") + '?suffix=<%=suffix%>\';this.onerror=null;" class="img-responsive"></a><a href="javascript:;" class="btn btn-danger btn-xs btn-trash"><i class="fa fa-trash"></i></a></li>',
|
||||
},
|
||||
events: {
|
||||
//初始化
|
||||
onInit: function () {
|
||||
|
||||
},
|
||||
//上传成功的回调
|
||||
onUploadSuccess: function (up, ret, file) {
|
||||
var button = up.element;
|
||||
var onUploadSuccess = up.options.onUploadSuccess;
|
||||
var data = typeof ret.data !== 'undefined' ? ret.data : null;
|
||||
//上传成功后回调
|
||||
if (button) {
|
||||
//如果有文本框则填充
|
||||
var input_id = $(button).data("input-id") ? $(button).data("input-id") : "";
|
||||
if (input_id) {
|
||||
var urlArr = [];
|
||||
var inputObj = $("#" + input_id);
|
||||
if ($(button).data("multiple") && inputObj.val() !== "") {
|
||||
urlArr.push(inputObj.val());
|
||||
}
|
||||
var url = Config.upload.fullmode ? Fast.api.cdnurl(data.url) : data.url;
|
||||
urlArr.push(url);
|
||||
inputObj.val(urlArr.join(",")).trigger("change").trigger("validate");
|
||||
}
|
||||
//如果有回调函数
|
||||
var onDomUploadSuccess = $(button).data("upload-success");
|
||||
if (onDomUploadSuccess) {
|
||||
if (typeof onDomUploadSuccess !== 'function' && typeof Upload.api.custom[onDomUploadSuccess] === 'function') {
|
||||
onDomUploadSuccess = Upload.api.custom[onDomUploadSuccess];
|
||||
}
|
||||
if (typeof onDomUploadSuccess === 'function') {
|
||||
var result = onDomUploadSuccess.call(button, data, ret);
|
||||
if (result === false)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof onUploadSuccess === 'function') {
|
||||
var result = onUploadSuccess.call(button, data, ret);
|
||||
if (result === false)
|
||||
return;
|
||||
}
|
||||
},
|
||||
//上传错误的回调
|
||||
onUploadError: function (up, ret, file) {
|
||||
var button = up.element;
|
||||
var onUploadError = up.options.onUploadError;
|
||||
var data = typeof ret.data !== 'undefined' ? ret.data : null;
|
||||
if (button) {
|
||||
var onDomUploadError = $(button).data("upload-error");
|
||||
if (onDomUploadError) {
|
||||
if (typeof onDomUploadError !== 'function' && typeof Upload.api.custom[onDomUploadError] === 'function') {
|
||||
onDomUploadError = Upload.api.custom[onDomUploadError];
|
||||
}
|
||||
if (typeof onDomUploadError === 'function') {
|
||||
var result = onDomUploadError.call(button, data, ret);
|
||||
if (result === false)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof onUploadError === 'function') {
|
||||
var result = onUploadError.call(button, data, ret);
|
||||
if (result === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Toastr.error(ret.msg.toString().replace(/(<([^>]+)>)/gi, "") + "(code:" + ret.code + ")");
|
||||
},
|
||||
//服务器响应数据后
|
||||
onUploadResponse: function (response, up, file) {
|
||||
try {
|
||||
var ret = typeof response === 'object' ? response : JSON.parse(response);
|
||||
if (!ret.hasOwnProperty('code')) {
|
||||
$.extend(ret, {code: -2, msg: response, data: null});
|
||||
}
|
||||
} catch (e) {
|
||||
var ret = {code: -1, msg: e.message, data: null};
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
//上传全部结束后
|
||||
onUploadComplete: function (up, files) {
|
||||
var button = up.element;
|
||||
var onUploadComplete = up.options.onUploadComplete;
|
||||
if (button) {
|
||||
var onDomUploadComplete = $(button).data("upload-complete");
|
||||
if (onDomUploadComplete) {
|
||||
if (typeof onDomUploadComplete !== 'function' && typeof Upload.api.custom[onDomUploadComplete] === 'function') {
|
||||
onDomUploadComplete = Upload.api.custom[onDomUploadComplete];
|
||||
}
|
||||
if (typeof onDomUploadComplete === 'function') {
|
||||
var result = onDomUploadComplete.call(button, files);
|
||||
if (result === false)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof onUploadComplete === 'function') {
|
||||
var result = onUploadComplete.call(button, files);
|
||||
if (result === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
api: {
|
||||
//上传接口
|
||||
upload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
|
||||
element = typeof element === 'undefined' ? Upload.config.classname : element;
|
||||
$(element, Upload.config.container).each(function () {
|
||||
if ($(this).attr("initialized")) {
|
||||
return true;
|
||||
}
|
||||
$(this).attr("initialized", true);
|
||||
var that = this;
|
||||
var id = $(this).prop("id") || $(this).prop("name") || Dropzone.uuidv4();
|
||||
var url = $(this).data("url");
|
||||
var maxsize = $(this).data("maxsize");
|
||||
var maxcount = $(this).data("maxcount");
|
||||
var mimetype = $(this).data("mimetype");
|
||||
var multipart = $(this).data("multipart");
|
||||
var multiple = $(this).data("multiple");
|
||||
|
||||
//填充ID
|
||||
var input_id = $(that).data("input-id") ? $(that).data("input-id") : "";
|
||||
//预览ID
|
||||
var preview_id = $(that).data("preview-id") ? $(that).data("preview-id") : "";
|
||||
|
||||
//上传URL
|
||||
url = url ? url : Config.upload.uploadurl;
|
||||
url = Fast.api.fixurl(url);
|
||||
var chunking = false, chunkSize = Config.upload.chunksize || 2097152, timeout = Config.upload.timeout || 600000;
|
||||
|
||||
//最大可上传文件大小
|
||||
maxsize = typeof maxsize !== "undefined" ? maxsize : Config.upload.maxsize;
|
||||
//文件类型
|
||||
mimetype = typeof mimetype !== "undefined" ? mimetype : Config.upload.mimetype;
|
||||
//请求的表单参数
|
||||
multipart = typeof multipart !== "undefined" ? multipart : Config.upload.multipart;
|
||||
//是否支持批量上传
|
||||
multiple = typeof multiple !== "undefined" ? multiple : Config.upload.multiple;
|
||||
//后缀特殊处理
|
||||
mimetype = mimetype.split(",").map(function (k) {
|
||||
return k.indexOf("/") > -1 ? k : (!k || k === "*" || k.charAt(0) === "." ? k : "." + k);
|
||||
}).join(",");
|
||||
mimetype = mimetype === '*' ? null : mimetype;
|
||||
|
||||
//最大文件限制转换成mb
|
||||
var maxFilesize = (function (maxsize) {
|
||||
var matches = maxsize.toString().match(/^([0-9\.]+)(\w+)$/);
|
||||
var size = matches ? parseFloat(matches[1]) : parseFloat(maxsize),
|
||||
unit = matches ? matches[2].toLowerCase() : 'b';
|
||||
var unitDict = {'b': 0, 'k': 1, 'kb': 1, 'm': 2, 'mb': 2, 'gb': 3, 'g': 3, 'tb': 4, 't': 4};
|
||||
var y = typeof unitDict[unit] !== 'undefined' ? unitDict[unit] : 0;
|
||||
var bytes = size * Math.pow(1024, y);
|
||||
return bytes / Math.pow(1024, 2);
|
||||
}(maxsize));
|
||||
|
||||
var options = $(this).data() || {};
|
||||
options = $.extend(true, {}, options, $(this).data("upload-options") || {});
|
||||
delete options.success;
|
||||
delete options.url;
|
||||
multipart = $.isArray(multipart) ? {} : multipart;
|
||||
var params = $(this).data("params") || {};
|
||||
var category = typeof params.category !== 'undefined' ? params.category : ($(this).data("category") || '');
|
||||
if (category) {
|
||||
// multipart.category = category;
|
||||
}
|
||||
|
||||
Upload.list[id] = new Dropzone(this, $.extend({
|
||||
url: url,
|
||||
params: function (files, xhr, chunk) {
|
||||
var params = multipart;
|
||||
if (chunk) {
|
||||
return $.extend({}, params, {
|
||||
filesize: chunk.file.size,
|
||||
filename: chunk.file.name,
|
||||
chunkid: chunk.file.upload.uuid,
|
||||
chunkindex: chunk.index,
|
||||
chunkcount: chunk.file.upload.totalChunkCount,
|
||||
chunksize: this.options.chunkSize,
|
||||
chunkfilesize: chunk.dataBlock.data.size,
|
||||
width: chunk.file.width || 0,
|
||||
height: chunk.file.height || 0,
|
||||
type: chunk.file.type,
|
||||
});
|
||||
}
|
||||
return params;
|
||||
},
|
||||
chunking: chunking,
|
||||
chunkSize: chunkSize,
|
||||
maxFilesize: maxFilesize,
|
||||
acceptedFiles: mimetype,
|
||||
maxFiles: (maxcount && parseInt(maxcount) > 1 ? maxcount : (multiple ? null : 1)),
|
||||
timeout: timeout,
|
||||
parallelUploads: 1,
|
||||
previewsContainer: false,
|
||||
dictDefaultMessage: __("Drop files here to upload"),
|
||||
dictFallbackMessage: __("Your browser does not support drag'n'drop file uploads"),
|
||||
dictFallbackText: __("Please use the fallback form below to upload your files like in the olden days"),
|
||||
dictFileTooBig: __("File is too big (%sMiB), Max filesize: %sMiB", "{{filesize}}", "{{maxFilesize}}"),
|
||||
dictInvalidFileType: __("You can't upload files of this type"),
|
||||
dictResponseError: __("Server responded with %s code.", "{{statusCode}}"),
|
||||
dictCancelUpload: __("Cancel upload"),
|
||||
dictUploadCanceled: __("Upload canceled"),
|
||||
dictCancelUploadConfirmation: __("Are you sure you want to cancel this upload?"),
|
||||
dictRemoveFile: __("Remove file"),
|
||||
dictMaxFilesExceeded: __("You can only upload a maximum of %s files", "{{maxFiles}}"),
|
||||
init: function () {
|
||||
Upload.events.onInit.call(this);
|
||||
//必须添加dz-message,否则点击icon无法唤起上传窗口
|
||||
$(">i", this.element).addClass("dz-message");
|
||||
this.options.elementHtml = $(this.element).html();
|
||||
},
|
||||
sending: function (file, xhr, formData) {
|
||||
if (typeof file.category !== 'undefined') {
|
||||
formData.append('category', file.category);
|
||||
}
|
||||
},
|
||||
addedfile: function (file) {
|
||||
var params = $(this.element).data("params") || {};
|
||||
var category = typeof params.category !== 'undefined' ? params.category : ($(this.element).data("category") || '');
|
||||
file.category = typeof category === 'function' ? category.call(this, file) : category;
|
||||
},
|
||||
addedfiles: function (files) {
|
||||
if (this.options.maxFiles && (!this.options.maxFiles || this.options.maxFiles > 1) && this.options.inputId) {
|
||||
var inputObj = $("#" + this.options.inputId);
|
||||
if (inputObj.length > 0) {
|
||||
var value = $.trim(inputObj.val());
|
||||
var nums = value === '' ? 0 : value.split(/\,/).length;
|
||||
var remain = this.options.maxFiles - nums;
|
||||
if (remain === 0 || files.length > remain) {
|
||||
files = Array.prototype.slice.call(files, remain);
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
this.removeFile(files[i]);
|
||||
}
|
||||
Toastr.error(__("You can only upload a maximum of %s files", this.options.maxFiles));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
success: function (file, response) {
|
||||
var ret = Upload.events.onUploadResponse(response, this, file);
|
||||
file.ret = ret;
|
||||
if (ret.code === 1) {
|
||||
Upload.events.onUploadSuccess(this, ret, file);
|
||||
} else {
|
||||
Upload.events.onUploadError(this, ret, file);
|
||||
}
|
||||
},
|
||||
error: function (file, response, xhr) {
|
||||
var responseObj = $("<div>" + (xhr && typeof xhr.responseText !== 'undefined' ? xhr.responseText : response) + "</div>");
|
||||
responseObj.find("style, title, script").remove();
|
||||
var msg = responseObj.text() || __('Network error');
|
||||
var ret = {code: 0, data: null, msg: msg};
|
||||
Upload.events.onUploadError(this, ret, file);
|
||||
},
|
||||
uploadprogress: function (file, progress, bytesSent) {
|
||||
if (file.upload.chunked) {
|
||||
$(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('Upload') + Math.floor((file.upload.bytesSent / file.size) * 100) + "%");
|
||||
}
|
||||
},
|
||||
totaluploadprogress: function (progress, bytesSent) {
|
||||
if (this.getActiveFiles().length > 0 && !this.options.chunking) {
|
||||
$(this.element).prop("disabled", true).html("<i class='fa fa-upload'></i> " + __('Upload') + Math.floor(progress) + "%");
|
||||
}
|
||||
},
|
||||
queuecomplete: function () {
|
||||
Upload.events.onUploadComplete(this, this.files);
|
||||
this.removeAllFiles(true);
|
||||
$(this.element).prop("disabled", false).html(this.options.elementHtml);
|
||||
},
|
||||
chunkSuccess: function (chunk, file, response) {
|
||||
},
|
||||
chunksUploaded: function (file, done) {
|
||||
var that = this;
|
||||
Fast.api.ajax({
|
||||
url: this.options.url,
|
||||
data: $.extend({}, multipart, {
|
||||
action: 'merge',
|
||||
filesize: file.size,
|
||||
filename: file.name,
|
||||
chunkid: file.upload.uuid,
|
||||
chunkcount: file.upload.totalChunkCount,
|
||||
})
|
||||
}, function (data, ret) {
|
||||
done(JSON.stringify(ret));
|
||||
return false;
|
||||
}, function (data, ret) {
|
||||
file.accepted = false;
|
||||
that._errorProcessing([file], ret.msg);
|
||||
});
|
||||
},
|
||||
onUploadSuccess: onUploadSuccess,
|
||||
onUploadError: onUploadError,
|
||||
onUploadComplete: onUploadComplete,
|
||||
}, Upload.options, options));
|
||||
|
||||
//拖动排序
|
||||
if (preview_id && multiple) {
|
||||
require(['dragsort'], function () {
|
||||
$("#" + preview_id).dragsort({
|
||||
dragSelector: "li a:not(.btn-trash)",
|
||||
dragEnd: function () {
|
||||
$("#" + preview_id).trigger("fa.preview.change");
|
||||
},
|
||||
placeHolderTemplate: '<li class="col-xs-3"></li>'
|
||||
});
|
||||
});
|
||||
}
|
||||
//刷新隐藏textarea的值
|
||||
var refresh = function (name) {
|
||||
var data = {};
|
||||
var textarea = $("textarea[name='" + name + "']");
|
||||
var container = textarea.prev("ul");
|
||||
$.each($("input,select,textarea", container).serializeArray(), function (i, j) {
|
||||
var reg = /\[?(\w+)\]?\[(\w+)\]$/g;
|
||||
var match = reg.exec(j.name);
|
||||
if (!match)
|
||||
return true;
|
||||
if (!isNaN(match[2])) {
|
||||
data[i] = j.value;
|
||||
} else {
|
||||
match[1] = "x" + parseInt(match[1]);
|
||||
if (typeof data[match[1]] === 'undefined') {
|
||||
data[match[1]] = {};
|
||||
}
|
||||
data[match[1]][match[2]] = j.value;
|
||||
}
|
||||
});
|
||||
var result = [];
|
||||
$.each(data, function (i, j) {
|
||||
result.push(j);
|
||||
});
|
||||
textarea.val(JSON.stringify(result));
|
||||
};
|
||||
if (preview_id && input_id) {
|
||||
$(document.body).on("keyup change", "#" + input_id, function (e) {
|
||||
var inputStr = $("#" + input_id).val();
|
||||
var inputArr = inputStr.split(/\,/);
|
||||
$("#" + preview_id).empty();
|
||||
var tpl = $("#" + preview_id).data("template") ? $("#" + preview_id).data("template") : "";
|
||||
var extend = $("#" + preview_id).next().is("textarea") ? $("#" + preview_id).next("textarea").val() : "{}";
|
||||
var json = {};
|
||||
try {
|
||||
json = JSON.parse(extend);
|
||||
} catch (e) {
|
||||
}
|
||||
$.each(inputArr, function (i, j) {
|
||||
if (!j) {
|
||||
return true;
|
||||
}
|
||||
var suffix = /[\.]?([a-zA-Z0-9]+)$/.exec(j);
|
||||
suffix = suffix ? suffix[1] : 'file';
|
||||
j = Config.upload.fullmode ? Fast.api.cdnurl(j) : j;
|
||||
var value = (json && typeof json[i] !== 'undefined' ? json[i] : null);
|
||||
var data = {url: j, fullurl: Fast.api.cdnurl(j), data: $(that).data(), key: i, index: i, value: value, row: value, suffix: suffix};
|
||||
var html = tpl ? Template(tpl, data) : Template.render(Upload.config.previewtpl, data);
|
||||
$("#" + preview_id).append(html);
|
||||
});
|
||||
refresh($("#" + preview_id).data("name"));
|
||||
});
|
||||
$("#" + input_id).trigger("change");
|
||||
}
|
||||
if (preview_id) {
|
||||
//监听文本框改变事件
|
||||
$("#" + preview_id).on('change keyup', "input,textarea,select", function () {
|
||||
refresh($(this).closest("ul").data("name"));
|
||||
});
|
||||
// 监听事件
|
||||
$(document.body).on("fa.preview.change", "#" + preview_id, function () {
|
||||
var urlArr = [];
|
||||
$("#" + preview_id + " [data-url]").each(function (i, j) {
|
||||
urlArr.push($(this).data("url"));
|
||||
});
|
||||
if (input_id) {
|
||||
$("#" + input_id).val(urlArr.join(","));
|
||||
}
|
||||
refresh($("#" + preview_id).data("name"));
|
||||
});
|
||||
// 移除按钮事件
|
||||
$(document.body).on("click", "#" + preview_id + " .btn-trash", function () {
|
||||
$(this).closest("li").remove();
|
||||
$("#" + preview_id).trigger("fa.preview.change");
|
||||
});
|
||||
}
|
||||
if (input_id) {
|
||||
$("#" + input_id).closest("form").on("reset", function () {
|
||||
setTimeout($.proxy(function () {
|
||||
$("#" + input_id, this).trigger("change");
|
||||
}, this), 0);
|
||||
});
|
||||
//粘贴上传、拖拽上传
|
||||
$("body").on('paste drop', "#" + input_id, function (event) {
|
||||
var originEvent = event.originalEvent;
|
||||
var button = $(".plupload[data-input-id='" + $(this).attr("id") + "'],.faupload[data-input-id='" + $(this).attr("id") + "']");
|
||||
if (event.type === 'paste' && originEvent.clipboardData && originEvent.clipboardData.items) {
|
||||
var items = originEvent.clipboardData.items;
|
||||
if ((items.length === 1 && items[0].type.indexOf("text") > -1) || (items.length === 2 && items[1].type.indexOf("text") > -1)) {
|
||||
|
||||
} else {
|
||||
Upload.list[button.attr("id")].paste(originEvent);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (event.type === 'drop' && originEvent.dataTransfer && originEvent.dataTransfer.files) {
|
||||
Upload.list[button.attr("id")].drop(originEvent);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* @deprecated Use upload instead.
|
||||
*/
|
||||
plupload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
|
||||
return Upload.api.upload(element, onUploadSuccess, onUploadError, onUploadComplete);
|
||||
},
|
||||
/**
|
||||
* @deprecated Use upload instead.
|
||||
*/
|
||||
faupload: function (element, onUploadSuccess, onUploadError, onUploadComplete) {
|
||||
return Upload.api.upload(element, onUploadSuccess, onUploadError, onUploadComplete);
|
||||
},
|
||||
// AJAX异步上传
|
||||
send: function (file, onUploadSuccess, onUploadError, onUploadComplete) {
|
||||
var index = Layer.msg(__('Uploading'), {offset: 't', time: 0});
|
||||
var id = "dropzone-" + Dropzone.uuidv4();
|
||||
$('<button type="button" id="' + id + '" class="btn btn-danger hidden faupload" />').appendTo("body");
|
||||
$("#" + id).data("upload-complete", function (files) {
|
||||
Layer.close(index);
|
||||
Upload.list[id].removeAllFiles(true);
|
||||
});
|
||||
Upload.api.upload("#" + id, onUploadSuccess, onUploadError, onUploadComplete);
|
||||
setTimeout(function () {
|
||||
Upload.list[id].addFile(file);
|
||||
}, 1);
|
||||
},
|
||||
custom: {
|
||||
//自定义上传完成回调
|
||||
afteruploadcallback: function (response) {
|
||||
console.log(this, response);
|
||||
alert("Custom Callback,Response URL:" + response.url);
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
return Upload;
|
||||
});
|
||||
2142
public/assets/js/require.js
Normal file
2142
public/assets/js/require.js
Normal file
File diff suppressed because it is too large
Load Diff
1
public/assets/js/require.min.js
vendored
Normal file
1
public/assets/js/require.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5
public/assets/js/respond.min.js
vendored
Normal file
5
public/assets/js/respond.min.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/*! Respond.js v1.4.2: min/max-width media query polyfill * Copyright 2013 Scott Jehl
|
||||
* Licensed under https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT
|
||||
* */
|
||||
|
||||
!function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeChild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b<s.length;b++){var c=s[b],e=c.href,f=c.media,g=c.rel&&"stylesheet"===c.rel.toLowerCase();e&&g&&!o[e]&&(c.styleSheet&&c.styleSheet.rawCssText?(v(c.styleSheet.rawCssText,e,f),o[e]=!0):(!/^([a-zA-Z:]*\/\/)/.test(e)&&!r||e.replace(RegExp.$1,"").split("/")[0]===a.location.host)&&("//"===e.substring(0,2)&&(e=a.location.protocol+e),d.push({href:e,media:f})))}w()};x(),c.update=x,c.getEmValue=t,a.addEventListener?a.addEventListener("resize",b,!1):a.attachEvent&&a.attachEvent("onresize",b)}}(this);
|
||||
663
public/assets/js/tagsinput.js
Normal file
663
public/assets/js/tagsinput.js
Normal file
@@ -0,0 +1,663 @@
|
||||
/*
|
||||
* bootstrap-tagsinput v0.8.0
|
||||
*
|
||||
* For details, see the web site: https://github.com/bootstrap-tagsinput/bootstrap-tagsinput
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
"use strict";
|
||||
|
||||
var defaultOptions = {
|
||||
tagClass: function (item) {
|
||||
return 'label label-info';
|
||||
},
|
||||
focusClass: 'focus',
|
||||
itemValue: function (item) {
|
||||
return item ? item.toString() : item;
|
||||
},
|
||||
itemText: function (item) {
|
||||
return this.itemValue(item);
|
||||
},
|
||||
itemTitle: function (item) {
|
||||
return null;
|
||||
},
|
||||
freeInput: true,
|
||||
addOnBlur: true,
|
||||
maxTags: undefined,
|
||||
maxChars: undefined,
|
||||
confirmKeys: [13, 44],
|
||||
delimiter: ',',
|
||||
inputMinWidth: 80,
|
||||
delimiterRegex: null,
|
||||
cancelConfirmKeysOnEmpty: false,
|
||||
onTagExists: function (item, $tag) {
|
||||
$tag.hide().fadeIn();
|
||||
},
|
||||
trimValue: false,
|
||||
allowDuplicates: false,
|
||||
triggerChange: true
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor function
|
||||
*/
|
||||
function TagsInput(element, options) {
|
||||
this.isInit = true;
|
||||
this.itemsArray = [];
|
||||
|
||||
this.$element = $(element);
|
||||
this.$element.hide();
|
||||
|
||||
this.isSelect = (element.tagName === 'SELECT');
|
||||
this.multiple = (this.isSelect && element.hasAttribute('multiple'));
|
||||
this.objectItems = options && options.itemValue;
|
||||
this.placeholderText = element.hasAttribute('placeholder') ? this.$element.attr('placeholder') : '';
|
||||
this.inputSize = Math.max(1, this.placeholderText.length);
|
||||
|
||||
this.$container = $('<div class="bootstrap-tagsinput"></div>');
|
||||
this.$input = $('<input type="text" placeholder="' + this.placeholderText + '"/>').appendTo(this.$container);
|
||||
|
||||
this.$element.before(this.$container);
|
||||
this.build(options);
|
||||
this.isInit = false;
|
||||
}
|
||||
|
||||
TagsInput.prototype = {
|
||||
constructor: TagsInput,
|
||||
|
||||
/**
|
||||
* Adds the given item as a new tag. Pass true to dontPushVal to prevent
|
||||
* updating the elements val()
|
||||
*/
|
||||
add: function (item, dontPushVal, options) {
|
||||
var self = this;
|
||||
|
||||
if (self.options.maxTags && self.itemsArray.length >= self.options.maxTags)
|
||||
return;
|
||||
|
||||
// Ignore falsey values, except false
|
||||
if (item !== false && !item)
|
||||
return;
|
||||
|
||||
// Trim value
|
||||
if (typeof item === "string" && self.options.trimValue) {
|
||||
item = $.trim(item);
|
||||
}
|
||||
|
||||
// Throw an error when trying to add an object while the itemValue option was not set
|
||||
if (typeof item === "object" && !self.objectItems)
|
||||
throw("Can't add objects when itemValue option is not set");
|
||||
|
||||
// Ignore strings only containg whitespace
|
||||
if (item.toString().match(/^\s*$/))
|
||||
return;
|
||||
|
||||
// If SELECT but not multiple, remove current tag
|
||||
if (self.isSelect && !self.multiple && self.itemsArray.length > 0)
|
||||
self.remove(self.itemsArray[0]);
|
||||
|
||||
if (typeof item === "string" && this.$element[0].tagName === 'INPUT') {
|
||||
var delimiter = (self.options.delimiterRegex) ? self.options.delimiterRegex : self.options.delimiter;
|
||||
var items = item.split(delimiter);
|
||||
if (items.length > 1) {
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
this.add(items[i], true);
|
||||
}
|
||||
|
||||
if (!dontPushVal)
|
||||
self.pushVal(self.options.triggerChange);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var itemValue = self.options.itemValue(item),
|
||||
itemText = self.options.itemText(item),
|
||||
tagClass = self.options.tagClass(item),
|
||||
itemTitle = self.options.itemTitle(item);
|
||||
|
||||
// Ignore items allready added
|
||||
var existing = $.grep(self.itemsArray, function (item) {
|
||||
return self.options.itemValue(item) === itemValue;
|
||||
})[0];
|
||||
if (existing && !self.options.allowDuplicates) {
|
||||
// Invoke onTagExists
|
||||
if (self.options.onTagExists) {
|
||||
var $existingTag = $(".tag", self.$container).filter(function () {
|
||||
return $(this).data("item") === existing;
|
||||
});
|
||||
self.options.onTagExists(item, $existingTag);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// if length greater than limit
|
||||
if (self.items().toString().length + item.length + 1 > self.options.maxInputLength)
|
||||
return;
|
||||
|
||||
// raise beforeItemAdd arg
|
||||
var beforeItemAddEvent = $.Event('beforeItemAdd', {item: item, cancel: false, options: options});
|
||||
self.$element.trigger(beforeItemAddEvent);
|
||||
if (beforeItemAddEvent.cancel)
|
||||
return;
|
||||
|
||||
// register item in internal array and map
|
||||
self.itemsArray.push(item);
|
||||
|
||||
// add a tag element
|
||||
|
||||
var $tag = $('<span class="tag ' + htmlEncode(tagClass) + (itemTitle !== null ? ('" title="' + itemTitle) : '') + '">' + htmlEncode(itemText) + '<span data-role="remove"></span></span>');
|
||||
$tag.data('item', item);
|
||||
self.findInputWrapper().before($tag);
|
||||
$tag.after(' ');
|
||||
|
||||
// Check to see if the tag exists in its raw or uri-encoded form
|
||||
var optionExists = (
|
||||
$('option[value="' + encodeURIComponent(itemValue) + '"]', self.$element).length ||
|
||||
$('option[value="' + htmlEncode(itemValue) + '"]', self.$element).length
|
||||
);
|
||||
|
||||
// add <option /> if item represents a value not present in one of the <select />'s options
|
||||
if (self.isSelect && !optionExists) {
|
||||
var $option = $('<option selected>' + htmlEncode(itemText) + '</option>');
|
||||
$option.data('item', item);
|
||||
$option.attr('value', itemValue);
|
||||
self.$element.append($option);
|
||||
}
|
||||
|
||||
if (!dontPushVal)
|
||||
self.pushVal(self.options.triggerChange);
|
||||
|
||||
// Add class when reached maxTags
|
||||
if (self.options.maxTags === self.itemsArray.length || self.items().toString().length === self.options.maxInputLength)
|
||||
self.$container.addClass('bootstrap-tagsinput-max');
|
||||
|
||||
// If using autocomplete, once the tag has been added, clear the autocomplete value so it does not stick around in the input.
|
||||
if (self.options.autocomplete) {
|
||||
// self.$input.autocomplete('clear');
|
||||
}
|
||||
|
||||
if (this.isInit) {
|
||||
self.$element.trigger($.Event('itemAddedOnInit', {item: item, options: options}));
|
||||
} else {
|
||||
self.$element.trigger($.Event('itemAdded', {item: item, options: options}));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the given item. Pass true to dontPushVal to prevent updating the
|
||||
* elements val()
|
||||
*/
|
||||
remove: function (item, dontPushVal, options) {
|
||||
var self = this;
|
||||
|
||||
if (self.objectItems) {
|
||||
if (typeof item === "object")
|
||||
item = $.grep(self.itemsArray, function (other) {
|
||||
return self.options.itemValue(other) == self.options.itemValue(item);
|
||||
});
|
||||
else
|
||||
item = $.grep(self.itemsArray, function (other) {
|
||||
return self.options.itemValue(other) == item;
|
||||
});
|
||||
|
||||
item = item[item.length - 1];
|
||||
}
|
||||
|
||||
if (item) {
|
||||
var beforeItemRemoveEvent = $.Event('beforeItemRemove', {item: item, cancel: false, options: options});
|
||||
self.$element.trigger(beforeItemRemoveEvent);
|
||||
if (beforeItemRemoveEvent.cancel)
|
||||
return;
|
||||
|
||||
$('.tag', self.$container).filter(function () {
|
||||
return $(this).data('item') === item;
|
||||
}).remove();
|
||||
$('option', self.$element).filter(function () {
|
||||
return $(this).data('item') === item;
|
||||
}).remove();
|
||||
if ($.inArray(item, self.itemsArray) !== -1)
|
||||
self.itemsArray.splice($.inArray(item, self.itemsArray), 1);
|
||||
}
|
||||
|
||||
if (!dontPushVal)
|
||||
self.pushVal(self.options.triggerChange);
|
||||
|
||||
// Remove class when reached maxTags
|
||||
if (self.options.maxTags > self.itemsArray.length)
|
||||
self.$container.removeClass('bootstrap-tagsinput-max');
|
||||
|
||||
self.$element.trigger($.Event('itemRemoved', {item: item, options: options}));
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes all items
|
||||
*/
|
||||
removeAll: function () {
|
||||
var self = this;
|
||||
|
||||
$('.tag', self.$container).remove();
|
||||
$('option', self.$element).remove();
|
||||
|
||||
while (self.itemsArray.length > 0)
|
||||
self.itemsArray.pop();
|
||||
|
||||
self.pushVal(self.options.triggerChange);
|
||||
},
|
||||
|
||||
/**
|
||||
* Refreshes the tags so they match the text/value of their corresponding
|
||||
* item.
|
||||
*/
|
||||
refresh: function () {
|
||||
var self = this;
|
||||
$('.tag', self.$container).each(function () {
|
||||
var $tag = $(this),
|
||||
item = $tag.data('item'),
|
||||
itemValue = self.options.itemValue(item),
|
||||
itemText = self.options.itemText(item),
|
||||
tagClass = self.options.tagClass(item);
|
||||
|
||||
// Update tag's class and inner text
|
||||
$tag.attr('class', null);
|
||||
$tag.addClass('tag ' + htmlEncode(tagClass));
|
||||
$tag.contents().filter(function () {
|
||||
return this.nodeType == 3;
|
||||
})[0].nodeValue = htmlEncode(itemText);
|
||||
|
||||
if (self.isSelect) {
|
||||
var option = $('option', self.$element).filter(function () {
|
||||
return $(this).data('item') === item;
|
||||
});
|
||||
option.attr('value', itemValue);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* reset the items
|
||||
*/
|
||||
reset: function () {
|
||||
var val = this.$element.val();
|
||||
this.removeAll();
|
||||
this.add(val);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the items added as tags
|
||||
*/
|
||||
items: function () {
|
||||
return this.itemsArray;
|
||||
},
|
||||
|
||||
/**
|
||||
* Assembly value by retrieving the value of each item, and set it on the
|
||||
* element.
|
||||
*/
|
||||
pushVal: function () {
|
||||
var self = this,
|
||||
val = $.map(self.items(), function (item) {
|
||||
return self.options.itemValue(item).toString();
|
||||
});
|
||||
|
||||
self.$element.val(val, true);
|
||||
|
||||
if (self.options.triggerChange)
|
||||
self.$element.trigger('change');
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the tags input behaviour on the element
|
||||
*/
|
||||
build: function (options) {
|
||||
var self = this;
|
||||
|
||||
self.options = $.extend({}, defaultOptions, options);
|
||||
// When itemValue is set, freeInput should always be false
|
||||
if (self.objectItems)
|
||||
self.options.freeInput = false;
|
||||
|
||||
makeOptionItemFunction(self.options, 'itemValue');
|
||||
makeOptionItemFunction(self.options, 'itemText');
|
||||
makeOptionFunction(self.options, 'tagClass');
|
||||
|
||||
if (self.options.autocomplete) {
|
||||
var autocomplete = self.options.autocomplete || {};
|
||||
|
||||
// makeOptionFunction(autocomplete, 'lookup');
|
||||
self.$input.autocomplete($.extend(true, {}, {
|
||||
type: 'post',
|
||||
params: function (q) {
|
||||
var params = {};
|
||||
params['name'] = self.$element.prop("name");
|
||||
params['tags'] = self.$element.val();
|
||||
return params;
|
||||
},
|
||||
onSelect: function (suggestion) {
|
||||
self.add(suggestion.value);
|
||||
self.$input.val('').width(self.options.inputMinWidth).focus();
|
||||
}
|
||||
}, autocomplete));
|
||||
}
|
||||
|
||||
self.$container.on('click', $.proxy(function (event) {
|
||||
if (!self.$element.attr('disabled')) {
|
||||
self.$input.removeAttr('disabled');
|
||||
}
|
||||
self.$input.focus();
|
||||
if (self.options.autocomplete && self.$input.autocomplete().visible) {
|
||||
clearTimeout(self.$input.autocomplete().blurTimeoutId);
|
||||
}
|
||||
}, self));
|
||||
|
||||
if (self.options.addOnBlur && self.options.freeInput) {
|
||||
self.$input.on('focusout', $.proxy(function (event) {
|
||||
// HACK: only process on focusout when no autocomplete opened, to
|
||||
// avoid adding the autocomplete text as tag
|
||||
if (!self.options.autocomplete) {
|
||||
self.add(self.$input.val());
|
||||
self.$input.val('').css("width", self.options.inputMinWidth);
|
||||
} else {
|
||||
var autocomplete = self.$input.autocomplete();
|
||||
setTimeout(function () {
|
||||
if (!autocomplete.visible && self.$input.val() !== '') {
|
||||
self.add(self.$input.val());
|
||||
self.$input.val('').css("width", self.options.inputMinWidth);
|
||||
}
|
||||
}, 210);
|
||||
}
|
||||
}, self));
|
||||
}
|
||||
|
||||
// Toggle the 'focus' css class on the container when it has focus
|
||||
self.$container.on({
|
||||
focusin: function () {
|
||||
self.$container.addClass(self.options.focusClass);
|
||||
},
|
||||
focusout: function () {
|
||||
self.$container.removeClass(self.options.focusClass);
|
||||
},
|
||||
});
|
||||
|
||||
self.$container.on('keydown', 'input', $.proxy(function (event) {
|
||||
var $input = $(event.target),
|
||||
$inputWrapper = self.findInputWrapper();
|
||||
|
||||
if (self.$element.attr('disabled')) {
|
||||
self.$input.attr('disabled', 'disabled');
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event.which) {
|
||||
// BACKSPACE
|
||||
case 8:
|
||||
if (doGetCaretPosition($input[0]) === 0) {
|
||||
var prev = $inputWrapper.prev();
|
||||
if (prev.length) {
|
||||
self.remove(prev.data('item'));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// DELETE
|
||||
case 46:
|
||||
if (doGetCaretPosition($input[0]) === 0) {
|
||||
var next = $inputWrapper.next();
|
||||
if (next.length) {
|
||||
self.remove(next.data('item'));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// LEFT ARROW
|
||||
case 37:
|
||||
// Try to move the input before the previous tag
|
||||
var $prevTag = $inputWrapper.prev();
|
||||
if ($input.val().length === 0 && $prevTag[0]) {
|
||||
$prevTag.before($inputWrapper);
|
||||
$input.focus();
|
||||
}
|
||||
break;
|
||||
// RIGHT ARROW
|
||||
case 39:
|
||||
// Try to move the input after the next tag
|
||||
var $nextTag = $inputWrapper.next();
|
||||
if ($input.val().length === 0 && $nextTag[0]) {
|
||||
$nextTag.after($inputWrapper);
|
||||
$input.focus();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// ignore
|
||||
}
|
||||
|
||||
$input.css('width', self.getInputTextWidth());
|
||||
|
||||
}, self));
|
||||
|
||||
self.$container.on('keypress', 'input', $.proxy(function (event) {
|
||||
var $input = $(event.target);
|
||||
|
||||
if (self.$element.attr('disabled')) {
|
||||
self.$input.attr('disabled', 'disabled');
|
||||
return;
|
||||
}
|
||||
|
||||
var text = $input.val(),
|
||||
maxLengthReached = self.options.maxChars && text.length >= self.options.maxChars;
|
||||
if (self.options.freeInput && (keyCombinationInList(event, self.options.confirmKeys) || maxLengthReached)) {
|
||||
// Only attempt to add a tag if there is data in the field
|
||||
if (text.length !== 0) {
|
||||
self.add(maxLengthReached ? text.substr(0, self.options.maxChars) : text);
|
||||
$input.val('').css("width", self.options.inputMinWidth);
|
||||
}
|
||||
|
||||
// If the field is empty, let the event triggered fire as usual
|
||||
if (self.options.cancelConfirmKeysOnEmpty === false) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
$input.css('width', self.getInputTextWidth());
|
||||
|
||||
}, self));
|
||||
|
||||
// Remove icon clicked
|
||||
self.$container.on('click', '[data-role=remove]', $.proxy(function (event) {
|
||||
if (self.$element.attr('disabled')) {
|
||||
return;
|
||||
}
|
||||
self.remove($(event.target).closest('.tag').data('item'));
|
||||
}, self));
|
||||
|
||||
// Only add existing value as tags when using strings as tags
|
||||
if (self.options.itemValue === defaultOptions.itemValue) {
|
||||
if (self.$element[0].tagName === 'INPUT') {
|
||||
self.add(self.$element.val());
|
||||
} else {
|
||||
$('option', self.$element).each(function () {
|
||||
self.add($(this).attr('value'), true);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes all tagsinput behaviour and unregsiter all event handlers
|
||||
*/
|
||||
destroy: function () {
|
||||
var self = this;
|
||||
|
||||
// Unbind events
|
||||
self.$container.off('keypress', 'input');
|
||||
self.$container.off('click', '[role=remove]');
|
||||
|
||||
self.$container.remove();
|
||||
self.$element.removeData('tagsinput');
|
||||
self.$element.show();
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets focus on the tagsinput
|
||||
*/
|
||||
focus: function () {
|
||||
this.$input.focus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the internal input element
|
||||
*/
|
||||
input: function () {
|
||||
return this.$input;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the element which is wrapped around the internal input. This
|
||||
* is normally the $container, but typeahead.js moves the $input element.
|
||||
*/
|
||||
findInputWrapper: function () {
|
||||
var elt = this.$input[0],
|
||||
container = this.$container[0];
|
||||
while (elt && elt.parentNode !== container)
|
||||
elt = elt.parentNode;
|
||||
|
||||
return $(elt);
|
||||
},
|
||||
/**
|
||||
* Get input text width
|
||||
* @returns {number}
|
||||
*/
|
||||
getInputTextWidth: function () {
|
||||
var $input = this.$input;
|
||||
var self = this;
|
||||
var msgspan = $input.next().length > 0 ? $input.next() : $("<span />").addClass("tagsinput-text").insertAfter($input);
|
||||
var textWidth = msgspan.text($input.val()).outerWidth();
|
||||
textWidth = Math.max(textWidth, self.options.inputMinWidth);
|
||||
textWidth = Math.min(textWidth, self.$container.innerWidth());
|
||||
return textWidth;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Register JQuery plugin
|
||||
*/
|
||||
$.fn.tagsinput = function (arg1, arg2, arg3) {
|
||||
var results = [];
|
||||
|
||||
this.each(function () {
|
||||
var tagsinput = $(this).data('tagsinput');
|
||||
// Initialize a new tags input
|
||||
if (!tagsinput) {
|
||||
tagsinput = new TagsInput(this, $.extend(true, {}, arg1, $(this).data('tagsinput-options') || {}));
|
||||
$(this).data('tagsinput', tagsinput);
|
||||
results.push(tagsinput);
|
||||
|
||||
if (this.tagName === 'SELECT') {
|
||||
$('option', $(this)).attr('selected', 'selected');
|
||||
}
|
||||
|
||||
// Init tags from $(this).val()
|
||||
$(this).val($(this).val());
|
||||
} else if (!arg1 && !arg2) {
|
||||
// tagsinput already exists
|
||||
// no function, trying to init
|
||||
results.push(tagsinput);
|
||||
} else if (tagsinput[arg1] !== undefined) {
|
||||
// Invoke function on existing tags input
|
||||
if (tagsinput[arg1].length === 3 && arg3 !== undefined) {
|
||||
var retVal = tagsinput[arg1](arg2, null, arg3);
|
||||
} else {
|
||||
var retVal = tagsinput[arg1](arg2);
|
||||
}
|
||||
if (retVal !== undefined)
|
||||
results.push(retVal);
|
||||
}
|
||||
});
|
||||
|
||||
return results.length > 1 ? results : results[0];
|
||||
};
|
||||
|
||||
$.fn.tagsinput.Constructor = TagsInput;
|
||||
|
||||
/**
|
||||
* Most options support both a string or number as well as a function as
|
||||
* option value. This function makes sure that the option with the given
|
||||
* key in the given options is wrapped in a function
|
||||
*/
|
||||
function makeOptionItemFunction(options, key) {
|
||||
if (typeof options[key] !== 'function') {
|
||||
var propertyName = options[key];
|
||||
options[key] = function (item) {
|
||||
return item[propertyName];
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function makeOptionFunction(options, key) {
|
||||
if (typeof options[key] !== 'function') {
|
||||
var value = options[key];
|
||||
options[key] = function () {
|
||||
return value;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HtmlEncodes the given value
|
||||
*/
|
||||
var htmlEncodeContainer = $('<div />');
|
||||
|
||||
function htmlEncode(value) {
|
||||
if (value) {
|
||||
return htmlEncodeContainer.text(value).html();
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the position of the caret in the given input field
|
||||
* http://flightschool.acylt.com/devnotes/caret-position-woes/
|
||||
*/
|
||||
function doGetCaretPosition(oField) {
|
||||
var iCaretPos = 0;
|
||||
if (document.selection) {
|
||||
oField.focus();
|
||||
var oSel = document.selection.createRange();
|
||||
oSel.moveStart('character', -oField.value.length);
|
||||
iCaretPos = oSel.text.length;
|
||||
} else if (oField.selectionStart || oField.selectionStart == '0') {
|
||||
iCaretPos = oField.selectionStart;
|
||||
}
|
||||
return (iCaretPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns boolean indicates whether user has pressed an expected key combination.
|
||||
* @param object keyPressEvent: JavaScript event object, refer
|
||||
* http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
||||
* @param object lookupList: expected key combinations, as in:
|
||||
* [13, {which: 188, shiftKey: true}]
|
||||
*/
|
||||
function keyCombinationInList(keyPressEvent, lookupList) {
|
||||
var found = false;
|
||||
$.each(lookupList, function (index, keyCombination) {
|
||||
if (typeof (keyCombination) === 'number' && keyPressEvent.which === keyCombination) {
|
||||
found = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (keyPressEvent.which === keyCombination.which) {
|
||||
var alt = !keyCombination.hasOwnProperty('altKey') || keyPressEvent.altKey === keyCombination.altKey,
|
||||
shift = !keyCombination.hasOwnProperty('shiftKey') || keyPressEvent.shiftKey === keyCombination.shiftKey,
|
||||
ctrl = !keyCombination.hasOwnProperty('ctrlKey') || keyPressEvent.ctrlKey === keyCombination.ctrlKey;
|
||||
if (alt && shift && ctrl) {
|
||||
found = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
})(window.jQuery);
|
||||
Reference in New Issue
Block a user