html5forms-rails 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/CHANGELOG.md +5 -0
  2. data/Gemfile +11 -0
  3. data/README.md +208 -0
  4. data/Rakefile +49 -0
  5. data/VERSION +1 -0
  6. data/demos/html5-form-demo.html +79 -0
  7. data/html5forms-rails.gemspec +142 -0
  8. data/lib/html5forms.rb +6 -0
  9. data/vendor/assets/images/colorpicker/blank.gif +0 -0
  10. data/vendor/assets/images/colorpicker/colorpicker_background.png +0 -0
  11. data/vendor/assets/images/colorpicker/colorpicker_hex.png +0 -0
  12. data/vendor/assets/images/colorpicker/colorpicker_hsb_b.png +0 -0
  13. data/vendor/assets/images/colorpicker/colorpicker_hsb_h.png +0 -0
  14. data/vendor/assets/images/colorpicker/colorpicker_hsb_s.png +0 -0
  15. data/vendor/assets/images/colorpicker/colorpicker_indic.gif +0 -0
  16. data/vendor/assets/images/colorpicker/colorpicker_overlay.png +0 -0
  17. data/vendor/assets/images/colorpicker/colorpicker_rgb_b.png +0 -0
  18. data/vendor/assets/images/colorpicker/colorpicker_rgb_g.png +0 -0
  19. data/vendor/assets/images/colorpicker/colorpicker_rgb_r.png +0 -0
  20. data/vendor/assets/images/colorpicker/colorpicker_select.gif +0 -0
  21. data/vendor/assets/images/colorpicker/colorpicker_submit.png +0 -0
  22. data/vendor/assets/images/colorpicker/custom_background.png +0 -0
  23. data/vendor/assets/images/colorpicker/custom_hex.png +0 -0
  24. data/vendor/assets/images/colorpicker/custom_hsb_b.png +0 -0
  25. data/vendor/assets/images/colorpicker/custom_hsb_h.png +0 -0
  26. data/vendor/assets/images/colorpicker/custom_hsb_s.png +0 -0
  27. data/vendor/assets/images/colorpicker/custom_indic.gif +0 -0
  28. data/vendor/assets/images/colorpicker/custom_rgb_b.png +0 -0
  29. data/vendor/assets/images/colorpicker/custom_rgb_g.png +0 -0
  30. data/vendor/assets/images/colorpicker/custom_rgb_r.png +0 -0
  31. data/vendor/assets/images/colorpicker/custom_submit.png +0 -0
  32. data/vendor/assets/images/colorpicker/select.png +0 -0
  33. data/vendor/assets/images/colorpicker/select2.png +0 -0
  34. data/vendor/assets/images/colorpicker/slider.png +0 -0
  35. data/vendor/assets/images/h5f/form_validation.png +0 -0
  36. data/vendor/assets/images/html5form-shim/asterisk.png +0 -0
  37. data/vendor/assets/images/html5form-shim/down.png +0 -0
  38. data/vendor/assets/images/html5form-shim/fail.png +0 -0
  39. data/vendor/assets/images/html5form-shim/ok.png +0 -0
  40. data/vendor/assets/images/html5forms/jscolor/arrow.gif +0 -0
  41. data/vendor/assets/images/html5forms/jscolor/cross.gif +0 -0
  42. data/vendor/assets/images/html5forms/jscolor/hs.png +0 -0
  43. data/vendor/assets/images/html5forms/jscolor/hv.png +0 -0
  44. data/vendor/assets/images/html5forms/slider/slider-1.png +0 -0
  45. data/vendor/assets/images/html5forms/slider/slider-disabled-1.png +0 -0
  46. data/vendor/assets/images/html5forms/slider/slider-disabled.png +0 -0
  47. data/vendor/assets/images/html5forms/slider/slider.png +0 -0
  48. data/vendor/assets/javascripts/colorpicker.js +484 -0
  49. data/vendor/assets/javascripts/colorpicker.min.js +9 -0
  50. data/vendor/assets/javascripts/h5f.js +328 -0
  51. data/vendor/assets/javascripts/h5f.min.js +4 -0
  52. data/vendor/assets/javascripts/html5forms/EventHelpers.min.js +15 -0
  53. data/vendor/assets/javascripts/html5forms/autocomplete.min.js +1 -0
  54. data/vendor/assets/javascripts/html5forms/cssQuery-p.min.js +6 -0
  55. data/vendor/assets/javascripts/html5forms/dev/EventHelpers.js +486 -0
  56. data/vendor/assets/javascripts/html5forms/dev/autocomplete.js +387 -0
  57. data/vendor/assets/javascripts/html5forms/dev/cssQuery-p.js +6 -0
  58. data/vendor/assets/javascripts/html5forms/dev/html5.js +121 -0
  59. data/vendor/assets/javascripts/html5forms/dev/html5Forms.js +892 -0
  60. data/vendor/assets/javascripts/html5forms/dev/html5Widgets.js +1417 -0
  61. data/vendor/assets/javascripts/html5forms/dev/jscolor.js +840 -0
  62. data/vendor/assets/javascripts/html5forms/dev/slider.js +797 -0
  63. data/vendor/assets/javascripts/html5forms/dev/timer.js +137 -0
  64. data/vendor/assets/javascripts/html5forms/dev/visibleIf.js +1100 -0
  65. data/vendor/assets/javascripts/html5forms/html5.min.js +2 -0
  66. data/vendor/assets/javascripts/html5forms/html5Forms.min.js +1 -0
  67. data/vendor/assets/javascripts/html5forms/html5Widgets.min.js +20 -0
  68. data/vendor/assets/javascripts/html5forms/jscolor.min.js +10 -0
  69. data/vendor/assets/javascripts/html5forms/slider.min.js +25 -0
  70. data/vendor/assets/javascripts/html5forms/timer.min.js +1 -0
  71. data/vendor/assets/javascripts/html5forms/visibleIf.min.js +19 -0
  72. data/vendor/assets/javascripts/html5forms.fallback.js +115 -0
  73. data/vendor/assets/javascripts/html5forms.fallback.min.js +11 -0
  74. data/vendor/assets/javascripts/jquery.html5form-shim.js +402 -0
  75. data/vendor/assets/javascripts/jquery.html5form.min.js +4 -0
  76. data/vendor/assets/javascripts/jquery.placehold.min.js +7 -0
  77. data/vendor/assets/javascripts/ui.spinner.js +649 -0
  78. data/vendor/assets/javascripts/ui.spinner.min.js +7 -0
  79. data/vendor/assets/javascripts/webforms2/webforms2-msie.js +1 -0
  80. data/vendor/assets/javascripts/webforms2/webforms2-p.js +14 -0
  81. data/vendor/assets/javascripts/webforms2/webforms2.js +14 -0
  82. data/vendor/assets/javascripts/webforms2/webforms2_src.js +3195 -0
  83. data/vendor/assets/stylesheets/colorpicker.css +161 -0
  84. data/vendor/assets/stylesheets/h5f.css +86 -0
  85. data/vendor/assets/stylesheets/html5form-shim.css +109 -0
  86. data/vendor/assets/stylesheets/html5forms/number.css +35 -0
  87. data/vendor/assets/stylesheets/html5forms/slider.css +169 -0
  88. data/vendor/assets/stylesheets/html5forms/slider_ie.css +41 -0
  89. data/vendor/assets/stylesheets/html5forms/visibleIf.css +23 -0
  90. data/vendor/assets/stylesheets/html5forms.layout.css +116 -0
  91. data/vendor/assets/stylesheets/ui.spinner.css +3 -0
  92. data/vendor/assets/stylesheets/webforms2.css +42 -0
  93. metadata +221 -0
@@ -0,0 +1,2 @@
1
+ // For discussion and comments, see: http://remysharp.com/2009/01/07/html5-enabling-script/
2
+ (function(){if(!0)return;var e="abbr,article,aside,audio,canvas,datalist,details,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','),i=e.length;while(i--){document.createElement(e[i])}})()var html5=new function(){var me=this;me.getAttributeByName=function(obj,attrName){var i;var attributes=obj.attributes;for(i=0;i<attributes.length;i++){var attr=attributes[i]if(attr.nodeName==attrName&&attr.specified){return attr}}return null}me.getAttributeValue=function(obj,attrName){var attr=me.getAttributeByName(obj,attrName);if(attr!=null){return attr.nodeValue}else{return null}}me.setAttributeValue=function(obj,attrName,attrValue){var attr=me.getAttributeByName(obj,attrName);if(attr!=null){attr.nodeValue=attrValue}else{return}}me.getDefinedAttributes=function(obj){var attrs=obj.attributes;var r=new Array();for(var i=0;i<attrs.length;i++){attr=attrs[i];if(attr.specified){r[attr.name]=attr.value}}return r}me.getDataset=function(obj){var r=new Array();var attributes=me.getDefinedAttributes(obj);for(var i=0;i<attributes.length;i++){var attr=attributes[i];if(attr.indexOf('data-')==0){var name=attr.substring(5);r[name]=attr.value}}return r}me.getDatasetItem=function(obj,name){var r=me.getAttributeValue(obj,'data-'+name);if(!r){r=me.getAttributeValue(obj,'data-'+name.toLowerCase())}return r}me.setDatasetItem=function(obj,name,value){var attrName='data-'+name.toLowerCase();var val=me.setAttributeValue(obj,attrName,value);if(me.getAttributeValue(obj,attrName)==null){obj[attrName]=value}}}
@@ -0,0 +1 @@
1
+ var html5Forms=new function(){var me=this;var scriptNode=null,scriptDir=null,isScriptCompressed=false,hasNativeBubbles=navigator.userAgent.indexOf('WebKit')<0||parseInt(navigator.userAgent.match(/AppleWebKit\/([^ ]*)/)[1].split('.')[0])>534,hasBadValidationImplementation=!hasNativeBubbles;var globalEvent=document.addEventListener?document.createEvent("HTMLEvents"):null;function getBrowserLanguage(){var r=navigator.language;if(!r){r=navigator.browserLanguage}return r}me.start=function(){var split=navigator.userAgent.split('Firefox/');if(split.length>=1&&parseFloat(split[1])<=3.6){EventHelpers.addEvent(window,'load',me.init)}else{me.init()}}me.init=function(){var scriptNodes=document.getElementsByTagName('script');for(var i=0;i<scriptNodes.length;i++){scriptNode=scriptNodes[i];if(scriptNode.src.match('html5Forms(_src|-p|)\.js')){scriptNode=scriptNode;scriptDir=getScriptDir();if(scriptNode.src.indexOf('html5Forms-p.js')>=0){isScriptCompressed=true}break}}if(scriptNode){if(window.yepnope){var inputSupport=Modernizr.inputtypes;var supportArray=scriptNode.getAttribute('data-webforms2-support');me.forceJSValidation=(scriptNode.getAttribute('data-webforms2-force-js-validation')=='true');me.turnOffValidation=(scriptNode.getAttribute('data-webforms2-turn-off-validation')=='true');me.forceJSDatePicker=(scriptNode.getAttribute('data-webforms2-force-js-date-picker')=='true');if(!supportArray){return}else if(trim(supportArray)=='all'){supportArray="validation,number,color,date,ouput,range,placeholder"}supportArray=supportArray.split(',');var toLoad=[];var toRunAfterLoad=[];var loadHTML5Widgets=false;for(var i=0;i<supportArray.length;i++){var supportReq=trim(supportArray[i]);switch(supportReq){case"validation":case"autofocus":if(me.turnOffValidation){EventHelpers.addPageLoadEvent('html5Forms.turnOffNativeValidation')}else{if(!Modernizr.input.required||hasBadValidationImplementation||me.forceJSValidation){if(isScriptCompressed){toLoad=toLoad.concat([scriptDir+'../html5forms/weston.ruter.net/webforms2/webforms2-p.js'])}else{toLoad=toLoad.concat([scriptDir+'../html5forms/weston.ruter.net/webforms2/webforms2_src.js'])}if(supportReq=='autofocus'){loadHTML5Widgets=true}}}break;case"number":if(!inputSupport.number){toLoad=toLoad.concat([scriptDir+'../../shared/css/number.css']);loadHTML5Widgets=true}break;case"color":if(!inputSupport.color){toLoad=toLoad.concat([scriptDir+'../html5forms/jscolor/jscolor.js']);loadHTML5Widgets=true}break;case"datetime":case"date":var lang=scriptNode.getAttribute('data-lang');if(!lang||!lang.match(/^(af|al|bg|big5|br|ca|cn|cs|da|de|du|el|en|es|fi|fr|he|hr|hu|it|jp|ko|ko|lt|lt|lv|nl|no|pl|pl|pt|ro|ru|si|sk|sp|sv|tr|zh)$/)){lang=getBrowserLanguage().split('-')[0]}if(!inputSupport.date||me.forceJSDatePicker){toLoad=toLoad.concat([scriptDir+'../html5forms/jscalendar-1.0/calendar-win2k-1.css',scriptDir+'../html5forms/jscalendar-1.0/calendar.js',scriptDir+'../html5forms/jscalendar-1.0/lang/calendar-'+lang+'.js',scriptDir+'../html5forms/jscalendar-1.0/calendar-setup.js']);loadHTML5Widgets=true}break;case"output":if(!supportsOutput()){loadHTML5Widgets=true}break;case"range":if(!inputSupport.range){toLoad=toLoad.concat([scriptDir+'../../shared/css/slider.css',scriptDir+'../html5forms/frequency-decoder.com/slider.js']);loadHTML5Widgets=true;toRunAfterLoad.push('fdSliderController.redrawAll')}break;case"placeholder":case"autofocus":if(!Modernizr.input[supportReq]){loadHTML5Widgets=true}}}if(toLoad.length==0){loadWidgets();if(document.addEventListener){document.addEventListener('DOMContentLoaded',setupExtraFeatures,false)}}else{yepnope({load:toLoad,complete:function(){loadWidgets();setupExtraFeatures()}})}}}function loadWidgets(){yepnope({test:loadHTML5Widgets,yep:scriptDir+'../html5forms/html5Widgets.js',complete:function(){if(loadHTML5Widgets){for(var i=0;i<toRunAfterLoad.length;i++){eval(toRunAfterLoad[i]+'()')}EventHelpers.init();html5Widgets.init()}}})}function setupExtraFeatures(){var nodeNames=["input","select","textarea"];for(var i=0;i<nodeNames.length;i++){var nodes=document.getElementsByTagName(nodeNames[i]);for(var j=0;j<nodes.length;j++){var node=nodes[j];setErrorMessageEvents(node);setCustomClassesEvents(node);setNodeClasses(node,true)}if(i==0&&node.type=="submit"){EventHelpers.addEvent(node,'click',submitClickEvent)}}var forms=document.getElementsByTagName('form');for(var i=0;i<forms.length;i++){EventHelpers.addEvent(forms[i],'submit',submitEvent);EventHelpers.addEvent(forms[i],'reset',resetEvent)}}function submitEvent(e){var target=EventHelpers.getEventTarget(e);markSubmitAttempt(target)}function resetEvent(e){var target=EventHelpers.getEventTarget(e);resetForm(target)}function submitClickEvent(e){var target=EventHelpers.getEventTarget(e);markSubmitAttempt(target.form)}function markSubmitAttempt(form){me.css.addClass(form,'wf2_submitAttempted')}function removeSubmitAttempt(form){me.css.removeClass(form,'wf2_submitAttempted')}function resetForm(form){removeSubmitAttempt(form);var nodeNames=["input","select","textarea"];for(var i=0;i<nodeNames.length;i++){var nodes=form.getElementsByTagName(nodeNames[i]);for(var j=0;j<nodes.length;j++){var node=nodes[j];me.css.removeClass(node,'wf2_lostFocus');me.css.removeClass(node,'wf2_notBlank');me.css.addClass(node,'wf2_isBlank')}}}function setCustomClassesEvents(node){EventHelpers.addEvent(node,'keyup',nodeChangeEvent);EventHelpers.addEvent(node,'change',nodeChangeEvent);EventHelpers.addEvent(node,'blur',nodeBlurEvent)}function nodeChangeEvent(e){var node=EventHelpers.getEventTarget(e);setNodeClasses(node)}function setNodeClasses(node,isLoadEvent){if(node.value===''){me.css.addClass(node,'wf2_isBlank');me.css.removeClass(node,'wf2_notBlank')}else{me.css.addClass(node,'wf2_notBlank');me.css.removeClass(node,'wf2_isBlank')}if(isLoadEvent&&node.nodeName=='SELECT'){node.setAttribute('data-wf2-initialvalue',node.value)}if((node.nodeName=='SELECT'&&me.getAttributeValue(node,'data-wf2-initialvalue')!=node.value)||(node.nodeName!='SELECT'&&me.getAttributeValue(node,'value')!=node.value)){me.css.removeClass(node,'wf2_defaultValue');me.css.addClass(node,'wf2_notDefaultValue')}else{me.css.addClass(node,'wf2_defaultValue');me.css.removeClass(node,'wf2_notDefaultValue')}}function nodeBlurEvent(e){var node=EventHelpers.getEventTarget(e);me.css.addClass(node,'wf2_lostFocus')}function setErrorMessageEvents(node){var message=me.getAttributeValue(node,'data-errormessage');if(message){if(document.addEventListener){node.addEventListener('invalid',showCustomMessageEvent,false);node.addEventListener('focus',showCustomMessageEvent,false);if(!window.opera){node.addEventListener('keypress',clearMessageIfValidEvent,false)}node.addEventListener('input',clearMessageIfValidEvent,false);if(node.nodeName=='SELECT'){node.addEventListener('change',clearMessageIfValidEvent,false);node.addEventListener('click',clearMessageIfValidEvent,false)}}else{var invalidEvent=' this.setCustomValidity("'+message+'");';if(node.oninvalid){node.oninvalid+=invalidEvent}else{node.oninvalid=invalidEvent}node.oninvalid=new Function('event',node.oninvalid);node.attachEvent('onkeydown',clearMessageIfValidEvent);node.attachEvent('oninput',clearMessageIfValidEvent);if(node.nodeName=='SELECT'){node.attachEvent('change',clearMessageIfValidEvent,false);node.attachEvent('click',clearMessageIfValidEvent,false)}}clearMessageIfValid(node)}}function showCustomMessageEvent(event){var node=event.currentTarget||event.srcElement;showCustomMessage(node)}function showCustomMessage(node){if(node.validity.valid){return}var message=me.getAttributeValue(node,'data-errormessage');node.setCustomValidity(message)}function clearMessageIfValidEvent(event){var node=event.currentTarget||event.srcElement;clearMessageIfValid(node)}function clearMessageIfValid(node){if(!node.setCustomValidity){return}node.setCustomValidity('');if(!node.checkValidity()){showCustomMessage(node);if(document.addEventListener){globalEvent.initEvent('invalid',true,true);node.dispatchEvent(globalEvent)}}else{}}}me.turnOffNativeValidation=function(){var formNodes=document.getElementsByTagName('form');for(var i=0;i<formNodes.length;i++){formNodes[i].setAttribute('novalidate','novalidate')}}var supportsOutput=function(){var outputEl=document.createElement('output');return(outputEl.value!=undefined&&(outputEl.onforminput!==undefined||outputEl.oninput!==undefined))}var getScriptDir=function(){var arr=scriptNode.src.split('/');arr.pop();return arr.join('/')+'/'}me.getAttributeByName=function(obj,attrName){var i;var attributes=obj.attributes;for(var i=0;i<attributes.length;i++){var attr=attributes[i]if(attr.nodeName==attrName&&attr.specified){return attr}}return null}me.getAttributeValue=function(obj,attrName){var attr=me.getAttributeByName(obj,attrName);if(attr!=null){return attr.nodeValue}else{return null}}var initWhitespaceRe=/^\s\s*/;var endWhitespaceRe=/\s\s*$/;function trim(str){return str.replace(initWhitespaceRe,'').replace(endWhitespaceRe,'')}me.css=new function(){var me=this;var blankRe=new RegExp('\\s');function getClassReString(className){return'\\s'+className+'\\s|^'+className+'\\s|\\s'+className+'$|'+'^'+className+'$'}function getClassPrefixReString(className){return'\\s'+className+'-[0-9a-zA-Z_]+\\s|^'+className+'[0-9a-zA-Z_]+\\s|\\s'+className+'[0-9a-zA-Z_]+$|'+'^'+className+'[0-9a-zA-Z_]+$'}me.addClass=function(obj,className){if(blankRe.test(className)){return}if(!me.isMemberOfClass(obj,className)){obj.className+=" "+className}}me.removeClass=function(obj,className){if(blankRe.test(className)){return}var re=new RegExp(getClassReString(className),"g");var oldClassName=obj.className;if(obj.className){obj.className=oldClassName.replace(re,' ')}}me.isMemberOfClass=function(obj,className){if(blankRe.test(className))return false;var re=new RegExp(getClassReString(className),"g");return(re.test(obj.className))}}}var EventHelpers=new function(){var me=this;var safariTimer;var isSafari=/WebKit/i.test(navigator.userAgent);var isIEPolling=false;var globalEvent;var safariVer=navigator.userAgent.match(/Version\/([^\s]*)/);if(safariVer!=null&&safariVer.length==2){safariVer=parseFloat(safariVer[1])}me.init=function(){if(me.hasPageLoadHappened(arguments)){return}if(document.createEvent){globalEvent=document.createEvent("HTMLEvents")}else if(document.createEventObject){globalEvent=document.createEventObject()}me.docIsLoaded=true}me.addEvent=function(obj,evType,fn){if(obj.addEventListener){obj.addEventListener(evType,fn,false)}else if(obj.attachEvent){obj['e'+evType+fn]=fn;obj[evType+fn]=function(){obj["e"+evType+fn](self.event)}obj.attachEvent("on"+evType,obj[evType+fn])}}me.removeEvent=function(obj,evType,fn){if(obj.removeEventListener){obj.removeEventListener(evType,fn,false)}else if(obj.detachEvent){try{obj.detachEvent("on"+evType,obj[evType+fn]);obj[evType+fn]=null;obj["e"+evType+fn]=null}catch(ex){}}}me.getEventTarget=function(e){if(e.toElement){return e.toElement}else if(e.currentTarget){return e.currentTarget}else if(e.srcElement){return e.srcElement}else{return null}}me.getKey=function(e){if(e.keyCode){return e.keyCode}else if(e.event&&e.event.keyCode){return window.event.keyCode}else if(e.which){return e.which}}function mylog(s){if(window.console&&window.console.log){console.log(s)}}me.addPageLoadEvent=function(funcName,timerForIE){var func=eval(funcName);if(!isIEPolling&&/loaded|complete|interactive/.test(document.readyState)){mylog('execute immediately')func();return}if((isSafari&&safariVer<3.1)||isIEPolling){mylog('polling')pageLoadEventArray.push(func);if(!safariTimer){safariTimer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(safariTimer);me.runPageLoadEvents();return}set=true},10)}}else if(document.addEventListener){document.addEventListener("DOMContentLoaded",func,null);mylog("DOMContentLoaded "+document.readyState)}else{mylog('window.load')me.addEvent(window,'load',func)}}var pageLoadEventArray=new Array();me.runPageLoadEvents=function(e){if(isSafari||isIEPolling||e.srcElement.readyState=="complete"){for(var i=0;i<pageLoadEventArray.length;i++){pageLoadEventArray[i]()}}}me.hasPageLoadHappened=function(funcArgs){if(funcArgs.callee.done)return true;funcArgs.callee.done=true}me.preventDefault=function(e){if(e.preventDefault){e.preventDefault()}try{e.returnValue=false}catch(ex){}}me.fireEvent=function(element,event,options){if(!element){return}if(element.dispatchEvent){globalEvent.initEvent(event,true,true);return!element.dispatchEvent(globalEvent)}else if(document.createEventObject){return element.fireEvent('on'+event,globalEvent)}else{return false}}me.isSupported=function(eventName,nodeName){var el=document.createElement(nodeName);eventName='on'+eventName;var isSupported=(eventName in el);if(!isSupported){el.setAttribute(eventName,'return;');isSupported=typeof el[eventName]=='function'}el=null;return isSupported}function init(){}if(!window.html5Forms){init()}}html5Forms.start();
@@ -0,0 +1,20 @@
1
+ /*******************************************************************************
2
+ * This notice must be untouched at all times.
3
+ *
4
+ * This javascript library contains helper routines to assist with event
5
+ * handling consinstently among browsers
6
+ *
7
+ * html5Widgets.js v.1.1 by Zoltan Hawryluk
8
+ * latest version and documentation available at http://www.useragentman.com/
9
+ *
10
+ * Changelog:
11
+ * version 1.0: initial release
12
+ * version 1.1: implemented oninput method for form elements for unsupported browsers
13
+ * fix IE9 to ensure backspace and delete keys fire an oninput event.
14
+ * version 1.2: Added Number Element Widget
15
+ *
16
+ * released under the MIT License:
17
+ * http://www.opensource.org/licenses/mit-license.php
18
+ *
19
+ *******************************************************************************/
20
+ var html5Widgets=new function(){var me=this;var delayEventTimeout=null;me.inputNodes=new Array();me.outputNodes=new Array();me.formElements=null;me.placeholderNodes=new Array();me.dummyLink=document.createElement('input');var quoteRe=/\"/g;var dummyIDCount=0;var supportsNatively=new Object();var isBadChrome=navigator.userAgent.indexOf('Chrome');var valueRe=/this\.value/g;var varRe=/([a-zA-Z][a-zA-Z0-9]*\.value)/g;var isDebug;var isIE9=false;me.init=function(){if(EventHelpers.hasPageLoadHappened(arguments)){return}supportsNatively['oninput']=EventHelpers.isSupported('input','form');isDebug=CSSHelpers.isMemberOfClass(document.body,'html5Widgets-debug')me.type='text'me.dummyLink.style.position='absolute';me.dummyLink.style.top='-200px';document.body.appendChild(me.dummyLink)var inputSupport=Modernizr.input if(!inputSupport['placeholder']){setPlaceholders()}indexOutputNodes();insertElements();me.resolveOutputs()}function supports_input_placeholder(){var i=document.createElement('input');return'placeholder'in i}function setPlaceholders(){var nodes=[document.getElementsByTagName('input'),document.getElementsByTagName('textarea')];for(var i=0;i<nodes.length;i++){for(var j=0;j<nodes[i].length;j++){var node=nodes[i][j];if(DOMHelpers.getAttributeValue(node,'placeholder')){me.placeholderNodes.push(new PlaceholderInput(node))}}}}function getNextDummyID(){dummyIDCount++;return"id"+dummyIDCount}function indexOutputNodes(){var outputElements=document.getElementsByTagName('output');for(var i=0;i<outputElements.length;i++){var outputEl=outputElements[i];if(outputEl.value!=undefined&&outputEl.onforminput!=undefined){supportsNatively["output"]=true;break}me.outputNodes.push(new OutputElement(outputEl))}me.formElements=document.getElementsByTagName('form')}function setOutputEvents(nodeName){var formElements=document.getElementsByTagName(nodeName);for(var i=0;i<formElements.length;i++){var formElement=formElements[i];EventHelpers.addEvent(formElement,'change',me.resolveOutputs);EventHelpers.addEvent(formElement,'keyup',me.resolveOutputs);EventHelpers.addEvent(formElement,'cut',me.resolveOutputs)}}function insertElements(){var inputSupport=Modernizr.inputtypes;if(window.fdSliderController){fdSliderController.removeOnLoadEvent()}var formElementTypes=["input","select","textarea"];for(var i=0;i<formElementTypes.length;i++){setOutputEvents(formElementTypes[i])}var formElements=document.getElementsByTagName('input');if(formElements.length<=0){return}for(var i=0;i<formElements.length;i++){var formElement=formElements[i];var elType=DOMHelpers.getAttributeValue(formElement,'type');if(!formElement.name){formElement.name=getNextDummyID()}switch(elType){case"range":if(!inputSupport.range){me.inputNodes.push(new RangeElement(formElement))}break;case"date":case"week":case"month":case"datetime":case"datetime-local":if(!inputSupport[elType]||(window.html5Forms&&html5Forms.forceJSDatePicker)){me.inputNodes.push(new CalendarElement(formElement,elType))}break;case"color":if(!inputSupport.color||isBadChrome){me.inputNodes.push(new ColorElement(formElement,elType))}break;case"number":if(!inputSupport.number){me.inputNodes.push(new NumberElement(formElement,elType))}break}}if(window.fdSliderController){fdSliderController.redrawAll()}if(window.jscolor){jscolor.init()}}function delayedFireEvent(el,ev,callback){if(!document.createEventObject){me.fireEvent(el,ev);if(callback){callback()}}else{if(delayEventTimeout!=null){clearTimeout(delayEventTimeout)}delayEventTimeout=setTimeout(function(){EventHelpers.fireEvent(el,ev);if(callback){callback()}},1)}}me.fireEvent=function(el,ev){EventHelpers.fireEvent(el,ev)}me.resolveOutputs=function(e){for(var i=0;i<me.outputNodes.length;i++){var outputNode=me.outputNodes[i];outputNode.resolve()}if(!supportsNatively['oninput']){for(var i=0;i<me.formElements.length;i++){var formNode=me.formElements[i];var oninput=DOMHelpers.getAttributeValue(formNode,'oninput');if(oninput){eval(me.getValueFormula(oninput,formNode))}}}else if(isIE9&&e){var input=EventHelpers.getEventTarget(e);switch(e.type){case"keyup":var key=EventHelpers.getKey(e);switch(key){case 8:case 46:case 88:EventHelpers.fireEvent(input.form,'input')}break;case"cut":delayedFireEvent(input.form,'input');break}}}me.hideInput=function(node){node.style.position='absolute';node.style.top='-1000px';node.style.left='-1000px';node.style.visibility='hidden'}me.getValueFormula=function(expr,parentForm){var formula=expr if(formula==null){return null}formula=formula.replace(valueRe,'value').replace(varRe,'document.forms["'+parentForm.id+'"].$1');return formula}function showError(err){if(isDebug){alert(err)}throw(err)}function RangeElement(node){var me=this,parentForm,hasFiredChangeEvent=false;me.node=node;me.sliderNode=null;function init(){parentForm=DOMHelpers.getAncestorByTagName(node,'form');var min=parseFloat(DOMHelpers.getAttributeValue(me.node,'min'));var max=parseFloat(DOMHelpers.getAttributeValue(me.node,'max'));if(!window.fdSliderController){showError("slider.js must be included in order for the range element to work in this browser. See documentation for more details.")}if(isNaN(min)){min=0}if(isNaN(max)){max=100}var step=DOMHelpers.getAttributeValue(me.node,'step');if(step==null){step="1"}else if(typeof(step)=='number'){step=step+""}if(!me.node.id){me.node.id="HTML5Form-slider"+getNextDummyID()}var options={inp:me.node,inc:step,maxInc:step,range:[min,max],callbacks:{"update":[me.changeEvent]},classNames:"html5Widgets-slider fd_jump",tween:false,vertical:false,hideInput:false,clickJump:true,fullARIA:false,noMouseWheel:false};fdSliderController.createSlider(options);me.sliderNode=document.getElementById('fd-slider-'+me.node.id);me.sliderNode.style.width=me.node.offsetWidth+"px";elDisplay=me.node.style.display if(elDisplay!='block'){me.sliderNode.style.display='inline-block'}html5Widgets.hideInput(me.node);document.getElementById('fd-slider-'+me.node.id).style.zIndex='0';me.node.tabIndex="-1";me.node.type="text";EventHelpers.addEvent(me.node,'change',changeOriginalNodeEvent)}me.changeEvent=function(e){var oninput=DOMHelpers.getAttributeValue(parentForm,'oninput');if(oninput){eval(html5Widgets.getValueFormula(oninput,parentForm))}if(!hasFiredChangeEvent){hasFiredChangeEvent=true;delayedFireEvent(me.node,'change',function(){hasFiredChangeEvent=false})}}function changeOriginalNodeEvent(e){fdSliderController.updateSlider(me.node.id)}init()}function CalendarElement(node,type){var me=this;me.node=node;me.type=type;var badDateTimeValueRe=/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}Z{0,1}$/;var displayDateTimeValueRe=/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$/;var originalVisibilityState;function init(){if(!window.Calendar&&isDebug){showError("jscalendar scripts and CSS must be included for date and time form elements to work. See documentation for more details. ")}if(!me.node.id){me.node.id="HTML5Form-calendar"+getNextDummyID()}prepareForDisplay();var formatString="";switch(me.type){case'date':formatString="%Y-%m-%d";break;case'month':formatString="%Y-%m";break;case'week':formatString="%Y-W%W";break;case'datetime':placeUTCInfo();case'datetime-local':case'datetime':formatString="%Y-%m-%d %H:%M"break}me.node.type='text';Calendar.setup({eventName:"click",showsTime:type.indexOf('time')>=0,cache:true,inputField:me.node.id,ifFormat:formatString,button:me.node.id});EventHelpers.addEvent(me.node,'click',forceCalToTop);EventHelpers.addEvent(me.node,'focus',focusEvent)EventHelpers.addEvent(me.node,'keypress',openCalendar);EventHelpers.addEvent(me.node,'blur',closeCalendar);EventHelpers.addEvent(me.node,'keypress',keydownEvent)if(window.$wf2){$wf2.callBeforeValidation.push(prepareForSubmission);$wf2.callAfterValidation.push(validationEvent)}}function placeUTCInfo(){var label=document.createElement('span');label.innerHTML="UTC";label.style.paddingLeft="5px";DOMHelpers.insertAfter(me.node,label);var width=label.offsetWidth;me.node.style.width=(me.node.offsetWidth-5-width)+'px'}function prepareForSubmission(){var splitVals;switch(me.type){case"datetime":case"datetime-local":originalVisibilityState=me.node.style.visibility;me.node.style.visibility='hidden';if(me.node.value.match(displayDateTimeValueRe)){splitVals=me.node.value.split(' ');me.node.value=splitVals[0]+"T"+splitVals[1]}switch(me.type){case"datetime-local":break;case"datetime":if(me.node.value!=""){me.node.value+="Z"}}}}function prepareForDisplay(){switch(me.type){case"datetime":case"datetime-local":if(me.node.value.match(badDateTimeValueRe)){me.node.value=me.node.value.replace(/T/,' ').replace(/Z/,'')}if(originalVisibilityState!=null){me.node.style.visibility=originalVisibilityState}}}function validationEvent(e,hasValidated){if(!hasValidated){prepareForDisplay()}}function forceCalToTop(e){var cal=window.calendar;cal.element.style.zIndex=100}function focusEvent(e){var el=EventHelpers.getEventTarget(e);EventHelpers.fireEvent(el,'click')}function openCalendar(e){var cal=window.calendar;cal.element.style.zIndex=100;if(cal.open!=undefined){cal.open()}}function closeCalendar(e){var cal=window.calendar;if(cal){cal.hide()}}function keydownEvent(e){var c=EventHelpers.getKey(e);switch(c){case 13:html5Widgets.dummyLink.focus();this.focus();EventHelpers.preventDefault(e);openCalendar(e);break;case 9:closeCalendar(e);break;default:EventHelpers.preventDefault(e);break}}function submitEvent(e){prepareForSubmission()}init()}function OutputElement(node){var me=this;me.node=node;var value;var valueFormula;var parentForm;function init(){parentForm=DOMHelpers.getAncestorByTagName(node,'form');if(!parentForm.id){parentForm.id=getNextDummyID()}valueFormula=html5Widgets.getValueFormula(DOMHelpers.getAttributeValue(me.node,'onforminput'),parentForm)}me.resolve=function(){if(valueFormula==null){return}else{eval(valueFormula);me.node.innerHTML=value;me.node.value=value}}init()}function ColorElement(node){var me=this;me.node=node;function init(){if(!window.jscolor){showError('jscolor script must be included in order for the color input type to work in this browser. See documentation for more details.')}CSSHelpers.addClass(me.node,'color');CSSHelpers.addClass(me.node,'{hash:true,caps:false}');me.node.type="text"}init()}function NumberElement(node){var me=this,min=parseFloat(DOMHelpers.getAttributeValue(node,'min')),max=parseFloat(DOMHelpers.getAttributeValue(node,'max')),step=parseFloat(DOMHelpers.getAttributeValue(node,'step'));me.node=node;if(isNaN(step)){return}EventHelpers.addEvent(node,'keyup',keyUpEvent);function keyUpEvent(){if(isNumeric(this.value)){}else if(this.value!=''){var val=parseFloat(this.value);if(isNaN(val)){this.value=''}else{this.value=val}}}function nearestValid(value,direction){var n=(value-min)/step,r;if(n==parseInt(n)){r=value}else{if(direction<0){n=Math.floor(n+1)}else{n=Math.ceil(n-1)}r=min+step*n}if(r>max){r-=step}else if(r<min){r+=step}return r}function buttonMouseDownEvent(e){var buttonType=this.className;var stepMult=step;if(buttonType=='dnbutton'){stepMult=-step}var min=this.min;var max=this.max;if((stepMult<0&&(node.value>min||isNaN(min)))||(stepMult>0&&(node.value<max||isNaN(max)))){setValue(me.node,nearestValid(parseFloat(node.value)+stepMult,stepMult))}var delayedOnce=false;var date=new Date();var curDate=null;this.interval=setInterval(function(){if(!delayedOnce){curDate=new Date();if(curDate-date>500)delayedOnce=true}else if((stepMult<0&&(node.value>min||isNaN(min)))||(stepMult>0&&(node.value<max||isNaN(max)))){setValue(me.node,nearestValid(parseFloat(node.value)+stepMult,stepMult))}},50);EventHelpers.preventDefault(e)}function setValue(node,value){if(isNaN(value)){node.value=''}else{node.value=value}}function buttonClickEvent(e){clearInterval(this.interval);EventHelpers.preventDefault(e)}function buttonMouseUpEvent(e){clearInterval(this.interval);EventHelpers.preventDefault(e)}function isNumeric(n){return!isNaN(parseFloat(n))&&isFinite(n)}function hasNativeSpinner(){try{return window.getComputedStyle(me.node,'-webkit-inner-spin-button').WebkitAppearance!=undefined}catch(ex){return false}}function init(){var upbutton=document.createElement('a');upbutton.className='upbutton';upbutton.appendChild(document.createTextNode("\u25B2"));upbutton.targInput=node;upbutton.max=max;var dnbutton=document.createElement('a');dnbutton.className='dnbutton';dnbutton.appendChild(document.createTextNode("\u25BC"));dnbutton.targInput=node;dnbutton.min=min;dnbutton.max=max;EventHelpers.addEvent(upbutton,'mousedown',buttonMouseDownEvent);EventHelpers.addEvent(dnbutton,'mousedown',buttonMouseDownEvent);EventHelpers.addEvent(upbutton,'click',buttonClickEvent);EventHelpers.addEvent(upbutton,'mouseup',buttonMouseUpEvent);EventHelpers.addEvent(dnbutton,'click',buttonClickEvent);EventHelpers.addEvent(dnbutton,'mouseup',buttonMouseUpEvent);if(!hasNativeSpinner()){var controlsNode=document.createElement('div');controlsNode.className='html5-numberControls';controlsNode.appendChild(upbutton);controlsNode.appendChild(dnbutton);var wrapperNode=document.createElement('div')wrapperNode.className='html5-numberWrapper';wrapperNode.appendChild(controlsNode);var parentNode=node.parentNode;parentNode.insertBefore(wrapperNode,node);var nodeWidth=node.offsetWidth;var nodeStyle=CSSHelpers.getCurrentStyle(node);node.style.width=(nodeWidth-upbutton.offsetWidth-9)+'px';wrapperNode.style.width=nodeWidth+'px';wrapperNode.style.marginTop=nodeStyle.marginTop;wrapperNode.style.height=(node.offsetHeight)+'px'}}init()}function PlaceholderInput(node){var me=this;me.node=node;var form,defaultText;function init(){defaultText=DOMHelpers.getAttributeValue(node,'placeholder');form=DOMHelpers.getAncestorByTagName(node,'form');me.setPlaceholderText(true);EventHelpers.addEvent(me.node,'blur',blurEvent);EventHelpers.addEvent(me.node,'focus',focusEvent);if(me.node.form){EventHelpers.addEvent(me.node.form,'submit',removePlaceholderText)}if(window.$wf2){if($wf2.callBeforeValidation!=undefined){$wf2.callBeforeValidation.push(removePlaceholderText)}if($wf2.callAfterValidation!=undefined){$wf2.callAfterValidation.push(postValidationEvent)}}}me.setPlaceholderText=function(isLoadEvent){var isAutofocus=DOMHelpers.getAttributeValue(me.node,'autofocus')!=null;if(me.node.value==""||(isLoadEvent&&me.node.value==defaultText)){CSSHelpers.addClass(me.node,'html5-hasPlaceholderText');me.node.value=defaultText}if(isLoadEvent&&isAutofocus&&me.node.value==defaultText){CSSHelpers.removeClass(me.node,'html5-hasPlaceholderText');me.node.value=''}}function focusEvent(e){CSSHelpers.addClass(me.node,'html5-hasFocus');removePlaceholderText()}function blurEvent(e){CSSHelpers.removeClass(me.node,'html5-hasFocus');me.setPlaceholderText()}function removePlaceholderText(){if(CSSHelpers.isMemberOfClass(me.node,'html5-hasPlaceholderText')){me.node.value="";CSSHelpers.removeClass(me.node,'html5-hasPlaceholderText')}}function postValidationEvent(e,didValidate){if(!didValidate&&!CSSHelpers.isMemberOfClass(me.node,'html5-hasFocus')){me.setPlaceholderText()}}init()}var CSSHelpers=new function(){var me=this;var blankRe=new RegExp('\\s');function getClassReString(className){return'\\s'+className+'\\s|^'+className+'\\s|\\s'+className+'$|'+'^'+className+'$'}function getClassPrefixReString(className){return'\\s'+className+'-[0-9a-zA-Z_]+\\s|^'+className+'[0-9a-zA-Z_]+\\s|\\s'+className+'[0-9a-zA-Z_]+$|'+'^'+className+'[0-9a-zA-Z_]+$'}me.addClass=function(obj,className){if(blankRe.test(className)){return}if(!me.isMemberOfClass(obj,className)){obj.className+=" "+className}}me.removeClass=function(obj,className){if(blankRe.test(className)){return}var re=new RegExp(getClassReString(className),"g");var oldClassName=obj.className;if(obj.className){obj.className=oldClassName.replace(re,' ')}}me.isMemberOfClass=function(obj,className){if(blankRe.test(className))return false;var re=new RegExp(getClassReString(className),"g");return(re.test(obj.className))}me.getCurrentStyle=function(obj){var computedStyle;if(typeof obj.currentStyle!='undefined'){computedStyle=obj.currentStyle}else{computedStyle=document.defaultView.getComputedStyle(obj,null)}return computedStyle}}var DOMHelpers=new function(){var me=this;me.getAttributeByName=function(obj,attrName){var i;var attributes=obj.attributes;for(i=0;i<attributes.length;i++){var attr=attributes[i]if(attr.nodeName==attrName&&attr.specified){return attr}}return null}me.getAttributeValue=function(obj,attrName){var attr=me.getAttributeByName(obj,attrName);if(attr!=null){return attr.nodeValue}else{var typeRe=new RegExp(attrName+'=(\\"([a-zA-Z\-]*)\\"|[a-zA-Z\-]*)');var typeVal=XMLHelpers.getOuterXML(obj).split('>')[0].match(typeRe);if(typeVal&&typeVal.length>=1){return typeVal[1].replace(quoteRe,'')}else{return null}}}me.insertAfter=function(refNode,nodeToInsert){var parent=refNode.parentNode;var nextSibling=refNode.nextSibling;if(nextSibling){parent.insertBefore(nodeToInsert,nextSibling)}else{parent.appendChild(nodeToInsert)}}me.getAncestorByTagName=function(obj,tagName){for(var node=obj.parentNode;node.nodeName.toLowerCase()!='body';node=node.parentNode){if(tagName.toLowerCase()==node.nodeName.toLowerCase()){return node}}return null}me.removeNode=function(node){var parentNode=node.parentNode;if(parentNode){parentNode.removeChild(node)}}}var StringHelpers=new function(){var me=this;me.sprintf=function(fstring){var pad=function(str,ch,len){var ps='';for(var i=0;i<Math.abs(len);i++)ps+=ch;return len>0?str+ps:ps+str}var processFlags=function(flags,width,rs,arg){var pn=function(flags,arg,rs){if(arg>=0){if(flags.indexOf(' ')>=0)rs=' '+rs;else if(flags.indexOf('+')>=0)rs='+'+rs}else rs='-'+rs;return rs}var iWidth=parseInt(width,10);if(width.charAt(0)=='0'){var ec=0;if(flags.indexOf(' ')>=0||flags.indexOf('+')>=0)ec++;if(rs.length<(iWidth-ec))rs=pad(rs,'0',rs.length-(iWidth-ec));return pn(flags,arg,rs)}rs=pn(flags,arg,rs);if(rs.length<iWidth){if(flags.indexOf('-')<0)rs=pad(rs,' ',rs.length-iWidth);else rs=pad(rs,' ',iWidth-rs.length)}return rs}var converters=new Array();converters['c']=function(flags,width,precision,arg){if(typeof(arg)=='number')return String.fromCharCode(arg);if(typeof(arg)=='string')return arg.charAt(0);return''}converters['d']=function(flags,width,precision,arg){return converters['i'](flags,width,precision,arg)}converters['u']=function(flags,width,precision,arg){return converters['i'](flags,width,precision,Math.abs(arg))}converters['i']=function(flags,width,precision,arg){var iPrecision=parseInt(precision);var rs=((Math.abs(arg)).toString().split('.'))[0];if(rs.length<iPrecision)rs=pad(rs,' ',iPrecision-rs.length);return processFlags(flags,width,rs,arg)}converters['E']=function(flags,width,precision,arg){return(converters['e'](flags,width,precision,arg)).toUpperCase()}converters['e']=function(flags,width,precision,arg){iPrecision=parseInt(precision);if(isNaN(iPrecision))iPrecision=6;rs=(Math.abs(arg)).toExponential(iPrecision);if(rs.indexOf('.')<0&&flags.indexOf('#')>=0)rs=rs.replace(/^(.*)(e.*)$/,'$1.$2');return processFlags(flags,width,rs,arg)}converters['f']=function(flags,width,precision,arg){iPrecision=parseInt(precision);if(isNaN(iPrecision))iPrecision=6;rs=(Math.abs(arg)).toFixed(iPrecision);if(rs.indexOf('.')<0&&flags.indexOf('#')>=0)rs=rs+'.';return processFlags(flags,width,rs,arg)}converters['G']=function(flags,width,precision,arg){return(converters['g'](flags,width,precision,arg)).toUpperCase()}converters['g']=function(flags,width,precision,arg){iPrecision=parseInt(precision);absArg=Math.abs(arg);rse=absArg.toExponential();rsf=absArg.toFixed(6);if(!isNaN(iPrecision)){rsep=absArg.toExponential(iPrecision);rse=rsep.length<rse.length?rsep:rse;rsfp=absArg.toFixed(iPrecision);rsf=rsfp.length<rsf.length?rsfp:rsf}if(rse.indexOf('.')<0&&flags.indexOf('#')>=0)rse=rse.replace(/^(.*)(e.*)$/,'$1.$2');if(rsf.indexOf('.')<0&&flags.indexOf('#')>=0)rsf=rsf+'.';rs=rse.length<rsf.length?rse:rsf;return processFlags(flags,width,rs,arg)}converters['o']=function(flags,width,precision,arg){var iPrecision=parseInt(precision);var rs=Math.round(Math.abs(arg)).toString(8);if(rs.length<iPrecision)rs=pad(rs,' ',iPrecision-rs.length);if(flags.indexOf('#')>=0)rs='0'+rs;return processFlags(flags,width,rs,arg)}converters['X']=function(flags,width,precision,arg){return(converters['x'](flags,width,precision,arg)).toUpperCase()}converters['x']=function(flags,width,precision,arg){var iPrecision=parseInt(precision);arg=Math.abs(arg);var rs=Math.round(arg).toString(16);if(rs.length<iPrecision)rs=pad(rs,' ',iPrecision-rs.length);if(flags.indexOf('#')>=0)rs='0x'+rs;return processFlags(flags,width,rs,arg)}converters['s']=function(flags,width,precision,arg){var iPrecision=parseInt(precision);var rs=arg;if(rs.length>iPrecision)rs=rs.substring(0,iPrecision);return processFlags(flags,width,rs,0)}farr=fstring.split('%');retstr=farr[0];fpRE=/^([-+ #]*)(\d*)\.?(\d*)([cdieEfFgGosuxX])(.*)$/;for(var i=1;i<farr.length;i++){fps=fpRE.exec(farr[i]);if(!fps)continue;if(arguments[i]!=null)retstr+=converters[fps[4]](fps[1],fps[2],fps[3],arguments[i]);retstr+=fps[5]}return retstr}}var XMLHelpers=new function(){var me=this;me.getOuterXML=function(node,options){var r;if(node.xml){r=node.xml}else if(node.outerHTML){r=node.outerHTML}else if(window.XMLSerializer){var serializer=new XMLSerializer();var text=serializer.serializeToString(node);r=text}else{return null}if(options){if(options.insertClosingTags){r=r.replace(selfClosingTagRe,"<$1></$1>")}}return r}}var placeholderCSS='color: #999999; font-style: italic';var placeholderRequiredCSS='color: #ffcccc !important;'var sb="";if(document.getElementsByTagName('body').length==0){sb='<style type="text/css" id="testCSS">'+StringHelpers.sprintf('.html5-hasPlaceholderText{%s} input::-webkit-input-placeholder {%s}',placeholderCSS,placeholderCSS)+'</style>';document.write(sb)}}EventHelpers.addPageLoadEvent('html5Widgets.init');
@@ -0,0 +1,10 @@
1
+ /**
2
+ * jscolor, JavaScript Color Picker
3
+ *
4
+ * @version 1.3.1
5
+ * @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html
6
+ * @author Jan Odvarko, http://odvarko.cz
7
+ * @created 2008-06-15
8
+ * @updated 2010-01-23
9
+ * @link http://jscolor.com
10
+ */var jscolor={dir:"",binding:!0,preloading:!0,install:function(){jscolor.addEvent(window,"load",jscolor.init)},init:function(){jscolor.binding&&jscolor.bind(),jscolor.preloading&&jscolor.preload()},getDir:function(){if(!jscolor.dir){var a=jscolor.detectDir();jscolor.dir=a!==!1?a:"jscolor/"}return jscolor.dir},detectDir:function(){var a=location.href,b=document.getElementsByTagName("base");for(var c=0;c<b.length;c+=1)b[c].href&&(a=b[c].href);var b=document.getElementsByTagName("script");for(var c=0;c<b.length;c+=1)if(b[c].src&&/(^|\/)jscolor(\.min)?\.js([?#].*)?$/i.test(b[c].src)){var d=new jscolor.URI(b[c].src),e=d.toAbsolute(a);return e.path=e.path.replace(/[^\/]+$/,""),e.query=null,e.fragment=null,e.toString()}return!1},bind:function(){var a=document.getElementsByTagName("input");for(var b=0;b<a.length;b+=1){var c;!a[b].color&&a[b].hasAttribute("type")&&a[b].getAttribute("type")==="color"&&(a[b].color=new jscolor.color(a[b],{}))}},preload:function(){for(var a in jscolor.imgRequire)jscolor.imgRequire.hasOwnProperty(a)&&jscolor.loadImage(a)},images:{pad:[181,101],sld:[16,101],cross:[15,15],arrow:[7,11]},imgRequire:{},imgLoaded:{},requireImage:function(a){jscolor.imgRequire[a]=!0},loadImage:function(a){jscolor.imgLoaded[a]||(jscolor.imgLoaded[a]=new Image,jscolor.imgLoaded[a].src=jscolor.getDir()+a)},fetchElement:function(a){return typeof a=="string"?document.getElementById(a):a},addEvent:function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)},fireEvent:function(a,b){if(!a)return;if(document.createEventObject){var c=document.createEventObject();a.fireEvent("on"+b,c)}else if(document.createEvent){var c=document.createEvent("HTMLEvents");c.initEvent(b,!0,!0),a.dispatchEvent(c)}else a["on"+b]&&a["on"+b]()},getElementPos:function(a){var b=a,c=a,d=0,e=0;if(b.offsetParent)do d+=b.offsetLeft,e+=b.offsetTop;while(b=b.offsetParent);while((c=c.parentNode)&&c.nodeName.toUpperCase()!=="BODY")d-=c.scrollLeft,e-=c.scrollTop;return[d,e]},getElementSize:function(a){return[a.offsetWidth,a.offsetHeight]},getMousePos:function(a){a||(a=window.event);if(typeof a.pageX=="number")return[a.pageX,a.pageY];if(typeof a.clientX=="number")return[a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,a.clientY+document.body.scrollTop+document.documentElement.scrollTop]},getViewPos:function(){return typeof window.pageYOffset=="number"?[window.pageXOffset,window.pageYOffset]:document.body&&(document.body.scrollLeft||document.body.scrollTop)?[document.body.scrollLeft,document.body.scrollTop]:document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)?[document.documentElement.scrollLeft,document.documentElement.scrollTop]:[0,0]},getViewSize:function(){return typeof window.innerWidth=="number"?[window.innerWidth,window.innerHeight]:document.body&&(document.body.clientWidth||document.body.clientHeight)?[document.body.clientWidth,document.body.clientHeight]:document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)?[document.documentElement.clientWidth,document.documentElement.clientHeight]:[0,0]},URI:function(a){function b(a){var b="";while(a)if(a.substr(0,3)==="../"||a.substr(0,2)==="./")a=a.replace(/^\.+/,"").substr(1);else if(a.substr(0,3)==="/./"||a==="/.")a="/"+a.substr(3);else if(a.substr(0,4)==="/../"||a==="/..")a="/"+a.substr(4),b=b.replace(/\/?[^\/]*$/,"");else if(a==="."||a==="..")a="";else{var c=a.match(/^\/?[^\/]*/)[0];a=a.substr(c.length),b+=c}return b}this.scheme=null,this.authority=null,this.path="",this.query=null,this.fragment=null,this.parse=function(a){var b=a.match(/^(([A-Za-z][0-9A-Za-z+.-]*)(:))?((\/\/)([^\/?#]*))?([^?#]*)((\?)([^#]*))?((#)(.*))?/);return this.scheme=b[3]?b[2]:null,this.authority=b[5]?b[6]:null,this.path=b[7],this.query=b[9]?b[10]:null,this.fragment=b[12]?b[13]:null,this},this.toString=function(){var a="";return this.scheme!==null&&(a=a+this.scheme+":"),this.authority!==null&&(a=a+"//"+this.authority),this.path!==null&&(a+=this.path),this.query!==null&&(a=a+"?"+this.query),this.fragment!==null&&(a=a+"#"+this.fragment),a},this.toAbsolute=function(a){var a=new jscolor.URI(a),c=this,d=new jscolor.URI;return a.scheme===null?!1:(c.scheme!==null&&c.scheme.toLowerCase()===a.scheme.toLowerCase()&&(c.scheme=null),c.scheme!==null?(d.scheme=c.scheme,d.authority=c.authority,d.path=b(c.path),d.query=c.query):(c.authority!==null?(d.authority=c.authority,d.path=b(c.path),d.query=c.query):(c.path===""?(d.path=a.path,c.query!==null?d.query=c.query:d.query=a.query):(c.path.substr(0,1)==="/"?d.path=b(c.path):(a.authority!==null&&a.path===""?d.path="/"+c.path:d.path=a.path.replace(/[^\/]+$/,"")+c.path,d.path=b(d.path)),d.query=c.query),d.authority=a.authority),d.scheme=a.scheme),d.fragment=c.fragment,d)},a&&this.parse(a)},color:function(a,b){function d(a,b,c){var d=Math.min(Math.min(a,b),c),e=Math.max(Math.max(a,b),c),f=e-d;if(f===0)return[null,0,e];var g=a===d?3+(c-b)/f:b===d?5+(a-c)/f:1+(b-a)/f;return[g===6?0:g,f/e,e]}function e(a,b,c){var d=[a,b,c],e,f,g,h;e=d[2]*d[1],f=d[2]-e;if(d[0]===null)return[f,f,f];h=f+e,g=f+e*(1-Math.abs(d[0]%2-1));switch(Math.floor(d[0])){case 0:return[h,g,f];case 1:return[g,h,f];case 2:return[f,h,g];case 3:return[f,g,h];case 4:return[g,f,h];case 5:return[h,f,g]}}function f(){delete jscolor.picker.owner,document.getElementsByTagName("body")[0].removeChild(jscolor.picker.boxB)}function g(b,c){if(!jscolor.picker){jscolor.picker={box:document.createElement("div"),boxB:document.createElement("div"),pad:document.createElement("div"),padB:document.createElement("div"),padM:document.createElement("div"),sld:document.createElement("div"),sldB:document.createElement("div"),sldM:document.createElement("div")};for(var d=0,e=4;d<jscolor.images.sld[1];d+=e){var f=document.createElement("div");f.style.height=e+"px",f.style.fontSize="1px",f.style.lineHeight="0",jscolor.picker.sld.appendChild(f)}jscolor.picker.sldB.appendChild(jscolor.picker.sld),jscolor.picker.box.appendChild(jscolor.picker.sldB),jscolor.picker.box.appendChild(jscolor.picker.sldM),jscolor.picker.padB.appendChild(jscolor.picker.pad),jscolor.picker.box.appendChild(jscolor.picker.padB),jscolor.picker.box.appendChild(jscolor.picker.padM),jscolor.picker.boxB.appendChild(jscolor.picker.box)}var g=jscolor.picker;v=[b+o.pickerBorder+o.pickerFace+o.pickerInset,c+o.pickerBorder+o.pickerFace+o.pickerInset],w=[null,c+o.pickerBorder+o.pickerFace+o.pickerInset],g.box.onmouseup=g.box.onmouseout=function(){a.focus()},g.box.onmousedown=function(){q=!0},g.box.onmousemove=function(a){t&&m(a),u&&n(a)},g.padM.onmouseup=g.padM.onmouseout=function(){t&&(t=!1,jscolor.fireEvent(r,"change"))},g.padM.onmousedown=function(a){t=!0,m(a)},g.sldM.onmouseup=g.sldM.onmouseout=function(){u&&(u=!1,jscolor.fireEvent(r,"change"))},g.sldM.onmousedown=function(a){u=!0,n(a)},g.box.style.width=4*o.pickerInset+2*o.pickerFace+jscolor.images.pad[0]+2*jscolor.images.arrow[0]+jscolor.images.sld[0]+"px",g.box.style.height=2*o.pickerInset+2*o.pickerFace+jscolor.images.pad[1]+"px",g.boxB.style.position="absolute",g.boxB.style.clear="both",g.boxB.style.left=b+"px",g.boxB.style.top=c+"px",g.boxB.style.zIndex=o.pickerZIndex,g.boxB.style.border=o.pickerBorder+"px solid",g.boxB.style.borderColor=o.pickerBorderColor,g.boxB.style.background=o.pickerFaceColor,g.pad.style.width=jscolor.images.pad[0]+"px",g.pad.style.height=jscolor.images.pad[1]+"px",g.padB.style.position="absolute",g.padB.style.left=o.pickerFace+"px",g.padB.style.top=o.pickerFace+"px",g.padB.style.border=o.pickerInset+"px solid",g.padB.style.borderColor=o.pickerInsetColor,g.padM.style.position="absolute",g.padM.style.left="0",g.padM.style.top="0",g.padM.style.width=o.pickerFace+2*o.pickerInset+jscolor.images.pad[0]+jscolor.images.arrow[0]+"px",g.padM.style.height=g.box.style.height,g.padM.style.cursor="crosshair",g.sld.style.overflow="hidden",g.sld.style.width=jscolor.images.sld[0]+"px",g.sld.style.height=jscolor.images.sld[1]+"px",g.sldB.style.position="absolute",g.sldB.style.right=o.pickerFace+"px",g.sldB.style.top=o.pickerFace+"px",g.sldB.style.border=o.pickerInset+"px solid",g.sldB.style.borderColor=o.pickerInsetColor,g.sldM.style.position="absolute",g.sldM.style.right="0",g.sldM.style.top="0",g.sldM.style.width=jscolor.images.sld[0]+jscolor.images.arrow[0]+o.pickerFace+2*o.pickerInset+"px",g.sldM.style.height=g.box.style.height;try{g.sldM.style.cursor="pointer"}catch(j){g.sldM.style.cursor="hand"}switch(p){case 0:var k="hs.png";break;case 1:var k="hv.png"}g.padM.style.background="url('"+jscolor.getDir()+"cross.gif') no-repeat",g.sldM.style.background="url('"+jscolor.getDir()+"arrow.gif') no-repeat",g.pad.style.background="url('"+jscolor.getDir()+k+"') 0 0 no-repeat",h(),i(),jscolor.picker.owner=o,document.getElementsByTagName("body")[0].appendChild(g.boxB)}function h(){switch(p){case 0:var a=1;break;case 1:var a=2}var b=Math.round(o.hsv[0]/6*(jscolor.images.pad[0]-1)),c=Math.round((1-o.hsv[a])*(jscolor.images.pad[1]-1));jscolor.picker.padM.style.backgroundPosition=o.pickerFace+o.pickerInset+b-Math.floor(jscolor.images.cross[0]/2)+"px "+(o.pickerFace+o.pickerInset+c-Math.floor(jscolor.images.cross[1]/2))+"px";var d=jscolor.picker.sld.childNodes;switch(p){case 0:var f=e(o.hsv[0],o.hsv[1],1);for(var g=0;g<d.length;g+=1)d[g].style.backgroundColor="rgb("+f[0]*(1-g/d.length)*100+"%,"+f[1]*(1-g/d.length)*100+"%,"+f[2]*(1-g/d.length)*100+"%)";break;case 1:var f,h,i=[o.hsv[2],0,0],g=Math.floor(o.hsv[0]),j=g%2?o.hsv[0]-g:1-(o.hsv[0]-g);switch(g){case 6:case 0:f=[0,1,2];break;case 1:f=[1,0,2];break;case 2:f=[2,0,1];break;case 3:f=[2,1,0];break;case 4:f=[1,2,0];break;case 5:f=[0,2,1]}for(var g=0;g<d.length;g+=1)h=1-1/(d.length-1)*g,i[1]=i[0]*(1-h*j),i[2]=i[0]*(1-h),d[g].style.backgroundColor="rgb("+i[f[0]]*100+"%,"+i[f[1]]*100+"%,"+i[f[2]]*100+"%)"}}function i(){switch(p){case 0:var a=2;break;case 1:var a=1}var b=Math.round((1-o.hsv[a])*(jscolor.images.sld[1]-1));jscolor.picker.sldM.style.backgroundPosition="0 "+(o.pickerFace+o.pickerInset+b-Math.floor(jscolor.images.arrow[1]/2))+"px"}function j(){return jscolor.picker&&jscolor.picker.owner===o}function k(){r===a&&o.importColor(),o.pickerOnfocus&&o.hidePicker()}function l(){r!==a&&o.importColor()}function m(a){var b=jscolor.getMousePos(a),c=b[0]-v[0],d=b[1]-v[1];switch(p){case 0:o.fromHSV(c*(6/(jscolor.images.pad[0]-1)),1-d/(jscolor.images.pad[1]-1),null,A);break;case 1:o.fromHSV(c*(6/(jscolor.images.pad[0]-1)),null,1-d/(jscolor.images.pad[1]-1),A)}}function n(a){var b=jscolor.getMousePos(a),c=b[1]-v[1];switch(p){case 0:o.fromHSV(null,null,1-c/(jscolor.images.sld[1]-1),z);break;case 1:o.fromHSV(null,1-c/(jscolor.images.sld[1]-1),null,z)}}this.required=!0,this.adjust=!0,this.hash=!1,this.caps=!0,this.valueElement=a,this.styleElement=a,this.hsv=[0,0,1],this.rgb=[1,1,1],this.pickerOnfocus=!0,this.pickerMode="HSV",this.pickerPosition="bottom",this.pickerFace=10,this.pickerFaceColor="ThreeDFace",this.pickerBorder=1,this.pickerBorderColor="ThreeDHighlight ThreeDShadow ThreeDShadow ThreeDHighlight",this.pickerInset=1,this.pickerInsetColor="ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow",this.pickerZIndex=1e4;for(var c in b)b.hasOwnProperty(c)&&(this[c]=b[c]);this.hidePicker=function(){j()&&f()},this.showPicker=function(){if(!j()){var b=jscolor.getElementPos(a),c=jscolor.getElementSize(a),d=jscolor.getViewPos(),e=jscolor.getViewSize(),f=[2*this.pickerBorder+4*this.pickerInset+2*this.pickerFace+jscolor.images.pad[0]+2*jscolor.images.arrow[0]+jscolor.images.sld[0],2*this.pickerBorder+2*this.pickerInset+2*this.pickerFace+jscolor.images.pad[1]],h,i,k;switch(this.pickerPosition.toLowerCase()){case"left":h=1,i=0,k=-1;break;case"right":h=1,i=0,k=1;break;case"top":h=0,i=1,k=-1;break;default:h=0,i=1,k=1}var l=(c[i]+f[i])/2,m=[-d[h]+b[h]+f[h]>e[h]?-d[h]+b[h]+c[h]/2>e[h]/2&&b[h]+c[h]-f[h]>=0?b[h]+c[h]-f[h]:b[h]:b[h],-d[i]+b[i]+c[i]+f[i]-l+l*k>e[i]?-d[i]+b[i]+c[i]/2>e[i]/2&&b[i]+c[i]-l-l*k>=0?b[i]+c[i]-l-l*k:b[i]+c[i]-l+l*k:b[i]+c[i]-l+l*k>=0?b[i]+c[i]-l+l*k:b[i]+c[i]-l-l*k];g(m[h],m[i])}},this.importColor=function(){r?this.adjust?!this.required&&/^\s*$/.test(r.value)?(r.value="",s.style.backgroundColor=s.jscStyle.backgroundColor,s.style.color=s.jscStyle.color,this.exportColor(x|y)):this.fromString(r.value)||this.exportColor():this.fromString(r.value,x)||(s.style.backgroundColor=s.jscStyle.backgroundColor,s.style.color=s.jscStyle.color,this.exportColor(x|y)):this.exportColor()},this.exportColor=function(a){if(!(a&x)&&r){var b=this.toString();this.caps&&(b=b.toUpperCase()),this.hash&&(b="#"+b),r.value=b}!(a&y)&&s&&(s.style.backgroundColor="#"+this.toString(),s.style.color=.213*this.rgb[0]+.715*this.rgb[1]+.072*this.rgb[2]<.5?"#FFF":"#000"),!(a&z)&&j()&&h(),!(a&A)&&j()&&i()},this.fromHSV=function(a,b,c,d){a<0&&(a=0)||a>6&&(a=6),b<0&&(b=0)||b>1&&(b=1),c<0&&(c=0)||c>1&&(c=1),this.rgb=e(a===null?this.hsv[0]:this.hsv[0]=a,b===null?this.hsv[1]:this.hsv[1]=b,c===null?this.hsv[2]:this.hsv[2]=c),this.exportColor(d)},this.fromRGB=function(a,b,c,e){a<0&&(a=0)||a>1&&(a=1),b<0&&(b=0)||b>1&&(b=1),c<0&&(c=0)||c>1&&(c=1);var f=d(a===null?this.rgb[0]:this.rgb[0]=a,b===null?this.rgb[1]:this.rgb[1]=b,c===null?this.rgb[2]:this.rgb[2]=c);f[0]!==null&&(this.hsv[0]=f[0]),f[2]!==0&&(this.hsv[1]=f[1]),this.hsv[2]=f[2],this.exportColor(e)},this.fromString=function(a,b){var c=a.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i);return c?(c[1].length===6?this.fromRGB(parseInt(c[1].substr(0,2),16)/255,parseInt(c[1].substr(2,2),16)/255,parseInt(c[1].substr(4,2),16)/255,b):this.fromRGB(parseInt(c[1].charAt(0)+c[1].charAt(0),16)/255,parseInt(c[1].charAt(1)+c[1].charAt(1),16)/255,parseInt(c[1].charAt(2)+c[1].charAt(2),16)/255,b),!0):!1},this.toString=function(){return(256|Math.round(255*this.rgb[0])).toString(16).substr(1)+(256|Math.round(255*this.rgb[1])).toString(16).substr(1)+(256|Math.round(255*this.rgb[2])).toString(16).substr(1)};var o=this,p=this.pickerMode.toLowerCase()==="hvs"?1:0,q=!1,r=jscolor.fetchElement(this.valueElement),s=jscolor.fetchElement(this.styleElement),t=!1,u=!1,v,w,x=1,y=2,z=4,A=8;jscolor.addEvent(a,"focus",function(){o.pickerOnfocus&&o.showPicker()}),jscolor.addEvent(a,"blur",function(){q?q=!1:window.setTimeout(function(){q||k(),q=!1},0)});if(r){var B=function(){o.fromString(r.value,x)};jscolor.addEvent(r,"keyup",B),jscolor.addEvent(r,"input",B),jscolor.addEvent(r,"blur",l),r.setAttribute("autocomplete","off")}s&&(s.jscStyle={backgroundColor:s.style.backgroundColor,color:s.style.color});switch(p){case 0:jscolor.requireImage("hs.png");break;case 1:jscolor.requireImage("hv.png")}jscolor.requireImage("cross.gif"),jscolor.requireImage("arrow.gif"),this.importColor()}};jscolor.install();
@@ -0,0 +1,25 @@
1
+ /*
2
+ Unobtrusive Slider Control by frequency decoder v2.6 (http://www.frequency-decoder.com/)
3
+
4
+ Released under a creative commons Attribution-Share Alike 3.0 Unported license (http://creativecommons.org/licenses/by-sa/3.0/)
5
+
6
+ You are free:
7
+
8
+ * to copy, distribute, display, and perform the work
9
+ * to make derivative works
10
+ * to make commercial use of the work
11
+
12
+ Under the following conditions:
13
+
14
+ by Attribution.
15
+ --------------
16
+ You must attribute the work in the manner specified by the author or licensor.
17
+
18
+ sa
19
+ --
20
+ Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.
21
+
22
+ * For any reuse or distribution, you must make clear to others the license terms of this work.
23
+ * Any of these conditions can be waived if you get permission from the copyright holder.
24
+ */
25
+ var fdSliderController=(function(){var sliders={},uniqueid=0,mouseWheelEnabled=true;var removeMouseWheelSupport=function(){mouseWheelEnabled=false};var addEvent=function(obj,type,fn){if(obj.attachEvent){obj["e"+type+fn]=fn;obj[type+fn]=function(){obj["e"+type+fn](window.event)};obj.attachEvent("on"+type,obj[type+fn])}else{obj.addEventListener(type,fn,true)}};var removeEvent=function(obj,type,fn){if(obj.detachEvent){try{obj.detachEvent("on"+type,obj[type+fn]);obj[type+fn]=null}catch(err){}}else{obj.removeEventListener(type,fn,true)}};var stopEvent=function(e){if(e==null)e=document.parentWindow.event;if(e.stopPropagation){e.stopPropagation();e.preventDefault()};return false};var joinNodeLists=function(){if(!arguments.length){return[]};var nodeList=[];for(var i=0;i<arguments.length;i++){for(var j=0,item;item=arguments[i][j];j++){nodeList[nodeList.length]=item}};return nodeList};var parseCallbacks=function(cbs){if(cbs==null){return{}};var func,type,cbObj={},parts,obj;for(var i=0,fn;fn=cbs[i];i++){type=fn.match(/(fd_slider_cb_(update|create|destroy|redraw|move|focus|blur|enable|disable)_)([^\s|$]+)/i)[1];fn=fn.replace(new RegExp("^"+type),"").replace(/-/g,".");type=type.replace(/^fd_slider_cb_/i,"").replace(/_$/,"");try{if(fn.indexOf(".")!=-1){parts=fn.split('.');obj=window;for(var x=0,part;part=obj[parts[x]];x++){if(part instanceof Function){(function(){var method=part;func=function(data){method.apply(obj,[data])}})()}else{obj=part}}}else{func=window[fn]};if(!(func instanceof Function))continue;if(!(type in cbObj)){cbObj[type]=[]};cbObj[type][cbObj[type].length]=func}catch(err){}};return cbObj};var parseClassNames=function(cbs){if(cbs==null){return""};var cns=[];for(var i=0,cn;cn=cbs[i];i++){cns[cns.length]=cn.replace(/^fd_slider_cn_/,"")};return cns.join(" ")};var createSlider=function(options){if(!options||!options.inp||!options.inp.id){return false};destroySingleSlider(options.inp.id);sliders[options.inp.id]=new fdSlider(options);return true};var init=function(elem){var ranges=/fd_range_([-]{0,1}[0-9]+(d[0-9]+){0,1}){1}_([-]{0,1}[0-9]+(d[0-9]+){0,1}){1}/i,increment=/fd_inc_([-]{0,1}[0-9]+(d[0-9]+){0,1}){1}/,kIncrement=/fd_maxinc_([-]{0,1}[0-9]+(d[0-9]+){0,1}){1}/,callbacks=/((fd_slider_cb_(update|create|destroy|redraw|move|focus|blur|enable|disable)_)([^\s|$]+))/ig,classnames=/(fd_slider_cn_([a-zA-Z0-9_\-]+))/ig,inputs=elem&&elem.tagName&&elem.tagName.search(/input|select/i)!=-1?[elem]:joinNodeLists(document.getElementsByTagName('input'),document.getElementsByTagName('select')),range,tmp,options;for(var i=0,inp;inp=inputs[i];i++){if((inp.tagName.toLowerCase()=="input"&&inp.type=="text"&&(inp.className.search(ranges)!=-1||inp.className.search(/fd_slider/)!=-1))||(inp.tagName.toLowerCase()=="select"&&inp.className.search(/fd_slider/)!=-1)){if(!elem&&inp.id&&document.getElementById("fd-slider-"+inp.id)){continue};if(!inp.id){inp.id=="sldr"+uniqueid++};options={inp:inp,inc:inp.className.search(increment)!=-1?inp.className.match(increment)[0].replace("fd_inc_","").replace("d","."):"1",maxInc:inp.className.search(kIncrement)!=-1?inp.className.match(kIncrement)[0].replace("fd_maxinc_","").replace("d","."):false,range:[0,100],callbacks:parseCallbacks(inp.className.match(callbacks)),classNames:parseClassNames(inp.className.match(classnames)),tween:inp.className.search(/fd_tween/i)!=-1,vertical:inp.className.search(/fd_vertical/i)!=-1,hideInput:inp.className.search(/fd_hide_input/i)!=-1,clickJump:inp.className.search(/fd_jump/i)!=-1,fullARIA:inp.className.search(/fd_full_aria/i)!=-1,noMouseWheel:inp.className.search(/fd_disable_mousewheel/i)!=-1};if(inp.tagName.toLowerCase()=="select"){options.range=[0,inp.options.length-1]}else if(inp.className.search(ranges)!=-1){range=inp.className.match(ranges)[0].replace("fd_range_","").replace(/d/g,".").split("_");options.range=[range[0],range[1]]};createSlider(options)}};return true};var destroySingleSlider=function(id){if(id in sliders){sliders[id].destroy();delete sliders[id];return true};return false};var destroyAllsliders=function(e){for(slider in sliders){sliders[slider].destroy()}};var unload=function(e){destroyAllsliders();sliders=null;removeEvent(window,"unload",unload);removeEvent(window,"resize",resize);removeOnloadEvent()};var resize=function(e){for(slider in sliders){sliders[slider].onResize()}};var removeOnloadEvent=function(){removeEvent(window,"load",init)};function fdSlider(options){var inp=options.inp,disabled=false,tagName=inp.tagName.toLowerCase(),min=+options.range[0],max=+options.range[1],range=Math.abs(max-min),inc=tagName=="select"?1:+options.inc||1,maxInc=options.maxInc&&options.maxInc!='undefined'?options.maxInc:inc*2;var precision=options.inc.search(".")!=-1?options.inc.substr(options.inc.indexOf(".")+1,options.inc.length-1).length:0,steps=Math.ceil(range/inc),useTween=!!options.tween,fullARIA=!!options.fullARIA,hideInput=!!options.hideInput,clickJump=useTween?false:!!options.clickJump,vertical=!!options.vertical,callbacks=options.callbacks,classNames=options.classNames,noMWheel=!!options.noMouseWheel,timer=null,kbEnabled=true,sliderH=0,sliderW=0,tweenX=0,tweenB=0,tweenC=0,tweenD=0,frame=0,x=0,y=0,maxPx=0,handlePos=0,destPos=0,mousePos=0,deltaPx=0,stepPx=0,self=this,changeList={},initVal=null,outerWrapper,wrapper,handle,bar;if(max<min){inc=-inc;maxInc=-maxInc};function disableSlider(noCallback){if(disabled&&!noCallback){return};try{removeEvent(outerWrapper,"mouseover",onMouseOver);removeEvent(outerWrapper,"mouseout",onMouseOut);removeEvent(outerWrapper,"mousedown",onMouseDown);removeEvent(handle,"focus",onFocus);removeEvent(handle,"blur",onBlur);if(!window.opera){removeEvent(handle,"keydown",onKeyDown);removeEvent(handle,"keypress",onKeyPress)}else{removeEvent(handle,"keypress",onKeyDown)};removeEvent(handle,"mousedown",onHandleMouseDown);removeEvent(handle,"mouseup",onHandleMouseUp);if(mouseWheelEnabled&&!noMWheel){if(window.addEventListener&&!window.devicePixelRatio)window.removeEventListener('DOMMouseScroll',trackMouseWheel,false);else{removeEvent(document,"mousewheel",trackMouseWheel);removeEvent(window,"mousewheel",trackMouseWheel)}}}catch(err){};clearTimeout(timer);outerWrapper.className=outerWrapper.className.replace("slider-disabled","")+" slider-disabled";outerWrapper.setAttribute("aria-disabled",true);inp.disabled=disabled=true;if(!noCallback){callback("disable")}};function enableSlider(noCallback){if(!disabled&&!noCallback)return;addEvent(outerWrapper,"mouseover",onMouseOver);addEvent(outerWrapper,"mouseout",onMouseOut);addEvent(outerWrapper,"mousedown",onMouseDown);if(!window.opera){addEvent(handle,"keydown",onKeyDown);addEvent(handle,"keypress",onKeyPress)}else{addEvent(handle,"keypress",onKeyDown)};addEvent(handle,"focus",onFocus);addEvent(handle,"blur",onBlur);addEvent(handle,"mousedown",onHandleMouseDown);addEvent(handle,"mouseup",onHandleMouseUp);outerWrapper.className=outerWrapper.className.replace("slider-disabled","");outerWrapper.setAttribute("aria-disabled",false);inp.disabled=disabled=false;if(!noCallback){callback("enable")}};function destroySlider(){try{disableSlider();outerWrapper.parentNode.removeChild(outerWrapper)}catch(err){};wrapper=bar=handle=outerWrapper=timer=null;callback("destroy");callbacks=null};function redraw(){locate();try{var sW=outerWrapper.offsetWidth,sH=outerWrapper.offsetHeight,hW=handle.offsetWidth,hH=handle.offsetHeight,bH=bar.offsetHeight,bW=bar.offsetWidth;maxPx=vertical?sH-hH:sW-hW;stepPx=maxPx/steps;deltaPx=maxPx/Math.ceil(range/maxInc);sliderW=sW;sliderH=sH;valueToPixels()}catch(err){};callback("redraw")};function callback(type){var cbObj={"elem":inp,"value":tagName=="select"?inp.options[inp.selectedIndex].value:inp.value};if(type in callbacks){for(var i=0,func;func=callbacks[type][i];i++){func(cbObj)}}};function onFocus(e){outerWrapper.className=outerWrapper.className.replace('focused','')+' focused';if(mouseWheelEnabled&&!noMWheel){addEvent(window,'DOMMouseScroll',trackMouseWheel);addEvent(document,'mousewheel',trackMouseWheel);if(!window.opera)addEvent(window,'mousewheel',trackMouseWheel)};callback("focus")};function onBlur(e){outerWrapper.className=outerWrapper.className.replace(/focused|fd-fc-slider-hover|fd-slider-hover/g,'');if(mouseWheelEnabled&&!noMWheel){removeEvent(document,'mousewheel',trackMouseWheel);removeEvent(window,'DOMMouseScroll',trackMouseWheel);if(!window.opera)removeEvent(window,'mousewheel',trackMouseWheel)};callback("blur")};function trackMouseWheel(e){if(!kbEnabled)return;e=e||window.event;var delta=0;if(e.wheelDelta){delta=e.wheelDelta/120;if(window.opera&&window.opera.version()<9.2)delta=-delta}else if(e.detail){delta=-e.detail/3};if(vertical){delta=-delta};if(delta){var xtmp=vertical?handle.offsetTop:handle.offsetLeft;xtmp=(delta<0)?Math.ceil(xtmp+deltaPx):Math.floor(xtmp-deltaPx);pixelsToValue(Math.min(Math.max(xtmp,0),maxPx))}return stopEvent(e)};function onKeyPress(e){e=e||document.parentWindow.event;if((e.keyCode>=33&&e.keyCode<=40)||!kbEnabled||e.keyCode==45||e.keyCode==46){return stopEvent(e)};return true};function onKeyDown(e){if(!kbEnabled)return true;e=e||document.parentWindow.event;var kc=e.keyCode!=null?e.keyCode:e.charCode;if(kc<33||(kc>40&&(kc!=45&&kc!=46)))return true;var value=tagName=="input"?parseFloat(inp.value):inp.selectedIndex;if(isNaN(value)||value<Math.min(min,max))value=Math.min(min,max);if(kc==37||kc==40||kc==46||kc==34){value-=(e.ctrlKey||kc==34?maxInc:inc)}else if(kc==39||kc==38||kc==45||kc==33){value+=(e.ctrlKey||kc==33?maxInc:inc)}else if(kc==35){value=max}else if(kc==36){value=min};valueToPixels(value);callback("update");return stopEvent(e)};function onMouseOver(e){this.className=this.className.replace(/fd\-slider\-hover/g,"")+' fd-slider-hover'};function onMouseOut(e){this.className=this.className.replace(/fd\-slider\-hover/g,"")};function onHandleMouseUp(e){e=e||window.event;removeEvent(document,'mousemove',trackMouse);removeEvent(document,'mouseup',onHandleMouseUp);kbEnabled=true;if(window.opera)try{setTimeout(function(){onfocus()},0)}catch(err){};document.body.className=document.body.className.replace(/slider-drag-vertical|slider-drag-horizontal/g,"");return stopEvent(e)};function onHandleMouseDown(e){e=e||window.event;mousePos=vertical?e.clientY:e.clientX;handlePos=parseInt(vertical?handle.offsetTop:handle.offsetLeft)||0;kbEnabled=false;clearTimeout(timer);timer=null;addEvent(document,'mousemove',trackMouse);addEvent(document,'mouseup',onHandleMouseUp);if(window.devicePixelRatio||(document.all&&!window.opera))try{setTimeout(function(){handle.focus()},0)}catch(err){};document.body.className+=" slider-drag-"+(vertical?"vertical":"horizontal")};function onMouseUp(e){e=e||window.event;removeEvent(document,'mouseup',onMouseUp);if(!useTween){clearTimeout(timer);timer=null;kbEnabled=true};return stopEvent(e)};function trackMouse(e){e=e||window.event;pixelsToValue(snapToNearestValue(handlePos+(vertical?e.clientY-mousePos:e.clientX-mousePos)))};function onMouseDown(e){e=e||window.event;var targ;if(e.target)targ=e.target;else if(e.srcElement)targ=e.srcElement;if(targ.nodeType==3)targ=targ.parentNode;if(targ.className.search("fd-slider-handle")!=-1){return true};try{setTimeout(function(){handle.focus()},0)}catch(err){};clearTimeout(timer);locate();timer=null;kbEnabled=false;var posx=0,sLft=0,sTop=0;if(document.documentElement&&document.documentElement.scrollTop){sTop=document.documentElement.scrollTop;sLft=document.documentElement.scrollLeft}else if(document.body){sTop=document.body.scrollTop;sLft=document.body.scrollLeft};if(e.pageX)posx=vertical?e.pageY:e.pageX;else if(e.clientX)posx=vertical?e.clientY+sTop:e.clientX+sLft;posx-=vertical?y+Math.round(handle.offsetHeight/2):x+Math.round(handle.offsetWidth/2);posx=snapToNearestValue(posx);if(useTween){tweenTo(posx)}else if(clickJump){pixelsToValue(posx)}else{addEvent(document,'mouseup',onMouseUp);destPos=posx;onTimer()}};function incrementHandle(numOfSteps){var value=tagName=="input"?parseFloat(inp.value):inp.selectedIndex;if(isNaN(value)||value<Math.min(min,max))value=Math.min(min,max);value+=inc*numOfSteps;valueToPixels(value)};function snapToNearestValue(px){var rem=px%stepPx;if(rem&&rem>=(stepPx/2)){px+=(stepPx-rem)}else{px-=rem};return Math.min(Math.max(parseInt(px,10),0),maxPx)};function locate(){var curleft=0,curtop=0,obj=outerWrapper;try{while(obj.offsetParent){curleft+=obj.offsetLeft;curtop+=obj.offsetTop;obj=obj.offsetParent}}catch(err){};x=curleft;y=curtop};function onTimer(){var xtmp=vertical?handle.offsetTop:handle.offsetLeft;xtmp=Math.round((destPos<xtmp)?Math.max(destPos,Math.floor(xtmp-deltaPx)):Math.min(destPos,Math.ceil(xtmp+deltaPx)));pixelsToValue(xtmp);if(xtmp!=destPos)timer=setTimeout(onTimer,steps>20?50:100);else kbEnabled=true};var tween=function(){frame++;var c=tweenC,d=20,t=frame,b=tweenB,x=Math.ceil((t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b);pixelsToValue(t==d?tweenX:x);callback("move");if(t!=d)timer=setTimeout(tween,20);else{clearTimeout(timer);timer=null;kbEnabled=true}};function tweenTo(tx){kbEnabled=false;tweenX=parseInt(tx,10);tweenB=parseInt(vertical?handle.style.top:handle.style.left,10);tweenC=tweenX-tweenB;tweenD=20;frame=0;if(!timer)timer=setTimeout(tween,20)};function pixelsToValue(px){handle.style[vertical?"top":"left"]=px+"px";var val=min+(Math.round(px/stepPx)*inc);setInputValue((tagName=="select"||inc==1)?Math.round(val):val)};function valueToPixels(val){var value=isNaN(val)?tagName=="input"?parseFloat(inp.value):inp.selectedIndex:val;if(isNaN(value)||value<Math.min(min,max))value=Math.min(min,max);else if(value>Math.max(min,max))value=Math.max(min,max);setInputValue(value);handle.style[vertical?"top":"left"]=Math.round(((value-min)/inc)*stepPx)+"px"};function setInputValue(val){val=isNaN(val)?min:val;if(tagName=="select"){try{val=parseInt(val,10);if(inp.selectedIndex==val)return;inp.options[val].selected=true}catch(err){}}else{val=(min+(Math.round((val-min)/inc)*inc)).toFixed(precision);if(inp.value==val)return;inp.value=val};updateAriaValues();callback("update")};function findLabel(){var label;if(inp.parentNode&&inp.parentNode.tagName.toLowerCase()=="label")label=inp.parentNode;else{var labelList=document.getElementsByTagName('label');for(var i=0,lbl;lbl=labelList[i];i++){if((lbl['htmlFor']&&lbl['htmlFor']==inp.id)||(lbl.getAttribute('for')==inp.id)){label=lbl;break}}};if(label&&!label.id){label.id=inp.id+"_label"};return label};function updateAriaValues(){handle.setAttribute("aria-valuenow",tagName=="select"?inp.options[inp.selectedIndex].value:inp.value);handle.setAttribute("aria-valuetext",tagName=="select"?inp.options[inp.selectedIndex].text:inp.value)};function onChange(e){valueToPixels();callback("update");return true};(function(){if(hideInput){inp.className+=" fd_hide_slider_input"}else{addEvent(inp,'change',onChange)};outerWrapper=document.createElement('div');outerWrapper.className="fd-slider"+(vertical?"-vertical ":" ")+classNames;outerWrapper.id="fd-slider-"+inp.id;wrapper=document.createElement('span');wrapper.className="fd-slider-inner";bar=document.createElement('span');bar.className="fd-slider-bar";if(fullARIA){handle=document.createElement('span');handle.setAttribute(!false?"tabIndex":"tabindex","0")}else{handle=document.createElement('button');handle.setAttribute("type","button")};handle.className="fd-slider-handle";handle.appendChild(document.createTextNode(String.fromCharCode(160)));outerWrapper.appendChild(wrapper);outerWrapper.appendChild(bar);outerWrapper.appendChild(handle);inp.parentNode.insertBefore(outerWrapper,inp);handle.setAttribute("role","slider");handle.setAttribute("aria-valuemin",min);handle.setAttribute("aria-valuemax",max);var lbl=findLabel();if(lbl){handle.setAttribute("aria-labelledby",lbl.id);handle.id="fd-slider-handle-"+inp.id;lbl.setAttribute("for",handle.id)};if(document.getElementById("fd_slider_describedby")){handle.setAttribute("aria-describedby","fd_slider_describedby")};if(inp.getAttribute("disabled")==true){disableSlider(true)}else{enableSlider(true)};updateAriaValues();callback("create");redraw()})();return{onResize:function(e){if(outerWrapper.offsetHeight!=sliderH||outerWrapper.offsetWidth!=sliderW){redraw()}},destroy:function(){destroySlider()},reset:function(){valueToPixels()},increment:function(n){incrementHandle(n)},disable:function(){disableSlider()},enable:function(){enableSlider()}}};addEvent(window,"load",init);addEvent(window,"unload",unload);addEvent(window,"resize",resize);return{create:function(elem){init(elem)},createSlider:function(opts){createSlider(opts)},destroyAll:function(){destroyAllsliders()},destroySlider:function(id){return destroySingleSlider(id)},redrawAll:function(){resize()},increment:function(id,numSteps){if(!(id in sliders)){return false};sliders[id].increment(numSteps)},addEvent:addEvent,removeEvent:removeEvent,stopEvent:stopEvent,updateSlider:function(id){if(!(id in sliders)){return false};sliders[id].reset()},disableMouseWheel:function(){removeMouseWheelSupport()},removeOnLoadEvent:function(){removeOnloadEvent()},disableSlider:function(id){if(!(id in sliders)){return false};sliders[id].disable()},enableSlider:function(id){if(!(id in sliders)){return false};sliders[id].enable()}}})();
@@ -0,0 +1 @@
1
+ function Timer(){this.obj=(arguments.length)?arguments[0]:window;return this}Timer.prototype.setInterval=function(func,msec){var i=Timer.getNew();var t=Timer.buildCall(this.obj,i,arguments);Timer.set[i].timer=window.setInterval(t,msec);return i}Timer.prototype.setTimeout=function(func,msec){var i=Timer.getNew();Timer.buildCall(this.obj,i,arguments);Timer.set[i].timer=window.setTimeout("Timer.callOnce("+i+");",msec);return i}Timer.prototype.clearInterval=function(i){if(!Timer.set[i])return;window.clearInterval(Timer.set[i].timer);Timer.set[i]=null}Timer.prototype.clearTimeout=function(i){if(!Timer.set[i])return;window.clearTimeout(Timer.set[i].timer);Timer.set[i]=null}Timer.set=new Array();Timer.buildCall=function(obj,i,args){var t="";Timer.set[i]=new Array();if(obj!=window){Timer.set[i].obj=obj;t="Timer.set["+i+"].obj."}t+=args[0]+"(";if(args.length>2){Timer.set[i][0]=args[2];t+="Timer.set["+i+"][0]";for(var j=1;(j+2)<args.length;j++){Timer.set[i][j]=args[j+2];t+=", Timer.set["+i+"]["+j+"]"}}t+=");";Timer.set[i].call=t;return t}Timer.callOnce=function(i){if(!Timer.set[i])return;eval(Timer.set[i].call);Timer.set[i]=null}Timer.getNew=function(){var i=0;while(Timer.set[i])i++;return i}
@@ -0,0 +1,19 @@
1
+ /*
2
+ * This notice must be untouched at all times.
3
+ *
4
+ * visibleIf.js - a cross browser form field manager that hides and shows
5
+ * form fields depending on the values of other form fields.
6
+ *
7
+ * Version 1.0 released Feb 21, 2009
8
+ * Version 2.0 (this release) released June 20, 2010. Features new
9
+ * rules engine originally developed for HTML5Widgets.js and HTML5 custom
10
+ * data- attribute support.
11
+ *
12
+ * Written by: Zoltan Hawryluk.
13
+ *
14
+ * Latest release available at http://www.useragentman.com/
15
+ *
16
+ * released under the MIT License:
17
+ * http://www.opensource.org/licenses/mit-license.php
18
+ */
19
+ var visibleIf=new function(){var me=this;var formInputCache=new Array();var changedInput=null;var visibleIfNodes;var mandatoryNodes;var varRe=/\s([a-zA-Z][a-zA-Z0-9\.]*)\s/g;var operatorRe=/\s*(~|!=|==|>={0,1}|<={0,1})\s*/g;var leftBkRe=/\(/g;var rightBkRe=/\)/g;var reRe=/~ \"([^\"]*)\"/g;var equalsRe=/ == /g;var quotedStringRe=/"[^"]*"/g;var quotedStringOneOnlyRe=/"[^"]*"/;var placeHolderString='_pLaCeHoLdEr_';var placeHolderRe=new RegExp(placeHolderString);var nodesWithEventsAttached=new Array();var inputsToClear;var req=null;var nameCounter=0;var CSSHelpers,StringHelpers,XMLHelpers,DOMHelpers;me.init=function(reset){if(EventHelpers.hasPageLoadHappened(arguments)&&!reset){return}visibleIfNodes=CSSHelpers.getElementsByClassName(document,'visibleIf');mandatoryNodes=CSSHelpers.getElementsByClassName(document,'mandatoryIf');removeDisabledNodes();me.refreshPage({isPageLoad:true});setMandatoryStates();setEvents()}function removeDisabledNodes(){for(var i=0;i<visibleIfNodes.length;i++){var node=visibleIfNodes[i];var els=getAllFormElementsIn(node)for(var j=0;j<els.length;j++){var el=els[j];el.disabled=false}}}function refreshPageEvent(e){me.refreshPage()}me.refreshPage=function(options){changedInput=this;inputsToClear=new Array();qsSb=new StringBuffer();for(var i=0;i<visibleIfNodes.length;i++){setVisibility(visibleIfNodes[i],options)}if(!(options&&!options.isPageLoaded)){for(i in inputsToClear){var el=inputsToClear[i];if(i!=0){qsSb.append('&')}qsSb.append(i).append('=')}var qs=qsSb.toString();if(qsSb.getLength()>0){var url=DOMHelpers.getDatasetItem(document.body,'visibleif-deletedataurl');if(url){req=XMLHelpers.getXMLHttpRequest(url,deleteRequestHandler,'GET',qs)}}for(var i=0;i<mandatoryNodes.length;i++){setMandatoryStates(mandatoryNodes[i],options)}}var formNodes=document.getElementsByTagName('form');for(var i=0;i<formNodes.length;i++){updateVisibilityProperties(formNodes[i])}}function setMandatoryStates(e){changedInput=this;for(var i=0;i<mandatoryNodes.length;i++){setMandatoryState(mandatoryNodes[i])}}function getRule(node,type){var r=DOMHelpers.getDatasetItem(node,type);if(!r){r=CSSHelpers.getElementsByClassName(node,type);if(r.length==0){r=null}else{r=r[0].innerHTML.trim()}}if(r){r=StringHelpers.unentify(" "+r.replace(operatorRe,' $1 ')+" ")}return r}function setEvents(){visibleIfNodes=CSSHelpers.getElementsByClassName(document,'visibleIf');mandatoryNodes=CSSHelpers.getElementsByClassName(document,'mandatoryIf');var nodesToIndex=[visibleIfNodes,mandatoryNodes];var nameCounter=0;var forms=document.getElementsByTagName('form');for(var i=0;i<forms.length;i++){EventHelpers.addEvent(forms[i],'submit',formSubmitEvent)}for(var n=0;n<nodesToIndex.length;n++){var nodes=nodesToIndex[n];for(var i=0;i<nodes.length;i++){var node=nodes[i];var parentForm=DOMHelpers.getAncestorByTagName(node,'form');var rule;var ruleType;if(n==0){ruleType="visibleIf-rule"}else{ruleType="mandatoryIf-rule"}rule=getRule(node,ruleType);if(!rule){throw"There is no rule for with the node with the following HTML:"+XMLHelpers.getOuterXML(node)}var inputVars=getInputVars(rule);if(inputVars){for(var j=0;j<inputVars.length;j++){var inputVar=inputVars[j];if(!nodesWithEventsAttached[parentForm.id]||!nodesWithEventsAttached[parentForm.id][inputVar]){if(!nodesWithEventsAttached[parentForm.id]){nodesWithEventsAttached[parentForm.id]=new Array()}nodesWithEventsAttached[parentForm.id][inputVar]=true;if(inputVars.length>0){var fieldNode=parentForm[inputVars[j]];if(fieldNode!=null){if(fieldNode.nodeName!="SELECT"&&fieldNode.length){for(var k=0;k<fieldNode.length;k++){EventHelpers.addEvent(fieldNode[k],'click',refreshPageEvent)}}else{EventHelpers.addEvent(fieldNode,'change',refreshPageEvent)}if(fieldNode.type=='text'){EventHelpers.addEvent(fieldNode,'change',refreshPageEvent)}if(fieldNode.type=='checkbox'){EventHelpers.addEvent(fieldNode,'click',refreshPageEvent)}}}}}}}}}function updateVisibilityProperties(formNode){var fields=formNode.elements;for(var i=0;i<fields.length;i++){var field=fields[i]if(!isVisible(field)&&!CSSHelpers.isMemberOfClass(field,'visibleIf-submitIfInvisible')){CSSHelpers.addClass(field,'visibleIf-notSubmitted');field.disabled=true}else{CSSHelpers.removeClass(field,'visibleIf-notSubmitted');field.disabled=false}}}function formSubmitEvent(e){if(CSSHelpers.isMemberOfClass(this,'visibleIf-submitInvisibleData')){return}updateVisibilityProperties(this)}function isVisible(node){return node.offsetWidth!=0}function setVisibility(node,options){var rule=getRule(node,'visibleIf-rule')if(rule==null){throw"There is no rule for with the node with the following HTML:"+XMLHelpers.getOuterXML(node)}var isRuleTrue=evaluateRule(DOMHelpers.getAncestorByTagName(node,'form'),rule);if(isRuleTrue){CSSHelpers.addClass(node,'visibleIf-visible');setFormElementsInside(node,false,options)}else{CSSHelpers.removeClass(node,'visibleIf-visible');if(options&&options.isPageLoad){setFormElementsInside(node,false,options)}else{setFormElementsInside(node,true,options)}}}function setMandatoryState(node){var rule=getRule(node,'mandatoryIf-rule')if(rule==null){throw"There is no rule for with the node with the following HTML:"+XMLHelpers.getOuterXML(node)}var isRuleTrue=evaluateRule(DOMHelpers.getAncestorByTagName(node,'form'),getRule(node,rule));if(isRuleTrue){CSSHelpers.addClass(node,'mandatoryIf-mandatory')}else{CSSHelpers.removeClass(node,'mandatoryIf-mandatory')}}function evaluateRule(parentForm,rule){if(rule==""){return true}else{if(rule!=null){if(!parentForm){throw"Error: the rule "+rule+" is not attached to a form."}var stringToEval;var formElem=parentForm[rule.name];var diddledRule=rule.replace(quotedStringRe,placeHolderString);var quotedVals=rule.match(quotedStringRe);var formId=parentForm.id;if(!formId){formId='visibleIf-form'+nameCounter;parentForm.id=formId;nameCounter++}stringToEval=diddledRule.replace(leftBkRe,'( ').replace(rightBkRe,' )').replace(varRe,'getFieldValue(document.getElementById("'+formId+'")["$1"]) ').replace(reRe,'.match(/$1/)');if(quotedVals){for(var i=0;i<quotedVals.length;i++){stringToEval=stringToEval.replace(placeHolderRe,quotedVals[i])}}try{if(eval(stringToEval)){return true}else{return false}}catch(ex){return false}}}}function setFormElementsInside(node,doClear,options){if(!options){options={}}var formElements=getAllFormElementsIn(node);for(var i=0;i<formElements.length;i++){var el=formElements[i];if(el!=changedInput){switch(el.nodeName){case"INPUT":switch(el.type){case"checkbox":if(el.checked){if(doClear){if(!CSSHelpers.isMemberOfClass(el,'visibleIf-doNotReset')){formCache.setValue(el.name,el.value);el.checked=false;addToInputToClear(el)}}else if(formCache.getValue(el.name)==el.value){}}break;case"radio":if(doClear){if(!CSSHelpers.isMemberOfClass(el,'visibleIf-doNotReset')){if(el.checked){formCache.setValue(el.name,el.value);el.checked=false}addToInputToClear(el)}}else if(formCache.getValue(el.name)==el.value){}break;case"file":break;case"hidden":break;default:if(doClear){if(CSSHelpers.isMemberOfClass(el,'fileList_fileDisplay')){CSSHelpers.removeClass(el,'fileList_fileDisplay');el.disabled=false;el.name=el.name.replace("_ignore","")var html=XMLHelpers.getOuterXML(el).replace(/text/,'file');el.parentNode.innerHTML=html;url=config.getScriptedValue('visibleIf.urls.deleteFiles',{files:StringHelpers.urlencode(el.value),formProperty:el.name})req=XMLHelpers.getXMLHttpRequest(url,deleteRequestHandler)}formCache.setValue(el.name,el.value);if(options.isPageLoad){el.value=DOMHelpers.getAttributeValue(el,'value');if(el.value=="null"){el.value=""}}else if(!CSSHelpers.isMemberOfClass(el,'visibleIf-doNotReset')){el.value="";addToInputToClear(el)}}else{}break}break;case"TEXTAREA":if(doClear){formCache.setValue(el.name,el.value);if(options.isPageLoad){}else if(!CSSHelpers.isMemberOfClass(el,'visibleIf-doNotReset')){el.value="";addToInputToClear(el)}}else{}break;case"SELECT":if(doClear){if(!CSSHelpers.isMemberOfClass(el,'visibleIf-doNotReset')){formCache.setValue(el.name,el.selectedIndex);el.selectedIndex=0;addToInputToClear(el)}el.disabled=true}else{el.disabled=false}break}}}}function addToInputToClear(el){if(!inputsToClear[el.name]){inputsToClear[el.name]=el}}function deleteRequestHandler(){if(!req){return}if(req.readyState==ReadyState.COMPLETED){if(req.status==HttpCode.OK||req.status==HttpCode.LOCAL_OK){}else{throw"Something bad happened. HTTP Status: "+req.status}}}function getInputVars(rule){rule=rule.replace(leftBkRe,'( ').replace(rightBkRe,' )');var vars=rule.match(varRe);if(vars==null){return new Array()}for(var i=0;i<vars.length;i++){vars[i]=vars[i].trim()}return vars}function getFieldValue(formElementNode){var r="";var type;type=formElementNode.type if(!type){if(formElementNode.length)type=formElementNode[0].type}switch(type){case'text':case'hidden':case'password':case'textarea':case'select-one':r=formElementNode.value;case'checkbox':if(formElementNode.checked){r=formElementNode.value}break;case'radio':for(var i=0;i<formElementNode.length;i++){if(formElementNode[i].checked){r=formElementNode[i].value;break}}}if(formElementNode.length){for(var i=0;i<formElementNode.length;i++){if(formElementNode[i].checked){r=formElementNode[i].value}}}return r.replace('\n','').replace(' ','')}function getAllFormElementsIn(node){if(!node){node=document}var r=new Array();var elems={inputs:node.getElementsByTagName('input'),selects:node.getElementsByTagName('select'),textareas:node.getElementsByTagName('textarea')};for(var i in elems){var elem=elems[i];for(j=0;j<elem.length;j++){r.push(elem[j])}}return r}if(window.CSSHelpers){CSSHelpers=window.CSSHelpers}else{CSSHelpers=new function(){var me=this;var blankRe=new RegExp('\\s');function getClassReString(className){return'\\s'+className+'\\s|^'+className+'\\s|\\s'+className+'$|'+'^'+className+'$'}function getClassPrefixReString(className){return'\\s'+className+'-[0-9a-zA-Z_]+\\s|^'+className+'[0-9a-zA-Z_]+\\s|\\s'+className+'[0-9a-zA-Z_]+$|'+'^'+className+'[0-9a-zA-Z_]+$'}me.addClass=function(obj,className){if(blankRe.test(className)){return}if(!me.isMemberOfClass(obj,className)){obj.className+=" "+className}}me.removeClass=function(obj,className){if(blankRe.test(className)){return}var re=new RegExp(getClassReString(className),"g");var oldClassName=obj.className;if(obj.className){obj.className=oldClassName.replace(re,'')}}me.getElementsByClassName=function(obj,className){if(obj.getElementsByClassName){return DOMHelpers.nodeListToArray(obj.getElementsByClassName(className))}else{var a=[];var re=new RegExp(getClassReString(className));var els=DOMHelpers.getAllDescendants(obj);for(var i=0,j=els.length;i<j;i++){if(re.test(els[i].className)){a.push(els[i])}}return a}}me.isMemberOfClass=function(obj,className){if(blankRe.test(className))return false;var re=new RegExp(getClassReString(className),"g");return(re.test(obj.className))}}}if(window.DOMHelpers){DOMHelpers=window.DOMHelpers}else{DOMHelpers=new function(){var me=this;me.getAllDescendants=function(obj){return obj.all?obj.all:obj.getElementsByTagName('*')}me.getAncestorByTagName=function(obj,tagName){for(var node=obj.parentNode;node.nodeName.toLowerCase()!='body';node=node.parentNode){if(tagName.toLowerCase()==node.nodeName.toLowerCase()){return node}}return null}me.getAttributeByName=function(obj,attrName){var i;var attributes=obj.attributes;for(i=0;i<attributes.length;i++){var attr=attributes[i]if(attr.nodeName==attrName&&attr.specified){return attr}}return null}me.getAttributeValue=function(obj,attrName){var attr=me.getAttributeByName(obj,attrName);if(attr!=null){return attr.nodeValue}else{return null}}me.getDatasetItem=function(obj,name){var r=DOMHelpers.getAttributeValue(obj,'data-'+name);if(!r){r=DOMHelpers.getAttributeValue(obj,'data-'+name.toLowerCase())}return r}me.nodeListToArray=function(nodeList){var ary=[];for(var i=0,len=nodeList.length;i<len;i++){ary.push(nodeList[i])}return ary}}}if(window.StringHelpers){StringHelpers=window.StringHelpers}else{StringHelpers=new function(){var me=this;me.initWhitespaceRe=/^\s\s*/;me.endWhitespaceRe=/\s\s*$/;me.whitespaceRe=/\s/;me.unentify=function(s){return s.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>')}me.urlencode=function(str){return escape(str).replace('+','%2B').replace('%20','+').replace('*','%2A').replace('/','%2F').replace('@','%40')}}}if(window.XMLHelpers){XMLHelpers=window.XMLHelpers}else{XMLHelpers=new function(){var me=this;me.getOuterXML=function(node,options){var r;if(node.xml){r=node.xml}else if(node.outerHTML){r=node.outerHTML}else if(window.XMLSerializer){var serializer=new XMLSerializer();var text=serializer.serializeToString(node);r=text}else{return null}if(options){if(options.insertClosingTags){r=r.replace(selfClosingTagRe,"<$1></$1>")}}return r}me.getXMLHttpRequest=function(url,processReqChange){var argv=me.getXMLHttpRequest.arguments;var argc=me.getXMLHttpRequest.arguments.length;var httpMethod=(argc>2)?argv[2]:'GET';var data=(argc>3)?argv[3]:"";var isAsync=(argc>4)?argv[4]:true;var req;if(window.XMLHttpRequest){req=new XMLHttpRequest()}else if(window.ActiveXObject){try{req=new ActiveXObject('Msxml2.XMLHTTP')}catch(ex){req=new ActiveXObject("Microsoft.XMLHTTP")}}else{return null}if(isAsync){req.onreadystatechange=processReqChange}if(httpMethod=="GET"&&data!=""){url+="?"+data}req.open(httpMethod,url,isAsync);req.setRequestHeader("If-Modified-Since","Sat, 1 Jan 2000 00:00:00 GMT");req.send(data);return req}}}function StringBuffer(){var me=this;var buffer=[];me.append=function(string){buffer.push(string);return me}me.appendBuffer=function(bufferToAppend){buffer=buffer.concat(bufferToAppend)}me.toString=function(){return buffer.join("")}me.getLength=function(){return buffer.length}me.flush=function(){buffer.length=0}}String.prototype.trim=function(){var str=this;if(this.length>6000){str=this.replace(StringHelpers.initWhitespaceRe,'');var i=str.length;while(StringHelpers.whitespaceRe.test(str.charAt(--i)));return str.slice(0,i+1)}else{return this.replace(StringHelpers.initWhitespaceRe,'').replace(StringHelpers.endWhitespaceRe,'')}}}var formCache=new function(){var me=this;var values=new Array();me.setValue=function(name,value){values[name]=value}me.getValue=function(name){if(values[name]==undefined){return""}else{return values[name]}}}EventHelpers.addPageLoadEvent('visibleIf.init');
@@ -0,0 +1,115 @@
1
+ /*
2
+ * HTML5 Forms Fallback for older and unsupporting browsers
3
+ * Using jQuery, jQuery UI, Modernizr, Webforms2, and other jQuery Plugins
4
+ *
5
+ * 2010 Cristian I. Colceriu
6
+ *
7
+ * www.ghinda.net
8
+ * contact@ghinda.net
9
+ *
10
+ */
11
+
12
+ /* Slide
13
+ * input[type=range] fallback
14
+ *
15
+ * using jQuery UI Slider
16
+ */
17
+ var initSlider = function() {
18
+ $('input[type=range]').each(function() {
19
+ var $input = $(this);
20
+ var $slider = $('<div id="' + $input.attr('id') + '" class="' + $input.attr('class') + '"></div>');
21
+ var step = $input.attr('step');
22
+
23
+ $input.after($slider).hide();
24
+
25
+ $slider.slider({
26
+ min: $input.attr('min'),
27
+ max: $input.attr('max'),
28
+ step: $input.attr('step'),
29
+ change: function(e, ui) {
30
+ $(this).val(ui.value);
31
+ }
32
+ });
33
+ });
34
+ };
35
+
36
+ if(!Modernizr.inputtypes.range){
37
+ $(document).ready(initSlider);
38
+ };
39
+
40
+ /* Numeric Spinner
41
+ * input[type=number] fallback
42
+ *
43
+ * using jQuery Spinner plugin by Brant Burnett(http://btburnett.com/)
44
+ */
45
+ var initSpinner = function() {
46
+ $('input[type=number]').each(function() {
47
+ var $input = $(this);
48
+ $input.spinner({
49
+ min: $input.attr('min'),
50
+ max: $input.attr('max'),
51
+ step: $input.attr('step')
52
+ });
53
+ });
54
+ };
55
+ if(!Modernizr.inputtypes.number){
56
+ $(document).ready(initSpinner);
57
+ };
58
+
59
+ /* Datepicker
60
+ * input[type=date] fallback
61
+ *
62
+ * using jQuery UI Datepicker
63
+ */
64
+ var initDatepicker = function() {
65
+ $('input[type=date]').each(function() {
66
+ var $input = $(this);
67
+ $input.datepicker({
68
+ minDate: $input.attr('min'),
69
+ maxDate: $input.attr('max'),
70
+ dateFormat: 'yy-mm-dd'
71
+ });
72
+ });
73
+ };
74
+
75
+ if(!Modernizr.inputtypes.date){
76
+ $(document).ready(initDatepicker);
77
+ };
78
+
79
+ /* ColorPicker
80
+ * input[type=color] fallback
81
+ *
82
+ * using jQuery ColorPicker plugin by Stefan Petre(http://www.eyecon.ro/)
83
+ * http://www.eyecon.ro/colorpicker/
84
+ */
85
+ var initColorpicker = function() {
86
+ $('input[type=color]').each(function() {
87
+ var $input = $(this);
88
+ $input.ColorPicker({
89
+ onSubmit: function(hsb, hex, rgb, el) {
90
+ $(el).val(hex);
91
+ $(el).ColorPickerHide();
92
+ }
93
+ });
94
+ });
95
+ };
96
+
97
+ if(!Modernizr.inputtypes.color){
98
+ $(document).ready(initColorpicker);
99
+ };
100
+
101
+ /* Placeholder
102
+ * placeholder attribute fallback
103
+ *
104
+ * using jQuery Placehold plugin by Viget Inspire(http://www.viget.com/inspire/)
105
+ * http://www.viget.com/inspire/a-jquery-placeholder-enabling-plugin/
106
+ */
107
+ var initPlaceholder = function() {
108
+ $('input[placeholder]').placehold({
109
+ placeholderClassName: 'placeholder'
110
+ });
111
+ };
112
+
113
+ if(!Modernizr.input.placeholder){
114
+ $(document).ready(initPlaceholder);
115
+ };
@@ -0,0 +1,11 @@
1
+ /*
2
+ * HTML5 Forms Fallback for older and unsupporting browsers
3
+ * Using jQuery, jQuery UI, Modernizr, Webforms2, and other jQuery Plugins
4
+ *
5
+ * 2010 Cristian I. Colceriu
6
+ *
7
+ * www.ghinda.net
8
+ * contact@ghinda.net
9
+ *
10
+ */
11
+ var initSlider=function(){$('input[type=range]').each(function(){var $input=$(this);var $slider=$('<div id="'+$input.attr('id')+'" class="'+$input.attr('class')+'"></div>');var step=$input.attr('step');$input.after($slider).hide();$slider.slider({min:$input.attr('min'),max:$input.attr('max'),step:$input.attr('step'),change:function(e,ui){$(this).val(ui.value)}})})};if(!Modernizr.inputtypes.range){$(document).ready(initSlider)};var initSpinner=function(){$('input[type=number]').each(function(){var $input=$(this);$input.spinner({min:$input.attr('min'),max:$input.attr('max'),step:$input.attr('step')})})};if(!Modernizr.inputtypes.number){$(document).ready(initSpinner)};var initDatepicker=function(){$('input[type=date]').each(function(){var $input=$(this);$input.datepicker({minDate:$input.attr('min'),maxDate:$input.attr('max'),dateFormat:'yy-mm-dd'})})};if(!Modernizr.inputtypes.date){$(document).ready(initDatepicker)};var initColorpicker=function(){$('input[type=color]').each(function(){var $input=$(this);$input.ColorPicker({onSubmit:function(hsb,hex,rgb,el){$(el).val(hex);$(el).ColorPickerHide()}})})};if(!Modernizr.inputtypes.color){$(document).ready(initColorpicker)};var initPlaceholder=function(){$('input[placeholder]').placehold({placeholderClassName:'placeholder'})};if(!Modernizr.input.placeholder){$(document).ready(initPlaceholder)};