Added express.js web interface options.
This commit is contained in:
1 parent
353e440241
commit
5c9d9e67ca
568 files changed
+122395
-1
No files matched your search
@@ -0,0 +1,252 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
(function(global, $, UI){
|
||||
|
||||
// Datepicker
|
||||
|
||||
var active = false,
|
||||
dropdown = $('<div class="uk-dropdown uk-datepicker"></div>');
|
||||
|
||||
dropdown.on("click", ".uk-datepicker-next, .uk-datepicker-previous, [data-date]", function(e){
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
var ele = $(this);
|
||||
|
||||
if(ele.is('[data-date]')) {
|
||||
active.element.val(moment(ele.data("date")).format(active.options.format)).trigger("change");
|
||||
dropdown.hide();
|
||||
active = false;
|
||||
} else {
|
||||
active.add("months", 1 * (ele.hasClass("uk-datepicker-next") ? 1:-1));
|
||||
}
|
||||
});
|
||||
|
||||
var DatePicker = function(element, options) {
|
||||
|
||||
var $this = this, $element = $(element);
|
||||
|
||||
if($element.data("datepicker")) return;
|
||||
|
||||
this.element = $element;
|
||||
this.options = $.extend({}, DatePicker.defaults, options);
|
||||
this.current = this.element.val() ? moment(this.element.val(), this.options.format) : moment();
|
||||
|
||||
this.element.on("click", function(){
|
||||
if(active!==$this) $this.pick(this.value);
|
||||
}).on("change", function(){
|
||||
|
||||
if($this.element.val() && !moment($this.element.val(), $this.options.format).isValid()) {
|
||||
$this.element.val(moment().format($this.options.format));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
this.element.data("datepicker", this);
|
||||
};
|
||||
|
||||
DatePicker.defaults = {
|
||||
weekstart: 1,
|
||||
i18n: {
|
||||
months : ['January','February','March','April','May','June','July','August','September','October','November','December'],
|
||||
weekdays : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
|
||||
},
|
||||
format: "DD.MM.YYYY",
|
||||
offsettop: 5,
|
||||
template: function(data, opts) {
|
||||
|
||||
var content = '';
|
||||
|
||||
|
||||
content += '<div class="uk-datepicker-nav">';
|
||||
content += '<a href="" class="uk-datepicker-previous"></a>';
|
||||
content += '<a href="" class="uk-datepicker-next"></a>';
|
||||
content += '<div class="uk-datepicker-heading">'+ opts.i18n.months[data.month] +' '+ data.year+'</div>';
|
||||
content += '</div>';
|
||||
|
||||
content += '<table class="uk-datepicker-table">';
|
||||
content += '<thead>';
|
||||
for(var i = 0; i < data.weekdays.length; i++) {
|
||||
if (data.weekdays[i]) {
|
||||
content += '<th>'+data.weekdays[i]+'</th>';
|
||||
}
|
||||
}
|
||||
content += '</thead>';
|
||||
|
||||
content += '<tbody>';
|
||||
for(var i = 0; i < data.days.length; i++) {
|
||||
if (data.days[i] && data.days[i].length){
|
||||
content += '<tr>';
|
||||
for(var d = 0; d < data.days[i].length; d++) {
|
||||
if (data.days[i][d]) {
|
||||
var day = data.days[i][d],
|
||||
cls = [];
|
||||
|
||||
if(!day.inmonth) cls.push("uk-datepicker-table-muted");
|
||||
if(day.selected) cls.push("uk-active");
|
||||
|
||||
content += '<td><a href="" class="'+cls.join(" ")+'" data-date="'+day.day.format()+'">'+day.day.format("D")+'</a></td>';
|
||||
}
|
||||
}
|
||||
content += '</tr>';
|
||||
}
|
||||
}
|
||||
content += '</tbody>';
|
||||
|
||||
content += '</table>';
|
||||
|
||||
|
||||
|
||||
return content;
|
||||
}
|
||||
};
|
||||
|
||||
$.extend(DatePicker.prototype, {
|
||||
|
||||
pick: function(initdate) {
|
||||
|
||||
var offset = this.element.offset(),
|
||||
css = {"top": offset.top + this.element.outerHeight() + this.options.offsettop, "left": offset.left, "right":""};
|
||||
|
||||
this.current = initdate ? moment(initdate, this.options.format):moment();
|
||||
this.initdate = this.current.format("YYYY-MM-DD");
|
||||
|
||||
this.update();
|
||||
|
||||
if ($.UIkit.langdirection == 'right') {
|
||||
css.right = window.innerWidth - (css.left + this.element.outerWidth());
|
||||
css.left = "";
|
||||
}
|
||||
|
||||
dropdown.css(css).show();
|
||||
|
||||
active = this;
|
||||
},
|
||||
|
||||
add: function(unit, value) {
|
||||
this.current.add(unit, value);
|
||||
this.update();
|
||||
},
|
||||
|
||||
setMonth: function(month) {
|
||||
this.current.month(month);
|
||||
this.update();
|
||||
},
|
||||
|
||||
setYear: function(year) {
|
||||
this.current.year(year);
|
||||
this.update();
|
||||
},
|
||||
|
||||
update: function() {
|
||||
|
||||
var data = this.getRows(this.current.year(), this.current.month()),
|
||||
tpl = this.options.template(data, this.options);
|
||||
|
||||
dropdown.html(tpl);
|
||||
},
|
||||
|
||||
getRows: function(year, month) {
|
||||
|
||||
var opts = this.options,
|
||||
now = moment().format('YYYY-MM-DD'),
|
||||
days = [31, (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month],
|
||||
before = new Date(year, month, 1).getDay(),
|
||||
data = {"month":month, "year":year,"weekdays":[],"days":[]},
|
||||
row = [];
|
||||
|
||||
data.weekdays = (function(){
|
||||
|
||||
for (var i=0, arr=[]; i < 7; i++) {
|
||||
|
||||
var day = i + (opts.weekstart || 0);
|
||||
|
||||
while (day >= 7) {
|
||||
day -= 7;
|
||||
}
|
||||
|
||||
arr.push(opts.i18n.weekdays[day]);
|
||||
}
|
||||
|
||||
return arr;
|
||||
})();
|
||||
|
||||
if (opts.weekstart && opts.weekstart > 0) {
|
||||
before -= opts.weekstart;
|
||||
if (before < 0) {
|
||||
before += 7;
|
||||
}
|
||||
}
|
||||
|
||||
var cells = days + before, after = cells;
|
||||
|
||||
while(after > 7) { after -= 7; }
|
||||
|
||||
cells += 7 - after;
|
||||
|
||||
var day, isDisabled, isSelected, isToday, isInMonth;
|
||||
|
||||
for (var i = 0, r = 0; i < cells; i++) {
|
||||
|
||||
day = new Date(year, month, 1 + (i - before));
|
||||
isDisabled = (opts.mindate && day < opts.mindate) || (opts.maxdate && day > opts.maxdate);
|
||||
isInMonth = !(i < before || i >= (days + before));
|
||||
|
||||
day = moment(day);
|
||||
|
||||
isSelected = this.initdate == day.format("YYYY-MM-DD");
|
||||
isToday = now == day.format("YYYY-MM-DD");
|
||||
|
||||
row.push({"selected": isSelected, "today": isToday, "disabled": isDisabled, "day":day, "inmonth":isInMonth});
|
||||
|
||||
if (++r === 7) {
|
||||
data.days.push(row);
|
||||
row = [];
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
});
|
||||
|
||||
UI["datepicker"] = DatePicker;
|
||||
|
||||
// init code
|
||||
$(document).on("focus.datepicker.uikit", "[data-uk-datepicker]", function(e) {
|
||||
|
||||
var ele = $(this);
|
||||
if (!ele.data("datepicker")) {
|
||||
e.preventDefault();
|
||||
var obj = new DatePicker(ele, UI.Utils.options(ele.attr("data-uk-datepicker")));
|
||||
ele.trigger("focus");
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click.datepicker.uikit", function(e) {
|
||||
|
||||
var target = $(e.target);
|
||||
|
||||
if (active && target[0] != dropdown[0] && !target.data("datepicker") && !target.parents(".uk-datepicker:first").length) {
|
||||
dropdown.hide();
|
||||
active = false;
|
||||
}
|
||||
});
|
||||
|
||||
$(function(){
|
||||
dropdown.appendTo("body");
|
||||
});
|
||||
|
||||
})(this, jQuery, jQuery.UIkit);
|
||||
|
||||
|
||||
if(!window.moment) {
|
||||
|
||||
//! moment.js
|
||||
//! version : 2.5.1
|
||||
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
||||
//! license : MIT
|
||||
//! momentjs.com
|
||||
(function(a){function b(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function c(a,b){return function(c){return k(a.call(this,c),b)}}function d(a,b){return function(c){return this.lang().ordinal(a.call(this,c),b)}}function e(){}function f(a){w(a),h(this,a)}function g(a){var b=q(a),c=b.year||0,d=b.month||0,e=b.week||0,f=b.day||0,g=b.hour||0,h=b.minute||0,i=b.second||0,j=b.millisecond||0;this._milliseconds=+j+1e3*i+6e4*h+36e5*g,this._days=+f+7*e,this._months=+d+12*c,this._data={},this._bubble()}function h(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return b.hasOwnProperty("toString")&&(a.toString=b.toString),b.hasOwnProperty("valueOf")&&(a.valueOf=b.valueOf),a}function i(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&qb.hasOwnProperty(b)&&(c[b]=a[b]);return c}function j(a){return 0>a?Math.ceil(a):Math.floor(a)}function k(a,b,c){for(var d=""+Math.abs(a),e=a>=0;d.length<b;)d="0"+d;return(e?c?"+":"":"-")+d}function l(a,b,c,d){var e,f,g=b._milliseconds,h=b._days,i=b._months;g&&a._d.setTime(+a._d+g*c),(h||i)&&(e=a.minute(),f=a.hour()),h&&a.date(a.date()+h*c),i&&a.month(a.month()+i*c),g&&!d&&db.updateOffset(a),(h||i)&&(a.minute(e),a.hour(f))}function m(a){return"[object Array]"===Object.prototype.toString.call(a)}function n(a){return"[object Date]"===Object.prototype.toString.call(a)||a instanceof Date}function o(a,b,c){var d,e=Math.min(a.length,b.length),f=Math.abs(a.length-b.length),g=0;for(d=0;e>d;d++)(c&&a[d]!==b[d]||!c&&s(a[d])!==s(b[d]))&&g++;return g+f}function p(a){if(a){var b=a.toLowerCase().replace(/(.)s$/,"$1");a=Tb[a]||Ub[b]||b}return a}function q(a){var b,c,d={};for(c in a)a.hasOwnProperty(c)&&(b=p(c),b&&(d[b]=a[c]));return d}function r(b){var c,d;if(0===b.indexOf("week"))c=7,d="day";else{if(0!==b.indexOf("month"))return;c=12,d="month"}db[b]=function(e,f){var g,h,i=db.fn._lang[b],j=[];if("number"==typeof e&&(f=e,e=a),h=function(a){var b=db().utc().set(d,a);return i.call(db.fn._lang,b,e||"")},null!=f)return h(f);for(g=0;c>g;g++)j.push(h(g));return j}}function s(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function t(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function u(a){return v(a)?366:365}function v(a){return a%4===0&&a%100!==0||a%400===0}function w(a){var b;a._a&&-2===a._pf.overflow&&(b=a._a[jb]<0||a._a[jb]>11?jb:a._a[kb]<1||a._a[kb]>t(a._a[ib],a._a[jb])?kb:a._a[lb]<0||a._a[lb]>23?lb:a._a[mb]<0||a._a[mb]>59?mb:a._a[nb]<0||a._a[nb]>59?nb:a._a[ob]<0||a._a[ob]>999?ob:-1,a._pf._overflowDayOfYear&&(ib>b||b>kb)&&(b=kb),a._pf.overflow=b)}function x(a){return null==a._isValid&&(a._isValid=!isNaN(a._d.getTime())&&a._pf.overflow<0&&!a._pf.empty&&!a._pf.invalidMonth&&!a._pf.nullInput&&!a._pf.invalidFormat&&!a._pf.userInvalidated,a._strict&&(a._isValid=a._isValid&&0===a._pf.charsLeftOver&&0===a._pf.unusedTokens.length)),a._isValid}function y(a){return a?a.toLowerCase().replace("_","-"):a}function z(a,b){return b._isUTC?db(a).zone(b._offset||0):db(a).local()}function A(a,b){return b.abbr=a,pb[a]||(pb[a]=new e),pb[a].set(b),pb[a]}function B(a){delete pb[a]}function C(a){var b,c,d,e,f=0,g=function(a){if(!pb[a]&&rb)try{require("./lang/"+a)}catch(b){}return pb[a]};if(!a)return db.fn._lang;if(!m(a)){if(c=g(a))return c;a=[a]}for(;f<a.length;){for(e=y(a[f]).split("-"),b=e.length,d=y(a[f+1]),d=d?d.split("-"):null;b>0;){if(c=g(e.slice(0,b).join("-")))return c;if(d&&d.length>=b&&o(e,d,!0)>=b-1)break;b--}f++}return db.fn._lang}function D(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function E(a){var b,c,d=a.match(vb);for(b=0,c=d.length;c>b;b++)d[b]=Yb[d[b]]?Yb[d[b]]:D(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function F(a,b){return a.isValid()?(b=G(b,a.lang()),Vb[b]||(Vb[b]=E(b)),Vb[b](a)):a.lang().invalidDate()}function G(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(wb.lastIndex=0;d>=0&&wb.test(a);)a=a.replace(wb,c),wb.lastIndex=0,d-=1;return a}function H(a,b){var c,d=b._strict;switch(a){case"DDDD":return Ib;case"YYYY":case"GGGG":case"gggg":return d?Jb:zb;case"Y":case"G":case"g":return Lb;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return d?Kb:Ab;case"S":if(d)return Gb;case"SS":if(d)return Hb;case"SSS":if(d)return Ib;case"DDD":return yb;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Cb;case"a":case"A":return C(b._l)._meridiemParse;case"X":return Fb;case"Z":case"ZZ":return Db;case"T":return Eb;case"SSSS":return Bb;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return d?Hb:xb;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return xb;default:return c=new RegExp(P(O(a.replace("\\","")),"i"))}}function I(a){a=a||"";var b=a.match(Db)||[],c=b[b.length-1]||[],d=(c+"").match(Qb)||["-",0,0],e=+(60*d[1])+s(d[2]);return"+"===d[0]?-e:e}function J(a,b,c){var d,e=Line truncated
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
(function(t,e,n){var i=!1,s=e('<div class="uk-dropdown uk-datepicker"></div>');s.on("click",".uk-datepicker-next, .uk-datepicker-previous, [data-date]",function(t){t.stopPropagation(),t.preventDefault();var n=e(this);n.is("[data-date]")?(i.element.val(moment(n.data("date")).format(i.options.format)).trigger("change"),s.hide(),i=!1):i.add("months",1*(n.hasClass("uk-datepicker-next")?1:-1))});var o=function(t,n){var s=this,a=e(t);a.data("datepicker")||(this.element=a,this.options=e.extend({},o.defaults,n),this.current=this.element.val()?moment(this.element.val(),this.options.format):moment(),this.element.on("click",function(){i!==s&&s.pick(this.value)}).on("change",function(){s.element.val()&&!moment(s.element.val(),s.options.format).isValid()&&s.element.val(moment().format(s.options.format))}),this.element.data("datepicker",this))};o.defaults={weekstart:1,i18n:{months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},format:"DD.MM.YYYY",offsettop:5,template:function(t,e){var n="";n+='<div class="uk-datepicker-nav">',n+='<a href="" class="uk-datepicker-previous"></a>',n+='<a href="" class="uk-datepicker-next"></a>',n+='<div class="uk-datepicker-heading">'+e.i18n.months[t.month]+" "+t.year+"</div>",n+="</div>",n+='<table class="uk-datepicker-table">',n+="<thead>";for(var i=0;t.weekdays.length>i;i++)t.weekdays[i]&&(n+="<th>"+t.weekdays[i]+"</th>");n+="</thead>",n+="<tbody>";for(var i=0;t.days.length>i;i++)if(t.days[i]&&t.days[i].length){n+="<tr>";for(var s=0;t.days[i].length>s;s++)if(t.days[i][s]){var o=t.days[i][s],a=[];o.inmonth||a.push("uk-datepicker-table-muted"),o.selected&&a.push("uk-active"),n+='<td><a href="" class="'+a.join(" ")+'" data-date="'+o.day.format()+'">'+o.day.format("D")+"</a></td>"}n+="</tr>"}return n+="</tbody>",n+="</table>"}},e.extend(o.prototype,{pick:function(t){var n=this.element.offset(),o={top:n.top+this.element.outerHeight()+this.options.offsettop,left:n.left,right:""};this.current=t?moment(t,this.options.format):moment(),this.initdate=this.current.format("YYYY-MM-DD"),this.update(),"right"==e.UIkit.langdirection&&(o.right=window.innerWidth-(o.left+this.element.outerWidth()),o.left=""),s.css(o).show(),i=this},add:function(t,e){this.current.add(t,e),this.update()},setMonth:function(t){this.current.month(t),this.update()},setYear:function(t){this.current.year(t),this.update()},update:function(){var t=this.getRows(this.current.year(),this.current.month()),e=this.options.template(t,this.options);s.html(e)},getRows:function(t,e){var n=this.options,i=moment().format("YYYY-MM-DD"),s=[31,0===t%4&&0!==t%100||0===t%400?29:28,31,30,31,30,31,31,30,31,30,31][e],o=new Date(t,e,1).getDay(),a={month:e,year:t,weekdays:[],days:[]},r=[];a.weekdays=function(){for(var t=0,e=[];7>t;t++){for(var i=t+(n.weekstart||0);i>=7;)i-=7;e.push(n.i18n.weekdays[i])}return e}(),n.weekstart&&n.weekstart>0&&(o-=n.weekstart,0>o&&(o+=7));for(var u=s+o,l=u;l>7;)l-=7;u+=7-l;for(var d,h,c,f,p,m=0,g=0;u>m;m++)d=new Date(t,e,1+(m-o)),h=n.mindate&&n.mindate>d||n.maxdate&&d>n.maxdate,p=!(o>m||m>=s+o),d=moment(d),c=this.initdate==d.format("YYYY-MM-DD"),f=i==d.format("YYYY-MM-DD"),r.push({selected:c,today:f,disabled:h,day:d,inmonth:p}),7===++g&&(a.days.push(r),r=[],g=0);return a}}),n.datepicker=o,e(document).on("focus.datepicker.uikit","[data-uk-datepicker]",function(t){var i=e(this);i.data("datepicker")||(t.preventDefault(),new o(i,n.Utils.options(i.attr("data-uk-datepicker"))),i.trigger("focus"))}),e(document).on("click.datepicker.uikit",function(t){var n=e(t.target);!i||n[0]==s[0]||n.data("datepicker")||n.parents(".uk-datepicker:first").length||(s.hide(),i=!1)}),e(function(){s.appendTo("body")})})(this,jQuery,jQuery.UIkit),window.moment||function(t){function e(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function n(t,e){return function(n){return d(t.call(this,n),e)}}function i(t,e){return function(n){return this.lang().ordinal(t.call(this,n),e)}}function s(){}function o(t){b(t),r(this,t)}function a(t){var e=g(t),n=e.year||0,i=e.month||0,s=e.week||0,o=e.day||0,a=e.hour||0,r=e.minute||0,u=e.second||0,l=e.millisecond||0;this._milliseconds=+l+1e3*u+6e4*r+36e5*a,this._days=+o+7*s,this._months=+i+12*n,this._data={},this._bubble()}function r(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return e.hasOwnProperty("toString")&&(t.toString=e.toString),e.hasOwnProperty("valueOf")&&(t.valueOf=e.valueOf),t}function u(t){var e,n={};for(e in t)t.hasOwnProperty(e)&&ge.hasOwnProperty(e)&&(n[e]=t[e]);return n}function l(t){return 0>t?Math.ceil(t):Math.floor(t)}function d(t,e,n){for(var i=""+Math.abs(t),s=t>=0;e>i.length;)i="0"+i;return(s?n?"+":"":"-")+i}function h(t,e,n,i){var s,o,a=e._milliseconds,r=e._days,u=e._months;a&&t._d.setTime(+t._d+a*n),(r||u)&&(s=t.minute(),o=t.hour()),r&&t.date(t.date()+r*n),u&&t.month(t.monLine truncated
|
||||
@@ -0,0 +1,42 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
(function($, UI){
|
||||
|
||||
var FormFile = function(element, options) {
|
||||
|
||||
var $this = this, $element = $(element);
|
||||
|
||||
if($element.data("formfile")) return;
|
||||
|
||||
this.options = $.extend({}, FormFile.defaults, options);
|
||||
|
||||
this.element = $element;
|
||||
|
||||
this.input = this.element.find("input[type='text']:first");
|
||||
this.file = this.element.find("input[type='file']:first");
|
||||
|
||||
this.file.on("change", function(){
|
||||
$this.input.val(this.value.replace(/^.*[\/\\]/g, ''));
|
||||
});
|
||||
|
||||
this.element.data("formfile", this);
|
||||
};
|
||||
|
||||
FormFile.defaults = {};
|
||||
|
||||
UI["formfile"] = FormFile;
|
||||
|
||||
// init code
|
||||
$(document).on("click.formfile.uikit", "[data-uk-form-file]", function(e) {
|
||||
|
||||
var ele = $(this);
|
||||
if (!ele.data("formfile")) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
var obj = new FormFile(ele, UI.Utils.options(ele.attr("data-uk-form-file")));
|
||||
ele.trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery, jQuery.UIkit);
|
||||
@@ -0,0 +1,3 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
(function(t,e){var n=function(e,i){var s=this,o=t(e);o.data("formfile")||(this.options=t.extend({},n.defaults,i),this.element=o,this.input=this.element.find("input[type='text']:first"),this.file=this.element.find("input[type='file']:first"),this.file.on("change",function(){s.input.val(this.value.replace(/^.*[\/\\]/g,""))}),this.element.data("formfile",this))};n.defaults={},e.formfile=n,t(document).on("click.formfile.uikit","[data-uk-form-file]",function(i){var s=t(this);s.data("formfile")||(i.preventDefault(),new n(s,e.Utils.options(s.attr("data-uk-form-file"))),s.trigger("click"))})})(jQuery,jQuery.UIkit);
|
||||
@@ -0,0 +1,50 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
(function($, UI){
|
||||
|
||||
var FormPassword = function(element, options) {
|
||||
|
||||
var $this = this, $element = $(element);
|
||||
|
||||
if($element.data("formPassword")) return;
|
||||
|
||||
this.options = $.extend({}, FormPassword.defaults, options);
|
||||
|
||||
this.element = $element.on("click", function(e) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if($this.input.length) {
|
||||
var type = $this.input.attr("type");
|
||||
$this.input.attr("type", type=="text" ? "password":"text");
|
||||
$this.element.text($this.options[type=="text" ? "lblShow":"lblHide"]);
|
||||
}
|
||||
});
|
||||
|
||||
$this.input = this.element.next("input").length ? this.element.next("input") : this.element.prev("input");
|
||||
$this.element.text(this.options[$this.input.is("[type='password']") ? "lblShow":"lblHide"]);
|
||||
|
||||
this.element.data("formPassword", this);
|
||||
};
|
||||
|
||||
FormPassword.defaults = {
|
||||
"lblShow": "Show",
|
||||
"lblHide": "Hide"
|
||||
};
|
||||
|
||||
UI["formPassword"] = FormPassword;
|
||||
|
||||
// init code
|
||||
$(document).on("click.formpassword.uikit", "[data-uk-form-password]", function(e) {
|
||||
|
||||
var ele = $(this);
|
||||
if (!ele.data("formPassword")) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
var obj = new FormPassword(ele, UI.Utils.options(ele.attr("data-uk-form-password")));
|
||||
ele.trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery, jQuery.UIkit);
|
||||
@@ -0,0 +1,3 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
(function(t,e){var n=function(e,i){var s=this,o=t(e);o.data("formPassword")||(this.options=t.extend({},n.defaults,i),this.element=o.on("click",function(t){if(t.preventDefault(),s.input.length){var e=s.input.attr("type");s.input.attr("type","text"==e?"password":"text"),s.element.text(s.options["text"==e?"lblShow":"lblHide"])}}),s.input=this.element.next("input").length?this.element.next("input"):this.element.prev("input"),s.element.text(this.options[s.input.is("[type='password']")?"lblShow":"lblHide"]),this.element.data("formPassword",this))};n.defaults={lblShow:"Show",lblHide:"Hide"},e.formPassword=n,t(document).on("click.formpassword.uikit","[data-uk-form-password]",function(i){var s=t(this);s.data("formPassword")||(i.preventDefault(),new n(s,e.Utils.options(s.attr("data-uk-form-password"))),s.trigger("click"))})})(jQuery,jQuery.UIkit);
|
||||
@@ -0,0 +1,336 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
(function(global, $, UI){
|
||||
|
||||
var Markdownarea = function(element, options){
|
||||
|
||||
var $element = $(element);
|
||||
|
||||
if($element.data("markdownarea")) return;
|
||||
|
||||
this.element = $element;
|
||||
this.options = $.extend({}, Markdownarea.defaults, options);
|
||||
|
||||
this.init();
|
||||
|
||||
this.element.data("markdownarea", this);
|
||||
};
|
||||
|
||||
$.extend(Markdownarea.prototype, {
|
||||
|
||||
init: function(){
|
||||
|
||||
var $this = this, tpl = Markdownarea.template;
|
||||
|
||||
tpl = tpl.replace(/\{\:lblPreview\}/g, this.options.lblPreview);
|
||||
tpl = tpl.replace(/\{\:lblCodeview\}/g, this.options.lblCodeview);
|
||||
|
||||
this.markdownarea = $(tpl);
|
||||
this.content = this.markdownarea.find(".uk-markdownarea-content");
|
||||
this.toolbar = this.markdownarea.find(".uk-markdownarea-toolbar");
|
||||
this.preview = this.markdownarea.find(".uk-markdownarea-preview").children().eq(0);
|
||||
this.code = this.markdownarea.find(".uk-markdownarea-code");
|
||||
|
||||
this.element.before(this.markdownarea).appendTo(this.code);
|
||||
|
||||
this.editor = CodeMirror.fromTextArea(this.element[0], this.options.codemirror);
|
||||
|
||||
this.editor.markdownarea = this;
|
||||
|
||||
this.editor.on("change", (function(){
|
||||
var render = function(){
|
||||
|
||||
var value = $this.editor.getValue();
|
||||
|
||||
$this.originalvalue = String(value);
|
||||
$this.currentvalue = String(value);
|
||||
|
||||
$this.element.trigger("markdownarea-before", [$this]);
|
||||
|
||||
marked($this.currentvalue, function (err, markdown) {
|
||||
|
||||
if (err) throw err;
|
||||
|
||||
$this.preview.html(markdown);
|
||||
$this.element.val($this.currentvalue).trigger("markdownarea-update", [$this]);
|
||||
});
|
||||
};
|
||||
render();
|
||||
return UI.Utils.debounce(render, 200);
|
||||
})());
|
||||
|
||||
this._buildtoolbar();
|
||||
this.fit();
|
||||
|
||||
$(window).on("resize", UI.Utils.debounce(function(){
|
||||
$this.fit();
|
||||
}, 200));
|
||||
|
||||
|
||||
var previewContainer = $this.preview.parent(),
|
||||
codeContent = this.code.find('.CodeMirror-sizer'),
|
||||
codeScroll = this.code.find('.CodeMirror-scroll').on('scroll',UI.Utils.debounce(function() {
|
||||
|
||||
if($this.markdownarea.attr("data-mode")=="tab") return;
|
||||
|
||||
// calc position
|
||||
var codeHeight = codeContent.height() - codeScroll.height(),
|
||||
previewHeight = previewContainer[0].scrollHeight - previewContainer.height(),
|
||||
ratio = previewHeight / codeHeight,
|
||||
previewPostition = codeScroll.scrollTop() * ratio;
|
||||
|
||||
// apply new scroll
|
||||
previewContainer.scrollTop(previewPostition);
|
||||
}, 10));
|
||||
|
||||
this.markdownarea.on("click", ".uk-markdown-button-markdown, .uk-markdown-button-preview", function(e){
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if($this.markdownarea.attr("data-mode")=="tab") {
|
||||
|
||||
$this.markdownarea.find(".uk-markdown-button-markdown, .uk-markdown-button-preview").removeClass("uk-active").filter(this).addClass("uk-active");
|
||||
|
||||
$this.activetab = $(this).hasClass("uk-markdown-button-markdown") ? "code":"preview";
|
||||
$this.markdownarea.attr("data-active-tab", $this.activetab);
|
||||
}
|
||||
});
|
||||
|
||||
this.preview.parent().css("height", this.code.height());
|
||||
},
|
||||
|
||||
_buildtoolbar: function(){
|
||||
|
||||
if(!(this.options.toolbar && this.options.toolbar.length)) return;
|
||||
|
||||
var $this = this, bar = [];
|
||||
|
||||
this.options.toolbar.forEach(function(cmd){
|
||||
if(Markdownarea.commands[cmd]) {
|
||||
|
||||
var title = Markdownarea.commands[cmd].title ? Markdownarea.commands[cmd].title : cmd;
|
||||
|
||||
bar.push('<li><a data-markdownarea-cmd="'+cmd+'" title="'+title+'" data-uk-tooltip>'+Markdownarea.commands[cmd].label+'</a></li>');
|
||||
|
||||
if(Markdownarea.commands[cmd].shortcut) {
|
||||
$this.registerShortcut(Markdownarea.commands[cmd].shortcut, Markdownarea.commands[cmd].action);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.toolbar.html(bar.join("\n"));
|
||||
|
||||
this.markdownarea.on("click", "a[data-markdownarea-cmd]", function(){
|
||||
var cmd = $(this).data("markdownareaCmd");
|
||||
|
||||
if(cmd && Markdownarea.commands[cmd] && (!$this.activetab || $this.activetab=="code")) {
|
||||
Markdownarea.commands[cmd].action.apply($this, [$this.editor])
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
fit: function() {
|
||||
|
||||
var mode = this.options.mode;
|
||||
|
||||
if(mode=="split" && this.markdownarea.width() < this.options.maxsplitsize) {
|
||||
mode = "tab";
|
||||
}
|
||||
|
||||
if(mode=="tab") {
|
||||
|
||||
if(!this.activetab) {
|
||||
this.activetab = "code";
|
||||
this.markdownarea.attr("data-active-tab", this.activetab);
|
||||
}
|
||||
|
||||
this.markdownarea.find(".uk-markdown-button-markdown, .uk-markdown-button-preview").removeClass("uk-active")
|
||||
.filter(this.activetab=="code" ? '.uk-markdown-button-markdown':'.uk-markdown-button-preview').addClass("uk-active");
|
||||
|
||||
}
|
||||
|
||||
this.markdownarea.attr("data-mode", mode);
|
||||
},
|
||||
|
||||
registerShortcut: function(combination, callback){
|
||||
|
||||
var $this = this;
|
||||
|
||||
combination = $.isArray(combination) ? combination : [combination];
|
||||
|
||||
for(var i=0,max=combination.length;i < max;i++) {
|
||||
var map = {};
|
||||
|
||||
map[combination[i]] = function(){
|
||||
callback.apply($this, [$this.editor]);
|
||||
};
|
||||
|
||||
$this.editor.addKeyMap(map);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//jQuery plugin
|
||||
|
||||
$.fn.markdownarea = function(options){
|
||||
|
||||
return this.each(function(){
|
||||
|
||||
var ele = $(this);
|
||||
|
||||
if(!ele.data("markdownarea")) {
|
||||
var obj = new Markdownarea(ele, options);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var baseReplacer = function(replace, editor){
|
||||
var text = editor.getSelection(),
|
||||
markdown = replace.replace('$1', text);
|
||||
|
||||
editor.replaceSelection(markdown, 'end');
|
||||
};
|
||||
|
||||
Markdownarea.commands = {
|
||||
"fullscreen": {
|
||||
"title" : 'Fullscreen',
|
||||
"label" : '<i class="uk-icon-expand"></i>',
|
||||
"action" : function(editor){
|
||||
|
||||
editor.markdownarea.markdownarea.toggleClass("uk-markdownarea-fullscreen");
|
||||
|
||||
var wrap = editor.getWrapperElement();
|
||||
|
||||
if(editor.markdownarea.markdownarea.hasClass("uk-markdownarea-fullscreen")) {
|
||||
|
||||
editor.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset, width: wrap.style.width, height: wrap.style.height};
|
||||
wrap.style.width = "";
|
||||
wrap.style.height = editor.markdownarea.content.height()+"px";
|
||||
document.documentElement.style.overflow = "hidden";
|
||||
|
||||
} else {
|
||||
|
||||
document.documentElement.style.overflow = "";
|
||||
var info = editor.state.fullScreenRestore;
|
||||
wrap.style.width = info.width; wrap.style.height = info.height;
|
||||
window.scrollTo(info.scrollLeft, info.scrollTop);
|
||||
}
|
||||
|
||||
editor.refresh();
|
||||
editor.markdownarea.preview.parent().css("height", editor.markdownarea.code.height());
|
||||
}
|
||||
},
|
||||
|
||||
"bold" : {
|
||||
"title" : "Bold",
|
||||
"label" : '<i class="uk-icon-bold"></i>',
|
||||
"shortcut": ['Ctrl-B', 'Cmd-B'],
|
||||
"action" : function(editor){
|
||||
|
||||
baseReplacer("**$1**", editor);
|
||||
}
|
||||
},
|
||||
"italic" : {
|
||||
"title" : "Italic",
|
||||
"label" : '<i class="uk-icon-italic"></i>',
|
||||
"action" : function(editor){
|
||||
baseReplacer("*$1*", editor);
|
||||
}
|
||||
},
|
||||
"strike" : {
|
||||
"title" : "Strikethrough",
|
||||
"label" : '<i class="uk-icon-strikethrough"></i>',
|
||||
"action" : function(editor){
|
||||
baseReplacer("~~$1~~", editor);
|
||||
}
|
||||
},
|
||||
"blockquote" : {
|
||||
"title" : "Blockquote",
|
||||
"label" : '<i class="uk-icon-quote-right"></i>',
|
||||
"action" : function(editor){
|
||||
baseReplacer("> $1", editor);
|
||||
}
|
||||
},
|
||||
"link" : {
|
||||
"title" : "Link",
|
||||
"label" : '<i class="uk-icon-link"></i>',
|
||||
"action" : function(editor){
|
||||
baseReplacer("[$1](http://)", editor);
|
||||
}
|
||||
},
|
||||
"picture" : {
|
||||
"title" : "Picture",
|
||||
"label" : '<i class="uk-icon-picture-o"></i>',
|
||||
"action" : function(editor){
|
||||
baseReplacer("", editor);
|
||||
}
|
||||
},
|
||||
"listUl" : {
|
||||
"title" : "Unordered List",
|
||||
"label" : '<i class="uk-icon-list-ul"></i>',
|
||||
"action" : function(editor){
|
||||
baseReplacer("* $1", editor);
|
||||
}
|
||||
},
|
||||
"listOl" : {
|
||||
"title" : "Ordered List",
|
||||
"label" : '<i class="uk-icon-list-ol"></i>',
|
||||
"action" : function(editor){
|
||||
baseReplacer("1. $1", editor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Markdownarea.defaults = {
|
||||
"mode" : "split",
|
||||
"maxsplitsize" : 1000,
|
||||
"codemirror" : { mode: 'gfm', tabMode: 'indent', tabindex: "2", lineWrapping: true, dragDrop: false },
|
||||
"toolbar" : [ "bold", "italic", "strike", "link", "picture", "blockquote", "listUl", "listOl" ],
|
||||
"lblPreview" : "Preview",
|
||||
"lblCodeview" : "Markdown"
|
||||
};
|
||||
|
||||
Markdownarea.template = '<div class="uk-markdownarea uk-clearfix" data-mode="split">' +
|
||||
'<div class="uk-markdownarea-navbar">' +
|
||||
'<ul class="uk-markdownarea-navbar-nav uk-markdownarea-toolbar"></ul>' +
|
||||
'<div class="uk-markdownarea-navbar-flip">' +
|
||||
'<ul class="uk-markdownarea-navbar-nav">' +
|
||||
'<li class="uk-markdown-button-markdown"><a>{:lblCodeview}</a></li>' +
|
||||
'<li class="uk-markdown-button-preview"><a>{:lblPreview}</a></li>' +
|
||||
'<li><a data-markdownarea-cmd="fullscreen"><i class="uk-icon-expand"></i></a></li>' +
|
||||
'</ul>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'<div class="uk-markdownarea-content">' +
|
||||
'<div class="uk-markdownarea-code"></div>' +
|
||||
'<div class="uk-markdownarea-preview"><div></div></div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
UI["markdownarea"] = Markdownarea;
|
||||
|
||||
// init code
|
||||
$(function() {
|
||||
|
||||
marked.setOptions({
|
||||
gfm: true,
|
||||
tables: true,
|
||||
breaks: true,
|
||||
pedantic: false,
|
||||
sanitize: false,
|
||||
smartLists: true,
|
||||
smartypants: false,
|
||||
langPrefix: 'lang-'
|
||||
});
|
||||
|
||||
$("textarea[data-uk-markdownarea]").each(function() {
|
||||
var area = $(this), obj;
|
||||
|
||||
if (!area.data("markdownarea")) {
|
||||
obj = new Markdownarea(area, UI.Utils.options(area.attr("data-uk-markdownarea")));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
})(window, jQuery, jQuery.UIkit);
|
||||
@@ -0,0 +1,3 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
(function(t,e,n){var i=function(t,n){var s=e(t);s.data("markdownarea")||(this.element=s,this.options=e.extend({},i.defaults,n),this.init(),this.element.data("markdownarea",this))};e.extend(i.prototype,{init:function(){var t=this,s=i.template;s=s.replace(/\{\:lblPreview\}/g,this.options.lblPreview),s=s.replace(/\{\:lblCodeview\}/g,this.options.lblCodeview),this.markdownarea=e(s),this.content=this.markdownarea.find(".uk-markdownarea-content"),this.toolbar=this.markdownarea.find(".uk-markdownarea-toolbar"),this.preview=this.markdownarea.find(".uk-markdownarea-preview").children().eq(0),this.code=this.markdownarea.find(".uk-markdownarea-code"),this.element.before(this.markdownarea).appendTo(this.code),this.editor=CodeMirror.fromTextArea(this.element[0],this.options.codemirror),this.editor.markdownarea=this,this.editor.on("change",function(){var e=function(){var e=t.editor.getValue();t.originalvalue=e+"",t.currentvalue=e+"",t.element.trigger("markdownarea-before",[t]),marked(t.currentvalue,function(e,n){if(e)throw e;t.preview.html(n),t.element.val(t.currentvalue).trigger("markdownarea-update",[t])})};return e(),n.Utils.debounce(e,200)}()),this._buildtoolbar(),this.fit(),e(window).on("resize",n.Utils.debounce(function(){t.fit()},200));var a=t.preview.parent(),o=this.code.find(".CodeMirror-sizer"),r=this.code.find(".CodeMirror-scroll").on("scroll",n.Utils.debounce(function(){if("tab"!=t.markdownarea.attr("data-mode")){var e=o.height()-r.height(),n=a[0].scrollHeight-a.height(),i=n/e,s=r.scrollTop()*i;a.scrollTop(s)}},10));this.markdownarea.on("click",".uk-markdown-button-markdown, .uk-markdown-button-preview",function(n){n.preventDefault(),"tab"==t.markdownarea.attr("data-mode")&&(t.markdownarea.find(".uk-markdown-button-markdown, .uk-markdown-button-preview").removeClass("uk-active").filter(this).addClass("uk-active"),t.activetab=e(this).hasClass("uk-markdown-button-markdown")?"code":"preview",t.markdownarea.attr("data-active-tab",t.activetab))}),this.preview.parent().css("height",this.code.height())},_buildtoolbar:function(){if(this.options.toolbar&&this.options.toolbar.length){var t=this,n=[];this.options.toolbar.forEach(function(e){if(i.commands[e]){var s=i.commands[e].title?i.commands[e].title:e;n.push('<li><a data-markdownarea-cmd="'+e+'" title="'+s+'" data-uk-tooltip>'+i.commands[e].label+"</a></li>"),i.commands[e].shortcut&&t.registerShortcut(i.commands[e].shortcut,i.commands[e].action)}}),this.toolbar.html(n.join("\n")),this.markdownarea.on("click","a[data-markdownarea-cmd]",function(){var n=e(this).data("markdownareaCmd");!n||!i.commands[n]||t.activetab&&"code"!=t.activetab||i.commands[n].action.apply(t,[t.editor])})}},fit:function(){var t=this.options.mode;"split"==t&&this.markdownarea.width()<this.options.maxsplitsize&&(t="tab"),"tab"==t&&(this.activetab||(this.activetab="code",this.markdownarea.attr("data-active-tab",this.activetab)),this.markdownarea.find(".uk-markdown-button-markdown, .uk-markdown-button-preview").removeClass("uk-active").filter("code"==this.activetab?".uk-markdown-button-markdown":".uk-markdown-button-preview").addClass("uk-active")),this.markdownarea.attr("data-mode",t)},registerShortcut:function(t,n){var i=this;t=e.isArray(t)?t:[t];for(var s=0,a=t.length;a>s;s++){var o={};o[t[s]]=function(){n.apply(i,[i.editor])},i.editor.addKeyMap(o)}}}),e.fn.markdownarea=function(t){return this.each(function(){var n=e(this);n.data("markdownarea")||new i(n,t)})};var s=function(t,e){var n=e.getSelection(),i=t.replace("$1",n);e.replaceSelection(i,"end")};i.commands={fullscreen:{title:"Fullscreen",label:'<i class="uk-icon-expand"></i>',action:function(t){t.markdownarea.markdownarea.toggleClass("uk-markdownarea-fullscreen");var e=t.getWrapperElement();if(t.markdownarea.markdownarea.hasClass("uk-markdownarea-fullscreen"))t.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:e.style.width,height:e.style.height},e.style.width="",e.style.height=t.markdownarea.content.height()+"px",document.documentElement.style.overflow="hidden";else{document.documentElement.style.overflow="";var n=t.state.fullScreenRestore;e.style.width=n.width,e.style.height=n.height,window.scrollTo(n.scrollLeft,n.scrollTop)}t.refresh(),t.markdownarea.preview.parent().css("height",t.markdownarea.code.height())}},bold:{title:"Bold",label:'<i class="uk-icon-bold"></i>',shortcut:["Ctrl-B","Cmd-B"],action:function(t){s("**$1**",t)}},italic:{title:"Italic",label:'<i class="uk-icon-italic"></i>',action:function(t){s("*$1*",t)}},strike:{title:"Strikethrough",label:'<i class="uk-icon-strikethrough"></i>',action:function(t){s("~~$1~~",t)}},blockquote:{title:"Blockquote",label:'<i class="uk-icon-quote-right"></i>',action:function(t){s("> $1",t)}},link:{title:"Link",label:'<i class="uk-icon-link"></i>',action:function(t){s("[$1](http://)",t)}},picture:{title:"Picture",label:'<i class="uk-icon-picture-o"></i>',action:function(t){s("",t)}},listUl:{title:"Unordered List",label:'<i class="uk-icon-lLine truncated
|
||||
@@ -0,0 +1,165 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
(function($, UI){
|
||||
|
||||
var containers = {},
|
||||
messages = {},
|
||||
|
||||
notify = function(options){
|
||||
|
||||
if ($.type(options) == 'string') {
|
||||
options = { message: options };
|
||||
}
|
||||
|
||||
if (arguments[1]) {
|
||||
options = $.extend(options, $.type(arguments[1]) == 'string' ? {status:arguments[1]} : arguments[1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return (new Message(options)).show();
|
||||
},
|
||||
closeAll = function(group, instantly){
|
||||
if(group) {
|
||||
for(var id in messages) { if(group===messages[id].group) messages[id].close(instantly); }
|
||||
} else {
|
||||
for(var id in messages) { messages[id].close(instantly); }
|
||||
}
|
||||
};
|
||||
|
||||
var Message = function(options){
|
||||
|
||||
var $this = this;
|
||||
|
||||
this.options = $.extend({}, Message.defaults, options);
|
||||
|
||||
this.uuid = "ID"+(new Date().getTime())+"RAND"+(Math.ceil(Math.random() * 100000));
|
||||
this.element = $([
|
||||
|
||||
'<div class="uk-notify-message">',
|
||||
'<a class="uk-close"></a>',
|
||||
'<div>'+this.options.message+'</div>',
|
||||
'</div>'
|
||||
|
||||
].join('')).data("notifyMessage", this);
|
||||
|
||||
// status
|
||||
if (this.options.status) {
|
||||
this.element.addClass('uk-notify-message-'+this.options.status);
|
||||
this.currentstatus = this.options.status;
|
||||
}
|
||||
|
||||
this.group = this.options.group;
|
||||
|
||||
messages[this.uuid] = this;
|
||||
|
||||
if(!containers[this.options.pos]) {
|
||||
containers[this.options.pos] = $('<div class="uk-notify uk-notify-'+this.options.pos+'"></div>').appendTo('body').on("click", ".uk-notify-message", function(){
|
||||
$(this).data("notifyMessage").close();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$.extend(Message.prototype, {
|
||||
|
||||
uuid: false,
|
||||
element: false,
|
||||
timout: false,
|
||||
currentstatus: "",
|
||||
group: false,
|
||||
|
||||
show: function() {
|
||||
|
||||
if (this.element.is(":visible")) return;
|
||||
|
||||
var $this = this;
|
||||
|
||||
containers[this.options.pos].show().prepend(this.element);
|
||||
|
||||
var marginbottom = parseInt(this.element.css("margin-bottom"), 10);
|
||||
|
||||
this.element.css({"opacity":0, "margin-top": -1*this.element.outerHeight(), "margin-bottom":0}).animate({"opacity":1, "margin-top": 0, "margin-bottom":marginbottom}, function(){
|
||||
|
||||
if ($this.options.timeout) {
|
||||
|
||||
var closefn = function(){ $this.close(); };
|
||||
|
||||
$this.timeout = setTimeout(closefn, $this.options.timeout);
|
||||
|
||||
$this.element.hover(
|
||||
function() { clearTimeout($this.timeout); },
|
||||
function() { $this.timeout = setTimeout(closefn, $this.options.timeout); }
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
close: function(instantly) {
|
||||
|
||||
var $this = this,
|
||||
finalize = function(){
|
||||
$this.element.remove();
|
||||
|
||||
if(!containers[$this.options.pos].children().length) {
|
||||
containers[$this.options.pos].hide();
|
||||
}
|
||||
|
||||
delete messages[$this.uuid];
|
||||
};
|
||||
|
||||
if(this.timeout) clearTimeout(this.timeout);
|
||||
|
||||
if(instantly) {
|
||||
finalize();
|
||||
} else {
|
||||
this.element.animate({"opacity":0, "margin-top": -1* this.element.outerHeight(), "margin-bottom":0}, function(){
|
||||
finalize();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
content: function(html){
|
||||
|
||||
var container = this.element.find(">div");
|
||||
|
||||
if(!html) {
|
||||
return container.html();
|
||||
}
|
||||
|
||||
container.html(html);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
status: function(status) {
|
||||
|
||||
if(!status) {
|
||||
return this.currentstatus;
|
||||
}
|
||||
|
||||
this.element.removeClass('uk-notify-message-'+this.currentstatus).addClass('uk-notify-message-'+status);
|
||||
|
||||
this.currentstatus = status;
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
Message.defaults = {
|
||||
message: "",
|
||||
status: "",
|
||||
timeout: 5000,
|
||||
group: null,
|
||||
pos: 'top-center'
|
||||
};
|
||||
|
||||
|
||||
UI["notify"] = notify;
|
||||
UI["notify"].message = Message;
|
||||
UI["notify"].closeAll = closeAll;
|
||||
|
||||
})(jQuery, jQuery.UIkit);
|
||||
@@ -0,0 +1,3 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
(function(t,e){var n={},i={},s=function(e){return"string"==t.type(e)&&(e={message:e}),arguments[1]&&(e=t.extend(e,"string"==t.type(arguments[1])?{status:arguments[1]}:arguments[1])),new a(e).show()},o=function(t,e){if(t)for(var n in i)t===i[n].group&&i[n].close(e);else for(var n in i)i[n].close(e)},a=function(e){this.options=t.extend({},a.defaults,e),this.uuid="ID"+(new Date).getTime()+"RAND"+Math.ceil(1e5*Math.random()),this.element=t(['<div class="uk-notify-message">','<a class="uk-close"></a>',"<div>"+this.options.message+"</div>","</div>"].join("")).data("notifyMessage",this),this.options.status&&(this.element.addClass("uk-notify-message-"+this.options.status),this.currentstatus=this.options.status),this.group=this.options.group,i[this.uuid]=this,n[this.options.pos]||(n[this.options.pos]=t('<div class="uk-notify uk-notify-'+this.options.pos+'"></div>').appendTo("body").on("click",".uk-notify-message",function(){t(this).data("notifyMessage").close()}))};t.extend(a.prototype,{uuid:!1,element:!1,timout:!1,currentstatus:"",group:!1,show:function(){if(!this.element.is(":visible")){var t=this;n[this.options.pos].show().prepend(this.element);var e=parseInt(this.element.css("margin-bottom"),10);return this.element.css({opacity:0,"margin-top":-1*this.element.outerHeight(),"margin-bottom":0}).animate({opacity:1,"margin-top":0,"margin-bottom":e},function(){if(t.options.timeout){var e=function(){t.close()};t.timeout=setTimeout(e,t.options.timeout),t.element.hover(function(){clearTimeout(t.timeout)},function(){t.timeout=setTimeout(e,t.options.timeout)})}}),this}},close:function(t){var e=this,s=function(){e.element.remove(),n[e.options.pos].children().length||n[e.options.pos].hide(),delete i[e.uuid]};this.timeout&&clearTimeout(this.timeout),t?s():this.element.animate({opacity:0,"margin-top":-1*this.element.outerHeight(),"margin-bottom":0},function(){s()})},content:function(t){var e=this.element.find(">div");return t?(e.html(t),this):e.html()},status:function(t){return t?(this.element.removeClass("uk-notify-message-"+this.currentstatus).addClass("uk-notify-message-"+t),this.currentstatus=t,this):this.currentstatus}}),a.defaults={message:"",status:"",timeout:5e3,group:null,pos:"top-center"},e.notify=s,e.notify.message=a,e.notify.closeAll=o})(jQuery,jQuery.UIkit);
|
||||
@@ -0,0 +1,592 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
/*
|
||||
* Based on Nestable jQuery Plugin - Copyright (c) 2012 David Bushell - http://dbushell.com/
|
||||
*/
|
||||
|
||||
(function($, UI, window, document, undefined) {
|
||||
var hasTouch = 'ontouchstart' in window,
|
||||
html = $("html"),
|
||||
touchedlists = [];
|
||||
|
||||
/**
|
||||
* Detect CSS pointer-events property
|
||||
* events are normally disabled on the dragging element to avoid conflicts
|
||||
* https://github.com/ausi/Feature-detection-technique-for-pointer-events/blob/master/modernizr-pointerevents.js
|
||||
*/
|
||||
var hasPointerEvents = (function()
|
||||
{
|
||||
var el = document.createElement('div'),
|
||||
docEl = document.documentElement;
|
||||
if (!('pointerEvents' in el.style)) {
|
||||
return false;
|
||||
}
|
||||
el.style.pointerEvents = 'auto';
|
||||
el.style.pointerEvents = 'x';
|
||||
docEl.appendChild(el);
|
||||
var supports = window.getComputedStyle && window.getComputedStyle(el, '').pointerEvents === 'auto';
|
||||
docEl.removeChild(el);
|
||||
return !!supports;
|
||||
})();
|
||||
|
||||
var eStart = hasTouch ? 'touchstart' : 'mousedown',
|
||||
eMove = hasTouch ? 'touchmove' : 'mousemove',
|
||||
eEnd = hasTouch ? 'touchend' : 'mouseup',
|
||||
eCancel = hasTouch ? 'touchcancel' : 'mouseup';
|
||||
|
||||
function Plugin(element, options)
|
||||
{
|
||||
var $element = $(element);
|
||||
|
||||
if($element.data("uksortable")) return;
|
||||
|
||||
|
||||
this.w = $(window);
|
||||
this.el = $element;
|
||||
this.options = $.extend({}, $.fn.uksortable.defaults, options);
|
||||
|
||||
this.tplempty = '<div class="' + this.options.emptyClass + '"/>';
|
||||
|
||||
this.el.find(">"+this.options.itemNodeName).addClass(this.options.listitemClass).end().find("ul:not(.ignore-list)").addClass(this.options.listClass).find(">li").addClass(this.options.listitemClass);
|
||||
|
||||
if(!this.el.children(this.options.itemNodeName).length) {
|
||||
this.el.append(this.tplempty);
|
||||
}
|
||||
|
||||
this.el.data("uksortable", this);
|
||||
this.el.data("uksortable-id", "ID"+(new Date().getTime())+"RAND"+(Math.ceil(Math.random() *100000)));
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
Plugin.prototype = {
|
||||
|
||||
init: function()
|
||||
{
|
||||
var list = this;
|
||||
|
||||
list.reset();
|
||||
|
||||
list.el.data('uksortable-group', this.options.group);
|
||||
|
||||
list.placeEl = $('<div class="' + list.options.placeClass + '"/>');
|
||||
|
||||
$.each(this.el.find(list.options.itemNodeName), function(k, el)
|
||||
{
|
||||
list.setParent($(el));
|
||||
});
|
||||
|
||||
list.el.on('click', '[data-sortable-action]', function(e)
|
||||
{
|
||||
if (list.dragEl || (!hasTouch && e.button !== 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
var target = $(e.currentTarget),
|
||||
action = target.data('sortableAction'),
|
||||
item = target.closest(list.options.itemNodeName);
|
||||
if (action === 'collapse') {
|
||||
list.collapseItem(item);
|
||||
}
|
||||
if (action === 'expand') {
|
||||
list.expandItem(item);
|
||||
}
|
||||
if (action === 'toggle') {
|
||||
list.toggleItem(item);
|
||||
}
|
||||
});
|
||||
|
||||
var onStartEvent = function(e)
|
||||
{
|
||||
var handle = $(e.target);
|
||||
if (!handle.hasClass(list.options.handleClass)) {
|
||||
if (handle.closest('.' + list.options.noDragClass).length) {
|
||||
return;
|
||||
}
|
||||
handle = handle.closest('.' + list.options.handleClass);
|
||||
}
|
||||
if (!handle.length || list.dragEl || (!hasTouch && e.button !== 0) || (hasTouch && e.touches.length !== 1)) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
list.dragStart(hasTouch ? e.touches[0] : e);
|
||||
};
|
||||
|
||||
var onMoveEvent = function(e)
|
||||
{
|
||||
if (list.dragEl) {
|
||||
e.preventDefault();
|
||||
list.dragMove(hasTouch ? e.touches[0] : e);
|
||||
}
|
||||
};
|
||||
|
||||
var onEndEvent = function(e)
|
||||
{
|
||||
if (list.dragEl) {
|
||||
e.preventDefault();
|
||||
list.dragStop(hasTouch ? e.touches[0] : e);
|
||||
}
|
||||
};
|
||||
|
||||
if (hasTouch) {
|
||||
list.el[0].addEventListener(eStart, onStartEvent, false);
|
||||
window.addEventListener(eMove, onMoveEvent, false);
|
||||
window.addEventListener(eEnd, onEndEvent, false);
|
||||
window.addEventListener(eCancel, onEndEvent, false);
|
||||
} else {
|
||||
list.el.on(eStart, onStartEvent);
|
||||
list.w.on(eMove, onMoveEvent);
|
||||
list.w.on(eEnd, onEndEvent);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
serialize: function()
|
||||
{
|
||||
var data,
|
||||
depth = 0,
|
||||
list = this;
|
||||
step = function(level, depth)
|
||||
{
|
||||
var array = [ ],
|
||||
items = level.children(list.options.itemNodeName);
|
||||
items.each(function()
|
||||
{
|
||||
var li = $(this),
|
||||
item = $.extend({}, li.data()),
|
||||
sub = li.children(list.options.listNodeName);
|
||||
if (sub.length) {
|
||||
item.children = step(sub, depth + 1);
|
||||
}
|
||||
array.push(item);
|
||||
});
|
||||
return array;
|
||||
};
|
||||
data = step(list.el, depth);
|
||||
return data;
|
||||
},
|
||||
|
||||
list: function(options)
|
||||
{
|
||||
var data = [],
|
||||
list = this,
|
||||
depth = 0,
|
||||
options = $.extend({}, list.options, options),
|
||||
step = function(level, depth, parent)
|
||||
{
|
||||
var items = level.children(options.itemNodeName);
|
||||
items.each(function(index)
|
||||
{
|
||||
var li = $(this),
|
||||
item = $.extend({parent_id: (parent ? parent : null), depth: depth, order: index}, li.data()),
|
||||
sub = li.children(options.listNodeName);
|
||||
|
||||
data.push(item);
|
||||
if (sub.length) {
|
||||
step(sub, depth + 1, li.data(options.idProperty || 'id'));
|
||||
}
|
||||
});
|
||||
};
|
||||
step(list.el, depth);
|
||||
return data;
|
||||
},
|
||||
|
||||
reset: function()
|
||||
{
|
||||
this.mouse = {
|
||||
offsetX : 0,
|
||||
offsetY : 0,
|
||||
startX : 0,
|
||||
startY : 0,
|
||||
lastX : 0,
|
||||
lastY : 0,
|
||||
nowX : 0,
|
||||
nowY : 0,
|
||||
distX : 0,
|
||||
distY : 0,
|
||||
dirAx : 0,
|
||||
dirX : 0,
|
||||
dirY : 0,
|
||||
lastDirX : 0,
|
||||
lastDirY : 0,
|
||||
distAxX : 0,
|
||||
distAxY : 0
|
||||
};
|
||||
this.moving = false;
|
||||
this.dragEl = null;
|
||||
this.dragRootEl = null;
|
||||
this.dragDepth = 0;
|
||||
this.hasNewRoot = false;
|
||||
this.pointEl = null;
|
||||
|
||||
for(var i=0; i<touchedlists.length; i++) {
|
||||
if(!touchedlists[i].children().length) {
|
||||
touchedlists[i].append(this.tplempty);
|
||||
}
|
||||
}
|
||||
|
||||
touchedlists = [];
|
||||
},
|
||||
|
||||
toggleItem: function(li) {
|
||||
this[li.hasClass(this.options.collapsedClass) ? "expandItem":"collapseItem"](li);
|
||||
},
|
||||
|
||||
expandItem: function(li)
|
||||
{
|
||||
li.removeClass(this.options.collapsedClass);
|
||||
},
|
||||
|
||||
collapseItem: function(li)
|
||||
{
|
||||
var lists = li.children(this.options.listNodeName);
|
||||
if (lists.length) {
|
||||
li.addClass(this.options.collapsedClass);
|
||||
}
|
||||
},
|
||||
|
||||
expandAll: function()
|
||||
{
|
||||
var list = this;
|
||||
list.el.find(list.options.itemNodeName).each(function()
|
||||
{
|
||||
list.expandItem($(this));
|
||||
});
|
||||
},
|
||||
|
||||
collapseAll: function()
|
||||
{
|
||||
var list = this;
|
||||
list.el.find(list.options.itemNodeName).each(function()
|
||||
{
|
||||
list.collapseItem($(this));
|
||||
});
|
||||
},
|
||||
|
||||
setParent: function(li)
|
||||
{
|
||||
if (li.children(this.options.listNodeName).length) {
|
||||
li.addClass("uk-parent");
|
||||
}
|
||||
},
|
||||
|
||||
unsetParent: function(li)
|
||||
{
|
||||
li.removeClass('uk-parent '+this.options.collapsedClass);
|
||||
li.children(this.options.listNodeName).remove();
|
||||
},
|
||||
|
||||
dragStart: function(e)
|
||||
{
|
||||
var mouse = this.mouse,
|
||||
target = $(e.target),
|
||||
dragItem = target.closest(this.options.itemNodeName),
|
||||
offset = dragItem.offset();
|
||||
|
||||
this.placeEl.css('height', dragItem.height());
|
||||
|
||||
mouse.offsetX = e.pageX - offset.left;
|
||||
mouse.offsetY = e.pageY - offset.top;
|
||||
|
||||
mouse.startX = mouse.lastX = offset.left;
|
||||
mouse.startY = mouse.lastY = offset.top;
|
||||
|
||||
this.dragRootEl = this.el;
|
||||
|
||||
this.dragEl = $(document.createElement(this.options.listNodeName)).addClass(this.options.listClass + ' ' + this.options.dragClass);
|
||||
this.dragEl.css('width', dragItem.width());
|
||||
|
||||
this.tmpDragOnSiblings = [dragItem[0].previousSibling, dragItem[0].nextSibling];
|
||||
|
||||
// fix for zepto.js
|
||||
//dragItem.after(this.placeEl).detach().appendTo(this.dragEl);
|
||||
dragItem.after(this.placeEl);
|
||||
dragItem[0].parentNode.removeChild(dragItem[0]);
|
||||
dragItem.appendTo(this.dragEl);
|
||||
|
||||
$(document.body).append(this.dragEl);
|
||||
|
||||
this.dragEl.css({
|
||||
left : offset.left,
|
||||
top : offset.top
|
||||
});
|
||||
|
||||
// total depth of dragging item
|
||||
var i, depth,
|
||||
items = this.dragEl.find(this.options.itemNodeName);
|
||||
for (i = 0; i < items.length; i++) {
|
||||
depth = $(items[i]).parents(this.options.listNodeName).length;
|
||||
if (depth > this.dragDepth) {
|
||||
this.dragDepth = depth;
|
||||
}
|
||||
}
|
||||
|
||||
html.addClass(this.options.movingClass);
|
||||
},
|
||||
|
||||
dragStop: function(e)
|
||||
{
|
||||
// fix for zepto.js
|
||||
//this.placeEl.replaceWith(this.dragEl.children(this.options.itemNodeName + ':first').detach());
|
||||
var el = this.dragEl.children(this.options.itemNodeName).first();
|
||||
el[0].parentNode.removeChild(el[0]);
|
||||
this.placeEl.replaceWith(el);
|
||||
|
||||
this.dragEl.remove();
|
||||
|
||||
if (this.tmpDragOnSiblings[0]!=el[0].previousSibling || this.tmpDragOnSiblings[0]!=el[0].previousSibling) {
|
||||
|
||||
this.el.trigger('sortable-change',[el, this.hasNewRoot ? "added":"moved"]);
|
||||
|
||||
if (this.hasNewRoot) {
|
||||
this.dragRootEl.trigger('sortable-change', [el, "removed"]);
|
||||
}
|
||||
}
|
||||
|
||||
this.reset();
|
||||
|
||||
html.removeClass(this.options.movingClass);
|
||||
},
|
||||
|
||||
dragMove: function(e)
|
||||
{
|
||||
var list, parent, prev, next, depth,
|
||||
opt = this.options,
|
||||
mouse = this.mouse;
|
||||
|
||||
this.dragEl.css({
|
||||
left : e.pageX - mouse.offsetX,
|
||||
top : e.pageY - mouse.offsetY
|
||||
});
|
||||
|
||||
// mouse position last events
|
||||
mouse.lastX = mouse.nowX;
|
||||
mouse.lastY = mouse.nowY;
|
||||
// mouse position this events
|
||||
mouse.nowX = e.pageX;
|
||||
mouse.nowY = e.pageY;
|
||||
// distance mouse moved between events
|
||||
mouse.distX = mouse.nowX - mouse.lastX;
|
||||
mouse.distY = mouse.nowY - mouse.lastY;
|
||||
// direction mouse was moving
|
||||
mouse.lastDirX = mouse.dirX;
|
||||
mouse.lastDirY = mouse.dirY;
|
||||
// direction mouse is now moving (on both axis)
|
||||
mouse.dirX = mouse.distX === 0 ? 0 : mouse.distX > 0 ? 1 : -1;
|
||||
mouse.dirY = mouse.distY === 0 ? 0 : mouse.distY > 0 ? 1 : -1;
|
||||
// axis mouse is now moving on
|
||||
var newAx = Math.abs(mouse.distX) > Math.abs(mouse.distY) ? 1 : 0;
|
||||
|
||||
// do nothing on first move
|
||||
if (!mouse.moving) {
|
||||
mouse.dirAx = newAx;
|
||||
mouse.moving = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// calc distance moved on this axis (and direction)
|
||||
if (mouse.dirAx !== newAx) {
|
||||
mouse.distAxX = 0;
|
||||
mouse.distAxY = 0;
|
||||
} else {
|
||||
mouse.distAxX += Math.abs(mouse.distX);
|
||||
if (mouse.dirX !== 0 && mouse.dirX !== mouse.lastDirX) {
|
||||
mouse.distAxX = 0;
|
||||
}
|
||||
mouse.distAxY += Math.abs(mouse.distY);
|
||||
if (mouse.dirY !== 0 && mouse.dirY !== mouse.lastDirY) {
|
||||
mouse.distAxY = 0;
|
||||
}
|
||||
}
|
||||
mouse.dirAx = newAx;
|
||||
|
||||
/**
|
||||
* move horizontal
|
||||
*/
|
||||
if (mouse.dirAx && mouse.distAxX >= opt.threshold) {
|
||||
// reset move distance on x-axis for new phase
|
||||
mouse.distAxX = 0;
|
||||
prev = this.placeEl.prev(opt.itemNodeName);
|
||||
// increase horizontal level if previous sibling exists and is not collapsed
|
||||
if (mouse.distX > 0 && prev.length && !prev.hasClass(opt.collapsedClass)) {
|
||||
// cannot increase level when item above is collapsed
|
||||
list = prev.find(opt.listNodeName).last();
|
||||
// check if depth limit has reached
|
||||
depth = this.placeEl.parents(opt.listNodeName).length;
|
||||
if (depth + this.dragDepth <= opt.maxDepth) {
|
||||
// create new sub-level if one doesn't exist
|
||||
if (!list.length) {
|
||||
list = $('<' + opt.listNodeName + '/>').addClass(opt.listClass);
|
||||
list.append(this.placeEl);
|
||||
prev.append(list);
|
||||
this.setParent(prev);
|
||||
} else {
|
||||
// else append to next level up
|
||||
list = prev.children(opt.listNodeName).last();
|
||||
list.append(this.placeEl);
|
||||
}
|
||||
}
|
||||
}
|
||||
// decrease horizontal level
|
||||
if (mouse.distX < 0) {
|
||||
// we can't decrease a level if an item preceeds the current one
|
||||
next = this.placeEl.next(opt.itemNodeName);
|
||||
if (!next.length) {
|
||||
parent = this.placeEl.parent();
|
||||
this.placeEl.closest(opt.itemNodeName).after(this.placeEl);
|
||||
if (!parent.children().length) {
|
||||
this.unsetParent(parent.parent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var isEmpty = false;
|
||||
|
||||
// find list item under cursor
|
||||
if (!hasPointerEvents) {
|
||||
this.dragEl[0].style.visibility = 'hidden';
|
||||
}
|
||||
this.pointEl = $(document.elementFromPoint(e.pageX - document.body.scrollLeft, e.pageY - (window.pageYOffset || document.documentElement.scrollTop)));
|
||||
if (!hasPointerEvents) {
|
||||
this.dragEl[0].style.visibility = 'visible';
|
||||
}
|
||||
|
||||
if (this.pointEl.hasClass(opt.handleClass)) {
|
||||
this.pointEl = this.pointEl.closest(opt.itemNodeName);
|
||||
} else {
|
||||
|
||||
var sortableitem = this.pointEl.closest('.'+opt.itemClass);
|
||||
|
||||
if(sortableitem.length) {
|
||||
this.pointEl = sortableitem.closest(opt.itemNodeName);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.pointEl.hasClass(opt.emptyClass)) {
|
||||
isEmpty = true;
|
||||
}
|
||||
else if (this.pointEl.data('uksortable') && !this.pointEl.children().length) {
|
||||
isEmpty = true;
|
||||
this.pointEl = $(this.tplempty).appendTo(this.pointEl);
|
||||
}
|
||||
else if (!this.pointEl.length || !this.pointEl.hasClass(opt.listitemClass)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// find parent list of item under cursor
|
||||
var pointElRoot = this.el,
|
||||
tmpRoot = this.pointEl.closest('.'+this.options.listBaseClass),
|
||||
isNewRoot = pointElRoot[0] !== this.pointEl.closest('.'+this.options.listBaseClass)[0],
|
||||
$newRoot = tmpRoot;
|
||||
|
||||
/**
|
||||
* move vertical
|
||||
*/
|
||||
if (!mouse.dirAx || isNewRoot || isEmpty) {
|
||||
// check if groups match if dragging over new root
|
||||
if (isNewRoot && opt.group !== $newRoot.data('uksortable-group')) {
|
||||
return;
|
||||
} else {
|
||||
touchedlists.push(pointElRoot);
|
||||
}
|
||||
|
||||
// check depth limit
|
||||
depth = this.dragDepth - 1 + this.pointEl.parents(opt.listNodeName).length;
|
||||
if (depth > opt.maxDepth) {
|
||||
return;
|
||||
}
|
||||
var before = e.pageY < (this.pointEl.offset().top + this.pointEl.height() / 2);
|
||||
parent = this.placeEl.parent();
|
||||
// if empty create new list to replace empty placeholder
|
||||
if (isEmpty) {
|
||||
this.pointEl.replaceWith(this.placeEl);
|
||||
}
|
||||
else if (before) {
|
||||
this.pointEl.before(this.placeEl);
|
||||
}
|
||||
else {
|
||||
this.pointEl.after(this.placeEl);
|
||||
}
|
||||
if (!parent.children().length) {
|
||||
if(!parent.data("uksortable")) this.unsetParent(parent.parent());
|
||||
}
|
||||
if (!this.dragRootEl.find(opt.itemNodeName).length && !this.dragRootEl.children().length) {
|
||||
this.dragRootEl.append(this.tplempty);
|
||||
}
|
||||
|
||||
// parent root list has changed
|
||||
if (isNewRoot) {
|
||||
this.dragRootEl = tmpRoot;
|
||||
this.hasNewRoot = this.el[0] !== this.dragRootEl[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$.fn.uksortable = function(params)
|
||||
{
|
||||
var lists = this,
|
||||
retval = this;
|
||||
|
||||
lists.each(function()
|
||||
{
|
||||
var element = $(this),
|
||||
plugin = element.data("uksortable");
|
||||
|
||||
if (!plugin) {
|
||||
plugin = new Plugin(element, params);
|
||||
} else {
|
||||
if (typeof params === 'string' && typeof plugin[params] === 'function') {
|
||||
retval = plugin[params]();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return retval || lists;
|
||||
};
|
||||
|
||||
$.fn.uksortable.defaults = {
|
||||
prefix : 'uk',
|
||||
listNodeName : 'ul',
|
||||
itemNodeName : 'li',
|
||||
listBaseClass : '{prefix}-sortable',
|
||||
listClass : '{prefix}-sortable-list',
|
||||
listitemClass : '{prefix}-sortable-list-item',
|
||||
itemClass : '{prefix}-sortable-item',
|
||||
dragClass : '{prefix}-sortable-list-dragged',
|
||||
movingClass : '{prefix}-sortable-moving',
|
||||
handleClass : '{prefix}-sortable-handle',
|
||||
collapsedClass : '{prefix}-collapsed',
|
||||
placeClass : '{prefix}-sortable-placeholder',
|
||||
noDragClass : '{prefix}-sortable-nodrag',
|
||||
emptyClass : '{prefix}-sortable-empty',
|
||||
group : 0,
|
||||
maxDepth : 10,
|
||||
threshold : 20
|
||||
};
|
||||
|
||||
$(document).on("uk-domready", function(e) {
|
||||
|
||||
$("[data-uk-sortable]").each(function(){
|
||||
|
||||
var ele = $(this),
|
||||
options = $.extend({}, $.fn.uksortable.defaults, UI.Utils.options(ele.attr("data-uk-sortable")));
|
||||
|
||||
Object.keys(options).forEach(function(key){
|
||||
|
||||
if(String(options[key]).indexOf('{prefix}')!=-1) {
|
||||
options[key] = options[key].replace('{prefix}', options.prefix);
|
||||
}
|
||||
});
|
||||
|
||||
if(!ele.data("uksortable")) {
|
||||
ele.uksortable(options);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
})(window.jQuery, jQuery.UIkit, window, document);
|
||||
@@ -0,0 +1,3 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
(function(t,e,i,n){function s(e,n){var s=t(e);s.data("uksortable")||(this.w=t(i),this.el=s,this.options=t.extend({},t.fn.uksortable.defaults,n),this.tplempty='<div class="'+this.options.emptyClass+'"/>',this.el.find(">"+this.options.itemNodeName).addClass(this.options.listitemClass).end().find("ul:not(.ignore-list)").addClass(this.options.listClass).find(">li").addClass(this.options.listitemClass),this.el.children(this.options.itemNodeName).length||this.el.append(this.tplempty),this.el.data("uksortable",this),this.el.data("uksortable-id","ID"+(new Date).getTime()+"RAND"+Math.ceil(1e5*Math.random())),this.init())}var o="ontouchstart"in i,a=t("html"),r=[],l=function(){var t=n.createElement("div"),e=n.documentElement;if(!("pointerEvents"in t.style))return!1;t.style.pointerEvents="auto",t.style.pointerEvents="x",e.appendChild(t);var s=i.getComputedStyle&&"auto"===i.getComputedStyle(t,"").pointerEvents;return e.removeChild(t),!!s}(),u=o?"touchstart":"mousedown",d=o?"touchmove":"mousemove",h=o?"touchend":"mouseup",c=o?"touchcancel":"mouseup";s.prototype={init:function(){var e=this;e.reset(),e.el.data("uksortable-group",this.options.group),e.placeEl=t('<div class="'+e.options.placeClass+'"/>'),t.each(this.el.find(e.options.itemNodeName),function(i,n){e.setParent(t(n))}),e.el.on("click","[data-sortable-action]",function(i){if(!e.dragEl&&(o||0===i.button)){i.preventDefault();var n=t(i.currentTarget),s=n.data("sortableAction"),a=n.closest(e.options.itemNodeName);"collapse"===s&&e.collapseItem(a),"expand"===s&&e.expandItem(a),"toggle"===s&&e.toggleItem(a)}});var n=function(i){var n=t(i.target);if(!n.hasClass(e.options.handleClass)){if(n.closest("."+e.options.noDragClass).length)return;n=n.closest("."+e.options.handleClass)}!n.length||e.dragEl||!o&&0!==i.button||o&&1!==i.touches.length||(i.preventDefault(),e.dragStart(o?i.touches[0]:i))},s=function(t){e.dragEl&&(t.preventDefault(),e.dragMove(o?t.touches[0]:t))},a=function(t){e.dragEl&&(t.preventDefault(),e.dragStop(o?t.touches[0]:t))};o?(e.el[0].addEventListener(u,n,!1),i.addEventListener(d,s,!1),i.addEventListener(h,a,!1),i.addEventListener(c,a,!1)):(e.el.on(u,n),e.w.on(d,s),e.w.on(h,a))},serialize:function(){var e,i=0,n=this;return step=function(e,i){var s=[],o=e.children(n.options.itemNodeName);return o.each(function(){var e=t(this),o=t.extend({},e.data()),a=e.children(n.options.listNodeName);a.length&&(o.children=step(a,i+1)),s.push(o)}),s},e=step(n.el,i)},list:function(e){var i=[],n=this,s=0,e=t.extend({},n.options,e),o=function(n,s,a){var r=n.children(e.itemNodeName);r.each(function(n){var r=t(this),l=t.extend({parent_id:a?a:null,depth:s,order:n},r.data()),u=r.children(e.listNodeName);i.push(l),u.length&&o(u,s+1,r.data(e.idProperty||"id"))})};return o(n.el,s),i},reset:function(){this.mouse={offsetX:0,offsetY:0,startX:0,startY:0,lastX:0,lastY:0,nowX:0,nowY:0,distX:0,distY:0,dirAx:0,dirX:0,dirY:0,lastDirX:0,lastDirY:0,distAxX:0,distAxY:0},this.moving=!1,this.dragEl=null,this.dragRootEl=null,this.dragDepth=0,this.hasNewRoot=!1,this.pointEl=null;for(var t=0;r.length>t;t++)r[t].children().length||r[t].append(this.tplempty);r=[]},toggleItem:function(t){this[t.hasClass(this.options.collapsedClass)?"expandItem":"collapseItem"](t)},expandItem:function(t){t.removeClass(this.options.collapsedClass)},collapseItem:function(t){var e=t.children(this.options.listNodeName);e.length&&t.addClass(this.options.collapsedClass)},expandAll:function(){var e=this;e.el.find(e.options.itemNodeName).each(function(){e.expandItem(t(this))})},collapseAll:function(){var e=this;e.el.find(e.options.itemNodeName).each(function(){e.collapseItem(t(this))})},setParent:function(t){t.children(this.options.listNodeName).length&&t.addClass("uk-parent")},unsetParent:function(t){t.removeClass("uk-parent "+this.options.collapsedClass),t.children(this.options.listNodeName).remove()},dragStart:function(e){var i=this.mouse,s=t(e.target),o=s.closest(this.options.itemNodeName),r=o.offset();this.placeEl.css("height",o.height()),i.offsetX=e.pageX-r.left,i.offsetY=e.pageY-r.top,i.startX=i.lastX=r.left,i.startY=i.lastY=r.top,this.dragRootEl=this.el,this.dragEl=t(n.createElement(this.options.listNodeName)).addClass(this.options.listClass+" "+this.options.dragClass),this.dragEl.css("width",o.width()),this.tmpDragOnSiblings=[o[0].previousSibling,o[0].nextSibling],o.after(this.placeEl),o[0].parentNode.removeChild(o[0]),o.appendTo(this.dragEl),t(n.body).append(this.dragEl),this.dragEl.css({left:r.left,top:r.top});var l,u,d=this.dragEl.find(this.options.itemNodeName);for(l=0;d.length>l;l++)u=t(d[l]).parents(this.options.listNodeName).length,u>this.dragDepth&&(this.dragDepth=u);a.addClass(this.options.movingClass)},dragStop:function(){var t=this.dragEl.children(this.options.itemNodeName).first();t[0].parentNode.removeChild(t[0]),this.placeEl.replaceWith(t),this.dragEl.remove(),(this.tmpDragOnSiblings[0]!=t[0].previousSibling||this.tmpDragOnSiblings[0]!=t[0].previousSibling)&&(this.el.trigger("sortable-change",[t,this.hasNeLine truncated
|
||||
@@ -0,0 +1,141 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
/*
|
||||
* Based on https://github.com/garand/sticky
|
||||
*/
|
||||
|
||||
(function(global, $, UI, $window, $document){
|
||||
|
||||
var defaults = {
|
||||
top : 0,
|
||||
bottom : 0,
|
||||
clsactive : 'uk-sticky-active',
|
||||
clswrapper : 'uk-sticky-wrapper',
|
||||
getWidthFrom : ''
|
||||
},
|
||||
|
||||
sticked = [],
|
||||
|
||||
windowHeight = $window.height(),
|
||||
|
||||
scroller = function() {
|
||||
|
||||
var scrollTop = $window.scrollTop(),
|
||||
documentHeight = $document.height(),
|
||||
dwh = documentHeight - windowHeight,
|
||||
extra = (scrollTop > dwh) ? dwh - scrollTop : 0;
|
||||
|
||||
for (var i = 0; i < sticked.length; i++) {
|
||||
|
||||
if(!sticked[i].stickyElement.is(":visible")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var s = sticked[i], elementTop = s.stickyWrapper.offset().top, etse = elementTop - s.top - extra;
|
||||
|
||||
if (scrollTop <= etse) {
|
||||
|
||||
if (s.currentTop !== null) {
|
||||
s.stickyElement.css({"position":"", "top":"", "width":""}).parent().removeClass(s.clsactive);
|
||||
s.currentTop = null;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
var newTop = documentHeight - s.stickyElement.outerHeight() - s.top - s.bottom - scrollTop - extra;
|
||||
|
||||
newTop = newTop<0 ? newTop + s.top : s.top;
|
||||
|
||||
if (s.currentTop != newTop) {
|
||||
s.stickyElement.css({"position": "fixed", "top": newTop, "width": s.stickyElement.width()});
|
||||
|
||||
if (typeof s.getWidthFrom !== 'undefined') {
|
||||
s.stickyElement.css('width', $(s.getWidthFrom).width());
|
||||
}
|
||||
|
||||
s.stickyElement.parent().addClass(s.clsactive);
|
||||
s.currentTop = newTop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
resizer = function() {
|
||||
windowHeight = $window.height();
|
||||
},
|
||||
|
||||
methods = {
|
||||
|
||||
init: function(options) {
|
||||
|
||||
var o = $.extend({}, defaults, options);
|
||||
|
||||
return this.each(function() {
|
||||
|
||||
var stickyElement = $(this);
|
||||
|
||||
if(stickyElement.data("sticky")) return;
|
||||
|
||||
var stickyId = stickyElement.attr('id') || ("s"+Math.ceil(Math.random()*10000)),
|
||||
wrapper = $('<div></div>').attr('id', stickyId + '-sticky-wrapper').addClass(o.clswrapper);
|
||||
|
||||
stickyElement.wrapAll(wrapper);
|
||||
|
||||
if (stickyElement.css("float") == "right") {
|
||||
stickyElement.css({"float":"none"}).parent().css({"float":"right"});
|
||||
}
|
||||
|
||||
stickyElement.data("sticky", true);
|
||||
|
||||
var stickyWrapper = stickyElement.parent();
|
||||
stickyWrapper.css('height', stickyElement.outerHeight());
|
||||
sticked.push({
|
||||
top: o.top,
|
||||
bottom: o.bottom,
|
||||
stickyElement: stickyElement,
|
||||
currentTop: null,
|
||||
stickyWrapper: stickyWrapper,
|
||||
clsactive: o.clsactive,
|
||||
getWidthFrom: o.getWidthFrom
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
update: scroller
|
||||
};
|
||||
|
||||
// should be more efficient than using $window.scroll(scroller) and $window.resize(resizer):
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener('scroll', scroller, false);
|
||||
window.addEventListener('resize', resizer, false);
|
||||
} else if (window.attachEvent) {
|
||||
window.attachEvent('onscroll', scroller);
|
||||
window.attachEvent('onresize', resizer);
|
||||
}
|
||||
|
||||
$.fn.uksticky = function(method) {
|
||||
if (methods[method]) {
|
||||
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
||||
} else if (typeof method === 'object' || !method ) {
|
||||
return methods.init.apply( this, arguments );
|
||||
} else {
|
||||
$.error('Method ' + method + ' does not exist on jQuery.sticky');
|
||||
}
|
||||
};
|
||||
|
||||
$(document).on("uk-domready", function(e) {
|
||||
setTimeout(function(){
|
||||
|
||||
scroller();
|
||||
|
||||
$("[data-uk-sticky]").each(function(){
|
||||
|
||||
var $ele = $(this);
|
||||
|
||||
if(!$ele.data("sticky")) $ele.uksticky(UI.Utils.options($ele.attr('data-uk-sticky')));
|
||||
});
|
||||
}, 0);
|
||||
});
|
||||
|
||||
})(this, jQuery, jQuery.UIkit, jQuery(window), jQuery(document));
|
||||
@@ -0,0 +1,3 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
(function(t,e,i,n,s){var o={top:0,bottom:0,clsactive:"uk-sticky-active",clswrapper:"uk-sticky-wrapper",getWidthFrom:""},a=[],r=n.height(),l=function(){for(var t=n.scrollTop(),i=s.height(),o=i-r,l=t>o?o-t:0,u=0;a.length>u;u++)if(a[u].stickyElement.is(":visible")){var d=a[u],h=d.stickyWrapper.offset().top,c=h-d.top-l;if(c>=t)null!==d.currentTop&&(d.stickyElement.css({position:"",top:"",width:""}).parent().removeClass(d.clsactive),d.currentTop=null);else{var f=i-d.stickyElement.outerHeight()-d.top-d.bottom-t-l;f=0>f?f+d.top:d.top,d.currentTop!=f&&(d.stickyElement.css({position:"fixed",top:f,width:d.stickyElement.width()}),d.getWidthFrom!==void 0&&d.stickyElement.css("width",e(d.getWidthFrom).width()),d.stickyElement.parent().addClass(d.clsactive),d.currentTop=f)}}},u=function(){r=n.height()},d={init:function(t){var i=e.extend({},o,t);return this.each(function(){var t=e(this);if(!t.data("sticky")){var n=t.attr("id")||"s"+Math.ceil(1e4*Math.random()),s=e("<div></div>").attr("id",n+"-sticky-wrapper").addClass(i.clswrapper);t.wrapAll(s),"right"==t.css("float")&&t.css({"float":"none"}).parent().css({"float":"right"}),t.data("sticky",!0);var o=t.parent();o.css("height",t.outerHeight()),a.push({top:i.top,bottom:i.bottom,stickyElement:t,currentTop:null,stickyWrapper:o,clsactive:i.clsactive,getWidthFrom:i.getWidthFrom})}})},update:l};window.addEventListener?(window.addEventListener("scroll",l,!1),window.addEventListener("resize",u,!1)):window.attachEvent&&(window.attachEvent("onscroll",l),window.attachEvent("onresize",u)),e.fn.uksticky=function(t){return d[t]?d[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?(e.error("Method "+t+" does not exist on jQuery.sticky"),void 0):d.init.apply(this,arguments)},e(document).on("uk-domready",function(){setTimeout(function(){l(),e("[data-uk-sticky]").each(function(){var t=e(this);t.data("sticky")||t.uksticky(i.Utils.options(t.attr("data-uk-sticky")))})},0)})})(this,jQuery,jQuery.UIkit,jQuery(window),jQuery(document));
|
||||
@@ -0,0 +1,521 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
/*
|
||||
* Based on https://github.com/jdewit/bootstrap-timepicker
|
||||
*/
|
||||
|
||||
(function(global, $, UI){
|
||||
|
||||
// Timepicker
|
||||
|
||||
var TimePicker = function(element, options) {
|
||||
|
||||
var $this = this, $element = $(element);
|
||||
|
||||
if($element.data("timepicker")) return;
|
||||
|
||||
this.$element = $element;
|
||||
this.element = this.$element[0];
|
||||
this.options = $.extend({}, TimePicker.defaults, options);
|
||||
|
||||
this.$element.on({
|
||||
'focus.timepicker.uikit' : $.proxy(this.highlightUnit, this),
|
||||
'click.timepicker.uikit' : $.proxy(this.highlightUnit, this),
|
||||
'keydown.timepicker.uikit': $.proxy(this.onKeydown, this),
|
||||
'blur.timepicker.uikit' : $.proxy(this.blurElement, this)
|
||||
});
|
||||
|
||||
this.setDefaultTime(this.options.defaultTime);
|
||||
|
||||
this.element.data("timepicker", this);
|
||||
};
|
||||
|
||||
TimePicker.defaults = {
|
||||
defaultTime: 'current',
|
||||
disableFocus: false,
|
||||
minuteStep: 15,
|
||||
secondStep: 15,
|
||||
showSeconds: false,
|
||||
showMeridian: false
|
||||
};
|
||||
|
||||
$.extend(TimePicker.prototype, {
|
||||
|
||||
setDefaultTime: function(defaultTime){
|
||||
|
||||
if (!this.element.value) {
|
||||
|
||||
if (defaultTime === 'current') {
|
||||
|
||||
var d = new Date();
|
||||
|
||||
this.hour = d.getHours(),
|
||||
this.minute = Math.floor(d.getMinutes() / this.options.minuteStep) * this.options.minuteStep,
|
||||
this.second = Math.floor(d.getSeconds() / this.options.secondStep) * this.options.secondStep,
|
||||
this.meridian = 'AM';
|
||||
|
||||
if (this.options.showMeridian) {
|
||||
if (this.hour === 0) {
|
||||
this.hour = 12;
|
||||
} else if (this.hour >= 12) {
|
||||
if (this.hour > 12) this.hour = this.hour - 12;
|
||||
this.meridian = 'PM';
|
||||
} else {
|
||||
this.meridian = 'AM';
|
||||
}
|
||||
}
|
||||
|
||||
this.update();
|
||||
|
||||
} else if (defaultTime === false) {
|
||||
this.hour = 0;
|
||||
this.minute = 0;
|
||||
this.second = 0;
|
||||
this.meridian = 'AM';
|
||||
} else {
|
||||
this.setTime(defaultTime);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.updateFromElementVal();
|
||||
}
|
||||
},
|
||||
|
||||
setTime: function(time) {
|
||||
var arr, timeArray;
|
||||
|
||||
if (this.options.showMeridian) {
|
||||
arr = time.split(' ');
|
||||
timeArray = arr[0].split(':');
|
||||
this.meridian = arr[1];
|
||||
} else {
|
||||
timeArray = time.split(':');
|
||||
}
|
||||
|
||||
this.hour = parseInt(timeArray[0], 10);
|
||||
this.minute = parseInt(timeArray[1], 10);
|
||||
this.second = parseInt(timeArray[2], 10);
|
||||
|
||||
if (isNaN(this.hour)) this.hour = 0;
|
||||
if (isNaN(this.minute)) this.minute = 0;
|
||||
|
||||
if (this.options.showMeridian) {
|
||||
if (this.hour > 12) {
|
||||
this.hour = 12;
|
||||
} else if (this.hour < 1) {
|
||||
this.hour = 12;
|
||||
}
|
||||
|
||||
if (this.meridian === 'am' || this.meridian === 'a') {
|
||||
this.meridian = 'AM';
|
||||
} else if (this.meridian === 'pm' || this.meridian === 'p') {
|
||||
this.meridian = 'PM';
|
||||
}
|
||||
|
||||
if (this.meridian !== 'AM' && this.meridian !== 'PM') {
|
||||
this.meridian = 'AM';
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (this.hour >= 24) {
|
||||
this.hour = 23;
|
||||
} else if (this.hour < 0) {
|
||||
this.hour = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.minute < 0) {
|
||||
this.minute = 0;
|
||||
} else if (this.minute >= 60) {
|
||||
this.minute = 59;
|
||||
}
|
||||
|
||||
if (this.options.showSeconds) {
|
||||
if (isNaN(this.second)) {
|
||||
this.second = 0;
|
||||
} else if (this.second < 0) {
|
||||
this.second = 0;
|
||||
} else if (this.second >= 60) {
|
||||
this.second = 59;
|
||||
}
|
||||
}
|
||||
|
||||
this.update();
|
||||
},
|
||||
|
||||
blurElement: function() {
|
||||
this.highlightedUnit = undefined;
|
||||
this.updateFromElementVal();
|
||||
},
|
||||
|
||||
decrementHour: function() {
|
||||
if (this.options.showMeridian) {
|
||||
if (this.hour === 1) {
|
||||
this.hour = 12;
|
||||
} else if (this.hour === 12) {
|
||||
this.hour--;
|
||||
|
||||
return this.toggleMeridian();
|
||||
} else if (this.hour === 0) {
|
||||
this.hour = 11;
|
||||
|
||||
return this.toggleMeridian();
|
||||
} else {
|
||||
this.hour--;
|
||||
}
|
||||
} else {
|
||||
if (this.hour === 0) {
|
||||
this.hour = 23;
|
||||
} else {
|
||||
this.hour--;
|
||||
}
|
||||
}
|
||||
this.update();
|
||||
},
|
||||
|
||||
decrementMinute: function(step) {
|
||||
|
||||
var newVal = (step) ? this.minute - step : this.minute - this.options.minuteStep;
|
||||
|
||||
if (newVal < 0) {
|
||||
this.decrementHour();
|
||||
this.minute = newVal + 60;
|
||||
} else {
|
||||
this.minute = newVal;
|
||||
}
|
||||
this.update();
|
||||
},
|
||||
|
||||
decrementSecond: function() {
|
||||
var newVal = this.second - this.options.secondStep;
|
||||
|
||||
if (newVal < 0) {
|
||||
this.decrementMinute(true);
|
||||
this.second = newVal + 60;
|
||||
} else {
|
||||
this.second = newVal;
|
||||
}
|
||||
this.update();
|
||||
},
|
||||
|
||||
onKeydown: function(e) {
|
||||
switch (e.keyCode) {
|
||||
case 9: //tab
|
||||
this.updateFromElementVal();
|
||||
|
||||
switch (this.highlightedUnit) {
|
||||
case 'hour':
|
||||
e.preventDefault();
|
||||
this.highlightNextUnit();
|
||||
break;
|
||||
case 'minute':
|
||||
if (this.options.showMeridian || this.options.showSeconds) {
|
||||
e.preventDefault();
|
||||
this.highlightNextUnit();
|
||||
}
|
||||
break;
|
||||
case 'second':
|
||||
if (this.options.showMeridian) {
|
||||
e.preventDefault();
|
||||
this.highlightNextUnit();
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 27: // escape
|
||||
this.updateFromElementVal();
|
||||
break;
|
||||
case 37: // left arrow
|
||||
e.preventDefault();
|
||||
this.highlightPrevUnit();
|
||||
this.updateFromElementVal();
|
||||
break;
|
||||
case 38: // up arrow
|
||||
e.preventDefault();
|
||||
switch (this.highlightedUnit) {
|
||||
case 'hour':
|
||||
this.incrementHour();
|
||||
this.highlightHour();
|
||||
break;
|
||||
case 'minute':
|
||||
this.incrementMinute();
|
||||
this.highlightMinute();
|
||||
break;
|
||||
case 'second':
|
||||
this.incrementSecond();
|
||||
this.highlightSecond();
|
||||
break;
|
||||
case 'meridian':
|
||||
this.toggleMeridian();
|
||||
this.highlightMeridian();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 39: // right arrow
|
||||
e.preventDefault();
|
||||
this.updateFromElementVal();
|
||||
this.highlightNextUnit();
|
||||
break;
|
||||
case 40: // down arrow
|
||||
e.preventDefault();
|
||||
switch (this.highlightedUnit) {
|
||||
case 'hour':
|
||||
this.decrementHour();
|
||||
this.highlightHour();
|
||||
break;
|
||||
case 'minute':
|
||||
this.decrementMinute();
|
||||
this.highlightMinute();
|
||||
break;
|
||||
case 'second':
|
||||
this.decrementSecond();
|
||||
this.highlightSecond();
|
||||
break;
|
||||
case 'meridian':
|
||||
this.toggleMeridian();
|
||||
this.highlightMeridian();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
formatTime: function(hour, minute, second, meridian) {
|
||||
hour = hour < 10 ? '0' + hour : hour;
|
||||
minute = minute < 10 ? '0' + minute : minute;
|
||||
second = second < 10 ? '0' + second : second;
|
||||
|
||||
return hour + ':' + minute + (this.options.showSeconds ? ':' + second : '') + (this.options.showMeridian ? ' ' + meridian : '');
|
||||
},
|
||||
|
||||
getCursorPosition: function() {
|
||||
|
||||
if ('selectionStart' in this.element) {// Standard-compliant browsers
|
||||
|
||||
return this.element.selectionStart;
|
||||
} else if (document.selection) {// IE fix
|
||||
this.element.focus();
|
||||
var sel = document.selection.createRange(),
|
||||
selLen = document.selection.createRange().text.length;
|
||||
|
||||
sel.moveStart('character', - this.element.value.length);
|
||||
|
||||
return sel.text.length - selLen;
|
||||
}
|
||||
},
|
||||
|
||||
getTime: function() {
|
||||
return this.formatTime(this.hour, this.minute, this.second, this.meridian);
|
||||
},
|
||||
|
||||
highlightUnit: function() {
|
||||
this.position = this.getCursorPosition();
|
||||
if (this.position >= 0 && this.position <= 2) {
|
||||
this.highlightHour();
|
||||
} else if (this.position >= 3 && this.position <= 5) {
|
||||
this.highlightMinute();
|
||||
} else if (this.position >= 6 && this.position <= 8) {
|
||||
if (this.options.showSeconds) {
|
||||
this.highlightSecond();
|
||||
} else {
|
||||
this.highlightMeridian();
|
||||
}
|
||||
} else if (this.position >= 9 && this.position <= 11) {
|
||||
this.highlightMeridian();
|
||||
}
|
||||
},
|
||||
|
||||
highlightNextUnit: function() {
|
||||
switch (this.highlightedUnit) {
|
||||
case 'hour':
|
||||
this.highlightMinute();
|
||||
break;
|
||||
case 'minute':
|
||||
if (this.options.showSeconds) {
|
||||
this.highlightSecond();
|
||||
} else if (this.options.showMeridian){
|
||||
this.highlightMeridian();
|
||||
} else {
|
||||
this.highlightHour();
|
||||
}
|
||||
break;
|
||||
case 'second':
|
||||
if (this.options.showMeridian) {
|
||||
this.highlightMeridian();
|
||||
} else {
|
||||
this.highlightHour();
|
||||
}
|
||||
break;
|
||||
case 'meridian':
|
||||
this.highlightHour();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
highlightPrevUnit: function() {
|
||||
switch (this.highlightedUnit) {
|
||||
case 'hour':
|
||||
this.highlightMeridian();
|
||||
break;
|
||||
case 'minute':
|
||||
this.highlightHour();
|
||||
break;
|
||||
case 'second':
|
||||
this.highlightMinute();
|
||||
break;
|
||||
case 'meridian':
|
||||
if (this.options.showSeconds) {
|
||||
this.highlightSecond();
|
||||
} else {
|
||||
this.highlightMinute();
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
highlightHour: function() {
|
||||
var $element = this.element;
|
||||
|
||||
this.highlightedUnit = 'hour';
|
||||
|
||||
if ($element.setSelectionRange) {
|
||||
setTimeout(function() {
|
||||
$element.setSelectionRange(0,2);
|
||||
}, 0);
|
||||
}
|
||||
},
|
||||
|
||||
highlightMinute: function() {
|
||||
var $element = this.element;
|
||||
|
||||
this.highlightedUnit = 'minute';
|
||||
|
||||
if ($element.setSelectionRange) {
|
||||
setTimeout(function() {
|
||||
$element.setSelectionRange(3,5);
|
||||
}, 0);
|
||||
}
|
||||
},
|
||||
|
||||
highlightSecond: function() {
|
||||
var $element = this.element;
|
||||
|
||||
this.highlightedUnit = 'second';
|
||||
|
||||
if ($element.setSelectionRange) {
|
||||
setTimeout(function() {
|
||||
$element.setSelectionRange(6,8);
|
||||
}, 0);
|
||||
}
|
||||
},
|
||||
|
||||
highlightMeridian: function() {
|
||||
var $element = this.element;
|
||||
|
||||
this.highlightedUnit = 'meridian';
|
||||
|
||||
if ($element.setSelectionRange) {
|
||||
if (this.options.showSeconds) {
|
||||
setTimeout(function() {
|
||||
$element.setSelectionRange(9,11);
|
||||
}, 0);
|
||||
} else {
|
||||
setTimeout(function() {
|
||||
$element.setSelectionRange(6,8);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
incrementHour: function() {
|
||||
if (this.options.showMeridian) {
|
||||
if (this.hour === 11) {
|
||||
this.hour++;
|
||||
return this.toggleMeridian();
|
||||
} else if (this.hour === 12) {
|
||||
this.hour = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.hour === 23) {
|
||||
this.hour = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
this.hour++;
|
||||
this.update();
|
||||
},
|
||||
|
||||
incrementMinute: function(step) {
|
||||
|
||||
var newVal = step ? (this.minute + step) : (this.minute + this.options.minuteStep - (this.minute % this.options.minuteStep));
|
||||
|
||||
if (newVal > 59) {
|
||||
this.incrementHour();
|
||||
this.minute = newVal - 60;
|
||||
} else {
|
||||
this.minute = newVal;
|
||||
}
|
||||
this.update();
|
||||
},
|
||||
|
||||
incrementSecond: function() {
|
||||
var newVal = this.second + this.options.secondStep - (this.second % this.options.secondStep);
|
||||
|
||||
if (newVal > 59) {
|
||||
this.incrementMinute(true);
|
||||
this.second = newVal - 60;
|
||||
} else {
|
||||
this.second = newVal;
|
||||
}
|
||||
this.update();
|
||||
},
|
||||
|
||||
remove: function() {
|
||||
$('document').off('.timepicker.uikit');
|
||||
delete this.$element.data().timepicker;
|
||||
},
|
||||
|
||||
toggleMeridian: function() {
|
||||
this.meridian = this.meridian === 'AM' ? 'PM' : 'AM';
|
||||
this.update();
|
||||
},
|
||||
|
||||
update: function() {
|
||||
this.$element.trigger({
|
||||
'type': 'changeTime.timepicker',
|
||||
'time': {
|
||||
'value': this.getTime(),
|
||||
'hours': this.hour,
|
||||
'minutes': this.minute,
|
||||
'seconds': this.second,
|
||||
'meridian': this.meridian
|
||||
}
|
||||
});
|
||||
|
||||
this.updateElement();
|
||||
},
|
||||
|
||||
updateElement: function() {
|
||||
this.$element.val(this.getTime()).trigger("change");
|
||||
},
|
||||
|
||||
updateFromElementVal: function() {
|
||||
if (this.element.value) this.setTime(this.element.value);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// init code
|
||||
$(document).on("focus.timepicker.uikit", "[data-uk-timepicker]", function(e) {
|
||||
|
||||
var ele = $(this);
|
||||
if (!ele.data("timepicker")) {
|
||||
e.preventDefault();
|
||||
var obj = new TimePicker(ele, UI.Utils.options(ele.attr("data-uk-timepicker")));
|
||||
ele.trigger("focus");
|
||||
}
|
||||
});
|
||||
|
||||
})(this, jQuery, jQuery.UIkit);
|
||||
@@ -0,0 +1,3 @@
|
||||
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
|
||||
|
||||
(function(t,e,i){var n=function(t,i){var s=e(t);s.data("timepicker")||(this.$element=s,this.element=this.$element[0],this.options=e.extend({},n.defaults,i),this.$element.on({"focus.timepicker.uikit":e.proxy(this.highlightUnit,this),"click.timepicker.uikit":e.proxy(this.highlightUnit,this),"keydown.timepicker.uikit":e.proxy(this.onKeydown,this),"blur.timepicker.uikit":e.proxy(this.blurElement,this)}),this.setDefaultTime(this.options.defaultTime),this.element.data("timepicker",this))};n.defaults={defaultTime:"current",disableFocus:!1,minuteStep:15,secondStep:15,showSeconds:!1,showMeridian:!1},e.extend(n.prototype,{setDefaultTime:function(t){if(this.element.value)this.updateFromElementVal();else if("current"===t){var e=new Date;this.hour=e.getHours(),this.minute=Math.floor(e.getMinutes()/this.options.minuteStep)*this.options.minuteStep,this.second=Math.floor(e.getSeconds()/this.options.secondStep)*this.options.secondStep,this.meridian="AM",this.options.showMeridian&&(0===this.hour?this.hour=12:this.hour>=12?(this.hour>12&&(this.hour=this.hour-12),this.meridian="PM"):this.meridian="AM"),this.update()}else t===!1?(this.hour=0,this.minute=0,this.second=0,this.meridian="AM"):this.setTime(t)},setTime:function(t){var e,i;this.options.showMeridian?(e=t.split(" "),i=e[0].split(":"),this.meridian=e[1]):i=t.split(":"),this.hour=parseInt(i[0],10),this.minute=parseInt(i[1],10),this.second=parseInt(i[2],10),isNaN(this.hour)&&(this.hour=0),isNaN(this.minute)&&(this.minute=0),this.options.showMeridian?(this.hour>12?this.hour=12:1>this.hour&&(this.hour=12),"am"===this.meridian||"a"===this.meridian?this.meridian="AM":("pm"===this.meridian||"p"===this.meridian)&&(this.meridian="PM"),"AM"!==this.meridian&&"PM"!==this.meridian&&(this.meridian="AM")):this.hour>=24?this.hour=23:0>this.hour&&(this.hour=0),0>this.minute?this.minute=0:this.minute>=60&&(this.minute=59),this.options.showSeconds&&(isNaN(this.second)?this.second=0:0>this.second?this.second=0:this.second>=60&&(this.second=59)),this.update()},blurElement:function(){this.highlightedUnit=void 0,this.updateFromElementVal()},decrementHour:function(){if(this.options.showMeridian)if(1===this.hour)this.hour=12;else{if(12===this.hour)return this.hour--,this.toggleMeridian();if(0===this.hour)return this.hour=11,this.toggleMeridian();this.hour--}else 0===this.hour?this.hour=23:this.hour--;this.update()},decrementMinute:function(t){var e=t?this.minute-t:this.minute-this.options.minuteStep;0>e?(this.decrementHour(),this.minute=e+60):this.minute=e,this.update()},decrementSecond:function(){var t=this.second-this.options.secondStep;0>t?(this.decrementMinute(!0),this.second=t+60):this.second=t,this.update()},onKeydown:function(t){switch(t.keyCode){case 9:switch(this.updateFromElementVal(),this.highlightedUnit){case"hour":t.preventDefault(),this.highlightNextUnit();break;case"minute":(this.options.showMeridian||this.options.showSeconds)&&(t.preventDefault(),this.highlightNextUnit());break;case"second":this.options.showMeridian&&(t.preventDefault(),this.highlightNextUnit())}break;case 27:this.updateFromElementVal();break;case 37:t.preventDefault(),this.highlightPrevUnit(),this.updateFromElementVal();break;case 38:switch(t.preventDefault(),this.highlightedUnit){case"hour":this.incrementHour(),this.highlightHour();break;case"minute":this.incrementMinute(),this.highlightMinute();break;case"second":this.incrementSecond(),this.highlightSecond();break;case"meridian":this.toggleMeridian(),this.highlightMeridian()}break;case 39:t.preventDefault(),this.updateFromElementVal(),this.highlightNextUnit();break;case 40:switch(t.preventDefault(),this.highlightedUnit){case"hour":this.decrementHour(),this.highlightHour();break;case"minute":this.decrementMinute(),this.highlightMinute();break;case"second":this.decrementSecond(),this.highlightSecond();break;case"meridian":this.toggleMeridian(),this.highlightMeridian()}}},formatTime:function(t,e,i,n){return t=10>t?"0"+t:t,e=10>e?"0"+e:e,i=10>i?"0"+i:i,t+":"+e+(this.options.showSeconds?":"+i:"")+(this.options.showMeridian?" "+n:"")},getCursorPosition:function(){if("selectionStart"in this.element)return this.element.selectionStart;if(document.selection){this.element.focus();var t=document.selection.createRange(),e=document.selection.createRange().text.length;return t.moveStart("character",-this.element.value.length),t.text.length-e}},getTime:function(){return this.formatTime(this.hour,this.minute,this.second,this.meridian)},highlightUnit:function(){this.position=this.getCursorPosition(),this.position>=0&&2>=this.position?this.highlightHour():this.position>=3&&5>=this.position?this.highlightMinute():this.position>=6&&8>=this.position?this.options.showSeconds?this.highlightSecond():this.highlightMeridian():this.position>=9&&11>=this.position&&this.highlightMeridian()},highlightNextUnit:function(){switch(this.highlightedUnit){case"hour":this.highlightMinute();break;case"minute":this.options.showSeconds?this.highlightSecond():this.options.showMeridian?this.highlightMeLine truncated
|
||||
Reference in new issue
Block a user