adding missing files
parent
ebe61450a1
commit
0ea14324ac
@ -0,0 +1,53 @@
|
|||||||
|
"use strict";
|
||||||
|
/* global define, socket, app */
|
||||||
|
|
||||||
|
/*
|
||||||
|
settings.js 2.0, because version 1:
|
||||||
|
- saved everything in "config" hash
|
||||||
|
- was hand-rolled (mm, salmon hand roll)
|
||||||
|
- Relied on app.config (!!)
|
||||||
|
This module should:
|
||||||
|
- Allow you to save to any specified hash
|
||||||
|
- Rely on jQuery
|
||||||
|
- Use sockets
|
||||||
|
- Be more awesome
|
||||||
|
*/
|
||||||
|
|
||||||
|
define(function() {
|
||||||
|
var Settings = {};
|
||||||
|
|
||||||
|
Settings.load = function(hash, formEl) {
|
||||||
|
socket.emit('modules.settings.get', {
|
||||||
|
hash: hash
|
||||||
|
}, function(err, values) {
|
||||||
|
if (!err) {
|
||||||
|
$(formEl).deserialize(values);
|
||||||
|
} else {
|
||||||
|
console.log('[settings] Unable to load settings for hash: ', hash);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Settings.save = function(hash, formEl) {
|
||||||
|
var formEl = $(formEl);
|
||||||
|
if (formEl.length) {
|
||||||
|
var values = formEl.serializeObject();
|
||||||
|
|
||||||
|
socket.emit('modules.settings.set', {
|
||||||
|
hash: hash,
|
||||||
|
values: values
|
||||||
|
}, function(err) {
|
||||||
|
app.alert({
|
||||||
|
title: 'Settings Saved',
|
||||||
|
message: 'Restarting NodeBB <i class="fa fa-spin fa-refresh"></i>',
|
||||||
|
type: 'success',
|
||||||
|
timeout: 2500
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log('[settings] Form not found.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return Settings;
|
||||||
|
});
|
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* @author Kyle Florence <kyle[dot]florence[at]gmail[dot]com>
|
||||||
|
* @website https://github.com/kflorence/jquery-deserialize/
|
||||||
|
* @version 1.2.1
|
||||||
|
*
|
||||||
|
* Dual licensed under the MIT and GPLv2 licenses.
|
||||||
|
*/
|
||||||
|
(function(i,b){var f=Array.prototype.push,a=/^(?:radio|checkbox)$/i,e=/\+/g,d=/^(?:option|select-one|select-multiple)$/i,g=/^(?:button|color|date|datetime|datetime-local|email|hidden|month|number|password|range|reset|search|submit|tel|text|textarea|time|url|week)$/i;function c(j){return j.map(function(){return this.elements?i.makeArray(this.elements):this}).filter(":input").get()}function h(j){var k,l={};i.each(j,function(n,m){k=l[m.name];l[m.name]=k===b?m:(i.isArray(k)?k.concat(m):[k,m])});return l}i.fn.deserialize=function(A,l){var y,n,q=c(this),t=[];if(!A||!q.length){return this}if(i.isArray(A)){t=A}else{if(i.isPlainObject(A)){var B,w;for(B in A){i.isArray(w=A[B])?f.apply(t,i.map(w,function(j){return{name:B,value:j}})):f.call(t,{name:B,value:w})}}else{if(typeof A==="string"){var v;A=A.split("&");for(y=0,n=A.length;y<n;y++){v=A[y].split("=");f.call(t,{name:decodeURIComponent(v[0]),value:decodeURIComponent(v[1].replace(e,"%20"))})}}}}if(!(n=t.length)){return this}var u,k,x,z,C,o,m,w,p=i.noop,s=i.noop,r={};l=l||{};q=h(q);if(i.isFunction(l)){s=l}else{p=i.isFunction(l.change)?l.change:p;s=i.isFunction(l.complete)?l.complete:s}for(y=0;y<n;y++){u=t[y];C=u.name;w=u.value;if(!(k=q[C])){continue}m=(z=k.length)?k[0]:k;m=(m.type||m.nodeName).toLowerCase();o=null;if(g.test(m)){if(z){x=r[C];k=k[r[C]=(x==b)?0:++x]}p.call(k,(k.value=w))}else{if(a.test(m)){o="checked"}else{if(d.test(m)){o="selected"}}}if(o){if(!z){k=[k];z=1}for(x=0;x<z;x++){u=k[x];if(u.value==w){p.call(u,(u[o]=true)&&w)}}}}s.call(this);return this}})(jQuery);
|
@ -0,0 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* jQuery serializeObject - v0.2 - 1/20/2010
|
||||||
|
* http://benalman.com/projects/jquery-misc-plugins/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2010 "Cowboy" Ben Alman
|
||||||
|
* Dual licensed under the MIT and GPL licenses.
|
||||||
|
* http://benalman.com/about/license/
|
||||||
|
*/
|
||||||
|
(function($,a){$.fn.serializeObject=function(){var b={};$.each(this.serializeArray(),function(d,e){var f=e.name,c=e.value;b[f]=b[f]===a?c:$.isArray(b[f])?b[f].concat(c):[b[f],c]});return b}})(jQuery);
|
Loading…
Reference in New Issue