vue_crud 0.1.9.5 → 0.1.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/vue_crud/example_generator.rb +12 -0
- data/lib/generators/vue_crud/install_generator.rb +1 -1
- data/lib/generators/vue_crud/pace_generator.rb +11 -0
- data/lib/generators/vue_crud/semantic_generator.rb +12 -0
- data/lib/generators/vue_crud/templates/assets/images/semantic-ui/flags.png +0 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/pace.min.js +1 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/semantic-ui/checkbox.js +831 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/semantic-ui/dimmer.js +708 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/semantic-ui/dropdown.js +3741 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/semantic-ui/modal.js +913 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/semantic-ui/site.js +487 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/semantic-ui/transition.js +1089 -0
- data/lib/generators/vue_crud/templates/assets/javascripts/vue.js +7402 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/pace.min.css +1 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/.DS_Store +0 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/.DS_Store +0 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/_all.scss +7 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +124 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/_form.scss +1706 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/_grid.scss +84 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/_grid_bk.scss +2032 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/_menu.scss +2021 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/_message.scss +482 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/_mixins.scss +3 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/_table.scss +1108 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/mixins/.DS_Store +0 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/mixins/_clearfix.scss +1 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/mixins/_grid-framework.scss +1 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/collections/mixins/_grid.scss +1 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_all.scss +15 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_button.scss +3470 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_container.scss +148 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_divider.scss +262 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_flag.scss +1031 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_header.scss +721 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_icon.scss +3148 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_image.scss +306 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_input.scss +517 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_label.scss +1314 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_list.scss +951 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_loader.scss +349 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_rail.scss +152 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_reveal.scss +307 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_segment.scss +799 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/elements/_step.scss +646 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/globals/_all.scss +3 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/globals/_reset.scss +424 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/globals/_site.scss +163 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/globals/_variables.scss +32 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_accordion.scss +256 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_all.scss +17 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_checkbox.scss +627 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_dimmer.scss +199 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_dropdown.scss +1425 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_embed.scss +167 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_modal.scss +509 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_nag.scss +147 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_popup.scss +764 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_progress.scss +516 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_rating.scss +265 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_search.scss +409 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_shape.scss +157 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_sidebar.scss +644 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_sticky.scss +78 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_tab.scss +91 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_transition.scss +1981 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/modules/_video.scss +125 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/views/_ad.scss +276 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/views/_all.scss +6 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/views/_card.scss +685 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/views/_comment.scss +270 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/views/_feed.scss +300 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/views/_item.scss +481 -0
- data/lib/generators/vue_crud/templates/assets/stylesheets/semantic-ui/views/_statistic.scss +583 -0
- data/lib/generators/vue_crud/templates/example/user.rb +10 -0
- data/lib/generators/vue_crud/templates/example/users/index.html.erb +154 -0
- data/lib/generators/vue_crud/templates/example/users/index.json.jbuilder +15 -0
- data/lib/generators/vue_crud/templates/example/users/show.json.jbuilder +11 -0
- data/lib/generators/vue_crud/templates/example/users_controller.rb +85 -0
- data/lib/generators/vue_crud/vuejs_generator.rb +10 -0
- data/lib/vue_crud/version.rb +1 -1
- data/vendor/assets/javascripts/vue_crud.js +24 -3
- data/vendor/assets/stylesheets/vue_crud.css +0 -2
- metadata +80 -6
- data/vue_crud-0.1.5.gem +0 -0
- data/vue_crud-0.1.6.gem +0 -0
- data/vue_crud-0.1.7.gem +0 -0
- data/vue_crud-0.1.8.gem +0 -0
- data/vue_crud-0.1.9.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96058cd1c27f7d9aad734504b8d942f396bd01a3
|
4
|
+
data.tar.gz: 033ea989c8713bab176953563887600208de6411
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ff490a536aff1ef8010363ec9db58a6687abd94a54e0b923ba5b89274ddb989758643483d0366131993e499f27c77629dff6c2ff1e1b4c82d1d3827943122b4
|
7
|
+
data.tar.gz: 4589b4036119ace6a8c4f57031f0ab642f7ea2e5f683e3e6aec84ea12323a437bdd1c8037b5ff68fb98362a8f9f86037e2958fe36ad11060e96707c71e68a767
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
module VueCrud
|
3
|
+
class ExampleGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../templates/example", __FILE__)
|
5
|
+
|
6
|
+
def copy_template_file
|
7
|
+
copy_file "user.rb", "public/vue_crud_example/user.rb"
|
8
|
+
copy_file "users_controller.rb", "public/vue_crud_example/users_controller.rb"
|
9
|
+
directory 'users', "public/vue_crud_example/users"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
module VueCrud
|
3
|
+
class PaceGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../templates/assets", __FILE__)
|
5
|
+
|
6
|
+
def copy_template_file
|
7
|
+
copy_file "javascripts/pace.min.js", "app/assets/javascripts/pace.min.js"
|
8
|
+
copy_file "stylesheets/pace.min.css", "app/assets/stylesheets/pace.min.css"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
module VueCrud
|
3
|
+
class SemanticGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../templates/assets", __FILE__)
|
5
|
+
|
6
|
+
def copy_semantic
|
7
|
+
directory 'javascripts/semantic-ui', 'app/assets/javascripts/semantic-ui'
|
8
|
+
directory 'stylesheets/semantic-ui', 'app/assets/stylesheets/semantic-ui'
|
9
|
+
directory 'images/semantic-ui', 'app/assets/images/semantic-ui'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(){var t,e,n,r,s,o,i,u,a,c,l,p,h,g,f,d,m,y,v,w,b,k,S,q,L,x,T,R,P,E,j,M,A,N,O,_,F,C,U,W,X,I,D,H,z,B,G,J,Q,K=[].slice,V={}.hasOwnProperty,Y=function(t,e){function n(){this.constructor=t}for(var r in e)V.call(e,r)&&(t[r]=e[r]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},Z=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};for(b={catchupTime:100,initialRate:.03,minTime:250,ghostTime:100,maxProgressPerFrame:20,easeFactor:1.25,startOnPageLoad:!0,restartOnPushState:!0,restartOnRequestAfter:500,target:"body",elements:{checkInterval:100,selectors:["body"]},eventLag:{minSamples:10,sampleCount:3,lagThreshold:3},ajax:{trackMethods:["GET"],trackWebSockets:!0,ignoreURLs:[]}},P=function(){var t;return null!=(t="undefined"!=typeof performance&&null!==performance&&"function"==typeof performance.now?performance.now():void 0)?t:+new Date},j=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,w=window.cancelAnimationFrame||window.mozCancelAnimationFrame,null==j&&(j=function(t){return setTimeout(t,50)},w=function(t){return clearTimeout(t)}),A=function(t){var e,n;return e=P(),(n=function(){var r;return r=P()-e,r>=33?(e=P(),t(r,function(){return j(n)})):setTimeout(n,33-r)})()},M=function(){var t,e,n;return n=arguments[0],e=arguments[1],t=3<=arguments.length?K.call(arguments,2):[],"function"==typeof n[e]?n[e].apply(n,t):n[e]},k=function(){var t,e,n,r,s,o,i;for(e=arguments[0],r=2<=arguments.length?K.call(arguments,1):[],o=0,i=r.length;i>o;o++)if(n=r[o])for(t in n)V.call(n,t)&&(s=n[t],null!=e[t]&&"object"==typeof e[t]&&null!=s&&"object"==typeof s?k(e[t],s):e[t]=s);return e},m=function(t){var e,n,r,s,o;for(n=e=0,s=0,o=t.length;o>s;s++)r=t[s],n+=Math.abs(r),e++;return n/e},q=function(t,e){var n,r,s;if(null==t&&(t="options"),null==e&&(e=!0),s=document.querySelector("[data-pace-"+t+"]")){if(n=s.getAttribute("data-pace-"+t),!e)return n;try{return JSON.parse(n)}catch(o){return r=o,"undefined"!=typeof console&&null!==console?console.error("Error parsing inline pace options",r):void 0}}},i=function(){function t(){}return t.prototype.on=function(t,e,n,r){var s;return null==r&&(r=!1),null==this.bindings&&(this.bindings={}),null==(s=this.bindings)[t]&&(s[t]=[]),this.bindings[t].push({handler:e,ctx:n,once:r})},t.prototype.once=function(t,e,n){return this.on(t,e,n,!0)},t.prototype.off=function(t,e){var n,r,s;if(null!=(null!=(r=this.bindings)?r[t]:void 0)){if(null==e)return delete this.bindings[t];for(n=0,s=[];n<this.bindings[t].length;)s.push(this.bindings[t][n].handler===e?this.bindings[t].splice(n,1):n++);return s}},t.prototype.trigger=function(){var t,e,n,r,s,o,i,u,a;if(n=arguments[0],t=2<=arguments.length?K.call(arguments,1):[],null!=(i=this.bindings)?i[n]:void 0){for(s=0,a=[];s<this.bindings[n].length;)u=this.bindings[n][s],r=u.handler,e=u.ctx,o=u.once,r.apply(null!=e?e:this,t),a.push(o?this.bindings[n].splice(s,1):s++);return a}},t}(),c=window.Pace||{},window.Pace=c,k(c,i.prototype),E=c.options=k({},b,window.paceOptions,q()),G=["ajax","document","eventLag","elements"],D=0,z=G.length;z>D;D++)F=G[D],E[F]===!0&&(E[F]=b[F]);a=function(t){function e(){return J=e.__super__.constructor.apply(this,arguments)}return Y(e,t),e}(Error),e=function(){function t(){this.progress=0}return t.prototype.getElement=function(){var t;if(null==this.el){if(t=document.querySelector(E.target),!t)throw new a;this.el=document.createElement("div"),this.el.className="pace pace-active",document.body.className=document.body.className.replace(/pace-done/g,""),document.body.className+=" pace-running",this.el.innerHTML='<div class="pace-progress">\n <div class="pace-progress-inner"></div>\n</div>\n<div class="pace-activity"></div>',null!=t.firstChild?t.insertBefore(this.el,t.firstChild):t.appendChild(this.el)}return this.el},t.prototype.finish=function(){var t;return t=this.getElement(),t.className=t.className.replace("pace-active",""),t.className+=" pace-inactive",document.body.className=document.body.className.replace("pace-running",""),document.body.className+=" pace-done"},t.prototype.update=function(t){return this.progress=t,this.render()},t.prototype.destroy=function(){try{this.getElement().parentNode.removeChild(this.getElement())}catch(t){a=t}return this.el=void 0},t.prototype.render=function(){var t,e,n,r,s,o,i;if(null==document.querySelector(E.target))return!1;for(t=this.getElement(),r="translate3d("+this.progress+"%, 0, 0)",i=["webkitTransform","msTransform","transform"],s=0,o=i.length;o>s;s++)e=i[s],t.children[0].style[e]=r;var u=document.getElementById("form-progress");return"undefined"!=typeof u&&null!=u&&(u.value=0|this.progress,jQuery(u).change()),(!this.lastRenderedProgress||this.lastRenderedProgress|0!==this.progress|0)&&(t.children[0].setAttribute("data-progress-text",""+(0|this.progress)+"%"),this.progress>=100?n="99":(n=this.progress<10?"0":"",n+=0|this.progress),t.children[0].setAttribute("data-progress",""+n)),this.lastRenderedProgress=this.progress},t.prototype.done=function(){return this.progress>=100},t}(),u=function(){function t(){this.bindings={}}return t.prototype.trigger=function(t,e){var n,r,s,o,i;if(null!=this.bindings[t]){for(o=this.bindings[t],i=[],r=0,s=o.length;s>r;r++)n=o[r],i.push(n.call(this,e));return i}},t.prototype.on=function(t,e){var n;return null==(n=this.bindings)[t]&&(n[t]=[]),this.bindings[t].push(e)},t}(),I=window.XMLHttpRequest,X=window.XDomainRequest,W=window.WebSocket,S=function(t,e){var n,r,s,o;o=[];for(r in e.prototype)try{s=e.prototype[r],o.push(null==t[r]&&"function"!=typeof s?t[r]=s:void 0)}catch(i){n=i}return o},T=[],c.ignore=function(){var t,e,n;return e=arguments[0],t=2<=arguments.length?K.call(arguments,1):[],T.unshift("ignore"),n=e.apply(null,t),T.shift(),n},c.track=function(){var t,e,n;return e=arguments[0],t=2<=arguments.length?K.call(arguments,1):[],T.unshift("track"),n=e.apply(null,t),T.shift(),n},_=function(t){var e;if(null==t&&(t="GET"),"track"===T[0])return"force";if(!T.length&&E.ajax){if("socket"===t&&E.ajax.trackWebSockets)return!0;if(e=t.toUpperCase(),Z.call(E.ajax.trackMethods,e)>=0)return!0}return!1},l=function(t){function e(){var t,n=this;e.__super__.constructor.apply(this,arguments),t=function(t){var e;return e=t.open,t.open=function(r,s){return _(r)&&n.trigger("request",{type:r,url:s,request:t}),e.apply(t,arguments)}},window.XMLHttpRequest=function(e){var n;return n=new I(e),t(n),n};try{S(window.XMLHttpRequest,I)}catch(r){}if(null!=X){window.XDomainRequest=function(){var e;return e=new X,t(e),e};try{S(window.XDomainRequest,X)}catch(r){}}if(null!=W&&E.ajax.trackWebSockets){window.WebSocket=function(t,e){var r;return r=null!=e?new W(t,e):new W(t),_("socket")&&n.trigger("request",{type:"socket",url:t,protocols:e,request:r}),r};try{S(window.WebSocket,W)}catch(r){}}}return Y(e,t),e}(u),H=null,L=function(){return null==H&&(H=new l),H},O=function(t){var e,n,r,s;for(s=E.ajax.ignoreURLs,n=0,r=s.length;r>n;n++)if(e=s[n],"string"==typeof e){if(-1!==t.indexOf(e))return!0}else if(e.test(t))return!0;return!1},L().on("request",function(e){var n,r,s,o,i;return o=e.type,s=e.request,i=e.url,O(i)?void 0:c.running||E.restartOnRequestAfter===!1&&"force"!==_(o)?void 0:(r=arguments,n=E.restartOnRequestAfter||0,"boolean"==typeof n&&(n=0),setTimeout(function(){var e,n,i,u,a,l;if(e="socket"===o?s.readyState<2:0<(u=s.readyState)&&4>u){for(c.restart(),a=c.sources,l=[],n=0,i=a.length;i>n;n++){if(F=a[n],F instanceof t){F.watch.apply(F,r);break}l.push(void 0)}return l}},n))}),t=function(){function t(){var t=this;this.elements=[],L().on("request",function(){return t.watch.apply(t,arguments)})}return t.prototype.watch=function(t){var e,n,r,s;return r=t.type,e=t.request,s=t.url,O(s)?void 0:(n="socket"===r?new g(e):new f(e),this.elements.push(n))},t}(),f=function(){function t(t){var e,n,r,s,o,i,u=this;if(this.progress=0,null!=window.ProgressEvent)for(n=null,t.addEventListener("progress",function(t){return u.progress=t.lengthComputable?100*t.loaded/t.total:u.progress+(100-u.progress)/2},!1),i=["load","abort","timeout","error"],r=0,s=i.length;s>r;r++)e=i[r],t.addEventListener(e,function(){return u.progress=100},!1);else o=t.onreadystatechange,t.onreadystatechange=function(){var e;return 0===(e=t.readyState)||4===e?u.progress=100:3===t.readyState&&(u.progress=50),"function"==typeof o?o.apply(null,arguments):void 0}}return t}(),g=function(){function t(t){var e,n,r,s,o=this;for(this.progress=0,s=["error","open"],n=0,r=s.length;r>n;n++)e=s[n],t.addEventListener(e,function(){return o.progress=100},!1)}return t}(),r=function(){function t(t){var e,n,r,o;for(null==t&&(t={}),this.elements=[],null==t.selectors&&(t.selectors=[]),o=t.selectors,n=0,r=o.length;r>n;n++)e=o[n],this.elements.push(new s(e))}return t}(),s=function(){function t(t){this.selector=t,this.progress=0,this.check()}return t.prototype.check=function(){var t=this;return document.querySelector(this.selector)?this.done():setTimeout(function(){return t.check()},E.elements.checkInterval)},t.prototype.done=function(){return this.progress=100},t}(),n=function(){function t(){var t,e,n=this;this.progress=null!=(e=this.states[document.readyState])?e:100,t=document.onreadystatechange,document.onreadystatechange=function(){return null!=n.states[document.readyState]&&(n.progress=n.states[document.readyState]),"function"==typeof t?t.apply(null,arguments):void 0}}return t.prototype.states={loading:0,interactive:50,complete:100},t}(),o=function(){function t(){var t,e,n,r,s,o=this;this.progress=0,t=0,s=[],r=0,n=P(),e=setInterval(function(){var i;return i=P()-n-50,n=P(),s.push(i),s.length>E.eventLag.sampleCount&&s.shift(),t=m(s),++r>=E.eventLag.minSamples&&t<E.eventLag.lagThreshold?(o.progress=100,clearInterval(e)):o.progress=100*(3/(t+3))},50)}return t}(),h=function(){function t(t){this.source=t,this.last=this.sinceLastUpdate=0,this.rate=E.initialRate,this.catchup=0,this.progress=this.lastProgress=0,null!=this.source&&(this.progress=M(this.source,"progress"))}return t.prototype.tick=function(t,e){var n;return null==e&&(e=M(this.source,"progress")),e>=100&&(this.done=!0),e===this.last?this.sinceLastUpdate+=t:(this.sinceLastUpdate&&(this.rate=(e-this.last)/this.sinceLastUpdate),this.catchup=(e-this.progress)/E.catchupTime,this.sinceLastUpdate=0,this.last=e),e>this.progress&&(this.progress+=this.catchup*t),n=1-Math.pow(this.progress/100,E.easeFactor),this.progress+=n*this.rate*t,this.progress=Math.min(this.lastProgress+E.maxProgressPerFrame,this.progress),this.progress=Math.max(0,this.progress),this.progress=Math.min(100,this.progress),this.lastProgress=this.progress,this.progress},t}(),C=null,N=null,y=null,U=null,d=null,v=null,c.running=!1,x=function(){return E.restartOnPushState?c.restart():void 0},null!=window.history.pushState&&(B=window.history.pushState,window.history.pushState=function(){return x(),B.apply(window.history,arguments)}),null!=window.history.replaceState&&(Q=window.history.replaceState,window.history.replaceState=function(){return x(),Q.apply(window.history,arguments)}),p={ajax:t,elements:r,document:n,eventLag:o},(R=function(){var t,n,r,s,o,i,u,a;for(c.sources=C=[],i=["ajax","elements","document","eventLag"],n=0,s=i.length;s>n;n++)t=i[n],E[t]!==!1&&C.push(new p[t](E[t]));for(a=null!=(u=E.extraSources)?u:[],r=0,o=a.length;o>r;r++)F=a[r],C.push(new F(E));return c.bar=y=new e,N=[],U=new h})(),c.stop=function(){return c.trigger("stop"),c.running=!1,y.destroy(),v=!0,null!=d&&("function"==typeof w&&w(d),d=null),R()},c.restart=function(){return c.trigger("restart"),c.stop(),c.start()},c.go=function(){var t;return c.running=!0,y.render(),t=P(),v=!1,d=A(function(e,n){var r,s,o,i,u,a,l,p,g,f,d,m,w,b,k,S;for(p=100-y.progress,s=d=0,o=!0,a=m=0,b=C.length;b>m;a=++m)for(F=C[a],f=null!=N[a]?N[a]:N[a]=[],u=null!=(S=F.elements)?S:[F],l=w=0,k=u.length;k>w;l=++w)i=u[l],g=null!=f[l]?f[l]:f[l]=new h(i),o&=g.done,g.done||(s++,d+=g.tick(e));return r=d/s,y.update(U.tick(e,r)),y.done()||o||v?(y.update(100),c.trigger("done"),setTimeout(function(){return y.finish(),c.running=!1,c.trigger("hide")},Math.max(E.ghostTime,Math.max(E.minTime-(P()-t),0)))):n()})},c.start=function(t){k(E,t),c.running=!0;try{y.render()}catch(e){a=e}return document.querySelector(".pace")?(c.trigger("start"),c.go()):setTimeout(c.start,50)},"function"==typeof define&&define.amd?define(function(){return c}):"object"==typeof exports?module.exports=c:E.startOnPageLoad&&c.start()}).call(this);
|
@@ -0,0 +1,831 @@
|
|
1
|
+
/*!
|
2
|
+
* # Semantic UI - Checkbox
|
3
|
+
* http://github.com/semantic-org/semantic-ui/
|
4
|
+
*
|
5
|
+
*
|
6
|
+
* Released under the MIT license
|
7
|
+
* http://opensource.org/licenses/MIT
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
;(function ($, window, document, undefined) {
|
12
|
+
|
13
|
+
"use strict";
|
14
|
+
|
15
|
+
window = (typeof window != 'undefined' && window.Math == Math)
|
16
|
+
? window
|
17
|
+
: (typeof self != 'undefined' && self.Math == Math)
|
18
|
+
? self
|
19
|
+
: Function('return this')()
|
20
|
+
;
|
21
|
+
|
22
|
+
$.fn.checkbox = function(parameters) {
|
23
|
+
var
|
24
|
+
$allModules = $(this),
|
25
|
+
moduleSelector = $allModules.selector || '',
|
26
|
+
|
27
|
+
time = new Date().getTime(),
|
28
|
+
performance = [],
|
29
|
+
|
30
|
+
query = arguments[0],
|
31
|
+
methodInvoked = (typeof query == 'string'),
|
32
|
+
queryArguments = [].slice.call(arguments, 1),
|
33
|
+
returnedValue
|
34
|
+
;
|
35
|
+
|
36
|
+
$allModules
|
37
|
+
.each(function() {
|
38
|
+
var
|
39
|
+
settings = $.extend(true, {}, $.fn.checkbox.settings, parameters),
|
40
|
+
|
41
|
+
className = settings.className,
|
42
|
+
namespace = settings.namespace,
|
43
|
+
selector = settings.selector,
|
44
|
+
error = settings.error,
|
45
|
+
|
46
|
+
eventNamespace = '.' + namespace,
|
47
|
+
moduleNamespace = 'module-' + namespace,
|
48
|
+
|
49
|
+
$module = $(this),
|
50
|
+
$label = $(this).children(selector.label),
|
51
|
+
$input = $(this).children(selector.input),
|
52
|
+
input = $input[0],
|
53
|
+
|
54
|
+
initialLoad = false,
|
55
|
+
shortcutPressed = false,
|
56
|
+
instance = $module.data(moduleNamespace),
|
57
|
+
|
58
|
+
observer,
|
59
|
+
element = this,
|
60
|
+
module
|
61
|
+
;
|
62
|
+
|
63
|
+
module = {
|
64
|
+
|
65
|
+
initialize: function() {
|
66
|
+
module.verbose('Initializing checkbox', settings);
|
67
|
+
|
68
|
+
module.create.label();
|
69
|
+
module.bind.events();
|
70
|
+
|
71
|
+
module.set.tabbable();
|
72
|
+
module.hide.input();
|
73
|
+
|
74
|
+
module.observeChanges();
|
75
|
+
module.instantiate();
|
76
|
+
module.setup();
|
77
|
+
},
|
78
|
+
|
79
|
+
instantiate: function() {
|
80
|
+
module.verbose('Storing instance of module', module);
|
81
|
+
instance = module;
|
82
|
+
$module
|
83
|
+
.data(moduleNamespace, module)
|
84
|
+
;
|
85
|
+
},
|
86
|
+
|
87
|
+
destroy: function() {
|
88
|
+
module.verbose('Destroying module');
|
89
|
+
module.unbind.events();
|
90
|
+
module.show.input();
|
91
|
+
$module.removeData(moduleNamespace);
|
92
|
+
},
|
93
|
+
|
94
|
+
fix: {
|
95
|
+
reference: function() {
|
96
|
+
if( $module.is(selector.input) ) {
|
97
|
+
module.debug('Behavior called on <input> adjusting invoked element');
|
98
|
+
$module = $module.closest(selector.checkbox);
|
99
|
+
module.refresh();
|
100
|
+
}
|
101
|
+
}
|
102
|
+
},
|
103
|
+
|
104
|
+
setup: function() {
|
105
|
+
module.set.initialLoad();
|
106
|
+
if( module.is.indeterminate() ) {
|
107
|
+
module.debug('Initial value is indeterminate');
|
108
|
+
module.indeterminate();
|
109
|
+
}
|
110
|
+
else if( module.is.checked() ) {
|
111
|
+
module.debug('Initial value is checked');
|
112
|
+
module.check();
|
113
|
+
}
|
114
|
+
else {
|
115
|
+
module.debug('Initial value is unchecked');
|
116
|
+
module.uncheck();
|
117
|
+
}
|
118
|
+
module.remove.initialLoad();
|
119
|
+
},
|
120
|
+
|
121
|
+
refresh: function() {
|
122
|
+
$label = $module.children(selector.label);
|
123
|
+
$input = $module.children(selector.input);
|
124
|
+
input = $input[0];
|
125
|
+
},
|
126
|
+
|
127
|
+
hide: {
|
128
|
+
input: function() {
|
129
|
+
module.verbose('Modifying <input> z-index to be unselectable');
|
130
|
+
$input.addClass(className.hidden);
|
131
|
+
}
|
132
|
+
},
|
133
|
+
show: {
|
134
|
+
input: function() {
|
135
|
+
module.verbose('Modifying <input> z-index to be selectable');
|
136
|
+
$input.removeClass(className.hidden);
|
137
|
+
}
|
138
|
+
},
|
139
|
+
|
140
|
+
observeChanges: function() {
|
141
|
+
if('MutationObserver' in window) {
|
142
|
+
observer = new MutationObserver(function(mutations) {
|
143
|
+
module.debug('DOM tree modified, updating selector cache');
|
144
|
+
module.refresh();
|
145
|
+
});
|
146
|
+
observer.observe(element, {
|
147
|
+
childList : true,
|
148
|
+
subtree : true
|
149
|
+
});
|
150
|
+
module.debug('Setting up mutation observer', observer);
|
151
|
+
}
|
152
|
+
},
|
153
|
+
|
154
|
+
attachEvents: function(selector, event) {
|
155
|
+
var
|
156
|
+
$element = $(selector)
|
157
|
+
;
|
158
|
+
event = $.isFunction(module[event])
|
159
|
+
? module[event]
|
160
|
+
: module.toggle
|
161
|
+
;
|
162
|
+
if($element.length > 0) {
|
163
|
+
module.debug('Attaching checkbox events to element', selector, event);
|
164
|
+
$element
|
165
|
+
.on('click' + eventNamespace, event)
|
166
|
+
;
|
167
|
+
}
|
168
|
+
else {
|
169
|
+
module.error(error.notFound);
|
170
|
+
}
|
171
|
+
},
|
172
|
+
|
173
|
+
event: {
|
174
|
+
click: function(event) {
|
175
|
+
var
|
176
|
+
$target = $(event.target)
|
177
|
+
;
|
178
|
+
if( $target.is(selector.input) ) {
|
179
|
+
module.verbose('Using default check action on initialized checkbox');
|
180
|
+
return;
|
181
|
+
}
|
182
|
+
if( $target.is(selector.link) ) {
|
183
|
+
module.debug('Clicking link inside checkbox, skipping toggle');
|
184
|
+
return;
|
185
|
+
}
|
186
|
+
module.toggle();
|
187
|
+
$input.focus();
|
188
|
+
event.preventDefault();
|
189
|
+
},
|
190
|
+
keydown: function(event) {
|
191
|
+
var
|
192
|
+
key = event.which,
|
193
|
+
keyCode = {
|
194
|
+
enter : 13,
|
195
|
+
space : 32,
|
196
|
+
escape : 27
|
197
|
+
}
|
198
|
+
;
|
199
|
+
if(key == keyCode.escape) {
|
200
|
+
module.verbose('Escape key pressed blurring field');
|
201
|
+
$input.blur();
|
202
|
+
shortcutPressed = true;
|
203
|
+
}
|
204
|
+
else if(!event.ctrlKey && ( key == keyCode.space || key == keyCode.enter) ) {
|
205
|
+
module.verbose('Enter/space key pressed, toggling checkbox');
|
206
|
+
module.toggle();
|
207
|
+
shortcutPressed = true;
|
208
|
+
}
|
209
|
+
else {
|
210
|
+
shortcutPressed = false;
|
211
|
+
}
|
212
|
+
},
|
213
|
+
keyup: function(event) {
|
214
|
+
if(shortcutPressed) {
|
215
|
+
event.preventDefault();
|
216
|
+
}
|
217
|
+
}
|
218
|
+
},
|
219
|
+
|
220
|
+
check: function() {
|
221
|
+
if( !module.should.allowCheck() ) {
|
222
|
+
return;
|
223
|
+
}
|
224
|
+
module.debug('Checking checkbox', $input);
|
225
|
+
module.set.checked();
|
226
|
+
if( !module.should.ignoreCallbacks() ) {
|
227
|
+
settings.onChecked.call(input);
|
228
|
+
settings.onChange.call(input);
|
229
|
+
}
|
230
|
+
},
|
231
|
+
|
232
|
+
uncheck: function() {
|
233
|
+
if( !module.should.allowUncheck() ) {
|
234
|
+
return;
|
235
|
+
}
|
236
|
+
module.debug('Unchecking checkbox');
|
237
|
+
module.set.unchecked();
|
238
|
+
if( !module.should.ignoreCallbacks() ) {
|
239
|
+
settings.onUnchecked.call(input);
|
240
|
+
settings.onChange.call(input);
|
241
|
+
}
|
242
|
+
},
|
243
|
+
|
244
|
+
indeterminate: function() {
|
245
|
+
if( module.should.allowIndeterminate() ) {
|
246
|
+
module.debug('Checkbox is already indeterminate');
|
247
|
+
return;
|
248
|
+
}
|
249
|
+
module.debug('Making checkbox indeterminate');
|
250
|
+
module.set.indeterminate();
|
251
|
+
if( !module.should.ignoreCallbacks() ) {
|
252
|
+
settings.onIndeterminate.call(input);
|
253
|
+
settings.onChange.call(input);
|
254
|
+
}
|
255
|
+
},
|
256
|
+
|
257
|
+
determinate: function() {
|
258
|
+
if( module.should.allowDeterminate() ) {
|
259
|
+
module.debug('Checkbox is already determinate');
|
260
|
+
return;
|
261
|
+
}
|
262
|
+
module.debug('Making checkbox determinate');
|
263
|
+
module.set.determinate();
|
264
|
+
if( !module.should.ignoreCallbacks() ) {
|
265
|
+
settings.onDeterminate.call(input);
|
266
|
+
settings.onChange.call(input);
|
267
|
+
}
|
268
|
+
},
|
269
|
+
|
270
|
+
enable: function() {
|
271
|
+
if( module.is.enabled() ) {
|
272
|
+
module.debug('Checkbox is already enabled');
|
273
|
+
return;
|
274
|
+
}
|
275
|
+
module.debug('Enabling checkbox');
|
276
|
+
module.set.enabled();
|
277
|
+
settings.onEnable.call(input);
|
278
|
+
// preserve legacy callbacks
|
279
|
+
settings.onEnabled.call(input);
|
280
|
+
},
|
281
|
+
|
282
|
+
disable: function() {
|
283
|
+
if( module.is.disabled() ) {
|
284
|
+
module.debug('Checkbox is already disabled');
|
285
|
+
return;
|
286
|
+
}
|
287
|
+
module.debug('Disabling checkbox');
|
288
|
+
module.set.disabled();
|
289
|
+
settings.onDisable.call(input);
|
290
|
+
// preserve legacy callbacks
|
291
|
+
settings.onDisabled.call(input);
|
292
|
+
},
|
293
|
+
|
294
|
+
get: {
|
295
|
+
radios: function() {
|
296
|
+
var
|
297
|
+
name = module.get.name()
|
298
|
+
;
|
299
|
+
return $('input[name="' + name + '"]').closest(selector.checkbox);
|
300
|
+
},
|
301
|
+
otherRadios: function() {
|
302
|
+
return module.get.radios().not($module);
|
303
|
+
},
|
304
|
+
name: function() {
|
305
|
+
return $input.attr('name');
|
306
|
+
}
|
307
|
+
},
|
308
|
+
|
309
|
+
is: {
|
310
|
+
initialLoad: function() {
|
311
|
+
return initialLoad;
|
312
|
+
},
|
313
|
+
radio: function() {
|
314
|
+
return ($input.hasClass(className.radio) || $input.attr('type') == 'radio');
|
315
|
+
},
|
316
|
+
indeterminate: function() {
|
317
|
+
return $input.prop('indeterminate') !== undefined && $input.prop('indeterminate');
|
318
|
+
},
|
319
|
+
checked: function() {
|
320
|
+
return $input.prop('checked') !== undefined && $input.prop('checked');
|
321
|
+
},
|
322
|
+
disabled: function() {
|
323
|
+
return $input.prop('disabled') !== undefined && $input.prop('disabled');
|
324
|
+
},
|
325
|
+
enabled: function() {
|
326
|
+
return !module.is.disabled();
|
327
|
+
},
|
328
|
+
determinate: function() {
|
329
|
+
return !module.is.indeterminate();
|
330
|
+
},
|
331
|
+
unchecked: function() {
|
332
|
+
return !module.is.checked();
|
333
|
+
}
|
334
|
+
},
|
335
|
+
|
336
|
+
should: {
|
337
|
+
allowCheck: function() {
|
338
|
+
if(module.is.determinate() && module.is.checked() && !module.should.forceCallbacks() ) {
|
339
|
+
module.debug('Should not allow check, checkbox is already checked');
|
340
|
+
return false;
|
341
|
+
}
|
342
|
+
if(settings.beforeChecked.apply(input) === false) {
|
343
|
+
module.debug('Should not allow check, beforeChecked cancelled');
|
344
|
+
return false;
|
345
|
+
}
|
346
|
+
return true;
|
347
|
+
},
|
348
|
+
allowUncheck: function() {
|
349
|
+
if(module.is.determinate() && module.is.unchecked() && !module.should.forceCallbacks() ) {
|
350
|
+
module.debug('Should not allow uncheck, checkbox is already unchecked');
|
351
|
+
return false;
|
352
|
+
}
|
353
|
+
if(settings.beforeUnchecked.apply(input) === false) {
|
354
|
+
module.debug('Should not allow uncheck, beforeUnchecked cancelled');
|
355
|
+
return false;
|
356
|
+
}
|
357
|
+
return true;
|
358
|
+
},
|
359
|
+
allowIndeterminate: function() {
|
360
|
+
if(module.is.indeterminate() && !module.should.forceCallbacks() ) {
|
361
|
+
module.debug('Should not allow indeterminate, checkbox is already indeterminate');
|
362
|
+
return false;
|
363
|
+
}
|
364
|
+
if(settings.beforeIndeterminate.apply(input) === false) {
|
365
|
+
module.debug('Should not allow indeterminate, beforeIndeterminate cancelled');
|
366
|
+
return false;
|
367
|
+
}
|
368
|
+
return true;
|
369
|
+
},
|
370
|
+
allowDeterminate: function() {
|
371
|
+
if(module.is.determinate() && !module.should.forceCallbacks() ) {
|
372
|
+
module.debug('Should not allow determinate, checkbox is already determinate');
|
373
|
+
return false;
|
374
|
+
}
|
375
|
+
if(settings.beforeDeterminate.apply(input) === false) {
|
376
|
+
module.debug('Should not allow determinate, beforeDeterminate cancelled');
|
377
|
+
return false;
|
378
|
+
}
|
379
|
+
return true;
|
380
|
+
},
|
381
|
+
forceCallbacks: function() {
|
382
|
+
return (module.is.initialLoad() && settings.fireOnInit);
|
383
|
+
},
|
384
|
+
ignoreCallbacks: function() {
|
385
|
+
return (initialLoad && !settings.fireOnInit);
|
386
|
+
}
|
387
|
+
},
|
388
|
+
|
389
|
+
can: {
|
390
|
+
change: function() {
|
391
|
+
return !( $module.hasClass(className.disabled) || $module.hasClass(className.readOnly) || $input.prop('disabled') || $input.prop('readonly') );
|
392
|
+
},
|
393
|
+
uncheck: function() {
|
394
|
+
return (typeof settings.uncheckable === 'boolean')
|
395
|
+
? settings.uncheckable
|
396
|
+
: !module.is.radio()
|
397
|
+
;
|
398
|
+
}
|
399
|
+
},
|
400
|
+
|
401
|
+
set: {
|
402
|
+
initialLoad: function() {
|
403
|
+
initialLoad = true;
|
404
|
+
},
|
405
|
+
checked: function() {
|
406
|
+
module.verbose('Setting class to checked');
|
407
|
+
$module
|
408
|
+
.removeClass(className.indeterminate)
|
409
|
+
.addClass(className.checked)
|
410
|
+
;
|
411
|
+
if( module.is.radio() ) {
|
412
|
+
module.uncheckOthers();
|
413
|
+
}
|
414
|
+
if(!module.is.indeterminate() && module.is.checked()) {
|
415
|
+
module.debug('Input is already checked, skipping input property change');
|
416
|
+
return;
|
417
|
+
}
|
418
|
+
module.verbose('Setting state to checked', input);
|
419
|
+
$input
|
420
|
+
.prop('indeterminate', false)
|
421
|
+
.prop('checked', true)
|
422
|
+
;
|
423
|
+
module.trigger.change();
|
424
|
+
},
|
425
|
+
unchecked: function() {
|
426
|
+
module.verbose('Removing checked class');
|
427
|
+
$module
|
428
|
+
.removeClass(className.indeterminate)
|
429
|
+
.removeClass(className.checked)
|
430
|
+
;
|
431
|
+
if(!module.is.indeterminate() && module.is.unchecked() ) {
|
432
|
+
module.debug('Input is already unchecked');
|
433
|
+
return;
|
434
|
+
}
|
435
|
+
module.debug('Setting state to unchecked');
|
436
|
+
$input
|
437
|
+
.prop('indeterminate', false)
|
438
|
+
.prop('checked', false)
|
439
|
+
;
|
440
|
+
module.trigger.change();
|
441
|
+
},
|
442
|
+
indeterminate: function() {
|
443
|
+
module.verbose('Setting class to indeterminate');
|
444
|
+
$module
|
445
|
+
.addClass(className.indeterminate)
|
446
|
+
;
|
447
|
+
if( module.is.indeterminate() ) {
|
448
|
+
module.debug('Input is already indeterminate, skipping input property change');
|
449
|
+
return;
|
450
|
+
}
|
451
|
+
module.debug('Setting state to indeterminate');
|
452
|
+
$input
|
453
|
+
.prop('indeterminate', true)
|
454
|
+
;
|
455
|
+
module.trigger.change();
|
456
|
+
},
|
457
|
+
determinate: function() {
|
458
|
+
module.verbose('Removing indeterminate class');
|
459
|
+
$module
|
460
|
+
.removeClass(className.indeterminate)
|
461
|
+
;
|
462
|
+
if( module.is.determinate() ) {
|
463
|
+
module.debug('Input is already determinate, skipping input property change');
|
464
|
+
return;
|
465
|
+
}
|
466
|
+
module.debug('Setting state to determinate');
|
467
|
+
$input
|
468
|
+
.prop('indeterminate', false)
|
469
|
+
;
|
470
|
+
},
|
471
|
+
disabled: function() {
|
472
|
+
module.verbose('Setting class to disabled');
|
473
|
+
$module
|
474
|
+
.addClass(className.disabled)
|
475
|
+
;
|
476
|
+
if( module.is.disabled() ) {
|
477
|
+
module.debug('Input is already disabled, skipping input property change');
|
478
|
+
return;
|
479
|
+
}
|
480
|
+
module.debug('Setting state to disabled');
|
481
|
+
$input
|
482
|
+
.prop('disabled', 'disabled')
|
483
|
+
;
|
484
|
+
module.trigger.change();
|
485
|
+
},
|
486
|
+
enabled: function() {
|
487
|
+
module.verbose('Removing disabled class');
|
488
|
+
$module.removeClass(className.disabled);
|
489
|
+
if( module.is.enabled() ) {
|
490
|
+
module.debug('Input is already enabled, skipping input property change');
|
491
|
+
return;
|
492
|
+
}
|
493
|
+
module.debug('Setting state to enabled');
|
494
|
+
$input
|
495
|
+
.prop('disabled', false)
|
496
|
+
;
|
497
|
+
module.trigger.change();
|
498
|
+
},
|
499
|
+
tabbable: function() {
|
500
|
+
module.verbose('Adding tabindex to checkbox');
|
501
|
+
if( $input.attr('tabindex') === undefined) {
|
502
|
+
$input.attr('tabindex', 0);
|
503
|
+
}
|
504
|
+
}
|
505
|
+
},
|
506
|
+
|
507
|
+
remove: {
|
508
|
+
initialLoad: function() {
|
509
|
+
initialLoad = false;
|
510
|
+
}
|
511
|
+
},
|
512
|
+
|
513
|
+
trigger: {
|
514
|
+
change: function() {
|
515
|
+
var
|
516
|
+
events = document.createEvent('HTMLEvents'),
|
517
|
+
inputElement = $input[0]
|
518
|
+
;
|
519
|
+
if(inputElement) {
|
520
|
+
module.verbose('Triggering native change event');
|
521
|
+
events.initEvent('change', true, false);
|
522
|
+
inputElement.dispatchEvent(events);
|
523
|
+
}
|
524
|
+
}
|
525
|
+
},
|
526
|
+
|
527
|
+
|
528
|
+
create: {
|
529
|
+
label: function() {
|
530
|
+
if($input.prevAll(selector.label).length > 0) {
|
531
|
+
$input.prev(selector.label).detach().insertAfter($input);
|
532
|
+
module.debug('Moving existing label', $label);
|
533
|
+
}
|
534
|
+
else if( !module.has.label() ) {
|
535
|
+
$label = $('<label>').insertAfter($input);
|
536
|
+
module.debug('Creating label', $label);
|
537
|
+
}
|
538
|
+
}
|
539
|
+
},
|
540
|
+
|
541
|
+
has: {
|
542
|
+
label: function() {
|
543
|
+
return ($label.length > 0);
|
544
|
+
}
|
545
|
+
},
|
546
|
+
|
547
|
+
bind: {
|
548
|
+
events: function() {
|
549
|
+
module.verbose('Attaching checkbox events');
|
550
|
+
$module
|
551
|
+
.on('click' + eventNamespace, module.event.click)
|
552
|
+
.on('keydown' + eventNamespace, selector.input, module.event.keydown)
|
553
|
+
.on('keyup' + eventNamespace, selector.input, module.event.keyup)
|
554
|
+
;
|
555
|
+
}
|
556
|
+
},
|
557
|
+
|
558
|
+
unbind: {
|
559
|
+
events: function() {
|
560
|
+
module.debug('Removing events');
|
561
|
+
$module
|
562
|
+
.off(eventNamespace)
|
563
|
+
;
|
564
|
+
}
|
565
|
+
},
|
566
|
+
|
567
|
+
uncheckOthers: function() {
|
568
|
+
var
|
569
|
+
$radios = module.get.otherRadios()
|
570
|
+
;
|
571
|
+
module.debug('Unchecking other radios', $radios);
|
572
|
+
$radios.removeClass(className.checked);
|
573
|
+
},
|
574
|
+
|
575
|
+
toggle: function() {
|
576
|
+
if( !module.can.change() ) {
|
577
|
+
if(!module.is.radio()) {
|
578
|
+
module.debug('Checkbox is read-only or disabled, ignoring toggle');
|
579
|
+
}
|
580
|
+
return;
|
581
|
+
}
|
582
|
+
if( module.is.indeterminate() || module.is.unchecked() ) {
|
583
|
+
module.debug('Currently unchecked');
|
584
|
+
module.check();
|
585
|
+
}
|
586
|
+
else if( module.is.checked() && module.can.uncheck() ) {
|
587
|
+
module.debug('Currently checked');
|
588
|
+
module.uncheck();
|
589
|
+
}
|
590
|
+
},
|
591
|
+
setting: function(name, value) {
|
592
|
+
module.debug('Changing setting', name, value);
|
593
|
+
if( $.isPlainObject(name) ) {
|
594
|
+
$.extend(true, settings, name);
|
595
|
+
}
|
596
|
+
else if(value !== undefined) {
|
597
|
+
if($.isPlainObject(settings[name])) {
|
598
|
+
$.extend(true, settings[name], value);
|
599
|
+
}
|
600
|
+
else {
|
601
|
+
settings[name] = value;
|
602
|
+
}
|
603
|
+
}
|
604
|
+
else {
|
605
|
+
return settings[name];
|
606
|
+
}
|
607
|
+
},
|
608
|
+
internal: function(name, value) {
|
609
|
+
if( $.isPlainObject(name) ) {
|
610
|
+
$.extend(true, module, name);
|
611
|
+
}
|
612
|
+
else if(value !== undefined) {
|
613
|
+
module[name] = value;
|
614
|
+
}
|
615
|
+
else {
|
616
|
+
return module[name];
|
617
|
+
}
|
618
|
+
},
|
619
|
+
debug: function() {
|
620
|
+
if(!settings.silent && settings.debug) {
|
621
|
+
if(settings.performance) {
|
622
|
+
module.performance.log(arguments);
|
623
|
+
}
|
624
|
+
else {
|
625
|
+
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
626
|
+
module.debug.apply(console, arguments);
|
627
|
+
}
|
628
|
+
}
|
629
|
+
},
|
630
|
+
verbose: function() {
|
631
|
+
if(!settings.silent && settings.verbose && settings.debug) {
|
632
|
+
if(settings.performance) {
|
633
|
+
module.performance.log(arguments);
|
634
|
+
}
|
635
|
+
else {
|
636
|
+
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
637
|
+
module.verbose.apply(console, arguments);
|
638
|
+
}
|
639
|
+
}
|
640
|
+
},
|
641
|
+
error: function() {
|
642
|
+
if(!settings.silent) {
|
643
|
+
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
|
644
|
+
module.error.apply(console, arguments);
|
645
|
+
}
|
646
|
+
},
|
647
|
+
performance: {
|
648
|
+
log: function(message) {
|
649
|
+
var
|
650
|
+
currentTime,
|
651
|
+
executionTime,
|
652
|
+
previousTime
|
653
|
+
;
|
654
|
+
if(settings.performance) {
|
655
|
+
currentTime = new Date().getTime();
|
656
|
+
previousTime = time || currentTime;
|
657
|
+
executionTime = currentTime - previousTime;
|
658
|
+
time = currentTime;
|
659
|
+
performance.push({
|
660
|
+
'Name' : message[0],
|
661
|
+
'Arguments' : [].slice.call(message, 1) || '',
|
662
|
+
'Element' : element,
|
663
|
+
'Execution Time' : executionTime
|
664
|
+
});
|
665
|
+
}
|
666
|
+
clearTimeout(module.performance.timer);
|
667
|
+
module.performance.timer = setTimeout(module.performance.display, 500);
|
668
|
+
},
|
669
|
+
display: function() {
|
670
|
+
var
|
671
|
+
title = settings.name + ':',
|
672
|
+
totalTime = 0
|
673
|
+
;
|
674
|
+
time = false;
|
675
|
+
clearTimeout(module.performance.timer);
|
676
|
+
$.each(performance, function(index, data) {
|
677
|
+
totalTime += data['Execution Time'];
|
678
|
+
});
|
679
|
+
title += ' ' + totalTime + 'ms';
|
680
|
+
if(moduleSelector) {
|
681
|
+
title += ' \'' + moduleSelector + '\'';
|
682
|
+
}
|
683
|
+
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
684
|
+
console.groupCollapsed(title);
|
685
|
+
if(console.table) {
|
686
|
+
console.table(performance);
|
687
|
+
}
|
688
|
+
else {
|
689
|
+
$.each(performance, function(index, data) {
|
690
|
+
console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
|
691
|
+
});
|
692
|
+
}
|
693
|
+
console.groupEnd();
|
694
|
+
}
|
695
|
+
performance = [];
|
696
|
+
}
|
697
|
+
},
|
698
|
+
invoke: function(query, passedArguments, context) {
|
699
|
+
var
|
700
|
+
object = instance,
|
701
|
+
maxDepth,
|
702
|
+
found,
|
703
|
+
response
|
704
|
+
;
|
705
|
+
passedArguments = passedArguments || queryArguments;
|
706
|
+
context = element || context;
|
707
|
+
if(typeof query == 'string' && object !== undefined) {
|
708
|
+
query = query.split(/[\. ]/);
|
709
|
+
maxDepth = query.length - 1;
|
710
|
+
$.each(query, function(depth, value) {
|
711
|
+
var camelCaseValue = (depth != maxDepth)
|
712
|
+
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
713
|
+
: query
|
714
|
+
;
|
715
|
+
if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
|
716
|
+
object = object[camelCaseValue];
|
717
|
+
}
|
718
|
+
else if( object[camelCaseValue] !== undefined ) {
|
719
|
+
found = object[camelCaseValue];
|
720
|
+
return false;
|
721
|
+
}
|
722
|
+
else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
|
723
|
+
object = object[value];
|
724
|
+
}
|
725
|
+
else if( object[value] !== undefined ) {
|
726
|
+
found = object[value];
|
727
|
+
return false;
|
728
|
+
}
|
729
|
+
else {
|
730
|
+
module.error(error.method, query);
|
731
|
+
return false;
|
732
|
+
}
|
733
|
+
});
|
734
|
+
}
|
735
|
+
if ( $.isFunction( found ) ) {
|
736
|
+
response = found.apply(context, passedArguments);
|
737
|
+
}
|
738
|
+
else if(found !== undefined) {
|
739
|
+
response = found;
|
740
|
+
}
|
741
|
+
if($.isArray(returnedValue)) {
|
742
|
+
returnedValue.push(response);
|
743
|
+
}
|
744
|
+
else if(returnedValue !== undefined) {
|
745
|
+
returnedValue = [returnedValue, response];
|
746
|
+
}
|
747
|
+
else if(response !== undefined) {
|
748
|
+
returnedValue = response;
|
749
|
+
}
|
750
|
+
return found;
|
751
|
+
}
|
752
|
+
};
|
753
|
+
|
754
|
+
if(methodInvoked) {
|
755
|
+
if(instance === undefined) {
|
756
|
+
module.initialize();
|
757
|
+
}
|
758
|
+
module.invoke(query);
|
759
|
+
}
|
760
|
+
else {
|
761
|
+
if(instance !== undefined) {
|
762
|
+
instance.invoke('destroy');
|
763
|
+
}
|
764
|
+
module.initialize();
|
765
|
+
}
|
766
|
+
})
|
767
|
+
;
|
768
|
+
|
769
|
+
return (returnedValue !== undefined)
|
770
|
+
? returnedValue
|
771
|
+
: this
|
772
|
+
;
|
773
|
+
};
|
774
|
+
|
775
|
+
$.fn.checkbox.settings = {
|
776
|
+
|
777
|
+
name : 'Checkbox',
|
778
|
+
namespace : 'checkbox',
|
779
|
+
|
780
|
+
silent : false,
|
781
|
+
debug : false,
|
782
|
+
verbose : true,
|
783
|
+
performance : true,
|
784
|
+
|
785
|
+
// delegated event context
|
786
|
+
uncheckable : 'auto',
|
787
|
+
fireOnInit : false,
|
788
|
+
|
789
|
+
onChange : function(){},
|
790
|
+
|
791
|
+
beforeChecked : function(){},
|
792
|
+
beforeUnchecked : function(){},
|
793
|
+
beforeDeterminate : function(){},
|
794
|
+
beforeIndeterminate : function(){},
|
795
|
+
|
796
|
+
onChecked : function(){},
|
797
|
+
onUnchecked : function(){},
|
798
|
+
|
799
|
+
onDeterminate : function() {},
|
800
|
+
onIndeterminate : function() {},
|
801
|
+
|
802
|
+
onEnable : function(){},
|
803
|
+
onDisable : function(){},
|
804
|
+
|
805
|
+
// preserve misspelled callbacks (will be removed in 3.0)
|
806
|
+
onEnabled : function(){},
|
807
|
+
onDisabled : function(){},
|
808
|
+
|
809
|
+
className : {
|
810
|
+
checked : 'checked',
|
811
|
+
indeterminate : 'indeterminate',
|
812
|
+
disabled : 'disabled',
|
813
|
+
hidden : 'hidden',
|
814
|
+
radio : 'radio',
|
815
|
+
readOnly : 'read-only'
|
816
|
+
},
|
817
|
+
|
818
|
+
error : {
|
819
|
+
method : 'The method you called is not defined'
|
820
|
+
},
|
821
|
+
|
822
|
+
selector : {
|
823
|
+
checkbox : '.ui.checkbox',
|
824
|
+
label : 'label, .box',
|
825
|
+
input : 'input[type="checkbox"], input[type="radio"]',
|
826
|
+
link : 'a[href]'
|
827
|
+
}
|
828
|
+
|
829
|
+
};
|
830
|
+
|
831
|
+
})( jQuery, window, document );
|