g;g++)if(!z(g)){var h=s(g),i=h[0],j=-1;a.each(h,function(a,b){for(var c=0;f>c;c++)b.locator[c]&&x(b.locator[c].toString().split(","),e[c].toString().split(","))&&c>j&&(j=c,i=b)}),n(g,a.extend({},i,{input:i.match.def}),!0)}}d=d===!0;for(var j=u(),p=b-1;p>-1&&!k().validPositions[p];p--);for(p++;b>p;p++)void 0==k().validPositions[p]&&((!z(p)||j[p]!=F(p))&&s(p).length>1||j[p]==f.radixPoint||"0"==j[p]&&a.inArray(f.radixPoint,j)=E;E++)if(r=g(E,c,d,e),r!==!1){i(q,E),q=E;break}}else r={caret:B(q)}}if(r===!1&&f.keepStatic&&N(j)&&(r=h(b,c,d,e)),r===!0&&(r={pos:q}),a.isFunction(f.postValidation)&&0!=r&&!d){l(!0);var H=f.postValidation(u(),f);if(!H)return l(!0),k().validPositions=a.extend(!0,{},t),!1}return r}function z(a){var b=q(a);return null!=b.fn?b.fn:!1}function A(){var a;cb=bb.prop("maxLength"),-1==cb&&(cb=void 0);var b,c=m(),d=k().validPositions[c],e=void 0!=d?d.locator.slice():void 0;for(b=c+1;void 0==d||null!=d.match.fn||null==d.match.fn&&""!=d.match.def;b++)d=p(b,e,b-1),e=d.locator.slice();return a=b,void 0==cb||cb>a?a:cb}function B(a){var b=A();if(a>=b)return b;for(var c=a;++cc););return c}function C(a){var b=a;if(0>=b)return 0;for(;--b>0&&!z(b););return b}function D(a){return void 0==k().validPositions[a]?F(a):k().validPositions[a].input}function E(b,c,d,e,g){if(e&&a.isFunction(f.onBeforeWrite)){var h=f.onBeforeWrite.call(b,e,c,d,f);if(h){if(h.refreshFromBuffer){var i=h.refreshFromBuffer;v(i===!0?i:i.start,i.end,h.buffer),l(!0),c=u()}d=h.caret||d}}b._valueSet(c.join("")),void 0!=d&&K(b,d),g===!0&&(fb=!0,a(b).trigger("input"))}function F(a,b){return b=b||q(a),void 0!=b.placeholder?b.placeholder:null==b.fn?b.def:f.placeholder.charAt(a%f.placeholder.length)}function G(b,c,d,e){function f(){var a=!1,b=t().slice(i,B(i)).join("").indexOf(h);if(-1!=b&&!z(i)){a=!0;for(var c=t().slice(i,i+b),d=0;d0&&(g.splice(0,n.length*j.length),i=B(i)),a.each(g,function(c,e){var g=a.Event("keypress");g.which=e.charCodeAt(0),h+=e;var j=m(),l=k().validPositions[j],n=p(j+1,l?l.locator.slice():void 0,j);if(!f()||d){var o=d?c:null==n.match.fn&&n.match.optionality&&j+10?b[0]:b;if("number"!=typeof c)return g.setSelectionRange?(c=g.selectionStart,d=g.selectionEnd):document.selection&&document.selection.createRange&&(e=document.selection.createRange(),c=0-e.duplicate().moveStart("character",-1e5),d=c+e.text.length),{begin:J(c),end:J(d)};if(c=J(c),d=J(d),d="number"==typeof d?d:c,a(g).is(":visible")){var h=a(g).css("font-size").replace("px","")*d;g.scrollLeft=h>g.scrollWidth?h:0,0==f.insertMode&&c==d&&d++,g.setSelectionRange?(g.selectionStart=c,g.selectionEnd=d):g.createTextRange&&(e=g.createTextRange(),e.collapse(!0),e.moveEnd("character",d),e.moveStart("character",c),e.select())}}function L(b){var c,d,e=u(),f=e.length,g=m(),h={},i=k().validPositions[g],j=void 0!=i?i.locator.slice():void 0;for(c=g+1;cg&&(d=h[c].match,(d.optionality||d.optionalQuantifier||i&&void 0!=i.alternation&&void 0!=h[c].locator[i.alternation]&&-1!=a.inArray(h[c].locator[i.alternation].toString(),l))&&e[c]==F(c,d));c--)f--;return b?{l:f,def:h[f]?h[f].match:void 0}:f}function M(a){for(var b=L(),c=a.length-1;c>b&&!z(c);c--);return a.splice(b,c+1-b),a}function N(b){if(a.isFunction(f.isComplete))return f.isComplete.call(bb,b,f);if("*"==f.repeat)return void 0;{var c=!1,d=L(!0),e=C(d.l);m()}if(void 0==d.def||d.def.newBlockMarker||d.def.optionality||d.def.optionalQuantifier){c=!0;for(var g=0;e>=g;g++){var h=z(g),i=q(g);if(h&&void 0==k().validPositions[g]&&i.optionality!==!0&&i.optionalQuantifier!==!0||!h&&b[g]!=F(g)){c=!1;break}}}return c}function O(a,b){return db?a-b>1||a-b==1&&f.insertMode:b-a>1||b-a==1&&f.insertMode}function P(b){var c=a._data(b).events;a.each(c,function(b,c){a.each(c,function(a,b){if("inputmask"==b.namespace&&"setvalue"!=b.type){var c=b.handler;b.handler=function(a){if(!this.disabled&&(!this.readOnly||"keydown"==a.type&&a.ctrlKey&&67==a.keyCode)){switch(a.type){case"input":if(fb===!0)return fb=!1,a.preventDefault();break;case"keydown":eb=!1;break;case"keypress":if(eb===!0)return a.preventDefault();eb=!0;break;case"compositionstart":break;case"compositionupdate":fb=!0;break;case"compositionend":}return c.apply(this,arguments)}a.preventDefault()}}})})}function Q(b){function c(b){if(void 0==a.valHooks[b]||1!=a.valHooks[b].inputmaskpatch){var c=a.valHooks[b]&&a.valHooks[b].get?a.valHooks[b].get:function(a){return a.value},d=a.valHooks[b]&&a.valHooks[b].set?a.valHooks[b].set:function(a,b){return a.value=b,a};a.valHooks[b]={get:function(b){var d=a(b);if(d.data("_inputmask")){if(d.data("_inputmask").opts.autoUnmask)return d.inputmask("unmaskedvalue");var e=c(b),f=d.data("_inputmask"),g=f.maskset,h=g._buffer;return h=h?h.join(""):"",e!=h?e:""}return c(b)},set:function(b,c){var e,f=a(b),g=f.data("_inputmask");return g?(e=d(b,a.isFunction(g.opts.onBeforeMask)?g.opts.onBeforeMask.call(mb,c,g.opts)||c:c),f.triggerHandler("setvalue.inputmask")):e=d(b,c),e},inputmaskpatch:!0}}}function d(){var b=a(this),c=a(this).data("_inputmask");return c?c.opts.autoUnmask?b.inputmask("unmaskedvalue"):h.call(this)!=t().join("")?h.call(this):"":h.call(this)}function e(b){var c=a(this).data("_inputmask");c?(i.call(this,a.isFunction(c.opts.onBeforeMask)?c.opts.onBeforeMask.call(mb,b,c.opts)||b:b),a(this).triggerHandler("setvalue.inputmask")):i.call(this,b)}function g(b){a(b).bind("mouseenter.inputmask",function(){var b=a(this),c=this,d=c._valueGet();""!=d&&d!=u().join("")&&(this._valueSet(a.isFunction(f.onBeforeMask)?f.onBeforeMask.call(mb,d,f)||d:d),b.triggerHandler("setvalue.inputmask"))});//!! the bound handlers are executed in the order they where bound
var c=a._data(b).events,d=c.mouseover;if(d){for(var e=d[d.length-1],g=d.length-1;g>0;g--)d[g]=d[g-1];d[0]=e}}var h,i;if(!b._valueGet){if(Object.getOwnPropertyDescriptor){Object.getOwnPropertyDescriptor(b,"value")}document.__lookupGetter__&&b.__lookupGetter__("value")?(h=b.__lookupGetter__("value"),i=b.__lookupSetter__("value"),b.__defineGetter__("value",d),b.__defineSetter__("value",e)):(h=function(){return b.value},i=function(a){b.value=a},c(b.type),g(b)),b._valueGet=function(a){return db&&a!==!0?h.call(this).split("").reverse().join(""):h.call(this)},b._valueSet=function(a){i.call(this,db?a.split("").reverse().join(""):a)}}}function R(b,c,d,e){function g(){if(f.keepStatic){l(!0);var c,d=[];for(c=m();c>=0;c--)if(k().validPositions[c]){if(void 0!=k().validPositions[c].alternation)break;d.push(k().validPositions[c].input),delete k().validPositions[c]}if(c>0)for(;d.length>0;){k().p=B(m());var e=a.Event("keypress");e.which=d.pop().charCodeAt(0),T.call(b,e,!0,!1,!1,k().p)}}}if((f.numericInput||db)&&(c==a.inputmask.keyCode.BACKSPACE?c=a.inputmask.keyCode.DELETE:c==a.inputmask.keyCode.DELETE&&(c=a.inputmask.keyCode.BACKSPACE),db)){var h=d.end;d.end=d.begin,d.begin=h}if(c==a.inputmask.keyCode.BACKSPACE&&(d.end-d.begin<1||0==f.insertMode)?d.begin=C(d.begin):c==a.inputmask.keyCode.DELETE&&d.begin==d.end&&(d.end=z(d.end)?d.end+1:B(d.end)+1),o(d.begin,d.end,!1,e),e!==!0){g();var i=m(d.begin);i1||void 0!=w[r].alternation)?r+1:B(r)}k().p=m}if(d!==!1){var x=this;if(setTimeout(function(){f.onKeyValidation.call(x,t,f)},0),k().writeOutBuffer&&t!==!1){var z=u();E(h,z,c?void 0:f.numericInput?C(m):m,b,c!==!0),c!==!0&&setTimeout(function(){N(z)===!0&&i.trigger("complete")},0)}else q&&(k().buffer=void 0,k().validPositions=k().undoPositions)}else q&&(k().buffer=void 0,k().validPositions=k().undoPositions);if(f.showTooltip&&i.prop("title",k().mask),c&&a.isFunction(f.onBeforeWrite)){var A=f.onBeforeWrite.call(this,b,u(),m,f);if(A&&A.refreshFromBuffer){var D=A.refreshFromBuffer;v(D===!0?D:D.start,D.end,A.buffer),l(!0),A.caret&&(k().p=A.caret)}}b.preventDefault()}}function U(b){var c=this,d=a(c),e=c._valueGet(!0),g=K(c);if("propertychange"==b.type&&c._valueGet().length<=A())return!0;if("paste"==b.type){var h=e.substr(0,g.begin),i=e.substr(g.end,e.length);h==t().slice(0,g.begin).join("")&&(h=""),i==t().slice(g.end).join("")&&(i=""),window.clipboardData&&window.clipboardData.getData?e=h+window.clipboardData.getData("Text")+i:b.originalEvent&&b.originalEvent.clipboardData&&b.originalEvent.clipboardData.getData&&(e=h+b.originalEvent.clipboardData.getData("text/plain")+i)}var j=e;if(a.isFunction(f.onBeforePaste)){if(j=f.onBeforePaste.call(c,e,f),j===!1)return b.preventDefault(),!1;j||(j=e)}return G(c,!0,!1,db?j.split("").reverse():j.split("")),d.click(),N(u())===!0&&d.trigger("complete"),!1}function V(b){var c=this;G(c,!0,!1),N(u())===!0&&a(c).trigger("complete"),b.preventDefault()}function W(a){var b=this;$=u().join(""),(""==ab||0!=a.originalEvent.data.indexOf(ab))&&(_=K(b))}function X(b){var c=this,d=_||K(c);0==b.originalEvent.data.indexOf(ab)&&(l(),d={begin:0,end:0});var e=b.originalEvent.data;K(c,d.begin,d.end);for(var g=0;ge?K(c,z(e)?e:B(e)):K(c,g)}}}).bind("dblclick.inputmask",function(){var a=this;setTimeout(function(){K(a,0,B(m()))},0)}).bind(j+".inputmask dragdrop.inputmask drop.inputmask",U).bind("setvalue.inputmask",function(){var a=this;G(a,!0,!1),$=u().join(""),(f.clearMaskOnLostFocus||f.clearIncomplete)&&a._valueGet()==t().join("")&&a._valueSet("")}).bind("cut.inputmask",function(b){fb=!0;var c=this,d=a(c),e=K(c);R(c,a.inputmask.keyCode.DELETE,e),E(c,u(),k().p,b,$!=u().join("")),c._valueGet()==t().join("")&&d.trigger("cleared"),f.showTooltip&&d.prop("title",k().mask)}).bind("complete.inputmask",f.oncomplete).bind("incomplete.inputmask",f.onincomplete).bind("cleared.inputmask",f.oncleared),bb.bind("keydown.inputmask",S).bind("keypress.inputmask",T),i||bb.bind("compositionstart.inputmask",W).bind("compositionupdate.inputmask",X).bind("compositionend.inputmask",Y),"paste"===j&&bb.bind("input.inputmask",V),Q(b);var g=a.isFunction(f.onBeforeMask)?f.onBeforeMask.call(b,b._valueGet(),f)||b._valueGet():b._valueGet();G(b,!0,!1,g.split(""));var h=u().slice();$=h.join("");var n;try{n=document.activeElement}catch(o){}N(h)===!1&&f.clearIncomplete&&l(),f.clearMaskOnLostFocus&&(h.join("")==t().join("")?h=[]:M(h)),E(b,h),n===b&&K(b,B(m())),P(b)}}var $,_,ab,bb,cb,db=!1,eb=!1,fb=!1,gb=!1,hb=!0;if(void 0!=d)switch(d.action){case"isComplete":return bb=a(d.el),e=bb.data("_inputmask").maskset,f=bb.data("_inputmask").opts,N(d.buffer);case"unmaskedvalue":return bb=d.$input,e=bb.data("_inputmask").maskset,f=bb.data("_inputmask").opts,db=d.$input.data("_inputmask").isRTL,I(d.$input);case"mask":$=u().join(""),Z(d.el);break;case"format":bb=a({}),bb.data("_inputmask",{maskset:e,opts:f,isRTL:f.numericInput}),f.numericInput&&(db=!0);var ib=(a.isFunction(f.onBeforeMask)?f.onBeforeMask.call(bb,d.value,f)||d.value:d.value).split("");return G(bb,!1,!1,db?ib.reverse():ib),a.isFunction(f.onBeforeWrite)&&f.onBeforeWrite.call(this,void 0,u(),0,f),d.metadata?{value:db?u().slice().reverse().join(""):u().join(""),metadata:bb.inputmask("getmetadata")}:db?u().slice().reverse().join(""):u().join("");case"isValid":bb=a({}),bb.data("_inputmask",{maskset:e,opts:f,isRTL:f.numericInput}),f.numericInput&&(db=!0);var ib=d.value.split("");G(bb,!1,!0,db?ib.reverse():ib);for(var jb=u(),kb=L(),lb=jb.length-1;lb>kb&&!z(lb);lb--);return jb.splice(kb,lb+1-kb),N(jb)&&d.value==jb.join("");case"getemptymask":return bb=a(d.el),e=bb.data("_inputmask").maskset,f=bb.data("_inputmask").opts,t();case"remove":var mb=d.el;bb=a(mb),e=bb.data("_inputmask").maskset,f=bb.data("_inputmask").opts,mb._valueSet(I(bb)),bb.unbind(".inputmask"),bb.removeData("_inputmask");var nb;Object.getOwnPropertyDescriptor&&(nb=Object.getOwnPropertyDescriptor(mb,"value")),nb&&nb.get?mb._valueGet&&Object.defineProperty(mb,"value",{get:mb._valueGet,set:mb._valueSet}):document.__lookupGetter__&&mb.__lookupGetter__("value")&&mb._valueGet&&(mb.__defineGetter__("value",mb._valueGet),mb.__defineSetter__("value",mb._valueSet));try{delete mb._valueGet,delete mb._valueSet}catch(ob){mb._valueGet=void 0,mb._valueSet=void 0}break;case"getmetadata":if(bb=a(d.el),e=bb.data("_inputmask").maskset,f=bb.data("_inputmask").opts,a.isArray(e.metadata)){for(var pb,qb=m(),rb=qb;rb>=0;rb--)if(k().validPositions[rb]&&void 0!=k().validPositions[rb].alternation){pb=k().validPositions[rb].alternation;break}return void 0!=pb?e.metadata[k().validPositions[qb].locator[pb]]:e.metadata[0]}return e.metadata}}if(void 0===a.fn.inputmask){var g=navigator.userAgent,h=null!==g.match(new RegExp("iphone","i")),i=(null!==g.match(new RegExp("android.*safari.*","i")),null!==g.match(new RegExp("android.*chrome.*","i")),null!==g.match(new RegExp("android.*firefox.*","i"))),j=(/Kindle/i.test(g)||/Silk/i.test(g)||/KFTT/i.test(g)||/KFOT/i.test(g)||/KFJWA/i.test(g)||/KFJWI/i.test(g)||/KFSOWI/i.test(g)||/KFTHWA/i.test(g)||/KFTHWI/i.test(g)||/KFAPWA/i.test(g)||/KFAPWI/i.test(g),b("paste")?"paste":b("input")?"input":"propertychange");a.inputmask={defaults:{placeholder:"_",optionalmarker:{start:"[",end:"]"},quantifiermarker:{start:"{",end:"}"},groupmarker:{start:"(",end:")"},alternatormarker:"|",escapeChar:"\\",mask:null,oncomplete:a.noop,onincomplete:a.noop,oncleared:a.noop,repeat:0,greedy:!0,autoUnmask:!1,removeMaskOnSubmit:!1,clearMaskOnLostFocus:!0,insertMode:!0,clearIncomplete:!1,aliases:{},alias:null,onKeyDown:a.noop,onBeforeMask:void 0,onBeforePaste:void 0,onBeforeWrite:void 0,onUnMask:void 0,showMaskOnFocus:!0,showMaskOnHover:!0,onKeyValidation:a.noop,skipOptionalPartCharacter:" ",showTooltip:!1,numericInput:!1,rightAlign:!1,undoOnEscape:!0,radixPoint:"",radixFocus:!1,nojumps:!1,nojumpsThreshold:0,keepStatic:void 0,definitions:{9:{validator:"[0-9]",cardinality:1,definitionSymbol:"*"},a:{validator:"[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",cardinality:1,definitionSymbol:"*"},"*":{validator:"[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",cardinality:1}},ignorables:[8,9,13,19,27,33,34,35,36,37,38,39,40,45,46,93,112,113,114,115,116,117,118,119,120,121,122,123],isComplete:void 0,canClearPosition:a.noop,postValidation:void 0},keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91},masksCache:{},escapeRegex:function(a){var b=["/",".","*","+","?","|","(",")","[","]","{","}","\\","$","^"];return a.replace(new RegExp("(\\"+b.join("|\\")+")","gim"),"\\$1")},format:function(b,c,g){var h=a.extend(!0,{},a.inputmask.defaults,c);return d(h.alias,c,h),f({action:"format",value:b,metadata:g},e(h),h)},isValid:function(b,c){var g=a.extend(!0,{},a.inputmask.defaults,c);return d(g.alias,c,g),f({action:"isValid",value:b},e(g),g)}},a.fn.inputmask=function(b,c){function g(b,c,e){var f=a(b);f.data("inputmask-alias")&&d(f.data("inputmask-alias"),{},c);for(var g in c){var h=f.data("inputmask-"+g.toLowerCase());void 0!=h&&("mask"==g&&0==h.indexOf("[")?(c[g]=h.replace(/[\s[\]]/g,"").split("','"),c[g][0]=c[g][0].replace("'",""),c[g][c[g].length-1]=c[g][c[g].length-1].replace("'","")):c[g]="boolean"==typeof h?h:h.toString(),e&&(e[g]=c[g]))}return c}var h,i=a.extend(!0,{},a.inputmask.defaults,c);if("string"==typeof b)switch(b){case"mask":return d(i.alias,c,i),h=e(i),void 0==h?this:this.each(function(){f({action:"mask",el:this},a.extend(!0,{},h),g(this,i))});case"unmaskedvalue":var j=a(this);return j.data("_inputmask")?f({action:"unmaskedvalue",$input:j}):j.val();case"remove":return this.each(function(){var b=a(this);b.data("_inputmask")&&f({action:"remove",el:this})});case"getemptymask":return this.data("_inputmask")?f({action:"getemptymask",el:this}):"";case"hasMaskedValue":return this.data("_inputmask")?!this.data("_inputmask").opts.autoUnmask:!1;case"isComplete":return this.data("_inputmask")?f({action:"isComplete",buffer:this[0]._valueGet().split(""),el:this}):!0;case"getmetadata":return this.data("_inputmask")?f({action:"getmetadata",el:this}):void 0;default:return d(i.alias,c,i),d(b,c,i)||(i.mask=b),h=e(i),void 0==h?this:this.each(function(){f({action:"mask",el:this},a.extend(!0,{},h),g(this,i))})}else{if("object"==typeof b)return i=a.extend(!0,{},a.inputmask.defaults,b),d(i.alias,b,i),h=e(i),void 0==h?this:this.each(function(){f({action:"mask",el:this},a.extend(!0,{},h),g(this,i))});if(void 0==b)return this.each(function(){var b=a(this).attr("data-inputmask");if(b&&""!=b)try{b=b.replace(new RegExp("'","g"),'"');var e=a.parseJSON("{"+b+"}");a.extend(!0,e,c),i=a.extend(!0,{},a.inputmask.defaults,e),i=g(this,i),d(i.alias,e,i),i.alias=void 0,a(this).inputmask("mask",i)}catch(f){}if(a(this).attr("data-inputmask-mask")||a(this).attr("data-inputmask-alias")){i=a.extend(!0,{},a.inputmask.defaults,{});var h={};i=g(this,i,h),d(i.alias,h,i),i.alias=void 0,a(this).inputmask("mask",i)}})}}}return a.fn.inputmask}(jQuery),function(a){return a.extend(a.inputmask.defaults.definitions,{h:{validator:"[01][0-9]|2[0-3]",cardinality:2,prevalidator:[{validator:"[0-2]",cardinality:1}]},s:{validator:"[0-5][0-9]",cardinality:2,prevalidator:[{validator:"[0-5]",cardinality:1}]},d:{validator:"0[1-9]|[12][0-9]|3[01]",cardinality:2,prevalidator:[{validator:"[0-3]",cardinality:1}]},m:{validator:"0[1-9]|1[012]",cardinality:2,prevalidator:[{validator:"[01]",cardinality:1}]},y:{validator:"(19|20)\\d{2}",cardinality:4,prevalidator:[{validator:"[12]",cardinality:1},{validator:"(19|20)",cardinality:2},{validator:"(19|20)\\d",cardinality:3}]}}),a.extend(a.inputmask.defaults.aliases,{"dd/mm/yyyy":{mask:"1/2/y",placeholder:"dd/mm/yyyy",regex:{val1pre:new RegExp("[0-3]"),val1:new RegExp("0[1-9]|[12][0-9]|3[01]"),val2pre:function(b){var c=a.inputmask.escapeRegex.call(this,b);return new RegExp("((0[1-9]|[12][0-9]|3[01])"+c+"[01])")},val2:function(b){var c=a.inputmask.escapeRegex.call(this,b);return new RegExp("((0[1-9]|[12][0-9])"+c+"(0[1-9]|1[012]))|(30"+c+"(0[13-9]|1[012]))|(31"+c+"(0[13578]|1[02]))")}},leapday:"29/02/",separator:"/",yearrange:{minyear:1900,maxyear:2099},isInYearRange:function(a,b,c){if(isNaN(a))return!1;var d=parseInt(a.concat(b.toString().slice(a.length))),e=parseInt(a.concat(c.toString().slice(a.length)));return(isNaN(d)?!1:d>=b&&c>=d)||(isNaN(e)?!1:e>=b&&c>=e)},determinebaseyear:function(a,b,c){var d=(new Date).getFullYear();if(a>d)return a;if(d>b){for(var e=b.toString().slice(0,2),f=b.toString().slice(2,4);e+c>b;)e--;var g=e+f;return a>g?a:g}return d},onKeyDown:function(b){var c=a(this);if(b.ctrlKey&&b.keyCode==a.inputmask.keyCode.RIGHT){var d=new Date;c.val(d.getDate().toString()+(d.getMonth()+1).toString()+d.getFullYear().toString()),c.triggerHandler("setvalue.inputmask")}},getFrontValue:function(a,b,c){for(var d=0,e=0,f=0;fg?(b.buffer[c]=g.toString(),b.buffer[c-1]="0"):(b.buffer[c]=g.toString().charAt(1),b.buffer[c-1]=g.toString().charAt(0)),{refreshFromBuffer:{start:c-1,end:c+6},c:b.buffer[c]}}return f},cardinality:2,prevalidator:[{validator:function(a,b,c,d,e){var f=e.regex.hrspre.test(a);return d||f||!(f=e.regex.hrs.test("0"+a))?f:(b.buffer[c]="0",c++,{pos:c})},cardinality:1}]},s:{validator:"[0-5][0-9]",cardinality:2,prevalidator:[{validator:function(a,b,c,d,e){var f=e.regex.mspre.test(a);return d||f||!(f=e.regex.ms.test("0"+a))?f:(b.buffer[c]="0",c++,{pos:c})},cardinality:1}]},t:{validator:function(a,b,c,d,e){return e.regex.ampm.test(a+"m")},casing:"lower",cardinality:1}},insertMode:!1,autoUnmask:!1},datetime12:{mask:"1/2/y h:s t\\m",placeholder:"dd/mm/yyyy hh:mm xm",alias:"datetime",hourFormat:"12"},"hh:mm t":{mask:"h:s t\\m",placeholder:"hh:mm xm",alias:"datetime",hourFormat:"12"},"h:s t":{mask:"h:s t\\m",placeholder:"hh:mm xm",alias:"datetime",hourFormat:"12"},"hh:mm:ss":{mask:"h:s:s",placeholder:"hh:mm:ss",alias:"datetime",autoUnmask:!1},"hh:mm":{mask:"h:s",placeholder:"hh:mm",alias:"datetime",autoUnmask:!1},date:{alias:"dd/mm/yyyy"},"mm/yyyy":{mask:"1/y",placeholder:"mm/yyyy",leapday:"donotuse",separator:"/",alias:"mm/dd/yyyy"}}),a.fn.inputmask}(jQuery),function(a){return a.extend(a.inputmask.defaults.definitions,{A:{validator:"[A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",cardinality:1,casing:"upper"},"#":{validator:"[0-9A-Za-z\u0410-\u044f\u0401\u0451\xc0-\xff\xb5]",cardinality:1,casing:"upper"}}),a.extend(a.inputmask.defaults.aliases,{url:{mask:"ir",placeholder:"",separator:"",defaultPrefix:"http://",regex:{urlpre1:new RegExp("[fh]"),urlpre2:new RegExp("(ft|ht)"),urlpre3:new RegExp("(ftp|htt)"),urlpre4:new RegExp("(ftp:|http|ftps)"),urlpre5:new RegExp("(ftp:/|ftps:|http:|https)"),urlpre6:new RegExp("(ftp://|ftps:/|http:/|https:)"),urlpre7:new RegExp("(ftp://|ftps://|http://|https:/)"),urlpre8:new RegExp("(ftp://|ftps://|http://|https://)")},definitions:{i:{validator:function(){return!0},cardinality:8,prevalidator:function(){for(var a=[],b=8,c=0;b>c;c++)a[c]=function(){var a=c;return{validator:function(b,c,d,e,f){if(f.regex["urlpre"+(a+1)]){var g,h=b;a+1-b.length>0&&(h=c.buffer.join("").substring(0,a+1-b.length)+""+h);var i=f.regex["urlpre"+(a+1)].test(h);if(!e&&!i){for(d-=a,g=0;g-1&&"."!=b.buffer[c-1]?(a=b.buffer[c-1]+a,a=c-2>-1&&"."!=b.buffer[c-2]?b.buffer[c-2]+a:"0"+a):a="00"+a,new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(a)},cardinality:1}}},email:{mask:"*{1,64}[.*{1,64}][.*{1,64}][.*{1,64}]@*{1,64}[.*{2,64}][.*{2,6}][.*{1,2}]",greedy:!1,onBeforePaste:function(a){return a=a.toLowerCase(),a.replace("mailto:","")},definitions:{"*":{validator:"[0-9A-Za-z!#$%&'*+/=?^_`{|}~-]",cardinality:1,casing:"lower"}}}}),a.fn.inputmask}(jQuery),function(a){return a.extend(a.inputmask.defaults.aliases,{numeric:{mask:function(a){function b(b){for(var c="",d=0;d0)&&(e+=a.digitsOptional?"["+(a.decimalProtect?":":a.radixPoint)+";{"+a.digits+"}]":(a.decimalProtect?":":a.radixPoint)+";{"+a.digits+"}"),""!=a.negationSymbol.back&&(e+="[-]"),e+=b(a.suffix),a.greedy=!1,e},placeholder:"",greedy:!1,digits:"*",digitsOptional:!0,groupSeparator:"",radixPoint:".",radixFocus:!0,groupSize:3,autoGroup:!1,allowPlus:!0,allowMinus:!0,negationSymbol:{front:"-",back:""},integerDigits:"+",prefix:"",suffix:"",rightAlign:!0,decimalProtect:!0,min:void 0,max:void 0,postFormat:function(b,c,d,e){var f=!1;b.length>=e.suffix.length&&b.join("").indexOf(e.suffix)==b.length-e.suffix.length&&(b.length=b.length-e.suffix.length,f=!0),c=c>=b.length?b.length-1:c=a.inArray(e.radixPoint,b)||new RegExp("["+a.inputmask.escapeRegex(e.negationSymbol.front)+"+]").test(h)){if(f)for(var i=0,j=e.suffix.length;j>i;i++)b.push(e.suffix.charAt(i));return{pos:c}}var k=b.slice();h==e.groupSeparator&&(k.splice(c--,1),h=k[c]),d?k[c]="?":k.splice(c,0,"?");var l=k.join(""),m=l;if(l.length>0&&e.autoGroup||d&&-1!=l.indexOf(e.groupSeparator)){var n=a.inputmask.escapeRegex(e.groupSeparator);g=0==l.indexOf(e.groupSeparator),l=l.replace(new RegExp(n,"g"),"");var o=l.split(e.radixPoint);if(l=""==e.radixPoint?l:o[0],l!=e.prefix+"?0"&&l.length>=e.groupSize+e.prefix.length)for(var p=new RegExp("([-+]?[\\d?]+)([\\d?]{"+e.groupSize+"})");p.test(l);)l=l.replace(p,"$1"+e.groupSeparator+"$2"),l=l.replace(e.groupSeparator+e.groupSeparator,e.groupSeparator);""!=e.radixPoint&&o.length>1&&(l+=e.radixPoint+o[1])}g=m!=l,b.length=l.length;for(var i=0,j=l.length;j>i;i++)b[i]=l.charAt(i);var q=a.inArray("?",b);if(d?b[q]=h:b.splice(q,1),!g&&f)for(var i=0,j=e.suffix.length;j>i;i++)b.push(e.suffix.charAt(i));return{pos:q,refreshFromBuffer:g,buffer:b}},onBeforeWrite:function(b,c,d,e){if(b&&"blur"==b.type){var f=c.join(""),g=f.replace(e.prefix,"");if(g=g.replace(e.suffix,""),g=g.replace(new RegExp(a.inputmask.escapeRegex(e.groupSeparator),"g"),""),g=g.replace(a.inputmask.escapeRegex(e.radixPoint),"."),isFinite(g)&&isFinite(e.min)&&parseFloat(g)0)return b.buffer[f.index]==("-"===a?"+":e.negationSymbol.front)?"-"==a?""!=e.negationSymbol.back?{pos:f.index,c:e.negationSymbol.front,remove:f.index,caret:c,insert:{pos:b.buffer.length-e.suffix.length-1,c:e.negationSymbol.back}}:{pos:f.index,c:e.negationSymbol.front,remove:f.index,caret:c}:""!=e.negationSymbol.back?{pos:f.index,c:"+",remove:[f.index,b.buffer.length-e.suffix.length-1],caret:c}:{pos:f.index,c:"+",remove:f.index,caret:c}:b.buffer[f.index]==("-"===a?e.negationSymbol.front:"+")?"-"==a&&""!=e.negationSymbol.back?{remove:[f.index,b.buffer.length-e.suffix.length-1],caret:c-1}:{remove:f.index,caret:c-1}:"-"==a?""!=e.negationSymbol.back?{pos:f.index,c:e.negationSymbol.front,caret:c+1,insert:{pos:b.buffer.length-e.suffix.length,c:e.negationSymbol.back}}:{pos:f.index,c:e.negationSymbol.front,caret:c+1}:{pos:f.index,c:a,caret:c+1}}return!1},radixHandler:function(b,c,d,e,f){if(!e&&b===f.radixPoint&&f.digits>0){var g=a.inArray(f.radixPoint,c.buffer),h=c.buffer.join("").match(f.regex.integerPart(f));if(-1!=g&&c.validPositions[g])return c.validPositions[g-1]?{caret:g+1}:{pos:h.index,c:h[0],caret:g+1};if(!h||"0"==h[0]&&h.index+1!=d)return c.buffer[h?h.index:d]="0",{pos:(h?h.index:d)+1}}return!1},leadingZeroHandler:function(b,c,d,e,f){var g=c.buffer.join("").match(f.regex.integerNPart(f)),h=a.inArray(f.radixPoint,c.buffer);if(g&&!e&&(-1==h||h>=d))if(0==g[0].indexOf("0")){dg.index?d-1:g.index,{pos:d,remove:g.index};
if(g.index+1==d||"0"==b)return c.buffer.splice(g.index,1),d=g.index,{pos:d,remove:g.index}}else if("0"===b&&d<=g.index&&g[0]!=f.groupSeparator)return!1;return!0},postValidation:function(b,c){var d=!0,e=b.join(""),f=e.replace(c.prefix,"");return f=f.replace(c.suffix,""),f=f.replace(new RegExp(a.inputmask.escapeRegex(c.groupSeparator),"g"),""),f=f.replace(a.inputmask.escapeRegex(c.radixPoint),"."),f=f.replace(new RegExp("^"+a.inputmask.escapeRegex(c.negationSymbol.front)),"-"),f=f.replace(new RegExp(a.inputmask.escapeRegex(c.negationSymbol.back)+"$"),""),isFinite(f)&&isFinite(c.max)&&(d=parseFloat(f)<=parseFloat(c.max)),d},definitions:{"~":{validator:function(b,c,d,e,f){var g=f.signHandler(b,c,d,e,f);if(!g&&(g=f.radixHandler(b,c,d,e,f),!g&&(g=e?new RegExp("[0-9"+a.inputmask.escapeRegex(f.groupSeparator)+"]").test(b):new RegExp("[0-9]").test(b),g===!0&&(g=f.leadingZeroHandler(b,c,d,e,f),g===!0)))){var h=a.inArray(f.radixPoint,c.buffer);g=f.digitsOptional===!1&&d>h&&!e?{pos:d,remove:d}:{pos:d}}return g},cardinality:1,prevalidator:null},"+":{validator:function(a,b,c,d,e){var f=e.signHandler(a,b,c,d,e);return!f&&(d&&e.allowMinus&&a===e.negationSymbol.front||e.allowMinus&&"-"==a||e.allowPlus&&"+"==a)&&(f="-"==a?""!=e.negationSymbol.back?{pos:c,c:"-"===a?e.negationSymbol.front:"+",caret:c+1,insert:{pos:b.buffer.length,c:e.negationSymbol.back}}:{pos:c,c:"-"===a?e.negationSymbol.front:"+",caret:c+1}:!0),f},cardinality:1,prevalidator:null,placeholder:""},"-":{validator:function(a,b,c,d,e){var f=e.signHandler(a,b,c,d,e);return!f&&d&&e.allowMinus&&a===e.negationSymbol.back&&(f=!0),f},cardinality:1,prevalidator:null,placeholder:""},":":{validator:function(b,c,d,e,f){var g=f.signHandler(b,c,d,e,f);if(!g){var h="["+a.inputmask.escapeRegex(f.radixPoint)+"]";g=new RegExp(h).test(b),g&&c.validPositions[d]&&c.validPositions[d].match.placeholder==f.radixPoint&&(g={caret:d+1})}return g},cardinality:1,prevalidator:null,placeholder:function(a){return a.radixPoint}}},insertMode:!0,autoUnmask:!1,onUnMask:function(b,c,d){var e=b.replace(d.prefix,"");return e=e.replace(d.suffix,""),e=e.replace(new RegExp(a.inputmask.escapeRegex(d.groupSeparator),"g"),"")},isComplete:function(b,c){var d=b.join(""),e=b.slice();if(c.postFormat(e,0,!0,c),e.join("")!=d)return!1;var f=d.replace(c.prefix,"");return f=f.replace(c.suffix,""),f=f.replace(new RegExp(a.inputmask.escapeRegex(c.groupSeparator),"g"),""),","===c.radixPoint&&(f=f.replace(a.inputmask.escapeRegex(c.radixPoint),".")),isFinite(f)},onBeforeMask:function(b,c){if(""!=c.radixPoint&&isFinite(b))b=b.toString().replace(".",c.radixPoint);else{var d=b.match(/,/g),e=b.match(/\./g);e&&d?e.length>d.length?(b=b.replace(/\./g,""),b=b.replace(",",c.radixPoint)):d.length>e.length?(b=b.replace(/,/g,""),b=b.replace(".",c.radixPoint)):b=b.indexOf(".")=c))if(0==i[0].indexOf("0"))h=i.index!=c||-1==n;else{var o=parseInt(i[0].replace(new RegExp(a.inputmask.escapeRegex(f.groupSeparator),"g"),""));-1!=n&&10>o&&"0"==f.placeholder.charAt(0)&&(b.validPositions[c].input="0",b.p=f.prefix.length+1,h=!1)}}return h}},currency:{prefix:"$ ",groupSeparator:",",alias:"numeric",placeholder:"0",autoGroup:!0,digits:2,digitsOptional:!1,clearMaskOnLostFocus:!1},decimal:{alias:"numeric"},integer:{alias:"numeric",digits:"0",radixPoint:""}}),a.fn.inputmask}(jQuery),function(a){return a.extend(a.inputmask.defaults.aliases,{phone:{url:"phone-codes/phone-codes.js",maskInit:"+pp(pp)pppppppp",countrycode:"",mask:function(b){b.definitions={p:{validator:function(){return!1},cardinality:1},"#":{validator:"[0-9]",cardinality:1}};var c=[];return a.ajax({url:b.url,async:!1,dataType:"json",success:function(a){c=a},error:function(a,c,d){alert(d+" - "+b.url)}}),c=c.sort(function(a,b){return(a.mask||a)<(b.mask||b)?-1:1}),""!=b.countrycode&&(b.maskInit="+"+b.countrycode+b.maskInit.substring(3)),c.splice(0,0,b.maskInit),c},nojumps:!0,nojumpsThreshold:1,onBeforeMask:function(a,b){var c=a.replace(/^0/g,"");return(c.indexOf(b.countrycode)>1||-1==c.indexOf(b.countrycode))&&(c="+"+b.countrycode+c),c}},phonebe:{alias:"phone",url:"phone-codes/phone-be.js",countrycode:"32",nojumpsThreshold:4}}),a.fn.inputmask}(jQuery),function(a){return a.extend(a.inputmask.defaults.aliases,{Regex:{mask:"r",greedy:!1,repeat:"*",regex:null,regexTokens:null,tokenizer:/\[\^?]?(?:[^\\\]]+|\\[\S\s]?)*]?|\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9][0-9]*|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Za-z]|[\S\s]?)|\((?:\?[:=!]?)?|(?:[?*+]|\{[0-9]+(?:,[0-9]*)?\})\??|[^.?*+^${[()|\\]+|./g,quantifierFilter:/[0-9]+[^,]/,isComplete:function(a,b){return new RegExp(b.regex).test(a.join(""))},definitions:{r:{validator:function(b,c,d,e,f){function g(a,b){this.matches=[],this.isGroup=a||!1,this.isQuantifier=b||!1,this.quantifier={min:1,max:1},this.repeaterPart=void 0}function h(){var a,b,c=new g,d=[];for(f.regexTokens=[];a=f.tokenizer.exec(f.regex);)switch(b=a[0],b.charAt(0)){case"(":d.push(new g(!0));break;case")":var e=d.pop();d.length>0?d[d.length-1].matches.push(e):c.matches.push(e);break;case"{":case"+":case"*":var h=new g(!1,!0);b=b.replace(/[{}]/g,"");var i=b.split(","),j=isNaN(i[0])?i[0]:parseInt(i[0]),k=1==i.length?j:isNaN(i[1])?i[1]:parseInt(i[1]);if(h.quantifier={min:j,max:k},d.length>0){var l=d[d.length-1].matches;if(a=l.pop(),!a.isGroup){var e=new g(!0);e.matches.push(a),a=e}l.push(a),l.push(h)}else{if(a=c.matches.pop(),!a.isGroup){var e=new g(!0);e.matches.push(a),a=e}c.matches.push(a),c.matches.push(h)}break;default:d.length>0?d[d.length-1].matches.push(b):c.matches.push(b)}c.matches.length>0&&f.regexTokens.push(c)}function i(b,c){var d=!1;c&&(k+="(",m++);for(var e=0;ek.length&&!(d=i(h,!0)););d=d||i(h,!0),d&&(f.repeaterPart=k),k=j+f.quantifier.max}else{for(var l=0,o=f.quantifier.max-1;o>l&&!(d=i(h,!0));l++);k=j+"{"+f.quantifier.min+","+f.quantifier.max+"}"}}else if(void 0!=f.matches)for(var p=0;pr;r++)q+=")";var s=new RegExp("^("+q+")$");d=s.test(n)}else for(var t=0,u=f.length;u>t;t++)if("\\"!=f.charAt(t)){q=k,q+=f.substr(0,t+1),q=q.replace(/\|$/,"");for(var r=0;m>r;r++)q+=")";var s=new RegExp("^("+q+")$");if(d=s.test(n))break}k+=f}if(d)break}return c&&(k+=")",m--),d}null==f.regexTokens&&h();var j=c.buffer.slice(),k="",l=!1,m=0;j.splice(d,0,b);for(var n=j.join(""),o=0;o=b}},c.prototype.validateInput=function(b){var c=a(b.target),d=c.data("bs.validator.errors");if(c.is('[type="radio"]')&&(c=this.$element.find('input[name="'+c.attr("name")+'"]')),this.$element.trigger(b=a.Event("validate.bs.validator",{relatedTarget:c[0]})),!b.isDefaultPrevented()){var e=this;this.runValidators(c).done(function(f){c.data("bs.validator.errors",f),f.length?e.showErrors(c):e.clearErrors(c),d&&f.toString()===d.toString()||(b=f.length?a.Event("invalid.bs.validator",{relatedTarget:c[0],detail:f}):a.Event("valid.bs.validator",{relatedTarget:c[0],detail:d}),e.$element.trigger(b)),e.toggleSubmit(),e.$element.trigger(a.Event("validated.bs.validator",{relatedTarget:c[0]}))})}},c.prototype.runValidators=function(b){function d(a){return b.data(a+"-error")||b.data("error")||"native"==a&&b[0].validationMessage||g.errors[a]}var e=[],f=([c.VALIDATORS.native],a.Deferred()),g=this.options;return b.data("bs.validator.deferred")&&b.data("bs.validator.deferred").reject(),b.data("bs.validator.deferred",f),a.each(c.VALIDATORS,a.proxy(function(a,c){if((b.data(a)||"native"==a)&&!c.call(this,b)){var f=d(a);!~e.indexOf(f)&&e.push(f)}},this)),!e.length&&b.val()&&b.data("remote")?this.defer(b,function(){var c={};c[b.attr("name")]=b.val(),a.get(b.data("remote"),c).fail(function(a,b,c){e.push(d("remote")||c)}).always(function(){f.resolve(e)})}):f.resolve(e),f.promise()},c.prototype.validate=function(){var a=this.options.delay;return this.options.delay=0,this.$element.find(':input:not([type="hidden"])').trigger("input.bs.validator"),this.options.delay=a,this},c.prototype.showErrors=function(b){var c=this.options.html?"html":"text";this.defer(b,function(){var d=b.closest(".form-group"),e=d.find(".help-block.with-errors"),f=d.find(".form-control-feedback"),g=b.data("bs.validator.errors");g.length&&(g=a("").addClass("list-unstyled").append(a.map(g,function(b){return a(" ")[c](b)})),void 0===e.data("bs.validator.originalContent")&&e.data("bs.validator.originalContent",e.html()),e.empty().append(g),d.removeClass("has-success"),d.addClass("has-error"),f.removeClass("glyphicon-ok"),f.addClass("glyphicon-warning-sign"))})},c.prototype.clearErrors=function(a){var b=a.closest(".form-group"),c=b.find(".help-block.with-errors"),d=b.find(".form-control-feedback");c.html(c.data("bs.validator.originalContent")),b.removeClass("has-error"),b.addClass("has-success"),d.removeClass("glyphicon-warning-sign"),d.addClass("glyphicon-ok")},c.prototype.hasErrors=function(){function b(){return!!(a(this).data("bs.validator.errors")||[]).length}return!!this.$element.find(":input:enabled").filter(b).length},c.prototype.isIncomplete=function(){function b(){return"checkbox"===this.type?!this.checked:"radio"===this.type?!a('[name="'+this.name+'"]:checked').length:""===a.trim(this.value)}return!!this.$element.find(":input[required]:enabled").filter(b).length},c.prototype.onSubmit=function(a){this.validate(),(this.isIncomplete()||this.hasErrors())&&a.preventDefault()},c.prototype.toggleSubmit=function(){if(this.options.disable){var a=this.$element.find('input[type="submit"], button[type="submit"]');a.toggleClass("disabled",this.isIncomplete()||this.hasErrors()).css({"pointer-events":"all",cursor:"pointer"})}},c.prototype.defer=function(a,b){return this.options.delay?(window.clearTimeout(a.data("bs.validator.timeout")),void a.data("bs.validator.timeout",window.setTimeout(b,this.options.delay))):b()},c.prototype.destroy=function(){return this.$element.removeAttr("novalidate").removeData("bs.validator").off(".bs.validator"),this.$element.find(":input").off(".bs.validator").removeData(["bs.validator.errors","bs.validator.deferred"]).each(function(){var b=a(this),c=b.data("bs.validator.timeout");window.clearTimeout(c)&&b.removeData("bs.validator.timeout")}),this.$element.find(".help-block.with-errors").each(function(){var b=a(this),c=b.data("bs.validator.originalContent");b.removeData("bs.validator.originalContent").html(c)}),this.$element.find('input[type="submit"], button[type="submit"]').removeClass("disabled"),this.$element.find(".has-error").removeClass("has-error"),this};var d=a.fn.validator;a.fn.validator=b,a.fn.validator.Constructor=c,a.fn.validator.noConflict=function(){return a.fn.validator=d,this},a(window).on("load",function(){a('form[data-toggle="validator"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery);
!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):window.jQuery&&!window.jQuery.fn.colorpicker&&a(window.jQuery)}(function(a){"use strict";var b=function(a){this.value={h:0,s:0,b:0,a:1},this.origFormat=null,a&&(void 0!==a.toLowerCase?(a+="",this.setColor(a)):void 0!==a.h&&(this.value=a))};b.prototype={constructor:b,colors:{aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",honeydew:"#f0fff0",hotpink:"#ff69b4","indianred ":"#cd5c5c","indigo ":"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",transparent:"transparent"},_sanitizeNumber:function(a){return"number"==typeof a?a:isNaN(a)||null===a||""===a||void 0===a?1:void 0!==a.toLowerCase?parseFloat(a):1},isTransparent:function(a){return a?(a=a.toLowerCase().trim(),"transparent"==a||a.match(/#?00000000/)||a.match(/(rgba|hsla)\(0,0,0,0?\.?0\)/)):!1},rgbaIsTransparent:function(a){return 0==a.r&&0==a.g&&0==a.b&&0==a.a},setColor:function(a){a=a.toLowerCase().trim(),a&&(this.value=this.isTransparent(a)?{h:0,s:0,b:0,a:0}:this.stringToHSB(a)||{h:0,s:0,b:0,a:1})},stringToHSB:function(b){b=b.toLowerCase();var c=this,d=!1;return a.each(this.stringParsers,function(a,e){var f=e.re.exec(b),g=f&&e.parse.apply(c,[f]),h=e.format||"rgba";return g?(d=h.match(/hsla?/)?c.RGBtoHSB.apply(c,c.HSLtoRGB.apply(c,g)):c.RGBtoHSB.apply(c,g),c.origFormat=h,!1):!0}),d},setHue:function(a){this.value.h=1-a},setSaturation:function(a){this.value.s=a},setBrightness:function(a){this.value.b=1-a},setAlpha:function(a){this.value.a=parseInt(100*(1-a),10)/100},toRGB:function(a,b,c,d){a||(a=this.value.h,b=this.value.s,c=this.value.b),a*=360;var e,f,g,h,i;return a=a%360/60,i=c*b,h=i*(1-Math.abs(a%2-1)),e=f=g=c-i,a=~~a,e+=[i,h,0,0,h,i][a],f+=[h,i,i,h,0,0][a],g+=[0,0,h,i,i,h][a],{r:Math.round(255*e),g:Math.round(255*f),b:Math.round(255*g),a:d||this.value.a}},toHex:function(a,b,c,d){var e=this.toRGB(a,b,c,d);return this.rgbaIsTransparent(e)?"transparent":"#"+(1<<24|parseInt(e.r)<<16|parseInt(e.g)<<8|parseInt(e.b)).toString(16).substr(1)},toHSL:function(a,b,c,d){a=a||this.value.h,b=b||this.value.s,c=c||this.value.b,d=d||this.value.a;var e=a,f=(2-b)*c,g=b*c;return g/=f>0&&1>=f?f:2-f,f/=2,g>1&&(g=1),{h:isNaN(e)?0:e,s:isNaN(g)?0:g,l:isNaN(f)?0:f,a:isNaN(d)?0:d}},toAlias:function(a,b,c,d){var e=this.toHex(a,b,c,d);for(var f in this.colors)if(this.colors[f]==e)return f;return!1},RGBtoHSB:function(a,b,c,d){a/=255,b/=255,c/=255;var e,f,g,h;return g=Math.max(a,b,c),h=g-Math.min(a,b,c),e=0===h?null:g===a?(b-c)/h:g===b?(c-a)/h+2:(a-b)/h+4,e=(e+360)%6*60/360,f=0===h?0:h/g,{h:this._sanitizeNumber(e),s:f,b:g,a:this._sanitizeNumber(d)}},HueToRGB:function(a,b,c){return 0>c?c+=1:c>1&&(c-=1),1>6*c?a+(b-a)*c*6:1>2*c?b:2>3*c?a+(b-a)*(2/3-c)*6:a},HSLtoRGB:function(a,b,c,d){0>b&&(b=0);var e;e=.5>=c?c*(1+b):c+b-c*b;var f=2*c-e,g=a+1/3,h=a,i=a-1/3,j=Math.round(255*this.HueToRGB(f,e,g)),k=Math.round(255*this.HueToRGB(f,e,h)),l=Math.round(255*this.HueToRGB(f,e,i));return[j,k,l,this._sanitizeNumber(d)]},toString:function(a){switch(a=a||"rgba"){case"rgb":var b=this.toRGB();return this.rgbaIsTransparent(b)?"transparent":"rgb("+b.r+","+b.g+","+b.b+")";case"rgba":var b=this.toRGB();return"rgba("+b.r+","+b.g+","+b.b+","+b.a+")";case"hsl":var c=this.toHSL();return"hsl("+Math.round(360*c.h)+","+Math.round(100*c.s)+"%,"+Math.round(100*c.l)+"%)";case"hsla":var c=this.toHSL();return"hsla("+Math.round(360*c.h)+","+Math.round(100*c.s)+"%,"+Math.round(100*c.l)+"%,"+c.a+")";case"hex":return this.toHex();case"alias":return this.toAlias()||this.toHex();default:return!1}},stringParsers:[{re:/rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*?\)/,format:"rgb",parse:function(a){return[a[1],a[2],a[3],1]}},{re:/rgb\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*?\)/,format:"rgb",parse:function(a){return[2.55*a[1],2.55*a[2],2.55*a[3],1]}},{re:/rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,format:"rgba",parse:function(a){return[a[1],a[2],a[3],a[4]]}},{re:/rgba\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,format:"rgba",parse:function(a){return[2.55*a[1],2.55*a[2],2.55*a[3],a[4]]}},{re:/hsl\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*?\)/,format:"hsl",parse:function(a){return[a[1]/360,a[2]/100,a[3]/100,a[4]]}},{re:/hsla\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,format:"hsla",parse:function(a){return[a[1]/360,a[2]/100,a[3]/100,a[4]]}},{re:/#?([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,format:"hex",parse:function(a){return[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16),1]}},{re:/#?([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/,format:"hex",parse:function(a){return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16),1]}},{re:/^([a-z]{3,})$/,format:"alias",parse:function(a){var b=this.colorNameToHex(a[0])||"#000000",c=this.stringParsers[6].re.exec(b),d=c&&this.stringParsers[6].parse.apply(this,[c]);return d}}],colorNameToHex:function(a){return"undefined"!=typeof this.colors[a.toLowerCase()]?this.colors[a.toLowerCase()]:!1}};var c={horizontal:!1,inline:!1,color:!1,format:!1,input:"input",container:!1,component:".add-on, .input-group-addon",sliders:{saturation:{maxLeft:100,maxTop:100,callLeft:"setSaturation",callTop:"setBrightness"},hue:{maxLeft:0,maxTop:100,callLeft:!1,callTop:"setHue"},alpha:{maxLeft:0,maxTop:100,callLeft:!1,callTop:"setAlpha"}},slidersHorz:{saturation:{maxLeft:100,maxTop:100,callLeft:"setSaturation",callTop:"setBrightness"},hue:{maxLeft:100,maxTop:0,callLeft:"setHue",callTop:!1},alpha:{maxLeft:100,maxTop:0,callLeft:"setAlpha",callTop:!1}},template:'',align:"right",customClass:null},d=function(d,e){this.element=a(d).addClass("colorpicker-element"),this.options=a.extend(!0,{},c,this.element.data(),e),this.component=this.options.component,this.component=this.component!==!1?this.element.find(this.component):!1,this.component&&0===this.component.length&&(this.component=!1),this.container=this.options.container===!0?this.element:this.options.container,this.container=this.container!==!1?a(this.container):!1,this.input=this.element.is("input")?this.element:this.options.input?this.element.find(this.options.input):!1,this.input&&0===this.input.length&&(this.input=!1),this.color=new b(this.options.color!==!1?this.options.color:this.getValue()),this.format=this.options.format!==!1?this.options.format:this.color.origFormat,this.picker=a(this.options.template),this.options.customClass&&this.picker.addClass(this.options.customClass),this.picker.addClass(this.options.inline?"colorpicker-inline colorpicker-visible":"colorpicker-hidden"),this.options.horizontal&&this.picker.addClass("colorpicker-horizontal"),("rgba"===this.format||"hsla"===this.format||this.options.format===!1)&&this.picker.addClass("colorpicker-with-alpha"),"right"===this.options.align&&this.picker.addClass("colorpicker-right"),this.picker.on("mousedown.colorpicker touchstart.colorpicker",a.proxy(this.mousedown,this)),this.picker.appendTo(this.container?this.container:a("body")),this.input!==!1&&(this.input.on({"keyup.colorpicker":a.proxy(this.keyup,this)}),this.component===!1&&this.element.on({"focus.colorpicker":a.proxy(this.show,this)}),this.options.inline===!1&&this.element.on({"focusout.colorpicker":a.proxy(this.hide,this)})),this.component!==!1&&this.component.on({"click.colorpicker":a.proxy(this.show,this)}),this.input===!1&&this.component===!1&&this.element.on({"click.colorpicker":a.proxy(this.show,this)}),this.input!==!1&&this.component!==!1&&"color"===this.input.attr("type")&&this.input.on({"click.colorpicker":a.proxy(this.show,this),"focus.colorpicker":a.proxy(this.show,this)}),this.update(),a(a.proxy(function(){this.element.trigger("create")},this))};d.Color=b,d.prototype={constructor:d,destroy:function(){this.picker.remove(),this.element.removeData("colorpicker").off(".colorpicker"),this.input!==!1&&this.input.off(".colorpicker"),this.component!==!1&&this.component.off(".colorpicker"),this.element.removeClass("colorpicker-element"),this.element.trigger({type:"destroy"})},reposition:function(){if(this.options.inline!==!1||this.options.container)return!1;var a=this.container&&this.container[0]!==document.body?"position":"offset",b=this.component||this.element,c=b[a]();"right"===this.options.align&&(c.left-=this.picker.outerWidth()-b.outerWidth()),this.picker.css({top:c.top+b.outerHeight(),left:c.left})},show:function(b){return this.isDisabled()?!1:(this.picker.addClass("colorpicker-visible").removeClass("colorpicker-hidden"),this.reposition(),a(window).on("resize.colorpicker",a.proxy(this.reposition,this)),!b||this.hasInput()&&"color"!==this.input.attr("type")||b.stopPropagation&&b.preventDefault&&(b.stopPropagation(),b.preventDefault()),this.options.inline===!1&&a(window.document).on({"mousedown.colorpicker":a.proxy(this.hide,this)}),void this.element.trigger({type:"showPicker",color:this.color}))},hide:function(){this.picker.addClass("colorpicker-hidden").removeClass("colorpicker-visible"),a(window).off("resize.colorpicker",this.reposition),a(document).off({"mousedown.colorpicker":this.hide}),this.update(),this.element.trigger({type:"hidePicker",color:this.color})},updateData:function(a){return a=a||this.color.toString(this.format),this.element.data("color",a),a},updateInput:function(a){return a=a||this.color.toString(this.format),this.input!==!1&&this.input.prop("value",a),a},updatePicker:function(a){void 0!==a&&(this.color=new b(a));var c=this.options.horizontal===!1?this.options.sliders:this.options.slidersHorz,d=this.picker.find("i");return 0!==d.length?(this.options.horizontal===!1?(c=this.options.sliders,d.eq(1).css("top",c.hue.maxTop*(1-this.color.value.h)).end().eq(2).css("top",c.alpha.maxTop*(1-this.color.value.a))):(c=this.options.slidersHorz,d.eq(1).css("left",c.hue.maxLeft*(1-this.color.value.h)).end().eq(2).css("left",c.alpha.maxLeft*(1-this.color.value.a))),d.eq(0).css({top:c.saturation.maxTop-this.color.value.b*c.saturation.maxTop,left:this.color.value.s*c.saturation.maxLeft}),this.picker.find(".colorpicker-saturation").css("backgroundColor",this.color.toHex(this.color.value.h,1,1,1)),this.picker.find(".colorpicker-alpha").css("backgroundColor",this.color.toHex()),this.picker.find(".colorpicker-color, .colorpicker-color div").css("backgroundColor",this.color.toString(this.format)),a):void 0},updateComponent:function(a){if(a=a||this.color.toString(this.format),this.component!==!1){var b=this.component.find("i").eq(0);b.length>0?b.css({backgroundColor:a}):this.component.css({backgroundColor:a})}return a},update:function(a){var b;return(this.getValue(!1)!==!1||a===!0)&&(b=this.updateComponent(),this.updateInput(b),this.updateData(b),this.updatePicker()),b},setValue:function(a){this.color=new b(a),this.update(),this.element.trigger({type:"changeColor",color:this.color,value:a})},getValue:function(a){a=void 0===a?"#000000":a;var b;return b=this.hasInput()?this.input.val():this.element.data("color"),(void 0===b||""===b||null===b)&&(b=a),b},hasInput:function(){return this.input!==!1},isDisabled:function(){return this.hasInput()?this.input.prop("disabled")===!0:!1},disable:function(){return this.hasInput()?(this.input.prop("disabled",!0),this.element.trigger({type:"disable",color:this.color,value:this.getValue()}),!0):!1},enable:function(){return this.hasInput()?(this.input.prop("disabled",!1),this.element.trigger({type:"enable",color:this.color,value:this.getValue()}),!0):!1},currentSlider:null,mousePointer:{left:0,top:0},mousedown:function(b){b.pageX||b.pageY||!b.originalEvent||(b.pageX=b.originalEvent.touches[0].pageX,b.pageY=b.originalEvent.touches[0].pageY),b.stopPropagation(),b.preventDefault();var c=a(b.target),d=c.closest("div"),e=this.options.horizontal?this.options.slidersHorz:this.options.sliders;if(!d.is(".colorpicker")){if(d.is(".colorpicker-saturation"))this.currentSlider=a.extend({},e.saturation);else if(d.is(".colorpicker-hue"))this.currentSlider=a.extend({},e.hue);else{if(!d.is(".colorpicker-alpha"))return!1;this.currentSlider=a.extend({},e.alpha)}var f=d.offset();this.currentSlider.guide=d.find("i")[0].style,this.currentSlider.left=b.pageX-f.left,this.currentSlider.top=b.pageY-f.top,this.mousePointer={left:b.pageX,top:b.pageY},a(document).on({"mousemove.colorpicker":a.proxy(this.mousemove,this),"touchmove.colorpicker":a.proxy(this.mousemove,this),"mouseup.colorpicker":a.proxy(this.mouseup,this),"touchend.colorpicker":a.proxy(this.mouseup,this)}).trigger("mousemove")}return!1},mousemove:function(a){a.pageX||a.pageY||!a.originalEvent||(a.pageX=a.originalEvent.touches[0].pageX,a.pageY=a.originalEvent.touches[0].pageY),a.stopPropagation(),a.preventDefault();var b=Math.max(0,Math.min(this.currentSlider.maxLeft,this.currentSlider.left+((a.pageX||this.mousePointer.left)-this.mousePointer.left))),c=Math.max(0,Math.min(this.currentSlider.maxTop,this.currentSlider.top+((a.pageY||this.mousePointer.top)-this.mousePointer.top)));return this.currentSlider.guide.left=b+"px",this.currentSlider.guide.top=c+"px",this.currentSlider.callLeft&&this.color[this.currentSlider.callLeft].call(this.color,b/this.currentSlider.maxLeft),this.currentSlider.callTop&&this.color[this.currentSlider.callTop].call(this.color,c/this.currentSlider.maxTop),"setAlpha"==this.currentSlider.callTop&&this.options.format===!1&&(1!=this.color.value.a?(this.format="rgba",this.color.origFormat="rgba"):(this.format="hex",this.color.origFormat="hex")),this.update(!0),this.element.trigger({type:"changeColor",color:this.color}),!1},mouseup:function(b){return b.stopPropagation(),b.preventDefault(),a(document).off({"mousemove.colorpicker":this.mousemove,"touchmove.colorpicker":this.mousemove,"mouseup.colorpicker":this.mouseup,"touchend.colorpicker":this.mouseup}),!1},keyup:function(a){if(38===a.keyCode)this.color.value.a<1&&(this.color.value.a=Math.round(100*(this.color.value.a+.01))/100),this.update(!0);else if(40===a.keyCode)this.color.value.a>0&&(this.color.value.a=Math.round(100*(this.color.value.a-.01))/100),this.update(!0);else{var c=this.input.val();this.color=new b(c),this.color.origFormat&&this.options.format===!1&&(this.format=this.color.origFormat),this.getValue(!1)!==!1&&(this.updateData(),this.updateComponent(),this.updatePicker())}this.element.trigger({type:"changeColor",color:this.color,value:c})}},a.colorpicker=d,a.fn.colorpicker=function(b){var c,e=arguments,f=this.each(function(){var f=a(this),g=f.data("colorpicker"),h="object"==typeof b?b:{};g||"string"==typeof b?"string"==typeof b&&(c=g[b].apply(g,Array.prototype.slice.call(e,1))):f.data("colorpicker",new d(this,h))});return"getValue"===b?c:f},a.fn.colorpicker.constructor=d});
/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
* If set to null or omitted, the cookie will be a session cookie and will not be retained
* when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
* require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
var path = options.path ? '; path=' + options.path : '';
var domain = options.domain ? '; domain=' + options.domain : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};
/*
* Treeview 1.4 - jQuery plugin to hide and show branches of a tree
*
* http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
* http://docs.jquery.com/Plugins/Treeview
*
* Copyright (c) 2007 Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Revision: $Id: jquery.treeview.js 4684 2008-02-07 19:08:06Z joern.zaefferer $
*
*/
;(function($) {
$.extend($.fn, {
swapClass: function(c1, c2) {
var c1Elements = this.filter('.' + c1);
this.filter('.' + c2).removeClass(c2).addClass(c1);
c1Elements.removeClass(c1).addClass(c2);
return this;
},
replaceClass: function(c1, c2) {
return this.filter('.' + c1).removeClass(c1).addClass(c2).end();
},
hoverClass: function(className) {
className = className || "hover";
return this.hover(function() {
$(this).addClass(className);
}, function() {
$(this).removeClass(className);
});
},
heightToggle: function(animated, callback) {
animated ?
this.animate({ height: "toggle" }, animated, callback) :
this.each(function(){
jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
if(callback)
callback.apply(this, arguments);
});
},
heightHide: function(animated, callback) {
if (animated) {
this.animate({ height: "hide" }, animated, callback);
} else {
this.hide();
if (callback)
this.each(callback);
}
},
prepareBranches: function(settings) {
if (!settings.prerendered) {
// mark last tree items
this.filter(":last-child:not(ul)").addClass(CLASSES.last);
// collapse whole tree, or only those marked as closed, anyway except those marked as open
this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide();
}
// return all items with sublists
return this.filter(":has(>ul)");
},
applyClasses: function(settings, toggler) {
this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event) {
toggler.apply($(this).next());
}).add( $("a", this) ).hoverClass();
if (!settings.prerendered) {
// handle closed ones first
this.filter(":has(>ul:hidden)")
.addClass(CLASSES.expandable)
.replaceClass(CLASSES.last, CLASSES.lastExpandable);
// handle open ones
this.not(":has(>ul:hidden)")
.addClass(CLASSES.collapsable)
.replaceClass(CLASSES.last, CLASSES.lastCollapsable);
// create hitarea
this.prepend("
").find("div." + CLASSES.hitarea).each(function() {
var classes = "";
$.each($(this).parent().attr("class").split(" "), function() {
classes += this + "-hitarea ";
});
$(this).addClass( classes );
});
}
// apply event to hitarea
this.find("div." + CLASSES.hitarea).click( toggler );
},
treeview: function(settings) {
settings = $.extend({
cookieId: "treeview"
}, settings);
if (settings.add) {
return this.trigger("add", [settings.add]);
}
if ( settings.toggle ) {
var callback = settings.toggle;
settings.toggle = function() {
return callback.apply($(this).parent()[0], arguments);
};
}
// factory for treecontroller
function treeController(tree, control) {
// factory for click handlers
function handler(filter) {
return function() {
// reuse toggle event handler, applying the elements to toggle
// start searching for all hitareas
toggler.apply( $("div." + CLASSES.hitarea, tree).filter(function() {
// for plain toggle, no filter is provided, otherwise we need to check the parent element
return filter ? $(this).parent("." + filter).length : true;
}) );
return false;
};
}
// click on first element to collapse tree
$("a:eq(0)", control).click( handler(CLASSES.collapsable) );
// click on second to expand tree
$("a:eq(1)", control).click( handler(CLASSES.expandable) );
// click on third to toggle tree
$("a:eq(2)", control).click( handler() );
}
// handle toggle event
function toggler() {
$(this)
.parent()
// swap classes for hitarea
.find(">.hitarea")
.swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
.swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea )
.end()
// swap classes for parent li
.swapClass( CLASSES.collapsable, CLASSES.expandable )
.swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
// find child lists
.find( ">ul" )
// toggle them
.heightToggle( settings.animated, settings.toggle );
if ( settings.unique ) {
$(this).parent()
.siblings()
// swap classes for hitarea
.find(">.hitarea")
.replaceClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea )
.replaceClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea )
.end()
.replaceClass( CLASSES.collapsable, CLASSES.expandable )
.replaceClass( CLASSES.lastCollapsable, CLASSES.lastExpandable )
.find( ">ul" )
.heightHide( settings.animated, settings.toggle );
}
}
function serialize() {
function binary(arg) {
return arg ? 1 : 0;
}
var data = [];
branches.each(function(i, e) {
data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0;
});
$.cookie(settings.cookieId, data.join("") );
}
function deserialize() {
var stored = $.cookie(settings.cookieId);
if ( stored ) {
var data = stored.split("");
branches.each(function(i, e) {
$(e).find(">ul")[ parseInt(data[i]) ? "show" : "hide" ]();
});
}
}
// add treeview class to activate styles
this.addClass("treeview");
// prepare branches and find all tree items with child lists
var branches = this.find("li").prepareBranches(settings);
switch(settings.persist) {
case "cookie":
var toggleCallback = settings.toggle;
settings.toggle = function() {
serialize();
if (toggleCallback) {
toggleCallback.apply(this, arguments);
}
};
deserialize();
break;
case "location":
var current = this.find("a").filter(function() { return this.href.toLowerCase() == location.href.toLowerCase(); });
if ( current.length ) {
current.addClass("selected").parents("ul, li").add( current.next() ).show();
}
break;
}
branches.applyClasses(settings, toggler);
// if control option is set, create the treecontroller and show it
if ( settings.control ) {
treeController(this, settings.control);
$(settings.control).show();
}
return this.bind("add", function(event, branches) {
$(branches).prev()
.removeClass(CLASSES.last)
.removeClass(CLASSES.lastCollapsable)
.removeClass(CLASSES.lastExpandable)
.find(">.hitarea")
.removeClass(CLASSES.lastCollapsableHitarea)
.removeClass(CLASSES.lastExpandableHitarea);
$(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings, toggler);
});
}
});
// classes used by the plugin
// need to be styled via external stylesheet, see first example
var CLASSES = $.fn.treeview.classes = {
open: "open",
closed: "closed",
expandable: "expandable",
expandableHitarea: "expandable-hitarea",
lastExpandableHitarea: "lastExpandable-hitarea",
collapsable: "collapsable",
collapsableHitarea: "collapsable-hitarea",
lastCollapsableHitarea: "lastCollapsable-hitarea",
lastCollapsable: "lastCollapsable",
lastExpandable: "lastExpandable",
last: "last",
hitarea: "hitarea"
};
// provide backwards compability
$.fn.Treeview = $.fn.treeview;
})(jQuery);
/**
* @preserve jQuery DateTimePicker plugin v2.4.3
* @homepage http://xdsoft.net/jqplugins/datetimepicker/
* (c) 2014, Chupurnov Valeriy.
*/
/*global document,window,jQuery,setTimeout,clearTimeout,HighlightedDate,getCurrentValue*/
(function ($) {
'use strict';
var default_options = {
i18n: {
ar: { // Arabic
months: [
"كانون الثاني", "شباط", "آذار", "نيسان", "مايو", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"
],
dayOfWeek: [
"ن", "ث", "ع", "خ", "ج", "س", "ح"
]
},
ro: { // Romanian
months: [
"ianuarie", "februarie", "martie", "aprilie", "mai", "iunie", "iulie", "august", "septembrie", "octombrie", "noiembrie", "decembrie"
],
dayOfWeek: [
"l", "ma", "mi", "j", "v", "s", "d"
]
},
id: { // Indonesian
months: [
"Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"
],
dayOfWeek: [
"Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"
]
},
bg: { // Bulgarian
months: [
"Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"
],
dayOfWeek: [
"Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
]
},
fa: { // Persian/Farsi
months: [
'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'
],
dayOfWeek: [
'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'
]
},
ru: { // Russian
months: [
'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'
],
dayOfWeek: [
"Вск", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
]
},
uk: { // Ukrainian
months: [
'Січень', 'Лютий', 'Березень', 'Квітень', 'Травень', 'Червень', 'Липень', 'Серпень', 'Вересень', 'Жовтень', 'Листопад', 'Грудень'
],
dayOfWeek: [
"Ндл", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Сбт"
]
},
en: { // English
months: [
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
],
dayOfWeek: [
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
]
},
el: { // Ελληνικά
months: [
"Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"
],
dayOfWeek: [
"Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ"
]
},
de: { // German
months: [
'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'
],
dayOfWeek: [
"So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"
]
},
nl: { // Dutch
months: [
"januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"
],
dayOfWeek: [
"zo", "ma", "di", "wo", "do", "vr", "za"
]
},
tr: { // Turkish
months: [
"Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"
],
dayOfWeek: [
"Paz", "Pts", "Sal", "Çar", "Per", "Cum", "Cts"
]
},
fr: { //French
months: [
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
],
dayOfWeek: [
"Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"
]
},
es: { // Spanish
months: [
"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"
],
dayOfWeek: [
"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"
]
},
th: { // Thai
months: [
'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'
],
dayOfWeek: [
'อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'
]
},
pl: { // Polish
months: [
"styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień"
],
dayOfWeek: [
"nd", "pn", "wt", "śr", "cz", "pt", "sb"
]
},
pt: { // Portuguese
months: [
"Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
],
dayOfWeek: [
"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"
]
},
ch: { // Simplified Chinese
months: [
"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
],
dayOfWeek: [
"日", "一", "二", "三", "四", "五", "六"
]
},
se: { // Swedish
months: [
"Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"
],
dayOfWeek: [
"Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
]
},
kr: { // Korean
months: [
"1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
],
dayOfWeek: [
"일", "월", "화", "수", "목", "금", "토"
]
},
it: { // Italian
months: [
"Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"
],
dayOfWeek: [
"Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"
]
},
da: { // Dansk
months: [
"January", "Februar", "Marts", "April", "Maj", "Juni", "July", "August", "September", "Oktober", "November", "December"
],
dayOfWeek: [
"Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
]
},
no: { // Norwegian
months: [
"Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember"
],
dayOfWeek: [
"Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
]
},
ja: { // Japanese
months: [
"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"
],
dayOfWeek: [
"日", "月", "火", "水", "木", "金", "土"
]
},
vi: { // Vietnamese
months: [
"Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12"
],
dayOfWeek: [
"CN", "T2", "T3", "T4", "T5", "T6", "T7"
]
},
sl: { // Slovenščina
months: [
"Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December"
],
dayOfWeek: [
"Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob"
]
},
cs: { // Čeština
months: [
"Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"
],
dayOfWeek: [
"Ne", "Po", "Út", "St", "Čt", "Pá", "So"
]
},
hu: { // Hungarian
months: [
"Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"
],
dayOfWeek: [
"Va", "Hé", "Ke", "Sze", "Cs", "Pé", "Szo"
]
},
az: { //Azerbaijanian (Azeri)
months: [
"Yanvar", "Fevral", "Mart", "Aprel", "May", "Iyun", "Iyul", "Avqust", "Sentyabr", "Oktyabr", "Noyabr", "Dekabr"
],
dayOfWeek: [
"B", "Be", "Ça", "Ç", "Ca", "C", "Ş"
]
},
bs: { //Bosanski
months: [
"Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
],
dayOfWeek: [
"Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
]
},
ca: { //Català
months: [
"Gener", "Febrer", "Març", "Abril", "Maig", "Juny", "Juliol", "Agost", "Setembre", "Octubre", "Novembre", "Desembre"
],
dayOfWeek: [
"Dg", "Dl", "Dt", "Dc", "Dj", "Dv", "Ds"
]
},
'en-GB': { //English (British)
months: [
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
],
dayOfWeek: [
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
]
},
et: { //"Eesti"
months: [
"Jaanuar", "Veebruar", "Märts", "Aprill", "Mai", "Juuni", "Juuli", "August", "September", "Oktoober", "November", "Detsember"
],
dayOfWeek: [
"P", "E", "T", "K", "N", "R", "L"
]
},
eu: { //Euskara
months: [
"Urtarrila", "Otsaila", "Martxoa", "Apirila", "Maiatza", "Ekaina", "Uztaila", "Abuztua", "Iraila", "Urria", "Azaroa", "Abendua"
],
dayOfWeek: [
"Ig.", "Al.", "Ar.", "Az.", "Og.", "Or.", "La."
]
},
fi: { //Finnish (Suomi)
months: [
"Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu"
],
dayOfWeek: [
"Su", "Ma", "Ti", "Ke", "To", "Pe", "La"
]
},
gl: { //Galego
months: [
"Xan", "Feb", "Maz", "Abr", "Mai", "Xun", "Xul", "Ago", "Set", "Out", "Nov", "Dec"
],
dayOfWeek: [
"Dom", "Lun", "Mar", "Mer", "Xov", "Ven", "Sab"
]
},
hr: { //Hrvatski
months: [
"Siječanj", "Veljača", "Ožujak", "Travanj", "Svibanj", "Lipanj", "Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac"
],
dayOfWeek: [
"Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
]
},
ko: { //Korean (한국어)
months: [
"1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
],
dayOfWeek: [
"일", "월", "화", "수", "목", "금", "토"
]
},
lt: { //Lithuanian (lietuvių)
months: [
"Sausio", "Vasario", "Kovo", "Balandžio", "Gegužės", "Birželio", "Liepos", "Rugpjūčio", "Rugsėjo", "Spalio", "Lapkričio", "Gruodžio"
],
dayOfWeek: [
"Sek", "Pir", "Ant", "Tre", "Ket", "Pen", "Šeš"
]
},
lv: { //Latvian (Latviešu)
months: [
"Janvāris", "Februāris", "Marts", "Aprīlis ", "Maijs", "Jūnijs", "Jūlijs", "Augusts", "Septembris", "Oktobris", "Novembris", "Decembris"
],
dayOfWeek: [
"Sv", "Pr", "Ot", "Tr", "Ct", "Pk", "St"
]
},
mk: { //Macedonian (Македонски)
months: [
"јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември"
],
dayOfWeek: [
"нед", "пон", "вто", "сре", "чет", "пет", "саб"
]
},
mn: { //Mongolian (Монгол)
months: [
"1-р сар", "2-р сар", "3-р сар", "4-р сар", "5-р сар", "6-р сар", "7-р сар", "8-р сар", "9-р сар", "10-р сар", "11-р сар", "12-р сар"
],
dayOfWeek: [
"Дав", "Мяг", "Лха", "Пүр", "Бсн", "Бям", "Ням"
]
},
'pt-BR': { //Português(Brasil)
months: [
"Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
],
dayOfWeek: [
"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"
]
},
sk: { //Slovenčina
months: [
"Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December"
],
dayOfWeek: [
"Ne", "Po", "Ut", "St", "Št", "Pi", "So"
]
},
sq: { //Albanian (Shqip)
months: [
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
],
dayOfWeek: [
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
]
},
'sr-YU': { //Serbian (Srpski)
months: [
"Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
],
dayOfWeek: [
"Ned", "Pon", "Uto", "Sre", "čet", "Pet", "Sub"
]
},
sr: { //Serbian Cyrillic (Српски)
months: [
"јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"
],
dayOfWeek: [
"нед", "пон", "уто", "сре", "чет", "пет", "суб"
]
},
sv: { //Svenska
months: [
"Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"
],
dayOfWeek: [
"Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
]
},
'zh-TW': { //Traditional Chinese (繁體中文)
months: [
"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
],
dayOfWeek: [
"日", "一", "二", "三", "四", "五", "六"
]
},
zh: { //Simplified Chinese (简体中文)
months: [
"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
],
dayOfWeek: [
"日", "一", "二", "三", "四", "五", "六"
]
},
he: { //Hebrew (עברית)
months: [
'ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר'
],
dayOfWeek: [
'א\'', 'ב\'', 'ג\'', 'ד\'', 'ה\'', 'ו\'', 'שבת'
]
},
hy: { // Armenian
months: [
"Հունվար", "Փետրվար", "Մարտ", "Ապրիլ", "Մայիս", "Հունիս", "Հուլիս", "Օգոստոս", "Սեպտեմբեր", "Հոկտեմբեր", "Նոյեմբեր", "Դեկտեմբեր"
],
dayOfWeek: [
"Կի", "Երկ", "Երք", "Չոր", "Հնգ", "Ուրբ", "Շբթ"
]
},
kg: { // Kyrgyz
months: [
'Үчтүн айы', 'Бирдин айы', 'Жалган Куран', 'Чын Куран', 'Бугу', 'Кулжа', 'Теке', 'Баш Оона', 'Аяк Оона', 'Тогуздун айы', 'Жетинин айы', 'Бештин айы'
],
dayOfWeek: [
"Жек", "Дүй", "Шей", "Шар", "Бей", "Жум", "Ише"
]
}
},
value: '',
lang: 'en',
format: 'Y/m/d H:i',
formatTime: 'H:i',
formatDate: 'Y/m/d',
startDate: false, // new Date(), '1986/12/08', '-1970/01/05','-1970/01/05',
step: 60,
monthChangeSpinner: true,
closeOnDateSelect: false,
closeOnTimeSelect: true,
closeOnWithoutClick: true,
closeOnInputClick: true,
timepicker: true,
datepicker: true,
weeks: false,
defaultTime: false, // use formatTime format (ex. '10:00' for formatTime: 'H:i')
defaultDate: false, // use formatDate format (ex new Date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05')
minDate: false,
maxDate: false,
minTime: false,
maxTime: false,
allowTimes: [],
opened: false,
initTime: true,
inline: false,
theme: '',
onSelectDate: function () {},
onSelectTime: function () {},
onChangeMonth: function () {},
onChangeYear: function () {},
onChangeDateTime: function () {},
onShow: function () {},
onClose: function () {},
onGenerate: function () {},
withoutCopyright: true,
inverseButton: false,
hours12: false,
next: 'xdsoft_next',
prev : 'xdsoft_prev',
dayOfWeekStart: 0,
parentID: 'body',
timeHeightInTimePicker: 25,
timepickerScrollbar: true,
todayButton: true,
prevButton: true,
nextButton: true,
defaultSelect: true,
scrollMonth: true,
scrollTime: true,
scrollInput: true,
lazyInit: false,
mask: false,
validateOnBlur: true,
allowBlank: true,
yearStart: 1950,
yearEnd: 2050,
monthStart: 0,
monthEnd: 11,
style: '',
id: '',
fixed: false,
roundTime: 'round', // ceil, floor
className: '',
weekends: [],
highlightedDates: [],
highlightedPeriods: [],
disabledDates : [],
yearOffset: 0,
beforeShowDay: null,
enterLikeTab: true,
showApplyButton: false
};
// fix for ie8
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (obj, start) {
var i, j;
for (i = (start || 0), j = this.length; i < j; i += 1) {
if (this[i] === obj) { return i; }
}
return -1;
};
}
Date.prototype.countDaysInMonth = function () {
return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate();
};
$.fn.xdsoftScroller = function (percent) {
return this.each(function () {
var timeboxparent = $(this),
pointerEventToXY = function (e) {
var out = {x: 0, y: 0},
touch;
if (e.type === 'touchstart' || e.type === 'touchmove' || e.type === 'touchend' || e.type === 'touchcancel') {
touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
out.x = touch.clientX;
out.y = touch.clientY;
} else if (e.type === 'mousedown' || e.type === 'mouseup' || e.type === 'mousemove' || e.type === 'mouseover' || e.type === 'mouseout' || e.type === 'mouseenter' || e.type === 'mouseleave') {
out.x = e.clientX;
out.y = e.clientY;
}
return out;
},
move = 0,
timebox,
parentHeight,
height,
scrollbar,
scroller,
maximumOffset = 100,
start = false,
startY = 0,
startTop = 0,
h1 = 0,
touchStart = false,
startTopScroll = 0,
calcOffset = function () {};
if (percent === 'hide') {
timeboxparent.find('.xdsoft_scrollbar').hide();
return;
}
if (!$(this).hasClass('xdsoft_scroller_box')) {
timebox = timeboxparent.children().eq(0);
parentHeight = timeboxparent[0].clientHeight;
height = timebox[0].offsetHeight;
scrollbar = $('
');
scroller = $('
');
scrollbar.append(scroller);
timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar);
calcOffset = function calcOffset(event) {
var offset = pointerEventToXY(event).y - startY + startTopScroll;
if (offset < 0) {
offset = 0;
}
if (offset + scroller[0].offsetHeight > h1) {
offset = h1 - scroller[0].offsetHeight;
}
timeboxparent.trigger('scroll_element.xdsoft_scroller', [maximumOffset ? offset / maximumOffset : 0]);
};
scroller
.on('touchstart.xdsoft_scroller mousedown.xdsoft_scroller', function (event) {
if (!parentHeight) {
timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
}
startY = pointerEventToXY(event).y;
startTopScroll = parseInt(scroller.css('margin-top'), 10);
h1 = scrollbar[0].offsetHeight;
if (event.type === 'mousedown') {
if (document) {
$(document.body).addClass('xdsoft_noselect');
}
$([document.body, window]).on('mouseup.xdsoft_scroller', function arguments_callee() {
$([document.body, window]).off('mouseup.xdsoft_scroller', arguments_callee)
.off('mousemove.xdsoft_scroller', calcOffset)
.removeClass('xdsoft_noselect');
});
$(document.body).on('mousemove.xdsoft_scroller', calcOffset);
} else {
touchStart = true;
event.stopPropagation();
event.preventDefault();
}
})
.on('touchmove', function (event) {
if (touchStart) {
event.preventDefault();
calcOffset(event);
}
})
.on('touchend touchcancel', function (event) {
touchStart = false;
startTopScroll = 0;
});
timeboxparent
.on('scroll_element.xdsoft_scroller', function (event, percentage) {
if (!parentHeight) {
timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percentage, true]);
}
percentage = percentage > 1 ? 1 : (percentage < 0 || isNaN(percentage)) ? 0 : percentage;
scroller.css('margin-top', maximumOffset * percentage);
setTimeout(function () {
timebox.css('marginTop', -parseInt((timebox[0].offsetHeight - parentHeight) * percentage, 10));
}, 10);
})
.on('resize_scroll.xdsoft_scroller', function (event, percentage, noTriggerScroll) {
var percent, sh;
parentHeight = timeboxparent[0].clientHeight;
height = timebox[0].offsetHeight;
percent = parentHeight / height;
sh = percent * scrollbar[0].offsetHeight;
if (percent > 1) {
scroller.hide();
} else {
scroller.show();
scroller.css('height', parseInt(sh > 10 ? sh : 10, 10));
maximumOffset = scrollbar[0].offsetHeight - scroller[0].offsetHeight;
if (noTriggerScroll !== true) {
timeboxparent.trigger('scroll_element.xdsoft_scroller', [percentage || Math.abs(parseInt(timebox.css('marginTop'), 10)) / (height - parentHeight)]);
}
}
});
timeboxparent.on('mousewheel', function (event) {
var top = Math.abs(parseInt(timebox.css('marginTop'), 10));
top = top - (event.deltaY * 20);
if (top < 0) {
top = 0;
}
timeboxparent.trigger('scroll_element.xdsoft_scroller', [top / (height - parentHeight)]);
event.stopPropagation();
return false;
});
timeboxparent.on('touchstart', function (event) {
start = pointerEventToXY(event);
startTop = Math.abs(parseInt(timebox.css('marginTop'), 10));
});
timeboxparent.on('touchmove', function (event) {
if (start) {
event.preventDefault();
var coord = pointerEventToXY(event);
timeboxparent.trigger('scroll_element.xdsoft_scroller', [(startTop - (coord.y - start.y)) / (height - parentHeight)]);
}
});
timeboxparent.on('touchend touchcancel', function (event) {
start = false;
startTop = 0;
});
}
timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
});
};
$.fn.datetimepicker = function (opt) {
var KEY0 = 48,
KEY9 = 57,
_KEY0 = 96,
_KEY9 = 105,
CTRLKEY = 17,
DEL = 46,
ENTER = 13,
ESC = 27,
BACKSPACE = 8,
ARROWLEFT = 37,
ARROWUP = 38,
ARROWRIGHT = 39,
ARROWDOWN = 40,
TAB = 9,
F5 = 116,
AKEY = 65,
CKEY = 67,
VKEY = 86,
ZKEY = 90,
YKEY = 89,
ctrlDown = false,
options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
lazyInitTimer = 0,
createDateTimePicker,
destroyDateTimePicker,
lazyInit = function (input) {
input
.on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function initOnActionCallback(event) {
if (input.is(':disabled') || input.data('xdsoft_datetimepicker')) {
return;
}
clearTimeout(lazyInitTimer);
lazyInitTimer = setTimeout(function () {
if (!input.data('xdsoft_datetimepicker')) {
createDateTimePicker(input);
}
input
.off('open.xdsoft focusin.xdsoft mousedown.xdsoft', initOnActionCallback)
.trigger('open.xdsoft');
}, 100);
});
};
createDateTimePicker = function (input) {
var datetimepicker = $('
'),
xdsoft_copyright = $(''),
datepicker = $('
'),
mounth_picker = $(''),
calendar = $('
'),
timepicker = $(''),
timeboxparent = timepicker.find('.xdsoft_time_box').eq(0),
timebox = $('
'),
applyButton = $('Save Selected '),
/*scrollbar = $('
'),
scroller = $('
'),*/
monthselect = $(''),
yearselect = $(''),
triggerAfterOpen = false,
XDSoft_datetime,
//scroll_element,
xchangeTimer,
timerclick,
current_time_index,
setPos,
timer = 0,
timer1 = 0,
_xdsoft_datetime;
if (options.id) datetimepicker.attr('id', options.id);
if (options.style) datetimepicker.attr('style', options.style);
if (options.weeks) datetimepicker.addClass('xdsoft_showweeks');
datetimepicker.addClass('xdsoft_' + options.theme);
datetimepicker.addClass(options.className);
mounth_picker
.find('.xdsoft_month span')
.after(monthselect);
mounth_picker
.find('.xdsoft_year span')
.after(yearselect);
mounth_picker
.find('.xdsoft_month,.xdsoft_year')
.on('mousedown.xdsoft', function (event) {
var select = $(this).find('.xdsoft_select').eq(0),
val = 0,
top = 0,
visible = select.is(':visible'),
items,
i;
mounth_picker
.find('.xdsoft_select')
.hide();
if (_xdsoft_datetime.currentTime) {
val = _xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month') ? 'getMonth' : 'getFullYear']();
}
select[visible ? 'hide' : 'show']();
for (items = select.find('div.xdsoft_option'), i = 0; i < items.length; i += 1) {
if (items.eq(i).data('value') === val) {
break;
} else {
top += items[0].offsetHeight;
}
}
select.xdsoftScroller(top / (select.children()[0].offsetHeight - (select[0].clientHeight)));
event.stopPropagation();
return false;
});
mounth_picker
.find('.xdsoft_select')
.xdsoftScroller()
.on('mousedown.xdsoft', function (event) {
event.stopPropagation();
event.preventDefault();
})
.on('mousedown.xdsoft', '.xdsoft_option', function (event) {
if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
}
var year = _xdsoft_datetime.currentTime.getFullYear();
if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
_xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect') ? 'setMonth' : 'setFullYear']($(this).data('value'));
}
$(this).parent().parent().hide();
datetimepicker.trigger('xchange.xdsoft');
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
});
datetimepicker.setOptions = function (_options) {
var highlightedDates = {},
getCaretPos = function (input) {
try {
if (document.selection && document.selection.createRange) {
var range = document.selection.createRange();
return range.getBookmark().charCodeAt(2) - 2;
}
if (input.setSelectionRange) {
return input.selectionStart;
}
} catch (e) {
return 0;
}
},
setCaretPos = function (node, pos) {
node = (typeof node === "string" || node instanceof String) ? document.getElementById(node) : node;
if (!node) {
return false;
}
if (node.createTextRange) {
var textRange = node.createTextRange();
textRange.collapse(true);
textRange.moveEnd('character', pos);
textRange.moveStart('character', pos);
textRange.select();
return true;
}
if (node.setSelectionRange) {
node.setSelectionRange(pos, pos);
return true;
}
return false;
},
isValidValue = function (mask, value) {
var reg = mask
.replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1')
.replace(/_/g, '{digit+}')
.replace(/([0-9]{1})/g, '{digit$1}')
.replace(/\{digit([0-9]{1})\}/g, '[0-$1_]{1}')
.replace(/\{digit[\+]\}/g, '[0-9_]{1}');
return (new RegExp(reg)).test(value);
};
options = $.extend(true, {}, options, _options);
if (_options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length) {
options.allowTimes = $.extend(true, [], _options.allowTimes);
}
if (_options.weekends && $.isArray(_options.weekends) && _options.weekends.length) {
options.weekends = $.extend(true, [], _options.weekends);
}
if (_options.highlightedDates && $.isArray(_options.highlightedDates) && _options.highlightedDates.length) {
$.each(_options.highlightedDates, function (index, value) {
var splitData = $.map(value.split(','), $.trim),
exDesc,
hDate = new HighlightedDate(Date.parseDate(splitData[0], options.formatDate), splitData[1], splitData[2]), // date, desc, style
keyDate = hDate.date.dateFormat(options.formatDate);
if (highlightedDates[keyDate] !== undefined) {
exDesc = highlightedDates[keyDate].desc;
if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
}
} else {
highlightedDates[keyDate] = hDate;
}
});
options.highlightedDates = $.extend(true, [], highlightedDates);
}
if (_options.highlightedPeriods && $.isArray(_options.highlightedPeriods) && _options.highlightedPeriods.length) {
highlightedDates = $.extend(true, [], options.highlightedDates);
$.each(_options.highlightedPeriods, function (index, value) {
var splitData = $.map(value.split(','), $.trim),
dateTest = Date.parseDate(splitData[0], options.formatDate), // start date
dateEnd = Date.parseDate(splitData[1], options.formatDate),
desc = splitData[2],
hDate,
keyDate,
exDesc,
style = splitData[3];
while (dateTest <= dateEnd) {
hDate = new HighlightedDate(dateTest, desc, style);
keyDate = dateTest.dateFormat(options.formatDate);
dateTest.setDate(dateTest.getDate() + 1);
if (highlightedDates[keyDate] !== undefined) {
exDesc = highlightedDates[keyDate].desc;
if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
}
} else {
highlightedDates[keyDate] = hDate;
}
}
});
options.highlightedDates = $.extend(true, [], highlightedDates);
}
if (_options.disabledDates && $.isArray(_options.disabledDates) && _options.disabledDates.length) {
options.disabledDates = $.extend(true, [], _options.disabledDates);
}
if ((options.open || options.opened) && (!options.inline)) {
input.trigger('open.xdsoft');
}
if (options.inline) {
triggerAfterOpen = true;
datetimepicker.addClass('xdsoft_inline');
input.after(datetimepicker).hide();
}
if (options.inverseButton) {
options.next = 'xdsoft_prev';
options.prev = 'xdsoft_next';
}
if (options.datepicker) {
datepicker.addClass('active');
} else {
datepicker.removeClass('active');
}
if (options.timepicker) {
timepicker.addClass('active');
} else {
timepicker.removeClass('active');
}
if (options.value) {
_xdsoft_datetime.setCurrentTime(options.value);
if (input && input.val) {
input.val(_xdsoft_datetime.str);
}
}
if (isNaN(options.dayOfWeekStart)) {
options.dayOfWeekStart = 0;
} else {
options.dayOfWeekStart = parseInt(options.dayOfWeekStart, 10) % 7;
}
if (!options.timepickerScrollbar) {
timeboxparent.xdsoftScroller('hide');
}
if (options.minDate && /^-(.*)$/.test(options.minDate)) {
options.minDate = _xdsoft_datetime.strToDateTime(options.minDate).dateFormat(options.formatDate);
}
if (options.maxDate && /^\+(.*)$/.test(options.maxDate)) {
options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat(options.formatDate);
}
applyButton.toggle(options.showApplyButton);
mounth_picker
.find('.xdsoft_today_button')
.css('visibility', !options.todayButton ? 'hidden' : 'visible');
mounth_picker
.find('.' + options.prev)
.css('visibility', !options.prevButton ? 'hidden' : 'visible');
mounth_picker
.find('.' + options.next)
.css('visibility', !options.nextButton ? 'hidden' : 'visible');
if (options.mask) {
input.off('keydown.xdsoft');
if (options.mask === true) {
options.mask = options.format
.replace(/Y/g, '9999')
.replace(/F/g, '9999')
.replace(/m/g, '19')
.replace(/d/g, '39')
.replace(/H/g, '29')
.replace(/i/g, '59')
.replace(/s/g, '59');
}
if ($.type(options.mask) === 'string') {
if (!isValidValue(options.mask, input.val())) {
input.val(options.mask.replace(/[0-9]/g, '_'));
}
input.on('keydown.xdsoft', function (event) {
var val = this.value,
key = event.which,
pos,
digit;
if (((key >= KEY0 && key <= KEY9) || (key >= _KEY0 && key <= _KEY9)) || (key === BACKSPACE || key === DEL)) {
pos = getCaretPos(this);
digit = (key !== BACKSPACE && key !== DEL) ? String.fromCharCode((_KEY0 <= key && key <= _KEY9) ? key - KEY0 : key) : '_';
if ((key === BACKSPACE || key === DEL) && pos) {
pos -= 1;
digit = '_';
}
while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
}
val = val.substr(0, pos) + digit + val.substr(pos + 1);
if ($.trim(val) === '') {
val = options.mask.replace(/[0-9]/g, '_');
} else {
if (pos === options.mask.length) {
event.preventDefault();
return false;
}
}
pos += (key === BACKSPACE || key === DEL) ? 0 : 1;
while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
}
if (isValidValue(options.mask, val)) {
this.value = val;
setCaretPos(this, pos);
} else if ($.trim(val) === '') {
this.value = options.mask.replace(/[0-9]/g, '_');
} else {
input.trigger('error_input.xdsoft');
}
} else {
if (([AKEY, CKEY, VKEY, ZKEY, YKEY].indexOf(key) !== -1 && ctrlDown) || [ESC, ARROWUP, ARROWDOWN, ARROWLEFT, ARROWRIGHT, F5, CTRLKEY, TAB, ENTER].indexOf(key) !== -1) {
return true;
}
}
event.preventDefault();
return false;
});
}
}
if (options.validateOnBlur) {
input
.off('blur.xdsoft')
.on('blur.xdsoft', function () {
if (options.allowBlank && !$.trim($(this).val()).length) {
$(this).val(null);
datetimepicker.data('xdsoft_datetime').empty();
} else if (!Date.parseDate($(this).val(), options.format)) {
var splittedHours = +([$(this).val()[0], $(this).val()[1]].join('')),
splittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));
// parse the numbers as 0312 => 03:12
if (!options.datepicker && options.timepicker && splittedHours >= 0 && splittedHours < 24 && splittedMinutes >= 0 && splittedMinutes < 60) {
$(this).val([splittedHours, splittedMinutes].map(function (item) {
return item > 9 ? item : '0' + item;
}).join(':'));
} else {
$(this).val((_xdsoft_datetime.now()).dateFormat(options.format));
}
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
} else {
datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
}
datetimepicker.trigger('changedatetime.xdsoft');
});
}
options.dayOfWeekStartPrev = (options.dayOfWeekStart === 0) ? 6 : options.dayOfWeekStart - 1;
datetimepicker
.trigger('xchange.xdsoft')
.trigger('afterOpen.xdsoft');
};
datetimepicker
.data('options', options)
.on('mousedown.xdsoft', function (event) {
event.stopPropagation();
event.preventDefault();
yearselect.hide();
monthselect.hide();
return false;
});
//scroll_element = timepicker.find('.xdsoft_time_box');
timeboxparent.append(timebox);
timeboxparent.xdsoftScroller();
datetimepicker.on('afterOpen.xdsoft', function () {
timeboxparent.xdsoftScroller();
});
datetimepicker
.append(datepicker)
.append(timepicker);
if (options.withoutCopyright !== true) {
datetimepicker
.append(xdsoft_copyright);
}
datepicker
.append(mounth_picker)
.append(calendar)
.append(applyButton);
$(options.parentID)
.append(datetimepicker);
XDSoft_datetime = function () {
var _this = this;
_this.now = function (norecursion) {
var d = new Date(),
date,
time;
if (!norecursion && options.defaultDate) {
date = _this.strToDateTime(options.defaultDate);
d.setFullYear(date.getFullYear());
d.setMonth(date.getMonth());
d.setDate(date.getDate());
}
if (options.yearOffset) {
d.setFullYear(d.getFullYear() + options.yearOffset);
}
if (!norecursion && options.defaultTime) {
time = _this.strtotime(options.defaultTime);
d.setHours(time.getHours());
d.setMinutes(time.getMinutes());
}
return d;
};
_this.isValidDate = function (d) {
if (Object.prototype.toString.call(d) !== "[object Date]") {
return false;
}
return !isNaN(d.getTime());
};
_this.setCurrentTime = function (dTime) {
_this.currentTime = (typeof dTime === 'string') ? _this.strToDateTime(dTime) : _this.isValidDate(dTime) ? dTime : _this.now();
datetimepicker.trigger('xchange.xdsoft');
};
_this.empty = function () {
_this.currentTime = null;
};
_this.getCurrentTime = function (dTime) {
return _this.currentTime;
};
_this.nextMonth = function () {
if (_this.currentTime === undefined || _this.currentTime === null) {
_this.currentTime = _this.now();
}
var month = _this.currentTime.getMonth() + 1,
year;
if (month === 12) {
_this.currentTime.setFullYear(_this.currentTime.getFullYear() + 1);
month = 0;
}
year = _this.currentTime.getFullYear();
_this.currentTime.setDate(
Math.min(
new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
_this.currentTime.getDate()
)
);
_this.currentTime.setMonth(month);
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
if (year !== _this.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
datetimepicker.trigger('xchange.xdsoft');
return month;
};
_this.prevMonth = function () {
if (_this.currentTime === undefined || _this.currentTime === null) {
_this.currentTime = _this.now();
}
var month = _this.currentTime.getMonth() - 1;
if (month === -1) {
_this.currentTime.setFullYear(_this.currentTime.getFullYear() - 1);
month = 11;
}
_this.currentTime.setDate(
Math.min(
new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
_this.currentTime.getDate()
)
);
_this.currentTime.setMonth(month);
if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
datetimepicker.trigger('xchange.xdsoft');
return month;
};
_this.getWeekOfYear = function (datetime) {
var onejan = new Date(datetime.getFullYear(), 0, 1);
return Math.ceil((((datetime - onejan) / 86400000) + onejan.getDay() + 1) / 7);
};
_this.strToDateTime = function (sDateTime) {
var tmpDate = [], timeOffset, currentTime;
if (sDateTime && sDateTime instanceof Date && _this.isValidDate(sDateTime)) {
return sDateTime;
}
tmpDate = /^(\+|\-)(.*)$/.exec(sDateTime);
if (tmpDate) {
tmpDate[2] = Date.parseDate(tmpDate[2], options.formatDate);
}
if (tmpDate && tmpDate[2]) {
timeOffset = tmpDate[2].getTime() - (tmpDate[2].getTimezoneOffset()) * 60000;
currentTime = new Date((_this.now(true)).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
} else {
currentTime = sDateTime ? Date.parseDate(sDateTime, options.format) : _this.now();
}
if (!_this.isValidDate(currentTime)) {
currentTime = _this.now();
}
return currentTime;
};
_this.strToDate = function (sDate) {
if (sDate && sDate instanceof Date && _this.isValidDate(sDate)) {
return sDate;
}
var currentTime = sDate ? Date.parseDate(sDate, options.formatDate) : _this.now(true);
if (!_this.isValidDate(currentTime)) {
currentTime = _this.now(true);
}
return currentTime;
};
_this.strtotime = function (sTime) {
if (sTime && sTime instanceof Date && _this.isValidDate(sTime)) {
return sTime;
}
var currentTime = sTime ? Date.parseDate(sTime, options.formatTime) : _this.now(true);
if (!_this.isValidDate(currentTime)) {
currentTime = _this.now(true);
}
return currentTime;
};
_this.str = function () {
return _this.currentTime.dateFormat(options.format);
};
_this.currentTime = this.now();
};
_xdsoft_datetime = new XDSoft_datetime();
applyButton.on('click', function (e) {//pathbrite
e.preventDefault();
datetimepicker.data('changed', true);
_xdsoft_datetime.setCurrentTime(getCurrentValue());
input.val(_xdsoft_datetime.str());
datetimepicker.trigger('close.xdsoft');
});
mounth_picker
.find('.xdsoft_today_button')
.on('mousedown.xdsoft', function () {
datetimepicker.data('changed', true);
_xdsoft_datetime.setCurrentTime(0);
datetimepicker.trigger('afterOpen.xdsoft');
}).on('dblclick.xdsoft', function () {
var currentDate = _xdsoft_datetime.getCurrentTime();
currentDate = new Date(currentDate.getFullYear(),currentDate.getMonth(),currentDate.getDate());
var minDate = _xdsoft_datetime.strToDate(options.minDate);
minDate = new Date(minDate.getFullYear(),minDate.getMonth(),minDate.getDate());
if(currentDate < minDate) {
return;
}
var maxDate = _xdsoft_datetime.strToDate(options.maxDate);
maxDate = new Date(maxDate.getFullYear(),maxDate.getMonth(),maxDate.getDate());
if(currentDate > maxDate) {
return;
}
input.val(_xdsoft_datetime.str());
datetimepicker.trigger('close.xdsoft');
});
mounth_picker
.find('.xdsoft_prev,.xdsoft_next')
.on('mousedown.xdsoft', function () {
var $this = $(this),
timer = 0,
stop = false;
(function arguments_callee1(v) {
if ($this.hasClass(options.next)) {
_xdsoft_datetime.nextMonth();
} else if ($this.hasClass(options.prev)) {
_xdsoft_datetime.prevMonth();
}
if (options.monthChangeSpinner) {
if (!stop) {
timer = setTimeout(arguments_callee1, v || 100);
}
}
}(500));
$([document.body, window]).on('mouseup.xdsoft', function arguments_callee2() {
clearTimeout(timer);
stop = true;
$([document.body, window]).off('mouseup.xdsoft', arguments_callee2);
});
});
timepicker
.find('.xdsoft_prev,.xdsoft_next')
.on('mousedown.xdsoft', function () {
var $this = $(this),
timer = 0,
stop = false,
period = 110;
(function arguments_callee4(v) {
var pheight = timeboxparent[0].clientHeight,
height = timebox[0].offsetHeight,
top = Math.abs(parseInt(timebox.css('marginTop'), 10));
if ($this.hasClass(options.next) && (height - pheight) - options.timeHeightInTimePicker >= top) {
timebox.css('marginTop', '-' + (top + options.timeHeightInTimePicker) + 'px');
} else if ($this.hasClass(options.prev) && top - options.timeHeightInTimePicker >= 0) {
timebox.css('marginTop', '-' + (top - options.timeHeightInTimePicker) + 'px');
}
timeboxparent.trigger('scroll_element.xdsoft_scroller', [Math.abs(parseInt(timebox.css('marginTop'), 10) / (height - pheight))]);
period = (period > 10) ? 10 : period - 10;
if (!stop) {
timer = setTimeout(arguments_callee4, v || period);
}
}(500));
$([document.body, window]).on('mouseup.xdsoft', function arguments_callee5() {
clearTimeout(timer);
stop = true;
$([document.body, window])
.off('mouseup.xdsoft', arguments_callee5);
});
});
xchangeTimer = 0;
// base handler - generating a calendar and timepicker
datetimepicker
.on('xchange.xdsoft', function (event) {
clearTimeout(xchangeTimer);
xchangeTimer = setTimeout(function () {
if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
}
var table = '',
start = new Date(_xdsoft_datetime.currentTime.getFullYear(), _xdsoft_datetime.currentTime.getMonth(), 1, 12, 0, 0),
i = 0,
j,
today = _xdsoft_datetime.now(),
maxDate = false,
minDate = false,
hDate,
d,
y,
m,
w,
classes = [],
customDateSettings,
newRow = true,
time = '',
h = '',
line_time,
description;
while (start.getDay() !== options.dayOfWeekStart) {
start.setDate(start.getDate() - 1);
}
table += '';
if (options.weeks) {
table += ' ';
}
for (j = 0; j < 7; j += 1) {
table += '' + options.i18n[options.lang].dayOfWeek[(j + options.dayOfWeekStart) % 7] + ' ';
}
table += ' ';
table += '';
if (options.maxDate !== false) {
maxDate = _xdsoft_datetime.strToDate(options.maxDate);
maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999);
}
if (options.minDate !== false) {
minDate = _xdsoft_datetime.strToDate(options.minDate);
minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
}
while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
classes = [];
i += 1;
d = start.getDate();
y = start.getFullYear();
m = start.getMonth();
w = _xdsoft_datetime.getWeekOfYear(start);
description = '';
classes.push('xdsoft_date');
if (options.beforeShowDay && $.isFunction(options.beforeShowDay.call)) {
customDateSettings = options.beforeShowDay.call(datetimepicker, start);
} else {
customDateSettings = null;
}
if ((maxDate !== false && start > maxDate) || (minDate !== false && start < minDate) || (customDateSettings && customDateSettings[0] === false)) {
classes.push('xdsoft_disabled');
} else if (options.disabledDates.indexOf(start.dateFormat(options.formatDate)) !== -1) {
classes.push('xdsoft_disabled');
}
if (customDateSettings && customDateSettings[1] !== "") {
classes.push(customDateSettings[1]);
}
if (_xdsoft_datetime.currentTime.getMonth() !== m) {
classes.push('xdsoft_other_month');
}
if ((options.defaultSelect || datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
classes.push('xdsoft_current');
}
if (today.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
classes.push('xdsoft_today');
}
if (start.getDay() === 0 || start.getDay() === 6 || options.weekends.indexOf(start.dateFormat(options.formatDate)) !== -1) {
classes.push('xdsoft_weekend');
}
if (options.highlightedDates[start.dateFormat(options.formatDate)] !== undefined) {
hDate = options.highlightedDates[start.dateFormat(options.formatDate)];
classes.push(hDate.style === undefined ? 'xdsoft_highlighted_default' : hDate.style);
description = hDate.desc === undefined ? '' : hDate.desc;
}
if (options.beforeShowDay && $.isFunction(options.beforeShowDay)) {
classes.push(options.beforeShowDay(start));
}
if (newRow) {
table += '';
newRow = false;
if (options.weeks) {
table += '' + w + ' ';
}
}
table += '' +
'' + d + '
' +
' ';
if (start.getDay() === options.dayOfWeekStartPrev) {
table += ' ';
newRow = true;
}
start.setDate(d + 1);
}
table += '
';
calendar.html(table);
mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[options.lang].months[_xdsoft_datetime.currentTime.getMonth()]);
mounth_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
// generate timebox
time = '';
h = '';
m = '';
line_time = function line_time(h, m) {
var now = _xdsoft_datetime.now(), optionDateTime, current_time;
now.setHours(h);
h = parseInt(now.getHours(), 10);
now.setMinutes(m);
m = parseInt(now.getMinutes(), 10);
optionDateTime = new Date(_xdsoft_datetime.currentTime);
optionDateTime.setHours(h);
optionDateTime.setMinutes(m);
classes = [];
if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && _xdsoft_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && _xdsoft_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
classes.push('xdsoft_disabled');
}
current_time = new Date(_xdsoft_datetime.currentTime);
current_time.setHours(parseInt(_xdsoft_datetime.currentTime.getHours(), 10));
current_time.setMinutes(Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step);
if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && current_time.getHours() === parseInt(h, 10) && (options.step > 59 || current_time.getMinutes() === parseInt(m, 10))) {
if (options.defaultSelect || datetimepicker.data('changed')) {
classes.push('xdsoft_current');
} else if (options.initTime) {
classes.push('xdsoft_init_time');
}
}
if (parseInt(today.getHours(), 10) === parseInt(h, 10) && parseInt(today.getMinutes(), 10) === parseInt(m, 10)) {
classes.push('xdsoft_today');
}
time += '' + now.dateFormat(options.formatTime) + '
';
};
if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
for (j = 0; j < 60; j += options.step) {
h = (i < 10 ? '0' : '') + i;
m = (j < 10 ? '0' : '') + j;
line_time(h, m);
}
}
} else {
for (i = 0; i < options.allowTimes.length; i += 1) {
h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
line_time(h, m);
}
}
timebox.html(time);
opt = '';
i = 0;
for (i = parseInt(options.yearStart, 10) + options.yearOffset; i <= parseInt(options.yearEnd, 10) + options.yearOffset; i += 1) {
opt += '' + i + '
';
}
yearselect.children().eq(0)
.html(opt);
for (i = parseInt(options.monthStart, 10), opt = ''; i <= parseInt(options.monthEnd, 10); i += 1) {
opt += '' + options.i18n[options.lang].months[i] + '
';
}
monthselect.children().eq(0).html(opt);
$(datetimepicker)
.trigger('generate.xdsoft');
}, 10);
event.stopPropagation();
})
.on('afterOpen.xdsoft', function () {
if (options.timepicker) {
var classType, pheight, height, top;
if (timebox.find('.xdsoft_current').length) {
classType = '.xdsoft_current';
} else if (timebox.find('.xdsoft_init_time').length) {
classType = '.xdsoft_init_time';
}
if (classType) {
pheight = timeboxparent[0].clientHeight;
height = timebox[0].offsetHeight;
top = timebox.find(classType).index() * options.timeHeightInTimePicker + 1;
if ((height - pheight) < top) {
top = height - pheight;
}
timeboxparent.trigger('scroll_element.xdsoft_scroller', [parseInt(top, 10) / (height - pheight)]);
} else {
timeboxparent.trigger('scroll_element.xdsoft_scroller', [0]);
}
}
});
timerclick = 0;
calendar
.on('click.xdsoft', 'td', function (xdevent) {
xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
timerclick += 1;
var $this = $(this),
currentTime = _xdsoft_datetime.currentTime;
if (currentTime === undefined || currentTime === null) {
_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
currentTime = _xdsoft_datetime.currentTime;
}
if ($this.hasClass('xdsoft_disabled')) {
return false;
}
currentTime.setDate(1);
currentTime.setFullYear($this.data('year'));
currentTime.setMonth($this.data('month'));
currentTime.setDate($this.data('date'));
datetimepicker.trigger('select.xdsoft', [currentTime]);
input.val(_xdsoft_datetime.str());
if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === 0 && !options.timepicker))) && !options.inline) {
datetimepicker.trigger('close.xdsoft');
}
if (options.onSelectDate && $.isFunction(options.onSelectDate)) {
options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
}
datetimepicker.data('changed', true);
datetimepicker.trigger('xchange.xdsoft');
datetimepicker.trigger('changedatetime.xdsoft');
setTimeout(function () {
timerclick = 0;
}, 200);
});
timebox
.on('click.xdsoft', 'div', function (xdevent) {
xdevent.stopPropagation();
var $this = $(this),
currentTime = _xdsoft_datetime.currentTime;
if (currentTime === undefined || currentTime === null) {
_xdsoft_datetime.currentTime = _xdsoft_datetime.now();
currentTime = _xdsoft_datetime.currentTime;
}
if ($this.hasClass('xdsoft_disabled')) {
return false;
}
currentTime.setHours($this.data('hour'));
currentTime.setMinutes($this.data('minute'));
datetimepicker.trigger('select.xdsoft', [currentTime]);
datetimepicker.data('input').val(_xdsoft_datetime.str());
if (options.inline !== true && options.closeOnTimeSelect === true) {
datetimepicker.trigger('close.xdsoft');
}
if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
}
datetimepicker.data('changed', true);
datetimepicker.trigger('xchange.xdsoft');
datetimepicker.trigger('changedatetime.xdsoft');
});
datepicker
.on('mousewheel.xdsoft', function (event) {
if (!options.scrollMonth) {
return true;
}
if (event.deltaY < 0) {
_xdsoft_datetime.nextMonth();
} else {
_xdsoft_datetime.prevMonth();
}
return false;
});
input
.on('mousewheel.xdsoft', function (event) {
if (!options.scrollInput) {
return true;
}
if (!options.datepicker && options.timepicker) {
current_time_index = timebox.find('.xdsoft_current').length ? timebox.find('.xdsoft_current').eq(0).index() : 0;
if (current_time_index + event.deltaY >= 0 && current_time_index + event.deltaY < timebox.children().length) {
current_time_index += event.deltaY;
}
if (timebox.children().eq(current_time_index).length) {
timebox.children().eq(current_time_index).trigger('mousedown');
}
return false;
}
if (options.datepicker && !options.timepicker) {
datepicker.trigger(event, [event.deltaY, event.deltaX, event.deltaY]);
if (input.val) {
input.val(_xdsoft_datetime.str());
}
datetimepicker.trigger('changedatetime.xdsoft');
return false;
}
});
datetimepicker
.on('changedatetime.xdsoft', function (event) {
if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) {
var $input = datetimepicker.data('input');
options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
delete options.value;
$input.trigger('change');
}
})
.on('generate.xdsoft', function () {
if (options.onGenerate && $.isFunction(options.onGenerate)) {
options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
}
if (triggerAfterOpen) {
datetimepicker.trigger('afterOpen.xdsoft');
triggerAfterOpen = false;
}
})
.on('click.xdsoft', function (xdevent) {
xdevent.stopPropagation();
});
current_time_index = 0;
setPos = function () {
var offset = datetimepicker.data('input').offset(), top = offset.top + datetimepicker.data('input')[0].offsetHeight - 1, left = offset.left, position = "absolute";
if (options.fixed) {
top -= $(window).scrollTop();
left -= $(window).scrollLeft();
position = "fixed";
} else {
if (top + datetimepicker[0].offsetHeight > $(window).height() + $(window).scrollTop()) {
top = offset.top - datetimepicker[0].offsetHeight + 1;
}
if (top < 0) {
top = 0;
}
if (left + datetimepicker[0].offsetWidth > $(window).width()) {
left = $(window).width() - datetimepicker[0].offsetWidth;
}
}
var node = datetimepicker[0]
do {
node = node.parentNode;
if(window.getComputedStyle(node).getPropertyValue('position') === 'relative' && $(window).width() >= node.offsetWidth) {
left = left - (($(window).width() - node.offsetWidth)/2)
break
}
} while(node.nodeName != 'HTML')
datetimepicker.css({
left: left,
top: top,
position: position
});
};
datetimepicker
.on('open.xdsoft', function (event) {
var onShow = true;
if (options.onShow && $.isFunction(options.onShow)) {
onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
}
if (onShow !== false) {
datetimepicker.show();
setPos();
$(window)
.off('resize.xdsoft', setPos)
.on('resize.xdsoft', setPos);
if (options.closeOnWithoutClick) {
$([document.body, window]).on('mousedown.xdsoft', function arguments_callee6() {
datetimepicker.trigger('close.xdsoft');
$([document.body, window]).off('mousedown.xdsoft', arguments_callee6);
});
}
}
})
.on('close.xdsoft', function (event) {
var onClose = true;
mounth_picker
.find('.xdsoft_month,.xdsoft_year')
.find('.xdsoft_select')
.hide();
if (options.onClose && $.isFunction(options.onClose)) {
onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
}
if (onClose !== false && !options.opened && !options.inline) {
datetimepicker.hide();
}
event.stopPropagation();
})
.on('toggle.xdsoft', function (event) {
if (datetimepicker.is(':visible')) {
datetimepicker.trigger('close.xdsoft');
} else {
datetimepicker.trigger('open.xdsoft');
}
})
.data('input', input);
timer = 0;
timer1 = 0;
datetimepicker.data('xdsoft_datetime', _xdsoft_datetime);
datetimepicker.setOptions(options);
function getCurrentValue() {
var ct = false, time;
if (options.startDate) {
ct = _xdsoft_datetime.strToDate(options.startDate);
} else {
ct = options.value || ((input && input.val && input.val()) ? input.val() : '');
if (ct) {
ct = _xdsoft_datetime.strToDateTime(ct);
} else if (options.defaultDate) {
ct = _xdsoft_datetime.strToDateTime(options.defaultDate);
if (options.defaultTime) {
time = _xdsoft_datetime.strtotime(options.defaultTime);
ct.setHours(time.getHours());
ct.setMinutes(time.getMinutes());
}
}
}
if (ct && _xdsoft_datetime.isValidDate(ct)) {
datetimepicker.data('changed', true);
} else {
ct = '';
}
return ct || 0;
}
_xdsoft_datetime.setCurrentTime(getCurrentValue());
input
.data('xdsoft_datetimepicker', datetimepicker)
.on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function (event) {
if (input.is(':disabled') || (input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick)) {
return;
}
clearTimeout(timer);
timer = setTimeout(function () {
if (input.is(':disabled')) {
return;
}
triggerAfterOpen = true;
_xdsoft_datetime.setCurrentTime(getCurrentValue());
datetimepicker.trigger('open.xdsoft');
}, 100);
})
.on('keydown.xdsoft', function (event) {
var val = this.value, elementSelector,
key = event.which;
if ([ENTER].indexOf(key) !== -1 && options.enterLikeTab) {
elementSelector = $("input:visible,textarea:visible");
datetimepicker.trigger('close.xdsoft');
elementSelector.eq(elementSelector.index(this) + 1).focus();
return false;
}
if ([TAB].indexOf(key) !== -1) {
datetimepicker.trigger('close.xdsoft');
return true;
}
});
};
destroyDateTimePicker = function (input) {
var datetimepicker = input.data('xdsoft_datetimepicker');
if (datetimepicker) {
datetimepicker.data('xdsoft_datetime', null);
datetimepicker.remove();
input
.data('xdsoft_datetimepicker', null)
.off('.xdsoft');
$(window).off('resize.xdsoft');
$([window, document.body]).off('mousedown.xdsoft');
if (input.unmousewheel) {
input.unmousewheel();
}
}
};
$(document)
.off('keydown.xdsoftctrl keyup.xdsoftctrl')
.on('keydown.xdsoftctrl', function (e) {
if (e.keyCode === CTRLKEY) {
ctrlDown = true;
}
})
.on('keyup.xdsoftctrl', function (e) {
if (e.keyCode === CTRLKEY) {
ctrlDown = false;
}
});
return this.each(function () {
var datetimepicker = $(this).data('xdsoft_datetimepicker'), $input;
if (datetimepicker) {
if ($.type(opt) === 'string') {
switch (opt) {
case 'show':
$(this).select().focus();
datetimepicker.trigger('open.xdsoft');
break;
case 'hide':
datetimepicker.trigger('close.xdsoft');
break;
case 'toggle':
datetimepicker.trigger('toggle.xdsoft');
break;
case 'destroy':
destroyDateTimePicker($(this));
break;
case 'reset':
this.value = this.defaultValue;
if (!this.value || !datetimepicker.data('xdsoft_datetime').isValidDate(Date.parseDate(this.value, options.format))) {
datetimepicker.data('changed', false);
}
datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value);
break;
case 'validate':
$input = datetimepicker.data('input');
$input.trigger('blur.xdsoft');
break;
}
} else {
datetimepicker
.setOptions(opt);
}
return 0;
}
if ($.type(opt) !== 'string') {
if (!options.lazyInit || options.open || options.inline) {
createDateTimePicker($(this));
} else {
lazyInit($(this));
}
}
});
};
$.fn.datetimepicker.defaults = default_options;
}(jQuery));
function HighlightedDate(date, desc, style) {
"use strict";
this.date = date;
this.desc = desc;
this.style = style;
}
(function () {
/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
* Licensed under the MIT License (LICENSE.txt).
*
* Version: 3.1.12
*
* Requires: jQuery 1.2.2+
*/
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});
// Parse and Format Library
//http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/
/*
* Copyright (C) 2004 Baron Schwartz
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, version 2.1.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(b){if(b=="unixtime"){return parseInt(this.getTime()/1000);}if(Date.formatFunctions[b]==null){Date.createNewFormat(b);}var a=Date.formatFunctions[b];return this[a]();};Date.createNewFormat=function(format){var funcName="format"+Date.formatFunctions.count++;Date.formatFunctions[format]=funcName;var codePrefix="Date.prototype."+funcName+" = function() {return ";var code="";var special=false;var ch="";for(var i=0;i 0) {";var regex="";var special=false;var ch="";for(var i=0;i 0 && z > 0){\nvar doyDate = new Date(y,0);\ndoyDate.setDate(z);\nm = doyDate.getMonth();\nd = doyDate.getDate();\n}";code+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new Date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new Date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new Date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new Date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new Date(y, m);}\nelse if (y > 0)\n{return new Date(y);}\n}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$",'i');eval(code);};Date.formatCodeToRegex=function(b,a){switch(b){case"D":return{g:0,c:null,s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:1,c:"z = parseInt(results["+a+"], 10);\n",s:"(\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m = parseInt(results["+a+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y = parseInt(results["+a+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+a+"], 10);\ny = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+a+"] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+a+"] == 'AM') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"O":return{g:0,c:null,s:"[+-]\\d{4}"};case"T":return{g:0,c:null,s:"[A-Z]{3}"};case"Z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:String.escape(b)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")+String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset())/60),2,"0")+String.leftPad(Math.abs(this.getTimezoneOffset())%60,2,"0");};Date.prototype.getDayOfYear=function(){var a=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var b=0;b '));
}
$(".editorConfAlign > div > button.alignLeft").click(function() {
ins.alignEditor("Left");
});
$(".editorConfAlign > div > button.alignRight").click(function() {
ins.alignEditor("Right");
});
$(".editorConfAlign > div > button.alignCenter").click(function() {
ins.alignEditor("Center");
});
$(".editorConfAlign > div > button.alignTextCenter").click(function() {
ins.alignEditor("TextCenter");
});
$(".editorConfAlign > div > button.alignNormal").click(function() {
ins.alignEditor("Normal");
});
$(".editorConfMove > div > button.moveBelow").click(function() {
ins.moveEditor("below");
});
$(".editorConfMove > div > button.moveAbove").click(function() {
ins.moveEditor("above");
});
$(".editorConfMove > div > button.moveAway").click(function() {
ins.moveEditor("away");
});
CKEDITOR.on('instanceReady', function(ev) {
ev.editor.on('paste', function(evt) {
evt.data.dataValue = evt.data.dataValue.replace(/ /g,'');
}, null, null, 9);
ev.editor.document.on('keydown', function(event) {
var key = event.data.getKey();
if (key == 27) {
ins.setEditor(false);
} else if (key == 9) {
ins.setEditor(true);
}
});
setTimeout(function() {
ev.editor.focus();
}, 10);
ev.editor.on("change", function(evt) {
//ckChanges();
});
});
}
SaberEditor.prototype = {
currentEditorParent : null,
currentEditorValue : '',
selectedEditor : null,
pictureUploadTarget : null,
allContentCSS : "contentStyleRight contentStyleCenter contentStyleNormal contentStyleLeft contentStyleTextCenter",
___noContentForm:'İçeriği düzenlemek için çift tıklayınız. ',
___noContentCode:'Kodu düzenlemek için çift tıklayınız. ',
___questionBlock: '',
___editorAlign:'',
___editorMove:'',
incCounter : 0,
turn:0,
uploading : Array(),
setUploading : function(num) {
if (num > 0)
this.uploading.push(1);
else {
this.uploading.splice(0,1);
}
if (this.uploading.length > 0 ) {
//window.onbeforeunload = confirmOnPageExit;
} else {
//window.onbeforeunload = null;
}
},
init : function(ctx, o, data) {
ctx.html('');
var ins = this;
o.forEach(function(entry) {
var c = null;
if (data != null) {
data.forEach(function(entry2) {
if ((entry2.field_name == entry.field_name) && (entry2.field_type == entry.field_type)) {
c = entry2.data;
}
});
}
ins.addNewContent(ctx, entry, c);
});
this.setSelectedEditor(null);
/*
this.addNewContent(ctx);
this.setSelectedEditor(null);
*/
if (ctx.attr("data-scrolled") == null) {
ctx.parents(".panel-body").on("scroll", function() {
ins.adjustEditors();
});
ctx.attr("data-scrolled", "1");
}
},
handleFileSelect : function(evt) {
var files = evt.target.files;
var elName = evt.target.id;
var isMultiple = evt.target.getAttribute("data-multiple");
for (var i = 0, f; f = files[i]; i++) {
var reader = new FileReader();
reader.onload = (function (theFile) {
return function (e) {
if (!theFile.type.match('image.*')) {
alert("Sadece Resim Yükleyebilirsiniz.");
return;
}
var dim = null;
saberEditor.turn++;
var x = saberEditor.turn;
try {
var image = new Image();
image.src = e.target.result;
image.onload = function() {
// access image size here
dim = Array(this.width, this.height);
var w = 0, h = 0;
if (dim[0] > 500) {
w = 500;
h = parseFloat((w * dim[1]) / dim[0]).toFixed(0);
} else if (dim[1] > 500) {
h = 500;
w = parseFloat((h * dim[0]) / dim[1]).toFixed(0);
} else {
w = dim[0], h = dim[1];
}
var div = $('
').append(' ');
saberEditor.pictureUploadTarget.append(div);
div.click(function() {
saberEditor.selectEditor($(this));
});
setTimeout(function () {
saberEditor.setUploading(x);
saberEditor.uploadFile(theFile, x);
}, 1000);
};
} catch (e) {
alert("Resim boyutları alınamadı.");
return;
}
};
})(f);
reader.readAsDataURL(f);
}
$(".editorFormObject").formReset();
},
uploadFile:function(f, x) {
var name = f.name;
if (name.length > 15) name = name.substr(0, 15) + '...';
var XHR = new XMLHttpRequest();
XHR.open('PUT', 'web.content/uploadPicture', true);
for (var key in f) {
var val = f[key];
if (typeof (val) == 'string' || typeof (val) == 'number')
XHR.setRequestHeader('file_' + key, val);
}
XHR.upload.addEventListener("progress", function (e) {
var percentComplete = parseInt(e.loaded / e.total * 100);
/*
if (!e.lengthComputable) return;
var percentComplete = parseInt(e.loaded / e.total * 100);
$("#prg_"+x+'_'+elName).find(".progress-bar").css("width", percentComplete+"%");
$("#prg_"+x+'_'+elName).find(".progress-bar").html(percentComplete+"%");*/
}, false);
XHR.onreadystatechange = function () {
if (this.readyState == this.DONE) {
$('#sabereditor-upload-'+x).attr("src", this.responseText);
$('#sabereditor-upload-'+x).attr("id", "");
saberEditor.setUploading(-1);
}
};
XHR.send(f);
},
alignEditor : function(direction) {
if (this.selectedEditor != null) {
this.selectedEditor.removeClass(this.allContentCSS).addClass("contentStyle"+direction);
this.adjustEditors();
}
},
moveEditor : function(direction) {
if (this.selectedEditor != null) {
if (direction == "below") {
if (this.selectedEditor.next().length > 0) {
var n = this.selectedEditor.next();
this.selectedEditor.insertAfter(n);
//hasChanges();
}
} else if (direction == "above") {
if (this.selectedEditor.prev().length > 0) {
var n = this.selectedEditor.prev();
this.selectedEditor.insertBefore(n);
//hasChanges();
}
} else if (direction == "away") {
var p = this.selectedEditor.parents(".panel-body");
var total = p.find(".editorArea").find("div").length;
this.selectedEditor.remove();
//hasChanges();
if (total == 1) {
p.find(".actionForm").click();
}
this.selectedEditor = null;
}
this.adjustEditors();
}
},
addNewContent : function(ctx, o, c) {
var _w = null;
/*
if (arguments.length > 0) {
_w = arguments[0].find(".panel-body").first();
} else {
this.incCounter++;
_w = $(this.___questionBlock.replace("{0}", "new-"+this.incCounter));
}*/
_w = $(this.___questionBlock.replace("{0}", "new-"+this.incCounter));
if (c != null) {
_w.find(".editorArea").html('');
if (c.length == 0) {
_w.find(".editorArea").append('
');
} else {
c.forEach(function(entry) {
_w.find(".editorArea").append(''+entry.detail+'
');
});
}
}
var ins = this;
_w.find(".contentForm").click(function() {
ins.selectEditor($(this));
});
_w.find(".contentPicture").click(function() {
ins.selectEditor($(this));
});
_w.find(".contentCode").click(function() {
ins.selectEditor($(this));
});
_w.find(".contentPictureURL").click(function() {
ins.selectEditor($(this));
});
_w.find(".actionCode").click(function() {
var div = $('
').append(ins.___noContentCode);
$(this).parent().parent().parent().parent().next().append(div);
//hasChanges();
div.click(function() {
ins.selectEditor($(this));
});
div.click();
});
_w.find(".actionForm").click(function() {
var div = $('
').append(ins.___noContentForm);
$(this).parent().parent().parent().parent().next().append(div);
//hasChanges();
div.click(function() {
ins.selectEditor($(this));
});
div.click();
});
_w.find(".actionPicture").click(function() {
ins.pictureUploadTarget = $(this).parent().parent().parent().parent().next();
$("#pictureQuestion").click();
/*var div = $('
').append(' ');
$(this).parent().parent().parent().parent().next().append(div);
div.click(function() {
selectEditor($(this));
});
div.click();*/
});
if (o.field_type != "rt") {
_w.find(".input-group-btn").css("display", "none");
_w.find(".input-group-nothing").css("display", "");
}
_w.attr("data-type", o.field_type);
_w.attr("data-field", o.field_name);
ctx.append(_w);
_w.find(".noContent").html(o.display_name);
_w.find(".input-group-label").html(o.display_name);
/*
if (arguments.length == 0) {
this.playGround.append(_w);
}*/
},
selectEditor : function(x) {
if (x.hasClass("selected")) {
this.getEditor(x);
this.setSelectedEditor(null);
} else {
this.setSelectedEditor(x);
}
},
getEditor:function(x) {
x.unbind("click");
var ins = this;
if (x.hasClass("contentForm")) {
this.currentEditorValue = (x.find(".noContent").length > 0) ? '' : x.html();
this.currentEditorParent = x;
this.currentEditorParent.addClass("currentEditorParent");
this.currentEditorParent.html('');
setTimeout(ins.getEditorDelegate, 10);
} else if (x.hasClass("contentPicture")) {
x.click(function() {
ins.selectEditor($(this));
});
} else if (x.hasClass("contentPictureURL")) {
this.currentCodeEditorValue = (x.find(".noContent").length > 0) ? '' : x.html();
this.currentCodeEditorParent = x;
this.currentCodeEditorParent.addClass("currentCodeEditorParent");
this.currentCodeEditorParent.html('');
$("#currentPictureURLEditor").focus();
$("#currentPictureURLEditor").blur(function() {
ins.currentCodeEditorParent.removeClass("currentCodeEditorParent");
ins.currentCodeEditorParent.removeClass("selected");
//currentCodeEditorParent.html($(this).val() == "" ? ___noContentCode : $(this).val());
var val = $(this).val();
turn++;
var x = turn;
ins.currentCodeEditorParent.html(' ');
ins.currentCodeEditorParent.removeClass("contentPictureURL");
ins.currentCodeEditorParent.addClass("contentPicture");
ins.currentCodeEditorParent.click(function() {
ins.selectEditor($(this));
});
ins.currentCodeEditorParent = null;
//upload_remote_file(val, x);
});
} else if (x.hasClass("contentCode")) {
this.currentCodeEditorValue = (x.find(".noContent").length > 0) ? '' : x.html();
this.currentCodeEditorParent = x;
this.currentCodeEditorParent.addClass("currentCodeEditorParent");
this.currentCodeEditorParent.html('');
$("#currentCodeEditor").focus();
$("#currentCodeEditor").blur(function() {
ins.currentCodeEditorParent.removeClass("currentCodeEditorParent");
ins.currentCodeEditorParent.removeClass("selected");
ins.currentCodeEditorParent.html($(this).val() == "" ? ins.___noContentCode : $(this).val());
ins.currentCodeEditorParent.click(function() {
ins.selectEditor($(this));
});
ins.currentCodeEditorParent = null;
});
/*$("#currentCodeEditor").change(function() {
hasChanges();
});*/
}
},
getEditorDelegate : function() {
CKEDITOR.replace("currentEditor", {
toolbar: [
[ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'],
[ 'TextColor', 'BGColor' ],
['NumberedList', 'BulletedList'],
['Paste', 'Undo', 'Redo' ]
],
height : 150
,
allowedContent : 'b i u'
});
},
setEditor : function(apply) {
var valueToSet = (!apply) ? this.currentEditorValue : CKEDITOR.instances.currentEditor.getData();
/*
if (apply && ckChanging)
{
ckChanging = false;
hasChanges();
}
*/
this.currentEditorParent.removeClass("currentEditorParent");
this.currentEditorParent.removeClass("selected");
this.currentEditorParent.html(valueToSet == "" ? this.___noContentForm : valueToSet);
var ins = this;
this.currentEditorParent.click(function() {
ins.selectEditor($(this));
});
var x = this.currentEditorParent;
this.currentEditorParent = null;
},
setSelectedEditor : function(x) {
if (x != null) {
x.addClass("selected");
if (x.hasClass("contentPicture")) {
$(".contentPictureActions").css("display", "");
var dim = Array(x.find("img").width(), x.find("img").height());
/*
$("#confPictureWidth").val(dim[0]).change(function() {
if ($(this).val() > 500) {
$(this).val(500);
}
$("#confPictureHeight").val(parseFloat(($(this).val() * dim[1]) / dim[0]).toFixed(0));
selectedEditor.find("img").width($("#confPictureWidth").val());
selectedEditor.find("img").height($("#confPictureHeight").val());
});
$("#confPictureHeight").val(dim[1]).change(function() {
if ($(this).val() > 500) {
$(this).val(500);
}
$("#confPictureWidth").val(parseFloat(($(this).val() * dim[0]) / dim[1]).toFixed(0));
selectedEditor.find("img").width($("#confPictureWidth").val());
selectedEditor.find("img").height($("#confPictureHeight").val());
});
*/
} else {
//$(".contentPictureActions").css("display", "none");
}
//$('.contentActions').css("display","");
if (x.parents(".input-group").attr("data-type") != "type-rt") {
$(".editorConfButtons").css("display", "none");
}
} else {
//$('.contentActions').css("display","none");
}
if (this.selectedEditor != null) {
this.selectedEditor.removeClass("selected");
}
this.selectedEditor = x;
this.adjustEditors();
},
adjustEditors : function() {
var a = $(".editorConfAlign");
var b = $(".editorConfMove");
if (this.selectedEditor != null) {
var pos = this.selectedEditor.offset();
a.css("display", "block");
b.css("display", "block");
if (this.selectedEditor.parents(".input-group").attr("data-type") != "rt") {
b.css("display", "none");
}
a.css("top", pos.top - a.height());
a.css("left", pos.left);
if (this.selectedEditor.width() > a.width()) {
a.css("left", pos.left + parseInt(parseFloat((this.selectedEditor.width()-a.width()) / 2).toFixed(0)));
}
b.css("top", pos.top + this.selectedEditor.height() + 8);
b.css("left", pos.left);
if (this.selectedEditor.width() > b.width()) {
b.css("left", pos.left + parseInt(parseFloat((this.selectedEditor.width()-b.width()) / 2).toFixed(0)));
}
} else {
a.css("display", "none");
b.css("display", "none");
}
},
getValue : function(ctx) {
var canSave = true;
var a=Array();
ctx.find(".saber-editor > .input-group").each(function() {
var x = Array();
x.push($(this).attr("data-field"));
x.push($(this).attr("data-type"));
$(this).find(".editorArea > div").each(function () {
if ($(this).find("#cke_currentEditor").length == 1) {
canSave = false;
}
var xx = Array();
xx.push($(this).attr("class"));
xx.push($(this).html());
x.push(xx);
});
a.push(x);
})
if (!canSave) return null;
else return a;
}
};
var saberEditor = new SaberEditor();
/*
document.getElementById('pictureQuestion').addEventListener('change', saberEditor.handleFileSelect, false);
document.getElementById('pictureAnswer').addEventListener('change', saberEditor.handleFileSelect, false);
*/
var SmartDatagrid = function(container,ent,remoteStructure) {
this.container = container;
this.ent = ent;
this.remoteStructure = remoteStructure;
this.filters = new Array();
this.orders = new Array();
this.subModules = new Array();
this.filterPanel = null;
this.init();
};
SmartDatagrid.prototype = {
container : null,
ent : null,
panel:null,
dg : null,
currentGrid : null,
resizer : null,
isRemote : false,
remoteStructure : null,
dataPage : "system.form",
remoteData : null,
editable : true,
deletable : true,
insertable : true,
subModules : null,
___cmenu : null,
cachedUpdates : false,
cachedRows : null,
cssEditing : '.datagrid-row-editing',
init : function() {
this.dispatchStart("initDatagrid");
var _t = this;
if (this.ent == null) {
this.ent = this.remoteStructure;
this.dataPage = this.remoteStructure.___dataPage;
}
this.panel = $(smart.getComp("smart.datagrid")).attr("data-id", this.ent.id);
this.panel.find(".content-main-header").html(this.ent.name);
this.panel.find(".btn-grid-action").hide();
this.___cmenu = this.panel.find("div.datagrid-context-menu");
this.___cmenu.click(function(e) {
e.stopPropagation();
});
if (this.ent.___fields == null)
this.ent.___fields = this.getFields();
this.filterConfig();
this.dg = this.panel.find(".datagrid-wrap");
this.dg.attr("data-id", this.ent.id);
var drh = (this.ent.default_row_height < 25) ? 25 : this.ent.default_row_height;
this.dg.attr("data-row-height", drh);
this.dg.find(".datagrid-row").css("height", drh);
var t_rc = this.dg.find(".rightColumns>tr>td[data-template=1]");
var t_rd = this.dg.find(".rightData>tr[data-template=1]");
var t_ld = this.dg.find(".leftData>tr[data-template=1]");
t_ld.find("td>.datagrid-cell, td>.datagrid-cell-rownumber").css("height", drh).css("line-height", drh+"px");
var sp = smart.storage.getObject("datagrid_"+this.ent.id);
var hf = smart.storage.getObject("datagrid_"+this.ent.id+"_hidden");
if (hf == null)
hf = new Array();
this.ent.___fields.forEach(function(a) {
if (a.is_hidden == "1") return;
var x = t_rc.clone();
x.removeAttr("data-template");
x.css("display", "");
x.attr("data-col", a.special_code);
x.find("div>span:last-child").html(a.name);
if (hf.indexOf(a.special_code) != -1) {
x.addClass("hidden");
}
t_rc.parent().append(x);
var x = t_rd.find("td[data-template=1]").clone();
x.attr("data-field-id", a.id);
x.removeAttr("data-template");
x.find(".editable").css("height", drh).css("line-height", drh+"px");
x.css("display", "");
if (hf.indexOf(a.special_code) != -1) {
x.addClass("hidden");
}
t_rd.append(x);
if (sp != null) {
if (sp[a.special_code] !== undefined) {
_t.setColumnWidth(a.special_code, parseInt(sp[a.special_code],10),0);
}
}
});
smart._data.setting.each(function(st) {
if (st.key == "additional-languages") {
_t.ent.___fields.forEach(function(a) {
if (a.has_localization == "1") {
var item = smart._data.___languages.findRowByProperty("shortName", st.val);
if (item != null) {
var x = t_rc.clone();
x.attr("data-col", a.special_code+"_"+st.val);
x.removeAttr("data-template");
x.css("display", "");
x.find("div>span:last-child").html(' '+a.name);
t_rc.parent().append(x);
var x = t_rd.find("td[data-template=1]").clone();
x.attr("data-field-id", a.id);
x.attr("data-field-tto", item.shortName);
x.removeAttr("data-template");
x.find(".editable").css("height", drh).css("line-height", drh+"px");
x.css("display", "");
t_rd.append(x);
}
}
});
}
});
this.container.append(this.panel);
this.panel.find(".rightColumns").contextmenu(function(e) {
var commands = new Array();
commands.push({caption:"New Folder", cmd:function() {
}});
_t.openContextMenu("cols", e, null);
e.stopPropagation();
e.preventDefault();
});
this.container.on("click", function() {
_t.___cmenu.hide();
});
this.dispatchEnd("initDatagrid");
},
cacheUpdates : function() {
this.cachedUpdates = true;
this.cachedRows = new Array();
this.dg.find(".btn-next").hide();
this.dg.find(".btn-previous").hide();
this.dg.find(".pagination-desc").html("");
this.panel.find(".datagrid-filters-modal").remove();
this.filterPanel = null;
},
openContextMenu : function(type, event, args) {
var _t = this;
_t.___cmenu.css("left", event.clientX);
_t.___cmenu.css("top", event.clientY);
_t.___cmenu.find("ul.list-group").html("");
var startTpl = ''
, endTpl = ' ';
if (type == "cols") {
var g = smart.storage.getObject("datagrid_"+this.dg.attr("data-id")+"_hidden");
if (g == null) {
g = new Array();
}
this.ent.___fields.forEach(function(a) {
var cItem = $(startTpl + '' + a.name + ' ' + endTpl);
cItem.find("input").on("change", function () {
_t.onShowHideColumn($(this));
});
_t.___cmenu.find("ul.list-group").append(cItem);
});
} else if (args != null) {
args.forEach(function (a) {
var cItem = $(startTpl + a.caption + endTpl);
cItem.click(function () {
a.cmd.call(undefined);
_t.___cmenu.hide();
});
_t.___cmenu.find("ul.list-group").append(cItem);
});
}
_t.___cmenu.show();
},
addSubModule : function(ent) {
var _t = this;
this.subModules.push(ent);
var colWidth = this.subModules.length * 50;
var lc = null, ld = null;
if (this.dg.find(".leftColumns>tr>td[data-sub-module=1]").length > 0) {
lc = this.dg.find(".leftColumns>tr>td[data-sub-module=1]");
ld = this.dg.find(".leftData>tr[data-sub-module=1]");
} else {
var t_lc = this.dg.find(".leftColumns>tr>td[data-template=1]");
var t_ld = this.dg.find(".leftData>tr[data-template=1]");
var drh = (this.ent.default_row_height < 25) ? 25 : this.ent.default_row_height;
lc = t_lc.clone();
lc.removeAttr("data-template");
lc.css("display", "");
lc.attr("data-sub-module", "1");
lc.find("div>span:last-child").html("");
t_lc.parent().append(lc);
ld = t_ld.find("td[data-template=1]").clone();
ld.removeAttr("data-template");
ld.find(".datagrid-cell").css("height", drh).css("line-height", drh+"px");
ld.attr("data-sub-module", "1");
ld.css("display", "");
t_ld.append(ld);
}
var btn = $(''+
' ');
ld.find(".datagrid-cell").append(btn);
ld.find(".datagrid-cell").css("width", colWidth);
lc.find(".datagrid-cell-header").css("width", colWidth);
lc.css("width", colWidth);
ld.css("width", colWidth);
},
/*
* FILTERS
*/
filterConfig : function() {
var _t = this;
this.filterPanel = new SmartFilters(this.panel.find(".datagrid-filters-modal"), this);
this.filterPanel.onReset = function(sender, args) {
sender.applyFilter(args);
};
this.filterPanel.onSearch = function(sender, args) {
sender.applyFilter(args);
};
this.filterPanel.setEnt(this.ent.id);
this.filterPanel.setCurrentPage("1");
this.ent.___fields.forEach(function(a) {
if (a.default_filter != "") {
var filterVAL = a.default_filter;
if ((a.field_type == "d") || (a.field_type == "e")) {
if (filterVAL == "1") {
filterVAL = smart.util.getToday();
}
}
_t.addFilter(a.special_code, filterVAL);
}
});
this.setFilterStatus();
},
addFilter : function(key, val) {
this.removeFilter(key);
this.filters.push([key, val]);
},
removeFilter : function(key) {
for (var i=0; i 0) {
this.panel.find(".datagrid-span-filter").addClass("has-filter");
}
this.filterPanel.reset(this.filters);
},
addRecord : function(t, app) {
this.dispatchStart("addRecord", [t,app]);
var _t = this;
var id = 0;
var xies = new Array();
if (t != null) {
id = t.id;
}
var leftData = this.dg.find(".leftData");
var trl = leftData.find("tr[data-template=1]");
var x = trl.clone();
x.removeAttr("data-template");
x.css("display", "");
x.attr("data-id", id);
if (id==0) {
x.find(".datagrid-cell-rownumber > i.datagrid-mode").addClass("glyphicon-plus");
x.find(".datagrid-cell-rownumber > i.datagrid-sort-up").hide();
x.find(".datagrid-cell-rownumber > i.datagrid-sort-down").hide();
} else {
x.find(".datagrid-cell-rownumber > i.datagrid-mode").hide();
x.find(".datagrid-cell-rownumber > i.datagrid-sort-up").css("display", "inline-block");
x.find(".datagrid-cell-rownumber > i.datagrid-sort-down").css("display", "inline-block");
}
var pid = (t == null) ? 0 : ((t.parent_id == null) ? 0 : t.parent_id);
x.attr("data-parent-id", pid);
if (app)
leftData.append(x);
else
x.insertAfter(leftData.find("tr[data-id=0]"));
x.find("button").click(function() {
var t_f = null;
smart._data.ent_field.each(function(t_m) {
if ((t_m.ent_id == _t.ent.id) && (t_m.field_type == "t")) {
t_f = t_m.special_code;
return false;
}
});
var targetEnt = $(this).attr("data-id");
var ctx = _t.container.parents(".extTabContent").first();
var cc = system.form.getComponent(ctx, targetEnt);
var x = $(this).parents(".datagrid-row").first().attr("data-id");
if (x != null && x != 0) {
var selectedRow = smart._data[_t.ent.special_code].findRow(x);
if (t_f != null) {
cc.setTitle(selectedRow[t_f] + " için");
}
cc.setParentRow(x);
cc.refresh();
$(this).parents(".panel-container").fadeOut(function() {
$(this).parents(".extTabContent").find(".panel-container[data-id="+targetEnt+"]").fadeIn();
smart.fixPanels(ctx);
cc.onSubModuleLoaded();
});
} else if (x == 0) {
alert("Lütfen bu işlemi kaydı oluşturduktan sonra yapınız.");
}
});
var rightData = this.dg.find(".rightData");
var tr = rightData.find("tr[data-template=1]");
xies.push(x);
var x = tr.clone();
x.removeAttr("data-template");
x.css("display", "");
x.attr("data-id", id);
if (id==0) {
x.addClass("datagrid-row-new");
}
x.attr("data-parent-id", pid);
if (_t.ent.is_tree == "1") {
if (pid != 0) {
x.find("td:nth-child(2) > div > span").css("padding-left", "30px");
}
}
if (app)
rightData.append(x);
else
x.insertAfter(rightData.find("tr[data-id=0]"));
if (t != null) {
var f = this.ent.___fields;
var pr = smart._data.project.findRowByProperty("is_default", "1");
var is_first = false;
f.forEach(function(ff) {
var pad = ((_t.ent.is_tree == "1") && !is_first && (t.parent_id != 0)) ? 30 : 0;
_t.setRecordValue(ff,t,x,pr,"0",pad);
is_first = true;
if (ff.has_localization == '1') {
smart._data.setting.each(function(st) {
if (st.key == "additional-languages") {
_t.setRecordValue(ff,t,x,pr,st.val,0);
}
});
}
});
}
xies.push(x);
x.find("td.datagrid-td").click(function() {
if ($(this).parent().hasClass("datagrid-row-selected")) {
var cd = $(this).find("div"); //current td's editor
var dTR = $(this).parents(".datagrid-row-selected").first(); //main tr
if (!dTR.hasClass("datagrid-row-editing")) {
dTR.addClass("datagrid-row-editing");
//change all editable elements of td to editor mode
dTR.find("td.datagrid-td").not("[data-template=1]").each(function() {
//cast info of the ent_field to t
var fid = $(this).attr("data-field-id");
var t = (_t.remoteStructure != null) ? _t.findRemoteField(fid) :smart._data.ent_field.findRow(fid);
if (t.is_hidden == '1') return;
//editable div's instance
var d = $(this).find("div");
var i = null;
var mc = null;
if (t.field_type == "c") {
mc = _t.showEditorCheckbox(d, t);
} else if ((t.field_type == "p") || (t.field_type == "f")) {
i = $(' Yükle ');
var i2 = $('');
var i3 = $(' Sil ');
var i4 = $(' ');
d.html("").append(i);
d.append(i2);
d.append(i3);
d.append(i4);
i4.val(d.attr("data-val"));
if (d.attr("data-val") != "") {
i.hide();
i3.show();
}
i.click(function(e) {
e.stopPropagation();
});
i3.click(function() {
$(this).parent().find("#uploaded-file").val("");
$(this).parent().find(".fileinput-button").show();
$(this).hide();
i.parents(".editable").first().attr("data-c", "1");
});
i.find("#picture").on("change", function(evt) {
var files = evt.target.files;
var el = $(evt.target);
var elp = el.parents(".editable");
elp.attr("data-upload", "1");
for (var i = 0, f; f = files[i]; i++) {
var reader = new FileReader();
reader.onload = (function (theFile) {
return function (e) {
elp.find(".progress").show();
elp.find(".fileinput-button").hide();
setTimeout(function() {
var XHR = new XMLHttpRequest();
XHR.open('PUT', 'util.upload/init?cid='+smart.cid, true);
try {
for (var key in theFile) {
var val = theFile[key];
if (typeof (val) == 'string' || typeof (val) == 'number') {
XHR.setRequestHeader('file_' + key, encodeURI(val));
}
}
} catch (e) {
alert("Yüklemeye çalıştığınız dosya isminde türkçe karakterler olmamalıdır.");
}
XHR.upload.addEventListener("progress", function (e) {
if (!e.lengthComputable) return;
var percentComplete = parseInt(e.loaded / e.total * 100);
elp.find(".progress-bar").css("width", percentComplete+"%");
elp.find(".progress-bar").html(percentComplete+"%");
}, false);
XHR.onreadystatechange = function () {
if (this.readyState == this.DONE) {
elp.attr("data-upload", "0");
elp.attr("data-c", "1");
elp.find(".progress").hide();
elp.find(".fileinput-button").hide();
elp.find(".filedelete-button").show();
elp.find("#uploaded-file").val(this.responseText);
}
}
XHR.send(theFile);
}, 500);
};
})(f);
reader.readAsDataURL(f);
}
});
mc = i;
} else if (t.field_type == "s") {
mc = _t.showEditorCombobox(d, t);
} else if (t.field_type == "t" || t.field_type == "r") {
i = $('');
i.val($(this).find("span").html());
d.html("").append(i);
i.click(function(e) {
e.stopPropagation();
});
i.on("change", function() {
i.parents(".editable").first().attr("data-c", "1");
});
i.on("keyup", function(e) {
if (e.keyCode != 9 && e.keyCode != 13 && e.keyCode != 27) {
i.parents(".editable").first().attr("data-c", "1");
}
});
mc = i;
} else if (t.field_type == "i") {
mc = _t.showEditorInteger(d,t);
} else {
var mask = '';
if (t.field_type == "d") {
//mask = 'data-inputmask="\'alias\': \'dd.mm.yyyy\'"';
} else if (t.field_type == "e") {
//mask = 'data-inputmask="\'alias\': \'dd.mm.yyyy hh:ii\'"';
} else if (t.field_type == "o") {
mask='data-inputmask="\'alias\': \'decimal\', \'groupSeparator\': \'.\', \'radixPoint\':\',\', \'autoGroup\': true, \'digitsOptional\': false, \'digits\': '+t.decimal_place+'"';
}
i = $(' ');
i.val($(this).find("span").html());
d.html("").append(i);
if (mask != "")
i.inputmask();
if (t.field_type == "d") {
i.datetimepicker({
timepicker:false,
format:'d.m.Y',
lang:'tr',
mask:'39.19.9999',
closeOnDateSelect:true,
allowBlank:true
});
} else if (t.field_type == "e") {
i.datetimepicker({
format:'d.m.Y H:i',
lang:'tr',
mask:'39.19.9999 29:59',
step:5,
closeOnDateSelect:true,
allowBlank:true
});
}
i.click(function(e) {
e.stopPropagation();
});
i.on("change", function() {
i.parents(".editable").first().attr("data-c", "1");
});
i.on("keyup", function(e) {
if (e.keyCode != 9 && e.keyCode != 13 && e.keyCode != 27) {
i.parents(".editable").first().attr("data-c", "1");
}
});
mc = i;
}
if (mc != null) {
mc.on("keyup", function(e) {
if (e.keyCode == 9 || e.keyCode == 13) {
mc.attr("data-keepon", "1");
if (e.shiftKey)
mc.attr("shift-key", "1");
else
mc.attr("shift-key", "0");
_t.findNextControl(mc);
e.preventDefault();
e.stopPropagation();
} else if (e.keyCode == 27) {
e.preventDefault();
e.stopPropagation();
}
});
mc.on("keydown", function(e) {
if (e.keyCode == 9 || e.keyCode == 13) {
e.preventDefault();
e.stopPropagation();
}
});
}
});
}
cd.find("input, textarea").focus();
cd.find("input, textarea").select();
_t.gridButtonEvents();
} else {
var valid = true;
if (_t.dg.find(".datagrid-row-editing").length > 0) {
valid = _t.setRowValues(_t.dg.find(".datagrid-row-editing").attr("data-id"), true);
}
if (!valid) return;
_t.onRowSelected($(this));
}
});
if (this.cachedUpdates && t != null) {
this.cachedRows.push(t);
this.setGridNums();
}
this.dispatchEnd("addRecord", [xies]);
return xies;
},
deleteRecord : function(rowID) {
var r = this.dg.find(".rightData > .datagrid-row[data-id="+rowID+"]");
var l = this.dg.find(".leftData > .datagrid-row[data-id="+rowID+"]");
r.remove();
l.remove();
this.setGridNums();
this.gridButtonEvents();
},
emptyGrid : function() {
this.dg.find(".leftData").find("tr:gt(0)").remove();
this.dg.find(".rightData").find("tr:gt(0)").remove();
},
gridButtonEvents : function() {
var pdg=this.dg;
var mode = "", tr = null;
if (this.dg.find("tr.datagrid-row-editing").length == 1) {
mode = "edit";
tr = this.dg.find("tr.datagrid-row-editing");
} else if (this.dg.find("tr.datagrid-row-selected").length == 1) {
mode = "select";
tr = this.dg.find("tr.datagrid-row-selected");
}
pdg.find(".btn-grid-action").hide();
if (mode == "edit") {
pdg.find(".btn-cancel").show();
pdg.find(".btn-add").show();
} else if (mode == "select") {
/*if ((this.ent.is_tree == "1") || (this.ent.has_sorting == "1")) {
pdg.find(".btn-new-record").show();
}*/
if (tr.attr("data-id") != 0) {
if (this.ent.is_tree == "1") {
pdg.find(".btn-append-record").show();
}
pdg.find(".btn-delete").show();
if (this.ent.has_sorting == "1") {
pdg.find(".btn-up").show();
pdg.find(".btn-down").show();
}
}
}
if ((mode == "") || (mode == "select")) {
pdg.find(".btn-new-record").show();
}
},
findNextControl : function(mc) {
var p = mc.parents(".editable");
var rowID = p.parents(".datagrid-row").attr("data-id");
var shiftKey = mc.attr("shift-key");
if (shiftKey == "1") {
this.findControlRecursive(p.parent(), "prev", rowID);
/*if (p.parent().prev().length > 0) {
p.parent().prev().find("input,button,textarea").focus();
p.parent().prev().find("input,button,textarea").select();
} else {
this.setRowValues(rowID, true);
}*/
} else {
this.findControlRecursive(p.parent(), "next", rowID);
/*if (p.parent().next().length > 0) {
p.parent().next().find("input,button,textarea").focus();
p.parent().next().find("input,button,textarea").select();
} else {
this.setRowValues(rowID, true);
}*/
}
},
findControlRecursive : function(p, direction, rowID) {
var pn = null;
if (direction == "next" && p.next().length >0) {
pn = p.next();
} else if (direction == "prev" && p.prev().length>0) {
pn = p.prev();
}
if (pn != null) {
if (!pn.hasClass("hidden")) {
pn.find("input,button,textarea").focus();
pn.find("input,button,textarea").select();
} else {
this.findControlRecursive(pn, direction);
}
} else {
this.setRowValues(rowID, true);
}
},
findRemoteRow : function(id) {
var r = null;
this.remoteData.forEach(function(a) {
if (a["id"] == id) r=a;
});
return r;
},
findRemoteField : function(id) {
var r = null;
this.ent.___fields.forEach(function(a) {
if (a.id == id) r = a;
});
return r;
},
findCachedRow : function(id) {
var r = null;
this.cachedRows.forEach(function(a) {
if (a["id"] == id) r=a;
});
return r;
},
setDefaultRowValues : function(rowID) {
var _t = this;
var x = this.dg.find(".rightData > .datagrid-row[data-id="+rowID+"]");
var pr = smart._data.project.findRowByProperty("is_default", "1");
var t = null;
if (this.cachedUpdates) {
t = this.findCachedRow(rowID);
} else {
t = (this.remoteStructure != null) ? this.findRemoteRow(rowID) : smart._data[this.ent.special_code].findRow(rowID);
if (this.ent.live_data != 1) {
t = this.findRemoteRow(rowID);
}
}
var f = this.ent.___fields;
var is_first = false;
f.forEach(function(ff) {
var pad = ((_t.ent.is_tree == "1") && !is_first && (t.parent_id != 0)) ? 30 : 0;
_t.setRecordValue(ff,t,x,pr,"0",pad);
is_first = true;
if (ff.has_localization == '1') {
smart._data.setting.each(function(st) {
if (st.key == "additional-languages") {
_t.setRecordValue(ff,t,x,pr,st.val,0);
}
});
}
});
x.removeClass("datagrid-row-editing");
},
setRowValues : function(rowID, commit) {
var _t = this;
var row = this.dg.find(".rightData > .datagrid-row[data-id="+rowID+"]");
var pr = smart._data.project.findRowByProperty("is_default", "1");
if (row.find(".editable[data-upload=1]").length > 0) {
alert("Upload edilen dosyalarınız var. Lütfen bekleyiniz.");
return false;
}
var is_first = false;
row.find(".datagrid-td").not("[data-template=1]").each(function() {
var fid = $(this).attr("data-field-id");
var t = (_t.remoteStructure != null) ? _t.findRemoteField(fid) :smart._data.ent_field.findRow(fid);
if (t.is_hidden == '1') return;
var p = $(this).find(".editable").first();
var pad = ((_t.ent.is_tree == "1") && !is_first && (row.attr("data-parent-id") != 0)) ? 30 : 0;
var pdd = (pad>0) ? ' style="padding-left:'+pad+'px;"' : '';
is_first = true;
if (t.field_type == "c") {
var iText = p.find("input[type=text]");
if (iText.length == 0) return;
var sel = p.find("select>option[value="+p.find("input:hidden").val()+"]");
p.html('');
p.attr("data-val", sel.val());
var text = (sel.val() == "") ? "" : ((sel.val() == "1") ? "Evet" : "Hayır");
p.append($(''+text+' '));
} else if (t.field_type == "s") {
var iText = p.find("input[type=text]");
if (iText.length == 0) return;
var sel = p.find("select>option[value="+p.find("input:hidden").val()+"]");
p.html('');
p.attr("data-val", sel.val());
var text = (sel.val() == "") ? "" : sel.text();
p.append($(''+text+' '));
} else if (t.field_type == "p") {
var val = p.find("#uploaded-file").val();
var html = (val == "") ? "" : ' ';
p.attr("data-val", val);
p.html(''+html+' ');
} else if (t.field_type == "f") {
var val = p.find("#uploaded-file").val();
var html = (val == "") ? "" : ' '+val+' ';
p.attr("data-val", val);
p.html(''+html+' ');
} else if (t.field_type == "t" || t.field_type == "r") {
var val = p.find("textarea").val().trim();
p.html('');
p.append($(''+val+' '));
} else if (t.field_type == "i") {
_t.setValueInteger(p);
} else {
var val = p.find("input[type=text]").val().trim();
p.html('');
p.append($(''+val+' '));
}
setTimeout(function() {
if (p.parent().find(".dropdown-menu").length > 0)
p.parent().find(".dropdown-menu").remove();
}, 100);
});
row.removeClass("datagrid-row-editing");
this.validateRow(rowID);
this.saveRecord(rowID);
return true;
},
setRecordValue : function(ff, t, x, pr, tto, pad) {
if (ff.is_hidden == '1') return;
var ext = (tto == "0") ? "" : "_"+tto;
var tfd = "td.datagrid-td[data-field-id="+ff.id+"][data-field-tto="+tto+"]";
var dval = (t == null) ? "" : t[ff.special_code+ext];
x.find(tfd+">div").attr("data-c", "0");
if (ff.field_type == "p") {
x.find(tfd+">div").attr("data-val", dval);
x.find(tfd+">div").attr("data-pic", "1");
var html = (dval == "") ? "" : ' ';
x.find(tfd+">div").html(''+html+' ');
} else if (ff.field_type == "f") {
x.find(tfd+">div").attr("data-val", dval);
x.find(tfd+">div").attr("data-pic", "1");
var html = (dval == "") ? "" : ' '+dval+' ';
x.find(tfd+">div").html(''+html+' ');
} else if (ff.field_type == "c") {
x.find(tfd+">div").attr("data-val", dval);
var text = (dval == "") ? "" : ((dval == "1") ? "Evet" : "Hayır");
x.find(tfd+">div").html(''+text+' ');
} else if (ff.field_type == "s") {
var _ent = smart._data.ent.findRow(ff.ent);
var _temp = ff.ent_field.split(",");
var _entFields = new Array();
_temp.forEach(function(a) {
_entFields.push(smart._data.ent_field.findRow(a));
});
//var _entField = smart._data.ent_field.findRow(ff.ent_field);
var val = smart._data[_ent.special_code].findRow(dval);
//var valText = (val != null) ? val[_entField.special_code] : "";
var valText = "";
if (val != null) {
_entFields.forEach(function(a) {
valText += val[a.special_code] + " ";
});
}
x.find(tfd+">div").attr("data-val", dval);
x.find(tfd+">div").html(''+valText+' ');
} else if (ff.field_type == "d") {
x.find(tfd+">div").html(''+dval+' ');
} else if (ff.field_type == "i") {
this.setDefaultValueInteger(ff, t, x);
} else {
var pdd = (pad>0) ? ' style="padding-left:'+pad+'px;"' : '';
x.find(tfd+">div").html(''+dval+' ');
}
this.dispatchEnd("setRecordValue", [ff, t, x]);
setTimeout(function() {
if (x.find(tfd).find(".dropdown-menu").length > 0)
x.find(tfd).find(".dropdown-menu").remove();
}, 100);
},
validateRow : function(rowID) {
var row = this.dg.find(".rightData > .datagrid-row[data-id="+rowID+"]");
row.find(".datagrid-td").not("[data-template=1]").each(function() {
var t = smart._data.ent_field.findRow($(this).attr("data-field-id"));
if (t.is_hidden == '1') return;
var p = $(this).find("div").first();
var val = p.find("span").html();
if (t.field_type == "c") {
val = (p.attr("data-val") != null) ? p.attr("data-val") : "";
}
var error = '';
if ((t.is_empty != '1') && (val.length == 0))
error = 'Bu alan boş geçilemez';
if ((t.min_length != -1) && (val.length < t.min_length)) {
if (t.min_length == 1)
error = 'Bu alan boş geçilemez.';
else
error = 'Bu alanın minimum uzunluğu ' + t.min_length + " olmalıdır";
}
if ((t.max_length != -1) && (val.length > t.max_length)) {
error = 'Bu alanın maximum uzunluğu ' + t.max_length + " olmalıdır";
}
p.find("i").remove();
if (error != "") {
var er = $(' ').tooltip();
p.prepend(er);
}
});
},
saveRecord : function(rowID) {
var _t = this;
var row = this.dg.find(".rightData > .datagrid-row[data-id="+rowID+"]");
var validated = true;
var hasChanges = false;
var dgID = this.dg.attr("data-id");
var values = {};
values.__dgID = dgID;
values.__rowID = rowID;
values.__parentID = 0;
try {
values.__parentID = this.panel.attr("data-parent-id");
} catch (e) {}
if (this.ent.is_tree == "1") {
values.__treeParentID = row.attr("data-parent-id");
}
row.find(".datagrid-td").not("[data-template=1]").each(function() {
var fid = $(this).attr("data-field-id");
var t = (_t.remoteStructure != null) ? _t.findRemoteField(fid) :smart._data.ent_field.findRow(fid);
if (t.is_hidden == '1') return;
var lc = $(this).attr("data-field-tto");
lc = (lc == "0") ? "" : "_"+lc;
var d = $(this).find("div");
if (d.find("i").length > 0) {
validated = false;
}
if (d.attr("data-c") == "1") {
hasChanges = true;
}
if ((t.field_type == "c") || (t.field_type == "s") || (t.field_type == "p") || (t.field_type == "f")) {
values[t.special_code+lc] = d.attr("data-val");
} else if (t.field_type == "i") {
values[t.special_code+lc] = _t.getValueInteger(d);
} else {
values[t.special_code+lc] = d.find("span").html();
}
});
if (validated && hasChanges && !this.cachedUpdates) {
smart.post(this.dataPage+"/update", values, this, function(msg, _t) {
var h = smart._data.ent.findRow(dgID);
var msg = msg.data[0];
if (rowID == 0) {
if (msg.result != 0) {
var m = (_t.remoteStructure != null || _t.ent.live_data != "1") ? msg.entity : smart._data[h.special_code].findRow(msg.result);
var y = _t.addRecord(m,false);
_t.setGridNums();
y[0].insertAfter(_t.dg.find(".datagrid-view1").find("tr.datagrid-row[data-id=0]"));
y[1].insertAfter(_t.dg.find(".datagrid-view2").find("tr.datagrid-row[data-id=0]"));
_t.dg.find("tr.datagrid-row[data-id=0]").remove();
_t.dispatchEnd("saveRecord", [m.id]);
} else {
}
} else {
_t.dg.find("tr.datagrid-row[data-id="+rowID+"]>td").not("[data-template=1]").each(function() {
$(this).find("div.editable").attr("data-c", "0");
});
_t.dispatchEnd("saveRecord", [rowID]);
}
_t.gridButtonEvents();
});
} else {
if (this.cachedUpdates) {
if (rowID == 0) {
values.id = system.dynaDetail.autoID--;
var y = _t.addRecord(values,false);
y[0].insertAfter(_t.dg.find(".datagrid-view1").find("tr.datagrid-row[data-id=0]"));
y[1].insertAfter(_t.dg.find(".datagrid-view2").find("tr.datagrid-row[data-id=0]"));
_t.dg.find("tr.datagrid-row[data-id=0]").remove();
_t.dispatchEnd("saveRecord", [values.id]);
} else {
for (var i=0; i<_t.cachedRows.length; i++) {
if (_t.cachedRows[i].id == values.__rowID) {
values.id = values.__rowID;
_t.cachedRows[i] = values;
break;
}
}
_t.dg.find("tr.datagrid-row[data-id="+rowID+"]>td").not("[data-template=1]").each(function() {
$(this).find("div.editable").attr("data-c", "0");
});
_t.dispatchEnd("saveRecord", [rowID]);
}
_t.setGridNums();
_t.gridButtonEvents();
}
}
this.dispatchEnd("saveRecord", [rowID]);
},
getFields : function() {
var fields = new Array();
var _t = this;
smart._data.ent_field.each(function(entry) {
if (entry.ent_id == _t.ent.id) {
fields.push(entry);
}
});
return fields.sort(function(a,b) { return a.sort_order-b.sort_order;});
},
getFieldType : function(f) {
var _t = this;
var _ft = null;
smart._data.ent_field.each(function(entry) {
if ((entry.ent_id == _t.ent.id) && (entry.special_code == f)) {
_ft = entry.field_type;
}
});
return _ft;
},
getGridDimensions : function() {
var w = {};
this.dg.find("tr.datagrid-header-row").each(function() {
$(this).find("td").not("[data-template=1]").each(function() {
w[$(this).attr("data-col")] = $(this).css("width");
});
});
/*
var gdx = new Array(this.dg.attr("data-id"), w);
var ob = {};
for (var i=0; i td:nth-child("+(col.index()+1)+")").width(width);
this.dg.find(".datagrid-view2").first().find(".datagrid-row > td:nth-child("+(col.index()+1)+") > div").width(width);
},
getSortingsRecursive : function(parent_id) {
var arr = new Array();
var _t = this;
this.dg.find(".datagrid-view2").find("tr[data-parent-id="+parent_id+"]").not("[data-template=1],[data-id=0]").each(function() {
var id = $(this).attr("data-id");
arr.push(id);
var temp = _t.getSortingsRecursive(id);
if (temp.length > 0) {
arr.push(temp);
}
});
return arr;
},
getSortings : function() {
var values = {};
values.__dgID = this.dg.attr("data-id");
var arr = this.getSortingsRecursive(0);
values.__orders = arr;
smart.post(this.dataPage+"/makeSort", values, this.dg.parents(".extTabContent").first(), function(msg, ctx) {
});
},
getSelectedRowID : function() {
var tr = this.dg.find(".datagrid-row-selected");
if (tr.length == 1) {
return tr.attr("data-id");
}
return null;
},
moveNodeUP : function(id) {
var _t = this;
var v1 = _t.dg.find(".datagrid-view1").find("tr[data-id="+id+"]");
var v2 = _t.dg.find(".datagrid-view2").find("tr[data-id="+id+"]");
if (_t.ent.is_tree=='1') {
var parent_id = v2.attr("data-parent-id");
var id = v2.attr("data-id");
var prv = v2.prev();
while (true) {
if (prv.length == 0) break;
if (prv.attr("data-parent-id") == parent_id) {
break;
}
prv = prv.prev();
}
if (prv.length != 0) {
var sb = v2.next();
var arr = new Array();
while (true) {
if (sb.length == 0) break;
if (sb.attr("data-parent-id") == id) {
arr.push(sb);
} else {
break;
}
sb = sb.next();
}
v1.insertBefore(_t.dg.find(".datagrid-view1").find("tr[data-id="+prv.attr("data-id")+"]"));
v2.insertBefore(prv);
var li1,li2 = null;
arr.forEach(function(entry) {
li1 = _t.dg.find(".datagrid-view1").find("tr[data-id="+entry.attr("data-id")+"]");
li2 = entry;
li1.insertAfter(v1);
li2.insertAfter(v2);
v1 = li1;
v2 = li2;
});
_t.getSortings(0);
}
} else {
if (v2.prev().hasClass("datagrid-row-new")) return;
v1.insertBefore(v1.prev());
v2.insertBefore(v2.prev());
_t.getSortings(0);
}
this.setGridNums();
},
showEditorCheckbox : function(d, t) {
var vals = new Array(["1", "Evet"], ["0", "Hayır"]);
var i = $('Seçiniz ');
vals.forEach(function(a) {
var opt = $(" ").attr("value",a[0]).text(a[1]);
if (d.attr("data-val") == a[0]) opt.attr("selected", true);
i.append(opt);
});
d.html("").append(i);
i.combobox();
var iText = i.prev().find("input[type=text]");
iText.focus();
iText.select();
iText.attr("data-keepon", "0");
iText.attr("shift-key", "0");
iText.addClass("form-control");
iText.css("width", "100%").css("height", "24px");
i.prev().find(".input-group-addon").css("padding", "0px 10px");
i.prev().click(function(e) {
e.stopPropagation();
});
i.on("change", function() {
i.parents(".editable").first().attr("data-c", "1");
});
return i;
},
showEditorCombobox : function(d, t) {
var _ent = smart._data.ent.findRow(t.ent);
var _temp = t.ent_field.split(",");
var _entFields = new Array();
_temp.forEach(function(a) {
_entFields.push(smart._data.ent_field.findRow(a));
});
var vals = new Array();
smart._data[_ent.special_code].sortByName(function(entry) {
var valText = "";
_entFields.forEach(function(a) {
valText += entry[a.special_code] + " ";
});
vals.push([entry.id, valText]);
});
var i = $('Seçiniz ');
vals.forEach(function(a) {
var opt = $(" ").attr("value",a[0]).text(a[1]);
if (d.attr("data-val") == a[0]) opt.attr("selected", true);
i.append(opt);
});
d.html("").append(i);
i.combobox();
var iText = i.prev().find("input[type=text]");
iText.focus();
iText.select();
iText.attr("data-keepon", "0");
iText.attr("shift-key", "0");
iText.addClass("form-control");
iText.css("width", "100%").css("height", "24px");
i.prev().find(".input-group-addon").css("padding", "0px 10px");
i.prev().click(function(e) {
e.stopPropagation();
});
i.on("change", function() {
i.parents(".editable").first().attr("data-c", "1");
});
return iText;
},
showEditorInteger : function(d, t) {
var mask = 'data-inputmask="\'alias\': \'numeric\', \'groupSeparator\': \',\', \'autoGroup\': true, \'digits\': 0"';
var i = $(' ');
i.val(d.find("span").html());
d.html("").append(i);
i.inputmask();
i.click(function(e) {
e.stopPropagation();
});
i.click(function(e) {
e.stopPropagation();
});
i.on("change", function() {
i.parents(".editable").first().attr("data-c", "1");
});
i.on("keyup", function(e) {
if (e.keyCode != 9 && e.keyCode != 13 && e.keyCode != 27) {
i.parents(".editable").first().attr("data-c", "1");
}
});
return i;
},
setDefaultValueInteger : function(ff, t, x) {
var tfd = "td.datagrid-td[data-field-id="+ff.id+"][data-field-tto=0]";
var dval = (t == null) ? "" : t[ff.special_code];
x.find(tfd+">div").attr("data-c", "0");
x.find(tfd+">div").html(''+dval+' ');
},
setValueInteger : function(p) {
var val = p.find("input[type=text]").val().trim();
p.html('');
p.append($(''+val+' '));
},
getValueInteger : function(d) {
return d.find("span").html();
},
onRowSelected : function(td) {
this.dg.find("tr.datagrid-row").removeClass("datagrid-row-selected");
td.parent().addClass("datagrid-row-selected");
this.gridButtonEvents();
this.dispatchEnd("onRowSelected", [td]);
},
onCancelClick : function() {
var tr = this.dg.find(".datagrid-row-editing");
if (tr.length == 1) {
//if ((this.ent.is_tree == "1") && (tr.hasClass("datagrid-row-new"))) {
if ((tr.hasClass("datagrid-row-new"))) {
tr.remove();
this.dg.find(".leftData > .datagrid-row[data-id=0]").remove();
} else {
this.setDefaultRowValues(tr.attr("data-id"));
}
this.gridButtonEvents();
}
},
onDeleteClick : function() {
var _t = this;
var dgID = this.dg.attr("data-id");
var tr = this.dg.find(".datagrid-row-selected");
if (tr.length == 1) {
if (confirm("Bu kaydı silmek istediğinize emin misiniz ?")) {
var values = {};
values.__dgID = dgID;
values.__rowID = tr.attr("data-id");
if (_t.cachedUpdates) {
for (var i=0; i<_t.cachedRows.length; i++) {
if (_t.cachedRows[i].id == values.__rowID) {
_t.cachedRows.splice(i, 1);
break;
}
}
_t.deleteRecord(values.__rowID);
return;
}
smart.post(this.dataPage+"/delete", values, this.dg.parents(".extTabContent").first(), function(msg, ctx) {
var msg = msg.data[0];
if (msg.result != "0") {
_t.deleteRecord(msg.result);
} else {
alert(msg.message);
}
});
}
}
},
onMoveUpClick : function() {
var tr = this.dg.find(".datagrid-row-selected");
if (tr.length == 1) {
this.moveNodeUP(tr.attr("data-id"));
}
this.setGridNums();
},
onMoveDownClick : function() {
var tr = this.dg.find(".datagrid-row-selected");
if (tr.length == 1) {
var v1 = this.dg.find(".datagrid-view1").find("tr[data-id="+tr.attr("data-id")+"]");
var v2 = this.dg.find(".datagrid-view2").find("tr[data-id="+tr.attr("data-id")+"]");
if (this.ent.is_tree=='1') {
var parent_id = v2.attr("data-parent-id");
var nxt = v2.next();
while (true) {
if (nxt.length == 0) break;
if (nxt.attr("data-parent-id") == parent_id) {
break;
}
nxt = nxt.next();
}
if (nxt.length != 0) {
this.moveNodeUP(nxt.attr("data-id"));
}
} else {
if (v1.next().length == 1) {
this.moveNodeUP(v1.next().attr("data-id"));
}
}
}
this.setGridNums();
},
onApplyClick : function() {
var tr = this.dg.find(".datagrid-row-editing");
if (tr.length == 1) {
this.setRowValues(tr.attr("data-id"), true);
}
},
onAppendClick : function() {
var _m = this.dg.find(".rightData>tr[data-id="+this.getSelectedRow()+"]");
var _subm = null;
this.dg.find(".rightData>tr[data-parent-id="+this.getSelectedRow()+"]").each(function() {
_subm = $(this);
});
var y = this.addRecord(null, true);
y[0].attr("data-parent-id", this.getSelectedRow());
y[1].attr("data-parent-id", this.getSelectedRow());
if (_subm != null) {
y[0].insertAfter(this.dg.find(".leftData>tr[data-id="+_subm.attr("data-id")+"]"));
y[1].insertAfter(_subm);
} else {
y[0].insertAfter(this.dg.find(".leftData>tr[data-id="+_m.attr("data-id")+"]"));
y[1].insertAfter(_m);
}
y[1].find("td.datagrid-td:nth-child(2)").click();
y[1].find("td.datagrid-td:nth-child(2)").click();
},
onGoBackClick : function() {
try {
var _t = this;
var mainEnt = smart._data.ent.findRow(this.dg.parents(".panel-container").attr("data-id"));
this.container.find(".panel-container[data-id="+mainEnt.id+"]").fadeOut(function() {
_t.container.find(".panel-container[data-id="+mainEnt.parent_id+"]").fadeIn();
smart.fixPanels(_t.container.parents(".extTabContent"));
});
} catch (e) {throw e;}
},
onOpenFilterClick : function() {
this.filterPanel.open(this.filters);
},
onCellOrderClick : function(cell) {
/*
* @param {object} cell - which is ordered
*/
var _t = this;
if (cell.hasClass("active")) {
if (cell.find("i").hasClass("glyphicon-chevron-up")) {
cell.find("i").removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down");
_t.orders[cell.parents("td").attr("data-col")] = "asc";
} else {
cell.find("i").removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up");
_t.orders[cell.parents("td").attr("data-col")] = "desc";
}
} else {
_t.dg.find(".datagrid-cell-order").removeClass("active");
_t.dg.find(".datagrid-cell-order").parents("td").removeClass("datagrid-cell-ordered");
_t.dg.find(".datagrid-cell-order > i").removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down");
_t.orders = new Array();
cell.addClass("active");
cell.parents("td").addClass("datagrid-cell-ordered");
_t.orders[cell.parents("td").attr("data-col")] = "asc";
}
_t.refresh();
},
onNextClick : function() {
var cp = this.filterPanel.getCurrentPage();
var tp = this.filterPanel.getTotalPages();
if (cp < tp) {
this.filterPanel.setCurrentPage(cp+1);
this.refresh();
}
},
onPreviousClick : function() {
var cp = this.filterPanel.getCurrentPage();
var tp = this.filterPanel.getTotalPages();
if (cp > 1) {
this.filterPanel.setCurrentPage(cp-1);
this.refresh();
}
},
onShowHideColumn : function(obj) {
var g = smart.storage.getObject("datagrid_"+this.dg.attr("data-id")+"_hidden");
if (g == null) {
g = new Array();
}
var cn = obj.attr("id").split('|')[1];
var hd = false;
if (!obj.is(":checked")) {
g.push(obj.attr("id").split('|')[1]);
hd = true;
} else {
var i = g.indexOf(cn);
if (i != -1) {
g.splice(i, 1);
}
hd = false;
}
var col = this.dg.find(".datagrid-view2").find("td[data-col="+cn+"]");
if (hd) {
col.addClass("hidden");
this.dg.find(".datagrid-view2").find(".datagrid-row > td:nth-child("+(col.index()+1)+")").addClass("hidden");
} else {
col.removeClass("hidden");
this.dg.find(".datagrid-view2").find(".datagrid-row > td:nth-child("+(col.index()+1)+")").removeClass("hidden");
}
smart.storage.setObject("datagrid_"+this.dg.attr("data-id")+"_hidden", g);
},
onGridScroll : function(db, e) {
/*
* @param {object} db - datagrid body which scrolls
*/
var cl = parseInt(this.dg.attr("data-sl"),10);
var ct = parseInt(this.dg.attr("data-st"),10);
if (db.scrollTop() != ct) {
this.dg.attr("data-st", db.scrollTop());
} else {
this.dg.attr("data-sl", db.scrollLeft());
}
db.prev().scrollLeft(db.scrollLeft());
db.parent().prev().find(".datagrid-body").scrollTop(db.scrollTop());
},
onGridKeyDown : function(e) {
/*
* @param {event} e - keyboard event
*/
var a = this.dg.find(".datagrid-row-editing")
,b = this.dg.find(".datagrid-row-selected")
,c = this.dg.find(".datagrid-body");
if (a.length == 0) {
if (b.length == 1) {
if (e.keyCode == 38) {
if (b.prev().not("[data-template=1]").length > 0) {
b.prev().focus();
c.scrollTop(c.scrollTop() - 25);
b.prev().find("td.datagrid-td:nth-child(2)")
.click();
}
e.stopPropagation();
e.preventDefault();
} else if (e.keyCode == 40) {
if (b.next().not("[data-template=1]").length > 0) {
c.scrollTop(c.scrollTop() + 25);
b.next().focus();
b.next().find("td.datagrid-td:nth-child(2)")
.click();
}
e.stopPropagation();
e.preventDefault();
}
}
}
},
onSeperatorMouseDown : function(cell, e) {
this.resizer = new Array(
cell
, cell.parent().width()
, cell.parent().parent().width()
, e.clientX
, cell.parent().parent().index()
);
cell.parents(".datagrid-view").first().addClass("noselect");
e.preventDefault();
e.stopPropagation();
},
onSeperatorDoubleClick : function(cell, e) {
this.resizer = new Array(
cell
, cell.parent().width()
, cell.parent().parent().width()
, e.clientX
, cell.parent().parent().index()
);
var maxWidth = 0;
this.resizer[0].parents(".datagrid-view2")
.find(".datagrid-row > td:nth-child("+(this.resizer[4]+1)+")")
.each(function() {
var colWidth = $(this).find("span").width();
if (maxWidth < colWidth) maxWidth = colWidth;
});
if (maxWidth < 100) maxWidth = 100;
this.setColumnWidth(this.resizer[0].parents("td").attr("data-col"), maxWidth, 4);
this.resizer = null;
e.preventDefault();
e.stopPropagation();
this.getGridDimensions();
},
onGridMouseMove : function(e) {
if (this.resizer != null) {
var dist = e.clientX - this.resizer[3];
var p = this.resizer[2] + dist;
if (p < 100) p = 100;
this.setColumnWidth(this.resizer[0].parents("td").attr("data-col"), p, 4);
}
},
onGridMouseUp : function(e) {
if (this.resizer != null) {
this.resizer[0].parents(".datagrid-view").first().removeClass("noselect");
this.getGridDimensions();
}
this.resizer = null;
},
onSubModuleLoaded : function(e) {
this.dispatchStart("onSubModuleLoaded");
},
resized : function() {
var w = 0, h = 0;
this.panel.find(".panel-body").each(function() {
w = $(this).width(); h = $(this).height();
$(this).find(".datagrid-wrap").width(w).height(h);
$(this).find(".datagrid-view").width(w).height(h);
$(this).find(".datagrid-body").height(h-60);
var lw =0;
$(this).find(".datagrid-view1").find(".datagrid-htable").find("td").not("[data-template=1]").each(function() {
lw += ($(this).width())+2;
});
$(this).find(".datagrid-view1").width(lw);
$(this).find(".datagrid-view1").find(".datagrid-header").width(lw);
$(this).find(".datagrid-view1").find(".datagrid-footer").width(lw);
$(this).find(".datagrid-view1").find(".datagrid-body").width(lw);
$(this).find(".datagrid-view2").width(w-lw);
$(this).find(".datagrid-view2").find(".datagrid-header").width(w-lw);
$(this).find(".datagrid-view2").find(".datagrid-footer").width(w-lw);
$(this).find(".datagrid-view2").find(".datagrid-footer-inner").width(w-lw);
$(this).find(".datagrid-view2").find(".datagrid-body").width(w-lw);
});
this.container.find(".datagrid-context-menu").css("max-height", h-60);
},
bindEvents : function() {
var _t = this;
this.panel.find(".btn-cancel").click(function() {
_t.onCancelClick();
});
this.panel.find(".btn-delete").click(function() {
_t.onDeleteClick();
});
this.dg.find(".datagrid-view2 > .datagrid-body").on("scroll", function(e) {
_t.onGridScroll($(this), e);
});
this.panel.find(".btn-up").click(function() {
_t.onMoveUpClick();
});
this.panel.find(".btn-down").click(function() {
_t.onMoveDownClick();
});
this.panel.find(".btn-add").click(function() {
_t.onApplyClick();
});
this.panel.find(".btn-next").click(function() {
_t.onNextClick();
});
this.panel.find(".btn-previous").click(function() {
_t.onPreviousClick();
});
this.panel.find(".btn-new-record").click(function() {
_t.override_newButton();
});
this.panel.find(".btn-append-record").click(function() {
_t.onAppendClick();
});
this.panel.find(".btn-goback").click(function() {
_t.onGoBackClick();
});
this.dg.find(".datagrid-span-filter").click(function() {
_t.onOpenFilterClick();
});
this.dg.find(".datagrid-cell-order").click(function() {
_t.onCellOrderClick($(this));
});
this.dg.find(".datagrid-cell-separator").on("mousedown", function(e) {
_t.onSeperatorMouseDown($(this),e);
});
this.dg.find(".datagrid-cell-separator").on("dblclick", function(e) {
_t.onSeperatorDoubleClick($(this),e);
});
$(document).on("keydown", function(e) {
_t.onGridKeyDown(e);
});
$(document).on("mousemove", function(e) {
_t.onGridMouseMove(e);
});
$(document).on("mouseup", function(e) {
_t.onGridMouseUp(e);
});
},
refreshRecursive : function(parent_id) {
var _t = this;
var pid = this.panel.attr("data-parent-id");
var currentField = this.ent;
var targetField = smart._data.ent.findRow(currentField.parent_id);
smart._data[this.ent.special_code].each(function(a) {
var c = true;
if ((pid != "") && (targetField != null) && (targetField.is_folder != "1") && (pid != a[targetField.special_code+"_id"])) {
c = false;
}
if (c) {
if ((a["parent_id"] != parent_id)) {
c = false;
}
}
if (c) {
_t.addRecord(a,true);
//_t.refreshRecursive(a.id);
}
});
},
getCountByParent : function() {
},
setGridNums : function() {
var x = (this.cachedUpdates) ? 1 : this.filterPanel.getRowStart();
this.dg.find(".datagrid-view1").find("tr.datagrid-row").each(function() {
if ($(this).attr("data-id") != 0) {
$(this).find(".datagrid-cell-rownumber").html(x++);
}
});
},
/*
* COMPONENT INTERFACE
*/
setParentRow : function(id) {
this.panel.attr("data-parent-id", id);
},
refresh : function() {
var _t = this;
if (_t.cachedUpdates) return;
this.dispatchStart("refresh");
this.panel.find(".btn-new-record").show();
/*
if ((this.ent.is_tree == "1") || (this.ent.has_sorting == "1")) {
this.panel.find(".btn-new-record").show();
} else if (this.insertable) {
if (this.dg.find("tr.datagrid-row-new").length ==0)
this.addRecord(null,true);
}*/
this.dg.find(".btn-next").hide();
this.dg.find(".btn-previous").hide();
this.dg.find(".pagination-desc").html("");
var pid = this.panel.attr("data-parent-id");
var currentField = this.ent;
var targetField = smart._data.ent.findRow(currentField.parent_id);
if (_t.ent.live_data != "1") {
var _m = _t.filterPanel.getVals();
for (var aa in _t.orders) {
_m.___orderBy = aa;
_m.___orderDir = _t.orders[aa];
}
if ((pid != "") && (targetField != null) && (targetField.is_folder != "1")) {
_m[targetField.special_code+"_id"] = pid;
}
var lastLeftPosition = this.dg.attr("data-sl");
smart.post(_t.dataPage+"/select", _m, this.dg.parents(".extTabContent").first(), function(msg, ctx) {
_t.emptyGrid();
var metaInfo = msg.data[0];
if (metaInfo.totalPages > 1) {
_t.dg.find(".btn-next").show();
_t.dg.find(".btn-previous").show();
}
_t.filterPanel.setRowStart(metaInfo.currentRecord);
_t.filterPanel.setTotalPages(metaInfo.totalPages);
_t.dg.find(".pagination-desc").html(metaInfo.currentRecord+" - "+metaInfo.lastRecord+" / "+metaInfo.totalRecords);
_t.remoteData = msg.data[1].rows;
_t.remoteData.forEach(function(a) {
_t.addRecord(a,true);
});
_t.setGridNums();
_t.gridButtonEvents();
_t.dg.find(".datagrid-view2 > .datagrid-body").scrollTop(0);
_t.dg.find(".datagrid-view2 > .datagrid-body").scrollLeft(lastLeftPosition);
_t.dispatchEnd("refresh");
});
return;
}
this.emptyGrid();
if (this.remoteStructure != null) {
smart.get(_t.dataPage+"/init", "", this.dg.parents(".extTabContent").first(), function(msg, ctx) {
_t.remoteData = eval(msg.data);
_t.remoteData.forEach(function(a) {
var c = true;
/*
if ((pid != "") && (targetField != null) && (targetField.is_folder != "1") && (pid != a[targetField.special_code+"_id"]))
c = false;
*/
if (c)
_t.addRecord(a,true);
});
});
return;
}
var data = smart._data[this.ent.special_code].rows.sort(function(a,b) {
for (var aa in _t.orders) {
switch (_t.getFieldType(aa)) {
case "c":
case "s":
case "i":
case "o":
case "l":
return _t.orders[aa] == "asc" ? parseInt(a[aa])-parseInt(b[aa]) : parseInt(b[aa])-parseInt(a[aa]);
break;
default:
return _t.orders[aa] == "asc" ? a[aa].toLowerCase().localeCompare(b[aa].toLowerCase()) : b[aa].toLowerCase().localeCompare(a[aa].toLowerCase());
break;
}
}
});
data.forEach(function(a) {
var c = true;
if ((pid != "") && (targetField != null) && (targetField.is_folder != "1") && (pid != a[targetField.special_code+"_id"])) {
c = false;
}
if (c) {
if ((_t.ent.is_tree == "1") && (a["parent_id"] != 0)) {
c = false;
}
}
/*
* filter config
*/
for (var i=0; i<_t.filters.length; i++) {
for (var b in a) {
if (b == _t.filters[i][0]) {
var valToCompare = a[b];
var fieldType = _t.getFieldType(b);
if (fieldType == "e") {
valToCompare = valToCompare.split(" ")[0];
}
if (valToCompare != _t.filters[i][1]) {
c = false;
}
}
}
}
if (c) {
_t.addRecord(a,true);
if (_t.ent.is_tree == "1")
_t.refreshRecursive(a.id);
}
});
this.setGridNums();
this.gridButtonEvents();
this.dispatchEnd("refresh");
},
getSelectedRow : function() {
var _x = this.dg.find(".datagrid-row-selected");
if ((_x.length == 1) && (_x.attr("data-id") > 0))
return _x.attr("data-id");
return null;
},
getBackButton : function() {
return this.panel.find(".btn-goback");
},
setIcon : function(ico) {
this.panel.find("#icon-module").removeClass("glyphicon-bell").addClass(ico);
},
setTitle : function(a) {
this.panel.find(".content-main-header").html(a+" " +this.ent.name);
},
override_newButton : function() {
if (this.dg.find(".datagrid-row-new").length == 1) {
this.dg.find(".datagrid-row-new > td.datagrid-td:nth-child(2)").click();
this.dg.find(".datagrid-row-new > td.datagrid-td:nth-child(2)").click();
return;
}
var y = this.addRecord(null, true);
y[1].find("td.datagrid-td:nth-child(2)").click();
y[1].find("td.datagrid-td:nth-child(2)").click();
},
focus : function() {
this.setFilterStatus();
this.dispatchEnd("focus", this);
},
removeFooter : function() {
this.panel.find(".panel-footer").remove();
},
getType : function() { return "datagrid"; },
/*
* EVENTS
*/
dispatchStart : function(name, args) {
smart.bridge.check(true, this, name, args);
},
dispatchEnd : function(name, args) {
smart.bridge.check(false, this, name, args);
}
};
var SmartForms = function(container,ent) {
this.container = container;
this.ent = ent;
this.filters = new Array();
this.orders = new Array();
this.hasPicture = "";
this.identityFields = [];
this.taggerFields = [];
this.filterPanel = null;
this.pr = null;
this.init();
};
SmartForms.prototype = {
container : null,
ent : null,
panel:null,
md:null,
labels : ["warning", "info", "success", "danger"],
hasRich:false,
___fields:null,
init : function() {
this.dispatchStart("initForms");
var _t = this;
this.panel = $(smart.getComp("smart.forms")).attr("data-id", this.ent.id);
this.panel.find(".content-main-header").html(this.ent.name);
this.container.append(this.panel);
this.panel.find(".btn-forms-update").hide();
this.panel.find(".btn-forms-delete").hide();
this.md = this.panel.next();
if (this.ent.___fields == null)
this.ent.___fields = this.getFields();
this.pr = smart._data.project.findRowByProperty("is_default", "1");
this.ent.___fields.forEach(function(b) {
if (b.field_type == "p") {
_t.hasPicture = b.special_code;
} else if (b.field_type == "t") {
_t.identityFields.push(b.special_code);
} else if (b.field_type == "s") {
_t.taggerFields.push(b);
} else if (b.field_type == "l") {
_t.taggerFields.push(b);
}
});
this.panel.find(".btn-up").hide();
this.panel.find(".btn-down").hide();
var frm = this.md.find(".forms-update");
frm.find(".form-group").hide();
frm.find(".form-group").addClass("to-remove");
frm.find("#__dgID").val(this.ent.id);
this.filterConfig();
this.ent.___fields.forEach(function(t) {
var tpl = frm.find(".form-type-"+t.field_type);
var x = tpl.clone();
x.attr("data-field-name", t.name);
x.removeClass("form-type-"+t.field_type);
x.removeClass("to-remove");
x.show();
var isRequired = false;
if (t.min_length > 0 || t.is_empty == "0") {
isRequired = true;
}
x.find(".control-label").html(t.name + (isRequired ? " * " : ""));
frm.find(".row").append(x);
x.find("input,textarea,select").attr("name", t.special_code);
x.find("input,textarea,select").attr("id", t.special_code);
if (isRequired)
x.find("input,textarea,select").attr("data-rule-required","true");
smart._data.setting.each(function(st) {
if (st.key == "additional-languages") {
if (t.has_localization == "1") {
var item = smart._data.___languages.findRowByProperty("shortName", st.val);
if (item != null) {
var x = tpl.clone();
x.attr("data-field-name", t.name+"_"+st.val);
x.removeClass("form-type-"+t.field_type);
x.removeClass("to-remove");
x.show();
x.find(".control-label").html(' '+t.name);
frm.find(".row").append(x);
x.find("input,textarea,select").attr("name", t.special_code+"_"+st.val);
x.find("input,textarea,select").attr("id", t.special_code+"_"+st.val);
if (t.field_type == "z") {
x.find("textarea").attr("name", t.special_code+"_"+st.val+"_"+t.id);
x.find("textarea").attr("id", t.special_code+"_"+st.val+"_"+t.id);
CKEDITOR.replace(t.special_code+"_"+st.val+"_"+t.id, {
toolbar: [
[ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'],
[ 'TextColor', 'BGColor' ],
['NumberedList', 'BulletedList'],
['Paste', 'Undo', 'Redo' ]
],
height : 150,
allowedContent : 'b i u'
});
}
}
}
}
});
if (t.field_type == "d") {
x.find("input").datetimepicker({
timepicker:false,
format:'d.m.Y',
lang:'tr',
mask:'39.19.9999',
closeOnDateSelect:true,
allowBlank:true,
validateOnBlur:false
});
} else if (t.field_type == "e") {
x.find("input").datetimepicker({
format:'d.m.Y H:i',
lang:'tr',
mask:'39.19.9999 29:59',
step:30,
closeOnDateSelect:true,
allowBlank:true,
validateOnBlur:false
});
} else if (t.field_type == "i") {
x.find("input").inputmask("numeric",{
groupSeparator: '',
autoGroup: true,
digits: 0
});
} else if (t.field_type == "o") {
x.find("input").inputmask("decimal", {
groupSeparator: '.',
radixPoint:',',
autoGroup: true,
digits: 2
});
} else if (t.field_type == "k") {
x.find(".colorpicker-component").colorpicker();
} else if ((t.field_type == "s") || (t.field_type == "m")) {
_t.fillCombo(t, x.find("select"));
} else if (t.field_type == "z") {
x.find("textarea").attr("name", t.special_code+"_"+t.id);
x.find("textarea").attr("id", t.special_code+"_"+t.id);
CKEDITOR.replace(t.special_code+"_"+t.id, {
toolbar: [
[ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'],
[ 'TextColor', 'BGColor' ],
['NumberedList', 'BulletedList'],
['Paste', 'Undo', 'Redo' ]
],
height : 150,
allowedContent : 'b i u'
});
_t.hasRich = true;
} else if (t.field_type == "p") {
x.find("input[type=file]").attr("name", t.special_code + "_current");
x.find("input[type=file]").attr("id", t.special_code + "_current");
x.find(".btn-forms-pic-del").click(function() {
var elp = $(this).parents(".picture-upload");
elp.find("img").attr("src", "lib/images/nopic.jpg");
elp.find("input[type=hidden]").val("");
});
x.find("#"+t.special_code + "_current").on("change", function(evt) {
var files = evt.target.files;
var el = $(evt.target);
var elp = el.parents(".picture-upload");
elp.attr("data-upload","1");
for (var i = 0, f; f = files[i]; i++) {
var reader = new FileReader();
reader.onload = (function (theFile) {
return function (e) {
elp.find(".progress").show();
elp.find(".btn,img").hide();
setTimeout(function() {
var XHR = new XMLHttpRequest();
XHR.open('PUT', 'util.upload/init?cid='+smart.cid, true);
try {
for (var key in theFile) {
var val = theFile[key];
if (typeof (val) == 'string' || typeof (val) == 'number') {
XHR.setRequestHeader('file_' + key, encodeURI(val));
}
}
} catch (e) {
alert("Yüklemeye çalıştığınız dosya isminde türkçe karakterler olmamalıdır.");
}
XHR.upload.addEventListener("progress", function (e) {
if (!e.lengthComputable) return;
var percentComplete = parseInt(e.loaded / e.total * 100);
elp.find(".progress-bar").css("width", percentComplete+"%");
elp.find(".progress-bar").html(percentComplete+"%");
}, false);
XHR.onreadystatechange = function () {
if (this.readyState == this.DONE) {
var pr = smart._data.project.findRowByProperty("is_default", "1");
elp.attr("data-upload","0");
elp.find(".progress").hide();
elp.find(".btn,img").show();
elp.find("input[type=hidden]").val(this.responseText);
elp.find("img").attr("src", pr.url+pr.app_path+'/uploads/'+this.responseText);
}
}
XHR.send(theFile);
}, 500);
};
})(f);
reader.readAsDataURL(f);
}
});
} else if (t.field_type == "l") {
if (t.is_empty == "0") {
var opt = $(" ").attr("value","").text("");
x.find("select").append(opt);
}
x.find("select").attr("data-placeholder", t.name + " Seçiniz");
smart._data.setting.each(function(st) {
if ((st.key == "additional-languages") || (st.key == "default-language")) {
var item = smart._data.___languages.findRowByProperty("shortName", st.val);
if (item != null) {
var opt = $(" ").attr("value",st.val).text(item.name);
x.find("select").append(opt);
}
}
});
x.find("select").chosen({
width:"100%",
allow_single_deselect:true
});
}
});
/*
frm.validate({
errorPlacement: function(error, element) {
$( element ).parent().append(error);
}
});
*/
frm.find(".to-remove").remove();
this.dispatchEnd("initForms");
},
fillAllCombo : function() {
var _t = this;
this.ent.___fields.forEach(function(t) {
if ((t.field_type == "s") || (t.field_type == "m")) {
_t.fillCombo(t, _t.md.find(".form-group").find("select#"+t.special_code));
}
});
},
fillCombo : function(t, x) {
var _ent = smart._data.ent.findRow(t.ent);
var _temp = t.ent_field.split(",");
var _entFields = new Array();
_temp.forEach(function(a) {
_entFields.push(smart._data.ent_field.findRow(a));
});
x.find("option").remove();
if (t.is_empty == "0") {
var opt = $(" ").attr("value","").text("");
x.find("select").append(opt);
}
x.attr("data-placeholder", t.name + " Seçiniz");
smart._data[_ent.special_code].each(function(entry) {
var valText = "";
_entFields.forEach(function(a) {
valText += entry[a.special_code] + " ";
});
var opt = $(" ").attr("value",entry.id).text(valText);
x.append(opt);
});
if (t.field_type == "s") {
x.chosen({
width:"100%",
allow_single_deselect:true
});
} else {
x.attr("name", t.special_code+"[]");
x.chosen({
width:"100%"
});
}
},
filterConfig : function() {
var _t = this;
this.filterPanel = new SmartFilters(this.panel.find(".form-filters-modal"), this);
this.filterPanel.onReset = function(sender, args) {
sender.applyFilter(args);
};
this.filterPanel.onSearch = function(sender, args) {
sender.applyFilter(args);
};
this.ent.___fields.forEach(function(a) {
if (a.default_filter != "") {
var filterVAL = a.default_filter;
if ((a.field_type == "d") || (a.field_type == "e")) {
if (filterVAL == "1") {
filterVAL = smart.util.getToday();
}
}
_t.addFilter(a.special_code, filterVAL);
}
});
this.setFilterStatus();
},
addFilter : function(key, val) {
this.removeFilter(key);
this.filters.push([key, val]);
},
removeFilter : function(key) {
for (var i=0; i 0) {
this.panel.find(".btn-forms-search").addClass("has-filter");
}
},
bindEvents : function() {
var _t = this;
var frm = this.md.find(".forms-update");
frm.find(".picture-upload").hover(
function() {
$(this).find(".btn-forms-pic-new").show();
if ($(this).find("input[type=hidden]").val() != "") {
$(this).find(".btn-forms-pic-del").show();
}
}, function() {
$(this).find(".btn").hide();
}
);
this.panel.find(".btn-forms-new").click(function() {
_t.fillAllCombo();
_t.md.find(".modal-title").html("Yeni Kayıt");
_t.md.modal("show");
frm.formReset();
_t.getFields().forEach(function(f) {
if (f.field_type == "z") {
CKEDITOR.instances[f.special_code+"_"+f.id].setData("");
smart._data.setting.each(function(st) {
if (st.key == "additional-languages") {
if (f.has_localization == "1") {
CKEDITOR.instances[f.special_code+"_"+st.val+"_"+f.id].setData("");
}
}
});
}
});
frm.find("#__rowID").val("0");
frm.find("#__parentID").val(_t.panel.attr("data-parent-id"));
});
this.panel.find(".btn-forms-delete").click(function(e) {
if (confirm("Emin misiniz ?")) {
frm.find("#__rowID").val(_t.getSelectedRow());
smart.post("system.form/delete", frm.serializeObject(), _t, function(msg, ctx) {
if (msg.data[0].result > 0) {
ctx.refresh();
} else {
alert(msg.data[0].message);
}
});
}
});
this.panel.find(".btn-forms-update").click(function() {
_t.fillAllCombo();
_t.md.find(".modal-title").html("Kayıt Güncelleme");
_t.md.modal("show");
frm.formReset();
_t.getFields().forEach(function(f) {
if (f.field_type == "z") {
CKEDITOR.instances[f.special_code+"_"+f.id].setData("");
smart._data.setting.each(function(st) {
if (st.key == "additional-languages") {
if (f.has_localization == "1") {
CKEDITOR.instances[f.special_code+"_"+st.val+"_"+f.id].setData("");
}
}
});
}
});
var recordID = _t.getSelectedRow();
var fields = _t.getFields();
frm.find("#__rowID").val(recordID);
frm.find("#__parentID").val(_t.panel.attr("data-parent-id"));
if (_t.hasRich) {
var values = {};
values.__dgID = _t.ent.id;
values.__rowID = recordID;
smart.post("system.form/getRichie", values, _t, function(msg, _t) {
fields.forEach(function(b) {
if (b.field_type == "z") {
CKEDITOR.instances[b.special_code+"_"+b.id].setData(msg.data[0][b.special_code]);
//frm.find("#"+b.special_code).val(msg.data[0][b.special_code]);
smart._data.setting.each(function(st) {
if (st.key == "additional-languages") {
if (b.has_localization == "1") {
var item = smart._data.___languages.findRowByProperty("shortName", st.val);
if (item != null) {
CKEDITOR.instances[b.special_code+"_"+st.val+"_"+b.id].setData(msg.data[0][b.special_code+"_"+st.val]);
//frm.find("#"+b.special_code+"_"+st.val).val(msg.data[0][b.special_code+"_"+st.val]);
}
}
}
});
}
});
});
}
var pr = smart._data.project.findRowByProperty("is_default", "1");
smart._data[_t.ent.special_code].each(function(a) {
if (a.id == recordID) {
fields.forEach(function(b) {
if (b.field_type == "s") {
frm.find("#"+b.special_code).val(a[b.special_code]).trigger("chosen:updated");
} else if (b.field_type == "l") {
frm.find("#"+b.special_code).val(a[b.special_code]).trigger("chosen:updated");
} else if (b.field_type == "k") {
frm.find("#"+b.special_code).val(a[b.special_code]);
frm.find("#"+b.special_code).parent().colorpicker("setValue", a[b.special_code]);
} else if (b.field_type == "p") {
frm.find("#"+b.special_code).val(a[b.special_code]);
if (a[b.special_code] != "") {
frm.find("#"+b.special_code).parents(".picture-upload").find("img").attr("src", _t.pr.url+_t.pr.app_path+'/uploads/'+a[b.special_code]);
} else {
frm.find("#"+b.special_code).parents(".picture-upload").find("img").attr("src", "lib/images/nopic.jpg");
}
} else if (b.field_type == "c") {
if (a[b.special_code] == "1") {
frm.find("#"+b.special_code)[0].checked = true;
}
} else if (b.field_type == "m") {
frm.find("#"+b.special_code).val(a[b.special_code].split(",")).trigger("chosen:updated");
} else {
frm.find("#"+b.special_code).val(a[b.special_code]);
smart._data.setting.each(function(st) {
if (st.key == "additional-languages") {
if (b.has_localization == "1") {
var item = smart._data.___languages.findRowByProperty("shortName", st.val);
if (item != null) {
frm.find("#"+b.special_code+"_"+st.val).val(a[b.special_code+"_"+st.val]);
}
}
}
});
}
});
}
});
});
this.panel.find(".btn-goback").click(function() {
_t.container.find(".panel-container[data-id="+_t.ent.id+"]").fadeOut(function() {
_t.container.find(".panel-container[data-id="+_t.ent.parent_id+"]").fadeIn();
smart.fixPanels(_t.container.parents(".extTabContent"));
});
});
this.panel.find(".btn-up").click(function() {
var a = _t.getSelectedElement();
if (a != null) {
var prv = a.prev().not("[data-template=1]");
if (prv.length > 0) {
a.insertBefore(prv);
_t.getSortings();
}
}
});
this.panel.find(".btn-down").click(function() {
var a = _t.getSelectedElement();
if (a != null) {
var nxt = a.next();
if (nxt.length > 0) {
a.insertAfter(nxt);
_t.getSortings();
}
}
});
this.panel.find(".btn-forms-search").click(function() {
_t.filterPanel.open(_t.filters);
});
this.md.find(".modal-forms-submit").click(function() {
if (frm.find("[data-upload=1]").length > 0) {
alert("Upload halen devam etmekte, kayda devam edemezsiniz.");
return;
}
if (!frm.valid()) {
return;
}
var sobe = frm.serializeObject();
_t.getFields().forEach(function(f) {
if (f.field_type == "z") {
try {
sobe[f.special_code] = CKEDITOR.instances[f.special_code+"_"+f.id].getData();
smart._data.setting.each(function(st) {
if (st.key == "additional-languages") {
if (f.has_localization == "1") {
var item = smart._data.___languages.findRowByProperty("shortName", st.val);
if (item != null) {
sobe[f.special_code+"_"+st.val] = CKEDITOR.instances[f.special_code+"_"+st.val+"_"+f.id].getData();
}
}
}
});
} catch (e) { console.log(e); }
}
});
smart.post(frm.attr("action"), sobe, _t, function(msg, ctx) {
if (msg.data[0].result > 0) {
ctx.refresh();
ctx.md.modal("hide");
} else {
alert(msg.data[0].message);
}
});
});
},
getSortings : function() {
var arr = new Array();
this.panel.find(".list-group > a").not("[data-template=1]").each(function() {
var id = $(this).attr("data-id");
arr.push(id);
});
var values = {};
values.__dgID = this.ent.id;
values.__orders = arr;
smart.post("system.form/makeSort", values, this, function(msg, ctx) {});
},
getSelectedElement:function() {
var a = this.panel.find("a.active");
if (a.length > 0) {
return a;
}
return null;
},
getFields : function() {
var fields = new Array();
var _t = this;
smart._data.ent_field.each(function(entry) {
if (entry.ent_id == _t.ent.id) {
fields.push(entry);
}
});
return fields.sort(function(a,b) { return a.sort_order-b.sort_order;});
},
getFieldType : function(f) {
var _t = this;
var _ft = null;
smart._data.ent_field.each(function(entry) {
if ((entry.ent_id == _t.ent.id) && (entry.special_code == f)) {
_ft = entry.field_type;
}
});
return _ft;
},
/*
* COMPONENT INTERFACE
*/
setParentRow : function(id) {
this.panel.attr("data-parent-id", id);
},
onSubModuleLoaded : function(e) {
this.dispatchStart("onSubModuleLoaded");
},
getSelectedRow : function() {
var a = this.panel.find("a.active");
if (a.length > 0) {
return a.attr("data-id");
}
return null;
},
getBackButton : function() {
return this.panel.find(".btn-goback");
},
setIcon : function(ico) {
this.panel.find("#icon-module").removeClass("glyphicon-bell").addClass(ico);
},
refresh : function() {
this.dispatchStart("refresh");
var _t = this;
this.panel.find(".list-group > a").not("[data-template=1]").remove();
this.panel.find("div[data-template-no-record=1]").hide();
var targetField = smart._data.ent.findRow(this.ent.parent_id);
var pid = this.panel.attr("data-parent-id");
var tpl = this.panel.find("a[data-template=1]");
var hasRecord = false;
smart._data[this.ent.special_code].each(function(a) {
var c = true;
if ((pid != "") && (targetField != null) && (targetField.is_folder != "1") && (pid != a[targetField.special_code+"_id"]))
c = false;
/*
* filter config
*/
for (var i=0; i<_t.filters.length; i++) {
for (var b in a) {
if (b == _t.filters[i][0]) {
var valToCompare = a[b];
var fieldType = _t.getFieldType(b);
if (fieldType == "e") {
valToCompare = valToCompare.split(" ")[0];
}
if (valToCompare != _t.filters[i][1]) {
c = false;
}
}
}
}
if (!c) return;
var x = _t.onRecordRender(tpl, a);
x.click(function() {
if ($(this).hasClass("active")) {
_t.panel.find(".btn-forms-update").click();
}
$(this).parent().find("a").removeClass("active");
$(this).addClass("active");
_t.panel.find(".btn-forms-update").show();
_t.panel.find(".btn-forms-delete").show();
if (_t.ent.has_sorting == "1") {
_t.panel.find(".btn-up").show();
_t.panel.find(".btn-down").show();
}
});
hasRecord = true;
});
if (!hasRecord) {
this.panel.find("div[data-template-no-record=1]").show();
}
this.dispatchEnd("refresh");
},
/*
*
* @param {object} tpl - current template
* @param {object} a - current row
* returns {object} - modified row
*/
onRecordRender : function(tpl, a) {
var _t = this;
var tgID = 0;
var x = tpl.clone();
x.removeAttr("data-template");
x.css("display", "block");
x.attr("data-id", a.id);
tpl.parent().append(x);
var tagTpl = x.find("span[data-sub-template=1]");
this.dispatchStart("onRecordRender", [a]);
if (_t.hasPicture != "") {
if (a[_t.hasPicture] != "")
x.find(".data-pic").attr("src", this.pr.url + this.pr.app_path+'/uploads/'+a[_t.hasPicture]);
} else {
x.find(".data-pic").hide();
}
if (_t.identityFields.length > 0) {
var toParse = [];
_t.identityFields.forEach(function(b) {
toParse.push(a[b]);
});
x.find(".data-identity").html(toParse.join(" "));
}
if (_t.taggerFields.length > 0) {
var toParse = [];
_t.taggerFields.forEach(function(ff) {
var val="",valText="";
if (ff.field_type == "l") {
val = smart._data.___languages.findRowByProperty("shortName", a[ff.special_code]);
valText = (val != null) ? val["name"] : "";
} else {
var _ent = smart._data.ent.findRow(ff.ent);
var _temp = ff.ent_field.split(",");
var _entFields = new Array();
_temp.forEach(function(a) {
_entFields.push(smart._data.ent_field.findRow(a));
});
val = smart._data[_ent.special_code].findRow(a[ff.special_code]);
var valText = "";
if (val != null) {
_entFields.forEach(function(a) {
valText += val[a.special_code] + " ";
});
}
}
if (valText != "") {
var xx = tagTpl.clone();
xx.show();
xx.removeAttr("data-sub-template");
xx.html(ff.name + " : " + valText);
xx.addClass("label-"+_t.labels[tgID]);
xx.css("display", "inline-block");
tgID++;
if (tgID >= _t.labels.length) tgID = 0;
tagTpl.parent().append(xx);
}
});
}
this.dispatchEnd("onRecordRender", [a,x]);
return x;
},
setTitle : function(a) {
this.panel.find(".content-main-header").html(a+" " +this.ent.name);
},
removeFooter : function() {
this.panel.find(".panel-footer").remove();
},
getType : function() { return "forms"; },
/*
* EVENTS
*/
dispatchStart : function(name, args) {
smart.bridge.check(true, this, name, args);
},
dispatchEnd : function(name, args) {
smart.bridge.check(false, this, name, args);
}
};
var SmartFilters = function(container,sender) {
this.container = container;
this.sender = sender;
this.init();
};
SmartFilters.prototype = {
container : null,
sender : null,
init : function() {
var filterContent = $(smart.getComp("smart.filters")).attr("data-id", this.sender.ent.id);
this.container.append(filterContent);
var _t = this;
var fields = this.getFields();
var frm = this.container.find("form");
frm.find(".form-group").hide();
frm.find(".form-group").addClass("to-remove");
fields.forEach(function(t) {
var tpl = frm.find(".form-type-"+t.field_type);
var x = tpl.clone();
x.attr("data-field-name", t.name);
x.removeClass("form-type-"+t.field_type);
x.removeClass("to-remove");
x.show();
x.find(".control-label").html(t.name);
frm.find(".row").append(x);
x.find("input,textarea,select").attr("name", t.special_code);
x.find("input,textarea,select").attr("id", t.special_code);
x.find("input,textarea,select").attr("placeholder", t.name);
smart._data.setting.each(function(st) {
if (st.key == "additional-languages") {
if (t.has_localization == "1") {
var item = smart._data.___languages.findRowByProperty("shortName", st.val);
if (item != null) {
var x = tpl.clone();
x.attr("data-field-name", t.name+"_"+st.val);
x.removeClass("form-type-"+t.field_type);
x.removeClass("to-remove");
x.show();
x.find(".control-label").html(' '+t.name);
frm.find(".row").append(x);
x.find("input,textarea,select").attr("name", t.special_code+"_"+st.val);
x.find("input,textarea,select").attr("id", t.special_code+"_"+st.val);
}
}
}
});
if ((t.field_type == "d") || (t.field_type == "e")) {
x.find("input").datetimepicker({
timepicker:false,
format:'d.m.Y',
lang:'tr',
mask:'39.19.9999',
closeOnDateSelect:true,
allowBlank:true,
validateOnBlur:false,
allowBlank:true
});
} else if (t.field_type == "i") {
x.find("input").inputmask("numeric",{
groupSeparator: '',
autoGroup: true,
digits: 0
});
} else if (t.field_type == "o") {
x.find("input").inputmask("decimal", {
groupSeparator: '.',
radixPoint:',',
autoGroup: true,
digits: 2
});
} else if ((t.field_type == "s") || (t.field_type == "m")) {
var _ent = smart._data.ent.findRow(t.ent);
var _temp = t.ent_field.split(",");
var _entFields = new Array();
var _hasNameField = false;
_temp.forEach(function(a) {
var _row = smart._data.ent_field.findRow(a);
_entFields.push(_row);
if (_row.special_code == 'name') {
_hasNameField = true;
}
});
//var _entField = smart._data.ent_field.findRow(t.ent_field);
var opt = $(" ").attr("value","").text("");
x.find("select").append(opt);
x.find("select").attr("data-placeholder", t.name + " Seçiniz");
if (_hasNameField) {
smart._data[_ent.special_code].sortByName(function(entry) {
var valText = "";
_entFields.forEach(function(a) {
valText += entry[a.special_code] + " ";
});
var opt = $(" ").attr("value",entry.id).text(valText);
//if (d.attr("data-val") == a[0]) opt.attr("selected", true);
x.find("select").append(opt);
});
} else {
smart._data[_ent.special_code].each(function(entry) {
var valText = "";
_entFields.forEach(function(a) {
valText += entry[a.special_code] + " ";
});
var opt = $(" ").attr("value",entry.id).text(valText);
//if (d.attr("data-val") == a[0]) opt.attr("selected", true);
x.find("select").append(opt);
});
}
if (t.field_type == "s") {
x.find("select").chosen({
width:"100%",
allow_single_deselect:true
});
} else {
x.find("select").attr("name", t.special_code+"[]");
x.find("select").chosen({
width:"100%"
});
}
} else if (t.field_type == "l") {
if (t.is_empty == "0") {
var opt = $(" ").attr("value","").text("");
x.find("select").append(opt);
}
x.find("select").attr("data-placeholder", t.name + " Seçiniz");
smart._data.setting.each(function(st) {
if ((st.key == "additional-languages") || (st.key == "default-language")) {
var item = smart._data.___languages.findRowByProperty("shortName", st.val);
if (item != null) {
var opt = $(" ").attr("value",st.val).text(item.name);
x.find("select").append(opt);
}
}
});
x.find("select").chosen({
width:"100%",
allow_single_deselect:true
});
}
});
frm.find(".to-remove").remove();
this.container.find(".btn-reset").click(function() {
_t.reset();
if (_t.onReset != null) {
setTimeout(function() {_t.onReset.call(undefined, _t.sender, frm.serializeObject())}, 100);
}
});
this.container.find(".btn-search").click(function() {
if (_t.onSearch != null) {
setTimeout(function() {_t.onSearch.call(undefined, _t.sender, frm.serializeObject());}, 100);
}
});
setTimeout(function() {
frm.find("input").on("keyup", function(e) {
if (e.keyCode === 13) {
$(this).parents("form").find(".btn-search").click();
}
});
}, 500);
},
setEnt : function(val) {
var frm = this.container.find("form");
frm.find("input[name=entID]").val(val);
},
setCurrentPage : function(val) {
var frm = this.container.find("form");
frm.find("input[name=currentPage]").val(val);
},
getCurrentPage : function() {
var frm = this.container.find("form");
return parseInt(frm.find("input[name=currentPage]").val(),10);
},
setTotalPages : function(val) {
var frm = this.container.find("form");
frm.find("input[name=totalPages]").val(val);
},
getTotalPages : function() {
var frm = this.container.find("form");
return parseInt(frm.find("input[name=totalPages]").val(),10);
},
setRowStart : function(val) {
var frm = this.container.find("form");
frm.find("input[name=gridRowStart]").val(val);
},
getRowStart : function() {
var frm = this.container.find("form");
return parseInt(frm.find("input[name=gridRowStart]").val(),10);
},
getFields : function() {
var fields = new Array();
var _t = this;
smart._data.ent_field.each(function(entry) {
if (entry.ent_id == _t.sender.ent.id) {
fields.push(entry);
}
});
return fields.sort(function(a,b) { return a.sort_order-b.sort_order;});
},
open : function(filters) {
this.reset(filters);
smart.showModal(this.container.parent(), "div.modal");
},
reset : function(filters) {
this.container.find("form").formReset();
var frm = this.container.find("form");
for (var i=0; iKULLANDIĞINIZ TARAYICI ARTIK TERCİH EDİLMİYOR ! Bu web sitesi, en son web teknolojileri kullanılarak hazırlanmıştır ve bu tarayıcı tarafından desteklenmemektedir. ! Lütfen Firefox veya Chrome tarayıcılarından birini edinerek tekrar deneyin.");', 1000);
}
},
reload : function() {
smart.get("data.dynamic_data/getData", "", null, function(msg, ctx) {
if (!smart.app)
$('[data-toggle=tooltip]').tooltip();
if (smart._data.___cur == undefined || smart._data.ent == undefined) {
$(".main-menu").hide();
// first view will be login when the current user is undefined
if (smart._firstView != "") {
smart.createTab(smart._firstView, null, true, false);
}
return;
} else {
$(".main-menu").show();
}
if (!smart.isClient()) {
$(".modal-client-profile").remove();
}
with (smart) {
$("#___loadingPane").css("background-color", "transparent");
$(".project-name").html(projectName);
setTimeout(worker, workerTimeout);
lateRuns.forEach(function(a) {
try { a.apply(undefined); } catch (e) {console.log(e);}
});
// by default first view is hidden
if (_firstView != "") {
createTab(_firstView, null, true, false, true);
}
with (_data) {
var cUser = ___cur.rows[0];
if (ent != undefined) {
$("#navbar-left").append($(''+
''+
'Ana Menü '+
' '));
if (___me.client !== 1) {
ent.each(function(m) {
if (m.special_code == "member")
userAdapter = m.adapter;
if (m.is_folder == "1" && m.parent_id == 0) {
if (___auth != undefined) {
var a = ___auth.findRowByProperty("ent", m.id);
if ((a != null) && (a.r == "0") && !cUser.prg) return;
}
$("#navbar-left").append($(''+
' '+
''+m.name+' '+
' '));
}
});
}
}
}
$("body").append($('
'));
$(window).resize(function () {
clearTimeout(_windowResizeTO);
_windowResizeTO = setTimeout(function () {
var ctx = null;
checkMenu();
$(".extTabContent.current").each(function() {
ctx = $(this);
fixPanels(ctx);
});
}, 200);
});
if (app) {
$(".menu-container-bg").on("mouseover", function() { hideMenu(); });
$(".main-menu").on("mouseover", function() { showMenu($(this)); });
} else {
$(".menu-container-bg").on("click", function() { hideMenu(); });
$(".main-menu").on("click", function() { showMenu($(this)); });
}
$(document).on("scroll", function() {
if ($(".extTabContent.current").length > 0)
$(".extTabContent.current").attr("data-scroll", ($(this).scrollTop()));
});
if (!app)
$('[data-toggle=tooltip]').tooltip();
user = _data.___cur.rows[0];
loader.hide();
checkMenu();
setTimeout(historyAdapter, 100);
}
});
},
checkMenu : function() {
var wn = parseInt($(window).width(),10);
if (wn < 900) {
$(".menu-ent").show();
$(".menu-gen").hide();
$(".navbar-fixed-bottom").addClass("hidden");
} else {
$(".menu-ent").hide();
$(".menu-gen").show();
$(".navbar-fixed-bottom").removeClass("hidden");
}
},
getComp:function(name) {
for (var i=0; i li").not("[data-template=1]").remove();
var tpl = $(".menu-item").find("li[data-template=1]");
smart._data.mm.each(function(m) {
if ((pr != null) && ((pr.is_web_site != "1") && ((m.id == "web.cms") || (m.id == "web.translate")))) return;
if (!smart.user.prg && ((m.id == "core.codeBase") || (m.id == "system.ent") || (m.id=="system.project") || (m.id=="system.setting"))) return;
var x = tpl.clone();
x.removeAttr("data-template");
x.css("display", "");
x.attr("data-view", m.id);
if (m.id == "user.profile") {
if (smart.isClient()) {
var usr = smart._data.client.findRow(smart._data.___cur.rows[0].id);
x.find("i.g-icon").addClass("glyphicon-user");
x.find("span").html(usr.user_name);
x.attr("data-click", "clientProfile");
} else {
var usr = smart._data.member.findRow(smart._data.___cur.rows[0].id);
if (usr == null) return;
var pic = (usr.picture != undefined && usr.picture != "") ? pr.app_path+'/uploads/'+usr.picture : "lib/images/nopic.jpg";
x.find("i.g-icon").removeClass().html(' ');
x.find("span").html(usr.name + " " + usr.surname);
}
} else {
x.find("i.g-icon").addClass("glyphicon-"+m.icon);
x.find("span").html(m.name);
}
x.find(".glyphicon-chevron-right").hide();
x.click(function() {
if ($(this).attr("data-click")) {
smart.hideMenu();
smart.showModal($("body"), ".modal-client-profile");
} else {
smart.hideMenu();
smart.navig($(this).attr("data-view"));
}
});
tpl.parent().append(x);
});
} else if (obj.hasClass("notify-menu")) {
smart.isNotifyActive = true;
user.chat.buildNotifications();
} else {
if (smart._data.ent) {
smart.createEntMenu(obj.attr("data-parent-id"), false, (obj.attr("data-is-general")!="1"));
}
}
},
createEntMenu : function(parent_id, showFolder, isGeneral) {
var tpl = $(".menu-item").find("li[data-template=1]");
$(".menu-item > li").not("[data-template=1]").remove();
if (parent_id != 0 && showFolder) {
var m = smart._data.ent.findRow(parent_id);
var x = tpl.clone();
x.removeAttr("data-template");
x.css("display", "");
x.addClass("parent-menu");
x.attr("data-view", m.adapter+","+m.id);
x.find("i.g-icon").addClass("glyphicon-menu-left");
x.find("span").html(m.name);
x.find(".glyphicon-chevron-right").hide();
x.click(function() {
smart.createEntMenu(m.parent_id, true, isGeneral, true);
});
tpl.parent().append(x);
}
var current = new Array();
var cUser = smart._data.___cur.rows[0];
smart._data.ent.each(function(m) {
//if (___me.client === 1 && (m.id !== 11 || m.id !== 21)) return;
if (m.parent_id != parent_id) return;
if (___me.client === 1) {
if (m.id === "11" || m.id === "21") {
current.push(m);
}
return;
}
if (smart._data.___auth != undefined) {
var a = smart._data.___auth.findRowByProperty("ent", m.id);
if ((a != null) && (a.r == "0") && !cUser.prg) return;
}
current.push(m);
});
console.log(current);
smart.orderBY(current).forEach(function(m) {
if (((m.is_folder != "1") && ((m.adapter == "NULL")))) return;
if (isGeneral && m.is_folder == "1") return;
var x = tpl.clone();
x.removeAttr("data-template");
x.css("display", "");
x.attr("data-view", m.adapter+","+m.id);
x.find("i.g-icon").addClass(m.icon);
x.find("span").html(m.name);
if (m.is_folder != "1") {
x.find(".glyphicon-chevron-right").hide();
x.click(function() {
smart.hideMenu();
smart.navig($(this).attr("data-view"));
});
} else {
x.click(function() {
smart.createEntMenu(m.id, true, isGeneral);
});
}
tpl.parent().append(x);
});
},
orderBY : function(x) {
return x.sort(function(a,b) { return a.sort_order-b.sort_order;});
},
showMenu:function(obj) {
smart.createMenu(obj);
var i = $(".active-menu").find("i");
i.removeClass();
i.addClass(obj.find("i").attr("class")).html(obj.find("i").html());
var of = obj.offset();
$(".active-menu").css("left", of.left);
$(".active-menu").find("span").html(obj.find("span").html());
if (obj.hasClass("notify-menu")) {
$(".menu-container").css("right", "0px");
$(".menu-container").css("left", "initial");
} else {
$(".menu-container").css("left", of.left);
}
$(".menu-container").css("min-width", obj.width());
$(".active-menu,.menu-container,.menu-container-bg").fadeIn(100);
},
hideMenu:function() {
smart.isNotifyActive = false;
$(".active-menu,.menu-container,.menu-container-bg").fadeOut(100);
},
worker:function() {
if (smart._loading) {
setTimeout(smart.worker, smart.workerTimeout);
return;
}
smart.inlineCall("data.dynamic_data/getNewData", "", "-", function(msg, sender) {
setTimeout(smart.worker, smart.workerTimeout);
}, "GET", true, true, null);
},
createTab : function(url, fnc, noclose, forceClose, silent) {
var dataView = url.replace(/#/g,',');
if (url.indexOf(",") != -1) {
url = url.replace(/,/g,'#');
}
var contextID = 0;
var contextDetailID = 0;
if (url.indexOf("#") != -1) {
url = url.split("#");
contextID = url[1];
if (url.length > 2) {
contextDetailID = url[2];
}
url = url[0];
}
var silent = (typeof silent != 'undefined' && silent);
var forceClose = (typeof forceClose != 'undefined' && forceClose);
var hasContext = false;
$(".extTabContent").each(function() {
if (($(this).attr("data-context") == url) && ($(this).attr("data-context-id") == contextID) && ($(this).attr("data-context-detail-id") == contextDetailID)) {
if (forceClose) {
$(this).remove();
} else {
if (!silent)
smart.changeTab($(this), false);
hasContext = true;
}
}
});
if (hasContext) return;
var x = ++this._tabID;
var _unclose = "0";
if (typeof noclose != 'undefined' && noclose) {
_unclose = "1";
}
var cntEL = $('Yükleniyor
');
$("body").append(cntEL);
var hasView = false;
this._view.forEach(function(entry) {
if (entry.name == url) {
hasView = true;
cntEL.html(entry.content);
smart.bindEvents(cntEL);
}
});
if (!hasView) {
$('#content-main-'+x).html("");
}
if (typeof fnc != 'undefined' && fnc != null) {
fnc.call(undefined, cntEL);
}
smart.setState(cntEL, "init");
if (url != "") {
eval("try {" + url + ".init(cntEL); } catch (e) {}");
}
if (!silent)
smart.changeTab(cntEL);
return cntEL;
},
closer : function(ctx) {
var id = ctx.attr("id");
if (ctx.attr("data-vul") != "1") {
eval("try {" + ctx.attr("data-context") + ".closing(ctx); } catch (e) {}");
ctx.attr("data-is-closing", 1);
}
smart.smartGoesBack = true;
window.history.back(-1);
},
_isModalShown:false,
showModal : function(ctx, selector) {
ctx.find(selector).modal("show");
ctx.find(selector).addClass("smart-shown-modal");
smart._isModalShown = true;
ctx.find(selector).unbind("hidden.bs.modal");
ctx.find(selector).on("hidden.bs.modal", function() {
smart._isModalShown = false;
setTimeout(function() {
if (window.location.hash == "#smartmodalshown") {
smart.smartGoesBack = true;
window.history.back(-1);
}
},100);
if ($("body").hasClass("no-overflow")) {
$("body").scrollTop(0);
}
$(this).removeClass("smart-shown-modal");
});
window.location.href="#smartmodalshown";
},
closeTab : function(ctx) {
smart.smartGoesBack = true;
window.history.back(-1);
},
goBack : function() {
smart.smartGoesBack = true;
window.history.back(-1);
},
hashChanged : function(event) {
},
getView: function(url) {
var result = null;
this._view.forEach(function(entry) {
if (entry.name == url) {
result = entry.content;
}
});
return result;
},
bindEvents : function(ctx) {
if (!smart.app)
ctx.find('[data-toggle=tooltip]').tooltip();
if (!smart.app && $(window).width() < 1200)
ctx.find('[data-toggle=menu-tooltip]').tooltip();
ctx.find('[data-toggle=popover]').popover();
ctx.find("input,textarea").on("focus", function() {
$(this).select();
});
$("form").each(function() {
if ($(this).attr("data-proc") != null) return;
$(this).find(".input-group.date").each(function() {
$(this).datepicker({
format : 'dd.mm.yyyy',
language: "tr",
autoclose: true
});
});
/*
$(this).find(".select-chosen").each(function() {
$(this).chosen({width: '100%', height:'25px' });
});
*/
$(this).submit(function() {
if ($(this).attr("action") == "") return false;
var errorMessage = '';
$(this).find("input").each(function() {
if ($(this).attr("data-required") != null) {
if ($(this).val() == "") {
errorMessage += ($(this).attr("data-required") + " boş geçilemez \n");
}
}
});
$(this).find("select").each(function() {
if ($(this).attr("data-required") != null) {
if ($(this).val() == "") {
errorMessage += ($(this).attr("data-required") + " boş geçilemez \n");
}
}
});
$(this).find(".select-chosen").each(function() {
if ($(this).attr("data-required") != null) {
if ($(this).val() == null) {
errorMessage += ($(this).attr("data-required") + " boş geçilemez \n");
}
}
});
if (errorMessage != "") {
alert(errorMessage);
return false;
}
var snd = $(this).parents(".extTabContent");
eval("try {" + snd.attr("data-context") + ".beforeSubmit(snd); } catch (e) { }");
var fnc = null;
if ($(this).attr("fnc") != null) fnc = $(this).attr("fnc");
var hasExtra = false;
if ($(this).attr("hasExtra") != null) hasExtra = true;
smart.post($(this).attr("action"), $(this).serializeObject(), snd, eval(fnc));
return false;
});
$(this).attr("data-proc", "1");
});
},
getTemplate : function(template) {
var x = template.clone();
x.removeAttr("data-template");
x.css("display", "");
template.parent().append(x);
return x;
},
windowManager : function() {
var a = $("");
$(".extTabContent").each(function() {
var toolbarItem = null;
var isActive = false;
var sender = $(this);
if (sender.hasClass("current")) {
isActive = true;
}
eval("try { toolbarItem = " + sender.attr("data-context") + ".toolbarItem(sender); } catch (e) {}");
if (toolbarItem != null) {
if (isActive) {
toolbarItem.addClass("active");
}
if (sender.attr("data-vul") != "1") {
var closer = $(' ');
toolbarItem.append(closer);
closer.click(function(e) {
e.preventDefault();
e.stopPropagation();
if (sender.attr("data-vul") != "1") {
eval("try {" + sender.attr("data-context") + ".closing(ctx); } catch (e) {}");
sender.attr("data-is-closing", 1);
}
if (sender.hasClass("current")) {
smart.smartGoesBack = true;
window.history.back(-1);
} else {
smart.changeTab($(".extTabContent.current"));
}
});
}
toolbarItem.click(function() {
smart.navig(sender.attr("data-view"));
});
a.append(toolbarItem);
}
});
if (a.find("button").length == 0)
return null;
return a;
},
changeTab : function(sender, goBack) {
var ct = $(".extTabContent.current");
var animate = false;
if (ct.length == 1) {
if (ct.attr("id") != sender.attr("id"))
animate = true;
}
if (!animate) {
$(".extTabContent").each(function() {
$(this).removeClass("current");
if ($(this).attr("data-is-closing") == "1") {
$(this).remove();
}
});
smart.changeTabDelegate(sender, goBack);
} else {
ct.fadeOut(40, function() {
$(this).removeClass("current");
$(this).removeAttr("style");
if ($(this).attr("data-is-closing") == "1") {
$(this).remove();
}
sender.fadeIn(40, function() {
sender.removeAttr("style");
smart.changeTabDelegate(sender, goBack);
});
});
}
},
changeTabDelegate : function(sender, goBack) {
sender.addClass("current");
if (!goBack)
smart.lastTabRefs.push(sender.attr("id"));
$("#sub-navbar-left").empty();
$("#footbar-left").empty();
$("#footbar-right").empty();
smart.dispatchNavItemLeft(sender);
smart.dispatchNavItemRight(sender);
var footItemLeft = null;
eval("try { footItemLeft = " + sender.attr("data-context") + ".footDrawerLeft(sender); } catch (e) {}");
if (footItemLeft != null)
$("#footbar-left").append(footItemLeft);
var footItemRight = null;
eval("try { footItemRight = " + sender.attr("data-context") + ".footDrawerRight(sender); } catch (e) {}");
if (footItemRight != null)
$("#footbar-right").append(footItemRight);
if (footItemLeft == null && footItemRight == null) {
var wn = parseInt($(window).width(),10);
if (wn < 900) {
$(".navbar-fixed-bottom").addClass("hidden");
} else {
var wm = smart.windowManager();
if (wm != null) {
$(".navbar-fixed-bottom").removeClass("hidden");
$("#footbar-left").append(wm);
} else {
$(".navbar-fixed-bottom").addClass("hidden");
}
}
} else
$(".navbar-fixed-bottom").removeClass("hidden");
$(document).scrollTop(sender.attr("data-scroll"));
eval("try {" + sender.attr("data-context") + ".focused(sender); } catch (e) {}");
smart.fixPanels(sender);
smart.tabChangeListeners.forEach(function(a) {
a.call(undefined, sender);
});
},
dispatchNavItemRight : function(sender) {
$("#sub-navbar-right").empty();
var navItemRight = null;
eval("try { navItemRight = " + sender.attr("data-context") + ".navDrawerRight(sender); } catch (e) {}");
if (navItemRight != null)
$("#sub-navbar-right").append(navItemRight);
},
dispatchNavItemLeft : function(sender) {
$("#sub-navbar-left").empty();
var navItemLeft = null;
eval("try { navItemLeft = " + sender.attr("data-context") + ".navDrawerLeft(sender); } catch (e) {}");
if (navItemLeft != null)
$("#sub-navbar-left").append(navItemLeft);
else {
if (smart._data.project != undefined) {
var project = smart._data.project.findRowByProperty("is_default", "1");
if (project != null) {
$("#sub-navbar-left").append($(''+project.name+' '));
}
}
}
},
fixPanels : function(sender) {
eval("try {" + sender.attr("data-context") + ".beforeResize(sender); } catch (e) {}");
$("body").removeClass();
$("body").addClass("overflows");
if (sender == null) return;
var wn = parseInt($(window).height(),10);
var pd = parseInt($("body").css("padding-top"),10)+10;
if (sender.find(".row").hasClass("panels-fixed")) {
sender.find(".row").find(".panel-to-fix").each(function() {
var td = pd + parseInt($(this).css("paddingTop"),10) + parseInt($(this).css("paddingBottom"),10);
if (($(this).next().length > 0) && ($(this).next().hasClass("panel-footer"))) {
td += $(this).next().height() + parseInt($(this).next().css("paddingTop"),10) + parseInt($(this).next().css("paddingBottom"),10);
}
if (($(this).prev().length > 0) && ($(this).prev().hasClass("panel-heading"))) {
td += $(this).prev().height() + parseInt($(this).prev().css("paddingTop"),10) + parseInt($(this).prev().css("paddingBottom"),10);
}
if (!$(".navbar-fixed-bottom").hasClass("hidden")) {
td += $(".navbar-fixed-bottom").height();
}
$(this).height((wn-td) + "px");
$(this).addClass("overflows");
});
}
if (sender.hasClass("current") && sender.find(".row").hasClass("panels-fixed")) {
$("body").removeClass();
$("body").addClass("no-overflow");
}
eval("try {" + sender.attr("data-context") + ".resized(sender); } catch (e) {}");
if ($(window).width()<1200)
$(".menu-container").css("max-height", wn-70);
else
$(".menu-container").css("max-height", wn-70);
},
registerListener : function(type, fnc) {
if (type == "tabChange")
smart.tabChangeListeners.push(fnc);
else if (type == "dataChange")
smart.dataChangeListeners.push(fnc);
},
showMessage : function(type, text) {
$(".smartGlobalMessage").html(text);
$(".smartGlobalMessage").removeClass("alert-danger");
$(".smartGlobalMessage").removeClass("alert-success");
$(".smartGlobalMessage").removeClass("alert-warning");
$(".smartGlobalMessage").addClass("alert-"+type);
$(".smartGlobalMessage").css("left", (($(document).width()-$(".smartGlobalMessage").width())/2));
$(".smartGlobalMessage").show();
$(".smartGlobalMessage").delay(2000).fadeOut("slow");
},
/*
* Rest of the functions are for ajax requests
*/
post : function(page, params, sender, fnc) {
smart.inlineCall(page, params, sender, fnc, "POST", false, false, null);
},
postExtra : function(page, params, extra, sender, fnc) {
smart.inlineCall(page, params, sender, fnc, "POST", false, false, extra);
},
getData : function(page, params, sender, fnc) {
smart.inlineCall(page, params, sender, fnc, "GET", true, false, null);
},
get : function(page, params, sender, fnc) {
smart.inlineCall(page, params, sender, fnc, "GET", false, false, null);
},
getQuiet : function(page, params, sender, fnc) {
smart.inlineCall(page, params, sender, fnc, "GET", false, true, null);
},
postQuiet : function(page, params, sender, fnc) {
smart.inlineCall(page, params, sender, fnc, "POST", false, true, null);
},
getQuietExtra : function(page, params, extra, sender, fnc) {
smart.inlineCall(page, params, sender, fnc, "GET", false, true, extra);
},
getDocument : function(page, params, sender, fnc) {
loader.show();
smart._loading = true;
if (smart._path == "/") smart._path = "";
$.ajax({
url: smart._path + '/' + page + "?cid="+smart.cid,
type: "POST",
data: {
p : params
}
}).done(function(msg) {
try {
if (fnc != null) {
try {
loader.hide();
fnc.call(undefined, msg, sender);
} catch (e) {
console.log("inlineCall.fnc::" + e.description);
}
}
} catch(e) {
console.log("inlineCall::"+e.description);
}
}).fail(function(msg) {
if (fnc != null) {
fnc.call(undefined, new Message(0, msg, null), sender);
}
}).always(function() {
smart._loading = false;
});
},
inlineCall : function(page, params, sender, fnc, callType, isData, quiet, extra) {
if (!quiet)
loader.show();
smart._loading = true;
if (smart._path == "/") smart._path = "";
$.ajax({
url: smart._path + '/' + page + "?cid="+smart.cid,
type: callType,
data: {
p : params,
x : extra
}
}).done(function(msg) {
var c="", d="", dbg="", t=msg.split("\n");
c = t[0];
if (t.length > 1) d = t[1];
if (t.length > 2) dbg = t[2];
try {
if (d != "") { eval(d); }
} catch(e) {
smart.throwError([e, d]);
}
if (!quiet)
loader.hide();
try {
if (fnc != null) {
try {
fnc.call(undefined, new Message(1, "", eval(c)), sender, eval(dbg));
} catch (e) {
throw e;
}
}
} catch(e) {
console.log(page);
console.log(params);
console.log(fnc);
console.log(sender);
smart.throwError([e, page, params, fnc, sender]);
}
}).fail(function(msg) {
if (fnc != null) {
fnc.call(undefined, msg, sender);
}
loader.hide();
}).always(function() {
smart._loading = false;
//loader.hide();
});
},
throwError : function(params) {
console.log(params);
var p = [];
params.forEach(function(a) {
if (a instanceof TypeError || a instanceof EvalError || a instanceof RangeError || a instanceof ReferenceError || a instanceof SyntaxError || a instanceof URIError) {
p.push(a.message);
p.push(a.name);
p.push(a.description);
p.push(a.stack);
p.push(a.number);
p.push(a.fileName);
} else {
p.push(a);
}
});
console.log(p);
return;
smart.postQuiet("core.errorReporting/silent", p, null, function(msg, ctx) {
smart.getErrorReporting();
});
},
getErrorReporting : function() {
var md = null;
if ($("body>.smart-error-reporter").length == 0) {
md = $(''+
'
'+
'
'+
''+
'
'+
'
'+
'
'+
'İşlem sırasında bir hata oluştu. Bu hata otomatik olarak tarafımıza rapor edilmiştir. '+
'Ancak yaptığınız işlemle ilgili bizi detaylı olarak bilgilendirseniz size daha etkili bir biçimde yardımcı olabiliriz.'+
'
'+
'
'+
'
'+
'
'+
''+
'
'+
'
'+
'
');
md.find(".btn-danger").click(function() {
smart.getData("system.login/logout", "", null, null);
});
md.find(".btn-warning").click(function() {
var obj = {};
obj.message = $('#smart-error-description').val();
smart.post("core.errorReporting/report", obj, null, function(msg, ctx) {
smart.goBack();
});
});
$("body").append(md);
}
loader.hide();
obj.message = $('#smart-error-description').val('');
smart.showModal($("body"), ".smart-error-reporter");
loader.hide();
},
debug : function(name, arr) {
/********* debug **********/
console.log("/******* "+name+" ********/");
arr.forEach(function(a) {
console.log("/* "+a);
});
console.log("/******* "+name+" ********/");
/********** debug *********/
},
smartCall:false,
smartGoesBack:false,
navig : function(nav) {
smart.smartCall = true;
window.location.href = "#"+nav;
},
validateForm : function(frm) {
var x = frm.validate({
errorPlacement: function(error, element) {
$( element ).parent().append(error);
}
});
x.resetForm();
},
/*
* Smart's new view drawer functions
*/
setState : function(ctx, state) {
ctx.find("*[data-state]").addClass("hidden");
ctx.find("[data-state="+state+"]").removeClass("hidden");
},
clone : function(ctx, selector, fnc) {
var tpl = ctx.find(selector).clone();
tpl.removeAttr("data-template");
tpl.show();
if (fnc != undefined && fnc != null && typeof(fnc)=="function") {
___ = tpl;
fnc.call(undefined);
___ = null;
}
return tpl;
},
find : function(ctx, selector, options) {
var tpl = ctx.find(selector);
smart.___checkEvents(tpl,options);
},
___checkEvents : function(tpl, options) {
___ = tpl;
if (options!= undefined && options != null) {
for (var o in options) {
if (options[o][0] == "attr") {
tpl.find(o).attr(options[o][1], options[o][2]);
} else if (options[o][0] == "val") {
tpl.find(o).val(options[o][1]);
} else if (options[o][0] == "html") {
tpl.find(o).html(options[o][1]);
} else if (options[o][0] == "on") {
var fnc = options[o][2];
tpl.find(o).on(options[o][1], fnc);
} else {
tpl.attr(options[o], options[o][0]);
}
}
}
___ = null;
},
history:[],
historyCurrent : ";", //we need to activate firstView if history is fresh new
historyAdapter : function() {
var l = window.location.href.split("#");
l = l.length > 1 ? l[1] : "";
if (l != smart.historyCurrent) {
var obj = {};
obj.state = l;
obj.smartCall = smart.smartCall;
obj.smartGoesBack = smart.smartGoesBack;
if (l != "smartmodalshown") {
if (l == "") {
smart.createTab(smart._firstView, null, false);
} else {
smart.createTab(l.replace(/,/g, "#"), null, false);
}
}
if (smart.historyCurrent == "smartmodalshown" && smart._isModalShown) {
$(".smart-shown-modal").modal("hide");
}
smart.historyCurrent = l;
}
smart.smartGoesBack = false;
smart.smartCall = false;
setTimeout(smart.historyAdapter, 100);
}
};
var smart = new Smart();
var ___ = null;
function val(a) {
return ["val", a];
}
function html(a) {
return ["html", a];
}
function attr(a, b) {
return ["attr", a,b];
}
function on(a,b) {
return ["on", a, b];
}
function click(a) {
return ["on", "click", a];
}
String.prototype.val = function() {
if (___ != null) {
if (arguments.length == 0) return ___.find(this).val();
else ___.find(this).val(arguments[0]);
return null;
}
}
String.prototype.attr = function() {
if (arguments.length == 1) return ___.find(this).attr(arguments[0]);
else ___.find(this).attr(arguments[0], arguments[1]);
return null;
}
String.prototype.click = function() {
___.find(this).on("click", arguments[0]);
return null;
}
/*
var historyAdapterBound = false;
function bindHistoryAdapter() {
historyAdapterBound = true;
return;
var State = History.getState();
if (smart._data.___cur == undefined) { return; }
var obj = {};
var x = State.hash.split('?')[0].split("#")[0].split("/");
obj.state = x[1];
obj.smartCall = smart.smartCall;
obj.isModalShown = smart._isModalShown;
obj.smartPanelClose = smart.smartPanelClose;
console.log(obj);
document.title = smart.windowTitle;
if (window.location.hash == "#smartmodalshown" && smart.smartCall) {
return;
}
if (smart._isModalShown) {
$(".modal").modal("hide");
}
if (smart.smartPanelClose) {
smart.smartPanelClose = false;
}
/*
if (smart.smartPanelClose) {
var contextHasIT = false;
$(".extTabContent").each(function() {
if (x[1] == $(this).attr("data-view")) {
contextHasIT = true;
}
});
if (!contextHasIT) {
smart.smartPanelClose = true;
window.history.back(-1);
return;
}
smart.smartPanelClose = false;
}
if (x.length < 2 || x[1] == "smartmodalshown" || x[1] == "") {
smart.createTab(smart._firstView, null, true);
return;
}
smart.createTab(x[1].replace(",", "#").replace(",", "#"), null, false);
smart.smartCall = false;
}
*/
//View Prototype
var View = function(name, content) {
this.name = name;
this.content = content;
};
View.prototype = {
name:'',
content : null
};
//Message Prototype
var Message = function(status, content, data) {
this.status = status;
this.content = content;
this.data = data;
};
Message.prototype = {
status : '',
content : '',
data : []
}
//Global Loader Prototype
var Loader = function(loadingDiv) {
this.loadingDiv = $("#"+loadingDiv);
};
Loader.prototype = {
loadingDiv:null,
show : function() { if (this.loadingDiv == null) return; this.loadingDiv.show(); },
hide : function() { if (this.loadingDiv == null) return; this.loadingDiv.hide(); }
};
//DataSource prototype
var DataSource = function(id) {
this.listeners = new Array();
this.id = id;
}
DataSource.prototype = {
rows : [],
compare : function(a, b) {
if (a.name.toLowerCase() === b.name.toLowerCase()) {
return 0;
}
else {
return (a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
}
},
sortByName : function(fnc) {
var l = this.rows.length;
var sorted = this.rows.sort(this.compare);
for (var i=0; i (dropped)
// a backslash followed by any character (including backslash) -> the character
// empty string -> empty string
var formatChr = /\\?(.?)/gi;
var formatChrCb = function (t, s) {
return f[t] ? f[t]() : s;
};
var _pad = function (n, c) {
n = String(n);
while (n.length < c) {
n = '0' + n;
}
return n;
};
f = {
// Day
d: function () { // Day of month w/leading 0; 01..31
return _pad(f.j(), 2);
},
D: function () { // Shorthand day name; Mon...Sun
return f.l()
.slice(0, 3);
},
j: function () { // Day of month; 1..31
return jsdate.getDate();
},
l: function () { // Full day name; Monday...Sunday
return txt_words[f.w()] + 'day';
},
N: function () { // ISO-8601 day of week; 1[Mon]..7[Sun]
return f.w() || 7;
},
S: function () { // Ordinal suffix for day of month; st, nd, rd, th
var j = f.j();
var i = j % 10;
if (i <= 3 && parseInt((j % 100) / 10, 10) == 1) {
i = 0;
}
return ['st', 'nd', 'rd'][i - 1] || 'th';
},
w: function () { // Day of week; 0[Sun]..6[Sat]
return jsdate.getDay();
},
z: function () { // Day of year; 0..365
var a = new Date(f.Y(), f.n() - 1, f.j());
var b = new Date(f.Y(), 0, 1);
return Math.round((a - b) / 864e5);
},
// Week
W: function () { // ISO-8601 week number
var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3);
var b = new Date(a.getFullYear(), 0, 4);
return _pad(1 + Math.round((a - b) / 864e5 / 7), 2);
},
// Month
F: function () { // Full month name; January...December
return txt_words[6 + f.n()];
},
m: function () { // Month w/leading 0; 01...12
return _pad(f.n(), 2);
},
M: function () { // Shorthand month name; Jan...Dec
return f.F()
.slice(0, 3);
},
n: function () { // Month; 1...12
return jsdate.getMonth() + 1;
},
t: function () { // Days in month; 28...31
return (new Date(f.Y(), f.n(), 0))
.getDate();
},
// Year
L: function () { // Is leap year?; 0 or 1
var j = f.Y();
return j % 4 === 0 & j % 100 !== 0 | j % 400 === 0;
},
o: function () { // ISO-8601 year
var n = f.n();
var W = f.W();
var Y = f.Y();
return Y + (n === 12 && W < 9 ? 1 : n === 1 && W > 9 ? -1 : 0);
},
Y: function () { // Full year; e.g. 1980...2010
return jsdate.getFullYear();
},
y: function () { // Last two digits of year; 00...99
return f.Y()
.toString()
.slice(-2);
},
// Time
a: function () { // am or pm
return jsdate.getHours() > 11 ? 'pm' : 'am';
},
A: function () { // AM or PM
return f.a()
.toUpperCase();
},
B: function () { // Swatch Internet time; 000..999
var H = jsdate.getUTCHours() * 36e2;
// Hours
var i = jsdate.getUTCMinutes() * 60;
// Minutes
var s = jsdate.getUTCSeconds(); // Seconds
return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3);
},
g: function () { // 12-Hours; 1..12
return f.G() % 12 || 12;
},
G: function () { // 24-Hours; 0..23
return jsdate.getHours();
},
h: function () { // 12-Hours w/leading 0; 01..12
return _pad(f.g(), 2);
},
H: function () { // 24-Hours w/leading 0; 00..23
return _pad(f.G(), 2);
},
i: function () { // Minutes w/leading 0; 00..59
return _pad(jsdate.getMinutes(), 2);
},
s: function () { // Seconds w/leading 0; 00..59
return _pad(jsdate.getSeconds(), 2);
},
u: function () { // Microseconds; 000000-999000
return _pad(jsdate.getMilliseconds() * 1000, 6);
},
// Timezone
e: function () { // Timezone identifier; e.g. Atlantic/Azores, ...
// The following works, but requires inclusion of the very large
// timezone_abbreviations_list() function.
/* return that.date_default_timezone_get();
*/
throw 'Not supported (see source code of date() for timezone on how to add support)';
},
I: function () { // DST observed?; 0 or 1
// Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC.
// If they are not equal, then DST is observed.
var a = new Date(f.Y(), 0);
// Jan 1
var c = Date.UTC(f.Y(), 0);
// Jan 1 UTC
var b = new Date(f.Y(), 6);
// Jul 1
var d = Date.UTC(f.Y(), 6); // Jul 1 UTC
return ((a - c) !== (b - d)) ? 1 : 0;
},
O: function () { // Difference to GMT in hour format; e.g. +0200
var tzo = jsdate.getTimezoneOffset();
var a = Math.abs(tzo);
return (tzo > 0 ? '-' : '+') + _pad(Math.floor(a / 60) * 100 + a % 60, 4);
},
P: function () { // Difference to GMT w/colon; e.g. +02:00
var O = f.O();
return (O.substr(0, 3) + ':' + O.substr(3, 2));
},
T: function () { // Timezone abbreviation; e.g. EST, MDT, ...
// The following works, but requires inclusion of the very
// large timezone_abbreviations_list() function.
/* var abbr, i, os, _default;
if (!tal.length) {
tal = that.timezone_abbreviations_list();
}
if (that.php_js && that.php_js.default_timezone) {
_default = that.php_js.default_timezone;
for (abbr in tal) {
for (i = 0; i < tal[abbr].length; i++) {
if (tal[abbr][i].timezone_id === _default) {
return abbr.toUpperCase();
}
}
}
}
for (abbr in tal) {
for (i = 0; i < tal[abbr].length; i++) {
os = -jsdate.getTimezoneOffset() * 60;
if (tal[abbr][i].offset === os) {
return abbr.toUpperCase();
}
}
}
*/
return 'UTC';
},
Z: function () { // Timezone offset in seconds (-43200...50400)
return -jsdate.getTimezoneOffset() * 60;
},
// Full Date/Time
c: function () { // ISO-8601 date.
return 'Y-m-d\\TH:i:sP'.replace(formatChr, formatChrCb);
},
r: function () { // RFC 2822
return 'D, d M Y H:i:s O'.replace(formatChr, formatChrCb);
},
U: function () { // Seconds since UNIX epoch
return jsdate / 1000 | 0;
}
};
this.date = function (format, timestamp) {
that = this;
jsdate = (timestamp === undefined ? new Date() : // Not provided
(timestamp instanceof Date) ? new Date(timestamp) : // JS Date()
new Date(timestamp * 1000) // UNIX timestamp (auto-convert to int)
);
return format.replace(formatChr, formatChrCb);
};
return this.date(format, timestamp);
}
};
smart.util = new Util();
//jquery extended functions
;(function($, window, document){
$.fn.formReset = function() {
$(this).find(".select-chosen").val("").trigger("chosen:updated");
$(this).find("input[type=text], textarea, input[type=password], input[type=email], select").val("");
$(this).find("input[type=checkbox]").each(function() {
try { document.getElementById($(this).attr("id")).checked = false; } catch (e) {}
});
$(this).find(".picture-upload").each(function() {
$(this).find("input[type=file]").val("");
$(this).find("input[type=hidden]").val("");
$(this).find("img").attr("src", "lib/images/nopic.jpg");
$(this).find(".progress-bar").css("width", "0%");
$(this).find(".progress-bar").html("0%");
});
}
$.fn.serializeObject = function() {
//Internet Explorer indxOf fix
if(!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) {
return i;
}
}
return -1;
}
}
var form_values = $(this).serializeArray(),
form_final = {};
//fill object with results
$.each(form_values, function(){
if (this.name.substring(0,7) == "ignore-") return;
//Empty assign Null
if(this.value == '') {
form_final[this.name] = null;
//Store Associated Array Input Array
} else if(this.name.match(/\[(.+?)\]/g)){
var arrayName = this.name.match(/\w+[^\[]/g)[0],
propertyName = this.name.match(/\[(.+?)\]/g)[0];
propertyName = propertyName.replace(/(\[|\])/g, "");
if(!form_final.hasOwnProperty(arrayName)){
form_final[arrayName] = new Object();
}
form_final[arrayName][propertyName] = this.value;
// Store Array Input Array
} else if(this.name.indexOf('[]') > 0){
//Remove [] from input name
this.name = this.name.split("[]")[0];
if(form_final.hasOwnProperty(this.name)){
form_final[this.name].push(this.value);
} else {
form_final[this.name] = [this.value]
}
// Store multiple / checkboxes as Array
} else if(form_final.hasOwnProperty(this.name)) {
if(typeof form_final[this.name] != 'object' ){
firstItem = form_final[this.name];
form_final[this.name] = new Object();
form_final[this.name][firstItem] = true;
}
form_final[this.name][this.value] = true;
} else {
form_final[this.name] = this.value;
}
});
//Output Object
return form_final;
}
}(jQuery, window, document));
//Bridge between app and extended functions
var Bridge = function() {};
Bridge.prototype = {
_bridges : [],
_overrides : [],
start : "start",
end : "end",
addHeader : function(id, name, startEnd, fnc) {
this._bridges.push([id, name, startEnd, fnc]);
},
addOverride : function(contextID, entityID, proto, fnc) {
this._overrides.push([contextID, entityID, proto, fnc]);
},
check : function(isStart, obj, fncName, args) {
if (obj.ent == undefined) return;
var state = false;
var se = (isStart) ? this.start : this.end;
this._bridges.forEach(function(a) {
if ((a[0] == obj.ent.id) && (a[2] == se) && (a[1] == fncName)) {
try {
a[3].call(undefined, obj, args);
state = true;
} catch (e) {
smart.throwError([e]);
state = false;
}
}
});
return state;
},
getOverride : function(contextID, entityID) {
var fnc = [];
this._overrides.forEach(function(a) {
if (a[0] == contextID && a[1] == entityID) {
fnc.push([a[2], a[3]]);
}
});
return fnc;
}
};
smart.bridge = new Bridge();