This repository has been archived on 2018-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
node-task/public/js/ink-all.min.map

1 line
1.2 MiB
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"version":3,"file":"ink-all.min.js","sources":["../../src/js/Ink/1/lib.js","../../src/js/Ink/Net/Ajax/1/lib.js","../../src/js/Ink/Net/JsonP/1/lib.js","../../src/js/Ink/Dom/Browser/1/lib.js","../../src/js/Ink/Dom/Css/1/lib.js","../../src/js/Ink/Dom/Element/1/lib.js","../../src/js/Ink/Dom/Event/1/lib.js","../../src/js/Ink/Dom/FormSerialize/1/lib.js","../../src/js/Ink/Dom/Loaded/1/lib.js","../../src/js/Ink/Dom/Selector/1/lib.js","../../src/js/Ink/UI/Animate/1/lib.js","../../src/js/Ink/UI/Carousel/1/lib.js","../../src/js/Ink/UI/Close/1/lib.js","../../src/js/Ink/UI/Common/1/lib.js","../../src/js/Ink/UI/DatePicker/1/lib.js","../../src/js/Ink/UI/Draggable/1/lib.js","../../src/js/Ink/UI/Drawer/1/lib.js","../../src/js/Ink/UI/Dropdown/1/lib.js","../../src/js/Ink/UI/Droppable/1/lib.js","../../src/js/Ink/UI/FormValidator/1/lib.js","../../src/js/Ink/UI/FormValidator/2/lib.js","../../src/js/Ink/UI/ImageQuery/1/lib.js","../../src/js/Ink/UI/LazyLoad/1/lib.js","../../src/js/Ink/UI/Modal/1/lib.js","../../src/js/Ink/UI/Pagination/1/lib.js","../../src/js/Ink/UI/ProgressBar/1/lib.js","../../src/js/Ink/UI/SmoothScroller/1/lib.js","../../src/js/Ink/UI/SortableList/1/lib.js","../../src/js/Ink/UI/Spy/1/lib.js","../../src/js/Ink/UI/Stacker/1/lib.js","../../src/js/Ink/UI/Sticky/1/lib.js","../../src/js/Ink/UI/Swipe/1/lib.js","../../src/js/Ink/UI/Table/1/lib.js","../../src/js/Ink/UI/Tabs/1/lib.js","../../src/js/Ink/UI/TagField/1/lib.js","../../src/js/Ink/UI/Toggle/1/lib.js","../../src/js/Ink/UI/Tooltip/1/lib.js","../../src/js/Ink/UI/TreeView/1/lib.js","../../src/js/Ink/UI/Upload/1/lib.js","../../src/js/Ink/Util/Array/1/lib.js","../../src/js/Ink/Util/BinPack/1/lib.js","../../src/js/Ink/Util/Cookie/1/lib.js","../../src/js/Ink/Util/Date/1/lib.js","../../src/js/Ink/Util/Dumper/1/lib.js","../../src/js/Ink/Util/I18n/1/lib.js","../../src/js/Ink/Util/Json/1/lib.js","../../src/js/Ink/Util/String/1/lib.js","../../src/js/Ink/Util/Url/1/lib.js","../../src/js/Ink/Util/Validator/1/lib.js"],"names":["window","document","paths","modules","modulesLoadOrder","modulesRequested","pendingRMs","modulesWaitingForDeps","apply","Function","prototype","isEmptyObject","o","k","hasOwnProperty","Ink","VERSION","_checkPendingRequireModules","I","F","dep","mod","cb","pRMs","length","left","args","remaining","push","setTimeout","getPath","key","noLib","split","curKey","i","root","path","slice","join","test","setPath","rootURI","replace","loadScript","uri","contentType","indexOf","givenUri","this","Error","scriptEl","createElement","setAttribute","onerror","onreadystatechange","ev","event","type","readyState","error","aHead","getElementsByTagName","appendChild","_loadLater","namespace","ns","returnParentAndKey","levels","nsobj","parent","f","getModule","version","createModule","ver","deps","modFn","modAll","Array","call","arguments","moduleContent","_version","isInkModule","t","requireModules","cbFn","undefined","_moduleRenames","warn","Ink.UI.Aux_1","getModulesLoadOrder","getModuleScripts","mlo","unshift","map","m","getModuleURL","createExt","moduleName","dependencies","bind","fn","context","innerArgs","finalArgs","concat","bindMethod","object","methodName","bindEvent","id","getElementById","ss","rule","from","Dom","Selector","select","s","extendObj","destination","sources","len","property","Object","log","console","Ajax","url","options","init","globalOptions","parameters","requestHeaders","xMLHttpRequestWithCredentials","XMLHttpRequest","userOptions","asynchronous","method","timeout","delay","postBody","onComplete","onSuccess","onFailure","onException","onHeaders","onCreate","onInit","onTimeout","sanitizeJSON","evalJS","xhrProxy","cors","debug","useCredentials","signRequest","globalParameters","paramsObjToStr","safeCall","urlLocation","_locationFromURL","isHTTP","_locationIsHTTP","isCrossDomain","_locationIsCrossDomain","location","requestHasBody","search","transport","getTransport","request","createElementNS","href","protocol","match","widget","host","usingXDomainReq","XDomainRequest","ActiveXObject","e","setHeaders","headers","Accept","Accept-Language","navigator","language","X-Requested-With","X-Ink-Version","headerReqName","overrideMimeType","userAgent","Connection","headerName","setRequestHeader","optParams","p","a","params","toString","isNaN","encodeURIComponent","pop","setParams","getHeader","name","getResponseHeader","getAllHeaders","getAllResponseHeaders","getResponse","r","headerJSON","responseJSON","timeTaken","Date","startTime","requestedUrl","responseText","responseXML","status","statusText","abort","clearTimeout","delayTimeout","stoTimeout","ex","finish","runStateChange","rs","getTime","responseContent","response","curStatus","makeError","isSuccess","headerContentType","evalJSON","mimeType","xmlDoc","DOMParser","parseFromString","xml","destroy","listener","first","rethrow","exception","message","stacktrace","stack","value","nodeType","crossDomain","open","withCredentials","onload","send","code","isJSON","str","strJSON","sanitize","JSON","parse","eval","load","callback","ping","JsonP","failureObj","callbackParam","internalCallback","randVar","parseInt","Math","random","Net","_removeScriptTag","_addScriptTag","_addParamsToGet","hasQuestionMark","sep","pKey","pValue","parts","_getScriptContainer","headEls","scriptEls","rnd_seed","src","scriptCtn","_requestFailed","scriptUri","getAttribute","parentNode","removeChild","Browser","IE","GECKO","OPERA","SAFARI","KONQUEROR","CHROME","model","cssPrefix","domPrefix","detectBrowser","setDimensions","setReferrer","myWidth","myHeight","innerWidth","innerHeight","documentElement","clientWidth","clientHeight","body","windowWidth","windowHeight","referrer","escape","_sniffUserAgent","sAgent","toLowerCase","rVersion","re","RegExp","reVersion","alert","getCs","defaultView","getComputedStyle","Css","addRemoveClassName","elm","className","addRemState","addClassName","removeClassName","classList","add","hasClassName","remove","elmClassName","setClassName","all","has","contains","blinkClass","element","negate","Number","toggleClassName","forceAdd","toggle","setOpacity","val","style","opacity","filter","_camelCase","_","$1","toUpperCase","getStyle","currentStyle","charAt","css","parseFloat","setStyle","cssText","prop","styleFloat","cssFloat","show","forceDisplayProperty","display","hide","showHide","forceShow","_getRefTag","head","firstElementChild","child","firstChild","nextSibling","appendStyleTag","selector","force","styles","oldStyle","l","innerHTML","defStyle","refTag","styleStr","styleSheet","createTextNode","insertBefore","appendStylesheet","media","rel","_loadingCSSFiles","_loadedCSSFiles","appendStylesheetCb","cbs","linkEl","headEl","imgEl","_url","callbacks","decToHex","dec","normalizeTo2","rDec","gDec","g","bDec","b","rgb","hexToDec","hex","substr","getPropertyFromStylesheet","getRuleFromStylesheet","getPropertyFromStylesheet2","rules","getRulesFromStylesheet","x","sheet","ri","rf","styleSheets","si","sf","cssRules","selectorText","res","getPropertiesFromRule","props","steps","pre","pos","substring","borderTopLeftRadius","borderBottomRightRadius","borderTopRightRadius","borderBottomLeftRadius","changeFontSize","delta","op","minVal","maxVal","that","TypeError","el","els","fontSize","rect","elem","dimensions","getBoundingClientRect","top","offsetTop","offsetLeft","createContextualFragmentSupport","createRange","Range","createContextualFragment","deleteThisTbodyToken","browserCreatesTbodies","div","InkElement","isDOMElement","get","create","tag","properties","parEl","scrollTo","scrollIntoView","elmOffset","elmTop","elmLeft","offsetParent","y","offset","positionedOffset","valueTop","valueLeft","tagName","position","doc","ownerDocument","docElem","box","clientTop","clientLeft","scrollTop","pageYOffset","scrollLeft","pageXOffset","scroll","_getPropPx","cs","n","c","getPropertyValue","offset2","hasAttribute","attr","insertAfter","newElm","targetElm","insertTop","insertBottom","textContent","node","text","innerText","lastChild","childNodes","nodeValue","setTextContent","isLink","hasAttributeNS","isAncestorOf","ancestor","compareDocumentPosition","descendantOf","descendant","lastElementChild","previousSibling","nextElementSibling","sibling","previousElementSibling","elementWidth","offsetWidth","elementHeight","offsetHeight","elementLeft","elementTop","elementDimensions","outerDimensions","bbox","right","bottom","inViewport","opts","dims","partial","margin","viewportWidth","viewportHeight","isHidden","w","h","isVisible","clonePosition","cloneTo","cloneFrom","ellipsizeText","overflow","whiteSpace","textOverflow","findUpwardsHaving","boolTest","findUpwardsByClass","tst","cls","findUpwardsByTag","nodeName","findUpwardsById","findUpwardsBySelector","sel","matchesSelector","getChildrenText","removeIt","j","part","nodes","jLen","_trimString","String","data","trim","getSelectValues","selectEl","values","_normalizeData","d","data2","fillSelect","container","skipEmpty","defaultValue","containerEl","optionEl","fillRadios","insertAfterEl","splitEl","inputEl","checked","fillChecks","parentIndexOf","parentEl","childEl","idx","nextSiblings","elements","siblings","children","index","previousSiblings","childElementCount","_wrapElements","TABLE","html","TBODY","THEAD","TFOOT","TR","_getWrapper","wrapper","wrapFunc","tds","tbody","appendHTML","prependHTML","setHTML","wrap","target","nextNode","unwrap","wrapperSelector","replacement","replaceChild","removeTextNodeChildren","prevEl","toRemove","htmlToFragment","range","createDocumentFragment","selectNode","fragment","tempElement","current","InkDomSelector","dataset","attrs","attributes","curAttr","curAttrName","curAttrValue","total","moveCursorTo","setSelectionRange","createTextRange","collapse","moveEnd","moveStart","pageWidth","xScroll","scrollMaxX","scrollWidth","self","pageHeight","yScroll","scrollMaxY","scrollHeight","bean","definition","win","old","namespaceRegex","nameRegex","addEvent","removeEvent","W3C_MODEL","eventSupport","ONE","str2arr","isString","isFunction","standardNativeEvents","w3cNativeEvents","nativeEvents","hash","events","customEvents","isAncestor","check","related","relatedTarget","prefix","mouseenter","base","condition","mouseleave","mousewheel","Event","commonProps","mouseProps","mouseWheelProps","keyProps","textProps","touchProps","messageProps","stateProps","overOutRegex","typeFixers","reg","fix","newEvent","keyCode","which","rightClick","button","pageX","pageY","clientX","clientY","typeFixerMap","isNative","parentWindow","originalEvent","isBean","srcElement","fixer","preventDefault","returnValue","stopPropagation","cancelBubble","stop","stopped","stopImmediatePropagation","isImmediatePropagationStopped","clone","currentTarget","ne","targetElement","RegEntry","wrappedHandler","eargs","findTarget","eventElement","__beanDel","ft","handler","original","namespaces","customType","once","removeListener","eventType","inNamespaces","checkNamespaces","matches","checkElement","checkOriginal","checkHandler","registry","forAll","pfx","list","entries","entry","put","del","splice","removed","selectorEngine","setSelectorEngine","querySelectorAll","rootListener","propertyName","listeners","custom","attachEvent","detachEvent","rm","originalFn","orgType","handlers","delegate","array","fireListener","evt","createEvent","dispatchEvent","fireEvent","createEventObject","off","typeSpec","isTypeStr","on","types","delfn","one","fire","names","beanDel","noConflict","cleanup","CollectGarbage","InkEvent","KEY_BACKSPACE","KEY_TAB","KEY_RETURN","KEY_ESC","KEY_SPACE","KEY_LEFT","KEY_UP","KEY_RIGHT","KEY_DOWN","KEY_DELETE","KEY_HOME","KEY_END","KEY_PAGEUP","KEY_PAGEDOWN","KEY_INSERT","throttle","func","wait","lastCall","throttled","now","timeDiff","delegationTarget","fromElement","toElement","findElement","elmTagName","observe","eventName","callBack","useCapture","addEventListener","observeOnce","onceBack","stopObserving","observeMulti","observeDelegated","cursor","Selector_1","removeEventListener","cancel","stopDefault","pointer","pointerX","pointerY","touches","isLeftClick","isRightClick","isMiddleClick","getCharFromKeyboardEvent","changeCasing","fromCharCode","shiftOn","shiftKey","InkArray","isArrayIsh","obj","isArray","toArray","FormSerialize","serialize","form","out","emptyArrayToken","pairs","asPairs","emptyArray","forEach","pair","_resultsInArray","emit","serializeEl","multiple","didEmit","thisOption","inputs","_isSerialized","fillIn","map2","_objToPairs","_fillInPairs","groupBy","reduce","_fillInOne","firstOne","firstNodeName","firstType","isSelectMulti","_fillInBoolean","min","checkAttr","input","isChecked","inArray","Loaded","_contexts","run","cbQueue","done","checkState","_checkState","poll","_poll","ael","rem","det","wet","csf","alreadyLoaded","frameElement","doScroll","where","_ready","rnative","createCache","cache","keys","Expr","cacheLength","shift","markFunction","expando","assert","Sizzle","results","seed","groups","nid","newContext","newSelector","preferredDoc","setDocument","documentIsHTML","rquickExpr","exec","support","getElementsByClassName","qsa","rbuggyQSA","tokenize","rescape","toSelector","rsibling","qsaError","removeAttribute","rtrim","siblingCheck","cur","diff","sourceIndex","MAX_NEGATIVE","createInputPseudo","createButtonPseudo","createPositionalPseudo","argument","matchIndexes","parseOnly","matched","tokens","soFar","preFilters","cached","tokenCache","preFilter","rcomma","rcombinators","matchExpr","addCombinator","matcher","combinator","dir","checkNonElements","doneName","outerCache","dirkey","dirruns","cachedruns","elementMatcher","matchers","condense","unmatched","newUnmatched","mapped","setMatcher","postFilter","postFinder","postSelector","temp","preMap","postMap","preexisting","elems","multipleContexts","matcherIn","matcherOut","matcherFromTokens","checkContext","leadingRelative","relative","implicitRelative","matchContext","matchAnyContext","outermostContext","matcherFromGroupMatchers","elementMatchers","setMatchers","matcherCachedRuns","bySet","byElement","superMatcher","expandContext","setMatched","matchedCount","outermost","contextBackup","find","dirrunsUnique","uniqueSort","contexts","token","runescape","funescape","compile","setFilters","getText","isXML","recompare","sortInput","rbuggyMatches","classCache","compilerCache","hasDuplicate","sortOrder","strundefined","arr","push_native","whitespace","characterEncoding","identifier","operators","pseudos","rpseudo","ridentifier","ID","CLASS","NAME","TAG","ATTR","PSEUDO","CHILD","needsContext","rinputs","rheader","rattributeQuotes","escaped","high","createComment","getByName","pass","getElementsByName","sortDetached","div1","attrHandle","attrId","getAttributeNode","tmp","mozMatchesSelector","webkitMatchesSelector","oMatchesSelector","msMatchesSelector","disconnectedMatch","adown","bup","compare","aup","ap","bp","expr","ret","specified","msg","duplicates","detectDuplicates","sortStable","sort","selectors","createPseudo",">"," ","+","~","excess","unquoted","pattern","operator","result","what","last","simple","forward","ofType","nodeIndex","start","useCache","pseudo","not","lang","elemLang","focus","activeElement","hasFocus","tabIndex","enabled","disabled","selected","selectedIndex","empty","header","eq","even","odd","lt","gt","radio","checkbox","file","password","image","submit","reset","group","filters","Common","Animate","BaseUIComponent","animationPrefix","animationEndEventName","animation","oAnimation","msAnimation","webkitAnimation","_name","_optionDefinition","trigger","duration","removeClass","onEnd","_init","_options","animate","_element","_animationPrefix","animationSupported","onAnimationEnd","animationName","elOrSelector","createUIComponent","Pagination","limitRange","max","Carousel","setTransitionProperty","newTransition","transitionProperty","oTransitionProperty","msTransitionProperty","mozTransitionProperty","webkitTransitionProperty","requestAnimationFrame","mozRequestAnimationFrame","webkitRequestAnimationFrame","autoAdvance","axis","initialPage","spaceAfterLastSlide","hideLast","center","keyboardSupport","pagination","onChange","swipe","_handlers","paginationChange","windowResize","_isY","ulEl","_ulEl","_currentPage","refit","_setUpPagination","_setUpAutoAdvance","_setUpHider","size","perpendicular","_liEls","numSlides","contRect","_ctnLength","_elLength","_slidesPerPage","floor","isFinite","numPages","ceil","numPagesChanged","_numPages","_deltaLength","_center","_updateHider","_IE7","_pagination","setSize","setPage","getPage","setCurrent","nextPage","hiderEl","_hiderEl","gap","pad","padding","slides","stl","_onTouchStart","_swipeData","ulRect","firstUlPos","inUlX","inUlY","_touchMoveIsFirstTouchMove","_onTouchMove","deltaY","abs","deltaX","_scrolling","_onAnimationFrame","pointerPos","swipeData","elRect","newPos","_onTouchEnd","snapToNext","relProgress","curPage","progressInPages","_onPaginationChange","pgn","_setPage","getCurrent","page","_lengthToGo","isLastPage","_itemsInLastPage","previousPage","getSlidesPerPage","getTotalPages","getStageElm","getSlidesList","getTotalSlides","Close","Url","warnStub","constructor","stub","_componentOptions","elementIsOptional","elsOrSelector","isValidInstance","_validateInstance","registerInstance","_stubInstance","nothing","es6WeakMapSupport","instances","WeakMap","domRegistry","__InkInstances","set","thing","Layouts","TINY","SMALL","MEDIUM","LARGE","XLARGE","isInteger","fieldName","required","fieldId","defaults","overrides","optionValue","lType","defaultVal","invalidThrow","_coerce_funcs","fromDataAttrs","dataAttrs","_coerce_from_string","_options_validate","invalid","quote","invalidStr","paramName","_options_validate_types","number","boolean","string","function","integer","round","stringify","childIndex","ajaxJSON","endpoint","currentLayout","v","detectorEl","hashSet","hashParams","getAnchorString","genQueryString","cleanChildren","storeIdAndClasses","fromEl","inObj","_id","classes","_classes","restoreIdAndClasses","toEl","_instanceId","_warnDoubleInstantiation","newInstance","getName","getInstance","nameWithoutVersion","inst","unregisterInstance","UIComponent","getInstanceFromSelector","getInstanceIds","getInstances","destroyComponent","instance","err","_validate","_validationError","getOption","setOption","getElement","theConstructor","assertProp","propType","propVal","_oldProto","hideF","InkDate","clamp","dateishFromYMDString","YMD","dateishFromYMD","year","month","day","_year","_month","_day","dateishFromDate","date","getFullYear","getMonth","getDate","DatePicker","autoOpen","cleanText","closeText","pickerField","containerElement","cssClass","dateRange","displayInSelect","dayField","monthField","yearField","format","nextLinkText","ofText","onFocus","onMonthSelected","onSetDate","onYearSelected","prevLinkText","showClean","showClose","shy","startDate","startWeekDay","validDayFn","validMonthFn","validYearFn","nextValidDateFn","prevValidDateFn","yearRange",1,2,3,4,5,6,7,8,9,10,11,12,"wDay","_dateParsers","_hoverPicker","_picker","_setMinMax","setDate","_lang","_render","_listenToContainerObjectEvents","_containerObject","_renderSuperTopBar","calendarTop","_monthDescContainer","_monthPrev","_monthNext","_monthContainer","_monthSelector","_renderMonthSelector","_yearSelector","_appendDatePickerToDom","_renderMonth","_monthChanger","_ofText","_yearChanger","inline","_addOpenCloseEvents","_addDateChangeHandlersToInputs","fields","_updateDate","_showDefaultView","_inline","_hide","opener","cannotBe","ulSelector","mon","_renderMonthButton","liMonth","data-cal-month","appendTarget","parentIsControl","_wrapper","_wrapperIsControl","_superTopBar","_onClick","_onRelativeChangerClick","_onAbsoluteChangerClick","_showMonthSelector","_showYearSelector","_clean","_updateDescription","changeYear","change_year_next","change_year_prev","changeMonth","change_month_next","change_month_prev","_updateCal","elemData","calDay","calMonth","calYear","_changeYear","blur","noLimits","_min","noMinLimit","_max","noMaxLimit","MAX_VALUE","dates","rDate","each","noLim","lim","_daysInMonth","valid","_dateCmp","_fitDateToRange","_isValidDate","_dateWithinRange","_dateAboveMax","_dateBelowMin","oth","_dateCmpUntil","depth","_getPrevMonth","_getNextMonth","dataParsed","_parseDate","_setDate","inc","_incrementViewingYear","firstYear","thisYear","yearUl","prevYearLi","_getYearButton","nextYearLi","_acceptableYear","li","data-cal-year","_addMonthClassNames","dateStr","yearRegExp","validOneOrTwo","_isDate","_acceptableDay","_acceptableDateComponent","_acceptableMonth","userCb","_callUserCallbackBool","_writeDateInFormat","dateString","auxDate","objClicked","dt","_updateMonth","_y","_m","exceptions","incValue","_tryLeap","_getPrevYear","_getNextYear","atomName","directionName","advancer","maxOrMin","boundary","leapUserCb","_callUserCallbackDate","_getNextDecade","decade","_getCurrentDecade","_getPrevDecade","_callUserCallbackBase","yyyy-mm-dd","yyyy/mm/dd","yy-mm-dd","yy/mm/dd","dd-mm-yyyy","dd/mm/yyyy","dd-mm-yy","dd/mm/yy","mm/dd/yyyy","mm-dd-yyyy","_getMonthCalendarHeader","_getDayButtons","_getFirstDayIndex","wDayFirst","getDay","daysInMonth","ul","firstDayIndex","_getDayButton","dayButton","_addMonthButtonClassNames","btn","toDisable","showMonth","isMonthRendered","between","Draggable","constraint","constraintElm","handle","revert","zIndex","fps","droppableProxy","mouseAnchor","dragClass","skipChildren","onStart","onDrag","elmStartPosition","active","dragged","prevCoords","placeholder","zindex","firstDrag","deltaMs","lastRunAt","_onStart","dragFacade","_onDragFacade","drag","_onDrag","end","_onEnd","selectStart","_getCoords","ps","_cloneStyle","dst","borderWidth","width","height","tgtEl","originalPosition","marginTop","marginBottom","marginLeft","marginRight","visibility","delta2","ad","applyDelta","dragHandlerName","proxy","fs","backgroundColor","firstEl","mouseCoords","mPosX","mPosY","newX","newY","draggableSize","constTop","constBottom","constLeft","constRight","Droppable","updateAll","mouseCoords2","action","pt","Element","elNotFound","Drawer","parentSelector","leftDrawer","leftTrigger","rightDrawer","rightTrigger","contentDrawer","closeOnContentClick","closeOnLinkClick","mode","sides","_contentDrawers","_leftDrawer","_leftTriggers","_rightDrawer","_rightTriggers","_triggers","_isOpen","_direction","click","afterTransition","_afterTransition","_delay","_addEvents","triggerClicked","side","close","direction","Toggle","Dropdown","hoverOpen","dismissOnInsideClick","dismissOnOutsideClick","dismissAfter","onInsideClick","onOutsideClick","onOpen","onDismiss","_toggle","closeOnInsideClick","closeOnClick","onChangeState","newState","_openOrDismiss","_onMouseOver","getState","_openTimeout","_dismissTimeout","_onMouseOut","_onInsideClick","_handlerCall","dismiss","_onOutsideClick","foundElem","needle","foundTarget","callHandler","doNotInformToggle","_doNotInformToggle","setState","hAddClassName","hRemoveClassName","_droppables","_draggables","cleanStyle","draggable","opt","hoverClass","hoverclass","accept","onHover","onDrop","onDropOut","namedEventHandlers","move","droppable","copy","cloneNode","_findDraggable","originalParent","elementData","_update","_findData","elms","update","coords","InkValidator","elementsWithSameName","FormValidator","_flagMap","ink-fv-required","ink-fv-email","ink-fv-url","ink-fv-number","ink-fv-phone_pt","ink-fv-phone_cv","ink-fv-phone_mz","ink-fv-phone_ao","ink-fv-date","ink-fv-confirm","ink-fv-custom","confirmElms","hasConfirm","_errorClassName","_errorValidationClassName","_errorTypeWarningClassName","_errorTypeErrorClassName","validate","_free","onError","customFlag","confirmGroup","fail","_validateElements","_showError","_clearError","_clearCache","_getElements","formElms","curElm","totalElm","flag","flag2","oGroups","_makeConfirmGroups","errors","customErrors","_isValid","_isCustomValid","_validateConfirmGroups","curGroup","totalG","curFlag","tCustom","fieldType","inputType","_trim","aFormRadios","totalRadio","mail","isPTPhone","isCVPhone","isAOPhone","isMZPhone","validFormat","validValues","isDate","formElm","aFail","tFail","_showAnErrorOnElement","controlGroupElm","controlElm","errorClasses","_errorTypeClassName","errorMsg","aErrorLabel","control","aErrorLabel2","I18n","FormElement","validationFunctions","min_length","minSize","max_length","maxSize","exact_length","exactSize","email","fullCheck","ip","ipType","isIP","phone","phoneType","countryCode","credit_card","cardType","isCreditCard","alpha","supportSpaces","ascii","singleLineWhitespace","punctuation","unicode","unicodePunctuation","latin","latin1","latin1Punctuation","alpha_numeric","numbers","alpha_dash","dash","underscore","digit","positive","negative","decimalPlaces","decimal","decimalSeparator","leftDigits","decimalSep","maxDigits","numeric","minValue","maxValue","multipleOf","color","isColor","fieldToCompare","getFormElements","getValue","validationMessages","en_US","formvalidator.required","formvalidator.min_length","formvalidator.max_length","formvalidator.exact_length","formvalidator.email","formvalidator.url","formvalidator.ip","formvalidator.phone","formvalidator.credit_card","formvalidator.date","formvalidator.alpha","formvalidator.text","formvalidator.latin","formvalidator.alpha_numeric","formvalidator.alpha_dash","formvalidator.digit","formvalidator.integer","formvalidator.decimal","formvalidator.numeric","formvalidator.range","formvalidator.color","formvalidator.matches","formvalidator.validation_function_not_found","pt_PT","label","_errors","_rules","_value","_getLabel","_parseRules","rulesLength","paramStartPos","_addError","paramObj","field","i18nKey","getErrors","_formElements","eventTrigger","neverSubmit","searchFor","beforeValidation","setRule","errorMessage","getKey","langObj","dictObj","append","getI18n","setI18n","i18n","appendI18n","setLanguage","getRules","_rootElement","_errorMessages","_markedErrorElements","getElements","formElements","errorElement","errorElements","counter","cancelEventOnSuccess","formElement","controlGroupElement","controlElement","paragraph","errorArr","ImageQuery","retina","queries","onLoad","lastIndexOf","_filename","sortMulti","reverse","_onLoad","_onResize","_findCurrentQuery","devicePixelRatio","query","LazyLoad","item","source","scrollElement","touchEvents","onInsideViewport","onAfterAttributeChange","autoInit","_rootElm","_aData","_hasEvents","_activate","_getData","_onScrollThrottled","aElms","_onScroll","_removeEvents","_elInViewport","_userCallback","reload","upName","dimension","firstCharacter","maxName","Modal","opacitySupported","openModals","shadeClass","modalClass","triggerEvent","autoDisplay","markup","onShow","closeOnEscape","responsive","_onShadeClick","keyDown","_onKeyDown","resize","_wasDismissed","_markupMode","_modalDiv","_modalDivStyle","_modalShadow","_modalShadowStyle","_contentContainer","setContentMarkup","triggerElements","_reposition","runNow","_timeoutResizeFunction","_resizeTimeout","isPercentage","currentViewport","originalStatus","_resizeContainer","_shadeElement","alertsInTheModal","alertsLength","containerHeight","_modalHeader","_modalFooter","compatMode","_contentElement","_waitForFade","keyValue","htmlEl","transitionEndEventNames","classicName","evName","fadeChecker","getContentElement","contentMarkup","tempHeader","tempFooter","toAdd","genAEl","inner","aEl","wrapText","spanEl","totalItemCount","itemsPerPage","sideButtons","firstLabel","lastLabel","previousLabel","nextLabel","previousPageLabel","nextPageLabel","hashParameter","parentTag","childTag","wrapperClass","paginationClass","activeClass","disabledClass","hideClass","previousClass","previousPageClass","nextClass","nextPageClass","numberFormatter","_size","_calculateSize","_current","_itemLiEls","_generateMarkup","_updateItems","_observe","count","liEls","isSimpleToggle","liEl","_nextEl","pi","pf","_pageStart","_pageEnd","_page","_prevPageEl","hasPreviousPage","_nextPageEl","hasNextPage","_firstEl","isFirst","_lastEl","isLast","_prevEl","hasPrevious","hasNext","hasUlAlready","isChevron","isDotted","createLiEl","isPrev","isNext","isPrevPage","isNextPage","firstClass","lastClass","aElem","nr","setOnChange","sz","setSizeInItems","totalItems","pageNumber","isRelative","getSize","ProgressBar","startValue","_elementBar","setValue","newValue","cancelAnimationFrame","SmoothScroller","speed","changeHash","endPos","interval","onDone","onClick","render","link","thisDocument","linkedDocument","activeLiSelector","activeLi","Events","SortableList","hasTouch","maxTouchPoints","msMaxTouchPoints","placeholderClass","draggedClass","draggingClass","dragSelector","dragObject","handleSelector","moveSelector","swap","cancelMouseOut","down","_onDown","_onMove","up","_onUp","_isMoving","_down","_move","_up","stopMoving","_placeholder","_movePlaceholder","_addMovingClasses","touch","elementFromPoint","validateMove","droppedElement","_removeMovingClasses","target_position","placeholder_position","from_top","from_left","targetIndex","spyTargets","addSpied","spied","observeOnScroll","observingOnScroll","onScroll","onScrollForTarget","activeEl","findActiveElement","toDeactivate","menuLinkSelector","toActivate","closest","Infinity","closestIndex","bBox","Spy","Stacker","column","customBreakPoints","largeMax","largeMin","mediumMax","mediumMin","smallMax","smallMin","largeCols","mediumCols","smallCols","isOrdered","onRunCallback","onResizeCallback","onAPIReloadCallback","_aList","_curLayout","_runFirstTime","_getPageItemsToList","_canApplyLayoutChange","_applyLayoutChange","addItem","reloadItems","_removeDomItems","_setCurLayout","customBreakpoints","_getColumnsToShow","cols","curLayout","_aColumn","totalCols","aItems","aNewList","ii","countCol","Sticky","offsetBottom","topElement","stickyClass","inlineDimensions","inlinePosition","bottomElement","activateInLayouts","_dims","scrollTarget","_isDisabledInLayout","_getDims","unstick","_unstick","bottomOfSticky","maxBottomOfSticky","_stickTo","_inlineDimensions","_getBottomOffset","bottomOfViewport","toBottomOfDocument","oldPosition","oldWidth","dimensionsInStatic","Swipe","onMove","minDist","maxDist","minDuration","maxDuration","storeGesture","stopEvents","_supported","db","_isOn","_isMeOrParent","_pushGesture","_gesture","_time","changedTouches","_target","_t0","_p0","t1","gesture","p1","dr","dist","sqrt","time","overallMovement","overallTime","InkUrl","InkString","Json","maybeTurnIntoNumber","rNumber","cmp","numberishEnabledCmp","aValue","bValue","Table","sameSame","pageSize","caretUpClass","caretDownClass","createEndpointUrl","getDataFromEndPoint","processJSONRows","processJSONRow","processJSONField","processJSONHeaders","processJSONTotalRows","totalRows","getSortKey","allowResetSorting","visibleFields","tdClassNames","paginationOptions","_thead","tHead","createTHead","_headers","thClick","_originalFields","_sortableFields","_originalData","_data","_totalRows","_resetSortOrder","_addHeadersClasses","_setPagination","headerLabel","classNames","_onThClick","paginated","sortable","_invertSortOrder","_setSortOrderOfColumn","_paginate","sortAndReverse","isAscending","_sort","caretHtml","order","firstIndex","lastIndex","_registerFieldNames","_fieldIsVisible","userKey","keyFunction","columnIndex","columnName","trA","trB","elementA","elementB","_createHeadersFromJson","tr","insertRow","th","_createSingleHeaderFromJson","_createRowsFromJSON","rows","row","trIndex","_createSingleRowFromJson","rowIndex","_createFieldFromJson","fieldData","processor","_elOrFieldData","processed","isNumber","setEndpoint","currentPage","paginationEl","pageNo","_getSortOrder","_getDataViaAjax","_getUrl","urlCreator","parseUrl","sortField","endpointUri","success","JSONData","_onAjaxSuccess","getDataFromEndpoint","jsonResponse","_rowLength","Tabs","preventUrlChange","onBeforeChange","menuSelector","contentSelector","tabSelector","triggerEventsOnLoad","_menu","_initializeDom","_setFirstActive","contentTabs","activeMenuLink","_findLinkByHref","_changeTab","runCallbacks","activeTabs","_activeMenuTab","_activeSection","_activeMenuLink","_onTabClickedGeneric","_onTabClicked","tabElm","_dehashify","changeTab","_lastLayout","smallLayout","_hashify","links","disable","enable","activeTab","activeMenuTab","activeSection","activeContentTab","TagField","enterKey","backspaceKey","isTruthy","tags","tagQuery","tagQueryAsync","allowRepeated","maxTags","outSeparator","separator","autoSplit","_readInput","_viewElm","_input","_tagsFromMarkup","_tags","_onKeyUp","_onBlur","_refocus","tagname","option","_tagsToMarkup","_addTag","_removeTag","spc","_onEnterKeyDown","_onBackspaceKeyDown","_removeConfirm","_unsetRemovingVisual","_setRemovingVisual","tagIndex","_removeRemovingVisualTimeout","isAccordion","initialState","classNameOn","classNameOff","_targets","_accordion","_firstTime","_bindEvents","state","_onTriggerEvent","isAncestorOfClickedElement","some","thisOne","_updateAccordion","accordionElement","shades","ancestorOfTargets","shadesLength","Tooltip","EachTooltip","transitionDurationName","transitionPropertyName","transitionTimingFunctionName","bodies","spacing","forever","template","templatefield","fade","tooltips","tooltip","_destroy","_oppositeDirections","_onMouseMove","_delayTimeout","_makeTooltip","mousePosition","_getOpt","_createTooltipElement","_removeTooltip","_fadeInTooltipElement","_placeTooltipElement","_onTooltipMouseOver","_getFloatOpt","outerHTML","_getIntOpt","fadeTime","mPos","_setPos","targetElementPos","tleft","ttop","centerh","centerv","tooltipDims","elementDims","maxX","maxY","_getWhereValueInsideViewport","arrow","tooltipLeft","tooltipTop","toBottom","toRight","toLeft","toTop","viewport","dataAttrVal","instanceOption","_getMousePosition","pageDims","_getPageXY","elmDims","scrollDim","_getScroll","cWidth","cHeight","dd","TreeView","parentClass","openNodeClass","openClass","closedClass","iconTag","isParent","isOpen","_getIcon","_setNodeOpen","_getChild","beOpen","icon","DirectoryReader","maxDepth","_read","_readDirectories","running","_readEntries","currentEntry","createReader","readEntries","isDirectory","clearArray","fullPath","_stopActivityTimeout","readError","activity","checkActivity","clearInterval","readComplete","setInterval","Queue","lists","items","getItems","parentId","purge","keepList","pid","priority","view","_searchByPid","UI","Upload","_fileButton","fileButton","_dropzone","dropzone","_setDropEvent","_setFileButton","dropzones","ondrop","_dropEventHandler","ondragleave","_onDragLeave","ondragend","_onDragEndEventHandler","ondragdrop","ondragenter","_onDragEnterHandler","ondragover","_onDragOverHandler","publish","btns","_fileChangeHandler","files","FormData","_addFilesToQueue","_events","fileFormName","maxFilesize","INVALID_FILE_NAME","extraData","useChunks","chunkSize","minSizeToUseChunks","endpointChunk","endpointChunkCommit","foldersEnabled","directoryMaxDepth","_queueId","_queueRunning","_folders","_supportChunks","Blob","dataTransfer","_files","webkitGetAsEntry","folders","_addFolderToQueue","invalidFolders","getFiles","isFile","convertToFile","hasParent","getSubDirs","created","fileID","directory","_processQueue","internalUpload","queueLen","canceled","_doRequest","_upload","xhr","forceAbort","showError","lengthComputable","loaded","lastModifiedDate","upload","onprogress","chunk_offset","chunk_upload_id","fd","blob","upload_path","parentID","rootPath","invalidOffset","upload_id","chunk_expires","expires","onabort","abortAll","abortOne","subscribe","arrayProto","testedObject","outKey","latestGroup","initial","aKeys","shuffle","tmp1","rnd","filtered","intersect","arr1","arr2","shared","J","convert","unique","newArr","step","insert","rLen","output","iLen","Packer","fit","blocks","block","findNode","splitNode","used","GrowingPacker","growNode","canGrowDown","canGrowRight","shouldGrowRight","shouldGrowDown","growRight","growDown","sorts","area","msort","maxside","criteria","BinPack","binPack","bl","packer","sorter","dims2","fitted","unfitted","filled","Cookie","cookie","_Cookie","aCookie","aItem","decodeURIComponent","domain","secure","sName","sExpires","sPath","sDomain","sSecure","oDate","sDate","valueOf","nDate","expiresString","toGMTString","portClean","cookieName","expiresDate","_months","_iMonth","janeiro","jan","fevereiro","fev","março","mar","abril","abr","maio","mai","junho","jun","julho","jul","agosto","ago","setembro","outubro","novembro","nov","dezembro","dez","_wDays","_d","_iWeek","week","segunda","seg","terça","ter","quarta","qua","quinta","qui","sexta","sex","sábado","sáb","domingo","dom","nDays","_date","iFormat","escapeChar","jsDate","jsFirstDay","jsThisDay","jsHour","jsDay","suffixes","suffix","UTC","jsYearStart","days","jsMonth","getYear","jsYear","getHours","jsMinute","getMinutes","jsSecond","getSeconds","getTimezoneOffset","jsMinZone","jsMinutes","jsDayName","jsMonthName","str_date","mList","objIndex","dayY","dayW","hour","hourD","sec","msec","ampm","diffM","diffH","pattr","_haveDatetime","_haveYear","_haveYDay","_haveDay","_haveMonth","_haveMonthDay","_haveOnlyDay","_haveWDay","_haveWeek","_haveWeekWDay","_haveOnlyWDay","_validDate","_noDate","_haveHour12","_haveHour24","_haveHour","_haveMin","_haveSec","_haveMSec","_haveMoreM","_haveMoreS","_haveDiffM","_haveDiffH","dList","gmt","aux","Dumper","_tab","_formatParam","param","formated","_outputFormat","_getTabs","numberOfTabs","tabs","_i","dim","_typeof","printDump","write","returnDump","alertDump","windowDump","dumperwindow","pattrText","funcOrVal","dict","testMode","_dicts","_dict","_testMode","_gLang","bool","gLang","langGlobal","_gDict","pars","isObj","$2","$3","ntext","strSin","strPlur","ordinal","num","lastDig","ordDict","byLastDigit","alias","_gDicts","appendGlobal","twoDigits","function_call","cx","dateToISOString","toISOString","getUTCFullYear","getUTCMonth","getUTCDate","getUTCHours","getUTCMinutes","getUTCSeconds","getUTCMilliseconds","toFixed","InkJson","_nativeJSON","_convertToUnicode","_escape","theString","\b","\t","\n","\f","\r","\"","\\","charCodeAt","_toUnicode","unicodeString","inInt","theUnicode","_stringifyValue","toJSON","arrayString","objectString","convertToUnicode","reviver","walk","holder","SyntaxError","InkUtilString","_chars","_entities","_accentedChars","_accentedRemovedChars","_htmlUnsafeChars","<","&","'","ucFirst","firstWordOnly","replacer","stripTags","allowed","aAllowed","aNewAllowed","cleanedTag","strAllowed","reAllowed","aFoundTags","htmlEntitiesEncode","htmlEntitiesDecode","$0","utf8Encode","utfstring","shortString","words","resultstr","truncateString","utf8Decode","c2","c3","removeAccentedChars","newString","substrCount","haystack","htmlEscapeUnsafe","chars","normalizeWhitespace","toUnicode","unescape","es","hexNum","escapeText","txt","whiteList","txt2","C","escapedCharRegex","unescapeText","strcmp","str1","str2","packetize","maxLen","_keyStr","getUrl","getQueryString","aParams","queryStr","aQueryStr","pairVar","getAnchor","anchor","anchorStr","aAnchorStr","aURL","scheme","re1","re2","re3","regPort","tmpHost1","port","tmpHost2","tmpUserPass","user","urlObj","frag","hostname","currentScriptElement","aScripts","curScript","_debug","Validator","_countryCodes","_internacionalPT","_indicativosPT",21,22,231,232,233,234,235,236,238,239,241,242,243,244,245,249,251,252,253,254,255,256,258,259,261,262,263,265,266,268,269,271,272,273,274,275,276,277,278,279,281,282,283,284,285,286,289,291,292,295,296,91,93,96,92,707,760,800,808,30,"_internacionalCV","_indicativosCV",95,97,98,99,"_internacionalAO","_indicativosAO","_internacionalMZ","_indicativosMZ",82,84,"_internacionalTL","_indicativosTL","_characterGroups","asciiAlpha","latin1Alpha","unicodeAlpha","space","nicknamePunctuation","newline","asciiPunctuation","createRegExp","checkCharacterGroups","numb","inOptions","thousandSep","returnNumber","maxExcl","minExcl","_isLeapYear","parser","emailValido","full","reHTTP","reUrl","aInd","strInd","re351","reSpecialChars","reInt","reValid","isPortuguesePhone","re238","re244","re258","isTLPhone","re670","isPhone","codPostal","cp1","cp2","returnBothResults","cPostalSep","cPostal4","cPostal3","parserCPostal","cPostal","yearIndex","monthIndex","dayIndex","dateParser","keyword","hexa","rgba","hsl","hsla","_creditCardSpecs","default","luhn","american express","diners club","discover","jcb","maestro","mastercard","visa","_luhn","checksum","dbl","creditCardType","ccLength"],"mappings":"CAME,SAASA,EAAQC,GAEf,YAGA,MAAI,OAASD,IAAb,CASA,GAAIE,MACAC,KACAC,KACAC,KACAC,KACAC,KAEAC,EAAQC,SAASC,UAAUF,MAG3BG,EAAgB,SAASC,GAEzB,GAAiB,gBAANA,GAAkB,OAAO,CACpC,KAAK,GAAIC,KAAKD,GACV,GAAIA,EAAEE,eAAeD,GACjB,OAAO,CAGf,QAAO,EAOXb,GAAOe,KACHC,QAAS,QACTC,4BAA6B,WACzB,GAAIC,GAAGC,EAAGP,EAAGQ,EAAKC,EAAKC,EAAIC,IAC3B,KAAKL,EAAI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AA0B3+F,OAAO,CACvC,GAAI5C,GAAGwhG,EAAWD,EAAeliG,MACjC,KAAMW,EAAE,EAAOwhG,EAAJxhG,EAAcA,IAErB,GAAIc,KAAK0vD,aAAa6/B,EAAKkR,EAAevhG,IACtC,OAAO,CAIf,QAAO,EAMX,GAFAuhG,EAAiBA,EAAepvF,cAEsB,mBAA1CrR,MAAK4/F,iBAAiBa,GAC9B,OAAO,CAIX,IAAIliG,GAASgxF,EAAIhxF,OAAO,EAGxB,OAAoF,KAA/EyB,KAAK4/F,iBAAiBa,GAAwB,OAAEzhG,MAAM,KAAKc,QAAQvB,IAC7D,EAILyB,KAAK4/F,iBAAiBa,GAAwB,OAAElhG,KAAKgwF,GAKvDvvF,KAAK4/F,iBAAiBa,GAAsB,QAAM,GAC3C,EAGJzgG,KAAKsgG,MAAM/Q,IARP,GAYnB,OAAOkI","sourcesContent":["/**\n * Ink Core.\n * @module Ink_1\n * This module provides the necessary methods to create and load the modules using Ink.\n */\n\n;(function(window, document) {\n\n 'use strict';\n\n // skip redefinition of Ink core\n if ('Ink' in window) { return; }\n\n\n // internal data\n\n /*\n * NOTE:\n * invoke Ink.setPath('Ink', '/Ink/'); before requiring local modules\n */\n var paths = {};\n var modules = {};\n var modulesLoadOrder = [];\n var modulesRequested = {};\n var pendingRMs = [];\n var modulesWaitingForDeps = {};\n\n var apply = Function.prototype.apply;\n\n // auxiliary fns\n var isEmptyObject = function(o) {\n /*jshint unused:false */\n if (typeof o !== 'object') { return false; }\n for (var k in o) {\n if (o.hasOwnProperty(k)) {\n return false;\n }\n }\n return true;\n };\n\n /**\n * @namespace Ink_1\n */\n\n window.Ink = {\n VERSION: '3.0.5',\n _checkPendingRequireModules: function() {\n var I, F, o, dep, mod, cb, pRMs = [];\n for (I = 0, F = pendingRMs.length; I < F; ++I) {\n o = pendingRMs[I];\n\n if (!o) { continue; }\n\n for (dep in o.left) {\n if (o.left.hasOwnProperty(dep)) {\n mod = modules[dep];\n if (mod) {\n o.args[o.left[dep] ] = mod;\n delete o.left[dep];\n --o.remaining;\n }\n }\n }\n\n if (o.remaining > 0) {\n pRMs.push(o);\n }\n else {\n cb = o.cb;\n if (!cb) { continue; }\n delete o.cb; // to make sure I won't call this more than once!\n cb.apply(false, o.args);\n }\n }\n\n pendingRMs = pRMs;\n\n if (pendingRMs.length > 0) {\n setTimeout( function() { Ink._checkPendingRequireModules(); }, 0 );\n }\n },\n\n /**\n * Get the full path of a module.\n * This method looks up the paths given in setPath (and ultimately the default Ink's path).\n *\n * @method getPath\n * @param {String} key Name of the module you want to get the path\n * @param {Boolean} [noLib] Flag to skip appending 'lib.js' to the returned path.\n */\n getPath: function(key, noLib) {\n var split = key.split(/[._]/g);\n var curKey;\n var i;\n var root;\n var path;\n\n // Look for Ink.Dom.Element.1, Ink.Dom.Element, Ink.Dom, Ink in this order.\n for (i = split.length; i >= 0; i -= 1) {\n curKey = split.slice(0, i + 1).join('.'); // See comment in setPath\n if (paths[curKey]) {\n root = curKey;\n break;\n }\n }\n\n if (root in paths) {\n path = paths[root];\n } else {\n return null;\n }\n\n if (!/\\/$/.test(path)) {\n path += '/';\n }\n if (i < split.length) {\n // Add the rest of the path. For example, if we found\n // paths['Ink.Dom'] to be 'http://example.com/Ink/Dom/',\n // we now add '/Element/' to get the full path.\n path += split.slice(i + 1).join('/') + '/';\n }\n if (!noLib) {\n path += 'lib.js';\n }\n return path;\n },\n \n /**\n * Sets the URL path for a namespace.\n * Use this to customize where requireModules and createModule will load dependencies from.\n * This can be useful to set your own CDN for dynamic module loading or simply to change your module folder structure\n * \n * @method setPath\n *\n * @param {String} key Module or namespace\n * @param {String} rootURI Base URL path and schema to be appended to the module or namespace\n *\n * @example\n * Ink.setPath('Ink', 'http://my-cdn/Ink/');\n * Ink.setPath('Lol', 'http://my-cdn/Lol/');\n *\n * // Loads from http://my-cdn/Ink/Dom/Whatever/lib.js\n * Ink.requireModules(['Ink.Dom.Whatever'], function () { ... });\n * // Loads from http://my-cdn/Lol/Whatever/lib.js\n * Ink.requireModules(['Lol.Whatever'], function () { ... });\n */\n setPath: function(key, rootURI) {\n // Replacing version separator with dot because the difference\n // between a submodule and a version doesn't matter here.\n // It would also overcomplicate the implementation of getPath\n paths[key.replace(/_/, '.')] = rootURI;\n },\n\n /**\n * Loads a script URL.\n * This creates a `script` tag in the `head` of the document.\n * Reports errors by listening to 'error' and 'readystatechange' events.\n *\n * @method loadScript\n * @param {String} uri Can be an external URL or a module name\n * @param {String} [contentType]='text/javascript' The `type` attribute of the new script tag.\n */\n loadScript: function(uri, contentType) {\n /*jshint evil:true */\n\n if (uri.indexOf('/') === -1) {\n var givenUri = uri; // For the error message\n uri = this.getPath(uri);\n if (uri === null) {\n throw new Error('Could not load script \"' + givenUri + '\". ' +\n 'Path not found in the registry. Did you misspell ' +\n 'the name, or forgot to call setPath()?');\n }\n }\n\n var scriptEl = document.createElement('script');\n scriptEl.setAttribute('type', contentType || 'text/javascript');\n scriptEl.setAttribute('src', uri);\n\n scriptEl.onerror = scriptEl.onreadystatechange = function (ev) {\n ev = ev || window.event;\n if (ev.type === 'readystatechange' && scriptEl.readyState !== 'loaded') {\n // if not readyState == 'loaded' it's not an error.\n return;\n }\n Ink.error(['Failed to load script from ', uri, '.'].join(''));\n };\n // CHECK ON ALL BROWSERS\n /*if (document.readyState !== 'complete' && !document.body) {\n document.write( scriptEl.outerHTML );\n }\n else {*/\n var aHead = document.getElementsByTagName('head');\n if(aHead.length > 0) {\n aHead[0].appendChild(scriptEl);\n }\n //}\n },\n\n _loadLater: function (dep) {\n setTimeout(function () {\n if (modules[dep] || modulesRequested[dep] ||\n modulesWaitingForDeps[dep]) {\n return;\n }\n modulesRequested[dep] = true;\n Ink.loadScript(dep);\n }, 0);\n },\n\n /**\n * Defines a module namespace.\n *\n * @method namespace\n * @param {String} ns Namespace to define.\n * @param {Boolean} [returnParentAndKey] Flag to change the return value to an array containing the namespace parent and the namespace key\n * @return {Object|Array} Returns the created namespace object\n */\n namespace: function(ns, returnParentAndKey) {\n if (!ns || !ns.length) { return null; }\n\n var levels = ns.split('.');\n var nsobj = window;\n var parent;\n\n for (var i = 0, f = levels.length; i < f; ++i) {\n nsobj[ levels[i] ] = nsobj[ levels[i] ] || {};\n parent = nsobj;\n nsobj = nsobj[ levels[i] ];\n }\n\n if (returnParentAndKey) {\n return [\n parent,\n levels[i-1]\n ];\n }\n\n return nsobj;\n },\n\n /**\n * Loads a module.\n * A synchronous method to get the module from the internal registry.\n * It assumes the module is defined and loaded already!\n *\n * @method getModule\n * @param {String} mod Module name\n * @param {Number} [version] Version number of the module\n * @return {Object|Function} Module object or function, depending how the module is defined\n */\n getModule: function(mod, version) {\n var key = version ? [mod, '_', version].join('') : mod;\n return modules[key];\n },\n\n /**\n * Creates a new module. \n * Use this to wrap your code and benefit from the module loading used throughout the Ink library\n *\n * @method createModule\n * @param {String} mod Module name, separated by dots. Like Ink.Dom.Selector, Ink.UI.Modal\n * @param {Number} version Version number\n * @param {Array} deps Array of module names which are dependencies of the module being created. The order in which they are passed here will define the order they will be passed to the callback function.\n * @param {Function} modFn The callback function to be executed when all the dependencies are resolved. The dependencies are passed as arguments, in the same order they were declared. The function itself should return the module.\n * @sample Ink_1_createModule.html \n *\n */\n createModule: function(mod, ver, deps, modFn) { // define\n if (typeof mod !== 'string') {\n throw new Error('module name must be a string!');\n }\n\n // validate version correctness\n if (!(typeof ver === 'number' || (typeof ver === 'string' && ver.length > 0))) {\n throw new Error('version number missing!');\n }\n\n var modAll = [mod, '_', ver].join('');\n\n modulesWaitingForDeps[modAll] = true;\n\n var cb = function() {\n //console.log(['createModule(', mod, ', ', ver, ', [', deps.join(', '), '], ', !!modFn, ')'].join(''));\n\n // make sure module in not loaded twice\n if (modules[modAll]) {\n //console.warn(['Ink.createModule ', modAll, ': module has been defined already.'].join(''));\n return;\n }\n\n\n // delete related pending tasks\n delete modulesRequested[modAll];\n delete modulesRequested[mod];\n\n\n // run module's supplied factory\n var args = Array.prototype.slice.call(arguments);\n var moduleContent = modFn.apply(window, args);\n modulesLoadOrder.push(modAll);\n // console.log('** loaded module ' + modAll + '**');\n\n\n // set version\n if (typeof moduleContent === 'object') { // Dom.Css Dom.Event\n moduleContent._version = ver;\n }\n else if (typeof moduleContent === 'function') {\n moduleContent.prototype._version = ver; // if constructor\n moduleContent._version = ver; // if regular function\n }\n\n\n // add to global namespace...\n var isInkModule = mod.indexOf('Ink.') === 0;\n var t;\n if (isInkModule) {\n t = Ink.namespace(mod, true); // for mod 'Ink.Dom.Css', t[0] gets 'Ink.Dom' object and t[1] 'Css'\n }\n\n\n // versioned\n modules[ modAll ] = moduleContent; // in modules\n delete modulesWaitingForDeps[ modAll ];\n\n if (isInkModule) {\n t[0][ t[1] + '_' + ver ] = moduleContent; // in namespace\n }\n\n\n // unversioned\n modules[ mod ] = moduleContent; // in modules\n\n if (isInkModule) {\n if (isEmptyObject( t[0][ t[1] ] )) {\n t[0][ t[1] ] = moduleContent; // in namespace\n }\n // else {\n // console.warn(['Ink.createModule ', modAll, ': module has been defined already with a different version!'].join(''));\n // }\n }\n\n\n if (this) { // there may be pending requires expecting this module, check...\n Ink._checkPendingRequireModules();\n }\n };\n\n this.requireModules(deps, cb);\n },\n\n /**\n * Requires modules asynchronously \n * Use this to get modules, even if they're not loaded yet\n *\n * @method requireModules\n * @param {Array} deps Array of module names. The order in which they are passed here will define the order they will be passed to the callback function. \n * @param {Function} cbFn The callback function to be executed when all the dependencies are resolved. The dependencies are passed as arguments, in the same order they were declared.\n * @sample Ink_1_requireModules.html \n */\n requireModules: function(deps, cbFn) { // require\n //console.log(['requireModules([', deps.join(', '), '], ', !!cbFn, ')'].join(''));\n var i, f, o, dep, mod;\n f = deps && deps.length;\n o = {\n args: new Array(f),\n left: {},\n remaining: f,\n cb: cbFn\n };\n\n if (!(typeof deps === 'object' && deps.length !== undefined)) {\n throw new Error('Dependency list should be an array!');\n }\n if (typeof cbFn !== 'function') {\n throw new Error('Callback should be a function!');\n }\n\n for (i = 0; i < f; ++i) {\n if (Ink._moduleRenames[deps[i]]) {\n Ink.warn(deps[i] + ' was renamed to ' + Ink._moduleRenames[deps[i]]);\n dep = Ink._moduleRenames[deps[i]];\n } else {\n dep = deps[i];\n }\n\n // Because trailing commas in oldIE bring us undefined values here\n if (!dep) {\n --o.remaining;\n continue;\n }\n\n mod = modules[dep];\n if (mod) {\n o.args[i] = mod;\n --o.remaining;\n continue;\n }\n else if (!modulesRequested[dep]) {\n Ink._loadLater(dep);\n }\n o.left[dep] = i;\n }\n\n if (o.remaining > 0) {\n pendingRMs.push(o);\n }\n else {\n cbFn.apply(true, o.args);\n }\n },\n\n _moduleRenames: {\n 'Ink.UI.Aux_1': 'Ink.UI.Common_1'\n },\n\n /**\n * Lists loaded module names.\n * The list is ordered by loaded time (oldest module comes first)\n *\n * @method getModulesLoadOrder\n * @return {Array} returns the order in which modules were resolved and correctly loaded\n */\n getModulesLoadOrder: function() {\n return modulesLoadOrder.slice();\n },\n\n /**\n * Builds the markup needed to load the modules.\n * This method builds the script tags needed to load the currently used modules\n * \n * @method getModuleScripts\n * @uses getModulesLoadOrder\n * @return {String} The script markup\n */\n getModuleScripts: function() {\n var mlo = this.getModulesLoadOrder();\n mlo.unshift('Ink_1');\n mlo = mlo.map(function(m) {\n return ['<scr', 'ipt type=\"text/javascript\" src=\"', Ink.getModuleURL(m), '\"></scr', 'ipt>'].join('');\n });\n\n return mlo.join('\\n');\n },\n \n /**\n * Creates an Ink.Ext module\n *\n * Does exactly the same as createModule but creates the module in the Ink.Ext namespace\n *\n * @method createExt\n * @uses createModule\n * @param {String} moduleName Extension name\n * @param {String} version Extension version\n * @param {Array} dependencies Extension dependencies\n * @param {Function} modFn Function returning the extension\n * @sample Ink_1_createExt.html \n */\n createExt: function (moduleName, version, dependencies, modFn) {\n return Ink.createModule('Ink.Ext.' + moduleName, version, dependencies, modFn);\n },\n\n /**\n * Function.prototype.bind alternative.\n * Creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.\n *\n * @method bind\n * @param {Function} fn The function \n * @param {Object} context The value to be passed as the this parameter to the target function when the bound function is called. If used as false, it preserves the original context and just binds the arguments.\n * @param {Any} [args*] Additional arguments will be sent to the original function as prefix arguments.\n * @return {Function}\n * @sample Ink_1_bind.html \n */\n bind: function(fn, context) {\n var args = Array.prototype.slice.call(arguments, 2);\n return function() {\n var innerArgs = Array.prototype.slice.call(arguments);\n var finalArgs = args.concat(innerArgs);\n return fn.apply(context === false ? this : context, finalArgs);\n };\n },\n\n /**\n * Function.prototype.bind alternative for class methods\n * Creates a new function that, when called, has this k\n * @method bindMethod\n * @uses bind\n * @param {Object} object The object that contains the method to bind\n * @param {String} methodName The name of the method that will be bound\n * @param {Any} [args*] Additional arguments will be sent to the new method as prefix arguments.\n * @return {Function}\n * @sample Ink_1_bindMethod.html \n */\n bindMethod: function (object, methodName) {\n return Ink.bind.apply(Ink,\n [object[methodName], object].concat([].slice.call(arguments, 2)));\n },\n\n /**\n * Function.prototype.bind alternative for event handlers.\n * Same as bind but keeps first argument of the call the original event.\n * Set \"context\" to `false` to preserve the original context of the function and just bind the arguments.\n *\n * @method bindEvent\n * @param {Function} fn The function \n * @param {Object} context The value to be passed as the this parameter to the target \n * @param {Any} [args*] Additional arguments will be sent to the original function as prefix arguments\n * @return {Function}\n * @sample Ink_1_bindEvent.html \n */\n bindEvent: function(fn, context) {\n var args = Array.prototype.slice.call(arguments, 2);\n return function(event) {\n var finalArgs = args.slice();\n finalArgs.unshift(event || window.event);\n return fn.apply(context === false ? this : context, finalArgs);\n };\n },\n\n /**\n * Alias to document.getElementById\n *\n * @method i\n * @param {String} id Element ID\n * @return {DOMElement}\n * @sample Ink_1_i.html \n */\n i: function(id) {\n if(!id) {\n throw new Error('Ink.i => id or element must be passed');\n }\n if(typeof(id) === 'string') {\n return document.getElementById(id);\n }\n return id;\n },\n\n /**\n * Alias for Ink.Dom.Selector\n *\n * @method ss\n * @uses Ink.Dom.Selector.select\n * @param {String} rule\n * @param {DOMElement} [from]\n * @return {Array} array of DOMElements\n * @sample Ink_1_ss.html \n */\n ss: function(rule, from)\n {\n if(typeof(Ink.Dom) === 'undefined' || typeof(Ink.Dom.Selector) === 'undefined') {\n throw new Error('This method requires Ink.Dom.Selector');\n }\n return Ink.Dom.Selector.select(rule, (from || document));\n },\n\n /**\n * Alias for Ink.Dom.Selector first result\n *\n * @method s\n * @uses Ink.Dom.Selector.select\n * @param {String} rule Selector string\n * @param {DOMElement} [from] Context element. If set to a DOM element, the rule will only look for descendants of this DOM Element.\n * @return {DOMElement}\n * @sample Ink_1_s.html \n */\n s: function(rule, from)\n {\n if(typeof(Ink.Dom) === 'undefined' || typeof(Ink.Dom.Selector) === 'undefined') {\n throw new Error('This method requires Ink.Dom.Selector');\n }\n return Ink.Dom.Selector.select(rule, (from || document))[0] || null;\n },\n\n /**\n * Extends an object with another\n * Copy all of the properties in one or more source objects over to the destination object, and return the destination object. It's in-order, so the last source will override properties of the same name in previous arguments.\n *\n * @method extendObj\n * @param {Object} destination The object that will receive the new/updated properties\n * @param {Object} source The object whose properties will be copied over to the destination object\n * @param {Object} [args*] Additional source objects. The last source will override properties of the same name in the previous defined sources\n * @return destination object, enriched with defaults from the sources\n * @sample Ink_1_extendObj.html \n */\n extendObj: function(destination/*, source... */) {\n var sources = [].slice.call(arguments, 1);\n\n for (var i = 0, len = sources.length; i < len; i++) {\n if (!sources[i]) { continue; }\n for (var property in sources[i]) {\n if(Object.prototype.hasOwnProperty.call(sources[i], property)) {\n destination[property] = sources[i][property];\n }\n }\n }\n\n return destination;\n },\n\n /**\n * Calls native console.log if available.\n *\n * @method log\n * @param {Any} [args*] Arguments to be evaluated\n * @sample Ink_1_log.html \n **/\n log: function () {\n // IE does not have console.log.apply in IE10 emulated mode\n var console = window.console;\n if (console && console.log) {\n apply.call(console.log, console, arguments);\n }\n },\n\n /**\n * Calls native console.warn if available.\n *\n * @method warn\n * @param {Any} [args*] Arguments to be evaluated\n * @sample Ink_1_warn.html \n **/\n warn: function () {\n // IE does not have console.log.apply in IE10 emulated mode\n var console = window.console;\n if (console && console.warn) {\n apply.call(console.warn, console, arguments);\n }\n },\n\n /**\n * Calls native console.error if available.\n *\n * @method error\n * @param {Any} [args*] Arguments to be evaluated\n * @sample Ink_1_error.html \n **/\n error: function () {\n // IE does not have console.log.apply in IE10 emulated mode\n var console = window.console;\n if (console && console.error) {\n apply.call(console.error, console, arguments);\n }\n }\n };\n\n\n // TODO for debug - to detect pending stuff\n /*\n var failCount = {}; // fail count per module name\n var maxFails = 3; // times\n var checkDelta = 0.5; //seconds\n\n var tmpTmr = setInterval(function() {\n var mk = Object.keys(modulesRequested);\n var l = mk.length;\n\n if (l > 0) {\n // console.log('** waiting for modules: ' + mk.join(', ') + ' **');\n\n for (var i = 0, f = mk.length, k, v; i < f; ++i) {\n k = mk[i];\n v = failCount[k];\n failCount[k] = (v === undefined) ? 1 : ++v;\n\n if (v >= maxFails) {\n console.error('** Loading of module ' + k + ' failed! **');\n delete modulesRequested[k];\n }\n }\n }\n else {\n // console.log('** Module loads complete. **');\n clearInterval(tmpTmr);\n }\n }, checkDelta*1000);\n */\n}(window, document));\n","/**\n * Cross Browser Ajax requests\n * @module Ink.Net.Ajax_1\n * @version 1\n */\n\nInk.createModule('Ink.Net.Ajax', '1', [], function() {\n\n 'use strict';\n\n /**\n * Creates a new XMLHttpRequest object\n *\n * @class Ink.Net.Ajax\n * @constructor\n *\n * @param {String} url Request URL\n * @param {Object} options Request options\n * @param {Boolean} [options.asynchronous]=true If false, the request synchronous.\n * @param {Boolean} [options.cors] Flag to activate CORS. Set this to true if you're doing a cross-origin request\n * @param {String} [options.method]='POST' HTTP request method. POST by default.\n * @param {Object|String} [options.parameters] Request parameters to be sent with the request\n * @param {Number} [options.timeout] Request timeout in seconds\n * @param {Number} [options.delay] Artificial delay. If the request is completed faster than this delay, wait the remaining time before executing the callbacks\n * @param {String} [options.postBody] POST request body. If not specified, it's filled with the contents from parameters\n * @param {String} [options.contentType] Content-type header to be sent. Defaults to 'application/x-www-form-urlencoded'\n * @param {Object} [options.requestHeaders] Key-value pairs for additional request headers\n * @param {Function} [options.onComplete] Callback executed after the request is completed, regardless of what happened during the request.\n * @param {Function} [options.onSuccess] Callback executed if the request is successful (requests with 2xx status codes)\n * @param {Function} [options.onFailure] Callback executed if the request fails (requests with status codes different from 2xx)\n * @param {Function} [options.onException] Callback executed if an exception occurs. Receives the exception as a parameter.\n * @param {Function} [options.onCreate] Callback executed after object initialization but before the request is made\n * @param {Function} [options.onInit] Callback executed before any initialization\n * @param {Function} [options.onTimeout] Callback executed if the request times out\n * @param {Boolean|String} [options.evalJS]=true If the request Content-type header is application/json, evaluates the response and populates responseJSON. Use 'force' if you want to force the response evaluation, no matter what Content-type it's using.\n * @param {Boolean} [options.sanitizeJSON] Flag to sanitize the content of responseText before evaluation\n * @param {String} [options.xhrProxy] URI for proxy service hosted on the same server as the web app, that can fetch documents from other domains. The service must pipe all input and output untouched (some input sanitization is allowed, like clearing cookies). e.g., requesting http://example.org/doc can become /proxy/http%3A%2F%2Fexample.org%2Fdoc The proxy service will be used for cross-domain requests, if set, else a network error is returned as exception.\n *\n * @sample Ink_Net_Ajax_1.html \n */\n var Ajax = function(url, options){\n\n // start of AjaxMock patch - uncomment to enable it\n /*var AM = SAPO.Communication.AjaxMock;\n if (AM && !options.inMock) {\n if (AM.autoRecordThisUrl && AM.autoRecordThisUrl(url)) {\n return new AM.Record(url, options);\n }\n if (AM.mockThisUrl && AM.mockThisUrl(url)) {\n return new AM.Play(url, options, true);\n }\n }*/\n // end of AjaxMock patch\n\n this.init(url, options);\n };\n\n /**\n * Options for all requests. These can then be overriden for individual ones.\n */\n Ajax.globalOptions = {\n parameters: {},\n requestHeaders: {}\n };\n\n\n // IE10 does not need XDomainRequest\n var xMLHttpRequestWithCredentials = 'XMLHttpRequest' in window && 'withCredentials' in (new XMLHttpRequest());\n\n\n\n Ajax.prototype = {\n\n init: function(url, userOptions) {\n if (!url) {\n throw new Error(\"WRONG_ARGUMENTS_ERR\");\n }\n var options = Ink.extendObj({\n asynchronous: true,\n method: 'POST',\n parameters: null,\n timeout: 0,\n delay: 0,\n postBody: '',\n contentType: 'application/x-www-form-urlencoded',\n requestHeaders: null,\n onComplete: null,\n onSuccess: null,\n onFailure: null,\n onException: null,\n onHeaders: null,\n onCreate: null,\n onInit: null,\n onTimeout: null,\n sanitizeJSON: false,\n evalJS: true,\n xhrProxy: '',\n cors: false,\n debug: false,\n useCredentials: false,\n signRequest: false\n }, Ajax.globalOptions);\n\n if (userOptions && typeof userOptions === 'object') {\n options = Ink.extendObj(options, userOptions);\n\n\n if (typeof userOptions.parameters === 'object') {\n options.parameters = Ink.extendObj(Ink.extendObj({}, Ajax.globalOptions.parameters), userOptions.parameters);\n } else if (userOptions.parameters !== null) {\n var globalParameters = this.paramsObjToStr(Ajax.globalOptions.parameters);\n if (globalParameters) {\n options.parameters = userOptions.parameters + '&' + globalParameters;\n }\n }\n\n options.requestHeaders = Ink.extendObj({}, Ajax.globalOptions.requestHeaders);\n options.requestHeaders = Ink.extendObj(options.requestHeaders, userOptions.requestHeaders);\n }\n\n this.options = options;\n\n this.safeCall('onInit');\n\n this.url = url;\n\n var urlLocation = this._locationFromURL(url);\n this.isHTTP = this._locationIsHTTP(urlLocation);\n this.isCrossDomain = this._locationIsCrossDomain(urlLocation, location);\n\n this.requestHasBody = options.method.search(/^get|head$/i) < 0;\n\n if(this.options.cors) {\n this.isCrossDomain = false;\n }\n\n this.transport = this.getTransport();\n\n this.request();\n },\n\n /**\n * Returns a location object from an URL\n *\n * @method _locationFromUrl\n * @param url\n * @private\n **/\n _locationFromURL: function (url) {\n var urlLocation = document.createElementNS ?\n document.createElementNS('http://www.w3.org/1999/xhtml', 'a') :\n document.createElement('a');\n urlLocation.href = url;\n return urlLocation;\n },\n\n /**\n * Checks whether a location is HTTP or HTTPS\n *\n * @method locationIsHttp\n * @param urlLocation\n * @private\n */\n _locationIsHTTP: function (urlLocation) {\n return urlLocation.protocol.match(/^https?:/i) ? true : false;\n },\n\n /**\n * Checks whether a location is cross-domain from another\n *\n * @method _locationIsCrossDomain\n * @param urlLocation {Location}\n * @param otherLocation {Location}\n */\n _locationIsCrossDomain: function (urlLocation, location) {\n location = location || window.location;\n if (!Ajax.prototype._locationIsHTTP(urlLocation) || location.protocol === 'widget:' || typeof window.widget === 'object') {\n return false;\n } else {\n return location.protocol !== urlLocation.protocol ||\n location.host.split(':')[0] !== urlLocation.host.split(':')[0];\n }\n },\n\n /**\n * Creates the appropriate XMLHttpRequest object\n *\n * @method getTransport\n * @return {Object} XMLHttpRequest object\n */\n getTransport: function()\n {\n /*global XDomainRequest:false, ActiveXObject:false */\n if (!xMLHttpRequestWithCredentials && this.options.cors && 'XDomainRequest' in window) {\n this.usingXDomainReq = true;\n return new XDomainRequest();\n }\n else if (typeof XMLHttpRequest !== 'undefined') {\n return new XMLHttpRequest();\n }\n else if (typeof ActiveXObject !== 'undefined') {\n try {\n return new ActiveXObject('Msxml2.XMLHTTP');\n } catch (e) {\n return new ActiveXObject('Microsoft.XMLHTTP');\n }\n } else {\n return null;\n }\n },\n\n /**\n * Set the necessary headers for an ajax request\n *\n * @method setHeaders\n * @param {String} url The url for the request\n */\n setHeaders: function()\n {\n if (this.transport) {\n try {\n var headers = {\n \"Accept\": \"text/javascript,text/xml,application/xml,application/xhtml+xml,text/html,application/json;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1\",\n \"Accept-Language\": navigator.language,\n \"X-Requested-With\": \"XMLHttpRequest\",\n \"X-Ink-Version\": \"2\"\n };\n if (this.options.cors) {\n if (!this.options.signRequest) {\n delete headers['X-Requested-With'];\n }\n delete headers['X-Ink-Version'];\n }\n\n if (this.options.requestHeaders && typeof this.options.requestHeaders === 'object') {\n for(var headerReqName in this.options.requestHeaders) {\n if (this.options.requestHeaders.hasOwnProperty(headerReqName)) {\n headers[headerReqName] = this.options.requestHeaders[headerReqName];\n }\n }\n }\n\n if (this.transport.overrideMimeType && (navigator.userAgent.match(/Gecko\\/(\\d{4})/) || [0,2005])[1] < 2005) {\n headers.Connection = 'close';\n }\n\n for (var headerName in headers) {\n if(headers.hasOwnProperty(headerName)) {\n this.transport.setRequestHeader(headerName, headers[headerName]);\n }\n }\n } catch(e) {}\n }\n },\n\n /**\n * Converts an object with parameters to a querystring\n *\n * @method paramsObjToStr\n * @param {Object|String} optParams parameters object\n * @return {String} querystring\n */\n paramsObjToStr: function(optParams) {\n var k, m, p, a, params = [];\n if (typeof optParams === 'object') {\n for (p in optParams){\n if (optParams.hasOwnProperty(p)) {\n a = optParams[p];\n if (Object.prototype.toString.call(a) === '[object Array]' && !isNaN(a.length)) {\n for (k = 0, m = a.length; k < m; k++) {\n params = params.concat([\n encodeURIComponent(p), '[]', '=',\n encodeURIComponent(a[k]), '&'\n ]);\n }\n }\n else {\n params = params.concat([\n encodeURIComponent(p), '=',\n encodeURIComponent(a), '&'\n ]);\n }\n }\n }\n if (params.length > 0) {\n params.pop();\n }\n }\n else\n {\n return optParams;\n }\n return params.join('');\n },\n\n /**\n * Set the url parameters for a GET request\n *\n * @method setParams\n */\n setParams: function()\n {\n var params = null, optParams = this.options.parameters;\n\n if(typeof optParams === \"object\"){\n params = this.paramsObjToStr(optParams);\n } else {\n params = '' + optParams;\n }\n\n if(params){\n if(this.url.indexOf('?') > -1) {\n this.url = this.url.split('#')[0] + '&' + params;\n } else {\n this.url = this.url.split('#')[0] + '?' + params;\n }\n }\n },\n\n /**\n * Gets an HTTP header from the response\n *\n * @method getHeader\n * @param {String} name Header name\n * @return {String} header Content\n */\n getHeader: function(name)\n {\n if (this.usingXDomainReq && name === 'Content-Type') {\n return this.transport.contentType;\n }\n try{\n return this.transport.getResponseHeader(name);\n } catch(e) {\n return null;\n }\n },\n\n /**\n * Gets all the HTTP headers from the response\n *\n * @method getAllHeaders\n * @return {String} The headers, each separated by a newline\n */\n getAllHeaders: function()\n {\n try {\n return this.transport.getAllResponseHeaders();\n } catch(e) {\n return null;\n }\n },\n\n /**\n * Sets the response object\n *\n * @method getResponse\n * @return {Object} the response object\n */\n getResponse: function(){\n // setup our own stuff\n var t = this.transport,\n r = {\n headerJSON: null,\n responseJSON: null,\n getHeader: this.getHeader,\n getAllHeaders: this.getAllHeaders,\n request: this,\n transport: t,\n timeTaken: new Date() - this.startTime,\n requestedUrl: this.url\n };\n\n // setup things expected from the native object\n r.readyState = t.readyState;\n try { r.responseText = t.responseText; } catch(e) {}\n try { r.responseXML = t.responseXML; } catch(e) {}\n try { r.status = t.status; } catch(e) { r.status = 0; }\n try { r.statusText = t.statusText; } catch(e) { r.statusText = ''; }\n\n return r;\n },\n\n /**\n * Aborts the request if still running. No callbacks are called\n *\n * @method abort\n */\n abort: function(){\n if (this.transport) {\n clearTimeout(this.delayTimeout);\n clearTimeout(this.stoTimeout);\n try { this.transport.abort(); } catch(ex) {}\n this.finish();\n }\n },\n\n /**\n * Executes the state changing phase of an ajax request\n *\n * @method runStateChange\n */\n runStateChange: function()\n {\n var rs = this.transport.readyState;\n if (rs === 3) {\n if (this.isHTTP) {\n this.safeCall('onHeaders');\n }\n } else if (rs === 4 || this.usingXDomainReq) {\n\n if (this.options.asynchronous && this.options.delay && (this.startTime + this.options.delay > new Date().getTime())) {\n this.delayTimeout = setTimeout(Ink.bind(this.runStateChange, this), this.options.delay + this.startTime - new Date().getTime());\n return;\n }\n\n var responseJSON,\n responseContent = this.transport.responseText,\n response = this.getResponse(),\n curStatus = this.transport.status;\n\n if (this.isHTTP && !this.options.asynchronous) {\n this.safeCall('onHeaders');\n }\n\n clearTimeout(this.stoTimeout);\n\n if (curStatus === 0) {\n // Status 0 indicates network error for http requests.\n // For http less requests, 0 is always returned.\n if (this.isHTTP) {\n this.safeCall('onException', this.makeError(18, 'NETWORK_ERR'));\n } else {\n curStatus = responseContent ? 200 : 404;\n }\n }\n else if (curStatus === 304) {\n curStatus = 200;\n }\n var isSuccess = this.usingXDomainReq || 200 <= curStatus && curStatus < 300;\n\n var headerContentType = this.getHeader('Content-Type') || '';\n if (this.options.evalJS &&\n (headerContentType.indexOf(\"application/json\") >= 0 || this.options.evalJS === 'force')){\n try {\n responseJSON = this.evalJSON(responseContent, this.sanitizeJSON);\n if(responseJSON){\n responseContent = response.responseJSON = responseJSON;\n }\n } catch(e){\n if (isSuccess) {\n // If the request failed, then this is perhaps an error page\n // so don't notify error.\n this.safeCall('onException', e);\n }\n }\n }\n\n if (this.usingXDomainReq && headerContentType.indexOf('xml') !== -1 && 'DOMParser' in window) {\n // http://msdn.microsoft.com/en-us/library/ie/ff975278(v=vs.85).aspx\n var mimeType;\n switch (headerContentType) {\n case 'application/xml':\n case 'application/xhtml+xml':\n case 'image/svg+xml':\n mimeType = headerContentType;\n break;\n default:\n mimeType = 'text/xml';\n }\n var xmlDoc = (new DOMParser()).parseFromString( this.transport.responseText, mimeType);\n this.transport.responseXML = xmlDoc;\n response.responseXML = xmlDoc;\n }\n\n if (this.transport.responseXML !== null && response.responseJSON === null && this.transport.responseXML.xml !== \"\"){\n responseContent = this.transport.responseXML;\n }\n\n if (curStatus || this.usingXDomainReq) {\n if (isSuccess) {\n this.safeCall('onSuccess', response, responseContent);\n } else {\n this.safeCall('onFailure', response, responseContent);\n }\n this.safeCall('on'+curStatus, response, responseContent);\n }\n this.finish(response, responseContent);\n }\n },\n\n /**\n * Last step after XHR is complete. Call onComplete and cleanup object\n *\n * @method finish\n * @param {Any} response\n * @param {Any} responseContent\n */\n finish: function(response, responseContent){\n if (response) {\n this.safeCall('onComplete', response, responseContent);\n }\n clearTimeout(this.stoTimeout);\n\n if (this.transport) {\n // IE6 sometimes barfs on this one\n try{ this.transport.onreadystatechange = null; } catch(e){}\n\n if (typeof this.transport.destroy === 'function') {\n // Stuff for Samsung.\n this.transport.destroy();\n }\n\n // Let XHR be collected.\n this.transport = null;\n }\n },\n\n /**\n * Safely calls a callback function.\n * Verifies that the callback is well defined and traps errors\n *\n * @method safeCall\n * @param {Function} listener\n */\n safeCall: function(listener, first/*, second*/) {\n function rethrow(exception){\n setTimeout(function() {\n // Rethrow exception so it'll land in\n // the error console, firebug, whatever.\n if (exception.message) {\n exception.message += '\\n'+(exception.stacktrace || exception.stack || '');\n }\n throw exception;\n }, 1);\n }\n if (typeof this.options[listener] === 'function') {\n //SAPO.safeCall(this, this.options[listener], first, second);\n //return object[listener].apply(object, [].slice.call(arguments, 2));\n try {\n this.options[listener].apply(this, [].slice.call(arguments, 1));\n } catch(ex) {\n rethrow(ex);\n }\n } else if (first && window.Error && (first instanceof Error)) {\n rethrow(first);\n }\n },\n\n /**\n * Sets a new request header for the next http request\n *\n * @method setRequestHeader\n * @param {String} name\n * @param {String} value\n */\n setRequestHeader: function(name, value){\n if (!this.options.requestHeaders) {\n this.options.requestHeaders = {};\n }\n this.options.requestHeaders[name] = value;\n },\n\n /**\n * Executes the request\n *\n * @method request\n */\n request: function()\n {\n if(this.transport) {\n var params = null;\n if(this.requestHasBody) {\n if(this.options.postBody !== null && this.options.postBody !== '') {\n params = this.options.postBody;\n this.setParams();\n } else if (this.options.parameters !== null && this.options.parameters !== ''){\n params = this.options.parameters;\n }\n\n if (typeof params === \"object\" && !params.nodeType) {\n params = this.paramsObjToStr(params);\n } else if (typeof params !== \"object\" && params !== null){\n params = '' + params;\n }\n\n if(this.options.contentType) {\n this.setRequestHeader('Content-Type', this.options.contentType);\n }\n } else {\n this.setParams();\n }\n\n var url = this.url;\n var method = this.options.method;\n var crossDomain = this.isCrossDomain;\n\n if (crossDomain && this.options.xhrProxy) {\n this.setRequestHeader('X-Url', url);\n url = this.options.xhrProxy + encodeURIComponent(url);\n crossDomain = false;\n }\n\n try {\n this.transport.open(method, url, this.options.asynchronous);\n } catch(e) {\n this.safeCall('onException', e);\n return this.finish(this.getResponse(), null);\n }\n\n this.setHeaders();\n\n this.safeCall('onCreate');\n\n if(this.options.timeout && !isNaN(this.options.timeout)) {\n this.stoTimeout = setTimeout(Ink.bind(function() {\n if(this.options.onTimeout) {\n this.safeCall('onTimeout');\n this.abort();\n }\n }, this), (this.options.timeout * 1000));\n }\n\n if(this.options.useCredentials && !this.usingXDomainReq) {\n this.transport.withCredentials = true;\n }\n\n if(this.options.asynchronous && !this.usingXDomainReq) {\n this.transport.onreadystatechange = Ink.bind(this.runStateChange, this);\n }\n else if (this.usingXDomainReq) {\n this.transport.onload = Ink.bind(this.runStateChange, this);\n }\n\n try {\n if (crossDomain) {\n // Need explicit handling because Mozila aborts\n // the script and Chrome fails silently.per the spec\n throw this.makeError(18, 'NETWORK_ERR');\n } else {\n this.startTime = new Date().getTime();\n this.transport.send(params);\n }\n } catch(e) {\n this.safeCall('onException', e);\n return this.finish(this.getResponse(), null);\n }\n\n if(!this.options.asynchronous) {\n this.runStateChange();\n }\n }\n },\n\n /**\n * Returns a new exception object that can be thrown\n *\n * @method makeError\n * @param code Error Code\n * @param message Message\n * @returns {Object}\n */\n makeError: function(code, message){\n if (typeof Error !== 'function') {\n return {code: code, message: message};\n }\n var e = new Error(message);\n e.code = code;\n return e;\n },\n\n /**\n * Checks if a given string is valid JSON\n *\n * @method isJSON\n * @param {String} str String to be evaluated\n * @return {Boolean} True if the string is valid JSON\n */\n isJSON: function(str)\n {\n if (typeof str !== \"string\" || !str){ return false; }\n str = str.replace(/\\\\./g, '@').replace(/\"[^\"\\\\\\n\\r]*\"/g, '');\n return (/^[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t]*$/).test(str);\n },\n\n /**\n * Evaluates a given string as JSON\n *\n * @method evalJSON\n * @param {String} str String to be evaluated\n * @param {Boolean} sanitize Flag to sanitize the content\n * @return {Object} JSON content as an object\n */\n evalJSON: function(strJSON, sanitize)\n {\n if (strJSON && (!sanitize || this.isJSON(strJSON))) {\n try {\n if (typeof JSON !== \"undefined\" && typeof JSON.parse !== 'undefined'){\n return JSON.parse(strJSON);\n }\n /*jshint evil:true */\n return eval('(' + strJSON + ')');\n } catch(e) {\n throw new Error('ERROR: Bad JSON string...');\n }\n }\n return null;\n }\n };\n\n /**\n * Loads content from a given url through an XMLHttpRequest.\n *\n * Shortcut function for simple AJAX use cases. Works with JSON, XML and plain text.\n *\n * @method load\n * @param {String} url Request URL\n * @param {Function} callback Callback to be executed if the request is successful\n * @return {Object} XMLHttpRequest object\n *\n * @sample Ink_Net_Ajax_load.html \n */\n Ajax.load = function(url, callback){\n return new Ajax(url, {\n method: 'GET',\n onSuccess: function(response){\n callback(response.responseJSON || response.responseText, response);\n }\n });\n };\n\n /**\n * Loads content from a given url through an XMLHttpRequest.\n * Shortcut function for simple AJAX use cases.\n *\n * @method ping\n * @param {String} url Request url\n * @param {Function} callback Callback to be executed if the request is successful\n * @return {Object} XMLHttpRequest object\n */\n Ajax.ping = function(url, callback){\n return new Ajax(url, {\n method: 'HEAD',\n onSuccess: function(response){\n if (typeof callback === 'function'){\n callback(response);\n }\n }\n });\n };\n\n\n return Ajax;\n});\n","/**\n * Cross Browser JsonP requests\n * @module Ink.Net.JsonP_1\n * @version 1\n */\n\nInk.createModule('Ink.Net.JsonP', '1', [], function() {\n\n 'use strict';\n\n /**\n * Executes a JSONP request\n *\n * @class Ink.Net.JsonP\n * @constructor\n *\n * @param {String} uri Request URL\n * @param {Object} options Request options\n * @param {Function} options.onSuccess Success callback\n * @param {Function} [options.onFailure] Failure callback\n * @param {Object} [options.failureObj] Object to be passed as argument to failure callback\n * @param {Number} [options.timeout] Timeout for request fail, in seconds. defaults to 10\n * @param {Object} [options.params] Object with the parameters and respective values to unfold\n * @param {String} [options.callbackParam] Parameter to use as callback. defaults to 'jsoncallback'\n * @param {String} [options.internalCallback] Name of the callback function stored in the Ink.Net.JsonP object.\n * @param {String} [options.randVar] (Advanced, not recommended unless you know what you're doing) A string to append to the callback name. By default, generate a random number. Use an empty string if you already passed the correct name in the internalCallback option.\n *\n * @sample Ink_Net_JsonP_1.html \n */\n var JsonP = function(uri, options) {\n this.init(uri, options);\n };\n\n JsonP.prototype = {\n\n init: function(uri, options) {\n this.options = Ink.extendObj( {\n onSuccess: undefined,\n onFailure: undefined,\n failureObj: {},\n timeout: 10,\n params: {},\n callbackParam: 'jsoncallback',\n internalCallback: '_cb',\n randVar: false\n }, options || {});\n\n if(this.options.randVar !== false) {\n this.randVar = this.options.randVar;\n } else {\n this.randVar = parseInt(Math.random() * 100000, 10);\n }\n\n this.options.internalCallback += this.randVar;\n\n this.uri = uri;\n\n // prevent SAPO legacy onComplete - make it onSuccess\n if(typeof(this.options.onComplete) === 'function') {\n this.options.onSuccess = this.options.onComplete;\n }\n\n if (typeof this.uri !== 'string') {\n throw 'Please define an URI';\n }\n\n if (typeof this.options.onSuccess !== 'function') {\n throw 'please define a callback function on option onSuccess!';\n }\n\n Ink.Net.JsonP[this.options.internalCallback] = Ink.bind(function() {\n window.clearTimeout(this.timeout);\n delete window.Ink.Net.JsonP[this.options.internalCallback];\n this._removeScriptTag();\n this.options.onSuccess(arguments[0]);\n }, this);\n\n this._addScriptTag();\n },\n\n _addParamsToGet: function(uri, params) {\n var hasQuestionMark = uri.indexOf('?') !== -1;\n var sep, pKey, pValue, parts = [uri];\n\n for (pKey in params) {\n if (params.hasOwnProperty(pKey)) {\n if (!hasQuestionMark) { sep = '?'; hasQuestionMark = true; }\n else { sep = '&'; }\n pValue = params[pKey];\n if (typeof pValue !== 'number' && !pValue) { pValue = ''; }\n parts = parts.concat([sep, pKey, '=', encodeURIComponent(pValue)]);\n }\n }\n\n return parts.join('');\n },\n\n _getScriptContainer: function() {\n var headEls = document.getElementsByTagName('head');\n if (headEls.length === 0) {\n var scriptEls = document.getElementsByTagName('script');\n return scriptEls[0];\n }\n return headEls[0];\n },\n\n _addScriptTag: function() {\n // enrich options will callback and random seed\n this.options.params[this.options.callbackParam] = 'Ink.Net.JsonP.' + this.options.internalCallback;\n this.options.params.rnd_seed = this.randVar;\n this.uri = this._addParamsToGet(this.uri, this.options.params);\n // create script tag\n var scriptEl = document.createElement('script');\n scriptEl.type = 'text/javascript';\n scriptEl.src = this.uri;\n var scriptCtn = this._getScriptContainer();\n scriptCtn.appendChild(scriptEl);\n this.timeout = setTimeout(Ink.bind(this._requestFailed, this), (this.options.timeout * 1000));\n },\n\n _requestFailed : function () {\n delete Ink.Net.JsonP[this.options.internalCallback];\n this._removeScriptTag();\n if(typeof this.options.onFailure === 'function'){\n this.options.onFailure(this.options.failureObj);\n }\n },\n\n _removeScriptTag: function() {\n var scriptEl;\n var scriptEls = document.getElementsByTagName('script');\n var scriptUri;\n for (var i = 0, f = scriptEls.length; i < f; ++i) {\n scriptEl = scriptEls[i];\n scriptUri = scriptEl.getAttribute('src') || scriptEl.src;\n if (scriptUri !== null && scriptUri === this.uri) {\n scriptEl.parentNode.removeChild(scriptEl);\n return;\n }\n }\n }\n\n };\n\n return JsonP;\n\n});\n","/**\n * Browser Detection and User Agent sniffing\n * @module Ink.Dom.Browser_1\n * @version 1\n */\nInk.createModule('Ink.Dom.Browser', '1', [], function() {\n 'use strict'; \n\n /**\n * @namespace Ink.Dom.Browser\n * @version 1\n * @static\n * @example\n * <script>\n * Ink.requireModules(['Ink.Dom.Browser_1'],function( InkBrowser ){\n * if( InkBrowser.CHROME ){\n * console.log( 'This is a CHROME browser.' );\n * }\n * });\n * </script>\n */\n var Browser = {\n /**\n * True if the browser is Internet Explorer\n *\n * @property IE\n * @type {Boolean}\n * @public\n * @static\n */\n IE: false,\n\n /**\n * True if the browser is Gecko based\n *\n * @property GECKO\n * @type {Boolean}\n * @public\n * @static\n */\n GECKO: false,\n\n /**\n * True if the browser is Opera\n *\n * @property OPERA\n * @type {Boolean}\n * @public\n * @static\n */\n OPERA: false,\n\n /**\n * True if the browser is Safari\n *\n * @property SAFARI\n * @type {Boolean}\n * @public\n * @static\n */\n SAFARI: false,\n\n /**\n * True if the browser is Konqueror\n *\n * @property KONQUEROR\n * @type {Boolean}\n * @public\n * @static\n */\n KONQUEROR: false,\n\n /**\n * True if browser is Chrome\n *\n * @property CHROME\n * @type {Boolean}\n * @public\n * @static\n */\n CHROME: false,\n\n /**\n * The specific browser model.\n * False if it is unavailable.\n *\n * @property model\n * @type {Boolean|String}\n * @public\n * @static\n */\n model: false,\n\n /**\n * The browser version.\n * False if it is unavailable.\n *\n * @property version\n * @type {Boolean|String}\n * @public\n * @static\n */\n version: false,\n\n /**\n * The user agent string.\n * False if it is unavailable.\n *\n * @property userAgent\n * @type {Boolean|String}\n * @public\n * @static\n */\n userAgent: false,\n\n /**\n * The CSS prefix (-moz-, -webkit-, -ms-, ...)\n * False if it is unavailable \n *\n * @property cssPrefix \n * @type {Boolean|String}\n * @public \n * @static \n */\n cssPrefix: false, \n\n /**\n * The DOM prefix (Moz, Webkit, ms, ...)\n * False if it is unavailable \n * @property domPrefix \n * @type {Boolean|String}\n * @public \n * @static \n */\n domPrefix: false,\n\n /**\n * Initialization function for the Browser object.\n *\n * Is called automatically when this module is loaded, and calls setDimensions, setBrowser and setReferrer.\n *\n * @method init\n * @public\n */\n init: function() {\n this.detectBrowser();\n this.setDimensions();\n this.setReferrer();\n },\n\n /**\n * Retrieves and stores window dimensions in this object. Called automatically when this module is loaded.\n *\n * @method setDimensions\n * @public\n */\n setDimensions: function() {\n //this.windowWidth=window.innerWidth !== null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body !== null ? document.body.clientWidth : null;\n //this.windowHeight=window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;\n var myWidth = 0, myHeight = 0;\n if ( typeof window.innerWidth=== 'number' ) {\n myWidth = window.innerWidth;\n myHeight = window.innerHeight;\n } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {\n myWidth = document.documentElement.clientWidth;\n myHeight = document.documentElement.clientHeight;\n } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {\n myWidth = document.body.clientWidth;\n myHeight = document.body.clientHeight;\n }\n this.windowWidth = myWidth;\n this.windowHeight = myHeight;\n },\n\n /**\n * Stores the referrer. Called automatically when this module is loaded.\n *\n * @method setReferrer\n * @public\n */\n setReferrer: function() {\n if (document.referrer && document.referrer.length) {\n this.referrer = window.escape(document.referrer);\n } else {\n this.referrer = false;\n }\n },\n\n /**\n * Detects the browser and stores the found properties. Called automatically when this module is loaded.\n *\n * @method detectBrowser\n * @public\n */\n detectBrowser: function() {\n this._sniffUserAgent(navigator.userAgent);\n },\n\n _sniffUserAgent: function (sAgent) {\n this.userAgent = sAgent;\n\n sAgent = sAgent.toLowerCase();\n\n if (/applewebkit\\//.test(sAgent)) {\n this.cssPrefix = '-webkit-';\n this.domPrefix = 'Webkit';\n if(/(chrome|crios)\\//.test(sAgent)) {\n // Chrome\n this.CHROME = true;\n this.model = 'chrome';\n this.version = sAgent.replace(/(.*)chrome\\/([^\\s]+)(.*)/, \"$2\");\n } else {\n // Safari\n this.SAFARI = true;\n this.model = 'safari';\n var rVersion = /version\\/([^) ]+)/;\n if (rVersion.test(sAgent)) {\n this.version = sAgent.match(rVersion)[1];\n } else {\n this.version = sAgent.replace(/(.*)applewebkit\\/([^\\s]+)(.*)/, \"$2\");\n }\n }\n } else if (/opera/.test(sAgent)) {\n // Opera\n this.OPERA = true;\n this.model = 'opera';\n this.version = sAgent.replace(/(.*)opera.([^\\s$]+)(.*)/, \"$2\");\n this.cssPrefix = '-o-';\n this.domPrefix = 'O';\n } else if (/konqueror/.test(sAgent)) {\n // Konqueroh\n this.KONQUEROR = true;\n this.model = 'konqueror';\n this.version = sAgent.replace(/(.*)konqueror\\/([^;]+);(.*)/, \"$2\");\n this.cssPrefix = '-khtml-';\n this.domPrefix = 'Khtml';\n } else if (/(msie|trident)/i.test(sAgent)) {\n // MSIE\n this.IE = true;\n this.model = 'ie';\n if (/rv:((?:\\d|\\.)+)/.test(sAgent)) { // IE 11\n this.version = sAgent.match(/rv:((?:\\d|\\.)+)/)[1];\n } else {\n this.version = sAgent.replace(/(.*)\\smsie\\s([^;]+);(.*)/, \"$2\");\n }\n this.cssPrefix = '-ms-';\n this.domPrefix = 'ms';\n } else if (/gecko/.test(sAgent)) {\n // GECKO\n // Supports only:\n // Camino, Chimera, Epiphany, Minefield (firefox 3), Firefox, Firebird, Phoenix, Galeon,\n // Iceweasel, K-Meleon, SeaMonkey, Netscape, Songbird, Sylera,\n this.cssPrefix = '-moz-';\n this.domPrefix = 'Moz';\n\n this.GECKO = true;\n\n var re = /(camino|chimera|epiphany|minefield|firefox|firebird|phoenix|galeon|iceweasel|k\\-meleon|seamonkey|netscape|songbird|sylera)/;\n if(re.test(sAgent)) {\n this.model = sAgent.match(re)[1];\n this.version = sAgent.replace(new RegExp(\"(.*)\"+this.model+\"\\/([^;\\\\s$]+)(.*)\"), \"$2\");\n } else {\n // probably is mozilla\n this.model = 'mozilla';\n var reVersion = /(.*)rv:([^)]+)(.*)/;\n if(reVersion.test(sAgent)) {\n this.version = sAgent.replace(reVersion, \"$2\");\n }\n }\n }\n },\n\n /**\n * Debug function which displays browser (and Ink.Dom.Browser) information as an alert message.\n *\n * @method debug\n * @public\n * @sample Ink_Dom_Browser_1_debug.html\n */\n debug: function() {\n /*global alert:false */\n var str = \"known browsers: (ie, gecko, opera, safari, konqueror) \\n\";\n str += [this.IE, this.GECKO, this.OPERA, this.SAFARI, this.KONQUEROR] +\"\\n\";\n str += \"cssPrefix -> \"+this.cssPrefix+\"\\n\";\n str += \"domPrefix -> \"+this.domPrefix+\"\\n\";\n str += \"model -> \"+this.model+\"\\n\";\n str += \"version -> \"+this.version+\"\\n\";\n str += \"\\n\";\n str += \"original UA -> \"+this.userAgent;\n\n alert(str);\n }\n };\n\n Browser.init();\n\n return Browser;\n});\n","/**\n * CSS Utilities and toolbox\n * @module Ink.Dom.Css_1\n * @version 1\n */\n\nInk.createModule( 'Ink.Dom.Css', 1, [], function() {\n\n 'use strict';\n\n // getComputedStyle feature detection.\n var getCs = (\"defaultView\" in document) && (\"getComputedStyle\" in document.defaultView) ? document.defaultView.getComputedStyle : window.getComputedStyle;\n\n /**\n * @namespace Ink.Dom.Css\n * @static\n */\n\n var Css = {\n /**\n * Adds of removes a class.\n * Depending on addRemState, this method either adds a class if it's true or removes if if false.\n *\n * @method addRemoveClassName\n * @param {DOMElement|string} elm DOM element or element id\n * @param {string} className class name to add or remove.\n * @param {boolean} addRemState Whether to add or remove. `true` to add, `false` to remove.\n * @sample Ink_Dom_Css_addRemoveClassName.html \n */\n addRemoveClassName: function(elm, className, addRemState) {\n if (addRemState) {\n return this.addClassName(elm, className);\n }\n this.removeClassName(elm, className);\n },\n\n /**\n * Adds a class to a given element\n *\n * @method addClassName\n * @param {DOMElement|String} elm DOM element or element id\n * @param {String|Array} className Classes \n * @sample Ink_Dom_Css_addClassName.html\n */\n addClassName: function(elm, className) {\n elm = Ink.i(elm);\n if (!elm || !className) { return null; }\n className = ('' + className).split(/[, ]+/);\n var i = 0;\n var len = className.length;\n\n for (; i < len; i++) {\n // remove whitespace and ignore on empty string\n if (className[i].replace(/^\\s+|\\s+$/g, '')) {\n if (typeof elm.classList !== \"undefined\") {\n elm.classList.add(className[i]);\n } else if (!Css.hasClassName(elm, className[i])) {\n elm.className += (elm.className ? ' ' : '') + className[i];\n }\n }\n }\n },\n\n /**\n * Removes a class from a given element\n *\n * @method removeClassName\n * @param {DOMElement|String} elm DOM element or element id\n * @param {String|Array} className Class names to remove. You can either use a space separated string of classnames, comma-separated list or an array\n * @sample Ink_Dom_Css_removeClassName.html \n */\n removeClassName: function(elm, className) {\n elm = Ink.i(elm);\n if (!elm || !className) { return null; }\n \n className = ('' + className).split(/[, ]+/);\n var i = 0;\n var len = className.length;\n\n if (typeof elm.classList !== \"undefined\"){\n for (; i < len; i++) {\n elm.classList.remove(className[i]);\n }\n } else {\n var elmClassName = elm.className || '';\n var re;\n for (; i < len; i++) {\n re = new RegExp(\"(^|\\\\s+)\" + className[i] + \"(\\\\s+|$)\");\n elmClassName = elmClassName.replace(re, ' ');\n }\n elm.className = (elmClassName\n .replace(/^\\s+/, '')\n .replace(/\\s+$/, ''));\n }\n },\n\n /**\n * Alias to addRemoveClassName. \n * Utility function, saves many if/elses.\n *\n * @method setClassName\n * @uses addRemoveClassName\n * @param {DOMElement|String} elm DOM element or element id\n * @param {String|Array} className Class names to add\\remove. Comma separated, space separated or simply an Array\n * @param {Boolean} [add]=false Flag to switch behavior from removal to addition. true to add, false to remove\n */\n setClassName: function(elm, className, add) {\n this.addRemoveClassName(elm, className, add || false);\n },\n\n /**\n * Checks if an element has a class.\n * This method verifies if an element has ONE of a list of classes. If the last argument is flagged as true, instead checks if the element has ALL the classes\n * \n * @method hasClassName\n * @param {DOMElement|String} elm DOM element or element id\n * @param {String|Array} className Class names to test\n * @param {Boolean} [all]=false If flagged as true, it will check if the element contains ALL the CSS classes\n * @return {Boolean} true if a given class is applied to a given element\n * @sample Ink_Dom_Css_hasClassName.html \n */\n hasClassName: function(elm, className, all) {\n elm = Ink.i(elm);\n if (!elm || !className) { return false; }\n\n className = ('' + className).split(/[, ]+/);\n var i = 0;\n var len = className.length;\n var has;\n var re;\n\n for ( ; i < len; i++) {\n if (typeof elm.classList !== \"undefined\"){\n has = elm.classList.contains(className[i]);\n } else {\n var elmClassName = elm.className;\n if (elmClassName === className[i]) {\n has = true;\n } else {\n re = new RegExp(\"(^|\\\\s)\" + className[i] + \"(\\\\s|$)\");\n has = re.test(elmClassName);\n }\n }\n if (has && !all) { return true; } // return if looking for any class\n if (!has && all) { return false; } // return if looking for all classes\n }\n\n if (all) {\n // if we got here, all classes were found so far\n return true;\n } else {\n // if we got here with all == false, no class was found\n return false;\n }\n },\n\n /**\n * Blinks a class from an element\n * Add and removes the class from the element with a timeout, so it blinks\n *\n * @method blinkClass\n * @uses addRemoveClassName\n * @param {DOMElement|String} elm DOM element or element id\n * @param {String|Array} className Class name(s) to blink\n * @param {Number} timeout timeout in ms between adding and removing, default 100 ms\n * @param {Boolean} negate is true, class is removed then added\n * @sample Ink_Dom_Css_blinkClass.html \n */\n blinkClass: function(element, className, timeout, negate){\n element = Ink.i(element);\n Css.addRemoveClassName(element, className, !negate);\n setTimeout(function() {\n Css.addRemoveClassName(element, className, negate);\n }, Number(timeout) || 100);\n },\n\n /**\n * Toggles a class name from a given element\n *\n * @method toggleClassName\n * @param {DOMElement|String} elm DOM element or element id\n * @param {String} className Class name\n * @param {Boolean} [forceAdd] Flag to force adding the the classe names if they don't exist yet.\n * @sample Ink_Dom_Css_toggleClassName.html \n */\n toggleClassName: function(elm, className, forceAdd) {\n if (elm && className){\n if (typeof elm.classList !== \"undefined\" && !/[, ]/.test(className)){\n elm = Ink.i(elm);\n if (elm !== null){\n elm.classList.toggle(className);\n }\n return true;\n }\n }\n\n if (typeof forceAdd !== 'undefined') {\n if (forceAdd === true) {\n Css.addClassName(elm, className);\n }\n else if (forceAdd === false) {\n Css.removeClassName(elm, className);\n }\n } else {\n if (Css.hasClassName(elm, className)) {\n Css.removeClassName(elm, className);\n } else {\n Css.addClassName(elm, className);\n }\n }\n },\n\n /**\n * Sets the opacity of given element \n *\n * @method setOpacity\n * @param {DOMElement|String} elm DOM element or element id\n * @param {Number} value allows 0 to 1(default mode decimal) or percentage (warning using 0 or 1 will reset to default mode)\n * @sample Ink_Dom_Css_setOpacity.html \n */\n setOpacity: function(elm, value) {\n elm = Ink.i(elm);\n if (elm !== null){\n var val = 1;\n\n if (!isNaN(Number(value))){\n if (value <= 0) { val = 0; }\n else if (value <= 1) { val = value; }\n else if (value <= 100) { val = value / 100; }\n else { val = 1; }\n }\n\n if (typeof elm.style.opacity !== 'undefined') {\n elm.style.opacity = val;\n }\n else {\n elm.style.filter = \"alpha(opacity:\"+(val*100|0)+\")\";\n }\n }\n },\n\n /**\n * Converts a css property name to a string in camelcase to be used with CSSStyleDeclaration.\n * @method _camelCase\n * @private\n * @param {String} str String to convert\n * @return {String} Converted string\n */\n _camelCase: function(str) {\n return str ? str.replace(/-(\\w)/g, function (_, $1) {\n return $1.toUpperCase();\n }) : str;\n },\n\n\n /**\n * Gets the value for an element's style attribute\n *\n * @method getStyle\n * @param {DOMElement|String} elm DOM element or element id\n * @param {String} style Which css attribute to fetch\n * @return Style value\n * @sample Ink_Dom_Css_getStyle.html \n */\n getStyle: function(elm, style) {\n elm = Ink.i(elm);\n if (elm !== null && elm.style) {\n style = style === 'float' ? 'cssFloat': this._camelCase(style);\n\n var value = elm.style[style];\n\n if (getCs && (!value || value === 'auto')) {\n var css = getCs(elm, null);\n value = css ? css[style] : null;\n }\n else if (!value && elm.currentStyle) {\n value = elm.currentStyle[style];\n if (value === 'auto' && (style === 'width' || style === 'height')) {\n value = elm[\"offset\" + style.charAt(0).toUpperCase() + style.slice(1)] + \"px\";\n }\n }\n\n if (style === 'opacity') {\n return value ? parseFloat(value, 10) : 1.0;\n }\n else if (style === 'borderTopWidth' || style === 'borderBottomWidth' ||\n style === 'borderRightWidth' || style === 'borderLeftWidth' ) {\n if (value === 'thin') { return '1px'; }\n else if (value === 'medium') { return '3px'; }\n else if (value === 'thick') { return '5px'; }\n }\n\n return value === 'auto' ? null : value;\n }\n },\n\n\n /**\n * Adds CSS rules to an element's style attribute.\n *\n * @method setStyle\n * @param {DOMElement|String} elm DOM element or element id\n * @param {String} style Which css attribute to set\n * @sample Ink_Dom_Css_setStyle.html \n */\n setStyle: function(elm, style) {\n elm = Ink.i(elm);\n if (elm === null) { return; }\n if (typeof style === 'string') {\n elm.style.cssText += '; '+style;\n\n if (style.indexOf('opacity') !== -1) {\n this.setOpacity(elm, style.match(/opacity:\\s*(\\d?\\.?\\d*)/)[1]);\n }\n }\n else {\n for (var prop in style) {\n if (style.hasOwnProperty(prop)){\n if (prop === 'opacity') {\n this.setOpacity(elm, style[prop]);\n }\n else if (prop === 'float' || prop === 'cssFloat') {\n if (typeof elm.style.styleFloat === 'undefined') {\n elm.style.cssFloat = style[prop];\n }\n else {\n elm.style.styleFloat = style[prop];\n }\n } else {\n elm.style[prop] = style[prop];\n }\n }\n }\n }\n },\n\n\n /**\n * Shows an element.\n * Internally it unsets the display property of an element. You can force a specific display property using forceDisplayProperty\n *\n * @method show\n * @param {DOMElement|String} elm DOM element or element id\n * @param {String} [forceDisplayProperty] Css display property to apply on show\n * @sample Ink_Dom_Css_show.html \n */\n show: function(elm, forceDisplayProperty) {\n elm = Ink.i(elm);\n if (elm !== null) {\n elm.style.display = (forceDisplayProperty) ? forceDisplayProperty : '';\n }\n },\n\n /**\n * Hides an element.\n *\n * @method hide\n * @param {DOMElement|String} elm DOM element or element id\n * @sample Ink_Dom_Css_hide.html \n */\n hide: function(elm) {\n elm = Ink.i(elm);\n if (elm !== null) {\n elm.style.display = 'none';\n }\n },\n\n /**\n * Shows or hides an element.\n * If the show parameter is true, it shows the element. Otherwise, hides it.\n *\n * @method showHide\n * @param {DOMElement|String} elm DOM element or element id\n * @param {boolean} [show]=false Whether to show or hide `elm`.\n * @sample Ink_Dom_Css_showHide.html \n */\n showHide: function(elm, show) {\n elm = Ink.i(elm);\n if (elm) {\n elm.style.display = show ? '' : 'none';\n }\n },\n\n /**\n * Toggles an element visibility.\n * \n * @method toggle\n * @param {DOMElement|String} elm DOM element or element id\n * @param {Boolean} forceShow Forces showing if element is hidden\n * @sample Ink_Dom_Css_toggle.html \n */\n toggle: function(elm, forceShow) {\n elm = Ink.i(elm);\n if (elm !== null) {\n if (typeof forceShow !== 'undefined') {\n if (forceShow === true) {\n this.show(elm);\n } else {\n this.hide(elm);\n }\n } else {\n if (this.getStyle(elm,'display').toLowerCase() === 'none') {\n this.show(elm);\n }\n else {\n this.hide(elm);\n }\n }\n }\n },\n\n _getRefTag: function(head){\n if (head.firstElementChild) {\n return head.firstElementChild;\n }\n\n for (var child = head.firstChild; child; child = child.nextSibling){\n if (child.nodeType === 1){\n return child;\n }\n }\n return null;\n },\n\n /**\n * Injects style tags with rules to the page.\n *\n * @method appendStyleTag\n * @param {String} selector The css selector for the rule\n * @param {String} style The content of the style rule\n * @param {Object} options Options for the tag\n * @param {String} [options.type]='text/css' File type\n * @param {Boolean} [options.force]=false If true, the style tag will be appended to end of head\n * \n * @sample Ink_Dom_Css_appendStyleTag.html \n */\n appendStyleTag: function(selector, style, options){\n options = Ink.extendObj({\n type: 'text/css',\n force: false\n }, options || {});\n\n var styles = document.getElementsByTagName(\"style\"),\n oldStyle = false, setStyle = true, i, l;\n\n for (i=0, l=styles.length; i<l; i++) {\n oldStyle = styles[i].innerHTML;\n if (oldStyle.indexOf(selector) >= 0) {\n setStyle = false;\n }\n }\n\n if (setStyle) {\n var defStyle = document.createElement(\"style\"),\n head = document.getElementsByTagName(\"head\")[0],\n refTag = false, styleStr = '';\n\n defStyle.type = options.type;\n\n styleStr += selector +\" {\";\n styleStr += style;\n styleStr += \"} \";\n\n if (typeof defStyle.styleSheet !== \"undefined\") {\n defStyle.styleSheet.cssText = styleStr;\n } else {\n defStyle.appendChild(document.createTextNode(styleStr));\n }\n\n if (options.force){\n head.appendChild(defStyle);\n } else {\n refTag = this._getRefTag(head);\n if (refTag){\n head.insertBefore(defStyle, refTag);\n }\n }\n }\n },\n\n /**\n * Injects an external link tag.\n * This method add a stylesheet to the head of a page\n *\n * @method appendStylesheet\n * @param {String} path File path\n * @param {Object} options Options for the tag\n * @param {String} [options.media]='screen' Media type\n * @param {String} [options.type]='text/css' File type\n * @param {Boolean} [options.force]=false If true, tag will be appended to end of head\n * @sample Ink_Dom_Css_appendStylesheet.html \n */\n appendStylesheet: function(path, options){\n options = Ink.extendObj({\n media: 'screen',\n type: 'text/css',\n force: false\n }, options || {});\n\n var refTag,\n style = document.createElement(\"link\"),\n head = document.getElementsByTagName(\"head\")[0];\n\n style.media = options.media;\n style.type = options.type;\n style.href = path;\n style.rel = \"Stylesheet\";\n\n if (options.force){\n head.appendChild(style);\n }\n else {\n refTag = this._getRefTag(head);\n if (refTag){\n head.insertBefore(style, refTag);\n }\n }\n },\n\n /**\n * Injects an external link tag.\n * Loads CSS via LINK element inclusion in HEAD (skips append if already there)\n *\n * Works similarly to appendStylesheet but:\n * supports optional callback which gets invoked once the CSS has been applied\n *\n * @method appendStylesheetCb\n * @param {String} cssURI URI of the CSS to load, if empty ignores and just calls back directly\n * @param {Function(cssURI)} [callback] optional callback which will be called once the CSS is loaded\n * @sample Ink_Dom_Css_appendStylesheetCb.html \n */\n _loadingCSSFiles: {},\n _loadedCSSFiles: {},\n appendStylesheetCb: function(url, callback) {\n if (!url) {\n return callback(url);\n }\n\n if (this._loadedCSSFiles[url]) {\n return callback(url);\n }\n\n var cbs = this._loadingCSSFiles[url];\n if (cbs) {\n return cbs.push(callback);\n }\n\n this._loadingCSSFiles[url] = [callback];\n\n var linkEl = document.createElement('link');\n linkEl.type = 'text/css';\n linkEl.rel = 'stylesheet';\n linkEl.href = url;\n\n var headEl = document.getElementsByTagName('head')[0];\n headEl.appendChild(linkEl);\n\n var imgEl = document.createElement('img');\n /*\n var _self = this;\n (function(_url) {\n imgEl.onerror = function() {\n //var url = this;\n var url = _url;\n _self._loadedCSSFiles[url] = true;\n var callbacks = _self._loadingCSSFiles[url];\n for (var i = 0, f = callbacks.length; i < f; ++i) {\n callbacks[i](url);\n }\n delete _self._loadingCSSFiles[url];\n };\n })(url);\n */\n imgEl.onerror = Ink.bindEvent(function(event, _url) {\n //var url = this;\n var url = _url;\n this._loadedCSSFiles[url] = true;\n var callbacks = this._loadingCSSFiles[url];\n for (var i = 0, f = callbacks.length; i < f; ++i) {\n callbacks[i](url);\n }\n delete this._loadingCSSFiles[url];\n }, this, url);\n imgEl.src = url;\n },\n\n /**\n * Converts decimal to hexadecimal values\n * Useful to convert colors to their hexadecimal representation.\n *\n * @method decToHex\n * @param {String} dec Either a single decimal value, an rgb(r, g, b) string or an Object with r, g and b properties\n * @return {String} Hexadecimal value\n * @sample Ink_Dom_Css_decToHex.html \n */\n decToHex: function(dec) {\n var normalizeTo2 = function(val) {\n if (val.length === 1) {\n val = '0' + val;\n }\n val = val.toUpperCase();\n return val;\n };\n\n if (typeof dec === 'object') {\n var rDec = normalizeTo2(parseInt(dec.r, 10).toString(16));\n var gDec = normalizeTo2(parseInt(dec.g, 10).toString(16));\n var bDec = normalizeTo2(parseInt(dec.b, 10).toString(16));\n return rDec+gDec+bDec;\n }\n else {\n dec += '';\n var rgb = dec.match(/\\((\\d+),\\s?(\\d+),\\s?(\\d+)\\)/);\n if (rgb !== null) {\n return normalizeTo2(parseInt(rgb[1], 10).toString(16)) +\n normalizeTo2(parseInt(rgb[2], 10).toString(16)) +\n normalizeTo2(parseInt(rgb[3], 10).toString(16));\n }\n else {\n return normalizeTo2(parseInt(dec, 10).toString(16));\n }\n }\n },\n\n /**\n * Converts hexadecimal values to decimal\n * Useful to use with CSS colors\n *\n * @method hexToDec\n * @param {String} hex hexadecimal Value with 6, 3, 2 or 1 characters\n * @return {Number} Object with properties r, g, b if length of number is >= 3 or decimal value instead.\n * @sample Ink_Dom_Css_hexToDec.html \n */\n hexToDec: function(hex){\n if (hex.indexOf('#') === 0) {\n hex = hex.substr(1);\n }\n if (hex.length === 6) { // will return object RGB\n return {\n r: parseInt(hex.substr(0,2), 16),\n g: parseInt(hex.substr(2,2), 16),\n b: parseInt(hex.substr(4,2), 16)\n };\n }\n else if (hex.length === 3) { // will return object RGB\n return {\n r: parseInt(hex.charAt(0) + hex.charAt(0), 16),\n g: parseInt(hex.charAt(1) + hex.charAt(1), 16),\n b: parseInt(hex.charAt(2) + hex.charAt(2), 16)\n };\n }\n else if (hex.length <= 2) { // will return int\n return parseInt(hex, 16);\n }\n },\n\n /**\n * Get a single property from a stylesheet.\n * Use this to obtain the value of a CSS property (searched from loaded CSS documents)\n *\n * @method getPropertyFromStylesheet\n * @param {String} selector a CSS rule. must be an exact match\n * @param {String} property a CSS property\n * @return {String} value of the found property, or null if it wasn't matched\n */\n getPropertyFromStylesheet: function(selector, property) {\n var rule = this.getRuleFromStylesheet(selector);\n if (rule) {\n return rule.style[property];\n }\n return null;\n },\n\n getPropertyFromStylesheet2: function(selector, property) {\n var rules = this.getRulesFromStylesheet(selector);\n /*\n rules.forEach(function(rule) {\n var x = rule.style[property];\n if (x !== null && x !== undefined) {\n return x;\n }\n });\n */\n var x;\n for(var i=0, t=rules.length; i < t; i++) {\n x = rules[i].style[property];\n if (x !== null && x !== undefined) {\n return x;\n }\n }\n return null;\n },\n\n getRuleFromStylesheet: function(selector) {\n var sheet, rules, ri, rf, rule;\n var s = document.styleSheets;\n if (!s) {\n return null;\n }\n\n for (var si = 0, sf = document.styleSheets.length; si < sf; ++si) {\n sheet = document.styleSheets[si];\n rules = sheet.rules ? sheet.rules : sheet.cssRules;\n if (!rules) { return null; }\n\n for (ri = 0, rf = rules.length; ri < rf; ++ri) {\n rule = rules[ri];\n if (!rule.selectorText) { continue; }\n if (rule.selectorText === selector) {\n return rule;\n }\n }\n }\n\n return null;\n },\n\n getRulesFromStylesheet: function(selector) {\n var res = [];\n var sheet, rules, ri, rf, rule;\n var s = document.styleSheets;\n if (!s) { return res; }\n\n for (var si = 0, sf = document.styleSheets.length; si < sf; ++si) {\n sheet = document.styleSheets[si];\n rules = sheet.rules ? sheet.rules : sheet.cssRules;\n if (!rules) {\n return null;\n }\n\n for (ri = 0, rf = rules.length; ri < rf; ++ri) {\n rule = rules[ri];\n if (!rule.selectorText) { continue; }\n if (rule.selectorText === selector) {\n res.push(rule);\n }\n }\n }\n\n return res;\n },\n\n getPropertiesFromRule: function(selector) {\n var rule = this.getRuleFromStylesheet(selector);\n var props = {};\n var prop, i, f;\n\n /*if (typeof rule.style.length === 'snumber') {\n for (i = 0, f = rule.style.length; i < f; ++i) {\n prop = this._camelCase( rule.style[i] );\n props[prop] = rule.style[prop];\n }\n }\n else { // HANDLES IE 8, FIREFOX RULE JOINING... */\n rule = rule.style.cssText;\n var parts = rule.split(';');\n var steps, val, pre, pos;\n for (i = 0, f = parts.length; i < f; ++i) {\n if (parts[i].charAt(0) === ' ') {\n parts[i] = parts[i].substring(1);\n }\n steps = parts[i].split(':');\n prop = this._camelCase( steps[0].toLowerCase() );\n val = steps[1];\n if (val) {\n val = val.substring(1);\n\n if (prop === 'padding' || prop === 'margin' || prop === 'borderWidth') {\n\n if (prop === 'borderWidth') { pre = 'border'; pos = 'Width'; }\n else { pre = prop; pos = ''; }\n\n if (val.indexOf(' ') !== -1) {\n val = val.split(' ');\n props[pre + 'Top' + pos] = val[0];\n props[pre + 'Bottom'+ pos] = val[0];\n props[pre + 'Left' + pos] = val[1];\n props[pre + 'Right' + pos] = val[1];\n }\n else {\n props[pre + 'Top' + pos] = val;\n props[pre + 'Bottom'+ pos] = val;\n props[pre + 'Left' + pos] = val;\n props[pre + 'Right' + pos] = val;\n }\n }\n else if (prop === 'borderRadius') {\n if (val.indexOf(' ') !== -1) {\n val = val.split(' ');\n props.borderTopLeftRadius = val[0];\n props.borderBottomRightRadius = val[0];\n props.borderTopRightRadius = val[1];\n props.borderBottomLeftRadius = val[1];\n }\n else {\n props.borderTopLeftRadius = val;\n props.borderTopRightRadius = val;\n props.borderBottomLeftRadius = val;\n props.borderBottomRightRadius = val;\n }\n }\n else {\n props[prop] = val;\n }\n }\n }\n //}\n //console.log(props);\n\n return props;\n },\n\n /**\n * Change the font size of elements.\n * Changes the font size of the elements which match the given CSS rule\n * For this function to work, the CSS file must be in the same domain than the host page, otherwise JS can't access it.\n *\n * @method changeFontSize\n * @param {String} selector CSS selector rule\n * @param {Number} delta Number of pixels to change on font-size\n * @param {String} [op] Supported operations are '+' and '*'. defaults to '+'\n * @param {Number} [minVal] If result gets smaller than minVal, change does not occurr\n * @param {Number} [maxVal] If result gets bigger than maxVal, change does not occurr\n */\n changeFontSize: function(selector, delta, op, minVal, maxVal) {\n var that = this;\n Ink.requireModules(['Ink.Dom.Selector_1'], function(Selector) {\n var e;\n if (typeof selector !== 'string') { e = '1st argument must be a CSS selector rule.'; }\n else if (typeof delta !== 'number') { e = '2nd argument must be a number.'; }\n else if (op !== undefined && op !== '+' && op !== '*') { e = '3rd argument must be one of \"+\", \"*\".'; }\n else if (minVal !== undefined && (typeof minVal !== 'number' || minVal <= 0)) { e = '4th argument must be a positive number.'; }\n else if (maxVal !== undefined && (typeof maxVal !== 'number' || maxVal < maxVal)) { e = '5th argument must be a positive number greater than minValue.'; }\n if (e) { throw new TypeError(e); }\n\n var val, el, els = Selector.select(selector);\n if (minVal === undefined) { minVal = 1; }\n op = (op === '*') ? function(a,b){return a*b;} : function(a,b){return a+b;};\n for (var i = 0, f = els.length; i < f; ++i) {\n el = els[i];\n val = parseFloat( that.getStyle(el, 'fontSize'));\n val = op(val, delta);\n if (val < minVal) { continue; }\n if (typeof maxVal === 'number' && val > maxVal) { continue; }\n el.style.fontSize = val + 'px';\n }\n });\n }\n\n };\n\n return Css;\n\n});\n","/**\n * DOM Traversal and manipulation\n * @module Ink.Dom.Element_1\n * @version 1\n */\n\nInk.createModule('Ink.Dom.Element', 1, [], function() {\n\n 'use strict';\n\n var createContextualFragmentSupport = (\n typeof document.createRange === 'function' &&\n typeof window.Range.prototype.createContextualFragment === 'function');\n\n var deleteThisTbodyToken = 'Ink.Dom.Element tbody: ' + Math.random();\n var browserCreatesTbodies = (function () {\n var div = document.createElement('div');\n div.innerHTML = '<table>';\n return div.getElementsByTagName('tbody').length !== 0;\n }());\n\n function rect(elem){\n var dimensions = {};\n try {\n dimensions = elem.getBoundingClientRect();\n } catch(e){\n dimensions = { top: elem.offsetTop, left: elem.offsetLeft };\n }\n return dimensions;\n }\n\n /**\n * @namespace Ink.Dom.Element_1\n */\n\n var InkElement = {\n\n /**\n * Checks if something is a DOM Element.\n *\n * @method isDOMElement\n * @static\n * @param {Mixed} o The object to be checked.\n * @return {Boolean} True if it's a valid DOM Element.\n * @example\n * var el = Ink.s('#element');\n * if( InkElement.isDOMElement( el ) === true ){\n * // It is a DOM Element.\n * } else {\n * // It is NOT a DOM Element.\n * }\n */\n isDOMElement: function(o) {\n return o !== null && typeof o === 'object' && 'nodeType' in o && o.nodeType === 1;\n },\n\n /**\n * Shortcut for `document.getElementById`\n *\n * @method get\n * @param {String|DOMElement} elm Either an ID of an element, or an element.\n * @return {DOMElement|null} The DOM element with the given id or null when it was not found\n * @sample Ink_Dom_Element_1_get.html\n */\n get: function(elm) {\n if(typeof elm !== 'undefined') {\n if(typeof elm === 'string') {\n return document.getElementById(elm);\n }\n return elm;\n }\n return null;\n },\n\n /**\n * Creates a DOM element\n *\n * @method create\n * @param {String} tag tag name\n * @param {Object} properties object with properties to be set on the element. You can also call other functions in Ink.Dom.Element like this\n * @sample Ink_Dom_Element_1_create.html\n */\n create: function(tag, properties) {\n var el = document.createElement(tag);\n //Ink.extendObj(el, properties);\n for(var property in properties) {\n if(properties.hasOwnProperty(property)) {\n if (property in InkElement) {\n InkElement[property](el, properties[property]);\n } else {\n if(property === 'className' || property === 'class') {\n el.className = properties.className || properties['class'];\n } else {\n el.setAttribute(property, properties[property]);\n }\n }\n }\n }\n return el;\n },\n\n /**\n * Removes a DOM Element\n *\n * @method remove\n * @param {DOMElement} elm The element to remove\n * @sample Ink_Dom_Element_1_remove.html\n */\n remove: function(el) {\n el = Ink.i(el);\n var parEl;\n if (el && (parEl = el.parentNode)) {\n parEl.removeChild(el);\n }\n },\n\n /**\n * Scrolls the window to an element\n *\n * @method scrollTo\n * @param {DOMElement|String} elm Element where to scroll\n * @sample Ink_Dom_Element_1_scrollTo.html\n */\n scrollTo: function(elm) {\n elm = InkElement.get(elm);\n if(elm) {\n if (elm.scrollIntoView) {\n return elm.scrollIntoView();\n }\n\n var elmOffset = {},\n elmTop = 0, elmLeft = 0;\n\n do {\n elmTop += elm.offsetTop || 0;\n elmLeft += elm.offsetLeft || 0;\n\n elm = elm.offsetParent;\n } while(elm);\n\n elmOffset = {x: elmLeft, y: elmTop};\n\n window.scrollTo(elmOffset.x, elmOffset.y);\n }\n },\n\n /**\n * Gets the top offset of an element\n *\n * @method offsetTop\n * @uses Ink.Dom.Browser\n *\n * @param {DOMElement|String} elm Target element\n * @return {Number} Offset from the target element to the top of the document\n * @sample Ink_Dom_Element_1_offsetTop.html\n */\n offsetTop: function(elm) {\n return InkElement.offset(elm)[1];\n },\n\n /**\n * Gets the left offset of an element\n *\n * @method offsetLeft\n * @uses Ink.Dom.Browser\n *\n * @param {DOMElement|String} elm Target element\n * @return {Number} Offset from the target element to the left of the document\n * @sample Ink_Dom_Element_1_offsetLeft.html\n */\n offsetLeft: function(elm) {\n return InkElement.offset(elm)[0];\n },\n\n /**\n * Gets the relative offset of an element\n *\n * @method positionedOffset\n * @param {DOMElement|String} elm Target element\n * @return {Array} Array with the element offsetleft and offsettop relative to the closest positioned ancestor\n * @sample Ink_Dom_Element_1_positionedOffset.html\n */\n positionedOffset: function(element) {\n var valueTop = 0, valueLeft = 0;\n element = InkElement.get(element);\n do {\n valueTop += element.offsetTop || 0;\n valueLeft += element.offsetLeft || 0;\n element = element.offsetParent;\n if (element) {\n if (element.tagName.toLowerCase() === 'body') { break; }\n\n var value = element.style.position;\n if (!value && element.currentStyle) {\n value = element.currentStyle.position;\n }\n if ((!value || value === 'auto') && typeof getComputedStyle !== 'undefined') {\n var css = getComputedStyle(element, null);\n value = css ? css.position : null;\n }\n if (value === 'relative' || value === 'absolute') { break; }\n }\n } while (element);\n return [valueLeft, valueTop];\n },\n\n /**\n * Gets the cumulative offset for an element\n *\n * Returns the top left position of the element on the page\n *\n * @method offset\n * @uses Ink.Dom.Browser\n *\n * @method offset\n * @param {DOMElement|String} elm Target element\n * @return {[Number, Number]} Array with pixel distance from the target element to the top left corner of the document\n * @sample Ink_Dom_Element_1_offset.html\n */\n offset: function(el) {\n /*jshint boss:true */\n el = Ink.i(el);\n var res = [0, 0];\n var doc = el.ownerDocument,\n docElem = doc.documentElement,\n box = rect(el),\n body = doc.body,\n clientTop = docElem.clientTop || body.clientTop || 0,\n clientLeft = docElem.clientLeft || body.clientLeft || 0,\n scrollTop = doc.pageYOffset || docElem.scrollTop || body.scrollTop,\n scrollLeft = doc.pageXOffset || docElem.scrollLeft || body.scrollLeft,\n top = box.top + scrollTop - clientTop,\n left = box.left + scrollLeft - clientLeft;\n res = [left, top];\n return res;\n },\n\n /**\n * Gets the scroll of the element\n *\n * @method scroll\n * @param {DOMElement|String} [elm] Target element or document.body\n * @returns {Array} offset values for x and y scroll\n * @sample Ink_Dom_Element_1_scroll.html\n */\n scroll: function(elm) {\n elm = elm ? Ink.i(elm) : document.body;\n return [\n ( ( !window.pageXOffset ) ? elm.scrollLeft : window.pageXOffset ),\n ( ( !window.pageYOffset ) ? elm.scrollTop : window.pageYOffset )\n ];\n },\n\n _getPropPx: function(cs, prop) {\n var n, c;\n var val = cs.getPropertyValue ? cs.getPropertyValue(prop) : cs[prop];\n if (!val) { n = 0; }\n else {\n c = val.indexOf('px');\n if (c === -1) { n = 0; }\n else {\n n = parseFloat(val, 10);\n }\n }\n\n //console.log([prop, ' \"', val, '\" ', n].join(''));\n\n return n;\n },\n\n /**\n * Alias for offset()\n *\n * @method offset2\n * @deprecated Kept for historic reasons. Use offset() instead.\n */\n offset2: function(el) {\n return InkElement.offset(el);\n },\n\n /**\n * Checks if an element has an attribute\n *\n * @method hasAttribute\n * @param {Object} elm Target element\n * @param {String} attr Attribute name\n * @return {Boolean} Boolean based on existance of attribute\n * @sample Ink_Dom_Element_1_hasAttribute.html\n */\n hasAttribute: function(elm, attr){\n elm = Ink.i(elm);\n return elm.hasAttribute ? elm.hasAttribute(attr) : !!elm.getAttribute(attr);\n },\n /**\n * Inserts an element right after another\n *\n * @method insertAfter\n * @param {DOMElement} newElm Element to be inserted\n * @param {DOMElement|String} targetElm Key element\n * @sample Ink_Dom_Element_1_insertAfter.html\n */\n insertAfter: function(newElm, targetElm) {\n /*jshint boss:true */\n if (targetElm = InkElement.get(targetElm)) {\n if (targetElm.nextSibling !== null) {\n targetElm.parentNode.insertBefore(newElm, targetElm.nextSibling);\n } else {\n targetElm.parentNode.appendChild(newElm);\n }\n }\n },\n\n /**\n * Inserts an element before another\n *\n * @method insertBefore\n * @param {DOMElement} newElm Element to be inserted\n * @param {DOMElement|String} targetElm Key element\n * @sample Ink_Dom_Element_1_insertBefore.html\n */\n insertBefore: function (newElm, targetElm) {\n /*jshint boss:true */\n if ( (targetElm = InkElement.get(targetElm)) ) {\n targetElm.parentNode.insertBefore(newElm, targetElm);\n }\n },\n\n /**\n * Inserts an element as the first child of another\n *\n * @method insertTop\n * @param {DOMElement} newElm Element to be inserted\n * @param {DOMElement|String} targetElm Key element\n * @sample Ink_Dom_Element_1_insertTop.html\n */\n insertTop: function(newElm,targetElm) {\n /*jshint boss:true */\n if (targetElm = InkElement.get(targetElm)) {\n if (targetElm.firstChild) {\n targetElm.insertBefore(newElm, targetElm.firstChild);\n } else {\n targetElm.appendChild(newElm);\n }\n }\n },\n\n /**\n * Inserts an element as the last child of another\n *\n * @method insertBottom\n * @param {DOMElement} newElm Element to be inserted\n * @param {DOMElement|String} targetElm Key element\n * @sample Ink_Dom_Element_1_insertBottom.html\n */\n insertBottom: function(newElm, targetElm) {\n /*jshint boss:true */\n targetElm = Ink.i(targetElm);\n targetElm.appendChild(newElm);\n },\n\n /**\n * Retrieves textContent from node\n *\n * @method textContent\n * @param {DOMNode} node Where to retreive text from. Can be any node type.\n * @return {String} the text\n * @sample Ink_Dom_Element_1_textContent.html\n */\n textContent: function(node){\n node = Ink.i(node);\n var text, k, cs, m;\n\n switch(node && node.nodeType) {\n case 9: /*DOCUMENT_NODE*/\n // IE quirks mode does not have documentElement\n return InkElement.textContent(node.documentElement || node.body && node.body.parentNode || node.body);\n\n case 1: /*ELEMENT_NODE*/\n text = node.innerText;\n if (typeof text !== 'undefined') {\n return text;\n }\n /* falls through */\n case 11: /*DOCUMENT_FRAGMENT_NODE*/\n text = node.textContent;\n if (typeof text !== 'undefined') {\n return text;\n }\n\n if (node.firstChild === node.lastChild) {\n // Common case: 0 or 1 children\n return InkElement.textContent(node.firstChild);\n }\n\n text = [];\n cs = node.childNodes;\n for (k = 0, m = cs.length; k < m; ++k) {\n text.push( InkElement.textContent( cs[k] ) );\n }\n return text.join('');\n\n case 3: /*TEXT_NODE*/\n case 4: /*CDATA_SECTION_NODE*/\n return node.nodeValue;\n }\n return '';\n },\n\n /**\n * Replaces text content of a DOM Node\n * This method removes any child node previously present\n *\n * @method setTextContent\n * @param {DOMNode} node node Target node where the text will be added.\n * @param {String} text text Text to be added on the node.\n * @sample Ink_Dom_Element_1_setTextContent.html\n */\n setTextContent: function(node, text){\n node = Ink.i(node);\n switch(node && node.nodeType)\n {\n case 1: /*ELEMENT_NODE*/\n if ('innerText' in node) {\n node.innerText = text;\n break;\n }\n /* falls through */\n case 11: /*DOCUMENT_FRAGMENT_NODE*/\n if ('textContent' in node) {\n node.textContent = text;\n break;\n }\n /* falls through */\n case 9: /*DOCUMENT_NODE*/\n while(node.firstChild) {\n node.removeChild(node.firstChild);\n }\n if (text !== '') {\n var doc = node.ownerDocument || node;\n node.appendChild(doc.createTextNode(text));\n }\n break;\n\n case 3: /*TEXT_NODE*/\n case 4: /*CDATA_SECTION_NODE*/\n node.nodeValue = text;\n break;\n }\n },\n\n /**\n * Checks if an element is a link\n *\n * @method isLink\n * @param {DOMNode} node Node to check if it's link\n * @return {Boolean}\n * @sample Ink_Dom_Element_1_isLink.html\n */\n isLink: function(element){\n var b = element && element.nodeType === 1 && ((/^a|area$/i).test(element.tagName) ||\n element.hasAttributeNS && element.hasAttributeNS('http://www.w3.org/1999/xlink','href'));\n return !!b;\n },\n\n /**\n * Checks if a node is an ancestor of another\n *\n * @method isAncestorOf\n * @param {DOMNode} ancestor Ancestor node\n * @param {DOMNode} node Descendant node\n * @return {Boolean}\n * @sample Ink_Dom_Element_1_isAncestorOf.html\n */\n isAncestorOf: function(ancestor, node){\n /*jshint boss:true */\n if (!node || !ancestor) {\n return false;\n }\n if (node.compareDocumentPosition) {\n return (ancestor.compareDocumentPosition(node) & 0x10) !== 0;/*Node.DOCUMENT_POSITION_CONTAINED_BY*/\n }\n while (node = node.parentNode){\n if (node === ancestor){\n return true;\n }\n }\n return false;\n },\n\n /**\n * Checks if a node is descendant of another\n *\n * @method descendantOf\n * @param {DOMNode} node The ancestor\n * @param {DOMNode} descendant The descendant\n * @return {Boolean} true if 'descendant' is descendant of 'node'\n * @sample Ink_Dom_Element_1_descendantOf.html\n */\n descendantOf: function(node, descendant){\n return node !== descendant && InkElement.isAncestorOf(node, descendant);\n },\n\n /**\n * Get first child element of another\n * @method firstElementChild\n * @param {DOMElement} elm Parent node\n * @return {DOMElement} the Element child\n * @sample Ink_Dom_Element_1_firstElementChild.html\n */\n firstElementChild: function(elm){\n if(!elm) {\n return null;\n }\n if ('firstElementChild' in elm) {\n return elm.firstElementChild;\n }\n var child = elm.firstChild;\n while(child && child.nodeType !== 1) {\n child = child.nextSibling;\n }\n return child;\n },\n\n /**\n * Get the last child element of another\n * @method lastElementChild\n * @param {DOMElement} elm Parent node\n * @return {DOMElement} the Element child\n * @sample Ink_Dom_Element_1_lastElementChild.html\n */\n lastElementChild: function(elm){\n if(!elm) {\n return null;\n }\n if ('lastElementChild' in elm) {\n return elm.lastElementChild;\n }\n var child = elm.lastChild;\n while(child && child.nodeType !== 1) {\n child = child.previousSibling;\n }\n return child;\n },\n\n /**\n * Get the first sibling element after the node\n *\n * @method nextElementSibling\n * @param {DOMNode} node The current node\n * @return {DOMElement|Null} The first sibling element after node or null if none is found\n * @sample Ink_Dom_Element_1_nextElementSibling.html \n */\n nextElementSibling: function(node){\n var sibling = null;\n\n if(!node){ return sibling; }\n\n if(\"nextElementSibling\" in node){\n return node.nextElementSibling;\n } else {\n sibling = node.nextSibling;\n\n // 1 === Node.ELEMENT_NODE\n while(sibling && sibling.nodeType !== 1){\n sibling = sibling.nextSibling;\n }\n\n return sibling;\n }\n },\n\n /**\n * Get the first sibling element before the node\n *\n * @method previousElementSibling\n * @param {DOMNode} node The current node\n * @return {DOMElement|Null} The first element sibling before node or null if none is found\n * @sample Ink_Dom_Element_1_previousElementSibling.html \n */\n previousElementSibling: function(node){\n var sibling = null;\n\n if(!node){ return sibling; }\n\n if(\"previousElementSibling\" in node){\n return node.previousElementSibling;\n } else {\n sibling = node.previousSibling;\n\n // 1 === Node.ELEMENT_NODE\n while(sibling && sibling.nodeType !== 1){\n sibling = sibling.previousSibling;\n }\n\n return sibling;\n }\n },\n\n /**\n * Get an element's width in pixels.\n *\n * @method elementWidth\n * @param {DOMElement|String} element Target DOM element or target ID\n * @return {Number} The element's width\n * @sample Ink_Dom_Element_1_elementWidth.html \n */\n elementWidth: function(element) {\n if(typeof element === \"string\") {\n element = document.getElementById(element);\n }\n return element.offsetWidth;\n },\n\n /**\n * Get an element's height in pixels.\n *\n * @method elementHeight\n * @param {DOMElement|String} element DOM element or target ID\n * @return {Number} The element's height\n * @sample Ink_Dom_Element_1_elementHeight.html \n */\n elementHeight: function(element) {\n if(typeof element === \"string\") {\n element = document.getElementById(element);\n }\n return element.offsetHeight;\n },\n\n /**\n * Deprecated. Alias for offsetLeft()\n *\n * @method elementLeft\n * @param {DOMElement|String} element DOM element or target ID\n * @return {Number} Element's left position\n */\n elementLeft: function(element) {\n return InkElement.offsetLeft(element);\n },\n\n /**\n * Deprecated. Alias for offsetTop()\n *\n * @method elementTop\n * @param {DOMElement|string} element Target DOM element or target ID\n * @return {Number} element's top position\n */\n elementTop: function(element) {\n return InkElement.offsetTop(element);\n },\n\n /**\n * Get an element's dimensions in pixels.\n *\n * @method elementDimensions\n * @param {DOMElement|string} element DOM element or target ID\n * @return {Array} Array with element's width and height\n * @sample Ink_Dom_Element_1_elementDimensions.html \n */\n elementDimensions: function(element) {\n element = Ink.i(element);\n return [element.offsetWidth, element.offsetHeight];\n },\n\n /**\n * Get the outer dimensions of an element in pixels.\n *\n * @method outerDimensions\n * @uses Ink.Dom.Css\n *\n * @param {DOMElement} element Target element\n * @return {Array} Array with element width and height.\n * @sample Ink_Dom_Element_1_outerDimensions.html \n */\n outerDimensions: function (element) {\n var bbox = rect(element);\n\n var Css = Ink.getModule('Ink.Dom.Css_1');\n var getStyle = Ink.bindMethod(Css, 'getStyle', element);\n\n return [\n bbox.right - bbox.left + parseFloat(getStyle('marginLeft') || 0) + parseFloat(getStyle('marginRight') || 0), // w\n bbox.bottom - bbox.top + parseFloat(getStyle('marginTop') || 0) + parseFloat(getStyle('marginBottom') || 0) // h\n ];\n },\n\n /**\n * Check if an element is inside the viewport\n *\n * @method inViewport\n * @param {DOMElement} element DOM Element\n * @param {Object} [options] Options object. If you pass a Boolean value here, it is interpreted as `options.partial`\n * @param {Boolean} [options.partial]=false Return `true` even if it is only partially visible.\n * @param {Number} [options.margin]=0 Consider a margin all around the viewport with `opts.margin` width a dead zone.\n * @return {Boolean}\n * @sample Ink_Dom_Element_1_inViewport.html \n */\n inViewport: function (element, opts) {\n var dims = rect(Ink.i(element));\n if (typeof opts === 'boolean') {\n opts = {partial: opts, margin: 0};\n }\n opts = Ink.extendObj({ partial: false, margin: 0}, opts || {});\n if (opts.partial) {\n return dims.bottom + opts.margin > 0 && // from the top\n dims.left - opts.margin < InkElement.viewportWidth() && // from the right\n dims.top - opts.margin < InkElement.viewportHeight() && // from the bottom\n dims.right + opts.margin > 0; // from the left\n } else {\n return dims.top + opts.margin > 0 && // from the top\n dims.right - opts.margin < InkElement.viewportWidth() && // from the right\n dims.bottom - opts.margin < InkElement.viewportHeight() && // from the bottom\n dims.left + opts.margin > 0; // from the left\n }\n },\n\n /**\n * Check if an element is hidden.\n * Taken from Mootools Element extras ( https://gist.github.com/cheeaun/73342 )\n * Does not take into account visibility:hidden\n * @method isHidden\n * @param {DOMElement} element Element to check\n * @return {Boolean}\n * @sample Ink_Dom_Element_1_isHidden.html \n */\n\n isHidden: function (element) {\n var w = element.offsetWidth, \n h = element.offsetHeight,\n force = (element.tagName.toLowerCase() === 'tr');\n\n var Css = Ink.getModule('Ink.Dom.Css_1');\n\n return (w===0 && h===0 && !force) ? true :\n (w!==0 && h!==0 && !force) ? false :\n Css.getStyle(element, 'display').toLowerCase() === 'none';\n },\n\n /**\n * Check if an element is visible \n *\n * @method isVisible\n * @uses isHidden\n * @param {DOMElement} element Element to check\n * @return {Boolean}\n * @sample Ink_Dom_Element_1_isVisible.html \n */\n\n isVisible: function (element) {\n return !this.isHidden(element);\n },\n\n /**\n * Clones an element's position to another\n *\n * @method clonePosition\n * @param {DOMElement} cloneTo element to be position cloned\n * @param {DOMElement} cloneFrom element to get the cloned position\n * @return {DOMElement} The element with positionClone\n * @sample Ink_Dom_Element_1_clonePosition.html \n */\n clonePosition: function(cloneTo, cloneFrom){\n var pos = InkElement.offset(cloneFrom);\n cloneTo.style.left = pos[0]+'px';\n cloneTo.style.top = pos[1]+'px';\n\n return cloneTo;\n },\n\n /**\n * Text-overflow: ellipsis emulation\n * Slices off a piece of text at the end of the element and adds the ellipsis so all text fits inside.\n *\n * @method ellipsizeText\n * @param {DOMElement} element Element to modify text content\n * @param {String} [ellipsis]='\\u2026' String to append to the chopped text\n */\n ellipsizeText: function(element/*, ellipsis*/){\n if ((element = Ink.i(element))) {\n element.style.overflow = 'hidden';\n element.style.whiteSpace = 'nowrap';\n element.style.textOverflow = 'ellipsis';\n }\n },\n\n /**\n * Finds the closest ancestor element matching your test function\n * \n *\n * @method findUpwardsHaving\n * @param {DOMElement} element Element to base the search from\n * @param {Function} boolTest Testing function\n * @return {DOMElement|false} The matched element or false if did not match\n * @sample Ink_Dom_Element_1_findUpwardsHaving.html \n */\n findUpwardsHaving: function(element, boolTest) {\n while (element && element.nodeType === 1) {\n if (boolTest(element)) {\n return element;\n }\n element = element.parentNode;\n }\n return false;\n },\n\n /**\n * Finds the closest ancestor by class name\n *\n * @method findUpwardsByClass\n * @uses findUpwardsHaving\n * @param {DOMElement} element Element to base the search from\n * @param {String} className Class name to search\n * @returns {DOMElement|false} The matched element or false if did not match\n * @sample Ink_Dom_Element_1_findUpwardsByClass.html \n */\n findUpwardsByClass: function(element, className) {\n var re = new RegExp(\"(^|\\\\s)\" + className + \"(\\\\s|$)\");\n var tst = function(el) {\n var cls = el.className;\n return cls && re.test(cls);\n };\n return InkElement.findUpwardsHaving(element, tst);\n },\n\n /**\n * Finds the closest ancestor by tag name\n *\n * @method findUpwardsByTag\n * @param {DOMElement} element Element to base the search from\n * @param {String} tag Tag to search\n * @returns {DOMElement|false} the matched element or false if did not match\n * @sample Ink_Dom_Element_1_findUpwardsByTag.html \n */\n findUpwardsByTag: function(element, tag) {\n tag = tag.toUpperCase();\n var tst = function(el) {\n return el.nodeName && el.nodeName.toUpperCase() === tag;\n };\n return InkElement.findUpwardsHaving(element, tst);\n },\n\n /**\n * Finds the closest ancestor by id\n *\n * @method findUpwardsById\n * @param {HtmlElement} element Element to base the search from\n * @param {String} id ID to search\n * @returns {HtmlElement|false} The matched element or false if did not match\n * @sample Ink_Dom_Element_1_findUpwardsById.html \n */\n findUpwardsById: function(element, id) {\n var tst = function(el) {\n return el.id === id;\n };\n return InkElement.findUpwardsHaving(element, tst);\n },\n\n /**\n * Finds the closest ancestor by CSS selector\n *\n * @method findUpwardsBySelector\n * @param {HtmlElement} element Element to base the search from\n * @param {String} sel CSS selector\n * @returns {HtmlElement|false} The matched element or false if did not match\n * @sample Ink_Dom_Element_1_findUpwardsBySelector.html \n */\n findUpwardsBySelector: function(element, sel) {\n var Selector = Ink.getModule('Ink.Dom.Selector', '1');\n if (!Selector) {\n throw new Error('This method requires Ink.Dom.Selector');\n }\n var tst = function(el) {\n return Selector.matchesSelector(el, sel);\n };\n return InkElement.findUpwardsHaving(element, tst);\n },\n\n /**\n * Gets the trimmed text of an element\n *\n * @method getChildrenText\n * @param {DOMElement} el Element to base the search from\n * @param {Boolean} [removeIt] Flag to remove the text from the element\n * @return {String} Text found\n * @sample Ink_Dom_Element_1_getChildrenText.html \n */\n getChildrenText: function(el, removeIt) {\n var node,\n j,\n part,\n nodes = el.childNodes,\n jLen = nodes.length,\n text = '';\n\n if (!el) {\n return text;\n }\n\n for (j = 0; j < jLen; ++j) {\n node = nodes[j];\n if (!node) { continue; }\n if (node.nodeType === 3) { // TEXT NODE\n part = InkElement._trimString( String(node.data) );\n if (part.length > 0) {\n text += part;\n if (removeIt) { el.removeChild(node); }\n }\n else { el.removeChild(node); }\n }\n }\n\n return text;\n },\n\n /**\n * String trim implementation\n * Used by getChildrenText\n *\n * function _trimString\n * param {String} text\n * return {String} trimmed text\n */\n _trimString: function(text) {\n return (String.prototype.trim) ? text.trim() : text.replace(/^\\s*/, '').replace(/\\s*$/, '');\n },\n\n /**\n * Gets value of a select element\n *\n * @method getSelectValues\n * @param {DOMElement|String} select element\n * @return {Array} The selected values\n * @sample Ink_Dom_Element_1_getSelectValues.html \n */\n getSelectValues: function (select) {\n var selectEl = Ink.i(select);\n var values = [];\n for (var i = 0; i < selectEl.options.length; ++i) {\n values.push( selectEl.options[i].value );\n }\n return values;\n },\n\n\n /* used by fills */\n _normalizeData: function(data) {\n var d, data2 = [];\n for (var i = 0, f = data.length; i < f; ++i) {\n d = data[i];\n\n if (!(d instanceof Array)) { // if not array, wraps primitive twice: val -> [val, val]\n d = [d, d];\n }\n else if (d.length === 1) { // if 1 element array: [val] -> [val, val]\n d.push(d[0]);\n }\n data2.push(d);\n }\n return data2;\n },\n\n\n /**\n * Fills a select element with options\n *\n * @method fillSelect\n * @param {DOMElement|String} container Select element which will get filled\n * @param {Array} data Data to populate the component\n * @param {Boolean} [skipEmpty] Flag to skip empty option\n * @param {String|Number} [defaultValue] Initial selected value\n *\n * @sample Ink_Dom_Element_1_fillSelect.html \n */\n fillSelect: function(container, data, skipEmpty, defaultValue) {\n var containerEl = Ink.i(container);\n if (!containerEl) { return; }\n\n containerEl.innerHTML = '';\n var d, optionEl;\n\n if (!skipEmpty) {\n // add initial empty option\n optionEl = document.createElement('option');\n optionEl.setAttribute('value', '');\n containerEl.appendChild(optionEl);\n }\n\n data = InkElement._normalizeData(data);\n\n for (var i = 0, f = data.length; i < f; ++i) {\n d = data[i];\n\n optionEl = document.createElement('option');\n optionEl.setAttribute('value', d[0]);\n if (d.length > 2) {\n optionEl.setAttribute('extra', d[2]);\n }\n optionEl.appendChild( document.createTextNode(d[1]) );\n\n if (d[0] === defaultValue) {\n optionEl.setAttribute('selected', 'selected');\n }\n\n containerEl.appendChild(optionEl);\n }\n },\n\n\n /**\n * Creates a set of radio buttons from an array of data\n *\n * @method fillRadios\n * @param {DOMElement|String} insertAfterEl Element after which the input elements will be created\n * @param {String} name Name for the form field ([] is added if not present as a suffix)\n * @param {Array} data Data to populate the component\n * @param {Boolean} [skipEmpty] Flag to skip creation of empty options\n * @param {String|Number} [defaultValue] Initial selected value\n * @param {String} [splitEl] Name of element to add after each input element (example: 'br')\n * @return {DOMElement} Wrapper element around the radio buttons\n */\n fillRadios: function(insertAfterEl, name, data, skipEmpty, defaultValue, splitEl) {\n insertAfterEl = Ink.i(insertAfterEl);\n var containerEl = document.createElement('span');\n InkElement.insertAfter(containerEl, insertAfterEl);\n\n data = InkElement._normalizeData(data);\n\n /*\n if (name.substring(name.length - 1) !== ']') {\n name += '[]';\n }\n */\n\n var d, inputEl;\n\n if (!skipEmpty) {\n // add initial empty option\n inputEl = document.createElement('input');\n inputEl.setAttribute('type', 'radio');\n inputEl.setAttribute('name', name);\n inputEl.setAttribute('value', '');\n containerEl.appendChild(inputEl);\n if (splitEl) { containerEl.appendChild( document.createElement(splitEl) ); }\n }\n\n for (var i = 0; i < data.length; ++i) {\n d = data[i];\n\n inputEl = document.createElement('input');\n inputEl.setAttribute('type', 'radio');\n inputEl.setAttribute('name', name);\n inputEl.setAttribute('value', d[0]);\n containerEl.appendChild(inputEl);\n containerEl.appendChild( document.createTextNode(d[1]) );\n if (splitEl) { containerEl.appendChild( document.createElement(splitEl) ); }\n\n if (d[0] === defaultValue) {\n inputEl.checked = true;\n }\n }\n\n return containerEl;\n },\n\n\n /**\n * Creates set of checkbox buttons\n *\n * @method fillChecks\n * @param {DOMElement|String} insertAfterEl Element after which the input elements will be created\n * @param {String} name Name for the form field ([] is added if not present as a suffix)\n * @param {Array} data Data to populate the component\n * @param {Boolean} [skipEmpty] Flag to skip creation of empty options\n * @param {String|Number} [defaultValue] Initial selected value\n * @param {String} [splitEl] Name of element to add after each input element (example: 'br')\n * @return {DOMElement} Wrapper element around the checkboxes\n */\n fillChecks: function(insertAfterEl, name, data, defaultValue, splitEl) {\n insertAfterEl = Ink.i(insertAfterEl);\n var containerEl = document.createElement('span');\n InkElement.insertAfter(containerEl, insertAfterEl);\n\n data = InkElement._normalizeData(data);\n\n if (name.substring(name.length - 1) !== ']') {\n name += '[]';\n }\n\n var d, inputEl;\n\n for (var i = 0; i < data.length; ++i) {\n d = data[i];\n\n inputEl = document.createElement('input');\n inputEl.setAttribute('type', 'checkbox');\n inputEl.setAttribute('name', name);\n inputEl.setAttribute('value', d[0]);\n containerEl.appendChild(inputEl);\n containerEl.appendChild( document.createTextNode(d[1]) );\n if (splitEl) { containerEl.appendChild( document.createElement(splitEl) ); }\n\n if (d[0] === defaultValue) {\n inputEl.checked = true;\n }\n }\n\n return containerEl;\n },\n\n\n /**\n * Gets the index of an element relative to a parent\n *\n * @method parentIndexOf\n * @param {DOMElement} parentEl Element to parse\n * @param {DOMElement} childEl Child Element to look for\n * @return {Number} The index of the childEl inside parentEl. Returns -1 if it's not a direct child\n * @sample Ink_Dom_Element_1_parentIndexOf.html \n */\n parentIndexOf: function(parentEl, childEl) {\n var node, idx = 0;\n for (var i = 0, f = parentEl.childNodes.length; i < f; ++i) {\n node = parentEl.childNodes[i];\n if (node.nodeType === 1) { // ELEMENT\n if (node === childEl) { return idx; }\n ++idx;\n }\n }\n return -1;\n },\n\n\n /**\n * Gets the next siblings of an element\n *\n * @method nextSiblings\n * @param {String|DOMElement} elm Element\n * @return {Array} Array of next sibling elements\n * @sample Ink_Dom_Element_1_nextSiblings.html \n */\n nextSiblings: function(elm) {\n elm = Ink.i(elm);\n if(typeof(elm) === 'object' && elm !== null && elm.nodeType && elm.nodeType === 1) {\n var elements = [],\n siblings = elm.parentNode.children,\n index = InkElement.parentIndexOf(elm.parentNode, elm);\n\n for(var i = ++index, len = siblings.length; i<len; i++) {\n elements.push(siblings[i]);\n }\n\n return elements;\n }\n return [];\n },\n\n\n /**\n * Gets the previous siblings of an element\n *\n * @method previousSiblings\n * @param {String|DOMElement} elm Element\n * @return {Array} Array of previous sibling elements\n * @sample Ink_Dom_Element_1_previousSiblings.html \n */\n previousSiblings: function(elm) {\n elm = Ink.i(elm);\n if(typeof(elm) === 'object' && elm !== null && elm.nodeType && elm.nodeType === 1) {\n var elements = [],\n siblings = elm.parentNode.children,\n index = InkElement.parentIndexOf(elm.parentNode, elm);\n\n for(var i = 0, len = index; i<len; i++) {\n elements.push(siblings[i]);\n }\n\n return elements;\n }\n return [];\n },\n\n\n /**\n * Gets the all siblings of an element\n *\n * @method siblings\n * @param {String|DOMElement} elm Element\n * @return {Array} Array of sibling elements\n * @sample Ink_Dom_Element_1_siblings.html \n */\n siblings: function(elm) {\n elm = Ink.i(elm);\n if(typeof(elm) === 'object' && elm !== null && elm.nodeType && elm.nodeType === 1) {\n var elements = [],\n siblings = elm.parentNode.children;\n\n for(var i = 0, len = siblings.length; i<len; i++) {\n if(elm !== siblings[i]) {\n elements.push(siblings[i]);\n }\n }\n\n return elements;\n }\n return [];\n },\n\n /**\n * Counts the number of children of an element\n *\n * @method childElementCount\n * @param {String|DOMElement} elm element\n * @return {Number} number of child elements\n * @sample Ink_Dom_Element_1_childElementCount.html \n */\n childElementCount: function(elm) {\n elm = Ink.i(elm);\n if ('childElementCount' in elm) {\n return elm.childElementCount;\n }\n if (!elm) { return 0; }\n return InkElement.siblings(elm).length + 1;\n },\n\n _wrapElements: {\n TABLE: function (div, html) {\n /* If we don't create a tbody, IE7 does that for us. Adding a tbody with a random string and then filtering for that random string is the only way to avoid double insertion of tbodies. */\n if (browserCreatesTbodies) {\n div.innerHTML = \"<table>\" + html + \"<tbody><tr><td>\" + deleteThisTbodyToken + \"</tr></td></tbody></table>\";\n } else {\n div.innerHTML = \"<table>\" + html + \"</table>\";\n }\n return div.firstChild;\n },\n TBODY: function (div, html) {\n div.innerHTML = '<table><tbody>' + html + '</tbody></table>';\n return div.firstChild.getElementsByTagName('tbody')[0];\n },\n THEAD: function (div, html) {\n div.innerHTML = '<table><thead>' + html + '</thead><tbody></tbody></table>';\n return div.firstChild.getElementsByTagName('thead')[0];\n },\n TFOOT: function (div, html) {\n div.innerHTML = '<table><tfoot>' + html + '</tfoot><tbody></tbody></table>';\n return div.firstChild.getElementsByTagName('tfoot')[0];\n },\n TR: function (div, html) {\n div.innerHTML = '<table><tbody><tr>' + html + '</tr></tbody></table>';\n return div.firstChild.firstChild.firstChild;\n }\n },\n\n /**\n * Gets a wrapper DIV with a certain HTML content to be inserted inside another element.\n * This is necessary for appendHTML,prependHTML functions, because they need a container element to copy the children from.\n *\n * Works around IE table quirks\n * @method _getWrapper\n * @private\n * @param elm\n * @param html\n */\n _getWrapper: function (elm, html) {\n var nodeName = elm.nodeName && elm.nodeName.toUpperCase();\n var wrapper = document.createElement('div');\n var wrapFunc = InkElement._wrapElements[nodeName];\n\n if ( !wrapFunc ) {\n wrapper.innerHTML = html;\n return wrapper;\n }\n // special cases\n wrapper = wrapFunc(wrapper, html);\n // worst case: tbody auto-creation even when our HTML has a tbody.\n if (browserCreatesTbodies && nodeName === 'TABLE') {\n // terrible case. Deal with tbody creation too.\n var tds = wrapper.getElementsByTagName('td');\n for (var i = 0, len = tds.length; i < len; i++) {\n if (tds[i].innerHTML === deleteThisTbodyToken) {\n var tbody = tds[i].parentNode.parentNode;\n tbody.parentNode.removeChild(tbody);\n }\n }\n }\n return wrapper;\n },\n\n /**\n * Appends HTML to an element.\n * This method parses the html string and doesn't modify its contents\n *\n * @method appendHTML\n * @param {String|DOMElement} elm Element\n * @param {String} html Markup string\n * @sample Ink_Dom_Element_1_appendHTML.html \n */\n appendHTML: function(elm, html){\n elm = Ink.i(elm);\n if(elm !== null) {\n var wrapper = InkElement._getWrapper(elm, html);\n while (wrapper.firstChild) {\n elm.appendChild(wrapper.firstChild);\n }\n }\n },\n\n /**\n * Prepends HTML to an element.\n * This method parses the html string and doesn't modify its contents\n *\n * @method prependHTML\n * @param {String|DOMElement} elm Element\n * @param {String} html Markup string\n * @sample Ink_Dom_Element_1_prependHTML.html \n */\n prependHTML: function(elm, html){\n elm = Ink.i(elm);\n if(elm !== null) {\n var wrapper = InkElement._getWrapper(elm, html);\n while (wrapper.lastChild) {\n elm.insertBefore(wrapper.lastChild, elm.firstChild);\n }\n }\n },\n\n /**\n * Sets the inner HTML of an element.\n *\n * @method setHTML\n * @param {String|DOMElement} elm Element\n * @param {String} html Markup string\n * @sample Ink_Dom_Element_1_setHTML.html \n */\n setHTML: function (elm, html) {\n elm = Ink.i(elm);\n if(elm !== null) {\n try {\n elm.innerHTML = html;\n } catch (e) {\n // Tables in IE7\n while (elm.firstChild) {\n elm.removeChild(elm.firstChild);\n }\n InkElement.appendHTML(elm, html);\n }\n }\n },\n\n /**\n * Wraps an element inside a container.\n *\n * The container may or may not be in the document yet.\n *\n * @method wrap\n * @param {String|DOMElement} target Element to be wrapped\n * @param {String|DOMElement} container Element to wrap the target\n * @return Container element\n * @sample Ink_Dom_Element_1_wrap.html \n *\n * @example\n * before:\n *\n * <div id=\"target\"></div>\n *\n * call this function to wrap #target with a wrapper div.\n *\n * InkElement.wrap('target', InkElement.create('div', {id: 'container'});\n * \n * after: \n *\n * <div id=\"container\"><div id=\"target\"></div></div>\n */\n wrap: function (target, container) {\n target = Ink.i(target);\n container = Ink.i(container);\n \n var nextNode = target.nextSibling;\n var parent = target.parentNode;\n\n container.appendChild(target);\n\n if (nextNode !== null) {\n parent.insertBefore(container, nextNode);\n } else {\n parent.appendChild(container);\n }\n\n return container;\n },\n\n /**\n * Places an element outside a wrapper.\n *\n * @method unwrap\n * @param {DOMElement} elem The element you're trying to unwrap. This should be an ancestor of the wrapper.\n * @param {String} [wrapperSelector] CSS Selector for the ancestor. Use this if your wrapper is not the direct parent of elem.\n * @sample Ink_Dom_Element_1_unwrap.html \n *\n * @example\n *\n * When you have this:\n *\n * <div id=\"wrapper\">\n * <div id=\"unwrapMe\"></div>\n * </div>\n *\n * If you do this:\n *\n * InkElement.unwrap('unwrapMe');\n *\n * You get this:\n *\n * <div id=\"unwrapMe\"></div>\n * <div id=\"wrapper\"></div>\n * \n **/\n unwrap: function (elem, wrapperSelector) {\n elem = Ink.i(elem);\n var wrapper;\n if (typeof wrapperSelector === 'string') {\n wrapper = InkElement.findUpwardsBySelector(elem, wrapperSelector);\n } else if (typeof wrapperSelector === 'object' && wrapperSelector.tagName) {\n wrapper = InkElement.findUpwardsHaving(elem, function (ancestor) {\n return ancestor === wrapperSelector;\n });\n } else {\n wrapper = elem.parentNode;\n }\n if (!wrapper || !wrapper.parentNode) { return; }\n\n InkElement.insertBefore(elem, wrapper);\n },\n\n /**\n * Replaces an element with another.\n *\n * @method replace\n * @param element The element to be replaced.\n * @param replacement The new element.\n * @sample Ink_Dom_Element_1_replace.html \n *\n * @example\n * var newelement1 = InkElement.create('div');\n * // ...\n * replace(Ink.i('element1'), newelement1);\n */\n replace: function (element, replacement) {\n element = Ink.i(element);\n if(element !== null) {\n element.parentNode.replaceChild(replacement, element);\n }\n },\n\n /**\n * Removes direct text children.\n * Useful to remove nasty layout gaps generated by whitespace on the markup.\n *\n * @method removeTextNodeChildren\n * @param {DOMElement} el Element to remove text from\n * @sample Ink_Dom_Element_1_removeTextNodeChildren.html \n */\n removeTextNodeChildren: function(el) {\n el = Ink.i(el);\n if(el !== null) {\n var prevEl, toRemove, parent = el;\n el = el.firstChild;\n while (el) {\n toRemove = (el.nodeType === 3);\n prevEl = el;\n el = el.nextSibling;\n if (toRemove) {\n parent.removeChild(prevEl);\n }\n }\n }\n },\n\n /**\n * Creates a documentFragment from an HTML string.\n *\n * @method htmlToFragment\n * @param {String} html HTML string\n * @return {DocumentFragment} DocumentFragment containing all of the elements from the html string\n * @sample Ink_Dom_Element_1_htmlToFragment.html \n */\n htmlToFragment: (createContextualFragmentSupport ?\n function(html){\n var range;\n\n if(typeof html !== 'string'){ return document.createDocumentFragment(); }\n\n range = document.createRange();\n\n // set the context to document.body (firefox does this already, webkit doesn't)\n range.selectNode(document.body);\n\n return range.createContextualFragment(html);\n } : function (html) {\n var fragment = document.createDocumentFragment(),\n tempElement,\n current;\n\n if(typeof html !== 'string'){ return fragment; }\n\n tempElement = document.createElement('div');\n tempElement.innerHTML = html;\n\n // append child removes elements from the original parent\n while( (current = tempElement.firstChild) ){ // intentional assignment\n fragment.appendChild(current);\n }\n\n return fragment;\n }),\n\n _camelCase: function(str)\n {\n return str ? str.replace(/-(\\w)/g, function (_, $1){\n return $1.toUpperCase();\n }) : str;\n },\n\n /**\n * Gets data attributes from an element\n *\n * @method data\n * @param {String|DOMElement} selector Element or CSS selector\n * @return {Object} Object with the data-* properties. If no data-attributes are present, an empty object is returned.\n * @sample Ink_Dom_Element_1_data.html \n */\n data: function(selector) {\n var el;\n if (typeof selector !== 'object' && typeof selector !== 'string') {\n throw '[Ink.Dom.Element.data] :: Invalid selector defined';\n }\n\n if (typeof selector === 'object') {\n el = selector;\n }\n else {\n var InkDomSelector = Ink.getModule('Ink.Dom.Selector', 1);\n if (!InkDomSelector) {\n throw \"[Ink.Dom.Element.data] :: this method requires Ink.Dom.Selector - v1\";\n }\n el = InkDomSelector.select(selector);\n if (el.length <= 0) {\n throw \"[Ink.Dom.Element.data] :: Can't find any element with the specified selector\";\n }\n el = el[0];\n }\n\n var dataset = {};\n var attrs = el.attributes || [];\n\n var curAttr, curAttrName, curAttrValue;\n if (attrs) {\n for (var i = 0, total = attrs.length; i < total; ++i) {\n curAttr = attrs[i];\n curAttrName = curAttr.name;\n curAttrValue = curAttr.value;\n if (curAttrName && curAttrName.indexOf('data-') === 0) {\n dataset[InkElement._camelCase(curAttrName.replace('data-', ''))] = curAttrValue;\n }\n }\n }\n\n return dataset;\n },\n\n /**\n * Move the cursor on an input or textarea element.\n * @method moveCursorTo\n * @param {DOMElement} el Input or Textarea element\n * @param {Number} t Index of the character to move the cursor to\n * @sample Ink_Dom_Element_1_moveCursorTo.html \n */\n moveCursorTo: function(el, t) {\n el = Ink.i(el);\n if(el !== null) {\n if (el.setSelectionRange) {\n el.setSelectionRange(t, t);\n //el.focus();\n }\n else {\n var range = el.createTextRange();\n range.collapse(true);\n range.moveEnd( 'character', t);\n range.moveStart('character', t);\n range.select();\n }\n }\n },\n\n /**\n * Get the page's width.\n * @method pageWidth\n * @return {Number} Page width in pixels\n * @sample Ink_Dom_Element_1_pageWidth.html \n */\n pageWidth: function() {\n var xScroll;\n\n if (window.innerWidth && window.scrollMaxX) {\n xScroll = window.innerWidth + window.scrollMaxX;\n } else if (document.body.scrollWidth > document.body.offsetWidth){\n xScroll = document.body.scrollWidth;\n } else {\n xScroll = document.body.offsetWidth;\n }\n\n var windowWidth;\n\n if (window.self.innerWidth) {\n if(document.documentElement.clientWidth){\n windowWidth = document.documentElement.clientWidth;\n } else {\n windowWidth = window.self.innerWidth;\n }\n } else if (document.documentElement && document.documentElement.clientWidth) {\n windowWidth = document.documentElement.clientWidth;\n } else if (document.body) {\n windowWidth = document.body.clientWidth;\n }\n\n if(xScroll < windowWidth){\n return xScroll;\n } else {\n return windowWidth;\n }\n },\n\n /**\n * Get the page's height.\n * @method pageHeight\n * @return {Number} Page height in pixels\n * @sample Ink_Dom_Element_1_pageHeight.html \n */\n pageHeight: function() {\n var yScroll;\n\n if (window.innerHeight && window.scrollMaxY) {\n yScroll = window.innerHeight + window.scrollMaxY;\n } else if (document.body.scrollHeight > document.body.offsetHeight){\n yScroll = document.body.scrollHeight;\n } else {\n yScroll = document.body.offsetHeight;\n }\n\n var windowHeight;\n\n if (window.self.innerHeight) {\n windowHeight = window.self.innerHeight;\n } else if (document.documentElement && document.documentElement.clientHeight) {\n windowHeight = document.documentElement.clientHeight;\n } else if (document.body) {\n windowHeight = document.body.clientHeight;\n }\n\n if(yScroll < windowHeight){\n return windowHeight;\n } else {\n return yScroll;\n }\n },\n\n /**\n * Get the viewport's width.\n * @method viewportWidth\n * @return {Number} Viewport width in pixels\n * @sample Ink_Dom_Element_1_viewportWidth.html \n */\n viewportWidth: function() {\n if(typeof window.innerWidth !== \"undefined\") {\n return window.innerWidth;\n }\n if (document.documentElement && typeof document.documentElement.offsetWidth !== \"undefined\") {\n return document.documentElement.offsetWidth;\n }\n },\n\n /**\n * Get the viewport's height.\n * @method viewportHeight\n * @return {Number} Viewport height in pixels\n * @sample Ink_Dom_Element_1_viewportHeight.html \n */\n viewportHeight: function() {\n if (typeof window.innerHeight !== \"undefined\") {\n return window.innerHeight;\n }\n if (document.documentElement && typeof document.documentElement.offsetHeight !== \"undefined\") {\n return document.documentElement.offsetHeight;\n }\n },\n\n /**\n * Get the scroll's width.\n * @method scrollWidth\n * @return {Number} Scroll width\n */\n scrollWidth: function() {\n if (typeof window.self.pageXOffset !== 'undefined') {\n return window.self.pageXOffset;\n }\n if (typeof document.documentElement !== 'undefined' && typeof document.documentElement.scrollLeft !== 'undefined') {\n return document.documentElement.scrollLeft;\n }\n return document.body.scrollLeft;\n },\n\n /**\n * Get the scroll's height.\n * @method scrollHeight\n * @return {Number} Scroll height\n */\n scrollHeight: function() {\n if (typeof window.self.pageYOffset !== 'undefined') {\n return window.self.pageYOffset;\n }\n if (typeof document.documentElement !== 'undefined' && typeof document.documentElement.scrollTop !== 'undefined') {\n return document.documentElement.scrollTop;\n }\n return document.body.scrollTop;\n }\n };\n\n return InkElement;\n\n});\n","/**\n * Event management\n * @module Ink.Dom.Event_1\n * @version 1\n */\n\nInk.createModule('Ink.Dom.Event', 1, [], function() {\n /* jshint\n asi:true,\n strict:false,\n laxcomma:true,\n eqeqeq:false,\n laxbreak:true,\n boss:true,\n curly:false,\n expr:true\n */\n\n /**\n * @namespace Ink.Dom.Event_1\n * @static\n */\n\n /*!\n * Bean - copyright (c) Jacob Thornton 2011-2012\n * https://github.com/fat/bean\n * MIT license\n */\n var bean = (function (name, context, definition) {\n return definition()\n })('bean', this, function (name, context) {\n name = name || 'bean'\n context = context || this\n\n var win = window\n , old = context[name]\n , namespaceRegex = /[^\\.]*(?=\\..*)\\.|.*/\n , nameRegex = /\\..*/\n , addEvent = 'addEventListener'\n , removeEvent = 'removeEventListener'\n , doc = document || {}\n , root = doc.documentElement || {}\n , W3C_MODEL = root[addEvent]\n , eventSupport = W3C_MODEL ? addEvent : 'attachEvent'\n , ONE = {} // singleton for quick matching making add() do one()\n\n , slice = Array.prototype.slice\n , str2arr = function (s, d) { return s.split(d || ' ') }\n , isString = function (o) { return typeof o == 'string' }\n , isFunction = function (o) { return typeof o == 'function' }\n\n // events that we consider to be 'native', anything not in this list will\n // be treated as a custom event\n , standardNativeEvents =\n 'click dblclick mouseup mousedown contextmenu ' + // mouse buttons\n 'mousewheel mousemultiwheel DOMMouseScroll ' + // mouse wheel\n 'mouseover mouseout mousemove selectstart selectend ' + // mouse movement\n 'keydown keypress keyup ' + // keyboard\n 'orientationchange ' + // mobile\n 'focus blur change reset select submit ' + // form elements\n 'load unload beforeunload resize move DOMContentLoaded ' + // window\n 'readystatechange message ' + // window\n 'error abort scroll ' // misc\n // element.fireEvent('onXYZ'... is not forgiving if we try to fire an event\n // that doesn't actually exist, so make sure we only do these on newer browsers\n , w3cNativeEvents =\n 'show ' + // mouse buttons\n 'input invalid ' + // form elements\n 'touchstart touchmove touchend touchcancel ' + // touch\n 'gesturestart gesturechange gestureend ' + // gesture\n 'textinput' + // TextEvent\n 'readystatechange pageshow pagehide popstate ' + // window\n 'hashchange offline online ' + // window\n 'afterprint beforeprint ' + // printing\n 'dragstart dragenter dragover dragleave drag drop dragend ' + // dnd\n 'loadstart progress suspend emptied stalled loadmetadata ' + // media\n 'loadeddata canplay canplaythrough playing waiting seeking ' + // media\n 'seeked ended durationchange timeupdate play pause ratechange ' + // media\n 'volumechange cuechange ' + // media\n 'checking noupdate downloading cached updateready obsolete ' // appcache\n\n // convert to a hash for quick lookups\n , nativeEvents = (function (hash, events, i) {\n for (i = 0; i < events.length; i++) events[i] && (hash[events[i]] = 1)\n return hash\n }({}, str2arr(standardNativeEvents + (W3C_MODEL ? w3cNativeEvents : ''))))\n\n // custom events are events that we *fake*, they are not provided natively but\n // we can use native events to generate them\n , customEvents = (function () {\n var isAncestor = 'compareDocumentPosition' in root\n ? function (element, container) {\n return container.compareDocumentPosition && (container.compareDocumentPosition(element) & 16) === 16\n }\n : 'contains' in root\n ? function (element, container) {\n container = container.nodeType === 9 || container === window ? root : container\n return container !== element && container.contains(element)\n }\n : function (element, container) {\n while (element = element.parentNode) if (element === container) return 1\n return 0\n }\n , check = function (event) {\n var related = event.relatedTarget\n return !related\n ? related == null\n : (related !== this && related.prefix !== 'xul' && !/document/.test(this.toString())\n && !isAncestor(related, this))\n }\n\n return {\n mouseenter: { base: 'mouseover', condition: check }\n , mouseleave: { base: 'mouseout', condition: check }\n , mousewheel: { base: /Firefox/.test(navigator.userAgent) ? 'DOMMouseScroll' : 'mousewheel' }\n }\n }())\n\n // we provide a consistent Event object across browsers by taking the actual DOM\n // event object and generating a new one from its properties.\n , Event = (function () {\n // a whitelist of properties (for different event types) tells us what to check for and copy\n var commonProps = str2arr('altKey attrChange attrName bubbles cancelable ctrlKey currentTarget ' +\n 'detail eventPhase getModifierState isTrusted metaKey relatedNode relatedTarget shiftKey ' +\n 'srcElement target timeStamp type view which propertyName')\n , mouseProps = commonProps.concat(str2arr('button buttons clientX clientY dataTransfer ' +\n 'fromElement offsetX offsetY pageX pageY screenX screenY toElement'))\n , mouseWheelProps = mouseProps.concat(str2arr('wheelDelta wheelDeltaX wheelDeltaY wheelDeltaZ ' +\n 'axis')) // 'axis' is FF specific\n , keyProps = commonProps.concat(str2arr('char charCode key keyCode keyIdentifier ' +\n 'keyLocation location'))\n , textProps = commonProps.concat(str2arr('data'))\n , touchProps = commonProps.concat(str2arr('touches targetTouches changedTouches scale rotation'))\n , messageProps = commonProps.concat(str2arr('data origin source'))\n , stateProps = commonProps.concat(str2arr('state'))\n , overOutRegex = /over|out/\n // some event types need special handling and some need special properties, do that all here\n , typeFixers = [\n { // key events\n reg: /key/i\n , fix: function (event, newEvent) {\n newEvent.keyCode = event.keyCode || event.which\n return keyProps\n }\n }\n , { // mouse events\n reg: /click|mouse(?!(.*wheel|scroll))|menu|drag|drop/i\n , fix: function (event, newEvent, type) {\n newEvent.rightClick = event.which === 3 || event.button === 2\n newEvent.pos = { x: 0, y: 0 }\n if (event.pageX || event.pageY) {\n newEvent.clientX = event.pageX\n newEvent.clientY = event.pageY\n } else if (event.clientX || event.clientY) {\n newEvent.clientX = event.clientX + doc.body.scrollLeft + root.scrollLeft\n newEvent.clientY = event.clientY + doc.body.scrollTop + root.scrollTop\n }\n if (overOutRegex.test(type)) {\n newEvent.relatedTarget = event.relatedTarget\n || event[(type == 'mouseover' ? 'from' : 'to') + 'Element']\n }\n return mouseProps\n }\n }\n , { // mouse wheel events\n reg: /mouse.*(wheel|scroll)/i\n , fix: function () { return mouseWheelProps }\n }\n , { // TextEvent\n reg: /^text/i\n , fix: function () { return textProps }\n }\n , { // touch and gesture events\n reg: /^touch|^gesture/i\n , fix: function () { return touchProps }\n }\n , { // message events\n reg: /^message$/i\n , fix: function () { return messageProps }\n }\n , { // popstate events\n reg: /^popstate$/i\n , fix: function () { return stateProps }\n }\n , { // everything else\n reg: /.*/\n , fix: function () { return commonProps }\n }\n ]\n , typeFixerMap = {} // used to map event types to fixer functions (above), a basic cache mechanism\n\n , Event = function (event, element, isNative) {\n if (!arguments.length) return\n event = event || ((element.ownerDocument || element.document || element).parentWindow || win).event\n this.originalEvent = event\n this.isNative = isNative\n this.isBean = true\n\n if (!event) return\n\n var type = event.type\n , target = event.target || event.srcElement\n , i, l, p, props, fixer\n\n this.target = target && target.nodeType === 3 ? target.parentNode : target\n\n if (isNative) { // we only need basic augmentation on custom events, the rest expensive & pointless\n fixer = typeFixerMap[type]\n if (!fixer) { // haven't encountered this event type before, map a fixer function for it\n for (i = 0, l = typeFixers.length; i < l; i++) {\n if (typeFixers[i].reg.test(type)) { // guaranteed to match at least one, last is .*\n typeFixerMap[type] = fixer = typeFixers[i].fix\n break\n }\n }\n }\n\n props = fixer(event, this, type)\n for (i = props.length; i--;) {\n if (!((p = props[i]) in this) && p in event) this[p] = event[p]\n }\n }\n }\n\n // preventDefault() and stopPropagation() are a consistent interface to those functions\n // on the DOM, stop() is an alias for both of them together\n Event.prototype.preventDefault = function () {\n if (this.originalEvent.preventDefault) this.originalEvent.preventDefault()\n else this.originalEvent.returnValue = false\n }\n Event.prototype.stopPropagation = function () {\n if (this.originalEvent.stopPropagation) this.originalEvent.stopPropagation()\n else this.originalEvent.cancelBubble = true\n }\n Event.prototype.stop = function () {\n this.preventDefault()\n this.stopPropagation()\n this.stopped = true\n }\n // stopImmediatePropagation() has to be handled internally because we manage the event list for\n // each element\n // note that originalElement may be a Bean#Event object in some situations\n Event.prototype.stopImmediatePropagation = function () {\n if (this.originalEvent.stopImmediatePropagation) this.originalEvent.stopImmediatePropagation()\n this.isImmediatePropagationStopped = function () { return true }\n }\n Event.prototype.isImmediatePropagationStopped = function () {\n return this.originalEvent.isImmediatePropagationStopped && this.originalEvent.isImmediatePropagationStopped()\n }\n Event.prototype.clone = function (currentTarget) {\n //TODO: this is ripe for optimisation, new events are *expensive*\n // improving this will speed up delegated events\n var ne = new Event(this, this.element, this.isNative)\n ne.currentTarget = currentTarget\n return ne\n }\n\n return Event\n }())\n\n // if we're in old IE we can't do onpropertychange on doc or win so we use doc.documentElement for both\n , targetElement = function (element, isNative) {\n return !W3C_MODEL && !isNative && (element === doc || element === win) ? root : element\n }\n\n /**\n * Bean maintains an internal registry for event listeners. We don't touch elements, objects\n * or functions to identify them, instead we store everything in the registry.\n * Each event listener has a RegEntry object, we have one 'registry' for the whole instance.\n */\n , RegEntry = (function () {\n // each handler is wrapped so we can handle delegation and custom events\n var wrappedHandler = function (element, fn, condition, args) {\n var call = function (event, eargs) {\n return fn.apply(element, args ? slice.call(eargs, event ? 0 : 1).concat(args) : eargs)\n }\n , findTarget = function (event, eventElement) {\n return fn.__beanDel ? fn.__beanDel.ft(event.target, element) : eventElement\n }\n , handler = condition\n ? function (event) {\n var target = findTarget(event, this) // deleated event\n if (condition.apply(target, arguments)) {\n if (event) event.currentTarget = target\n return call(event, arguments)\n }\n }\n : function (event) {\n if (fn.__beanDel) event = event.clone(findTarget(event)) // delegated event, fix the fix\n return call(event, arguments)\n }\n handler.__beanDel = fn.__beanDel\n return handler\n }\n\n , RegEntry = function (element, type, handler, original, namespaces, args, root) {\n var customType = customEvents[type]\n , isNative\n\n if (type == 'unload') {\n // self clean-up\n handler = once(removeListener, element, type, handler, original)\n }\n\n if (customType) {\n if (customType.condition) {\n handler = wrappedHandler(element, handler, customType.condition, args)\n }\n type = customType.base || type\n }\n\n this.isNative = isNative = nativeEvents[type] && !!element[eventSupport]\n this.customType = !W3C_MODEL && !isNative && type\n this.element = element\n this.type = type\n this.original = original\n this.namespaces = namespaces\n this.eventType = W3C_MODEL || isNative ? type : 'propertychange'\n this.target = targetElement(element, isNative)\n this[eventSupport] = !!this.target[eventSupport]\n this.root = root\n this.handler = wrappedHandler(element, handler, null, args)\n }\n\n // given a list of namespaces, is our entry in any of them?\n RegEntry.prototype.inNamespaces = function (checkNamespaces) {\n var i, j, c = 0\n if (!checkNamespaces) return true\n if (!this.namespaces) return false\n for (i = checkNamespaces.length; i--;) {\n for (j = this.namespaces.length; j--;) {\n if (checkNamespaces[i] == this.namespaces[j]) c++\n }\n }\n return checkNamespaces.length === c\n }\n\n // match by element, original fn (opt), handler fn (opt)\n RegEntry.prototype.matches = function (checkElement, checkOriginal, checkHandler) {\n return this.element === checkElement &&\n (!checkOriginal || this.original === checkOriginal) &&\n (!checkHandler || this.handler === checkHandler)\n }\n\n return RegEntry\n }())\n\n , registry = (function () {\n // our map stores arrays by event type, just because it's better than storing\n // everything in a single array.\n // uses '$' as a prefix for the keys for safety and 'r' as a special prefix for\n // rootListeners so we can look them up fast\n var map = {}\n\n // generic functional search of our registry for matching listeners,\n // `fn` returns false to break out of the loop\n , forAll = function (element, type, original, handler, root, fn) {\n var pfx = root ? 'r' : '$'\n if (!type || type == '*') {\n // search the whole registry\n for (var t in map) {\n if (t.charAt(0) == pfx) {\n forAll(element, t.substr(1), original, handler, root, fn)\n }\n }\n } else {\n var i = 0, l, list = map[pfx + type], all = element == '*'\n if (!list) return\n for (l = list.length; i < l; i++) {\n if ((all || list[i].matches(element, original, handler)) && !fn(list[i], list, i, type)) return\n }\n }\n }\n\n , has = function (element, type, original, root) {\n // we're not using forAll here simply because it's a bit slower and this\n // needs to be fast\n var i, list = map[(root ? 'r' : '$') + type]\n if (list) {\n for (i = list.length; i--;) {\n if (!list[i].root && list[i].matches(element, original, null)) return true\n }\n }\n return false\n }\n\n , get = function (element, type, original, root) {\n var entries = []\n forAll(element, type, original, null, root, function (entry) {\n return entries.push(entry)\n })\n return entries\n }\n\n , put = function (entry) {\n var has = !entry.root && !this.has(entry.element, entry.type, null, false)\n , key = (entry.root ? 'r' : '$') + entry.type\n ;(map[key] || (map[key] = [])).push(entry)\n return has\n }\n\n , del = function (entry) {\n forAll(entry.element, entry.type, null, entry.handler, entry.root, function (entry, list, i) {\n list.splice(i, 1)\n entry.removed = true\n if (list.length === 0) delete map[(entry.root ? 'r' : '$') + entry.type]\n return false\n })\n }\n\n // dump all entries, used for onunload\n , entries = function () {\n var t, entries = []\n for (t in map) {\n if (t.charAt(0) == '$') entries = entries.concat(map[t])\n }\n return entries\n }\n\n return { has: has, get: get, put: put, del: del, entries: entries }\n }())\n\n // we need a selector engine for delegated events, use querySelectorAll if it exists\n // but for older browsers we need Qwery, Sizzle or similar\n , selectorEngine\n , setSelectorEngine = function (e) {\n if (!arguments.length) {\n selectorEngine = doc.querySelectorAll\n ? function (s, r) {\n return r.querySelectorAll(s)\n }\n : function () {\n throw new Error('Bean: No selector engine installed') // eeek\n }\n } else {\n selectorEngine = e\n }\n }\n\n // we attach this listener to each DOM event that we need to listen to, only once\n // per event type per DOM element\n , rootListener = function (event, type) {\n if (!W3C_MODEL && type && event && event.propertyName != '_on' + type) return\n\n var listeners = registry.get(this, type || event.type, null, false)\n , l = listeners.length\n , i = 0\n\n event = new Event(event, this, true)\n if (type) event.type = type\n\n // iterate through all handlers registered for this type, calling them unless they have\n // been removed by a previous handler or stopImmediatePropagation() has been called\n for (; i < l && !event.isImmediatePropagationStopped(); i++) {\n if (!listeners[i].removed) listeners[i].handler.call(this, event)\n }\n }\n\n // add and remove listeners to DOM elements\n , listener = W3C_MODEL\n ? function (element, type, add) {\n // new browsers\n element[add ? addEvent : removeEvent](type, rootListener, false)\n }\n : function (element, type, add, custom) {\n // IE8 and below, use attachEvent/detachEvent and we have to piggy-back propertychange events\n // to simulate event bubbling etc.\n var entry\n if (add) {\n registry.put(entry = new RegEntry(\n element\n , custom || type\n , function (event) { // handler\n rootListener.call(element, event, custom)\n }\n , rootListener\n , null\n , null\n , true // is root\n ))\n if (custom && element['_on' + custom] == null) element['_on' + custom] = 0\n entry.target.attachEvent('on' + entry.eventType, entry.handler)\n } else {\n entry = registry.get(element, custom || type, rootListener, true)[0]\n if (entry) {\n entry.target.detachEvent('on' + entry.eventType, entry.handler)\n registry.del(entry)\n }\n }\n }\n\n , once = function (rm, element, type, fn, originalFn) {\n // wrap the handler in a handler that does a remove as well\n return function () {\n fn.apply(this, arguments)\n rm(element, type, originalFn)\n }\n }\n\n , removeListener = function (element, orgType, handler, namespaces) {\n var type = orgType && orgType.replace(nameRegex, '')\n , handlers = registry.get(element, type, null, false)\n , removed = {}\n , i, l\n\n for (i = 0, l = handlers.length; i < l; i++) {\n if ((!handler || handlers[i].original === handler) && handlers[i].inNamespaces(namespaces)) {\n // TODO: this is problematic, we have a registry.get() and registry.del() that\n // both do registry searches so we waste cycles doing this. Needs to be rolled into\n // a single registry.forAll(fn) that removes while finding, but the catch is that\n // we'll be splicing the arrays that we're iterating over. Needs extra tests to\n // make sure we don't screw it up. @rvagg\n registry.del(handlers[i])\n if (!removed[handlers[i].eventType] && handlers[i][eventSupport])\n removed[handlers[i].eventType] = { t: handlers[i].eventType, c: handlers[i].type }\n }\n }\n // check each type/element for removed listeners and remove the rootListener where it's no longer needed\n for (i in removed) {\n if (!registry.has(element, removed[i].t, null, false)) {\n // last listener of this type, remove the rootListener\n listener(element, removed[i].t, false, removed[i].c)\n }\n }\n }\n\n // set up a delegate helper using the given selector, wrap the handler function\n , delegate = function (selector, fn) {\n //TODO: findTarget (therefore $) is called twice, once for match and once for\n // setting e.currentTarget, fix this so it's only needed once\n var findTarget = function (target, root) {\n var i, array = isString(selector) ? selectorEngine(selector, root) : selector\n for (; target && target !== root; target = target.parentNode) {\n for (i = array.length; i--;) {\n if (array[i] === target) return target\n }\n }\n }\n , handler = function (e) {\n var match = findTarget(e.target, this)\n if (match) fn.apply(match, arguments)\n }\n\n // __beanDel isn't pleasant but it's a private function, not exposed outside of Bean\n handler.__beanDel = {\n ft : findTarget // attach it here for customEvents to use too\n , selector : selector\n }\n return handler\n }\n\n , fireListener = W3C_MODEL ? function (isNative, type, element) {\n // modern browsers, do a proper dispatchEvent()\n var evt = doc.createEvent(isNative ? 'HTMLEvents' : 'UIEvents')\n evt[isNative ? 'initEvent' : 'initUIEvent'](type, true, true, win, 1)\n element.dispatchEvent(evt)\n } : function (isNative, type, element) {\n // old browser use onpropertychange, just increment a custom property to trigger the event\n element = targetElement(element, isNative)\n isNative ? element.fireEvent('on' + type, doc.createEventObject()) : element['_on' + type]++\n }\n\n /**\n * Public API: off(), on(), add(), (remove()), one(), fire(), clone()\n */\n\n /**\n * off(element[, eventType(s)[, handler ]])\n */\n , off = function (element, typeSpec, fn) {\n var isTypeStr = isString(typeSpec)\n , k, type, namespaces, i\n\n if (isTypeStr && typeSpec.indexOf(' ') > 0) {\n // off(el, 't1 t2 t3', fn) or off(el, 't1 t2 t3')\n typeSpec = str2arr(typeSpec)\n for (i = typeSpec.length; i--;)\n off(element, typeSpec[i], fn)\n return element\n }\n\n type = isTypeStr && typeSpec.replace(nameRegex, '')\n if (type && customEvents[type]) type = customEvents[type].base\n\n if (!typeSpec || isTypeStr) {\n // off(el) or off(el, t1.ns) or off(el, .ns) or off(el, .ns1.ns2.ns3)\n if (namespaces = isTypeStr && typeSpec.replace(namespaceRegex, '')) namespaces = str2arr(namespaces, '.')\n removeListener(element, type, fn, namespaces)\n } else if (isFunction(typeSpec)) {\n // off(el, fn)\n removeListener(element, null, typeSpec)\n } else {\n // off(el, { t1: fn1, t2, fn2 })\n for (k in typeSpec) {\n if (typeSpec.hasOwnProperty(k)) off(element, k, typeSpec[k])\n }\n }\n\n return element\n }\n\n /**\n * on(element, eventType(s)[, selector], handler[, args ])\n */\n , on = function(element, events, selector, fn) {\n var originalFn, type, types, i, args, entry, first\n\n //TODO: the undefined check means you can't pass an 'args' argument, fix this perhaps?\n if (selector === undefined && typeof events == 'object') {\n //TODO: this can't handle delegated events\n for (type in events) {\n if (events.hasOwnProperty(type)) {\n on.call(this, element, type, events[type])\n }\n }\n return\n }\n\n if (!isFunction(selector)) {\n // delegated event\n originalFn = fn\n args = slice.call(arguments, 4)\n fn = delegate(selector, originalFn, selectorEngine)\n } else {\n args = slice.call(arguments, 3)\n fn = originalFn = selector\n }\n\n types = str2arr(events)\n\n // special case for one(), wrap in a self-removing handler\n if (this === ONE) {\n fn = once(off, element, events, fn, originalFn)\n }\n\n for (i = types.length; i--;) {\n // add new handler to the registry and check if it's the first for this element/type\n first = registry.put(entry = new RegEntry(\n element\n , types[i].replace(nameRegex, '') // event type\n , fn\n , originalFn\n , str2arr(types[i].replace(namespaceRegex, ''), '.') // namespaces\n , args\n , false // not root\n ))\n if (entry[eventSupport] && first) {\n // first event of this type on this element, add root listener\n listener(element, entry.eventType, true, entry.customType)\n }\n }\n\n return element\n }\n\n /**\n * add(element[, selector], eventType(s), handler[, args ])\n *\n * Deprecated: kept (for now) for backward-compatibility\n */\n , add = function (element, events, fn, delfn) {\n return on.apply(\n null\n , !isString(fn)\n ? slice.call(arguments)\n : [ element, fn, events, delfn ].concat(arguments.length > 3 ? slice.call(arguments, 5) : [])\n )\n }\n\n /**\n * one(element, eventType(s)[, selector], handler[, args ])\n */\n , one = function () {\n return on.apply(ONE, arguments)\n }\n\n /**\n * fire(element, eventType(s)[, args ])\n *\n * The optional 'args' argument must be an array, if no 'args' argument is provided\n * then we can use the browser's DOM event system, otherwise we trigger handlers manually\n */\n , fire = function (element, type, args) {\n var types = str2arr(type)\n , i, j, l, names, handlers\n\n for (i = types.length; i--;) {\n type = types[i].replace(nameRegex, '')\n if (names = types[i].replace(namespaceRegex, '')) names = str2arr(names, '.')\n if (!names && !args && element[eventSupport]) {\n fireListener(nativeEvents[type], type, element)\n } else {\n // non-native event, either because of a namespace, arguments or a non DOM element\n // iterate over all listeners and manually 'fire'\n handlers = registry.get(element, type, null, false)\n args = [false].concat(args)\n for (j = 0, l = handlers.length; j < l; j++) {\n if (handlers[j].inNamespaces(names)) {\n handlers[j].handler.apply(element, args)\n }\n }\n }\n }\n return element\n }\n\n /**\n * clone(dstElement, srcElement[, eventType ])\n *\n * TODO: perhaps for consistency we should allow the same flexibility in type specifiers?\n */\n , clone = function (element, from, type) {\n var handlers = registry.get(from, type, null, false)\n , l = handlers.length\n , i = 0\n , args, beanDel\n\n for (; i < l; i++) {\n if (handlers[i].original) {\n args = [ element, handlers[i].type ]\n if (beanDel = handlers[i].handler.__beanDel) args.push(beanDel.selector)\n args.push(handlers[i].original)\n on.apply(null, args)\n }\n }\n return element\n }\n\n , bean = {\n 'on' : on\n , 'add' : add\n , 'one' : one\n , 'off' : off\n , 'remove' : off\n , 'clone' : clone\n , 'fire' : fire\n , 'Event' : Event\n , 'setSelectorEngine' : setSelectorEngine\n , 'noConflict' : function () {\n context[name] = old\n return this\n }\n }\n\n // for IE, clean up on unload to avoid leaks\n if (win.attachEvent) {\n var cleanup = function () {\n var i, entries = registry.entries()\n for (i in entries) {\n if (entries[i].type && entries[i].type !== 'unload') off(entries[i].element, entries[i].type)\n }\n win.detachEvent('onunload', cleanup)\n win.CollectGarbage && win.CollectGarbage()\n }\n win.attachEvent('onunload', cleanup)\n }\n\n // initialize selector engine to internal default (qSA or throw Error)\n setSelectorEngine(Ink.ss)\n\n return bean\n });\n\n /**\n * Keep this declaration here and off Bean as it extends the Event\n * object and some properties are readonly in strict mode\n */\n 'use strict';\n\n var InkEvent = {\n\n KEY_BACKSPACE: 8,\n KEY_TAB: 9,\n KEY_RETURN: 13,\n KEY_ESC: 27,\n KEY_SPACE: 32,\n KEY_LEFT: 37,\n KEY_UP: 38,\n KEY_RIGHT: 39,\n KEY_DOWN: 40,\n KEY_DELETE: 46,\n KEY_HOME: 36,\n KEY_END: 35,\n KEY_PAGEUP: 33,\n KEY_PAGEDOWN: 34,\n KEY_INSERT: 45,\n \n /**\n * Creates a debounced version of a function.\n * Returns a function which calls `func`, waiting at least `wait` milliseconds between calls. This is useful for events such as `scroll` or `resize`, which can be triggered too many times per second, slowing down the browser with needless function calls.\n *\n * *note:* This does not delay the first function call to the function.\n *\n * @method throttle\n * @param {Function} func Function to call. Arguments and context are both passed.\n * @param {Number} [wait]=0 Milliseconds to wait between calls.\n * @sample Ink_Dom_Event_1_throttle.html \n **/\n throttle: function (func, wait) {\n wait = wait || 0;\n var lastCall = 0; // Warning: This breaks on Jan 1st 1970 0:00\n var timeout;\n var throttled = function () {\n var now = +new Date();\n var timeDiff = now - lastCall;\n if (timeDiff >= wait) {\n lastCall = now;\n return func.apply(this, [].slice.call(arguments));\n } else {\n var that = this;\n var args = [].slice.call(arguments);\n if (!timeout) {\n timeout = setTimeout(function () {\n timeout = null;\n return throttled.apply(that, args);\n }, wait - timeDiff);\n }\n }\n };\n return throttled;\n },\n\n /**\n * Gets the event's target element.\n *\n * @method element\n * @param {Object} ev Event object\n * @return {DOMNode} The target\n * @sample Ink_Dom_Event_1_element.html \n */\n element: function(ev) {\n var node = ev.delegationTarget ||\n ev.target ||\n // IE stuff\n (ev.type === 'mouseout' && ev.fromElement) ||\n (ev.type === 'mouseleave' && ev.fromElement) ||\n (ev.type === 'mouseover' && ev.toElement) ||\n (ev.type === 'mouseenter' && ev.toElement) ||\n ev.srcElement ||\n null;\n return node && (node.nodeType === 3 || node.nodeType === 4) ? node.parentNode : node;\n },\n\n /**\n * Gets the event's related target element.\n *\n * @method relatedTarget\n * @param {Object} ev event object\n * @return {DOMNode} The related target\n * @sample Ink_Dom_Event_1_relatedTarget.html \n */\n relatedTarget: function(ev){\n var node = ev.relatedTarget ||\n // IE stuff\n (ev.type === 'mouseout' && ev.toElement) ||\n (ev.type === 'mouseleave' && ev.toElement) ||\n (ev.type === 'mouseover' && ev.fromElement) ||\n (ev.type === 'mouseenter' && ev.fromElement) ||\n null;\n return node && (node.nodeType === 3 || node.nodeType === 4) ? node.parentNode : node;\n },\n\n /**\n * Find closest ancestor element by tag name related to the event target.\n * Navigate up the DOM tree, looking for a tag with the name `elmTagName`.\n *\n * If such tag is not found, `document` is returned.\n *\n * @method findElement\n * @param {Object} ev Event object\n * @param {String} elmTagName Tag name to find\n * @param {Boolean} [force]=false Flag to skip returning `document` and to return `false` instead.\n * @return {DOMElement} the first element which matches given tag name or the document element if the wanted tag is not found\n * @sample Ink_Dom_Event_1_findElement.html \n */\n findElement: function(ev, elmTagName, force)\n {\n var node = this.element(ev);\n while(true) {\n if(node.nodeName.toLowerCase() === elmTagName.toLowerCase()) {\n return node;\n } else {\n node = node.parentNode;\n if(!node) {\n if(force) {\n return false;\n }\n return document;\n }\n if(!node.parentNode){\n if(force){ return false; }\n return document;\n }\n }\n }\n },\n\n /**\n * Attaches an event to element\n *\n * @method observe\n * @param {DOMElement|String} element Element id or element\n * @param {String} eventName Event name\n * @param {Function} callBack Receives the event object as a parameter. If you're manually firing custom events, check it's eventName property to make sure you're handling the right event.\n * @param {Boolean} [useCapture] Flag to change event listening from bubbling to capture.\n * @return {Function} The event handler used. Hang on to this if you want to `stopObserving` later.\n * @sample Ink_Dom_Event_1_observe.html \n */\n observe: function(element, eventName, callBack, useCapture) {\n element = Ink.i(element);\n if(element) {\n if(element.addEventListener) {\n element.addEventListener(eventName, callBack, !!useCapture);\n } else {\n element.attachEvent('on' + eventName, (callBack = Ink.bind(callBack, element)));\n }\n return callBack;\n }\n },\n\n /**\n * Like observe, but listen to the event only once.\n *\n * @method observeOnce\n * @param {DOMElement|String} element Element id or element\n * @param {String} eventName Event name\n * @param {Function} callBack Receives the event object as a parameter. If you're manually firing custom events, check it's eventName property to make sure you're handling the right event.\n * @param {Boolean} [useCapture] Flag to change event listening from bubbling to capture.\n * @return {Function} The event handler used. Hang on to this if you want to `stopObserving` later.\n * @sample Ink_Dom_Event_1_observeOnce.html \n */\n observeOnce: function (element, eventName, callBack, useCapture) {\n var onceBack = function () {\n InkEvent.stopObserving(element, eventName, onceBack);\n return callBack();\n };\n return InkEvent.observe(element, eventName, onceBack, useCapture);\n },\n\n /**\n * Attaches an event to a selector or array of elements.\n *\n * @method observeMulti\n * @param {Array|String} elements \n * @param {String} eventName Event name\n * @param {Function} callBack Receives the event object as a parameter. If you're manually firing custom events, check it's eventName property to make sure you're handling the right event.\n * @param {Boolean} [useCapture] Flag change event listening from bubbling to capture.\n * @return {Function} The used callback.\n * @sample Ink_Dom_Event_1_observeMulti.html \n */\n observeMulti: function (elements, eventName, callBack, useCapture) {\n if (typeof elements === 'string') {\n elements = Ink.ss(elements);\n } else if ( /* is an element */ elements && elements.nodeType === 1) {\n elements = [elements];\n }\n if (!elements[0]) { return false; }\n\n for (var i = 0, len = elements.length; i < len; i++) {\n this.observe(elements[i], eventName, callBack, useCapture);\n }\n return callBack;\n },\n\n /**\n * Observes an event on an element and its descendants matching the selector.\n *\n * Requires Ink.Dom.Selector if you need to use a selector.\n *\n * @method observeDelegated\n * @param {DOMElement|String} element Element to observe.\n * @param {String} eventName Event name to observe.\n * @param {String} selector Child element selector. When null, finds any element.\n * @param {Function} callback Callback to be called when the event is fired\n * @return {Function} The used callback, for ceasing to listen to the event later.\n * @sample Ink_Dom_Event_1_observeDelegated.html \n **/\n observeDelegated: function (element, eventName, selector, callback) {\n return InkEvent.observe(element, eventName, function (event) {\n var fromElement = InkEvent.element(event);\n if (!fromElement || fromElement === element) { return; }\n\n var cursor = fromElement;\n\n // Go up the document tree until we hit the element itself.\n while (cursor !== element && cursor !== document && cursor) {\n if (Ink.Dom.Selector_1.matchesSelector(cursor, selector)) {\n event.delegationTarget = cursor;\n return callback(event);\n }\n cursor = cursor.parentNode;\n }\n });\n },\n\n /**\n * Removes an event attached to an element.\n *\n * @method stopObserving\n * @param {DOMElement|String} element Element id or element\n * @param {String} eventName Event name\n * @param {Function} callBack Callback function\n * @param {Boolean} [useCapture] Set to true if the event was being observed with useCapture set to true as well.\n * @sample Ink_Dom_Event_1_stopObserving.html \n */\n stopObserving: function(element, eventName, callBack, useCapture) {\n element = Ink.i(element);\n\n if(element) {\n if(element.removeEventListener) {\n element.removeEventListener(eventName, callBack, !!useCapture);\n } else {\n element.detachEvent('on' + eventName, callBack);\n }\n }\n },\n\n /**\n * Stops event propagation and bubbling.\n *\n * @method stop\n * @param {Object} event Event handle\n * @sample Ink_Dom_Event_1_stop.html \n */\n stop: function(event)\n {\n if(event.cancelBubble !== null) {\n event.cancelBubble = true;\n }\n if(event.stopPropagation) {\n event.stopPropagation();\n }\n if(event.preventDefault) {\n event.preventDefault();\n }\n if(window.attachEvent) {\n event.returnValue = false;\n }\n if(event.cancel !== null) {\n event.cancel = true;\n }\n },\n\n /**\n * Stops event propagation.\n *\n * @method stopPropagation\n * @param {Object} event Event handle\n * @sample Ink_Dom_Event_1_stopPropagation.html \n */\n stopPropagation: function(event) {\n if(event.cancelBubble !== null) {\n event.cancelBubble = true;\n }\n if(event.stopPropagation) {\n event.stopPropagation();\n }\n },\n\n /**\n * Stops event default behaviour.\n *\n * @method stopDefault\n * @param {Object} event Event handle\n * @sample Ink_Dom_Event_1_stopDefault.html \n */\n stopDefault: function(event)\n {\n if(event.preventDefault) {\n event.preventDefault();\n }\n if(window.attachEvent) {\n event.returnValue = false;\n }\n if(event.cancel !== null) {\n event.cancel = true;\n }\n },\n\n /**\n * Gets the pointer's coordinates from the event object.\n *\n * @method pointer\n * @param {Object} ev Event object\n * @return {Object} An object with the mouse X and Y position\n * @sample Ink_Dom_Event_1_pointer.html \n */\n pointer: function(ev)\n {\n return {\n x: this.pointerX(ev),\n y: this.pointerY(ev)\n };\n },\n\n /**\n * Gets the pointer's X coordinate.\n *\n * @method pointerX\n * @param {Object} ev Event object\n * @return {Number} Mouse X position\n */\n pointerX: function(ev)\n {\n return (ev.touches && ev.touches[0] && ev.touches[0].clientX) ||\n (ev.pageX) ||\n (ev.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft));\n },\n\n /**\n * Gets the pointer's Y coordinate.\n *\n * @method pointerY\n * @param {Object} ev Event object\n * @return {Number} Mouse Y position\n */\n pointerY: function(ev)\n {\n return (ev.touches && ev.touches[0] && ev.touches[0].clientY) ||\n (ev.pageY) ||\n (ev.clientY + (document.documentElement.scrollTop || document.body.scrollTop));\n },\n\n /**\n * Checks if an event is a left click.\n *\n * @method isLeftClick\n * @param {Object} ev Event object\n * @return {Boolean} True if the event is a left click\n * @sample Ink_Dom_Event_1_isLeftClick.html \n */\n isLeftClick: function(ev) {\n if (window.addEventListener) {\n if(ev.button === 0){\n return true;\n } else if(ev.type === 'touchend' && ev.button === null){\n // [todo] do the above check for pointerEvents too\n return true;\n }\n }\n else {\n if(ev.button === 1){ return true; }\n }\n return false;\n },\n\n /**\n * Checks if an event is a right click.\n *\n * @method isRightClick\n * @param {Object} ev Event object\n * @return {Boolean} True if the event is a right click\n * @sample Ink_Dom_Event_1_isRightClick.html \n */\n isRightClick: function(ev) {\n return (ev.button === 2);\n },\n\n /**\n * Checks if an event is a middle click.\n *\n * @method isMiddleClick\n * @param {Object} ev Event object\n * @return {Boolean} True if the event is a middle click\n * @sample Ink_Dom_Event_1_isMiddleClick.html \n */\n isMiddleClick: function(ev) {\n if (window.addEventListener) {\n return (ev.button === 1);\n }\n else {\n return (ev.button === 4);\n }\n return false;\n },\n\n /**\n * Gets character from an event.\n *\n * @method getCharFromKeyboardEvent\n * @param {Object} event Keyboard event\n * @param {Boolean} [changeCasing] If true uppercases, if false lowercases, otherwise keeps casing\n * @return {String} Character representation of pressed key combination\n * @sample Ink_Dom_Event_1_getCharFromKeyboardEvent.html \n */\n getCharFromKeyboardEvent: function(event, changeCasing) {\n var k = event.keyCode;\n var c = String.fromCharCode(k);\n\n var shiftOn = event.shiftKey;\n if (k >= 65 && k <= 90) { // A-Z\n if (typeof changeCasing === 'boolean') {\n shiftOn = changeCasing;\n }\n return (shiftOn) ? c : c.toLowerCase();\n }\n else if (k >= 96 && k <= 105) { // numpad digits\n return String.fromCharCode( 48 + (k-96) );\n }\n switch (k) {\n case 109: case 189: return '-';\n case 107: case 187: return '+';\n }\n return c;\n },\n\n debug: function(){}\n};\n\n/**\n * Lets you attach event listeners to both elements and objects.\n * http://github.com/fat/bean#on\n *\n * @method on\n * @param {DOMElement|Object} element An HTML DOM element or any JavaScript Object\n * @param {String} eventType An Event (or multiple events, space separated) to listen to\n * @param {String} [selector] A CSS DOM Element selector string to bind the listener to child elements matching the selector\n * @param {Function} [handler] The callback function\n * @param {Object} [args...] Additional arguments to pass to the callback function when triggered\n * \n * @return {DOMElement|Object} Returns the original DOM Element or Javascript Object\n * @sample Ink_Dom_Event_1_on.html \n */\n\n/**\n * Alias for `on` but will only be executed once.\n * bean.one() is an alias for bean.on() except that the handler will only be executed once and then removed for the event type(s).\n * http://github.com/fat/bean#one\n *\n * @method one\n * @param {DOMElement|Object} element An HTML DOM element or any JavaScript Object\n * @param {String} eventType An Event (or multiple events, space separated) to listen to\n * @param {String} [selector] A CSS DOM Element selector string to bind the listener to child elements matching the selector\n * @param {Function} [handler] The callback function\n * @param [args...] Additional arguments to pass to the callback function when triggered\n * \n * @return {DOMElement|Object} Returns the original DOM Element or Javascript Object\n * @sample Ink_Dom_Event_1_one.html \n */\n\n/**\n * Removes event handlers.\n * bean.off() is how you get rid of handlers once you no longer want them active. It's also a good idea to call off on elements before you remove them from your DOM; this gives Bean a chance to clean up some things and prevents memory leaks.\n * http://github.com/fat/bean#off\n *\n * @method off\n * @param {DOMElement|Object} element An HTML DOM element or any JavaScript Object\n * @param {String} eventType An Event (or multiple events, space separated) to remove\n * @param {Function} [handler] The specific callback function to remove\n * \n * @return {DOMElement|Object} Returns the original DOM Element or Javascript Object\n * @sample Ink_Dom_Event_1_off.html \n */\n\n/**\n * Clones events from one object to another\n * bean.clone() is a method for cloning events from one DOM element or object to another.\n * http://github.com/fat/bean#clone\n *\n * @method clone\n * @param {DOMElement|Object} destElement An HTML DOM element or any JavaScript Object to copy events to\n * @param {String} srcElement An HTML DOM element or any JavaScript Object to copy events from\n * @param {String} [eventType] An Event (or multiple events, space separated) to clone\n * \n * @return {DOMElement|Object} Returns the original DOM Element or Javascript Object\n * @sample Ink_Dom_Event_1_clone.html \n */\n\n/**\n * Triggers events.\n * http://github.com/fat/bean#fire\n *\n * @method fire\n * @param {DOMElement|Object} destElement An HTML DOM element or any JavaScript Object fire the event on\n * @param {String} eventType An Event (or multiple events, space separated) to fire\n * @param [args...] Additional arguments to pass to the callback function when triggered\n *\n * @return {DOMElement|Object} Returns the original DOM Element or Javascript Object\n * @sample Ink_Dom_Event_1_fire.html \n */\n\nreturn Ink.extendObj(InkEvent, bean);\n\n});\n","/**\n * @module Ink.Dom.FormSerialize_1\n * Two way serialization of form data and javascript objects.\n * Valid applications are ad hoc AJAX/syndicated submission of forms, restoring form values from server side state, etc.\n */\n\nInk.createModule('Ink.Dom.FormSerialize', 1, ['Ink.Util.Array_1', 'Ink.Dom.Element_1', 'Ink.Dom.Selector_1'], function (InkArray, InkElement, Selector) {\n 'use strict';\n\n // Check whether something is not a string or a DOM element, but still has length.\n function isArrayIsh(obj) {\n return obj != null &&\n (!InkElement.isDOMElement(obj)) &&\n (InkArray.isArray(obj) || (typeof obj !== 'string' && typeof obj.length === 'number'));\n }\n\n function toArray(obj) {\n if (isArrayIsh(obj)) { return obj; }\n else { return [obj]; }\n }\n\n /**\n * @namespace Ink.Dom.FormSerialize\n * @static\n **/\n var FormSerialize = {\n\n /**\n * Serializes a form element into a JS object\n * It turns field names into keys and field values into values.\n *\n * note: Multi-select and checkboxes with multiple values will result in arrays\n *\n * @method serialize\n * @param {DOMElement|String} form Form element to extract data\n * @return {Object} Map of fieldName -> String|String[]|Boolean\n * @sample Ink_Dom_FormSerialize_serialize.html \n */\n serialize: function(form) {\n var out = {};\n var emptyArrayToken = {}; // A hack so that empty select[multiple] elements appear although empty.\n\n var pairs = this.asPairs(form, { elements: true, emptyArray: emptyArrayToken });\n if (pairs == null) { return pairs; }\n InkArray.forEach(pairs, function (pair) {\n var name = pair[0].replace(/\\[\\]$/, '');\n var value = pair[1];\n var el = pair[2];\n\n if (value === emptyArrayToken) {\n out[name] = []; // It's an empty select[multiple]\n } else if (!(FormSerialize._resultsInArray(el) || /\\[\\]$/.test(pair[0]))) {\n out[name] = value;\n } else {\n out[name] = out[name] || [];\n out[name].push(value);\n }\n });\n\n return out;\n },\n\n /**\n * Like `serialize`, but returns an array of [fieldName, value] pairs.\n *\n * @method asPairs\n * @param {DOMElement|String} form Form element\n * @param {Object} [options] Options object, containing:\n * @param {Boolean} [options.elements] Instead of returning an array of [fieldName, value] pairs, return an array of [fieldName, value, fieldElement] triples.\n * @param {Boolean} [options.emptyArray] What to emit as the value of an empty select[multiple]. If you don't pass this option, nothing comes out.\n *\n * @return Array of [fieldName, value] pairs.\n **/\n asPairs: function (form, options) {\n var out = [];\n options = options || {};\n\n function emit(name, val, el) {\n if (options.elements) {\n out.push([name, val, el]);\n } else {\n out.push([name, val]);\n }\n }\n\n function serializeEl(el) {\n if (el.nodeName.toLowerCase() === 'select' && el.multiple) {\n var didEmit = false;\n InkArray.forEach(Selector.select('option:checked', el), function (thisOption) {\n emit(el.name, thisOption.value, el);\n didEmit = true;\n });\n if (!didEmit && 'emptyArray' in options) {\n emit(el.name, options.emptyArray, el);\n }\n } else {\n emit(el.name, el.value, el);\n }\n }\n\n if ((form = Ink.i(form))) {\n var inputs = InkArray.filter(form.elements, FormSerialize._isSerialized);\n for (var i = 0, len = inputs.length; i < len; i++) {\n serializeEl(inputs[i]);\n }\n return out;\n }\n\n return null;\n },\n\n /**\n * Sets form elements' values with values from an object\n *\n * Note: You can't set the values of an input with `type=\"file\"` (browser prohibits it)\n *\n * @method fillIn \n * @param {DOMElement|String} form Form element to be populated\n * @param {Object|Array} map2 mapping of fields to values contained in fields. Can be a hash (keys as names, strings or arrays for values), or an array of [name, value] pairs.\n * @sample Ink_Dom_FormSerialize_fillIn.html \n */\n fillIn: function(form, map2) {\n if (!(form = Ink.i(form))) { return null; }\n\n var pairs;\n\n if (typeof map2 === 'object' && !isArrayIsh(map2)) {\n pairs = FormSerialize._objToPairs(map2);\n } else if (isArrayIsh(map2)) {\n pairs = map2;\n } else {\n return null;\n }\n\n return FormSerialize._fillInPairs(form, pairs);\n },\n\n _objToPairs: function (obj) {\n var pairs = [];\n var val;\n for (var name in obj) if (obj.hasOwnProperty(name)) {\n val = toArray(obj[name]);\n for (var i = 0, len = val.length; i < len; i++) {\n pairs.push([name, val[i]]);\n }\n if (len === 0) {\n pairs.push([name, []]);\n }\n }\n return pairs;\n },\n\n _fillInPairs: function (form, pairs) {\n pairs = InkArray.groupBy(pairs, {\n key: function (pair) { return pair[0].replace(/\\[\\]$/, ''); }\n });\n\n // For each chunk...\n pairs = InkArray.map(pairs, function (pair) {\n // Join the items in the chunk by concatenating the values together and leaving the names alone\n var values = InkArray.reduce(pair, function (left, right) {\n return [null, left[1].concat([right[1]])];\n }, [null, []])[1];\n return [pair[0][0], values];\n });\n\n var name;\n var inputs;\n var values;\n for (var i = 0, len = pairs.length; i < len; i++) {\n name = pairs[i][0];\n\n if (name in form) {\n inputs = form[name];\n } else if ((name + '[]') in form) {\n inputs = form[name + '[]'];\n name = name + '[]';\n } else {\n continue;\n }\n\n inputs = toArray(inputs);\n values = pairs[i][1];\n\n FormSerialize._fillInOne(name, inputs, values);\n }\n },\n\n _fillInOne: function (name, inputs, values) {\n var firstOne = inputs[0];\n var firstNodeName = firstOne.nodeName.toLowerCase();\n var firstType = firstOne.getAttribute('type');\n firstType = firstType && firstType.toLowerCase();\n var isSelectMulti = firstNodeName === 'select' && InkElement.hasAttribute(firstOne, 'multiple');\n\n if (firstType === 'checkbox' || firstType === 'radio') {\n FormSerialize._fillInBoolean(inputs, values, 'checked');\n } else if (isSelectMulti) {\n FormSerialize._fillInBoolean(inputs[0].options, values, 'selected');\n } else {\n if (inputs.length !== values.length) {\n Ink.warn('Form had ' + inputs.length + ' inputs named \"' + name + '\", but received ' + values.length + ' values.');\n }\n\n for (var i = 0, len = Math.min(inputs.length, values.length); i < len; i += 1) {\n inputs[i].value = values[i];\n }\n }\n },\n\n _fillInBoolean: function (inputs, values, checkAttr /* 'selected' or 'checked' */) {\n InkArray.forEach(inputs, function (input) {\n var isChecked = InkArray.inArray(input.value, values);\n input[checkAttr] = isChecked;\n });\n },\n\n /**\n * Whether FormSerialize.serialize() should produce an array when looking at this element.\n * @method _resultsInArray\n * @private\n * @param element\n **/\n _resultsInArray: function (element) {\n var type = element.getAttribute('type');\n var nodeName = element.nodeName.toLowerCase();\n\n return type === 'checkbox' ||\n (nodeName === 'select' && InkElement.hasAttribute(element, 'multiple'));\n },\n\n _isSerialized: function (element) {\n if (!InkElement.isDOMElement(element)) { return false; }\n if (!InkElement.hasAttribute(element, 'name')) { return false; }\n\n var nodeName = element.nodeName.toLowerCase();\n\n if (!nodeName || nodeName === 'fieldset') { return false; }\n\n if (element.type === 'checkbox' || element.type === 'radio') {\n return !!element.checked;\n }\n\n return true;\n }\n };\n\n return FormSerialize;\n});\n","/**\n * Execute code only when the DOM is loaded.\n * @module Ink.Dom.Loaded_1\n * @version 1\n */\n \nInk.createModule('Ink.Dom.Loaded', 1, [], function() {\n\n 'use strict';\n\n /**\n * @namespace Ink.Dom.Loaded_1\n **/\n var Loaded = {\n\n /**\n * Callbacks and their contexts. Array of 2-arrays.\n *\n * []\n *\n * @attribute _contexts Array\n * @private\n * \n */\n _contexts: [], // Callbacks' queue\n\n /**\n * Specify a function to execute when the DOM is fully loaded.\n *\n * @method run\n * @param {Object} [win]=window Window object to attach/add the event\n * @param {Function} fn Callback function to be executed after the DOM is ready\n * @public\n * @sample Ink_Dom_Loaded_run.html \n */\n run: function(win, fn) {\n if (!fn) {\n fn = win;\n win = window;\n }\n\n var context;\n\n for (var i = 0, len = this._contexts.length; i < len; i++) {\n if (this._contexts[i][0] === win) {\n context = this._contexts[i][1];\n break;\n }\n }\n if (!context) {\n context = {\n cbQueue: [],\n win: win,\n doc: win.document,\n root: win.document.documentElement,\n done: false,\n top: true\n };\n context.handlers = {\n checkState: Ink.bindEvent(this._checkState, this, context),\n poll: Ink.bind(this._poll, this, context)\n };\n this._contexts.push(\n [win, context] // Javascript Objects cannot map different windows to\n // different values.\n );\n }\n\n var ael = context.doc.addEventListener;\n context.add = ael ? 'addEventListener' : 'attachEvent';\n context.rem = ael ? 'removeEventListener' : 'detachEvent';\n context.pre = ael ? '' : 'on';\n context.det = ael ? 'DOMContentLoaded' : 'onreadystatechange';\n context.wet = context.pre + 'load';\n\n var csf = context.handlers.checkState;\n var alreadyLoaded = (\n /complete|interactive|loaded/.test(context.doc.readyState) &&\n context.win.location.toString() !== 'about:blank'); // https://code.google.com/p/chromium/issues/detail?id=32357\n\n if (alreadyLoaded){\n setTimeout(Ink.bind(function () {\n fn.call(context.win, 'lazy');\n }, this), 0);\n } else {\n context.cbQueue.push(fn);\n\n context.doc[context.add]( context.det , csf );\n context.win[context.add]( context.wet , csf );\n\n var frameElement = 1;\n try{\n frameElement = context.win.frameElement;\n } catch(e) {}\n if ( !ael && context.root && context.root.doScroll ) { // IE HACK\n try {\n context.top = !frameElement;\n } catch(e) { }\n if (context.top) {\n this._poll(context);\n }\n }\n }\n },\n\n /**\n * Function that will be running the callbacks after the page is loaded\n *\n * @method _checkState\n * @param {Event} event Triggered event\n * @private\n */\n _checkState: function(event, context) {\n if ( !event || (event.type === 'readystatechange' && context.doc.readyState !== 'complete')) {\n return;\n }\n var where = (event.type === 'load') ? context.win : context.doc;\n where[context.rem](context.pre+event.type, context.handlers.checkState, false);\n this._ready(context);\n },\n\n /**\n * Polls the load progress of the page to see if it has already loaded or not\n *\n * @method _poll\n * @private\n */\n\n /**\n *\n * function _poll\n */\n _poll: function(context) {\n try {\n context.root.doScroll('left');\n } catch(e) {\n return setTimeout(context.handlers.poll, 50);\n }\n this._ready(context);\n },\n\n /**\n * Function that runs the callbacks from the queue when the document is ready.\n *\n * @method _ready\n * @private\n */\n _ready: function(context) {\n if (!context.done) {\n context.done = true;\n for (var i = 0; i < context.cbQueue.length; ++i) {\n context.cbQueue[i].call(context.win);\n }\n context.cbQueue = [];\n }\n }\n };\n\n return Loaded;\n\n});\n","/**\n * CSS selector engine\n * @module Ink.Dom.Selector_1\n * @version 1\n */\n \nInk.createModule('Ink.Dom.Selector', 1, [], function() {\n /*jshint forin:false, eqnull:true, noempty:false, expr:true, boss:true, maxdepth:false*/\n\t'use strict';\n\n/*!\n * Sizzle CSS Selector Engine\n * Copyright 2013 jQuery Foundation and other contributors\n * Released under the MIT license\n * http://sizzlejs.com/\n */\n\nvar i,\n\tcachedruns,\n\tExpr,\n\tgetText,\n\tisXML,\n\tcompile,\n\toutermostContext,\n\trecompare,\n\tsortInput,\n\n\t// Local document vars\n\tsetDocument,\n\tdocument,\n\tdocElem,\n\tdocumentIsHTML,\n\trbuggyQSA,\n\trbuggyMatches,\n\tmatches,\n\tcontains,\n\n\t// Instance-specific data\n\texpando = \"sizzle\" + -(new Date()),\n\tpreferredDoc = window.document,\n\tsupport = {},\n\tdirruns = 0,\n\tdone = 0,\n\tclassCache = createCache(),\n\ttokenCache = createCache(),\n\tcompilerCache = createCache(),\n\thasDuplicate = false,\n\tsortOrder = function() { return 0; },\n\n\t// General-purpose constants\n\tstrundefined = typeof undefined,\n\tMAX_NEGATIVE = 1 << 31,\n\n\t// Array methods\n\tarr = [],\n\tpop = arr.pop,\n\tpush_native = arr.push,\n\tpush = arr.push,\n\tslice = arr.slice,\n\t// Use a stripped-down indexOf if we can't use a native one\n\tindexOf = arr.indexOf || function( elem ) {\n\t\tvar i = 0,\n\t\t\tlen = this.length;\n\t\tfor ( ; i < len; i++ ) {\n\t\t\tif ( this[i] === elem ) {\n\t\t\t\treturn i;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t},\n\n\n\t// Regular expressions\n\n\t// Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace\n\twhitespace = \"[\\\\x20\\\\t\\\\r\\\\n\\\\f]\",\n\t// http://www.w3.org/TR/css3-syntax/#characters\n\tcharacterEncoding = \"(?:\\\\\\\\.|[\\\\w-]|[^\\\\x00-\\\\xa0])+\",\n\n\t// Loosely modeled on CSS identifier characters\n\t// An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors\n\t// Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier\n\tidentifier = characterEncoding.replace( \"w\", \"w#\" ),\n\n\t// Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors\n\toperators = \"([*^$|!~]?=)\",\n\tattributes = \"\\\\[\" + whitespace + \"*(\" + characterEncoding + \")\" + whitespace +\n\t\t\"*(?:\" + operators + whitespace + \"*(?:(['\\\"])((?:\\\\\\\\.|[^\\\\\\\\])*?)\\\\3|(\" + identifier + \")|)|)\" + whitespace + \"*\\\\]\",\n\n\t// Prefer arguments quoted,\n\t// then not containing pseudos/brackets,\n\t// then attribute selectors/non-parenthetical expressions,\n\t// then anything else\n\t// These preferences are here to reduce the number of selectors\n\t// needing tokenize in the PSEUDO preFilter\n\tpseudos = \":(\" + characterEncoding + \")(?:\\\\(((['\\\"])((?:\\\\\\\\.|[^\\\\\\\\])*?)\\\\3|((?:\\\\\\\\.|[^\\\\\\\\()[\\\\]]|\" + attributes.replace( 3, 8 ) + \")*)|.*)\\\\)|)\",\n\n\t// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter\n\trtrim = new RegExp( \"^\" + whitespace + \"+|((?:^|[^\\\\\\\\])(?:\\\\\\\\.)*)\" + whitespace + \"+$\", \"g\" ),\n\n\trcomma = new RegExp( \"^\" + whitespace + \"*,\" + whitespace + \"*\" ),\n\trcombinators = new RegExp( \"^\" + whitespace + \"*([\\\\x20\\\\t\\\\r\\\\n\\\\f>+~])\" + whitespace + \"*\" ),\n\trpseudo = new RegExp( pseudos ),\n\tridentifier = new RegExp( \"^\" + identifier + \"$\" ),\n\n\tmatchExpr = {\n\t\t\"ID\": new RegExp( \"^#(\" + characterEncoding + \")\" ),\n\t\t\"CLASS\": new RegExp( \"^\\\\.(\" + characterEncoding + \")\" ),\n\t\t\"NAME\": new RegExp( \"^\\\\[name=['\\\"]?(\" + characterEncoding + \")['\\\"]?\\\\]\" ),\n\t\t\"TAG\": new RegExp( \"^(\" + characterEncoding.replace( \"w\", \"w*\" ) + \")\" ),\n\t\t\"ATTR\": new RegExp( \"^\" + attributes ),\n\t\t\"PSEUDO\": new RegExp( \"^\" + pseudos ),\n\t\t\"CHILD\": new RegExp( \"^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\\\(\" + whitespace +\n\t\t\t\"*(even|odd|(([+-]|)(\\\\d*)n|)\" + whitespace + \"*(?:([+-]|)\" + whitespace +\n\t\t\t\"*(\\\\d+)|))\" + whitespace + \"*\\\\)|)\", \"i\" ),\n\t\t// For use in libraries implementing .is()\n\t\t// We use this for POS matching in `select`\n\t\t\"needsContext\": new RegExp( \"^\" + whitespace + \"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\\\(\" +\n\t\t\twhitespace + \"*((?:-\\\\d)?\\\\d*)\" + whitespace + \"*\\\\)|)(?=[^-]|$)\", \"i\" )\n\t},\n\n\trsibling = /[\\x20\\t\\r\\n\\f]*[+~]/,\n\n\trnative = /^[^{]+\\{\\s*\\[native code/,\n\n\t// Easily-parseable/retrievable ID or TAG or CLASS selectors\n\trquickExpr = /^(?:#([\\w-]+)|(\\w+)|\\.([\\w-]+))$/,\n\n\trinputs = /^(?:input|select|textarea|button)$/i,\n\trheader = /^h\\d$/i,\n\n\trescape = /'|\\\\/g,\n\trattributeQuotes = /\\=[\\x20\\t\\r\\n\\f]*([^'\"\\]]*)[\\x20\\t\\r\\n\\f]*\\]/g,\n\n\t// CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters\n\trunescape = /\\\\([\\da-fA-F]{1,6}[\\x20\\t\\r\\n\\f]?|.)/g,\n\tfunescape = function( _, escaped ) {\n\t\tvar high = \"0x\" + escaped - 0x10000;\n\t\t// NaN means non-codepoint\n\t\treturn high !== high ?\n\t\t\tescaped :\n\t\t\t// BMP codepoint\n\t\t\thigh < 0 ?\n\t\t\t\tString.fromCharCode( high + 0x10000 ) :\n\t\t\t\t// Supplemental Plane codepoint (surrogate pair)\n\t\t\t\tString.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );\n\t};\n\n// Optimize for push.apply( _, NodeList )\ntry {\n\tpush.apply(\n\t\t(arr = slice.call( preferredDoc.childNodes )),\n\t\tpreferredDoc.childNodes\n\t);\n\t// Support: Android<4.0\n\t// Detect silently failing push.apply\n\tarr[ preferredDoc.childNodes.length ].nodeType;\n} catch ( e ) {\n\tpush = { apply: arr.length ?\n\n\t\t// Leverage slice if possible\n\t\tfunction( target, els ) {\n\t\t\tpush_native.apply( target, slice.call(els) );\n\t\t} :\n\n\t\t// Support: IE<9\n\t\t// Otherwise append directly\n\t\tfunction( target, els ) {\n\t\t\tvar j = target.length,\n\t\t\t\ti = 0;\n\t\t\t// Can't trust NodeList.length\n\t\t\twhile ( (target[j++] = els[i++]) ) {}\n\t\t\ttarget.length = j - 1;\n\t\t}\n\t};\n}\n\n/*\n * For feature detection\n * @param {Function} fn The function to test for native support\n */\nfunction isNative( fn ) {\n\treturn rnative.test( fn + \"\" );\n}\n\n/*\n * Create key-value caches of limited size\n * @returns {Function(string, Object)} Returns the Object data after storing it on itself with\n *\tproperty name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)\n *\tdeleting the oldest entry\n */\nfunction createCache() {\n\tvar cache,\n\t\tkeys = [];\n\n\treturn (cache = function( key, value ) {\n\t\t// Use (key + \" \") to avoid collision with native prototype properties (see Issue #157)\n\t\tif ( keys.push( key += \" \" ) > Expr.cacheLength ) {\n\t\t\t// Only keep the most recent entries\n\t\t\tdelete cache[ keys.shift() ];\n\t\t}\n\t\treturn (cache[ key ] = value);\n\t});\n}\n\n/*\n * Mark a function for special use by Sizzle\n * @param {Function} fn The function to mark\n */\nfunction markFunction( fn ) {\n\tfn[ expando ] = true;\n\treturn fn;\n}\n\n/*\n * Support testing using an element\n * @param {Function} fn Passed the created div and expects a boolean result\n */\nfunction assert( fn ) {\n\tvar div = document.createElement(\"div\");\n\n\ttry {\n\t\treturn !!fn( div );\n\t} catch (e) {\n\t\treturn false;\n\t} finally {\n\t\t// release memory in IE\n\t\tdiv = null;\n\t}\n}\n\nfunction Sizzle( selector, context, results, seed ) {\n\tvar match, elem, m, nodeType,\n\t\t// QSA vars\n\t\ti, groups, old, nid, newContext, newSelector;\n\n\tif ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {\n\t\tsetDocument( context );\n\t}\n\n\tcontext = context || document;\n\tresults = results || [];\n\n\tif ( !selector || typeof selector !== \"string\" ) {\n\t\treturn results;\n\t}\n\n\tif ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {\n\t\treturn [];\n\t}\n\n\tif ( documentIsHTML && !seed ) {\n\n\t\t// Shortcuts\n\t\tif ( (match = rquickExpr.exec( selector )) ) {\n\t\t\t// Speed-up: Sizzle(\"#ID\")\n\t\t\tif ( (m = match[1]) ) {\n\t\t\t\tif ( nodeType === 9 ) {\n\t\t\t\t\telem = context.getElementById( m );\n\t\t\t\t\t// Check parentNode to catch when Blackberry 4.6 returns\n\t\t\t\t\t// nodes that are no longer in the document #6963\n\t\t\t\t\tif ( elem && elem.parentNode ) {\n\t\t\t\t\t\t// Handle the case where IE, Opera, and Webkit return items\n\t\t\t\t\t\t// by name instead of ID\n\t\t\t\t\t\tif ( elem.id === m ) {\n\t\t\t\t\t\t\tresults.push( elem );\n\t\t\t\t\t\t\treturn results;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn results;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Context is not a document\n\t\t\t\t\tif ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&\n\t\t\t\t\t\tcontains( context, elem ) && elem.id === m ) {\n\t\t\t\t\t\tresults.push( elem );\n\t\t\t\t\t\treturn results;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t// Speed-up: Sizzle(\"TAG\")\n\t\t\t} else if ( match[2] ) {\n\t\t\t\tpush.apply( results, context.getElementsByTagName( selector ) );\n\t\t\t\treturn results;\n\n\t\t\t// Speed-up: Sizzle(\".CLASS\")\n\t\t\t} else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {\n\t\t\t\tpush.apply( results, context.getElementsByClassName( m ) );\n\t\t\t\treturn results;\n\t\t\t}\n\t\t}\n\n\t\t// QSA path\n\t\tif ( support.qsa && !rbuggyQSA.test(selector) ) {\n\t\t\told = true;\n\t\t\tnid = expando;\n\t\t\tnewContext = context;\n\t\t\tnewSelector = nodeType === 9 && selector;\n\n\t\t\t// qSA works strangely on Element-rooted queries\n\t\t\t// We can work around this by specifying an extra ID on the root\n\t\t\t// and working up from there (Thanks to Andrew Dupont for the technique)\n\t\t\t// IE 8 doesn't work on object elements\n\t\t\tif ( nodeType === 1 && context.nodeName.toLowerCase() !== \"object\" ) {\n\t\t\t\tgroups = tokenize( selector );\n\n\t\t\t\tif ( (old = context.getAttribute(\"id\")) ) {\n\t\t\t\t\tnid = old.replace( rescape, \"\\\\$&\" );\n\t\t\t\t} else {\n\t\t\t\t\tcontext.setAttribute( \"id\", nid );\n\t\t\t\t}\n\t\t\t\tnid = \"[id='\" + nid + \"'] \";\n\n\t\t\t\ti = groups.length;\n\t\t\t\twhile ( i-- ) {\n\t\t\t\t\tgroups[i] = nid + toSelector( groups[i] );\n\t\t\t\t}\n\t\t\t\tnewContext = rsibling.test( selector ) && context.parentNode || context;\n\t\t\t\tnewSelector = groups.join(\",\");\n\t\t\t}\n\n\t\t\tif ( newSelector ) {\n\t\t\t\ttry {\n\t\t\t\t\tpush.apply( results,\n\t\t\t\t\t\tnewContext.querySelectorAll( newSelector )\n\t\t\t\t\t);\n\t\t\t\t\treturn results;\n\t\t\t\t} catch(qsaError) {\n\t\t\t\t} finally {\n\t\t\t\t\tif ( !old ) {\n\t\t\t\t\t\tcontext.removeAttribute(\"id\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// All others\n\treturn select( selector.replace( rtrim, \"$1\" ), context, results, seed );\n}\n\n/*\n * Detect xml\n * @param {Element|Object} elem An element or a document\n */\nisXML = Sizzle.isXML = function( elem ) {\n\t// documentElement is verified for cases where it doesn't yet exist\n\t// (such as loading iframes in IE - #4833)\n\tvar documentElement = elem && (elem.ownerDocument || elem).documentElement;\n\treturn documentElement ? documentElement.nodeName !== \"HTML\" : false;\n};\n\n/*\n * Sets document-related variables once based on the current document\n * @param {Element|Object} [doc] An element or document object to use to set the document\n * @returns {Object} Returns the current document\n */\nsetDocument = Sizzle.setDocument = function( node ) {\n\tvar doc = node ? node.ownerDocument || node : preferredDoc;\n\n\t// If no document and documentElement is available, return\n\tif ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {\n\t\treturn document;\n\t}\n\n\t// Set our document\n\tdocument = doc;\n\tdocElem = doc.documentElement;\n\n\t// Support tests\n\tdocumentIsHTML = !isXML( doc );\n\n\t// Check if getElementsByTagName(\"*\") returns only elements\n\tsupport.getElementsByTagName = assert(function( div ) {\n\t\tdiv.appendChild( doc.createComment(\"\") );\n\t\treturn !div.getElementsByTagName(\"*\").length;\n\t});\n\n\t// Check if attributes should be retrieved by attribute nodes\n\tsupport.attributes = assert(function( div ) {\n\t\tdiv.innerHTML = \"<select></select>\";\n\t\tvar type = typeof div.lastChild.getAttribute(\"multiple\");\n\t\t// IE8 returns a string for some attributes even when not present\n\t\treturn type !== \"boolean\" && type !== \"string\";\n\t});\n\n\t// Check if getElementsByClassName can be trusted\n\tsupport.getElementsByClassName = assert(function( div ) {\n\t\t// Opera can't find a second classname (in 9.6)\n\t\tdiv.innerHTML = \"<div class='hidden e'></div><div class='hidden'></div>\";\n\t\tif ( !div.getElementsByClassName || !div.getElementsByClassName(\"e\").length ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Safari 3.2 caches class attributes and doesn't catch changes\n\t\tdiv.lastChild.className = \"e\";\n\t\treturn div.getElementsByClassName(\"e\").length === 2;\n\t});\n\n\t// Check if getElementsByName privileges form controls or returns elements by ID\n\t// If so, assume (for broader support) that getElementById returns elements by name\n\tsupport.getByName = assert(function( div ) {\n\t\t// Inject content\n\t\tdiv.id = expando + 0;\n\t\t// Support: Windows 8 Native Apps\n\t\t// Assigning innerHTML with \"name\" attributes throws uncatchable exceptions\n\t\t// http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx\n\t\tdiv.appendChild( document.createElement(\"a\") ).setAttribute( \"name\", expando );\n\t\tdiv.appendChild( document.createElement(\"i\") ).setAttribute( \"name\", expando );\n\t\tdocElem.appendChild( div );\n\n\t\t// Test\n\t\tvar pass = doc.getElementsByName &&\n\t\t\t// buggy browsers will return fewer than the correct 2\n\t\t\tdoc.getElementsByName( expando ).length === 2 +\n\t\t\t// buggy browsers will return more than the correct 0\n\t\t\tdoc.getElementsByName( expando + 0 ).length;\n\n\t\t// Cleanup\n\t\tdocElem.removeChild( div );\n\n\t\treturn pass;\n\t});\n\n\t// Support: Webkit<537.32\n\t// Detached nodes confoundingly follow *each other*\n\tsupport.sortDetached = assert(function( div1 ) {\n\t\treturn div1.compareDocumentPosition &&\n\t\t\t// Should return 1, but Webkit returns 4 (following)\n\t\t\t(div1.compareDocumentPosition( document.createElement(\"div\") ) & 1);\n\t});\n\n\t// IE6/7 return modified attributes\n\tExpr.attrHandle = assert(function( div ) {\n\t\tdiv.innerHTML = \"<a href='#'></a>\";\n\t\treturn div.firstChild && typeof div.firstChild.getAttribute !== strundefined &&\n\t\t\tdiv.firstChild.getAttribute(\"href\") === \"#\";\n\t}) ?\n\t\t{} :\n\t\t{\n\t\t\t\"href\": function( elem ) {\n\t\t\t\treturn elem.getAttribute( \"href\", 2 );\n\t\t\t},\n\t\t\t\"type\": function( elem ) {\n\t\t\t\treturn elem.getAttribute(\"type\");\n\t\t\t}\n\t\t};\n\n\t// ID find and filter\n\tif ( support.getByName ) {\n\t\tExpr.find[\"ID\"] = function( id, context ) {\n\t\t\tif ( typeof context.getElementById !== strundefined && documentIsHTML ) {\n\t\t\t\tvar m = context.getElementById( id );\n\t\t\t\t// Check parentNode to catch when Blackberry 4.6 returns\n\t\t\t\t// nodes that are no longer in the document #6963\n\t\t\t\treturn m && m.parentNode ? [m] : [];\n\t\t\t}\n\t\t};\n\t\tExpr.filter[\"ID\"] = function( id ) {\n\t\t\tvar attrId = id.replace( runescape, funescape );\n\t\t\treturn function( elem ) {\n\t\t\t\treturn elem.getAttribute(\"id\") === attrId;\n\t\t\t};\n\t\t};\n\t} else {\n\t\tExpr.find[\"ID\"] = function( id, context ) {\n\t\t\tif ( typeof context.getElementById !== strundefined && documentIsHTML ) {\n\t\t\t\tvar m = context.getElementById( id );\n\n\t\t\t\treturn m ?\n\t\t\t\t\tm.id === id || typeof m.getAttributeNode !== strundefined && m.getAttributeNode(\"id\").value === id ?\n\t\t\t\t\t\t[m] :\n\t\t\t\t\t\tundefined :\n\t\t\t\t\t[];\n\t\t\t}\n\t\t};\n\t\tExpr.filter[\"ID\"] = function( id ) {\n\t\t\tvar attrId = id.replace( runescape, funescape );\n\t\t\treturn function( elem ) {\n\t\t\t\tvar node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode(\"id\");\n\t\t\t\treturn node && node.value === attrId;\n\t\t\t};\n\t\t};\n\t}\n\n\t// Tag\n\tExpr.find[\"TAG\"] = support.getElementsByTagName ?\n\t\tfunction( tag, context ) {\n\t\t\tif ( typeof context.getElementsByTagName !== strundefined ) {\n\t\t\t\treturn context.getElementsByTagName( tag );\n\t\t\t}\n\t\t} :\n\t\tfunction( tag, context ) {\n\t\t\tvar elem,\n\t\t\t\ttmp = [],\n\t\t\t\ti = 0,\n\t\t\t\tresults = context.getElementsByTagName( tag );\n\n\t\t\t// Filter out possible comments\n\t\t\tif ( tag === \"*\" ) {\n\t\t\t\twhile ( (elem = results[i++]) ) {\n\t\t\t\t\tif ( elem.nodeType === 1 ) {\n\t\t\t\t\t\ttmp.push( elem );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn tmp;\n\t\t\t}\n\t\t\treturn results;\n\t\t};\n\n\t// Name\n\tExpr.find[\"NAME\"] = support.getByName && function( tag, context ) {\n\t\tif ( typeof context.getElementsByName !== strundefined ) {\n\t\t\treturn context.getElementsByName( name );\n\t\t}\n\t};\n\n\t// Class\n\tExpr.find[\"CLASS\"] = support.getElementsByClassName && function( className, context ) {\n\t\tif ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {\n\t\t\treturn context.getElementsByClassName( className );\n\t\t}\n\t};\n\n\t// QSA and matchesSelector support\n\n\t// matchesSelector(:active) reports false when true (IE9/Opera 11.5)\n\trbuggyMatches = [];\n\n\t// qSa(:focus) reports false when true (Chrome 21),\n\t// no need to also add to buggyMatches since matches checks buggyQSA\n\t// A support test would require too much code (would include document ready)\n\trbuggyQSA = [ \":focus\" ];\n\n\tif ( (support.qsa = isNative(doc.querySelectorAll)) ) {\n\t\t// Build QSA regex\n\t\t// Regex strategy adopted from Diego Perini\n\t\tassert(function( div ) {\n\t\t\t// Select is set to empty string on purpose\n\t\t\t// This is to test IE's treatment of not explicitly\n\t\t\t// setting a boolean content attribute,\n\t\t\t// since its presence should be enough\n\t\t\t// http://bugs.jquery.com/ticket/12359\n\t\t\tdiv.innerHTML = \"<select><option selected=''></option></select>\";\n\n\t\t\t// IE8 - Some boolean attributes are not treated correctly\n\t\t\tif ( !div.querySelectorAll(\"[selected]\").length ) {\n\t\t\t\trbuggyQSA.push( \"\\\\[\" + whitespace + \"*(?:checked|disabled|ismap|multiple|readonly|selected|value)\" );\n\t\t\t}\n\n\t\t\t// Webkit/Opera - :checked should return selected option elements\n\t\t\t// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked\n\t\t\t// IE8 throws error here and will not see later tests\n\t\t\tif ( !div.querySelectorAll(\":checked\").length ) {\n\t\t\t\trbuggyQSA.push(\":checked\");\n\t\t\t}\n\t\t});\n\n\t\tassert(function( div ) {\n\n\t\t\t// Opera 10-12/IE8 - ^= $= *= and empty values\n\t\t\t// Should not select anything\n\t\t\tdiv.innerHTML = \"<input type='hidden' i=''/>\";\n\t\t\tif ( div.querySelectorAll(\"[i^='']\").length ) {\n\t\t\t\trbuggyQSA.push( \"[*^$]=\" + whitespace + \"*(?:\\\"\\\"|'')\" );\n\t\t\t}\n\n\t\t\t// FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)\n\t\t\t// IE8 throws error here and will not see later tests\n\t\t\tif ( !div.querySelectorAll(\":enabled\").length ) {\n\t\t\t\trbuggyQSA.push( \":enabled\", \":disabled\" );\n\t\t\t}\n\n\t\t\t// Opera 10-11 does not throw on post-comma invalid pseudos\n\t\t\tdiv.querySelectorAll(\"*,:x\");\n\t\t\trbuggyQSA.push(\",.*:\");\n\t\t});\n\t}\n\n\tif ( (support.matchesSelector = isNative( (matches = docElem.matchesSelector ||\n\t\tdocElem.mozMatchesSelector ||\n\t\tdocElem.webkitMatchesSelector ||\n\t\tdocElem.oMatchesSelector ||\n\t\tdocElem.msMatchesSelector) )) ) {\n\n\t\tassert(function( div ) {\n\t\t\t// Check to see if it's possible to do matchesSelector\n\t\t\t// on a disconnected node (IE 9)\n\t\t\tsupport.disconnectedMatch = matches.call( div, \"div\" );\n\n\t\t\t// This should fail with an exception\n\t\t\t// Gecko does not error, returns false instead\n\t\t\tmatches.call( div, \"[s!='']:x\" );\n\t\t\trbuggyMatches.push( \"!=\", pseudos );\n\t\t});\n\t}\n\n\trbuggyQSA = new RegExp( rbuggyQSA.join(\"|\") );\n\trbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join(\"|\") );\n\n\t// Element contains another\n\t// Purposefully does not implement inclusive descendent\n\t// As in, an element does not contain itself\n\tcontains = isNative(docElem.contains) || docElem.compareDocumentPosition ?\n\t\tfunction( a, b ) {\n\t\t\tvar adown = a.nodeType === 9 ? a.documentElement : a,\n\t\t\t\tbup = b && b.parentNode;\n\t\t\treturn a === bup || !!( bup && bup.nodeType === 1 && (\n\t\t\t\tadown.contains ?\n\t\t\t\t\tadown.contains( bup ) :\n\t\t\t\t\ta.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16\n\t\t\t));\n\t\t} :\n\t\tfunction( a, b ) {\n\t\t\tif ( b ) {\n\t\t\t\twhile ( (b = b.parentNode) ) {\n\t\t\t\t\tif ( b === a ) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn false;\n\t\t};\n\n\t// Document order sorting\n\tsortOrder = docElem.compareDocumentPosition ?\n\tfunction( a, b ) {\n\n\t\t// Flag for duplicate removal\n\t\tif ( a === b ) {\n\t\t\thasDuplicate = true;\n\t\t\treturn 0;\n\t\t}\n\n\t\tvar compare = b.compareDocumentPosition && a.compareDocumentPosition && a.compareDocumentPosition( b );\n\n\t\tif ( compare ) {\n\t\t\t// Disconnected nodes\n\t\t\tif ( compare & 1 ||\n\t\t\t\t(recompare && b.compareDocumentPosition( a ) === compare) ) {\n\n\t\t\t\t// Choose the first element that is related to our preferred document\n\t\t\t\tif ( a === doc || contains(preferredDoc, a) ) {\n\t\t\t\t\treturn -1;\n\t\t\t\t}\n\t\t\t\tif ( b === doc || contains(preferredDoc, b) ) {\n\t\t\t\t\treturn 1;\n\t\t\t\t}\n\n\t\t\t\t// Maintain original order\n\t\t\t\treturn sortInput ?\n\t\t\t\t\t( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :\n\t\t\t\t\t0;\n\t\t\t}\n\n\t\t\treturn compare & 4 ? -1 : 1;\n\t\t}\n\n\t\t// Not directly comparable, sort on existence of method\n\t\treturn a.compareDocumentPosition ? -1 : 1;\n\t} :\n\tfunction( a, b ) {\n\t\tvar cur,\n\t\t\ti = 0,\n\t\t\taup = a.parentNode,\n\t\t\tbup = b.parentNode,\n\t\t\tap = [ a ],\n\t\t\tbp = [ b ];\n\n\t\t// Exit early if the nodes are identical\n\t\tif ( a === b ) {\n\t\t\thasDuplicate = true;\n\t\t\treturn 0;\n\n\t\t// Parentless nodes are either documents or disconnected\n\t\t} else if ( !aup || !bup ) {\n\t\t\treturn a === doc ? -1 :\n\t\t\t\tb === doc ? 1 :\n\t\t\t\taup ? -1 :\n\t\t\t\tbup ? 1 :\n\t\t\t\t0;\n\n\t\t// If the nodes are siblings, we can do a quick check\n\t\t} else if ( aup === bup ) {\n\t\t\treturn siblingCheck( a, b );\n\t\t}\n\n\t\t// Otherwise we need full lists of their ancestors for comparison\n\t\tcur = a;\n\t\twhile ( (cur = cur.parentNode) ) {\n\t\t\tap.unshift( cur );\n\t\t}\n\t\tcur = b;\n\t\twhile ( (cur = cur.parentNode) ) {\n\t\t\tbp.unshift( cur );\n\t\t}\n\n\t\t// Walk down the tree looking for a discrepancy\n\t\twhile ( ap[i] === bp[i] ) {\n\t\t\ti++;\n\t\t}\n\n\t\treturn i ?\n\t\t\t// Do a sibling check if the nodes have a common ancestor\n\t\t\tsiblingCheck( ap[i], bp[i] ) :\n\n\t\t\t// Otherwise nodes in our document sort first\n\t\t\tap[i] === preferredDoc ? -1 :\n\t\t\tbp[i] === preferredDoc ? 1 :\n\t\t\t0;\n\t};\n\n\treturn document;\n};\n\nSizzle.matches = function( expr, elements ) {\n\treturn Sizzle( expr, null, null, elements );\n};\n\nSizzle.matchesSelector = function( elem, expr ) {\n\t// Set document vars if needed\n\tif ( ( elem.ownerDocument || elem ) !== document ) {\n\t\tsetDocument( elem );\n\t}\n\n\t// Make sure that attribute selectors are quoted\n\texpr = expr.replace( rattributeQuotes, \"='$1']\" );\n\n\t// rbuggyQSA always contains :focus, so no need for an existence check\n\tif ( support.matchesSelector && documentIsHTML && (!rbuggyMatches || !rbuggyMatches.test(expr)) && !rbuggyQSA.test(expr) ) {\n\t\ttry {\n\t\t\tvar ret = matches.call( elem, expr );\n\n\t\t\t// IE 9's matchesSelector returns false on disconnected nodes\n\t\t\tif ( ret || support.disconnectedMatch ||\n\t\t\t\t\t// As well, disconnected nodes are said to be in a document\n\t\t\t\t\t// fragment in IE 9\n\t\t\t\t\telem.document && elem.document.nodeType !== 11 ) {\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t} catch(e) {}\n\t}\n\n\treturn Sizzle( expr, document, null, [elem] ).length > 0;\n};\n\nSizzle.contains = function( context, elem ) {\n\t// Set document vars if needed\n\tif ( ( context.ownerDocument || context ) !== document ) {\n\t\tsetDocument( context );\n\t}\n\treturn contains( context, elem );\n};\n\nSizzle.attr = function( elem, name ) {\n\tvar val;\n\n\t// Set document vars if needed\n\tif ( ( elem.ownerDocument || elem ) !== document ) {\n\t\tsetDocument( elem );\n\t}\n\n\tif ( documentIsHTML ) {\n\t\tname = name.toLowerCase();\n\t}\n\tif ( (val = Expr.attrHandle[ name ]) ) {\n\t\treturn val( elem );\n\t}\n\tif ( !documentIsHTML || support.attributes ) {\n\t\treturn elem.getAttribute( name );\n\t}\n\treturn ( (val = elem.getAttributeNode( name )) || elem.getAttribute( name ) ) && elem[ name ] === true ?\n\t\tname :\n\t\tval && val.specified ? val.value : null;\n};\n\nSizzle.error = function( msg ) {\n\tthrow new Error( \"Syntax error, unrecognized expression: \" + msg );\n};\n\n// Document sorting and removing duplicates\nSizzle.uniqueSort = function( results ) {\n\tvar elem,\n\t\tduplicates = [],\n\t\tj = 0,\n\t\ti = 0;\n\n\t// Unless we *know* we can detect duplicates, assume their presence\n\thasDuplicate = !support.detectDuplicates;\n\t// Compensate for sort limitations\n\trecompare = !support.sortDetached;\n\tsortInput = !support.sortStable && results.slice( 0 );\n\tresults.sort( sortOrder );\n\n\tif ( hasDuplicate ) {\n\t\twhile ( (elem = results[i++]) ) {\n\t\t\tif ( elem === results[ i ] ) {\n\t\t\t\tj = duplicates.push( i );\n\t\t\t}\n\t\t}\n\t\twhile ( j-- ) {\n\t\t\tresults.splice( duplicates[ j ], 1 );\n\t\t}\n\t}\n\n\treturn results;\n};\n\n/*\n * Checks document order of two siblings\n * @param {Element} a\n * @param {Element} b\n * @returns Returns -1 if a precedes b, 1 if a follows b\n */\nfunction siblingCheck( a, b ) {\n\tvar cur = b && a,\n\t\tdiff = cur && ( ~b.sourceIndex || MAX_NEGATIVE ) - ( ~a.sourceIndex || MAX_NEGATIVE );\n\n\t// Use IE sourceIndex if available on both nodes\n\tif ( diff ) {\n\t\treturn diff;\n\t}\n\n\t// Check if b follows a\n\tif ( cur ) {\n\t\twhile ( (cur = cur.nextSibling) ) {\n\t\t\tif ( cur === b ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn a ? 1 : -1;\n}\n\n// Returns a function to use in pseudos for input types\nfunction createInputPseudo( type ) {\n\treturn function( elem ) {\n\t\tvar name = elem.nodeName.toLowerCase();\n\t\treturn name === \"input\" && elem.type === type;\n\t};\n}\n\n// Returns a function to use in pseudos for buttons\nfunction createButtonPseudo( type ) {\n\treturn function( elem ) {\n\t\tvar name = elem.nodeName.toLowerCase();\n\t\treturn (name === \"input\" || name === \"button\") && elem.type === type;\n\t};\n}\n\n// Returns a function to use in pseudos for positionals\nfunction createPositionalPseudo( fn ) {\n\treturn markFunction(function( argument ) {\n\t\targument = +argument;\n\t\treturn markFunction(function( seed, matches ) {\n\t\t\tvar j,\n\t\t\t\tmatchIndexes = fn( [], seed.length, argument ),\n\t\t\t\ti = matchIndexes.length;\n\n\t\t\t// Match elements found at the specified indexes\n\t\t\twhile ( i-- ) {\n\t\t\t\tif ( seed[ (j = matchIndexes[i]) ] ) {\n\t\t\t\t\tseed[j] = !(matches[j] = seed[j]);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t});\n}\n\n/*\n * Utility function for retrieving the text value of an array of DOM nodes\n * @param {Array|Element} elem\n */\ngetText = Sizzle.getText = function( elem ) {\n\tvar node,\n\t\tret = \"\",\n\t\ti = 0,\n\t\tnodeType = elem.nodeType;\n\n\tif ( !nodeType ) {\n\t\t// If no nodeType, this is expected to be an array\n\t\tfor ( ; (node = elem[i]); i++ ) {\n\t\t\t// Do not traverse comment nodes\n\t\t\tret += getText( node );\n\t\t}\n\t} else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {\n\t\t// Use textContent for elements\n\t\t// innerText usage removed for consistency of new lines (see #11153)\n\t\tif ( typeof elem.textContent === \"string\" ) {\n\t\t\treturn elem.textContent;\n\t\t} else {\n\t\t\t// Traverse its children\n\t\t\tfor ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {\n\t\t\t\tret += getText( elem );\n\t\t\t}\n\t\t}\n\t} else if ( nodeType === 3 || nodeType === 4 ) {\n\t\treturn elem.nodeValue;\n\t}\n\t// Do not include comment or processing instruction nodes\n\n\treturn ret;\n};\n\nExpr = Sizzle.selectors = {\n\n\t// Can be adjusted by the user\n\tcacheLength: 50,\n\n\tcreatePseudo: markFunction,\n\n\tmatch: matchExpr,\n\n\tfind: {},\n\n\trelative: {\n\t\t\">\": { dir: \"parentNode\", first: true },\n\t\t\" \": { dir: \"parentNode\" },\n\t\t\"+\": { dir: \"previousSibling\", first: true },\n\t\t\"~\": { dir: \"previousSibling\" }\n\t},\n\n\tpreFilter: {\n\t\t\"ATTR\": function( match ) {\n\t\t\tmatch[1] = match[1].replace( runescape, funescape );\n\n\t\t\t// Move the given value to match[3] whether quoted or unquoted\n\t\t\tmatch[3] = ( match[4] || match[5] || \"\" ).replace( runescape, funescape );\n\n\t\t\tif ( match[2] === \"~=\" ) {\n\t\t\t\tmatch[3] = \" \" + match[3] + \" \";\n\t\t\t}\n\n\t\t\treturn match.slice( 0, 4 );\n\t\t},\n\n\t\t\"CHILD\": function( match ) {\n\t\t\t/* matches from matchExpr[\"CHILD\"]\n\t\t\t\t1 type (only|nth|...)\n\t\t\t\t2 what (child|of-type)\n\t\t\t\t3 argument (even|odd|\\d*|\\d*n([+-]\\d+)?|...)\n\t\t\t\t4 xn-component of xn+y argument ([+-]?\\d*n|)\n\t\t\t\t5 sign of xn-component\n\t\t\t\t6 x of xn-component\n\t\t\t\t7 sign of y-component\n\t\t\t\t8 y of y-component\n\t\t\t*/\n\t\t\tmatch[1] = match[1].toLowerCase();\n\n\t\t\tif ( match[1].slice( 0, 3 ) === \"nth\" ) {\n\t\t\t\t// nth-* requires argument\n\t\t\t\tif ( !match[3] ) {\n\t\t\t\t\tSizzle.error( match[0] );\n\t\t\t\t}\n\n\t\t\t\t// numeric x and y parameters for Expr.filter.CHILD\n\t\t\t\t// remember that false/true cast respectively to 0/1\n\t\t\t\tmatch[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === \"even\" || match[3] === \"odd\" ) );\n\t\t\t\tmatch[5] = +( ( match[7] + match[8] ) || match[3] === \"odd\" );\n\n\t\t\t// other types prohibit arguments\n\t\t\t} else if ( match[3] ) {\n\t\t\t\tSizzle.error( match[0] );\n\t\t\t}\n\n\t\t\treturn match;\n\t\t},\n\n\t\t\"PSEUDO\": function( match ) {\n\t\t\tvar excess,\n\t\t\t\tunquoted = !match[5] && match[2];\n\n\t\t\tif ( matchExpr[\"CHILD\"].test( match[0] ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Accept quoted arguments as-is\n\t\t\tif ( match[4] ) {\n\t\t\t\tmatch[2] = match[4];\n\n\t\t\t// Strip excess characters from unquoted arguments\n\t\t\t} else if ( unquoted && rpseudo.test( unquoted ) &&\n\t\t\t\t// Get excess from tokenize (recursively)\n\t\t\t\t(excess = tokenize( unquoted, true )) &&\n\t\t\t\t// advance to the next closing parenthesis\n\t\t\t\t(excess = unquoted.indexOf( \")\", unquoted.length - excess ) - unquoted.length) ) {\n\n\t\t\t\t// excess is a negative index\n\t\t\t\tmatch[0] = match[0].slice( 0, excess );\n\t\t\t\tmatch[2] = unquoted.slice( 0, excess );\n\t\t\t}\n\n\t\t\t// Return only captures needed by the pseudo filter method (type and argument)\n\t\t\treturn match.slice( 0, 3 );\n\t\t}\n\t},\n\n\tfilter: {\n\n\t\t\"TAG\": function( nodeName ) {\n\t\t\tif ( nodeName === \"*\" ) {\n\t\t\t\treturn function() { return true; };\n\t\t\t}\n\n\t\t\tnodeName = nodeName.replace( runescape, funescape ).toLowerCase();\n\t\t\treturn function( elem ) {\n\t\t\t\treturn elem.nodeName && elem.nodeName.toLowerCase() === nodeName;\n\t\t\t};\n\t\t},\n\n\t\t\"CLASS\": function( className ) {\n\t\t\tvar pattern = classCache[ className + \" \" ];\n\n\t\t\treturn pattern ||\n\t\t\t\t(pattern = new RegExp( \"(^|\" + whitespace + \")\" + className + \"(\" + whitespace + \"|$)\" )) &&\n\t\t\t\tclassCache( className, function( elem ) {\n\t\t\t\t\treturn pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute(\"class\")) || \"\" );\n\t\t\t\t});\n\t\t},\n\n\t\t\"ATTR\": function( name, operator, check ) {\n\t\t\treturn function( elem ) {\n\t\t\t\tvar result = Sizzle.attr( elem, name );\n\n\t\t\t\tif ( result == null ) {\n\t\t\t\t\treturn operator === \"!=\";\n\t\t\t\t}\n\t\t\t\tif ( !operator ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tresult += \"\";\n\n\t\t\t\treturn operator === \"=\" ? result === check :\n\t\t\t\t\toperator === \"!=\" ? result !== check :\n\t\t\t\t\toperator === \"^=\" ? check && result.indexOf( check ) === 0 :\n\t\t\t\t\toperator === \"*=\" ? check && result.indexOf( check ) > -1 :\n\t\t\t\t\toperator === \"$=\" ? check && result.slice( -check.length ) === check :\n\t\t\t\t\toperator === \"~=\" ? ( \" \" + result + \" \" ).indexOf( check ) > -1 :\n\t\t\t\t\toperator === \"|=\" ? result === check || result.slice( 0, check.length + 1 ) === check + \"-\" :\n\t\t\t\t\tfalse;\n\t\t\t};\n\t\t},\n\n\t\t\"CHILD\": function( type, what, argument, first, last ) {\n\t\t\tvar simple = type.slice( 0, 3 ) !== \"nth\",\n\t\t\t\tforward = type.slice( -4 ) !== \"last\",\n\t\t\t\tofType = what === \"of-type\";\n\n\t\t\treturn first === 1 && last === 0 ?\n\n\t\t\t\t// Shortcut for :nth-*(n)\n\t\t\t\tfunction( elem ) {\n\t\t\t\t\treturn !!elem.parentNode;\n\t\t\t\t} :\n\n\t\t\t\tfunction( elem, context, xml ) {\n\t\t\t\t\tvar cache, outerCache, node, diff, nodeIndex, start,\n\t\t\t\t\t\tdir = simple !== forward ? \"nextSibling\" : \"previousSibling\",\n\t\t\t\t\t\tparent = elem.parentNode,\n\t\t\t\t\t\tname = ofType && elem.nodeName.toLowerCase(),\n\t\t\t\t\t\tuseCache = !xml && !ofType;\n\n\t\t\t\t\tif ( parent ) {\n\n\t\t\t\t\t\t// :(first|last|only)-(child|of-type)\n\t\t\t\t\t\tif ( simple ) {\n\t\t\t\t\t\t\twhile ( dir ) {\n\t\t\t\t\t\t\t\tnode = elem;\n\t\t\t\t\t\t\t\twhile ( (node = node[ dir ]) ) {\n\t\t\t\t\t\t\t\t\tif ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {\n\t\t\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Reverse direction for :only-* (if we haven't yet done so)\n\t\t\t\t\t\t\t\tstart = dir = type === \"only\" && !start && \"nextSibling\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstart = [ forward ? parent.firstChild : parent.lastChild ];\n\n\t\t\t\t\t\t// non-xml :nth-child(...) stores cache data on `parent`\n\t\t\t\t\t\tif ( forward && useCache ) {\n\t\t\t\t\t\t\t// Seek `elem` from a previously-cached index\n\t\t\t\t\t\t\touterCache = parent[ expando ] || (parent[ expando ] = {});\n\t\t\t\t\t\t\tcache = outerCache[ type ] || [];\n\t\t\t\t\t\t\tnodeIndex = cache[0] === dirruns && cache[1];\n\t\t\t\t\t\t\tdiff = cache[0] === dirruns && cache[2];\n\t\t\t\t\t\t\tnode = nodeIndex && parent.childNodes[ nodeIndex ];\n\n\t\t\t\t\t\t\twhile ( (node = ++nodeIndex && node && node[ dir ] ||\n\n\t\t\t\t\t\t\t\t// Fallback to seeking `elem` from the start\n\t\t\t\t\t\t\t\t(diff = nodeIndex = 0) || start.pop()) ) {\n\n\t\t\t\t\t\t\t\t// When found, cache indexes on `parent` and break\n\t\t\t\t\t\t\t\tif ( node.nodeType === 1 && ++diff && node === elem ) {\n\t\t\t\t\t\t\t\t\touterCache[ type ] = [ dirruns, nodeIndex, diff ];\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Use previously-cached element index if available\n\t\t\t\t\t\t} else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {\n\t\t\t\t\t\t\tdiff = cache[1];\n\n\t\t\t\t\t\t// xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Use the same loop as above to seek `elem` from the start\n\t\t\t\t\t\t\twhile ( (node = ++nodeIndex && node && node[ dir ] ||\n\t\t\t\t\t\t\t\t(diff = nodeIndex = 0) || start.pop()) ) {\n\n\t\t\t\t\t\t\t\tif ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {\n\t\t\t\t\t\t\t\t\t// Cache the index of each encountered element\n\t\t\t\t\t\t\t\t\tif ( useCache ) {\n\t\t\t\t\t\t\t\t\t\t(node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif ( node === elem ) {\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Incorporate the offset, then check against cycle size\n\t\t\t\t\t\tdiff -= last;\n\t\t\t\t\t\treturn diff === first || ( diff % first === 0 && diff / first >= 0 );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t},\n\n\t\t\"PSEUDO\": function( pseudo, argument ) {\n\t\t\t// pseudo-class names are case-insensitive\n\t\t\t// http://www.w3.org/TR/selectors/#pseudo-classes\n\t\t\t// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters\n\t\t\t// Remember that setFilters inherits from pseudos\n\t\t\tvar args,\n\t\t\t\tfn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||\n\t\t\t\t\tSizzle.error( \"unsupported pseudo: \" + pseudo );\n\n\t\t\t// The user may use createPseudo to indicate that\n\t\t\t// arguments are needed to create the filter function\n\t\t\t// just as Sizzle does\n\t\t\tif ( fn[ expando ] ) {\n\t\t\t\treturn fn( argument );\n\t\t\t}\n\n\t\t\t// But maintain support for old signatures\n\t\t\tif ( fn.length > 1 ) {\n\t\t\t\targs = [ pseudo, pseudo, \"\", argument ];\n\t\t\t\treturn Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?\n\t\t\t\t\tmarkFunction(function( seed, matches ) {\n\t\t\t\t\t\tvar idx,\n\t\t\t\t\t\t\tmatched = fn( seed, argument ),\n\t\t\t\t\t\t\ti = matched.length;\n\t\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\t\tidx = indexOf.call( seed, matched[i] );\n\t\t\t\t\t\t\tseed[ idx ] = !( matches[ idx ] = matched[i] );\n\t\t\t\t\t\t}\n\t\t\t\t\t}) :\n\t\t\t\t\tfunction( elem ) {\n\t\t\t\t\t\treturn fn( elem, 0, args );\n\t\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn fn;\n\t\t}\n\t},\n\n\tpseudos: {\n\t\t// Potentially complex pseudos\n\t\t\"not\": markFunction(function( selector ) {\n\t\t\t// Trim the selector passed to compile\n\t\t\t// to avoid treating leading and trailing\n\t\t\t// spaces as combinators\n\t\t\tvar input = [],\n\t\t\t\tresults = [],\n\t\t\t\tmatcher = compile( selector.replace( rtrim, \"$1\" ) );\n\n\t\t\treturn matcher[ expando ] ?\n\t\t\t\tmarkFunction(function( seed, matches, context, xml ) {\n\t\t\t\t\tvar elem,\n\t\t\t\t\t\tunmatched = matcher( seed, null, xml, [] ),\n\t\t\t\t\t\ti = seed.length;\n\n\t\t\t\t\t// Match elements unmatched by `matcher`\n\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\tif ( (elem = unmatched[i]) ) {\n\t\t\t\t\t\t\tseed[i] = !(matches[i] = elem);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}) :\n\t\t\t\tfunction( elem, context, xml ) {\n\t\t\t\t\tinput[0] = elem;\n\t\t\t\t\tmatcher( input, null, xml, results );\n\t\t\t\t\treturn !results.pop();\n\t\t\t\t};\n\t\t}),\n\n\t\t\"has\": markFunction(function( selector ) {\n\t\t\treturn function( elem ) {\n\t\t\t\treturn Sizzle( selector, elem ).length > 0;\n\t\t\t};\n\t\t}),\n\n\t\t\"contains\": markFunction(function( text ) {\n\t\t\treturn function( elem ) {\n\t\t\t\treturn ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;\n\t\t\t};\n\t\t}),\n\n\t\t// \"Whether an element is represented by a :lang() selector\n\t\t// is based solely on the element's language value\n\t\t// being equal to the identifier C,\n\t\t// or beginning with the identifier C immediately followed by \"-\".\n\t\t// The matching of C against the element's language value is performed case-insensitively.\n\t\t// The identifier C does not have to be a valid language name.\"\n\t\t// http://www.w3.org/TR/selectors/#lang-pseudo\n\t\t\"lang\": markFunction( function( lang ) {\n\t\t\t// lang value must be a valid identifier\n\t\t\tif ( !ridentifier.test(lang || \"\") ) {\n\t\t\t\tSizzle.error( \"unsupported lang: \" + lang );\n\t\t\t}\n\t\t\tlang = lang.replace( runescape, funescape ).toLowerCase();\n\t\t\treturn function( elem ) {\n\t\t\t\tvar elemLang;\n\t\t\t\tdo {\n\t\t\t\t\tif ( (elemLang = documentIsHTML ?\n\t\t\t\t\t\telem.lang :\n\t\t\t\t\t\telem.getAttribute(\"xml:lang\") || elem.getAttribute(\"lang\")) ) {\n\n\t\t\t\t\t\telemLang = elemLang.toLowerCase();\n\t\t\t\t\t\treturn elemLang === lang || elemLang.indexOf( lang + \"-\" ) === 0;\n\t\t\t\t\t}\n\t\t\t\t} while ( (elem = elem.parentNode) && elem.nodeType === 1 );\n\t\t\t\treturn false;\n\t\t\t};\n\t\t}),\n\n\t\t// Miscellaneous\n\t\t\"target\": function( elem ) {\n\t\t\tvar hash = window.location && window.location.hash;\n\t\t\treturn hash && hash.slice( 1 ) === elem.id;\n\t\t},\n\n\t\t\"root\": function( elem ) {\n\t\t\treturn elem === docElem;\n\t\t},\n\n\t\t\"focus\": function( elem ) {\n\t\t\treturn elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);\n\t\t},\n\n\t\t// Boolean properties\n\t\t\"enabled\": function( elem ) {\n\t\t\treturn elem.disabled === false;\n\t\t},\n\n\t\t\"disabled\": function( elem ) {\n\t\t\treturn elem.disabled === true;\n\t\t},\n\n\t\t\"checked\": function( elem ) {\n\t\t\t// In CSS3, :checked should return both checked and selected elements\n\t\t\t// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked\n\t\t\tvar nodeName = elem.nodeName.toLowerCase();\n\t\t\treturn (nodeName === \"input\" && !!elem.checked) || (nodeName === \"option\" && !!elem.selected);\n\t\t},\n\n\t\t\"selected\": function( elem ) {\n\t\t\t// Accessing this property makes selected-by-default\n\t\t\t// options in Safari work properly\n\t\t\tif ( elem.parentNode ) {\n\t\t\t\telem.parentNode.selectedIndex;\n\t\t\t}\n\n\t\t\treturn elem.selected === true;\n\t\t},\n\n\t\t// Contents\n\t\t\"empty\": function( elem ) {\n\t\t\t// http://www.w3.org/TR/selectors/#empty-pseudo\n\t\t\t// :empty is only affected by element nodes and content nodes(including text(3), cdata(4)),\n\t\t\t// not comment, processing instructions, or others\n\t\t\t// Thanks to Diego Perini for the nodeName shortcut\n\t\t\t// Greater than \"@\" means alpha characters (specifically not starting with \"#\" or \"?\")\n\t\t\tfor ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {\n\t\t\t\tif ( elem.nodeName > \"@\" || elem.nodeType === 3 || elem.nodeType === 4 ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\n\t\t\"parent\": function( elem ) {\n\t\t\treturn !Expr.pseudos[\"empty\"]( elem );\n\t\t},\n\n\t\t// Element/input types\n\t\t\"header\": function( elem ) {\n\t\t\treturn rheader.test( elem.nodeName );\n\t\t},\n\n\t\t\"input\": function( elem ) {\n\t\t\treturn rinputs.test( elem.nodeName );\n\t\t},\n\n\t\t\"button\": function( elem ) {\n\t\t\tvar name = elem.nodeName.toLowerCase();\n\t\t\treturn name === \"input\" && elem.type === \"button\" || name === \"button\";\n\t\t},\n\n\t\t\"text\": function( elem ) {\n\t\t\tvar attr;\n\t\t\t// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)\n\t\t\t// use getAttribute instead to test this case\n\t\t\treturn elem.nodeName.toLowerCase() === \"input\" &&\n\t\t\t\telem.type === \"text\" &&\n\t\t\t\t( (attr = elem.getAttribute(\"type\")) == null || attr.toLowerCase() === elem.type );\n\t\t},\n\n\t\t// Position-in-collection\n\t\t\"first\": createPositionalPseudo(function() {\n\t\t\treturn [ 0 ];\n\t\t}),\n\n\t\t\"last\": createPositionalPseudo(function( matchIndexes, length ) {\n\t\t\treturn [ length - 1 ];\n\t\t}),\n\n\t\t\"eq\": createPositionalPseudo(function( matchIndexes, length, argument ) {\n\t\t\treturn [ argument < 0 ? argument + length : argument ];\n\t\t}),\n\n\t\t\"even\": createPositionalPseudo(function( matchIndexes, length ) {\n\t\t\tvar i = 0;\n\t\t\tfor ( ; i < length; i += 2 ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t}),\n\n\t\t\"odd\": createPositionalPseudo(function( matchIndexes, length ) {\n\t\t\tvar i = 1;\n\t\t\tfor ( ; i < length; i += 2 ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t}),\n\n\t\t\"lt\": createPositionalPseudo(function( matchIndexes, length, argument ) {\n\t\t\tvar i = argument < 0 ? argument + length : argument;\n\t\t\tfor ( ; --i >= 0; ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t}),\n\n\t\t\"gt\": createPositionalPseudo(function( matchIndexes, length, argument ) {\n\t\t\tvar i = argument < 0 ? argument + length : argument;\n\t\t\tfor ( ; ++i < length; ) {\n\t\t\t\tmatchIndexes.push( i );\n\t\t\t}\n\t\t\treturn matchIndexes;\n\t\t})\n\t}\n};\n\n// Add button/input type pseudos\nfor ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {\n\tExpr.pseudos[ i ] = createInputPseudo( i );\n}\nfor ( i in { submit: true, reset: true } ) {\n\tExpr.pseudos[ i ] = createButtonPseudo( i );\n}\n\nfunction tokenize( selector, parseOnly ) {\n\tvar matched, match, tokens, type,\n\t\tsoFar, groups, preFilters,\n\t\tcached = tokenCache[ selector + \" \" ];\n\n\tif ( cached ) {\n\t\treturn parseOnly ? 0 : cached.slice( 0 );\n\t}\n\n\tsoFar = selector;\n\tgroups = [];\n\tpreFilters = Expr.preFilter;\n\n\twhile ( soFar ) {\n\n\t\t// Comma and first run\n\t\tif ( !matched || (match = rcomma.exec( soFar )) ) {\n\t\t\tif ( match ) {\n\t\t\t\t// Don't consume trailing commas as valid\n\t\t\t\tsoFar = soFar.slice( match[0].length ) || soFar;\n\t\t\t}\n\t\t\tgroups.push( tokens = [] );\n\t\t}\n\n\t\tmatched = false;\n\n\t\t// Combinators\n\t\tif ( (match = rcombinators.exec( soFar )) ) {\n\t\t\tmatched = match.shift();\n\t\t\ttokens.push( {\n\t\t\t\tvalue: matched,\n\t\t\t\t// Cast descendant combinators to space\n\t\t\t\ttype: match[0].replace( rtrim, \" \" )\n\t\t\t} );\n\t\t\tsoFar = soFar.slice( matched.length );\n\t\t}\n\n\t\t// Filters\n\t\tfor ( type in Expr.filter ) {\n\t\t\tif ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||\n\t\t\t\t(match = preFilters[ type ]( match ))) ) {\n\t\t\t\tmatched = match.shift();\n\t\t\t\ttokens.push( {\n\t\t\t\t\tvalue: matched,\n\t\t\t\t\ttype: type,\n\t\t\t\t\tmatches: match\n\t\t\t\t} );\n\t\t\t\tsoFar = soFar.slice( matched.length );\n\t\t\t}\n\t\t}\n\n\t\tif ( !matched ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t// Return the length of the invalid excess\n\t// if we're just parsing\n\t// Otherwise, throw an error or return tokens\n\treturn parseOnly ?\n\t\tsoFar.length :\n\t\tsoFar ?\n\t\t\tSizzle.error( selector ) :\n\t\t\t// Cache the tokens\n\t\t\ttokenCache( selector, groups ).slice( 0 );\n}\n\nfunction toSelector( tokens ) {\n\tvar i = 0,\n\t\tlen = tokens.length,\n\t\tselector = \"\";\n\tfor ( ; i < len; i++ ) {\n\t\tselector += tokens[i].value;\n\t}\n\treturn selector;\n}\n\nfunction addCombinator( matcher, combinator, base ) {\n\tvar dir = combinator.dir,\n\t\tcheckNonElements = base && dir === \"parentNode\",\n\t\tdoneName = done++;\n\n\treturn combinator.first ?\n\t\t// Check against closest ancestor/preceding element\n\t\tfunction( elem, context, xml ) {\n\t\t\twhile ( (elem = elem[ dir ]) ) {\n\t\t\t\tif ( elem.nodeType === 1 || checkNonElements ) {\n\t\t\t\t\treturn matcher( elem, context, xml );\n\t\t\t\t}\n\t\t\t}\n\t\t} :\n\n\t\t// Check against all ancestor/preceding elements\n\t\tfunction( elem, context, xml ) {\n\t\t\tvar data, cache, outerCache,\n\t\t\t\tdirkey = dirruns + \" \" + doneName;\n\n\t\t\t// We can't set arbitrary data on XML nodes, so they don't benefit from dir caching\n\t\t\tif ( xml ) {\n\t\t\t\twhile ( (elem = elem[ dir ]) ) {\n\t\t\t\t\tif ( elem.nodeType === 1 || checkNonElements ) {\n\t\t\t\t\t\tif ( matcher( elem, context, xml ) ) {\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\twhile ( (elem = elem[ dir ]) ) {\n\t\t\t\t\tif ( elem.nodeType === 1 || checkNonElements ) {\n\t\t\t\t\t\touterCache = elem[ expando ] || (elem[ expando ] = {});\n\t\t\t\t\t\tif ( (cache = outerCache[ dir ]) && cache[0] === dirkey ) {\n\t\t\t\t\t\t\tif ( (data = cache[1]) === true || data === cachedruns ) {\n\t\t\t\t\t\t\t\treturn data === true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tcache = outerCache[ dir ] = [ dirkey ];\n\t\t\t\t\t\t\tcache[1] = matcher( elem, context, xml ) || cachedruns;\n\t\t\t\t\t\t\tif ( cache[1] === true ) {\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t};\n}\n\nfunction elementMatcher( matchers ) {\n\treturn matchers.length > 1 ?\n\t\tfunction( elem, context, xml ) {\n\t\t\tvar i = matchers.length;\n\t\t\twhile ( i-- ) {\n\t\t\t\tif ( !matchers[i]( elem, context, xml ) ) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t} :\n\t\tmatchers[0];\n}\n\nfunction condense( unmatched, map, filter, context, xml ) {\n\tvar elem,\n\t\tnewUnmatched = [],\n\t\ti = 0,\n\t\tlen = unmatched.length,\n\t\tmapped = map != null;\n\n\tfor ( ; i < len; i++ ) {\n\t\tif ( (elem = unmatched[i]) ) {\n\t\t\tif ( !filter || filter( elem, context, xml ) ) {\n\t\t\t\tnewUnmatched.push( elem );\n\t\t\t\tif ( mapped ) {\n\t\t\t\t\tmap.push( i );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn newUnmatched;\n}\n\nfunction setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {\n\tif ( postFilter && !postFilter[ expando ] ) {\n\t\tpostFilter = setMatcher( postFilter );\n\t}\n\tif ( postFinder && !postFinder[ expando ] ) {\n\t\tpostFinder = setMatcher( postFinder, postSelector );\n\t}\n\treturn markFunction(function( seed, results, context, xml ) {\n\t\tvar temp, i, elem,\n\t\t\tpreMap = [],\n\t\t\tpostMap = [],\n\t\t\tpreexisting = results.length,\n\n\t\t\t// Get initial elements from seed or context\n\t\t\telems = seed || multipleContexts( selector || \"*\", context.nodeType ? [ context ] : context, [] ),\n\n\t\t\t// Prefilter to get matcher input, preserving a map for seed-results synchronization\n\t\t\tmatcherIn = preFilter && ( seed || !selector ) ?\n\t\t\t\tcondense( elems, preMap, preFilter, context, xml ) :\n\t\t\t\telems,\n\n\t\t\tmatcherOut = matcher ?\n\t\t\t\t// If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,\n\t\t\t\tpostFinder || ( seed ? preFilter : preexisting || postFilter ) ?\n\n\t\t\t\t\t// ...intermediate processing is necessary\n\t\t\t\t\t[] :\n\n\t\t\t\t\t// ...otherwise use results directly\n\t\t\t\t\tresults :\n\t\t\t\tmatcherIn;\n\n\t\t// Find primary matches\n\t\tif ( matcher ) {\n\t\t\tmatcher( matcherIn, matcherOut, context, xml );\n\t\t}\n\n\t\t// Apply postFilter\n\t\tif ( postFilter ) {\n\t\t\ttemp = condense( matcherOut, postMap );\n\t\t\tpostFilter( temp, [], context, xml );\n\n\t\t\t// Un-match failing elements by moving them back to matcherIn\n\t\t\ti = temp.length;\n\t\t\twhile ( i-- ) {\n\t\t\t\tif ( (elem = temp[i]) ) {\n\t\t\t\t\tmatcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( seed ) {\n\t\t\tif ( postFinder || preFilter ) {\n\t\t\t\tif ( postFinder ) {\n\t\t\t\t\t// Get the final matcherOut by condensing this intermediate into postFinder contexts\n\t\t\t\t\ttemp = [];\n\t\t\t\t\ti = matcherOut.length;\n\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\tif ( (elem = matcherOut[i]) ) {\n\t\t\t\t\t\t\t// Restore matcherIn since elem is not yet a final match\n\t\t\t\t\t\t\ttemp.push( (matcherIn[i] = elem) );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tpostFinder( null, (matcherOut = []), temp, xml );\n\t\t\t\t}\n\n\t\t\t\t// Move matched elements from seed to results to keep them synchronized\n\t\t\t\ti = matcherOut.length;\n\t\t\t\twhile ( i-- ) {\n\t\t\t\t\tif ( (elem = matcherOut[i]) &&\n\t\t\t\t\t\t(temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {\n\n\t\t\t\t\t\tseed[temp] = !(results[temp] = elem);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t// Add elements to results, through postFinder if defined\n\t\t} else {\n\t\t\tmatcherOut = condense(\n\t\t\t\tmatcherOut === results ?\n\t\t\t\t\tmatcherOut.splice( preexisting, matcherOut.length ) :\n\t\t\t\t\tmatcherOut\n\t\t\t);\n\t\t\tif ( postFinder ) {\n\t\t\t\tpostFinder( null, results, matcherOut, xml );\n\t\t\t} else {\n\t\t\t\tpush.apply( results, matcherOut );\n\t\t\t}\n\t\t}\n\t});\n}\n\nfunction matcherFromTokens( tokens ) {\n\tvar checkContext, matcher, j,\n\t\tlen = tokens.length,\n\t\tleadingRelative = Expr.relative[ tokens[0].type ],\n\t\timplicitRelative = leadingRelative || Expr.relative[\" \"],\n\t\ti = leadingRelative ? 1 : 0,\n\n\t\t// The foundational matcher ensures that elements are reachable from top-level context(s)\n\t\tmatchContext = addCombinator( function( elem ) {\n\t\t\treturn elem === checkContext;\n\t\t}, implicitRelative, true ),\n\t\tmatchAnyContext = addCombinator( function( elem ) {\n\t\t\treturn indexOf.call( checkContext, elem ) > -1;\n\t\t}, implicitRelative, true ),\n\t\tmatchers = [ function( elem, context, xml ) {\n\t\t\treturn ( !leadingRelative && ( xml || context !== outermostContext ) ) || (\n\t\t\t\t(checkContext = context).nodeType ?\n\t\t\t\t\tmatchContext( elem, context, xml ) :\n\t\t\t\t\tmatchAnyContext( elem, context, xml ) );\n\t\t} ];\n\n\tfor ( ; i < len; i++ ) {\n\t\tif ( (matcher = Expr.relative[ tokens[i].type ]) ) {\n\t\t\tmatchers = [ addCombinator(elementMatcher( matchers ), matcher) ];\n\t\t} else {\n\t\t\tmatcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );\n\n\t\t\t// Return special upon seeing a positional matcher\n\t\t\tif ( matcher[ expando ] ) {\n\t\t\t\t// Find the next relative operator (if any) for proper handling\n\t\t\t\tj = ++i;\n\t\t\t\tfor ( ; j < len; j++ ) {\n\t\t\t\t\tif ( Expr.relative[ tokens[j].type ] ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn setMatcher(\n\t\t\t\t\ti > 1 && elementMatcher( matchers ),\n\t\t\t\t\ti > 1 && toSelector( tokens.slice( 0, i - 1 ) ).replace( rtrim, \"$1\" ),\n\t\t\t\t\tmatcher,\n\t\t\t\t\ti < j && matcherFromTokens( tokens.slice( i, j ) ),\n\t\t\t\t\tj < len && matcherFromTokens( (tokens = tokens.slice( j )) ),\n\t\t\t\t\tj < len && toSelector( tokens )\n\t\t\t\t);\n\t\t\t}\n\t\t\tmatchers.push( matcher );\n\t\t}\n\t}\n\n\treturn elementMatcher( matchers );\n}\n\nfunction matcherFromGroupMatchers( elementMatchers, setMatchers ) {\n\t// A counter to specify which element is currently being matched\n\tvar matcherCachedRuns = 0,\n\t\tbySet = setMatchers.length > 0,\n\t\tbyElement = elementMatchers.length > 0,\n\t\tsuperMatcher = function( seed, context, xml, results, expandContext ) {\n\t\t\tvar elem, j, matcher,\n\t\t\t\tsetMatched = [],\n\t\t\t\tmatchedCount = 0,\n\t\t\t\ti = \"0\",\n\t\t\t\tunmatched = seed && [],\n\t\t\t\toutermost = expandContext != null,\n\t\t\t\tcontextBackup = outermostContext,\n\t\t\t\t// We must always have either seed elements or context\n\t\t\t\telems = seed || byElement && Expr.find[\"TAG\"]( \"*\", expandContext && context.parentNode || context ),\n\t\t\t\t// Use integer dirruns iff this is the outermost matcher\n\t\t\t\tdirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1);\n\n\t\t\tif ( outermost ) {\n\t\t\t\toutermostContext = context !== document && context;\n\t\t\t\tcachedruns = matcherCachedRuns;\n\t\t\t}\n\n\t\t\t// Add elements passing elementMatchers directly to results\n\t\t\t// Keep `i` a string if there are no elements so `matchedCount` will be \"00\" below\n\t\t\tfor ( ; (elem = elems[i]) != null; i++ ) {\n\t\t\t\tif ( byElement && elem ) {\n\t\t\t\t\tj = 0;\n\t\t\t\t\twhile ( (matcher = elementMatchers[j++]) ) {\n\t\t\t\t\t\tif ( matcher( elem, context, xml ) ) {\n\t\t\t\t\t\t\tresults.push( elem );\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif ( outermost ) {\n\t\t\t\t\t\tdirruns = dirrunsUnique;\n\t\t\t\t\t\tcachedruns = ++matcherCachedRuns;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Track unmatched elements for set filters\n\t\t\t\tif ( bySet ) {\n\t\t\t\t\t// They will have gone through all possible matchers\n\t\t\t\t\tif ( (elem = !matcher && elem) ) {\n\t\t\t\t\t\tmatchedCount--;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Lengthen the array for every element, matched or not\n\t\t\t\t\tif ( seed ) {\n\t\t\t\t\t\tunmatched.push( elem );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Apply set filters to unmatched elements\n\t\t\tmatchedCount += i;\n\t\t\tif ( bySet && i !== matchedCount ) {\n\t\t\t\tj = 0;\n\t\t\t\twhile ( (matcher = setMatchers[j++]) ) {\n\t\t\t\t\tmatcher( unmatched, setMatched, context, xml );\n\t\t\t\t}\n\n\t\t\t\tif ( seed ) {\n\t\t\t\t\t// Reintegrate element matches to eliminate the need for sorting\n\t\t\t\t\tif ( matchedCount > 0 ) {\n\t\t\t\t\t\twhile ( i-- ) {\n\t\t\t\t\t\t\tif ( !(unmatched[i] || setMatched[i]) ) {\n\t\t\t\t\t\t\t\tsetMatched[i] = pop.call( results );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Discard index placeholder values to get only actual matches\n\t\t\t\t\tsetMatched = condense( setMatched );\n\t\t\t\t}\n\n\t\t\t\t// Add matches to results\n\t\t\t\tpush.apply( results, setMatched );\n\n\t\t\t\t// Seedless set matches succeeding multiple successful matchers stipulate sorting\n\t\t\t\tif ( outermost && !seed && setMatched.length > 0 &&\n\t\t\t\t\t( matchedCount + setMatchers.length ) > 1 ) {\n\n\t\t\t\t\tSizzle.uniqueSort( results );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Override manipulation of globals by nested matchers\n\t\t\tif ( outermost ) {\n\t\t\t\tdirruns = dirrunsUnique;\n\t\t\t\toutermostContext = contextBackup;\n\t\t\t}\n\n\t\t\treturn unmatched;\n\t\t};\n\n\treturn bySet ?\n\t\tmarkFunction( superMatcher ) :\n\t\tsuperMatcher;\n}\n\ncompile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {\n\tvar i,\n\t\tsetMatchers = [],\n\t\telementMatchers = [],\n\t\tcached = compilerCache[ selector + \" \" ];\n\n\tif ( !cached ) {\n\t\t// Generate a function of recursive functions that can be used to check each element\n\t\tif ( !group ) {\n\t\t\tgroup = tokenize( selector );\n\t\t}\n\t\ti = group.length;\n\t\twhile ( i-- ) {\n\t\t\tcached = matcherFromTokens( group[i] );\n\t\t\tif ( cached[ expando ] ) {\n\t\t\t\tsetMatchers.push( cached );\n\t\t\t} else {\n\t\t\t\telementMatchers.push( cached );\n\t\t\t}\n\t\t}\n\n\t\t// Cache the compiled function\n\t\tcached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );\n\t}\n\treturn cached;\n};\n\nfunction multipleContexts( selector, contexts, results ) {\n\tvar i = 0,\n\t\tlen = contexts.length;\n\tfor ( ; i < len; i++ ) {\n\t\tSizzle( selector, contexts[i], results );\n\t}\n\treturn results;\n}\n\nfunction select( selector, context, results, seed ) {\n\tvar i, tokens, token, type, find,\n\t\tmatch = tokenize( selector );\n\n\tif ( !seed ) {\n\t\t// Try to minimize operations if there is only one group\n\t\tif ( match.length === 1 ) {\n\n\t\t\t// Take a shortcut and set the context if the root selector is an ID\n\t\t\ttokens = match[0] = match[0].slice( 0 );\n\t\t\tif ( tokens.length > 2 && (token = tokens[0]).type === \"ID\" &&\n\t\t\t\t\tcontext.nodeType === 9 && documentIsHTML &&\n\t\t\t\t\tExpr.relative[ tokens[1].type ] ) {\n\n\t\t\t\tcontext = ( Expr.find[\"ID\"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];\n\t\t\t\tif ( !context ) {\n\t\t\t\t\treturn results;\n\t\t\t\t}\n\n\t\t\t\tselector = selector.slice( tokens.shift().value.length );\n\t\t\t}\n\n\t\t\t// Fetch a seed set for right-to-left matching\n\t\t\ti = matchExpr[\"needsContext\"].test( selector ) ? 0 : tokens.length;\n\t\t\twhile ( i-- ) {\n\t\t\t\ttoken = tokens[i];\n\n\t\t\t\t// Abort if we hit a combinator\n\t\t\t\tif ( Expr.relative[ (type = token.type) ] ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif ( (find = Expr.find[ type ]) ) {\n\t\t\t\t\t// Search, expanding context for leading sibling combinators\n\t\t\t\t\tif ( (seed = find(\n\t\t\t\t\t\ttoken.matches[0].replace( runescape, funescape ),\n\t\t\t\t\t\trsibling.test( tokens[0].type ) && context.parentNode || context\n\t\t\t\t\t)) ) {\n\n\t\t\t\t\t\t// If seed is empty or no tokens remain, we can return early\n\t\t\t\t\t\ttokens.splice( i, 1 );\n\t\t\t\t\t\tselector = seed.length && toSelector( tokens );\n\t\t\t\t\t\tif ( !selector ) {\n\t\t\t\t\t\t\tpush.apply( results, seed );\n\t\t\t\t\t\t\treturn results;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Compile and execute a filtering function\n\t// Provide `match` to avoid retokenization if we modified the selector above\n\tcompile( selector, match )(\n\t\tseed,\n\t\tcontext,\n\t\t!documentIsHTML,\n\t\tresults,\n\t\trsibling.test( selector )\n\t);\n\treturn results;\n}\n\n// Deprecated\nExpr.pseudos[\"nth\"] = Expr.pseudos[\"eq\"];\n\n// Easy API for creating new setFilters\nfunction setFilters() {}\nsetFilters.prototype = Expr.filters = Expr.pseudos;\nExpr.setFilters = new setFilters();\n\n// Check sort stability\nsupport.sortStable = expando.split(\"\").sort( sortOrder ).join(\"\") === expando;\n\n// Initialize with the default document\nsetDocument();\n\n// Always assume the presence of duplicates if sort doesn't\n// pass them to our comparison function (as in Google Chrome).\n[0, 0].sort( sortOrder );\nsupport.detectDuplicates = hasDuplicate;\n\n// EXPOSE\n/*if ( typeof define === \"function\" && define.amd ) {\n\tdefine(function() { return Sizzle; });\n} else {\n\twindow.Sizzle = Sizzle;\n}*/\n// EXPOSE\n\n/**\n * @namespace Ink.Dom.Selector\n * @static\n */\n\n/**\n * Alias for the Sizzle selector engine\n *\n * @method select\n * @param {String} selector CSS selector to search for elements\n * @param {DOMElement} [context] By default the search is done in the document element. However, you can specify an element as search context\n * @param {Array} [results] By default this is considered an empty array. But if you want to merge it with other searches you did, pass their result array through here.\n * @return {Array} Array of resulting DOM Elements\n * @sample Ink_Dom_Selector_select.html\n */\n\n/**\n * Filters elements that match a CSS selector.\n *\n * @method matches\n * @param {String} selector CSS selector to search for elements\n * @param {Array} matches Elements to be 'matched' with\n * @return {Array} Elements that matched\n * @sample Ink_Dom_Selector_matches.html\n */\n\n/**\n * Checks if an element matches a given selector\n *\n * @method matchesSelector\n * @param {DOMElement} element Element to test\n * @param {String} selector CSS selector to test the element with\n * @return {Boolean} True if element matches the CSS selector\n * @sample Ink_Dom_Selector_matchesSelector.html \n */\n\nreturn {\n select: Sizzle,\n matches: Sizzle.matches,\n matchesSelector: Sizzle.matchesSelector\n};\n\n\n}); //( window );\n","/**\n * Animate.css Utility\n *\n * This module is a wrapper around animate.css's CSS classes to produce animation.\n * It contains options to ease common tasks, like listen to the \"animationend\" event with all necessary prefixes, remove the necessary class names when the animation finishes, or configure the duration of your animation with the necessary browser prefix.\n *\n * @module Ink.UI.Animate_1\n * @version 1\n */\n\nInk.createModule('Ink.UI.Animate', 1, ['Ink.UI.Common_1', 'Ink.Dom.Event_1', 'Ink.Dom.Css_1'], function (Common, InkEvent, Css) {\n 'use strict';\n\n var animationPrefix = (function (el) {\n return ('animationName' in el.style) ? 'animation' :\n ('oAnimationName' in el.style) ? 'oAnimation' :\n ('msAnimationName' in el.style) ? 'msAnimation' :\n ('webkitAnimationName' in el.style) ? 'webkitAnimation' : null;\n }(document.createElement('div')));\n\n var animationEndEventName = {\n animation: 'animationend',\n oAnimation: 'oanimationend',\n msAnimation: 'MSAnimationEnd',\n webkitAnimation: 'webkitAnimationEnd'\n }[animationPrefix];\n\n /**\n * @class Ink.UI.Animate_1\n * @constructor\n *\n * @param {DOMElement} element Animated element\n * @param {Object} options Options object\n * @param {String} options.animation Animation name\n * @param {String|Number} [options.duration] Duration name (fast|medium|slow) or duration in milliseconds. Defaults to 'medium'.\n * @param {Boolean} [options.removeClass] Flag to remove the CSS class when finished animating. Defaults to false.\n * @param {Function} [options.onEnd] Callback for the animation end\n *\n * @sample Ink_UI_Animate_1.html\n *\n **/\n function Animate() {\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n Animate._name = 'Animate_1';\n\n Animate._optionDefinition = {\n trigger: ['Element', null],\n duration: ['String', 'slow'], // Actually a string with a duration name, or a number of ms\n animation: ['String'],\n removeClass: ['Boolean', true],\n onEnd: ['Function', function () {}]\n };\n\n Animate.prototype._init = function () {\n if (!isNaN(parseInt(this._options.duration, 10))) {\n this._options.duration = parseInt(this._options.duration, 10);\n }\n\n if (this._options.trigger) {\n InkEvent.observe(this._options.trigger, 'click', Ink.bind(function () {\n this.animate();\n }, this)); // later\n } else {\n this.animate();\n }\n };\n\n Animate.prototype.animate = function () {\n Animate.animate(this._element, this._options.animation, this._options);\n };\n\n Ink.extendObj(Animate, {\n /**\n * Browser prefix for the CSS animations.\n *\n * @property _animationPrefix\n * @private\n **/\n _animationPrefix: animationPrefix,\n\n /**\n * Boolean which says whether this browser has CSS3 animation support.\n *\n * @property animationSupported\n **/\n animationSupported: !!animationPrefix,\n\n /**\n * Prefixed 'animationend' event name.\n *\n * @property animationEndEventName\n **/\n animationEndEventName: animationEndEventName,\n\n /**\n * Animate an element using one of the animate.css classes\n *\n * **Note: This is a utility method inside the `Animate` class, which you can access through `Animate.animate()`. Do not mix these up.**\n *\n * @static\n * @method animate\n * @param element {DOMElement} animated element\n * @param animation {String} animation name\n * @param [options] {Object}\n * @param [options.onEnd=null] {Function} callback for animation end\n * @param [options.removeClass=false] {Boolean} whether to remove the Css class when finished\n * @param [options.duration=medium] {String|Number} duration name (fast|medium|slow) or duration in ms\n *\n * @sample Ink_UI_Animate_1_animate.html\n **/\n animate: function (element, animation, options) {\n element = Common.elOrSelector(element);\n\n if (typeof options === 'number' || typeof options === 'string') {\n options = { duration: options };\n } else if (!options) {\n options = {};\n }\n\n if (typeof arguments[3] === 'function') {\n options.onEnd = arguments[3];\n }\n\n if (typeof options.duration !== 'number' && typeof options.duration !== 'string') {\n options.duration = 400;\n }\n\n if (!Animate.animationSupported) {\n if (options.onEnd) {\n setTimeout(function () {\n options.onEnd(null);\n }, 0);\n }\n return;\n }\n\n if (typeof options.duration === 'number') {\n element.style[animationPrefix + 'Duration'] = options.duration + 'ms';\n } else if (typeof options.duration === 'string') {\n Css.addClassName(element, options.duration);\n }\n\n Css.addClassName(element, ['animated', animation]);\n\n function onAnimationEnd(event) {\n if (event.target !== element) { return; }\n if (event.animationName !== animation) { return; }\n if (options.onEnd) { options.onEnd(event); }\n if (options.removeClass) {\n Css.removeClassName(element, animation);\n }\n if (typeof options.duration === 'string') {\n Css.removeClassName(element, options.duration);\n }\n element.removeEventListener(animationEndEventName, onAnimationEnd, false);\n }\n\n element.addEventListener(animationEndEventName, onAnimationEnd, false);\n }\n });\n\n Common.createUIComponent(Animate);\n\n return Animate;\n});\n","/**\n * Flexible Carousel\n * @module Ink.UI.Carousel_1\n * @version 1\n */\n\nInk.createModule('Ink.UI.Carousel', '1',\n ['Ink.UI.Common_1', 'Ink.Dom.Event_1', 'Ink.Dom.Css_1', 'Ink.Dom.Element_1', 'Ink.UI.Pagination_1', 'Ink.Dom.Browser_1', 'Ink.Dom.Selector_1'],\n function(Common, InkEvent, Css, InkElement, Pagination, Browser/*, Selector*/) {\n 'use strict';\n\n /*\n * TODO:\n * keyboardSupport\n */\n\n function limitRange(n, min, max) {\n return Math.min(max, Math.max(min, n));\n }\n\n var requestAnimationFrame = window.requestAnimationFrame ||\n window.mozRequestAnimationFrame ||\n window.webkitRequestAnimationFrame ||\n function (cb) {return setTimeout(cb, 1000 / 30); };\n\n /**\n * @class Ink.UI.Carousel_1\n * @constructor\n *\n * @param {String|DOMElement} selector DOM element or element id\n * @param {Object} [options] Carousel Options\n * @param {Integer} [options.autoAdvance] Milliseconds to wait before auto-advancing pages. Set to 0 to disable auto-advance. Defaults to 0.\n * @param {String} [options.axis] Axis of the carousel. Set to 'y' for a vertical carousel. Defaults to 'x'.\n * @param {Number} [options.initialPage] Initial index page of the carousel. Defaults to 0.\n * @param {Boolean} [options.spaceAfterLastSlide=true] If there are not enough slides to fill the full width of the last page, leave white space. Defaults to `true`.\n * @param {Boolean} [options.swipe] Enable swipe support if available. Defaults to true.\n * @param {Mixed} [options.pagination] Either an ul element to add pagination markup to or an `Ink.UI.Pagination` instance to use.\n * @param {Function} [options.onChange] Callback to be called when the page changes.\n *\n * @sample Ink_UI_Carousel_1.html\n */\n function Carousel() {\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n Carousel._name = 'Carousel_1';\n\n Carousel._optionDefinition = {\n autoAdvance: ['Integer', 0],\n axis: ['String', 'x'],\n initialPage: ['Integer', 0],\n spaceAfterLastSlide: ['Boolean', true],\n hideLast: ['Boolean', false],\n // [3.1.0] Deprecate \"center\". It is only needed when things are of unknown widths.\n center: ['Boolean', false],\n keyboardSupport:['Boolean', false],\n pagination: ['String', null],\n onChange: ['Function', null],\n onInit: ['Function', function () {}],\n swipe: ['Boolean', true]\n // TODO exponential swipe\n // TODO specify break point for next page when moving finger\n };\n\n Carousel.prototype = {\n _init: function () {\n this._handlers = {\n paginationChange: Ink.bindMethod(this, '_onPaginationChange'),\n windowResize: InkEvent.throttle(Ink.bindMethod(this, 'refit'), 200)\n };\n\n InkEvent.observe(window, 'resize', this._handlers.windowResize);\n\n this._isY = (this._options.axis === 'y');\n\n var ulEl = Ink.s('ul.stage', this._element);\n this._ulEl = ulEl;\n\n InkElement.removeTextNodeChildren(ulEl);\n\n if (this._options.pagination == null) {\n this._currentPage = this._options.initialPage;\n }\n\n this.refit(); // recalculate this._numPages\n\n if (this._isY) {\n // Override white-space: no-wrap which is only necessary to make sure horizontal stuff stays horizontal, but breaks stuff intended to be vertical.\n this._ulEl.style.whiteSpace = 'normal';\n }\n\n if (this._options.swipe) {\n InkEvent.observe(this._element, 'touchstart', Ink.bindMethod(this, '_onTouchStart'));\n InkEvent.observe(this._element, 'touchmove', Ink.bindMethod(this, '_onTouchMove'));\n InkEvent.observe(this._element, 'touchend', Ink.bindMethod(this, '_onTouchEnd'));\n }\n\n this._setUpPagination();\n this._setUpAutoAdvance();\n this._setUpHider();\n\n this._options.onInit.call(this, this);\n },\n\n /**\n * Repositions elements around.\n * Measure the carousel once again, adjusting the involved elements' sizes. This is called automatically when the window resizes, in order to cater for changes from responsive media queries, for instance.\n *\n * @method refit\n * @public\n */\n refit: function() {\n var _isY = this._isY;\n\n var size = function (elm, perpendicular) {\n if (!elm) { return 0; }\n\n if (!perpendicular) {\n return InkElement.outerDimensions(elm)[_isY ? 1 : 0];\n } else {\n return InkElement.outerDimensions(elm)[_isY ? 0 : 1];\n }\n };\n\n this._liEls = Ink.ss('li.slide', this._ulEl);\n var numSlides = this._liEls.length;\n\n var contRect = this._ulEl.getBoundingClientRect();\n this._ctnLength = _isY ? contRect.bottom - contRect.top : contRect.right - contRect.left;\n this._elLength = size(this._liEls[0]);\n this._slidesPerPage = Math.floor( this._ctnLength / this._elLength ) || 1;\n if (!isFinite(this._slidesPerPage)) { this._slidesPerPage = 1; }\n\n var numPages = Math.ceil( numSlides / this._slidesPerPage );\n var numPagesChanged = this._numPages !== numPages;\n this._numPages = numPages;\n this._deltaLength = this._slidesPerPage * this._elLength;\n \n this._center();\n this._updateHider();\n this._IE7();\n\n if (this._pagination && numPagesChanged) {\n this._pagination.setSize(this._numPages);\n }\n this.setPage(limitRange(this.getPage(), 0, this._numPages));\n },\n\n _setUpPagination: function () {\n if (this._options.pagination) {\n if (Common.isDOMElement(this._options.pagination) ||\n typeof this._options.pagination === 'string') {\n // if dom element or css selector string...\n this._pagination = new Pagination(this._options.pagination, {\n size: this._numPages,\n onChange: this._handlers.paginationChange\n });\n } else {\n // assumes instantiated pagination\n this._pagination = this._options.pagination;\n this._pagination._options.onChange = this._handlers.paginationChange;\n this._pagination.setSize(this._numPages);\n }\n this._pagination.setCurrent(this._options.initialPage || 0);\n } else {\n this._currentPage = this._options.initialPage || 0;\n }\n },\n\n _setUpAutoAdvance: function () {\n if (!this._options.autoAdvance) { return; }\n var self = this;\n\n setTimeout(function autoAdvance() {\n self.nextPage(true /* wrap */);\n setTimeout(autoAdvance, self._options.autoAdvance);\n }, this._options.autoAdvance);\n },\n\n _setUpHider: function () {\n if (this._options.hideLast) {\n var hiderEl = InkElement.create('div', {\n className: 'hider',\n insertBottom: this._element\n });\n hiderEl.style.position = 'absolute';\n hiderEl.style[ this._isY ? 'left' : 'top' ] = '0'; // fix to top..\n hiderEl.style[ this._isY ? 'right' : 'bottom' ] = '0'; // and bottom...\n hiderEl.style[ this._isY ? 'bottom' : 'right' ] = '0'; // and move to the end.\n this._hiderEl = hiderEl;\n }\n },\n\n // [3.1.0] Deprecate this already\n _center: function() {\n if (!this._options.center) { return; }\n var gap = Math.floor( (this._ctnLength - (this._elLength * this._slidesPerPage) ) / 2 );\n\n var pad;\n if (this._isY) {\n pad = [gap, 'px 0'];\n } else {\n pad = ['0 ', gap, 'px'];\n }\n\n this._ulEl.style.padding = pad.join('');\n },\n\n // [3.1.0] Deprecate this already\n _updateHider: function() {\n if (!this._hiderEl) { return; }\n if (this.getPage() === 0) {\n var gap = Math.floor( this._ctnLength - (this._elLength * this._slidesPerPage) );\n if (this._options.center) {\n gap /= 2;\n }\n this._hiderEl.style[ this._isY ? 'height' : 'width' ] = gap + 'px';\n } else {\n this._hiderEl.style[ this._isY ? 'height' : 'width' ] = '0px';\n }\n },\n \n /**\n * Refits elements for IE7 because it doesn't support inline-block.\n *\n * @method _IE7\n * @private\n */\n _IE7: function () {\n if (Browser.IE && '' + Browser.version.split('.')[0] === '7') {\n // var numPages = this._numPages;\n var slides = Ink.ss('li.slide', this._ulEl);\n var stl = function (prop, val) {slides[i].style[prop] = val; };\n for (var i = 0, len = slides.length; i < len; i++) {\n stl('position', 'absolute');\n stl(this._isY ? 'top' : 'left', (i * this._elLength) + 'px');\n }\n }\n },\n\n _onTouchStart: function (event) {\n if (event.touches.length > 1) { return; }\n\n this._swipeData = {\n x: InkEvent.pointerX(event),\n y: InkEvent.pointerY(event)\n };\n\n var ulRect = this._ulEl.getBoundingClientRect();\n\n this._swipeData.firstUlPos = ulRect[this._isY ? 'top' : 'left'];\n\n this._swipeData.inUlX = this._swipeData.x - ulRect.left;\n this._swipeData.inUlY = this._swipeData.y - ulRect.top;\n\n setTransitionProperty(this._ulEl, 'none');\n\n this._touchMoveIsFirstTouchMove = true;\n },\n\n _onTouchMove: function (event) {\n if (event.touches.length > 1) { return; /* multitouch event, not my problem. */ }\n\n var pointerX = InkEvent.pointerX(event);\n var pointerY = InkEvent.pointerY(event);\n\n var deltaY = Math.abs(pointerY - this._swipeData.y);\n var deltaX = Math.abs(pointerX - this._swipeData.x);\n\n if (this._touchMoveIsFirstTouchMove) {\n this._touchMoveIsFirstTouchMove = undefined;\n this._scrolling = this._isY ?\n deltaX > deltaY :\n deltaY > deltaX ;\n\n if (!this._scrolling) {\n this._onAnimationFrame();\n }\n }\n\n if (!this._scrolling && this._swipeData) {\n InkEvent.stopDefault(event);\n\n this._swipeData.pointerPos = this._isY ? pointerY : pointerX;\n }\n },\n\n _onAnimationFrame: function () {\n var swipeData = this._swipeData;\n\n if (!swipeData || this._scrolling || this._touchMoveIsFirstTouchMove) { return; }\n\n var elRect = this._element.getBoundingClientRect();\n\n var newPos;\n\n if (!this._isY) {\n newPos = swipeData.pointerPos - swipeData.inUlX - elRect.left;\n } else {\n newPos = swipeData.pointerPos - swipeData.inUlY - elRect.top;\n }\n\n this._ulEl.style[this._isY ? 'top' : 'left'] = newPos + 'px';\n\n requestAnimationFrame(Ink.bindMethod(this, '_onAnimationFrame'));\n },\n\n _onTouchEnd: function (event) {\n if (this._swipeData && this._swipeData.pointerPos && !this._scrolling && !this._touchMoveIsFirstTouchMove) {\n var snapToNext = 0.1; // swipe 10% of the way to change page\n\n var relProgress = this._swipeData.firstUlPos -\n this._ulEl.getBoundingClientRect()[this._isY ? 'top' : 'left'];\n\n var curPage = this.getPage();\n\n // How many pages were advanced? May be fractional.\n var progressInPages = relProgress / this._elLength / this._slidesPerPage;\n\n // Have we advanced enough to change page?\n if (Math.abs(progressInPages) > snapToNext) {\n curPage += Math[ relProgress < 0 ? 'floor' : 'ceil' ](progressInPages);\n }\n\n // If something used to calculate progressInPages was zero, we get NaN here.\n if (!isNaN(curPage)) {\n this.setPage(curPage);\n }\n\n InkEvent.stopDefault(event);\n }\n\n setTransitionProperty(this._ulEl, null /* transition: left, top */);\n this._swipeData = null;\n this._touchMoveIsFirstTouchMove = undefined;\n this._scrolling = undefined;\n },\n\n _onPaginationChange: function(pgn) {\n this._setPage(pgn.getCurrent());\n },\n\n /**\n * Gets the current page index\n * @method getPage\n * @return The current page number\n **/\n getPage: function () {\n if (this._pagination) {\n return this._pagination.getCurrent();\n } else {\n return this._currentPage || 0;\n }\n },\n\n /**\n * Sets the current page index\n * @method setPage\n * @param {Number} page Index of the destination page.\n * @param {Boolean} [wrap] Flag to activate circular counting.\n **/\n setPage: function (page, wrap) {\n if (wrap) {\n // Pages outside the range [0..this._numPages] are wrapped.\n page = page % this._numPages;\n if (page < 0) { page = this._numPages - page; }\n }\n page = limitRange(page, 0, this._numPages - 1);\n\n if (this._pagination) {\n this._pagination.setCurrent(page); // _setPage is called by pagination because it listens to its Change event.\n } else {\n this._setPage(page);\n }\n },\n\n _setPage: function (page) {\n var _lengthToGo = page * this._deltaLength;\n var isLastPage = page === (this._numPages - 1);\n\n if (!this._options.spaceAfterLastSlide && isLastPage && page > 0) { \n var _itemsInLastPage = this._liEls.length - (page * this._slidesPerPage);\n if(_itemsInLastPage < this._slidesPerPage) {\n _lengthToGo = ((page - 1) * this._deltaLength) + (_itemsInLastPage * this._elLength);\n }\n }\n\n this._ulEl.style[ this._isY ? 'top' : 'left'] =\n ['-', _lengthToGo, 'px'].join('');\n\n if (this._options.onChange) {\n this._options.onChange.call(this, page);\n }\n\n this._currentPage = page;\n\n this._updateHider();\n },\n\n /**\n * Goes to the next page\n * @method nextPage\n * @param {Boolean} [wrap] Flag to loop from last page to first page.\n **/\n nextPage: function (wrap) {\n this.setPage(this.getPage() + 1, wrap);\n },\n\n /**\n * Goes to the previous page\n * @method previousPage\n * @param {Boolean} [wrap] Flag to loop from first page to last page.\n **/\n previousPage: function (wrap) { this.setPage(this.getPage() - 1, wrap); },\n\n /**\n * Returns how many slides fit into a page\n * @method getSlidesPerPage\n * @return {Number} The number of slides per page\n * @public\n */\n getSlidesPerPage: function() {\n return this._slidesPerPage;\n },\n\n /**\n * Get the amount of pages in the carousel.\n * @method getTotalPages\n * @return {Number} The number of pages\n * @public\n */\n getTotalPages: function() {\n return this._numPages;\n },\n\n /**\n * Get the stage element (your UL with the class \".stage\").\n * @method getStageElm\n * @public\n * @return {DOMElement} Stage element\n **/\n getStageElm: function() {\n return this._ulEl;\n },\n\n /**\n * Get a list of your slides (elements with the \".slide\" class inside your stage)\n * @method getSlidesList\n * @return {DOMElement[]} Array containing the slides.\n * @public\n */\n getSlidesList: function() {\n return this._liEls;\n },\n\n /**\n * Get the total number of slides\n * @method getTotalSlides\n * @return {Number} The number of slides\n * @public\n */\n getTotalSlides: function() {\n return this.getSlidesList().length;\n }\n };\n\n function setTransitionProperty(el, newTransition) {\n el.style.transitionProperty =\n el.style.oTransitionProperty =\n el.style.msTransitionProperty =\n el.style.mozTransitionProperty =\n el.style.webkitTransitionProperty = newTransition;\n }\n\n Common.createUIComponent(Carousel);\n\n return Carousel;\n\n});\n","/**\n * Closing utilities\n * @module Ink.UI.Close_1\n * @version 1\n */\nInk.createModule('Ink.UI.Close', '1', ['Ink.Dom.Event_1','Ink.Dom.Element_1'], function(InkEvent, InkElement) {\n 'use strict';\n\n /**\n * Subscribes clicks on the document.body.\n * Whenever an element with the classes \".ink-close\" or \".ink-dismiss\" is clicked, this module finds an ancestor \".ink-alert\" or \".ink-alert-block\" element and removes it from the DOM.\n * This module should be created only once per page.\n * \n * @class Ink.UI.Close\n * @constructor\n * @example\n * <script>\n * Ink.requireModules(['Ink.UI.Close_1'],function( Close ){\n * new Close();\n * });\n * </script>\n *\n * @sample Ink_UI_Close_1.html\n */\n var Close = function() {\n InkEvent.observe(document.body, 'click', function(ev) {\n var el = InkEvent.element(ev);\n\n el = InkElement.findUpwardsByClass(el, 'ink-close') ||\n InkElement.findUpwardsByClass(el, 'ink-dismiss');\n\n if (!el) {\n return; // ink-close or ink-dismiss class not found\n }\n\n var toRemove = InkElement.findUpwardsByClass(el, 'ink-alert') ||\n InkElement.findUpwardsByClass(el, 'ink-alert-block') ||\n el;\n\n if (toRemove) {\n InkEvent.stop(ev);\n InkElement.remove(toRemove);\n }\n });\n };\n\n Close._name = 'Close_1';\n\n return Close;\n});\n","/**\n * Auxiliar utilities for UI Modules\n * @module Ink.UI.Common_1\n * @version 1\n */\n \nInk.createModule('Ink.UI.Common', '1', ['Ink.Dom.Element_1', 'Ink.Net.Ajax_1','Ink.Dom.Css_1','Ink.Dom.Selector_1','Ink.Util.Url_1'], function(InkElement, Ajax,Css,Selector,Url) {\n\n 'use strict';\n\n var nothing = {} /* a marker, for reference comparison. */;\n\n var keys = Object.keys || function (obj) {\n var ret = [];\n for (var k in obj) if (obj.hasOwnProperty(k)) {\n ret.push(k);\n }\n return ret;\n };\n\n var es6WeakMapSupport = 'WeakMap' in window;\n var instances = es6WeakMapSupport ? new WeakMap() : null;\n\n var domRegistry = {\n get: function get(el) {\n return es6WeakMapSupport ?\n instances.get(el) :\n el.__InkInstances;\n },\n set: function set(el, thing) {\n if (es6WeakMapSupport) {\n instances.set(el, thing);\n } else {\n el.__InkInstances = thing;\n }\n }\n };\n\n /**\n * @namespace Ink.UI.Common_1\n */\n\n var Common = {\n\n /**\n * Supported Ink Layouts\n *\n * @property Layouts\n * @type Object\n * @readOnly\n */\n Layouts: {\n TINY: 'tiny',\n SMALL: 'small',\n MEDIUM: 'medium',\n LARGE: 'large',\n XLARGE: 'xlarge'\n },\n\n /**\n * Checks if an item is a valid DOM Element.\n *\n * @method isDOMElement\n * @static\n * @param {Mixed} o The object to be checked.\n * @return {Boolean} True if it's a valid DOM Element.\n * @example\n * var el = Ink.s('#element');\n * if( Ink.UI.Common.isDOMElement( el ) === true ){\n * // It is a DOM Element.\n * } else {\n * // It is NOT a DOM Element.\n * }\n */\n isDOMElement: InkElement.isDOMElement,\n\n /**\n * Checks if an item is a valid integer.\n *\n * @method isInteger\n * @static\n * @param {Mixed} n The value to be checked.\n * @return {Boolean} True if it's a valid integer.\n * @example\n * var value = 1;\n * if( Ink.UI.Common.isInteger( value ) === true ){\n * // It is an integer.\n * } else {\n * // It is NOT an integer.\n * }\n */\n isInteger: function(n) {\n return (typeof n === 'number' && n % 1 === 0);\n },\n\n /**\n * Gets a DOM Element. \n *\n * @method elOrSelector\n * @static\n * @param {DOMElement|String} elOrSelector DOM Element or CSS Selector\n * @param {String} fieldName The name of the field. Commonly used for debugging.\n * @return {DOMElement} Returns the DOMElement passed or the first result of the CSS Selector. Otherwise it throws an exception.\n * @example\n * // In case there are several .myInput, it will retrieve the first found\n * var el = Ink.UI.Common.elOrSelector('.myInput','My Input');\n */\n elOrSelector: function(elOrSelector, fieldName) {\n if (!this.isDOMElement(elOrSelector)) {\n var t = Selector.select(elOrSelector);\n if (t.length === 0) {\n Ink.warn(fieldName + ' must either be a DOM Element or a selector expression!\\nThe script element must also be after the DOM Element itself.');\n return null;\n }\n return t[0];\n }\n return elOrSelector;\n },\n\n /**\n * Alias for `elOrSelector` but returns an array of elements.\n *\n * @method elsOrSelector\n *\n * @static\n * @param {DOMElement|String} elOrSelector DOM Element or CSS Selector\n * @param {String} fieldName The name of the field. Commonly used for debugging.\n * @return {DOMElement} Returns the DOMElement passed or the first result of the CSS Selector. Otherwise it throws an exception.\n * @param {Boolean} required Flag to accept an empty array as output.\n * @return {Array} The selected DOM Elements.\n * @example\n * var elements = Ink.UI.Common.elsOrSelector('input.my-inputs', 'My Input');\n */\n elsOrSelector: function(elsOrSelector, fieldName, required) {\n var ret;\n if (typeof elsOrSelector === 'string') {\n ret = Selector.select(elsOrSelector);\n } else if (Common.isDOMElement(elsOrSelector)) {\n ret = [elsOrSelector];\n } else if (elsOrSelector && typeof elsOrSelector === 'object' && typeof elsOrSelector.length === 'number') {\n ret = elsOrSelector;\n }\n\n if (ret && ret.length) {\n return ret;\n } else {\n if (required) {\n throw new TypeError(fieldName + ' must either be a DOM Element, an Array of elements, or a selector expression!\\nThe script element must also be after the DOM Element itself.');\n } else {\n return [];\n }\n }\n },\n\n /**\n * Gets options an object and element's metadata.\n *\n * The element's data attributes take precedence. Values from the element's data-atrributes are coerced into the required type.\n *\n * @method options\n *\n * @param {Object} [fieldId] Name to be used in debugging features.\n * @param {Object} defaults Object with the options' types and defaults.\n * @param {Object} overrides Options to override the defaults. Usually passed when instantiating an UI module.\n * @param {DOMElement} [element] Element with data-attributes\n *\n * @example\n *\n * this._options = Ink.UI.Common.options('MyComponent', {\n * 'anobject': ['Object', null], // Defaults to null\n * 'target': ['Element', null],\n * 'stuff': ['Number', 0.1],\n * 'stuff2': ['Integer', 0],\n * 'doKickFlip': ['Boolean', false],\n * 'targets': ['Elements'], // Required option since no default was given\n * 'onClick': ['Function', null]\n * }, options || {}, elm)\n *\n * @example\n *\n * ### Note about booleans\n *\n * Here is how options are read from the markup\n * data-attributes, for several values`data-a-boolean`.\n *\n * Options considered true:\n *\n * - `data-a-boolean=\"true\"`\n * - (Every other value which is not on the list below.)\n * \n * Options considered false:\n *\n * - `data-a-boolean=\"false\"`\n * - `data-a-boolean=\"\"`\n * - `data-a-boolean`\n *\n * Options which go to default:\n *\n * - (no attribute). When `data-a-boolean` is ommitted, the\n * option is not considered true nor false, and as such\n * defaults to what is in the `defaults` argument.\n *\n **/\n options: function (fieldId, defaults, overrides, element) {\n if (typeof fieldId !== 'string') {\n element = overrides;\n overrides = defaults;\n defaults = fieldId;\n fieldId = '';\n }\n overrides = overrides || {};\n var out = {};\n var dataAttrs = element ? InkElement.data(element) : {};\n var fromDataAttrs;\n var type;\n var lType;\n var defaultVal;\n\n var invalidStr = function (str) {\n if (fieldId) { str = fieldId + ': \"' + ('' + str).replace(/\"/, '\\\\\"') + '\"'; }\n return str;\n };\n\n var quote = function (str) {\n return '\"' + ('' + str).replace(/\"/, '\\\\\"') + '\"';\n };\n\n var invalidThrow = function (str) {\n throw new Error(invalidStr(str));\n };\n\n var invalid = function (str) {\n Ink.error(invalidStr(str) + '. Ignoring option.');\n };\n\n function optionValue(key) {\n type = defaults[key][0];\n lType = type.toLowerCase();\n defaultVal = defaults[key].length === 2 ? defaults[key][1] : nothing;\n\n if (!type) {\n invalidThrow('Ink.UI.Common.options: Always specify a type!');\n }\n if (!(lType in Common._coerce_funcs)) {\n invalidThrow('Ink.UI.Common.options: ' + defaults[key][0] + ' is not a valid type. Use one of ' + keys(Common._coerce_funcs).join(', '));\n\n }\n if (!defaults[key].length || defaults[key].length > 2) {\n invalidThrow('the \"defaults\" argument must be an object mapping option names to [typestring, optional] arrays.');\n }\n\n if (key in dataAttrs) {\n fromDataAttrs = Common._coerce_from_string(lType, dataAttrs[key], key, fieldId);\n // (above can return `nothing`)\n } else {\n fromDataAttrs = nothing;\n }\n\n if (fromDataAttrs !== nothing) {\n if (!Common._options_validate(fromDataAttrs, lType)) {\n invalid('(' + key + ' option) Invalid ' + lType + ' ' + quote(fromDataAttrs));\n return defaultVal;\n } else {\n return fromDataAttrs;\n }\n } else if (key in overrides) {\n return overrides[key];\n } else if (defaultVal !== nothing) {\n return defaultVal;\n } else {\n invalidThrow('Option ' + key + ' is required!');\n }\n }\n\n for (var key in defaults) {\n if (defaults.hasOwnProperty(key)) {\n out[key] = optionValue(key);\n }\n }\n\n return out;\n },\n\n _coerce_from_string: function (type, val, paramName, fieldId) {\n if (type in Common._coerce_funcs) {\n return Common._coerce_funcs[type](val, paramName, fieldId);\n } else {\n return val;\n }\n },\n\n _options_validate: function (val, type) {\n if (type in Common._options_validate_types) {\n return Common._options_validate_types[type].call(Common, val);\n } else {\n // 'object' options cannot be passed through data-attributes.\n // Json you say? Not any good to embed in HTML.\n return false;\n }\n },\n\n _coerce_funcs: (function () {\n var ret = {\n element: function (val) {\n return Common.elOrSelector(val, '');\n },\n elements: function (val) {\n return Common.elsOrSelector(val, '', false /*not required, so don't throw an exception now*/);\n },\n object: function (val) { return val; },\n number: function (val) { return parseFloat(val); },\n 'boolean': function (val) {\n return !(val === 'false' || val === '' || val === null);\n },\n string: function (val) { return val; },\n 'function': function (val, paramName, fieldId) {\n Ink.error(fieldId + ': You cannot specify the option \"' + paramName + '\" through data-attributes because it\\'s a function');\n return nothing;\n }\n };\n ret['float'] = ret.integer = ret.number;\n return ret;\n }()),\n\n _options_validate_types: (function () {\n var types = {\n string: function (val) {\n return typeof val === 'string';\n },\n number: function (val) {\n return typeof val === 'number' && !isNaN(val) && isFinite(val);\n },\n integer: function (val) {\n return val === Math.round(val);\n },\n element: function (val) {\n return Common.isDOMElement(val);\n },\n elements: function (val) {\n return val && typeof val === 'object' && typeof val.length === 'number' && val.length;\n },\n 'boolean': function (val) {\n return typeof val === 'boolean';\n },\n object: function () { return true; }\n };\n types['float'] = types.number;\n return types;\n }()),\n\n /**\n * Deep copy (clone) an object.\n * Note: The object cannot have referece loops.\n *\n * @method clone\n * @static\n * @param {Object} o The object to be cloned/copied.\n * @return {Object} Returns the result of the clone/copy.\n * @example\n * var originalObj = {\n * key1: 'value1',\n * key2: 'value2',\n * key3: 'value3'\n * };\n * var cloneObj = Ink.UI.Common.clone( originalObj );\n */\n clone: function(o) {\n try {\n return JSON.parse( JSON.stringify(o) );\n } catch (ex) {\n throw new Error('Given object cannot have loops!');\n }\n },\n\n\n /**\n * Gets an element's one-base index relative to its parent.\n *\n * @method childIndex\n * @static\n * @param {DOMElement} childEl Valid DOM Element.\n * @return {Number} Numerical position of an element relatively to its parent.\n * @example\n * <!-- Imagine the following HTML: -->\n * <ul>\n * <li>One</li>\n * <li>Two</li>\n * <li id=\"test\">Three</li>\n * <li>Four</li>\n * </ul>\n *\n * <script>\n * var testLi = Ink.s('#test');\n * Ink.UI.Common.childIndex( testLi ); // Returned value: 3\n * </script>\n */\n childIndex: function(childEl) {\n if( Common.isDOMElement(childEl) ){\n var els = Selector.select('> *', childEl.parentNode);\n for (var i = 0, f = els.length; i < f; ++i) {\n if (els[i] === childEl) {\n return i;\n }\n }\n }\n throw 'not found!';\n },\n\n\n /**\n * AJAX JSON request shortcut method\n * It provides a more convenient way to do an AJAX request and expect a JSON response.It also offers a callback option, as third parameter, for better async handling.\n *\n * @method ajaxJSON\n * @static\n * @async\n * @param {String} endpoint Valid URL to be used as target by the request.\n * @param {Object} params This field is used in the thrown Exception to identify the parameter.\n * @param {Function} cb Callback for the request.\n * @example\n * // In case there are several .myInput, it will retrieve the first found\n * var el = Ink.UI.Common.elOrSelector('.myInput','My Input');\n */\n ajaxJSON: function(endpoint, params, cb) {\n new Ajax(\n endpoint,\n {\n evalJS: 'force',\n method: 'POST',\n parameters: params,\n\n onSuccess: function( r) {\n try {\n r = r.responseJSON;\n if (r.status !== 'ok') {\n throw 'server error: ' + r.message;\n }\n cb(null, r);\n } catch (ex) {\n cb(ex);\n }\n },\n\n onFailure: function() {\n cb('communication failure');\n }\n }\n );\n },\n\n\n /**\n * Gets the current Ink layout.\n *\n * @method currentLayout\n * @static\n * @return {String} A string representation of the current layout name.\n * @example\n * var inkLayout = Ink.UI.Common.currentLayout();\n * if (inkLayout === 'small') {\n * // ...\n * }\n */\n currentLayout: function() {\n var i, f, k, v, el, detectorEl = Selector.select('#ink-layout-detector')[0];\n if (!detectorEl) {\n detectorEl = document.createElement('div');\n detectorEl.id = 'ink-layout-detector';\n for (k in this.Layouts) {\n if (this.Layouts.hasOwnProperty(k)) {\n v = this.Layouts[k];\n el = document.createElement('div');\n el.className = 'show-' + v + ' hide-all';\n el.setAttribute('data-ink-layout', v);\n detectorEl.appendChild(el);\n }\n }\n document.body.appendChild(detectorEl);\n }\n\n for (i = 0, f = detectorEl.children.length; i < f; ++i) {\n el = detectorEl.children[i];\n if (Css.getStyle(el, 'display') === 'block') {\n return el.getAttribute('data-ink-layout');\n }\n }\n\n return 'large';\n },\n\n\n /**\n * Sets the location's hash (window.location.hash).\n *\n * @method hashSet\n * @static\n * @param {Object} o Object with the info to be placed in the location's hash.\n * @example\n * // It will set the location's hash like: <url>#key1=value1&key2=value2&key3=value3\n * Ink.UI.Common.hashSet({\n * key1: 'value1',\n * key2: 'value2',\n * key3: 'value3'\n * });\n */\n hashSet: function(o) {\n if (typeof o !== 'object') { throw new TypeError('o should be an object!'); }\n var hashParams = Url.getAnchorString();\n hashParams = Ink.extendObj(hashParams, o);\n window.location.hash = Url.genQueryString('', hashParams).substring(1);\n },\n\n /**\n * Removes children nodes from a given object.\n * This method was initially created to help solve a problem in Internet Explorer(s) that occurred when trying to set the innerHTML of some specific elements like 'table'.\n *\n * @method cleanChildren\n * @static\n * @param {DOMElement} parentEl Valid DOM Element\n * @example\n * <!-- Imagine the following HTML: -->\n * <ul id=\"myUl\">\n * <li>One</li>\n * <li>Two</li>\n * <li>Three</li>\n * <li>Four</li>\n * </ul>\n *\n * <script>\n * Ink.UI.Common.cleanChildren( Ink.s( '#myUl' ) );\n * </script>\n *\n * <!-- After running it, the HTML changes to: -->\n * <ul id=\"myUl\"></ul>\n */\n cleanChildren: function(parentEl) {\n if( !Common.isDOMElement(parentEl) ){\n throw 'Please provide a valid DOMElement';\n }\n var prevEl, el = parentEl.lastChild;\n while (el) {\n prevEl = el.previousSibling;\n parentEl.removeChild(el);\n el = prevEl;\n }\n },\n\n /**\n * Stores the id and/or classes of an element in an object.\n *\n * @method storeIdAndClasses\n * @static\n * @param {DOMElement} fromEl Valid DOM Element to get the id and classes from.\n * @param {Object} inObj Object where the id and classes will be saved.\n * @example\n * <div id=\"myDiv\" class=\"aClass\"></div>\n *\n * <script>\n * var storageObj = {};\n * Ink.UI.Common.storeIdAndClasses( Ink.s('#myDiv'), storageObj );\n * // storageObj changes to:\n * {\n * _id: 'myDiv',\n * _classes: 'aClass'\n * }\n * </script>\n */\n storeIdAndClasses: function(fromEl, inObj) {\n if( !Common.isDOMElement(fromEl) ){\n throw 'Please provide a valid DOMElement as first parameter';\n }\n\n var id = fromEl.id;\n if (id) {\n inObj._id = id;\n }\n\n var classes = fromEl.className;\n if (classes) {\n inObj._classes = classes;\n }\n },\n\n /**\n * Sets the id and className properties of an element based \n *\n * @method restoreIdAndClasses\n * @static\n * @param {DOMElement} toEl Valid DOM Element to set the id and classes on.\n * @param {Object} inObj Object where the id and classes to be set are. This method uses the same format as the one given in `storeIdAndClasses`\n * @example\n * <div></div>\n *\n * <script>\n * var storageObj = {\n * _id: 'myDiv',\n * _classes: 'aClass'\n * };\n *\n * Ink.UI.Common.storeIdAndClasses( Ink.s('div'), storageObj );\n * </script>\n *\n * <!-- After the code runs the div element changes to: -->\n * <div id=\"myDiv\" class=\"aClass\"></div>\n */\n restoreIdAndClasses: function(toEl, inObj) {\n\n if( !Common.isDOMElement(toEl) ){\n throw 'Please provide a valid DOMElement as first parameter';\n }\n\n if (inObj._id && toEl.id !== inObj._id) {\n toEl.id = inObj._id;\n }\n\n if (inObj._classes && toEl.className.indexOf(inObj._classes) === -1) {\n if (toEl.className) { toEl.className += ' ' + inObj._classes; }\n else { toEl.className = inObj._classes; }\n }\n\n if (inObj._instanceId && !toEl.getAttribute('data-instance')) {\n toEl.setAttribute('data-instance', inObj._instanceId);\n }\n },\n\n _warnDoubleInstantiation: function (elm, newInstance) {\n var instances = Common.getInstance(elm);\n\n if (getName(newInstance) === '') { return; }\n if (!instances) { return; }\n\n var nameWithoutVersion = getName(newInstance);\n\n if (!nameWithoutVersion) { return; }\n\n for (var i = 0, len = instances.length; i < len; i++) {\n if (nameWithoutVersion === getName(instances[i])) {\n // Yes, I am using + to concatenate and , to split\n // arguments.\n //\n // Elements can't be concatenated with strings, but if\n // they are passed in an argument, modern debuggers will\n // pretty-print them and make it easy to find them in the\n // element inspector.\n //\n // On the other hand, if strings are passed as different\n // arguments, they get pretty printed. And the pretty\n // print of a string has quotes around it.\n //\n // If some day people find out that strings are not\n // just text and they start preserving contextual\n // information, then by all means change this to a\n // regular concatenation.\n //\n // But they won't. So don't change this.\n Ink.warn('Creating more than one ' + nameWithoutVersion + '.',\n '(Was creating a ' + nameWithoutVersion + ' on:', elm, ').');\n return false;\n }\n }\n\n function getName(thing) {\n return ((thing.constructor && (thing.constructor._name)) ||\n thing._name ||\n '').replace(/_.*?$/, '');\n }\n\n return true;\n },\n\n /**\n * Saves a component's instance reference for later retrieval.\n *\n * @method registerInstance\n * @static\n * @param {Object} inst Object that holds the instance.\n * @param {DOMElement} el DOM Element to associate with the object.\n */\n registerInstance: function(inst, el) {\n if (!inst) { return; }\n\n if (!Common.isDOMElement(el)) { throw new TypeError('Ink.UI.Common.registerInstance: The element passed in is not a DOM element!'); }\n\n // [todo] this belongs in the BaseUIComponent's initialization\n if (Common._warnDoubleInstantiation(el, inst) === false) {\n return false;\n }\n\n var instances = domRegistry.get(el);\n\n if (!instances) {\n instances = [];\n domRegistry.set(el, instances);\n }\n\n instances.push(inst);\n\n return true;\n },\n\n /**\n * Deletes an instance with a given id.\n *\n * @method unregisterInstance\n * @static\n * @param {String} id Id of the instance to be destroyed.\n */\n unregisterInstance: function(inst) {\n if (!inst || !inst._element) { return; }\n var instances = domRegistry.get(inst._element);\n for (var i = 0, len = instances.length; i < len; i++) {\n if (instances[i] === inst) {\n instances.splice(i, 1);\n }\n }\n },\n\n /**\n * Gets an UI instance from an element or instance id.\n *\n * @method getInstance\n * @static\n * @param {String|DOMElement} el DOM Element from which we want the instances.\n * @return {Object|Array} Returns an instance or a collection of instances.\n */\n getInstance: function(el, UIComponent) {\n el = Common.elOrSelector(el);\n var instances = domRegistry.get(el);\n\n if (!instances) {\n instances = [];\n }\n\n if (typeof UIComponent !== 'function') {\n return instances;\n }\n\n for (var i = 0, len = instances.length; i < len; i++) {\n if (instances[i] instanceof UIComponent) {\n return instances[i];\n }\n }\n\n return null;\n },\n\n /**\n * Gets an instance based on a selector.\n *\n * @method getInstanceFromSelector\n * @static\n * @param {String} selector CSS selector to get the instances from.\n * @return {Object|Array} Returns an instance or a collection of instances.\n */\n getInstanceFromSelector: function(selector) {\n return Common.getInstance(Common.elOrSelector(selector));\n },\n\n /**\n * Gets all the instance ids\n *\n * @method getInstanceIds\n * @static\n * @return {Array} Collection of instance ids\n */\n getInstanceIds: function() {\n var res = [];\n for (var id in instances) {\n if (instances.hasOwnProperty(id)) {\n res.push( id );\n }\n }\n return res;\n },\n\n /**\n * Gets all the instances\n *\n * @method getInstances\n * @static\n * @return {Array} Collection of existing instances.\n */\n getInstances: function() {\n var res = [];\n for (var id in instances) {\n if (instances.hasOwnProperty(id)) {\n res.push( instances[id] );\n }\n }\n return res;\n },\n\n /**\n * Boilerplate method to destroy a component.\n * Components should copy this method as its destroy method and modify it.\n *\n * @method destroyComponent\n * @static\n */\n destroyComponent: function() {\n Common.unregisterInstance(this);\n this._element.parentNode.removeChild(this._element);\n }\n\n };\n\n\n\n\n /**\n * Ink UI Base Class\n **/\n\n function warnStub() {\n /* jshint validthis: true */\n if (!this || this === window || typeof this.constructor !== 'function') { return; }\n Ink.warn('You called a method on an incorrectly instantiated ' + this.constructor._name + ' component. Check the warnings above to see what went wrong.');\n }\n\n function stub(prototype, obj) {\n for (var k in prototype) if (prototype.hasOwnProperty(k)) {\n if (k === 'constructor') { continue; }\n if (typeof obj[k] === 'function') {\n obj[k] = warnStub;\n }\n }\n }\n\n /**\n * Ink UI Base Class\n *\n * You don't use this class directly, or inherit from it directly.\n *\n * See createUIComponent() (in this module) for how to create a UI component and inherit from this. It's not plain old JS inheritance, for several reasons.\n *\n * @class Ink.UI.Common.BaseUIComponent\n * @constructor\n *\n * @param element\n * @param options\n **/\n function BaseUIComponent(element, options) {\n var constructor = this.constructor;\n var _name = constructor._name;\n\n if (!this || this === window) {\n throw new Error('Use \"new InkComponent()\" instead of \"InkComponent()\"');\n }\n\n if (this && !(this instanceof BaseUIComponent)) {\n throw new Error('You forgot to call Ink.UI.Common.createUIComponent() on this module!');\n }\n\n if (!element && !constructor._componentOptions.elementIsOptional) {\n Ink.error(new Error(_name + ': You need to pass an element or a selector as the first argument to \"new ' + _name + '()\"'));\n return;\n } else {\n this._element = Common.elsOrSelector(element,\n _name + ': An element with the selector \"' + element + '\" was not found!')[0];\n }\n\n if (!this._element && !constructor._componentOptions.elementIsOptional) {\n isValidInstance = false;\n Ink.error(new Error(element + ' does not match an element on the page. You need to pass a valid selector to \"new ' + _name + '\".'));\n }\n\n // TODO Change Common.options's signature? the below looks better, more manageable\n // var options = Common.options({\n // element: this._element,\n // modName: constructor._name,\n // options: constructor._optionDefinition,\n // defaults: constructor._globalDefaults\n // });\n\n this._options = Common.options(_name, constructor._optionDefinition, options, this._element);\n\n var isValidInstance = BaseUIComponent._validateInstance(this) === true;\n\n if (isValidInstance && typeof this._init === 'function') {\n try {\n this._init.apply(this, arguments);\n } catch(e) {\n isValidInstance = false;\n Ink.error(e);\n }\n }\n\n if (!isValidInstance) {\n BaseUIComponent._stubInstance(this, constructor, _name);\n } else if (this._element) {\n Common.registerInstance(this, this._element);\n }\n }\n\n /**\n * Calls the `instance`'s _validate() method so it can validate itself.\n *\n * Returns false if the method exists, was called, but no Error was returned or thrown.\n *\n * @method _validateInstance\n * @private\n */\n BaseUIComponent._validateInstance = function (instance) {\n var err;\n\n if (typeof instance._validate !== 'function') { return true; }\n\n try {\n err = instance._validate();\n } catch (e) {\n err = e;\n }\n\n if (err instanceof Error) {\n instance._validationError = err;\n return false;\n }\n\n return true;\n };\n\n\n /**\n * Replaces every method in the instance with stub functions which just call Ink.warn().\n *\n * This avoids breaking the page when there are errors.\n *\n * @method _stubInstance\n * @param instance\n * @param constructor\n * @param name\n * @private\n */\n BaseUIComponent._stubInstance = function (instance, constructor, name) {\n stub(constructor.prototype, instance);\n stub(BaseUIComponent.prototype, instance);\n Ink.warn(name + ' was not correctly created. ' + (instance._validationError || ''));\n };\n\n // TODO BaseUIComponent.setGlobalOptions = function () {}\n // TODO BaseUIComponent.createMany = function (selector) {}\n BaseUIComponent.getInstance = function (elOrSelector) {\n elOrSelector = Common.elOrSelector(elOrSelector);\n return Common.getInstance(elOrSelector, this /* get instance by constructor */);\n };\n\n Ink.extendObj(BaseUIComponent.prototype, {\n /**\n * Get an UI component's option's value.\n *\n * @method getOption\n * @param name\n *\n * @return The option value, or undefined if nothing is found.\n *\n * @example\n *\n * var myUIComponent = new Modal('#element', { trigger: '#trigger' }); // or anything else inheriting BaseUIComponent\n * myUIComponent.getOption('trigger'); // -> The trigger element (not the selector string, mind you)\n *\n **/\n getOption: function (name) {\n if (this.constructor && !(name in this.constructor._optionDefinition)) {\n Ink.error('\"' + name + '\" is not an option for ' + this.constructor._name);\n return undefined;\n }\n\n return this._options[name];\n },\n\n /**\n * Sets an option's value\n *\n * @method getOption\n * @param name\n * @param value\n *\n * @example\n *\n * var myUIComponent = new Modal(...);\n * myUIComponent.setOption('trigger', '#some-element');\n **/\n setOption: function (name, value) {\n if (this.constructor && !(name in this.constructor._optionDefinition)) {\n Ink.error('\"' + name + ' is not an option for ' + this.constructor._name);\n return;\n }\n\n this._options[name] = value;\n },\n\n /**\n * Get the element associated with an UI component (IE the one you used in the constructor)\n *\n * @method getElement\n * @return {Element} The component's element.\n *\n * @example\n * var myUIComponent = new Modal('#element'); // or anything else inheriting BaseUIComponent\n * myUIComponent.getElement(); // -> The '#element' (not the selector string, mind you).\n *\n **/\n getElement: function () {\n return this._element;\n }\n });\n\n Common.BaseUIComponent = BaseUIComponent;\n\n /**\n * @method createUIComponent\n * @param theConstructor UI component constructor. It should have an _init function in its prototype, an _optionDefinition object, and a _name property indicating its name.\n * @param options\n * @param [options.elementIsOptional=false] Whether the element argument is optional (For example, when the component might work on existing markup or create its own).\n **/\n Common.createUIComponent = function createUIComponent(theConstructor, options) {\n theConstructor._componentOptions = options || {};\n\n function assert(test, msg) {\n if (!test) {\n throw new Error('Ink.UI_1.createUIComponent: ' + msg);\n }\n }\n\n function assertProp(prop, propType, message) {\n var propVal = theConstructor[prop];\n // Check that the property was passed\n assert(typeof propVal !== 'undefined',\n theConstructor + ' doesn\\'t have a \"' + prop + '\" property. ' + message);\n // Check that its type is correct\n assert(propType && typeof propVal === propType,\n 'typeof ' + theConstructor + '.' + prop + ' is not \"' + propType + '\". ' + message);\n }\n\n assert(typeof theConstructor === 'function',\n 'constructor argument is not a function!');\n\n assertProp('_name', 'string', 'This property is used for error ' +\n 'messages. Set it to the full module path and version (Ink.My.Module_1).');\n assertProp('_optionDefinition', 'object', 'This property contains the ' +\n 'option names, types and defaults. See Ink.UI.Common.options() for reference.');\n\n // Extend the instance methods and props\n var _oldProto = theConstructor.prototype;\n\n if (typeof Object.create === 'function') {\n theConstructor.prototype = Object.create(BaseUIComponent.prototype);\n } else {\n theConstructor.prototype = (function hideF() {\n function F() {}\n F.prototype = BaseUIComponent.prototype;\n return new F();\n }());\n }\n\n Ink.extendObj(theConstructor.prototype, _oldProto);\n theConstructor.prototype.constructor = theConstructor;\n // Extend static methods\n Ink.extendObj(theConstructor, BaseUIComponent);\n };\n\n return Common;\n\n});\n","/**\n * Date selector\n * @module Ink.UI.DatePicker_1\n * @version 1\n */\n\nInk.createModule('Ink.UI.DatePicker', '1', ['Ink.UI.Common_1','Ink.Dom.Event_1','Ink.Dom.Css_1','Ink.Dom.Element_1','Ink.Dom.Selector_1','Ink.Util.Array_1','Ink.Util.Date_1', 'Ink.Dom.Browser_1'], function(Common, Event, Css, InkElement, Selector, InkArray, InkDate ) {\n 'use strict';\n\n // Clamp a number into a min/max limit\n function clamp(n, min, max) {\n if (n > max) { n = max; }\n if (n < min) { n = min; }\n\n return n;\n }\n\n function dateishFromYMDString(YMD) {\n var split = YMD.split('-');\n return dateishFromYMD(+split[0], +split[1] - 1, +split[2]);\n }\n\n function dateishFromYMD(year, month, day) {\n return {_year: year, _month: month, _day: day};\n }\n\n function dateishFromDate(date) {\n return {_year: date.getFullYear(), _month: date.getMonth(), _day: date.getDate()};\n }\n\n /**\n * @class Ink.UI.DatePicker\n * @constructor\n * @version 1\n *\n * @param {String|DOMElement} selector\n * @param {Object} [options] Options\n * @param {Boolean} [options.autoOpen] Flag to automatically open the datepicker.\n * @param {String} [options.cleanText] Text for the clean button. Defaults to 'Clear'.\n * @param {String} [options.closeText] Text for the close button. Defaults to 'Close'.\n * @param {String} [options.cssClass] CSS class to be applied on the datepicker\n * @param {String|DOMElement} [options.pickerField] (if not using in an input[type=\"text\"]) Element which displays the DatePicker when clicked. Defaults to an \"open\" link.\n * @param {String} [options.dateRange] Enforce limits to year, month and day for the Date, ex: '1990-08-25:2020-11'\n * @param {Boolean} [options.displayInSelect] Flag to display the component in a select element.\n * @param {String|DOMElement} [options.dayField] (if using options.displayInSelect) `select` field with days.\n * @param {String|DOMElement} [options.monthField] (if using options.displayInSelect) `select` field with months.\n * @param {String|DOMElement} [options.yearField] (if using options.displayInSelect) `select` field with years.\n * @param {String} [options.format] Date format string\n * @param {Object} [options.month] Hash of month names. Defaults to portuguese month names. January is 1.\n * @param {String} [options.nextLinkText] Text for the previous button. Defaults to '«'.\n * @param {String} [options.ofText] Text to show between month and year. Defaults to ' of '.\n * @param {Boolean} [options.onFocus] If the datepicker should open when the target element is focused. Defaults to true.\n * @param {Function} [options.onMonthSelected] Callback to execute when the month is selected.\n * @param {Function} [options.onSetDate] Callback to execute when the date is set.\n * @param {Function} [options.onYearSelected] Callback to execute when the year is selected.\n * @param {String} [options.position] Position for the datepicker. Either 'right' or 'bottom'. Defaults to 'right'.\n * @param {String} [options.prevLinkText] Text for the previous button. Defaults to '«'.\n * @param {Boolean} [options.showClean] If the clean button should be visible. Defaults to true.\n * @param {Boolean} [options.showClose] If the close button should be visible. Defaults to true.\n * @param {Boolean} [options.shy] If the datepicker should start automatically. Defaults to true.\n * @param {String} [options.startDate] Date to define initial month. Must be in yyyy-mm-dd format.\n * @param {Number} [options.startWeekDay] First day of the week. Sunday is zero. Defaults to 1 (Monday).\n * @param {Function} [options.validYearFn] Callback to execute when 'rendering' the month (in the month view)\n * @param {Function} [options.validMonthFn] Callback to execute when 'rendering' the month (in the month view)\n * @param {Function} [options.validDayFn] Callback to execute when 'rendering' the day (in the month view)\n * @param {Function} [options.nextValidDateFn] Function to calculate the next valid date, given the current. Useful when there's invalid dates or time frames.\n * @param {Function} [options.prevValidDateFn] Function to calculate the previous valid date, given the current. Useful when there's invalid dates or time frames.\n * @param {Object} [options.wDay] Hash of week day names. Sunday is 0. Defaults to { 0:'Sunday', 1:'Monday', etc...\n * @param {String} [options.yearRange] Enforce limits to year for the Date, ex: '1990:2020' (deprecated)\n *\n * @sample Ink_UI_DatePicker_1.html\n */\n var DatePicker = function() {\n Common.BaseUIComponent.apply(this, arguments);\n };\n\n DatePicker._name = 'DatePicker_1';\n\n DatePicker._optionDefinition = {\n autoOpen: ['Boolean', false],\n cleanText: ['String', 'Clear'],\n closeText: ['String', 'Close'],\n pickerField: ['Element', null],\n containerElement:['Element', null],\n cssClass: ['String', 'ink-calendar bottom'],\n dateRange: ['String', null],\n \n // use this in a <select>\n displayInSelect: ['Boolean', false],\n dayField: ['Element', null],\n monthField: ['Element', null],\n yearField: ['Element', null],\n\n format: ['String', 'yyyy-mm-dd'],\n nextLinkText: ['String', '»'],\n ofText: ['String', ' of '],\n onFocus: ['Boolean', true],\n onMonthSelected: ['Function', null],\n onSetDate: ['Function', null],\n onYearSelected: ['Function', null],\n position: ['String', 'right'],\n prevLinkText: ['String', '«'],\n showClean: ['Boolean', true],\n showClose: ['Boolean', true],\n shy: ['Boolean', true],\n startDate: ['String', null], // format yyyy-mm-dd,\n startWeekDay: ['Number', 1],\n\n // Validation\n validDayFn: ['Function', null],\n validMonthFn: ['Function', null],\n validYearFn: ['Function', null],\n nextValidDateFn: ['Function', null],\n prevValidDateFn: ['Function', null],\n yearRange: ['String', null],\n\n // Text\n month: ['Object', {\n 1:'January',\n 2:'February',\n 3:'March',\n 4:'April',\n 5:'May',\n 6:'June',\n 7:'July',\n 8:'August',\n 9:'September',\n 10:'October',\n 11:'November',\n 12:'December'\n }],\n wDay: ['Object', {\n 0:'Sunday',\n 1:'Monday',\n 2:'Tuesday',\n 3:'Wednesday',\n 4:'Thursday',\n 5:'Friday',\n 6:'Saturday'\n }]\n };\n\n DatePicker.prototype = {\n /**\n * Initialization function. Called by the constructor and receives the same parameters.\n *\n * @method _init\n * @private\n */\n _init: function(){\n this._options.format = this._dateParsers[ this._options.format ] || this._options.format;\n\n this._hoverPicker = false;\n\n this._picker = this._options.pickerField || null;\n\n this._setMinMax( this._options.dateRange || this._options.yearRange );\n\n if(this._options.startDate) {\n this.setDate( this._options.startDate );\n } else if (this._element && this._element.value) {\n this.setDate( this._element.value );\n } else {\n this.setDate(new Date());\n }\n\n if (this._options.startWeekDay < 0 || this._options.startWeekDay > 6) {\n Ink.warn('Ink.UI.DatePicker_1: option \"startWeekDay\" must be between 0 (sunday) and 6 (saturday)');\n this._options.startWeekDay = clamp(this._options.startWeekDay, 0, 6);\n }\n\n Ink.extendObj(this._options,this._lang || {});\n\n this._render();\n this._listenToContainerObjectEvents();\n },\n\n _validate: function () {\n if(this._options.displayInSelect &&\n !(this._options.dayField && this._options.monthField && this._options.yearField)){\n throw new Error(\n 'Ink.UI.DatePicker: displayInSelect option enabled.'+\n 'Please specify dayField, monthField and yearField selectors.');\n }\n },\n\n /**\n * Renders the DatePicker's markup.\n *\n * @method _render\n * @private\n */\n _render: function() {\n this._containerObject = document.createElement('div');\n\n this._containerObject.className = this._options.cssClass + ' ink-datepicker-calendar hide-all';\n\n this._renderSuperTopBar();\n\n var calendarTop = document.createElement(\"div\");\n calendarTop.className = 'ink-calendar-top';\n\n this._monthDescContainer = document.createElement(\"div\");\n this._monthDescContainer.className = 'ink-calendar-month_desc';\n\n this._monthPrev = document.createElement('div');\n this._monthPrev.className = 'ink-calendar-prev';\n this._monthPrev.appendChild(InkElement.create('a', {\n href: '#prev',\n className: 'change_month_prev',\n setHTML: this._options.prevLinkText\n }));\n\n this._monthNext = document.createElement('div');\n this._monthNext.className = 'ink-calendar-next';\n this._monthNext.appendChild(InkElement.create('a', {\n href: '#next',\n className: 'change_month_next',\n setHTML: this._options.nextLinkText\n }));\n\n calendarTop.appendChild(this._monthPrev);\n calendarTop.appendChild(this._monthDescContainer);\n calendarTop.appendChild(this._monthNext);\n\n this._monthContainer = document.createElement(\"div\");\n this._monthContainer.className = 'ink-calendar-month';\n\n this._containerObject.appendChild(calendarTop);\n this._containerObject.appendChild(this._monthContainer);\n\n this._monthSelector = this._renderMonthSelector();\n this._containerObject.appendChild(this._monthSelector);\n\n this._yearSelector = document.createElement('ul');\n this._yearSelector.className = 'ink-calendar-year-selector';\n\n this._containerObject.appendChild(this._yearSelector);\n\n if(!this._options.onFocus || this._options.displayInSelect){\n if(!this._options.pickerField){\n this._picker = InkElement.create('a', {\n href: '#open_cal',\n setHTML: 'open',\n insertBottom: this._element.parentNode,\n className: 'ink-datepicker-picker-field'\n });\n } else {\n this._picker = Common.elOrSelector(this._options.pickerField, 'pickerField');\n }\n }\n\n this._appendDatePickerToDom();\n\n this._renderMonth();\n\n this._monthChanger = InkElement.create('a', {\n href: '#monthchanger',\n className: 'ink-calendar-link-month',\n setTextContent: this._options.month[this._month + 1]\n });\n\n this._ofText = InkElement.create('span', {\n className: 'ink-calendar-of-text',\n setHTML: this._options.ofText\n });\n\n this._yearChanger = InkElement.create('a', {\n href: '#yearchanger',\n className: 'ink-calendar-link-year',\n setTextContent: this._year\n });\n\n this._monthDescContainer.appendChild(this._monthChanger);\n this._monthDescContainer.appendChild(this._ofText);\n this._monthDescContainer.appendChild(this._yearChanger);\n\n if (!this._options.inline) {\n this._addOpenCloseEvents();\n } else {\n this.show();\n }\n this._addDateChangeHandlersToInputs();\n },\n\n _addDateChangeHandlersToInputs: function () {\n var fields = this._element;\n if (this._options.displayInSelect) {\n fields = [\n this._options.dayField,\n this._options.monthField,\n this._options.yearField];\n }\n Event.observeMulti(fields ,'change', Ink.bindEvent(function(){\n this._updateDate( );\n this._showDefaultView( );\n this.setDate( );\n if ( !this._inline && !this._hoverPicker ) {\n this._hide(true);\n }\n },this));\n },\n\n /**\n * Shows the calendar.\n *\n * @method show\n **/\n show: function () {\n this._updateDate();\n this._renderMonth();\n Css.removeClassName(this._containerObject, 'hide-all');\n },\n\n _addOpenCloseEvents: function () {\n var opener = this._picker || this._element;\n\n Event.observe(opener, 'click', Ink.bindEvent(function(e){\n Event.stop(e);\n this.show();\n },this));\n\n if (this._options.autoOpen) {\n this.show();\n }\n\n if(!this._options.displayInSelect){\n Event.observe(opener, 'blur', Ink.bindEvent(function() {\n if ( !this._hoverPicker ) {\n this._hide(true);\n }\n },this));\n }\n\n if (this._options.shy) {\n // Close the picker when clicking elsewhere.\n Event.observe(document,'click',Ink.bindEvent(function(e){\n var target = Event.element(e);\n\n // \"elsewhere\" is outside any of these elements:\n var cannotBe = [\n this._options.dayField,\n this._options.monthField,\n this._options.yearField,\n this._picker,\n this._element\n ];\n\n for (var i = 0, len = cannotBe.length; i < len; i++) {\n if (cannotBe[i] && InkElement.descendantOf(cannotBe[i], target)) {\n return;\n }\n }\n\n this._hide(true);\n },this));\n }\n },\n\n /**\n * Creates the markup of the view with months.\n *\n * @method _renderMonthSelector\n * @private\n */\n _renderMonthSelector: function () {\n var selector = document.createElement('ul');\n selector.className = 'ink-calendar-month-selector';\n\n var ulSelector = document.createElement('ul');\n for(var mon=1; mon<=12; mon++){\n ulSelector.appendChild(this._renderMonthButton(mon));\n\n if (mon % 4 === 0) {\n selector.appendChild(ulSelector);\n ulSelector = document.createElement('ul');\n }\n }\n return selector;\n },\n\n /**\n * Renders a single month button.\n */\n _renderMonthButton: function (mon) {\n var liMonth = document.createElement('li');\n liMonth.appendChild(InkElement.create('a', {\n 'data-cal-month': mon,\n setTextContent: this._options.month[mon].substring(0, 3)\n }));\n return liMonth;\n },\n\n _appendDatePickerToDom: function () {\n if(this._options.containerElement) {\n var appendTarget =\n Common.elOrSelector(this._options.containerElement);\n appendTarget.appendChild(this._containerObject);\n }\n\n var parentIsControl = Selector.matchesSelector(\n this._element.parentNode,\n '.ink-form .control-group .control');\n\n if (parentIsControl) {\n this._wrapper = this._element.parentNode;\n this._wrapperIsControl = true;\n } else {\n this._wrapper = InkElement.create('div', { className: 'ink-datepicker-wrapper' });\n InkElement.wrap(this._element, this._wrapper);\n }\n\n InkElement.insertAfter(this._containerObject, this._element);\n },\n\n /**\n * Render the topmost bar with the \"close\" and \"clear\" buttons.\n */\n _renderSuperTopBar: function () {\n if((!this._options.showClose) || (!this._options.showClean)){ return; }\n\n this._superTopBar = document.createElement(\"div\");\n this._superTopBar.className = 'ink-calendar-top-options';\n if(this._options.showClean){\n this._superTopBar.appendChild(InkElement.create('a', {\n className: 'clean',\n setHTML: this._options.cleanText\n }));\n }\n if(this._options.showClose){\n this._superTopBar.appendChild(InkElement.create('a', {\n className: 'close',\n setHTML: this._options.closeText\n }));\n }\n this._containerObject.appendChild(this._superTopBar);\n },\n\n _listenToContainerObjectEvents: function () {\n Event.observe(this._containerObject,'mouseover',Ink.bindEvent(function(e){\n Event.stop( e );\n this._hoverPicker = true;\n },this));\n\n Event.observe(this._containerObject,'mouseout',Ink.bindEvent(function(e){\n Event.stop( e );\n this._hoverPicker = false;\n },this));\n\n Event.observe(this._containerObject,'click',Ink.bindEvent(this._onClick, this));\n },\n\n _onClick: function(e){\n var elem = Event.element(e);\n\n if (Css.hasClassName(elem, 'ink-calendar-off')) {\n Event.stopDefault(e);\n return null;\n }\n\n Event.stop(e);\n\n // Relative changers\n this._onRelativeChangerClick(elem);\n\n // Absolute changers\n this._onAbsoluteChangerClick(elem);\n\n // Mode changers\n if (Css.hasClassName(elem, 'ink-calendar-link-month')) {\n this._showMonthSelector();\n } else if (Css.hasClassName(elem, 'ink-calendar-link-year')) {\n this._showYearSelector();\n } else if(Css.hasClassName(elem, 'clean')){\n this._clean();\n } else if(Css.hasClassName(elem, 'close')){\n this._hide(false);\n }\n\n this._updateDescription();\n },\n\n /**\n * Handles click events on a changer (« ») for next/prev year/month\n * @method _onChangerClick\n * @private\n **/\n _onRelativeChangerClick: function (elem) {\n var changeYear = {\n change_year_next: 1,\n change_year_prev: -1\n };\n var changeMonth = {\n change_month_next: 1,\n change_month_prev: -1\n };\n\n if( elem.className in changeMonth ) {\n this._updateCal(changeMonth[elem.className]);\n } else if( elem.className in changeYear ) {\n this._showYearSelector(changeYear[elem.className]);\n }\n },\n\n /**\n * Handles click events on an atom-changer (day button, month button, year button)\n *\n * @method _onAbsoluteChangerClick\n * @private\n */\n _onAbsoluteChangerClick: function (elem) {\n var elemData = InkElement.data(elem);\n\n if( Number(elemData.calDay) ){\n this.setDate(new Date(this._year, this._month, elemData.calDay));\n this._hide();\n } else if( Number(elemData.calMonth) ) {\n this._month = Number(elemData.calMonth) - 1;\n this._showDefaultView();\n this._updateCal();\n } else if( Number(elemData.calYear) ){\n this._changeYear(Number(elemData.calYear));\n }\n },\n\n _changeYear: function (year) {\n year = +year;\n if(!isNaN(year)){\n this._year = year;\n if( typeof this._options.onYearSelected === 'function' ){\n this._options.onYearSelected(this, {\n 'year': this._year\n });\n }\n this._showMonthSelector();\n }\n },\n\n _clean: function () {\n if(this._options.displayInSelect){\n this._options.yearField.selectedIndex = 0;\n this._options.monthField.selectedIndex = 0;\n this._options.dayField.selectedIndex = 0;\n } else {\n this._element.value = '';\n }\n },\n\n /**\n * Hides the DatePicker.\n * If the component is shy (options.shy), behaves differently.\n *\n * @method _hide\n * @param {Boolean} [blur] If false, forces hiding even if the component is shy.\n */\n _hide: function(blur) {\n blur = blur === undefined ? true : blur;\n if (blur === false || (blur && this._options.shy)) {\n Css.addClassName(this._containerObject, 'hide-all');\n }\n },\n\n /**\n * Sets the range of dates allowed to be selected in the Date Picker\n *\n * @method _setMinMax\n * @param {String} dateRange Two dates separated by a ':'. Example: 2013-01-01:2013-12-12\n * @private\n */\n _setMinMax: function( dateRange ) {\n var self = this;\n\n var noMinLimit = {\n _year: -Number.MAX_VALUE,\n _month: 0,\n _day: 1\n };\n\n var noMaxLimit = {\n _year: Number.MAX_VALUE,\n _month: 11,\n _day: 31\n };\n\n function noLimits() {\n self._min = noMinLimit;\n self._max = noMaxLimit;\n }\n\n if (!dateRange) { return noLimits(); }\n\n var dates = dateRange.split( ':' );\n var rDate = /^(\\d{4})((\\-)(\\d{1,2})((\\-)(\\d{1,2}))?)?$/;\n\n InkArray.each([\n {name: '_min', date: dates[0], noLim: noMinLimit},\n {name: '_max', date: dates[1], noLim: noMaxLimit}\n ], Ink.bind(function (data) {\n\n var lim = data.noLim;\n\n if ( data.date.toUpperCase() === 'NOW' ) {\n var now = new Date();\n lim = dateishFromDate(now);\n } else if (data.date.toUpperCase() === 'EVER') {\n lim = data.noLim;\n } else if ( rDate.test( data.date ) ) {\n lim = dateishFromYMDString(data.date);\n\n lim._month = clamp(lim._month, 0, 11);\n lim._day = clamp(lim._day, 1, this._daysInMonth( lim._year, lim._month + 1 ));\n }\n\n this[data.name] = lim;\n }, this));\n\n // Should be equal, or min should be smaller\n var valid = this._dateCmp(this._max, this._min) !== -1;\n\n if (!valid) {\n noLimits();\n }\n },\n\n /**\n * Checks if a date is between the valid range.\n * Starts by checking if the date passed is valid. If not, will fallback to the 'today' date.\n * Then checks if the all params are inside of the date range specified. If not, it will fallback to the nearest valid date (either Min or Max).\n *\n * @method _fitDateToRange\n * @param {Number} year Year with 4 digits (yyyy)\n * @param {Number} month Month\n * @param {Number} day Day\n * @return {Array} Array with the final processed date.\n * @private\n */\n _fitDateToRange: function( date ) {\n if ( !this._isValidDate( date ) ) {\n date = dateishFromDate(new Date());\n }\n\n if (this._dateCmp(date, this._min) === -1) {\n return Ink.extendObj({}, this._min);\n } else if (this._dateCmp(date, this._max) === 1) {\n return Ink.extendObj({}, this._max);\n }\n\n return Ink.extendObj({}, date); // date is okay already, just copy it.\n },\n\n /**\n * Checks whether a date is within the valid date range\n * @method _dateWithinRange\n * @param year\n * @param month\n * @param day\n * @return {Boolean}\n * @private\n */\n _dateWithinRange: function (date) {\n if (!arguments.length) {\n date = this;\n }\n\n return (!this._dateAboveMax(date) &&\n (!this._dateBelowMin(date)));\n },\n\n _dateAboveMax: function (date) {\n return this._dateCmp(date, this._max) === 1;\n },\n\n _dateBelowMin: function (date) {\n return this._dateCmp(date, this._min) === -1;\n },\n\n _dateCmp: function (self, oth) {\n return this._dateCmpUntil(self, oth, '_day');\n },\n\n /**\n * _dateCmp with varied precision. You can compare down to the day field, or, just to the month.\n * // the following two dates are considered equal because we asked\n * // _dateCmpUntil to just check up to the years.\n *\n * _dateCmpUntil({_year: 2000, _month: 10}, {_year: 2000, _month: 11}, '_year') === 0\n */\n _dateCmpUntil: function (self, oth, depth) {\n var props = ['_year', '_month', '_day'];\n var i = -1;\n\n do {\n i++;\n if (self[props[i]] > oth[props[i]]) { return 1; }\n else if (self[props[i]] < oth[props[i]]) { return -1; }\n } while (props[i] !== depth &&\n self[props[i + 1]] !== undefined && oth[props[i + 1]] !== undefined);\n\n return 0;\n },\n\n /**\n * Sets the markup in the default view mode (showing the days).\n * Also disables the previous and next buttons in case they don't meet the range requirements.\n *\n * @method _showDefaultView\n * @private\n */\n _showDefaultView: function(){\n this._yearSelector.style.display = 'none';\n this._monthSelector.style.display = 'none';\n this._monthPrev.childNodes[0].className = 'change_month_prev';\n this._monthNext.childNodes[0].className = 'change_month_next';\n\n if ( !this._getPrevMonth() ) {\n this._monthPrev.childNodes[0].className = 'action_inactive';\n }\n\n if ( !this._getNextMonth() ) {\n this._monthNext.childNodes[0].className = 'action_inactive';\n }\n\n this._monthContainer.style.display = 'block';\n },\n\n /**\n * Updates the date shown on the datepicker\n *\n * @method _updateDate\n * @private\n */\n _updateDate: function(){\n var dataParsed;\n if(!this._options.displayInSelect && this._element.value){\n dataParsed = this._parseDate(this._element.value);\n } else if (this._options.displayInSelect) {\n dataParsed = {\n _year: this._options.yearField[this._options.yearField.selectedIndex].value,\n _month: this._options.monthField[this._options.monthField.selectedIndex].value - 1,\n _day: this._options.dayField[this._options.dayField.selectedIndex].value\n };\n }\n\n if (dataParsed) {\n dataParsed = this._fitDateToRange(dataParsed);\n this._year = dataParsed._year;\n this._month = dataParsed._month;\n this._day = dataParsed._day;\n }\n this._setDate();\n this._updateDescription();\n this._renderMonth();\n },\n\n /**\n * Updates the date description shown at the top of the datepicker\n *\n * EG \"12 de November\"\n *\n * @method _updateDescription\n * @private\n */\n _updateDescription: function(){\n InkElement.setTextContent(this._monthChanger, this._options.month[this._month + 1]);\n InkElement.setTextContent(this._ofText, this._options.ofText);\n InkElement.setTextContent(this._yearChanger, this._year);\n },\n\n /**\n * Renders the year selector view of the datepicker\n *\n * @method _showYearSelector\n * @private\n */\n _showYearSelector: function(inc){\n this._incrementViewingYear(inc);\n\n var firstYear = this._year - (this._year % 10);\n var thisYear = firstYear - 1;\n\n InkElement.setHTML(this._yearSelector, '');\n var yearUl = InkElement.create('ul');\n this._yearSelector.appendChild(yearUl);\n\n if (thisYear > this._min._year) {\n var prevYearLi = InkElement.create('li');\n\n prevYearLi.appendChild(InkElement.create('a', {\n href: '#year_prev',\n className: 'change_year_prev',\n setHTML: this._options.prevLinkText\n }));\n\n yearUl.appendChild(prevYearLi);\n } else {\n yearUl.appendChild(InkElement.create('li', { setHTML: '&nbsp;' }));\n }\n\n for (var i=1; i < 11; i++){\n if (i % 4 === 0){\n yearUl = InkElement.create('ul');\n this._yearSelector.appendChild(yearUl);\n }\n\n thisYear = firstYear + i - 1;\n\n yearUl.appendChild(this._getYearButton(thisYear));\n }\n\n if (thisYear < this._max._year) {\n var nextYearLi = InkElement.create('li');\n\n nextYearLi.appendChild(InkElement.create('a', {\n href: '#year_next',\n className: 'change_year_next',\n setHTML: this._options.nextLinkText\n }));\n\n yearUl.appendChild(nextYearLi);\n } else {\n yearUl.appendChild(InkElement.create('li', { setHTML: '&nbsp;' }));\n }\n\n this._monthPrev.childNodes[0].className = 'action_inactive';\n this._monthNext.childNodes[0].className = 'action_inactive';\n this._monthSelector.style.display = 'none';\n this._monthContainer.style.display = 'none';\n this._yearSelector.style.display = 'block';\n },\n\n /**\n * For the year selector.\n *\n * Update this._year, to find the next decade or use nextValidDateFn to find it.\n */\n _incrementViewingYear: function (inc) {\n if (!inc) { return; }\n\n var year = +this._year + inc*10;\n year = year - year % 10;\n if ( year > this._max._year || year + 9 < this._min._year){\n return;\n }\n this._year = +this._year + inc*10;\n },\n\n _getYearButton: function (thisYear) {\n var className = '';\n\n if (!this._acceptableYear({ _year: thisYear })) {\n className = 'ink-calendar-off';\n } else if (thisYear === this._year) {\n className = 'ink-calendar-on';\n }\n\n var li = InkElement.create('li');\n\n li.appendChild(InkElement.create('a', {\n href: '#',\n 'data-cal-year': thisYear,\n className: className,\n setTextContent: thisYear\n }));\n\n return li;\n },\n\n /**\n * Show the month selector (happens when you click a year, or the \"month\" link.\n * @method _showMonthSelector\n * @private\n */\n _showMonthSelector: function () {\n this._yearSelector.style.display = 'none';\n this._monthContainer.style.display = 'none';\n this._monthPrev.childNodes[0].className = 'action_inactive';\n this._monthNext.childNodes[0].className = 'action_inactive';\n this._addMonthClassNames();\n this._monthSelector.style.display = 'block';\n },\n\n /**\n * This function returns the given date in the dateish format\n *\n * @method _parseDate\n * @param {String} dateStr A date on a string.\n * @private\n */\n _parseDate: function(dateStr){\n var date = InkDate.set( this._options.format , dateStr );\n if (date) {\n return dateishFromDate(date);\n }\n return null;\n },\n\n /**\n * Checks if a date is valid\n *\n * @method _isValidDate\n * @param {Dateish} date\n * @private\n * @return {Boolean} True if the date is valid, false otherwise\n */\n _isValidDate: function(date){\n var yearRegExp = /^\\d{4}$/;\n var validOneOrTwo = /^\\d{1,2}$/;\n return (\n yearRegExp.test(date._year) &&\n validOneOrTwo.test(date._month) &&\n validOneOrTwo.test(date._day) &&\n +date._month + 1 >= 1 &&\n +date._month + 1 <= 12 &&\n +date._day >= 1 &&\n +date._day <= this._daysInMonth(date._year, date._month + 1)\n );\n },\n\n /**\n * Checks if a given date is an valid format.\n *\n * @method _isDate\n * @param {String} format A date format.\n * @param {String} dateStr A date on a string.\n * @private\n * @return {Boolean} True if the given date is valid according to the given format\n */\n _isDate: function(format, dateStr){\n try {\n if (typeof format === 'undefined'){\n return false;\n }\n var date = InkDate.set( format , dateStr );\n if( date && this._isValidDate( dateishFromDate(date) )) {\n return true;\n }\n } catch (ex) {}\n\n return false;\n },\n\n _acceptableDay: function (date) {\n return this._acceptableDateComponent(date, 'validDayFn');\n },\n\n _acceptableMonth: function (date) {\n return this._acceptableDateComponent(date, 'validMonthFn');\n },\n\n _acceptableYear: function (date) {\n return this._acceptableDateComponent(date, 'validYearFn');\n },\n\n /** DRY base for the above 2 functions */\n _acceptableDateComponent: function (date, userCb) {\n if (this._options[userCb]) {\n return this._callUserCallbackBool(this._options[userCb], date);\n } else {\n return this._dateWithinRange(date);\n }\n },\n\n /**\n * This method returns the date written with the format specified on the options\n *\n * @method _writeDateInFormat\n * @private\n * @return {String} Returns the current date of the object in the specified format\n */\n _writeDateInFormat:function(){\n return InkDate.get( this._options.format , this.getDate());\n },\n\n /**\n * This method allows the user to set the DatePicker's date on run-time.\n *\n * @method setDate\n * @param {Date|String} dateString A Date object, or date string in yyyy-mm-dd format.\n * @public\n */\n setDate: function( dateString ) {\n if (dateString && typeof dateString.getDate === 'function') {\n dateString = [ dateString.getFullYear(),\n dateString.getMonth() + 1, dateString.getDate() ].join('-');\n }\n\n if ( /\\d{4}-\\d{1,2}-\\d{1,2}/.test( dateString ) ) {\n var auxDate = dateString.split( '-' );\n this._year = +auxDate[ 0 ];\n this._month = +auxDate[ 1 ] - 1;\n this._day = +auxDate[ 2 ];\n }\n\n this._setDate( );\n },\n\n /**\n * Gets the currently selected date as a JavaScript date.\n *\n * @method getDate\n */\n getDate: function () {\n if (!this._day) {\n throw 'Ink.UI.DatePicker: Still picking a date. Cannot getDate now!';\n }\n return new Date(this._year, this._month, this._day);\n },\n\n /**\n * Sets the chosen date on the target input field\n *\n * @method _setDate\n * @param {DOMElement} objClicked Clicked object inside the DatePicker's calendar.\n * @private\n */\n _setDate : function( objClicked ) {\n if (objClicked) {\n var data = InkElement.data(objClicked);\n this._day = (+data.calDay) || this._day;\n }\n\n var dt = this._fitDateToRange(this);\n\n this._year = dt._year;\n this._month = dt._month;\n this._day = dt._day;\n\n if(!this._options.displayInSelect){\n this._element.value = this._writeDateInFormat();\n } else {\n this._options.dayField.value = this._day;\n this._options.monthField.value = this._month + 1;\n this._options.yearField.value = this._year;\n }\n\n if(this._options.onSetDate) {\n this._options.onSetDate( this , { date : this.getDate() } );\n }\n },\n\n /**\n * Makes the necessary work to update the calendar\n * when choosing a different month\n *\n * @method _updateCal\n * @param {Number} inc Indicates previous or next month\n * @private\n */\n _updateCal: function(inc){\n if( typeof this._options.onMonthSelected === 'function' ){\n this._options.onMonthSelected(this, {\n 'year': this._year,\n 'month' : this._month\n });\n }\n if (inc && this._updateMonth(inc) === null) {\n return;\n }\n this._renderMonth();\n },\n\n /**\n * Function that returns the number of days on a given month on a given year\n *\n * @method _daysInMonth\n * @param {Number} _y - year\n * @param {Number} _m - month\n * @private\n * @return {Number} The number of days on a given month on a given year\n */\n _daysInMonth: function(_y,_m){\n var exceptions = {\n 2: ((_y % 400 === 0) || (_y % 4 === 0 && _y % 100 !== 0)) ? 29 : 28,\n 4: 30,\n 6: 30,\n 9: 30,\n 11: 30\n };\n\n return exceptions[_m] || 31;\n },\n\n\n /**\n * Updates the calendar when a different month is chosen\n *\n * @method _updateMonth\n * @param {Number} incValue - indicates previous or next month\n * @private\n */\n _updateMonth: function(incValue){\n var date;\n if (incValue > 0) {\n date = this._getNextMonth();\n } else if (incValue < 0) {\n date = this._getPrevMonth();\n }\n if (!date) { return null; }\n this._year = date._year;\n this._month = date._month;\n this._day = date._day;\n },\n\n /**\n * Get the next month we can show.\n */\n _getNextMonth: function (date) {\n return this._tryLeap( date, 'Month', 'next', function (d) {\n d._month += 1;\n if (d._month > 11) {\n d._month = 0;\n d._year += 1;\n }\n return d;\n });\n },\n\n /**\n * Get the previous month we can show.\n */\n _getPrevMonth: function (date) {\n return this._tryLeap( date, 'Month', 'prev', function (d) {\n d._month -= 1;\n if (d._month < 0) {\n d._month = 11;\n d._year -= 1;\n }\n return d;\n });\n },\n\n /**\n * Get the next year we can show.\n */\n _getPrevYear: function (date) {\n return this._tryLeap( date, 'Year', 'prev', function (d) {\n d._year -= 1;\n return d;\n });\n },\n\n /**\n * Get the next year we can show.\n */\n _getNextYear: function (date) {\n return this._tryLeap( date, 'Year', 'next', function (d) {\n d._year += 1;\n return d;\n });\n },\n\n /**\n * DRY base for a function which tries to get the next or previous valid year or month.\n *\n * It checks if we can go forward by using _dateCmp with atomic\n * precision (this means, {_year} for leaping years, and\n * {_year, month} for leaping months), then it tries to get the\n * result from the user-supplied callback (nextDateFn or prevDateFn),\n * and when this is not present, advance the date forward using the\n * `advancer` callback.\n */\n _tryLeap: function (date, atomName, directionName, advancer) {\n date = date || { _year: this._year, _month: this._month, _day: this._day };\n\n var maxOrMin = directionName === 'prev' ? '_min' : '_max';\n var boundary = this[maxOrMin];\n\n // Check if we're by the boundary of min/max year/month\n if (this._dateCmpUntil(date, boundary, atomName) === 0) {\n return null; // We're already at the boundary. Bail.\n }\n\n var leapUserCb = this._options[directionName + 'ValidDateFn'];\n if (leapUserCb) {\n return this._callUserCallbackDate(leapUserCb, date);\n } else {\n date = advancer(date);\n }\n\n date = this._fitDateToRange(date);\n\n return this['_acceptable' + atomName](date) ? date : null;\n },\n\n _getNextDecade: function (date) {\n date = date || { _year: this._year, _month: this._month, _day: this._day };\n var decade = this._getCurrentDecade(date);\n if (decade + 10 > this._max._year) { return null; }\n return decade + 10;\n },\n\n _getPrevDecade: function (date) {\n date = date || { _year: this._year, _month: this._month, _day: this._day };\n var decade = this._getCurrentDecade(date);\n if (decade - 10 < this._min._year) { return null; }\n return decade - 10;\n },\n\n /** Returns the decade given a date or year*/\n _getCurrentDecade: function (year) {\n year = year ? (year._year || year) : this._year;\n return Math.floor(year / 10) * 10; // Round to first place\n },\n\n _callUserCallbackBase: function (cb, date) {\n return cb.call(this, date._year, date._month + 1, date._day);\n },\n\n _callUserCallbackBool: function (cb, date) {\n return !!this._callUserCallbackBase(cb, date);\n },\n\n _callUserCallbackDate: function (cb, date) {\n var ret = this._callUserCallbackBase(cb, date);\n return ret ? dateishFromDate(ret) : null;\n },\n\n /**\n * Key-value object that (for a given key) points to the correct parsing format for the DatePicker\n * @property _dateParsers\n * @type {Object}\n * @readOnly\n */\n _dateParsers: {\n 'yyyy-mm-dd' : 'Y-m-d' ,\n 'yyyy/mm/dd' : 'Y/m/d' ,\n 'yy-mm-dd' : 'y-m-d' ,\n 'yy/mm/dd' : 'y/m/d' ,\n 'dd-mm-yyyy' : 'd-m-Y' ,\n 'dd/mm/yyyy' : 'd/m/Y' ,\n 'dd-mm-yy' : 'd-m-y' ,\n 'dd/mm/yy' : 'd/m/y' ,\n 'mm/dd/yyyy' : 'm/d/Y' ,\n 'mm-dd-yyyy' : 'm-d-Y'\n },\n\n /**\n * Renders the current month\n *\n * @method _renderMonth\n * @private\n */\n _renderMonth: function(){\n var month = this._month;\n var year = this._year;\n\n this._showDefaultView();\n\n InkElement.setHTML(this._monthContainer, '');\n\n this._monthContainer.appendChild(\n this._getMonthCalendarHeader(this._options.startWeekDay));\n\n this._monthContainer.appendChild(\n this._getDayButtons(year, month));\n },\n\n /**\n * Figure out where the first day of a month lies\n * in the first row of the calendar.\n *\n * having options.startWeekDay === 0\n *\n * Su Mo Tu We Th Fr Sa \n * 1 <- The \"1\" is in the 7th day. return 6.\n * 2 3 4 5 6 7 8 \n * 9 10 11 12 13 14 15 \n * 16 17 18 19 20 21 22 \n * 23 24 25 26 27 28 29 \n * 30 31\n *\n * This obviously changes according to the user option \"startWeekDay\"\n **/\n _getFirstDayIndex: function (year, month) {\n var wDayFirst = (new Date( year , month , 1 )).getDay(); // Sunday=0\n var startWeekDay = this._options.startWeekDay || 0; // Sunday=0\n\n var result = wDayFirst - startWeekDay;\n\n result %= 7;\n\n if (result < 0) {\n result += 6;\n }\n\n return result;\n },\n\n _getDayButtons: function (year, month) {\n var daysInMonth = this._daysInMonth(year, month + 1);\n\n var ret = document.createDocumentFragment();\n\n var ul = InkElement.create('ul');\n ret.appendChild(ul);\n\n var firstDayIndex = this._getFirstDayIndex(year, month);\n\n // Add padding if the first day of the month is not monday.\n for (var i = 0; i < firstDayIndex; i ++) {\n ul.appendChild(InkElement.create('li', {\n className: 'ink-calendar-empty',\n setHTML: '&nbsp;'\n }));\n }\n\n for (var day = 1; day <= daysInMonth; day++) {\n if ((day - 1 + firstDayIndex) % 7 === 0){ // new week, new UL\n ul = InkElement.create('ul');\n ret.appendChild(ul);\n }\n\n ul.appendChild(this._getDayButton(year, month, day));\n }\n return ret;\n },\n\n /**\n * Get the HTML markup for a single day in month view, given year, month, day.\n *\n * @method _getDayButtonHtml\n * @private\n */\n _getDayButton: function (year, month, day) {\n var attrs = {};\n var date = dateishFromYMD(year, month, day);\n\n if (!this._acceptableDay(date)) {\n attrs.className = 'ink-calendar-off';\n } else {\n attrs['data-cal-day'] = day;\n\n if (this._day && this._dateCmp(date, this) === 0) {\n attrs.className = 'ink-calendar-on';\n }\n }\n\n attrs.setTextContent = day;\n\n var dayButton = InkElement.create('li');\n dayButton.appendChild(InkElement.create('a', attrs));\n return dayButton;\n },\n\n /** Write the top bar of the calendar (M T W T F S S) */\n _getMonthCalendarHeader: function (startWeekDay) {\n var header = InkElement.create('ul', {\n className: 'ink-calendar-header'\n });\n\n var wDay;\n for(var i=0; i<7; i++){\n wDay = (startWeekDay + i) % 7;\n header.appendChild(InkElement.create('li', {\n setTextContent: this._options.wDay[wDay].substring(0, 1)\n }));\n }\n\n return header;\n },\n\n /**\n * This method adds class names to month buttons, to visually distinguish.\n *\n * @method _addMonthClassNames\n * @param {DOMElement} parent DOMElement where all the months are.\n * @private\n */\n _addMonthClassNames: function(parent){\n InkArray.forEach(\n (parent || this._monthSelector).getElementsByTagName('a'),\n Ink.bindMethod(this, '_addMonthButtonClassNames'));\n },\n\n /**\n * Add the ink-calendar-on className if the given button is the current month,\n * otherwise add the ink-calendar-off className if the given button refers to\n * an unacceptable month (given dateRange and validMonthFn)\n */\n _addMonthButtonClassNames: function (btn) {\n var data = InkElement.data(btn);\n if (!data.calMonth) { throw 'not a calendar month button!'; }\n\n var month = +data.calMonth - 1;\n\n if ( month === this._month ) {\n Css.addClassName( btn, 'ink-calendar-on' ); // This month\n Css.removeClassName( btn, 'ink-calendar-off' );\n } else {\n Css.removeClassName( btn, 'ink-calendar-on' ); // Not this month\n\n var toDisable = !this._acceptableMonth({_year: this._year, _month: month});\n Css.addRemoveClassName( btn, 'ink-calendar-off', toDisable);\n }\n },\n\n /*\n * // TODO implement this\n * Prototype's method to allow the 'i18n files' to change all objects' language at once.\n * @param {Object} options Object with the texts' configuration.\n * @param {String} options.closeText Text of the close anchor\n * @param {String} options.cleanText Text of the clean text anchor\n * @param {String} options.prevLinkText \"Previous\" link's text\n * @param {String} options.nextLinkText \"Next\" link's text\n * @param {String} options.ofText The text \"of\", present in 'May of 2013'\n * @param {Object} options.month An object with keys from 1 to 12 for the full months' names\n * @param {Object} options.wDay An object with keys from 0 to 6 for the full weekdays' names\n * @public\n */\n lang: function( options ){\n this._lang = options;\n },\n\n /**\n * This calls the rendering of the selected month. (Deprecated: use show() instead)\n *\n */\n showMonth: function(){\n this._renderMonth();\n },\n\n /**\n * Checks if the calendar screen is in 'select day' mode\n * \n * @method isMonthRendered\n * @return {Boolean} True if the calendar screen is in 'select day' mode\n * @public\n */\n isMonthRendered: function(){\n var header = Selector.select('.ink-calendar-header', this._containerObject)[0];\n\n return ((Css.getStyle(header.parentNode,'display') !== 'none') &&\n (Css.getStyle(header.parentNode.parentNode,'display') !== 'none') );\n },\n\n /**\n * Destroys this datepicker, removing it from the page.\n *\n * @method destroy\n * @public\n **/\n destroy: function () {\n InkElement.unwrap(this._element);\n InkElement.remove(this._wrapper);\n InkElement.remove(this._containerObject);\n Common.unregisterInstance.call(this);\n }\n };\n\n Common.createUIComponent(DatePicker);\n\n return DatePicker;\n});","/**\n * Dragging elements around\n * @module Ink.UI.Draggable_1\n * @version 1\n */\n \nInk.createModule(\"Ink.UI.Draggable\",\"1\",[\"Ink.Dom.Element_1\", \"Ink.Dom.Event_1\", \"Ink.Dom.Css_1\", \"Ink.Dom.Browser_1\", \"Ink.Dom.Selector_1\", \"Ink.UI.Common_1\"],function( InkElement, InkEvent, Css, Browser, Selector, Common) {\n 'use strict';\n\n var x = 0,\n y = 1; // For accessing coords in [x, y] arrays\n \n // Get a value between two boundaries\n function between (val, min, max) {\n val = Math.min(val, max);\n val = Math.max(val, min);\n return val;\n }\n\n /**\n * @class Ink.UI.Draggable\n * @version 1\n * @constructor\n * @param {String|DOMElement} target Target element.\n * @param {Object} [options] Optional object to configure the component.\n * @param {String} [options.constraint] Movement constraint. None by default. Can be `vertical`, `horizontal`, or `both`.\n * @param {String|DOMElement} [options.constraintElm] Constrain dragging to be within this element. None by default.\n * @param {Number} [options.top] Limits to constrain draggable movement.\n * @param {Number} [options.right] Limits to constrain draggable movement.\n * @param {Number} [options.bottom] Limits to constrain draggable movement.\n * @param {Number} [options.left] Limits to constrain draggable movement.\n * @param {String|DOMElement} [options.handle] If specified, this element or CSS ID will be used as a handle for dragging.\n * @param {Boolean} [options.revert] Flag to revert the draggable to the original position when dragging stops.\n * @param {String} [options.cursor] Cursor type (CSS `cursor` value) used when the mouse is over the draggable object.\n * @param {Number} [options.zIndex] Z-index applied to the draggable element while dragged.\n * @param {Number} [options.fps] If set, throttles the drag effect to this number of frames per second.\n * @param {DOMElement} [options.droppableProxy] If set, a shallow copy of this element will be moved around with transparent background.\n * @param {String} [options.mouseAnchor] Anchor for the drag. Can be one of: 'left','center','right','top','center','bottom'.\n * @param {String} [options.dragClass] Class to add when the draggable is being dragged. Defaults to drag.\n * @param {Boolean} [options.skipChildren=true] Whether you have to drag the actual element, or dragging one of the children is okay too.\n * @param {Function} [options.onStart] Callback called when dragging starts.\n * @param {Function} [options.onEnd] Callback called when dragging stops.\n * @param {Function} [options.onDrag] Callback called while dragging, prior to position updates.\n * @param {Function} [options.onChange] Callback called while dragging, after position updates.\n *\n * @sample Ink_UI_Draggable_1.html\n */\n function Draggable() {\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n Draggable._name = 'Draggable_1';\n\n Draggable._optionDefinition = {\n constraint: ['String', false],\n constraintElm: ['Element', false],\n top: ['Number', false],\n right: ['Number', false],\n bottom: ['Number', false],\n left: ['Number', false],\n handle: ['Element', false],\n revert: ['Boolean', false],\n cursor: ['String', 'move'],\n zIndex: ['Number', 9999],\n fps: ['Number', 0],\n droppableProxy: ['Element', false],\n mouseAnchor: ['String', undefined],\n dragClass: ['String', 'drag'],\n skipChildren: ['Boolean', true], // Magic/More Magic\n onStart: ['Function', false],\n onEnd: ['Function', false],\n onDrag: ['Function', false],\n onChange: ['Function', false]\n };\n\n Draggable.prototype = {\n /**\n * Init function called by the constructor\n * \n * @method _init\n * @param {String|DOMElement} element Element ID of the element or DOM Element.\n * @param {Object} [options] Options object for configuration of the module.\n * @private\n */\n _init: function() {\n var o = this._options;\n this.constraintElm = o.constraintElm && Common.elOrSelector(o.constraintElm);\n\n this.handle = false;\n this.elmStartPosition = false;\n this.active = false;\n this.dragged = false;\n this.prevCoords = false;\n this.placeholder = false;\n\n this.position = false;\n this.zindex = false;\n this.firstDrag = true;\n\n if (o.fps) {\n this.deltaMs = 1000 / o.fps;\n this.lastRunAt = 0;\n }\n\n this.handlers = {};\n this.handlers.start = Ink.bindEvent(this._onStart,this);\n this.handlers.dragFacade = Ink.bindEvent(this._onDragFacade,this);\n this.handlers.drag = Ink.bindEvent(this._onDrag,this);\n this.handlers.end = Ink.bindEvent(this._onEnd,this);\n this.handlers.selectStart = function(event) { InkEvent.stop(event); return false; };\n\n // set handle\n this.handle = (this._options.handle) ?\n Common.elOrSelector(this._options.handle) :\n this._element;\n\n this.handle.style.cursor = o.cursor;\n\n InkEvent.observe(this.handle, 'touchstart', this.handlers.start);\n InkEvent.observe(this.handle, 'mousedown', this.handlers.start);\n\n if (Browser.IE) {\n InkEvent.observe(this._element, 'selectstart', this.handlers.selectStart);\n }\n },\n\n /**\n * Removes the ability of the element of being dragged\n * \n * @method destroy\n * @public\n */\n destroy: function() {\n InkEvent.stopObserving(this.handle, 'touchstart', this.handlers.start);\n InkEvent.stopObserving(this.handle, 'mousedown', this.handlers.start);\n\n if (Browser.IE) {\n InkEvent.stopObserving(this._element, 'selectstart', this.handlers.selectStart);\n }\n },\n\n /**\n * Gets coordinates for a given event (with added page scroll)\n * \n * @method _getCoords\n * @param {Object} e window.event object.\n * @return {Array} Array where the first position is the x coordinate, the second is the y coordinate\n * @private\n */\n _getCoords: function(e) {\n var ps = [InkElement.scrollWidth(), InkElement.scrollHeight()];\n return {\n x: (e.touches ? e.touches[0].clientX : e.clientX) + ps[x],\n y: (e.touches ? e.touches[0].clientY : e.clientY) + ps[y]\n };\n },\n\n /**\n * Clones src element's relevant properties to dst\n * \n * @method _cloneStyle\n * @param {DOMElement} src Element from where we're getting the styles\n * @param {DOMElement} dst Element where we're placing the styles.\n * @private\n */\n _cloneStyle: function(src, dst) {\n dst.className = src.className;\n dst.style.borderWidth = '0';\n dst.style.padding = '0';\n dst.style.position = 'absolute';\n dst.style.width = InkElement.elementWidth(src) + 'px';\n dst.style.height = InkElement.elementHeight(src) + 'px';\n dst.style.left = InkElement.elementLeft(src) + 'px';\n dst.style.top = InkElement.elementTop(src) + 'px';\n dst.style.cssFloat = Css.getStyle(src, 'float');\n dst.style.display = Css.getStyle(src, 'display');\n },\n\n /**\n * onStart event handler\n * \n * @method _onStart\n * @param {Object} e window.event object\n * @return {Boolean|void} In some cases return false. Otherwise is void\n * @private\n */\n _onStart: function(e) {\n if (!this.active && InkEvent.isLeftClick(e) || typeof e.button === 'undefined') {\n\n var tgtEl = InkEvent.element(e);\n if (this._options.skipChildren && tgtEl !== this.handle) { return; }\n\n InkEvent.stop(e);\n\n Css.addClassName(this._element, this._options.dragClass);\n\n this.elmStartPosition = [\n InkElement.elementLeft(this._element),\n InkElement.elementTop( this._element)\n ];\n\n var pos = [\n parseInt(Css.getStyle(this._element, 'left'), 10),\n parseInt(Css.getStyle(this._element, 'top'), 10)\n ];\n\n var dims = InkElement.elementDimensions(this._element);\n\n this.originalPosition = [ pos[x] ? pos[x]: null, pos[y] ? pos[y] : null ];\n this.delta = this._getCoords(e); // mouse coords at beginning of drag\n\n this.active = true;\n this.position = Css.getStyle(this._element, 'position');\n this.zindex = Css.getStyle(this._element, 'zIndex');\n\n var div = document.createElement('div');\n div.style.position = this.position;\n div.style.width = dims[x] + 'px';\n div.style.height = dims[y] + 'px';\n div.style.marginTop = Css.getStyle(this._element, 'margin-top');\n div.style.marginBottom = Css.getStyle(this._element, 'margin-bottom');\n div.style.marginLeft = Css.getStyle(this._element, 'margin-left');\n div.style.marginRight = Css.getStyle(this._element, 'margin-right');\n div.style.borderWidth = '0';\n div.style.padding = '0';\n div.style.cssFloat = Css.getStyle(this._element, 'float');\n div.style.display = Css.getStyle(this._element, 'display');\n div.style.visibility = 'hidden';\n\n this.delta2 = [ this.delta.x - this.elmStartPosition[x], this.delta.y - this.elmStartPosition[y] ]; // diff between top-left corner of obj and mouse\n if (this._options.mouseAnchor) {\n var parts = this._options.mouseAnchor.split(' ');\n var ad = [dims[x], dims[y]]; // starts with 'right bottom'\n if (parts[0] === 'left') { ad[x] = 0; } else if(parts[0] === 'center') { ad[x] = parseInt(ad[x]/2, 10); }\n if (parts[1] === 'top') { ad[y] = 0; } else if(parts[1] === 'center') { ad[y] = parseInt(ad[y]/2, 10); }\n this.applyDelta = [this.delta2[x] - ad[x], this.delta2[y] - ad[y]];\n }\n\n var dragHandlerName = this._options.fps ? 'dragFacade' : 'drag';\n\n this.placeholder = div;\n\n if (this._options.onStart) { this._options.onStart(this._element, e); }\n\n if (this._options.droppableProxy) { // create new transparent div to optimize DOM traversal during drag\n this.proxy = document.createElement('div');\n dims = [\n window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,\n window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight\n ];\n var fs = this.proxy.style;\n fs.width = dims[x] + 'px';\n fs.height = dims[y] + 'px';\n fs.position = 'fixed';\n fs.left = '0';\n fs.top = '0';\n fs.zIndex = this._options.zindex + 1;\n fs.backgroundColor = '#FF0000';\n Css.setOpacity(this.proxy, 0);\n\n var firstEl = document.body.firstChild;\n while (firstEl && firstEl.nodeType !== 1) { firstEl = firstEl.nextSibling; }\n document.body.insertBefore(this.proxy, firstEl);\n\n \n InkEvent.observe(this.proxy, 'mousemove', this.handlers[dragHandlerName]);\n InkEvent.observe(this.proxy, 'touchmove', this.handlers[dragHandlerName]);\n }\n else {\n InkEvent.observe(document, 'mousemove', this.handlers[dragHandlerName]);\n }\n\n this._element.style.position = 'absolute';\n this._element.style.zIndex = this._options.zindex;\n this._element.parentNode.insertBefore(this.placeholder, this._element);\n\n this._onDrag(e);\n\n InkEvent.observe(document, 'mouseup', this.handlers.end);\n InkEvent.observe(document, 'touchend', this.handlers.end);\n\n return false;\n }\n },\n\n /**\n * Function that gets the timestamp of the current run from time to time. (FPS)\n * \n * @method _onDragFacade\n * @param {Object} window.event object.\n * @private\n */\n _onDragFacade: function(e) {\n var now = +new Date();\n if (!this.lastRunAt || now > this.lastRunAt + this.deltaMs) {\n this.lastRunAt = now;\n this._onDrag(e);\n }\n },\n\n /**\n * Function that handles the dragging movement\n * \n * @method _onDrag\n * @param {Object} window.event object.\n * @private\n */\n _onDrag: function(e) {\n if (this.active) {\n InkEvent.stop(e);\n this.dragged = true;\n var mouseCoords = this._getCoords(e),\n mPosX = mouseCoords.x,\n mPosY = mouseCoords.y,\n o = this._options,\n newX = false,\n newY = false;\n\n if (this.prevCoords && mPosX !== this.prevCoords.x || mPosY !== this.prevCoords.y) {\n if (o.onDrag) { o.onDrag(this._element, e); }\n this.prevCoords = mouseCoords;\n\n newX = this.elmStartPosition[x] + mPosX - this.delta.x;\n newY = this.elmStartPosition[y] + mPosY - this.delta.y;\n\n var draggableSize = InkElement.elementDimensions(this._element);\n\n if (this.constraintElm) {\n var offset = InkElement.offset(this.constraintElm);\n var size = InkElement.elementDimensions(this.constraintElm);\n var constTop = offset[y] + (o.top || 0),\n constBottom = offset[y] + size[y] - (o.bottom || 0),\n constLeft = offset[x] + (o.left || 0),\n constRight = offset[x] + size[x] - (o.right || 0);\n\n newY = between(newY, constTop, constBottom - draggableSize[y]);\n newX = between(newX, constLeft, constRight - draggableSize[x]);\n } else if (o.constraint) {\n var right = o.right === false ? InkElement.pageWidth() - draggableSize[x] : o.right,\n left = o.left === false ? 0 : o.left,\n top = o.top === false ? 0 : o.top,\n bottom = o.bottom === false ? InkElement.pageHeight() - draggableSize[y] : o.bottom;\n if (o.constraint === 'horizontal' || o.constraint === 'both') {\n newX = between(newX, left, right);\n }\n if (o.constraint === 'vertical' || o.constraint === 'both') {\n newY = between(newY, top, bottom);\n }\n }\n\n var Droppable = Ink.getModule('Ink.UI.Droppable_1');\n if (this.firstDrag) {\n if (Droppable) { Droppable.updateAll(); }\n /*this._element.style.position = 'absolute';\n this._element.style.zIndex = this._options.zindex;\n this._element.parentNode.insertBefore(this.placeholder, this._element);*/\n this.firstDrag = false;\n }\n\n if (newX) { this._element.style.left = newX + 'px'; }\n if (newY) { this._element.style.top = newY + 'px'; }\n\n if (Droppable) {\n // apply applyDelta defined on drag init\n var mouseCoords2 = this._options.mouseAnchor ?\n {x: mPosX - this.applyDelta[x], y: mPosY - this.applyDelta[y]} :\n mouseCoords;\n Droppable.action(mouseCoords2, 'drag', e, this._element);\n }\n if (o.onChange) { o.onChange(this); }\n }\n }\n },\n\n /**\n * Function that handles the end of the dragging process\n * \n * @method _onEnd\n * @param {Object} window.event object.\n * @private\n */\n _onEnd: function(e) {\n InkEvent.stopObserving(document, 'mousemove', this.handlers.drag);\n InkEvent.stopObserving(document, 'touchmove', this.handlers.drag);\n\n if (this._options.fps) {\n this._onDrag(e);\n }\n\n Css.removeClassName(this._element, this._options.dragClass);\n\n if (this.active && this.dragged) {\n\n if (this._options.droppableProxy) { // remove transparent div...\n document.body.removeChild(this.proxy);\n }\n\n if (this.pt) { // remove debugging element...\n InkElement.remove(this.pt);\n this.pt = undefined;\n }\n\n /*if (this._options.revert) {\n this.placeholder.parentNode.removeChild(this.placeholder);\n }*/\n\n if(this.placeholder) {\n InkElement.remove(this.placeholder);\n }\n\n if (this._options.revert) {\n this._element.style.position = this.position;\n if (this.zindex !== null) {\n this._element.style.zIndex = this.zindex;\n }\n else {\n this._element.style.zIndex = 'auto';\n } // restore default zindex of it had none\n\n this._element.style.left = (this.originalPosition[x]) ? this.originalPosition[x] + 'px' : '';\n this._element.style.top = (this.originalPosition[y]) ? this.originalPosition[y] + 'px' : '';\n }\n\n if (this._options.onEnd) {\n this._options.onEnd(this._element, e);\n }\n \n var Droppable = Ink.getModule('Ink.UI.Droppable_1');\n if (Droppable) {\n Droppable.action(this._getCoords(e), 'drop', e, this._element);\n }\n\n this.position = false;\n this.zindex = false;\n this.firstDrag = true;\n }\n\n this.active = false;\n this.dragged = false;\n }\n };\n\n Common.createUIComponent(Draggable);\n\n return Draggable;\n\n});\n","/**\n * Off-canvas menu\n * @module Ink.UI.Drawer_1\n * @version 1\n */\n \nInk.createModule('Ink.UI.Drawer', '1', ['Ink.UI.Common_1', 'Ink.Dom.Loaded_1', 'Ink.Dom.Selector_1', 'Ink.Dom.Element_1', 'Ink.Dom.Event_1', 'Ink.Dom.Css_1'], function(Common, Loaded, Selector, Element, Event, Css) {\n 'use strict';\n\n function elNotFound(el) {\n Ink.warn( 'Ink.UI.Drawer_1: Could not find the \"' +\n el + '\" element on this page. Please make sure it exists.' );\n }\n\n function Drawer(options) {\n Common.BaseUIComponent.apply(this, [document.body, options]);\n }\n\n Drawer._name = 'Drawer_1';\n\n Drawer._optionDefinition = {\n parentSelector: ['String', '.ink-drawer'],\n leftDrawer: ['String', '.left-drawer'],\n leftTrigger: ['String', '.left-drawer-trigger'],\n rightDrawer: ['String', '.right-drawer'],\n rightTrigger: ['String', '.right-drawer-trigger'],\n contentDrawer: ['String', '.content-drawer'],\n closeOnContentClick: ['Boolean', true],\n closeOnLinkClick: ['Boolean', true],\n mode: ['String', 'push'],\n sides: ['String', 'both']\n };\n\n Drawer.prototype = {\n /**\n * Displays off-canvas content which can be triggered by clicking elements with the 'left-drawer-trigger' and 'right-drawer-trigger', respectively.\n * The left drawer has the 'left-drawer' class, and the right drawer has the 'right-drawer' class. The content drawer (EG your `<div id=\"main\">`) must have the 'content-drawer' class. For more, see the example below, or try the sample.\n * @class Ink.UI.Drawer_1\n * @constructor\n *\n * @param {Object} [options] Configuration options.\n * @xparam {String} [options.parentSelector] The class you are using in your wrapper (in the example below, it's the `body` tag.)\n * @xparam {String} [options.leftDrawer] Selector for the left drawer element. This element is placed outside the screen and shown when you click the `leftTrigger` element.\n * @xparam {String} [options.leftTrigger] Selector for the left drawer trigger(s). When you click this trigger, the `leftDrawer` is shown.\n * @xparam {String} [options.rightDrawer] Right drawer selector. (see `options.leftDrawer`)\n * @xparam {String} [options.rightTrigger] Right trigger selector (see `options.leftTrigger`)\n * @xparam {String} [options.contentDrawer] Selector for the content drawer.\n * @param {Boolean} [options.closeOnContentClick] Flag to close the drawer when someone clicks on the `.contentDrawer`\n * @param {String} [options.mode] This can be 'push' or 'over'.\n * @param {String} [options.sides] Can be 'left', 'right', or 'both'. Controls what sides have a drawer.\n *\n * @example\n * <body class=\"ink-drawer\">\n * <div class=\"left-drawer\">\n * Right drawer content...\n * </div>\n * <div class=\"right-drawer\">\n * Left drawer content...\n * </div>\n * <div id=\"main-content\" class=\"content-drawer ink-grid\">\n * <a class=\"left-drawer-trigger\" href=\"\">Open left drawer</a>\n * <a class=\"right-drawer-trigger\" href=\"\">Open right drawer</a>\n * Content...\n * </div>\n * </body>\n *\n * <script>\n * Ink.requireModules(['Ink.UI.Drawer_1'], function (Drawer) {\n * new Drawer();\n * });\n * </script>\n */\n _init: function () {\n // make sure we have the required elements acording to the config options\n\n this._contentDrawers = Ink.ss(this._options.contentDrawer);\n\n this._leftDrawer = Ink.s(this._options.leftDrawer);\n this._leftTriggers = Ink.ss(this._options.leftTrigger);\n\n this._rightDrawer = Ink.s(this._options.rightDrawer);\n this._rightTriggers = Ink.ss(this._options.rightTrigger);\n\n // The body might not have it\n Css.addClassName(document.body, 'ink-drawer');\n\n if(this._contentDrawers.length === 0) {\n throw new Error('Ink.UI.Drawer_1: Could not find any \"' +\n this._options.contentDrawer + '\" elements on this page. ' +\n 'Please make sure you have at least one.' );\n }\n\n switch (this._options.sides) {\n case 'both':\n this._triggers =\n this._options.leftTrigger + ', ' +\n this._options.rightTrigger + ', ' +\n this._options.contentDrawer;\n break;\n\n case 'left':\n this._triggers =\n this._options.leftTrigger + ', ' +\n this._options.contentDrawer;\n break;\n\n case 'right':\n this._triggers =\n this._options.rightTrigger + ', ' +\n this._options.contentDrawer;\n break;\n }\n\n if (this._options.sides === 'left' || this._options.sides === 'both') {\n if( !this._leftDrawer ){\n elNotFound(this._options.leftDrawer);\n }\n\n if(this._leftTriggers.length === 0){\n elNotFound(this._options.leftTrigger);\n }\n } else {\n if( !this._rightDrawer ){\n elNotFound(this._options.rightDrawer);\n }\n\n if( this._rightTriggers.length === 0 ){\n elNotFound(this._options.rightTrigger);\n }\n }\n\n this._isOpen = false;\n this._direction = undefined;\n\n this._handlers = {\n click: Ink.bindEvent(this._onClick, this),\n afterTransition: Ink.bindEvent(this._afterTransition, this)\n };\n this._delay = 10;\n this._addEvents();\n },\n\n /**\n * Click event handler.\n * Listens to the body's click event\n *\n * @method _onClick\n * @private\n **/\n _onClick: function(ev){\n var triggerClicked = Ink.bind(function (side) {\n // When clicking on the trigger, the corresponding side is toggled.\n if (this._isOpen) {\n this.close();\n } else {\n this.open(side);\n }\n ev.preventDefault();\n }, this);\n\n if(Element.findUpwardsBySelector(ev.currentTarget,this._options.leftTrigger)){\n // Clicked on the left trigger\n triggerClicked('left');\n } else if(Element.findUpwardsBySelector(ev.currentTarget,this._options.rightTrigger)){\n triggerClicked('right');\n } else if(Element.findUpwardsBySelector(ev.currentTarget,this._options.contentDrawer)){\n // Clicked on the rest of the body\n if(this._options.closeOnContentClick) {\n this.close();\n }\n } else if (this._options.closeOnLinkClick && Element.isLink(ev.target)) {\n this.close();\n // No preventDefault() here\n }\n },\n\n _afterTransition: function(){\n if(!this._isOpen){\n if(this._direction === 'left') {\n Css.removeClassName(this._leftDrawer, 'show');\n } else {\n Css.removeClassName(this._rightDrawer, 'show');\n }\n }\n },\n\n _addEvents: function(){\n Event.on(document.body, 'click', this._triggers + ', a[href*=\"#\"]', this._handlers.click);\n },\n\n open: function(direction) {\n this._isOpen = true;\n this._direction = direction;\n\n var open = direction === 'left' ?\n this._leftDrawer :\n this._rightDrawer;\n\n Css.addClassName(open,'show');\n setTimeout(Ink.bind(function(){\n Css.addClassName(document.body, [this._options.mode, direction]);\n },this), this._delay);\n },\n\n close: function() {\n if (this._isOpen === false) { return; }\n this._isOpen = false;\n // TODO detect transitionEnd exists, otherwise don't rely on it\n Event.one(document.body, 'transitionend oTransitionEnd webkitTransitionEnd', this._handlers.afterTransition);\n Css.removeClassName(document.body, [this._options.mode, this._direction]);\n }\n\n };\n\n Common.createUIComponent(Drawer);\n\n return Drawer;\n});\n","/**\n * Dropdown menus\n *\n * @module Ink.UI.Dropdown_1\n * Use this UI module to achieve a dropdown menu.\n *\n * @version 1\n */\n\nInk.createModule('Ink.UI.Dropdown', '1', ['Ink.UI.Common_1', 'Ink.UI.Toggle_1', 'Ink.Dom.Event_1', 'Ink.Dom.Element_1'], function(Common, Toggle, InkEvent, InkElement) {\n 'use strict';\n\n function Dropdown() {\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n Dropdown._name = 'Dropdown_1';\n\n Dropdown._optionDefinition = {\n 'target': ['Element'],\n 'hoverOpen': ['Number', null],\n 'dismissOnInsideClick': ['Boolean', false],\n 'dismissOnOutsideClick': ['Boolean', true],\n 'dismissAfter': ['Number', null],\n 'onInsideClick': ['Function', null],\n 'onOutsideClick': ['Function', null],\n 'onOpen': ['Function', null],\n 'onDismiss': ['Function', null]\n };\n\n Dropdown.prototype = {\n /**\n * @class Ink.UI.Dropdown\n *\n * @constructor\n * @param {DOMElement|String} trigger Trigger Element\n * @param {Object} options Options Object\n * @param {DOMElement|String} options.target Target of the dropdown action.\n *\n * @sample Ink_UI_Dropdown_1.html\n */\n _init: function() {\n this._toggle = new Toggle(this._element, {\n target: this._options.target,\n closeOnInsideClick: null,\n closeOnClick: false,\n onChangeState: Ink.bind(function (newState) {\n return this._openOrDismiss(newState, true, true);\n }, this)\n });\n\n // Event where we set this._dismissTimeout and clear this._openTimeout\n InkEvent.observeMulti([this._options.target, this._element],\n 'mouseout', Ink.bindMethod(this, '_onMouseOut'));\n\n // Events to keep clearing this._dismissTimeout and set this._openTimeout\n InkEvent.observeMulti([this._options.target, this._element],\n 'mouseover', Ink.bindMethod(this, '_onMouseOver'));\n\n // to call dismissOnInsideClick and onInsideClick\n InkEvent.observe(this._options.target, 'click', Ink.bindMethod(this, '_onInsideClick'));\n // to call dismissOnOutsideClick and onOutsideClick\n InkEvent.observe(document, 'click', Ink.bindMethod(this, '_onOutsideClick'));\n },\n\n /**\n * Called when the mouse is over the toggler, or the dropdown.\n *\n * Deals with \"hoverOpen\" by setting the dropdown to open later. Also cancels \"dismissAfter\".\n * @method _onMouseOver\n * @private\n **/\n _onMouseOver: function () {\n if (typeof this._options.hoverOpen === 'number' && this._toggle.getState() === false) {\n clearTimeout(this._openTimeout);\n this._openTimeout = setTimeout(\n Ink.bindMethod(this, 'open', true),\n this._options.hoverOpen * 1000);\n }\n if (typeof this._options.dismissAfter === 'number') {\n clearTimeout(this._dismissTimeout);\n }\n },\n\n /**\n * Called when the mouse leaves either the toggler, or the dropdown.\n *\n * Deals with \"dismissAfter\" by setting the dropdown to be dismissed later. Also cancels \"hoverOpen\".\n * @method _onMouseOut\n * @private\n **/\n _onMouseOut: function () {\n if (typeof this._options.dismissAfter === 'number' && this._toggle.getState() === true) {\n clearTimeout(this._dismissTimeout);\n this._dismissTimeout = setTimeout(\n Ink.bindMethod(this, 'dismiss', true),\n this._options.dismissAfter * 1000);\n }\n if (typeof this._options.hoverOpen === 'number') {\n clearTimeout(this._openTimeout);\n }\n },\n\n /**\n * Handle clicks on the dropdown.\n * @method _onInsideClick\n * @private\n */\n _onInsideClick: function (event) {\n var ret = this._handlerCall('onInsideClick', InkEvent.element(event));\n if (ret === false) { return; }\n if (this._options.dismissOnInsideClick) {\n this.dismiss(true);\n }\n },\n\n /**\n * Handle clicks outside the dropdown.\n * @method _onOutsideClick\n * @private\n */\n _onOutsideClick: function (event) {\n var target = InkEvent.element(event);\n var foundElem = InkElement.findUpwardsHaving(target, Ink.bind(function (needle) {\n return needle === this._element;\n }, this));\n var foundTarget = InkElement.findUpwardsHaving(target, Ink.bind(function (needle) {\n return needle === this._options.target;\n }, this));\n\n if (!foundElem && !foundTarget) {\n var ret = this._handlerCall('onOutsideClick', target);\n if (ret === false) { return; }\n if (this._options.dismissOnOutsideClick) {\n this.dismiss(true);\n }\n }\n },\n\n /**\n * Closes the dropdown.\n *\n * @method dismiss\n * @param [callHandler=false] call onDismiss handler\n */\n dismiss: function (callHandler, doNotInformToggle) {\n this._openOrDismiss(false, callHandler, doNotInformToggle);\n },\n\n /**\n * Opens the dropdown\n *\n * @method open\n * @param [callHandler=false] call onOpen handler\n */\n open: function (callHandler, _doNotInformToggle) {\n this._openOrDismiss(true, callHandler, _doNotInformToggle);\n },\n\n /**\n * DRY'ing up open() and dismiss()\n *\n * @method _openOrDismiss\n * @param [newState=false]\n * @param [callHandler=false]\n * @private\n */\n _openOrDismiss: function (newState, callHandler, _doNotInformToggle) {\n if (this._toggle && this._toggle.getState() === newState) { return; }\n if (callHandler) {\n if (this._handlerCall(newState ? 'onOpen' : 'onDismiss') === false) {\n return false; // canceled by event handler\n }\n }\n if (!_doNotInformToggle) {\n this._toggle.setState(newState);\n }\n clearTimeout(this._dismissTimeout);\n clearTimeout(this._openTimeout);\n },\n\n /**\n * call a method given by the user through the options\n *\n * @method _handlerCall\n * @param handler {String} The handler name in this._options\n * @param [args*] Arguments to pass to function\n */\n _handlerCall: function (handler/*, ... */) {\n if (this._options[handler]) {\n return this._options[handler].call(this, [].slice.call(arguments, 1));\n }\n }\n };\n\n Common.createUIComponent(Dropdown);\n\n return Dropdown;\n});\n","/**\n * Drop elements around\n * @module Ink.UI.Droppable_1\n * @version 1\n */\n\nInk.createModule(\"Ink.UI.Droppable\",\"1\",[\"Ink.Dom.Element_1\", \"Ink.Dom.Event_1\", \"Ink.Dom.Css_1\", \"Ink.UI.Common_1\", \"Ink.Util.Array_1\", \"Ink.Dom.Selector_1\"], function( InkElement, InkEvent, Css, Common, InkArray, Selector) {\n 'use strict';\n\n // Higher order functions\n var hAddClassName = function (element) {\n return function (className) {return Css.addClassName(element, className);};\n };\n var hRemoveClassName = function (element) {\n return function (className) {return Css.removeClassName(element, className);};\n };\n\n /**\n * @namespace Ink.UI.Droppable\n * @version 1\n * @static\n */\n var Droppable = {\n /**\n * Flag to activate debug mode\n *\n * @property debug\n * @type {Boolean}\n * @private\n */\n debug: false,\n\n /**\n * Array with the data of each element (`{element: ..., data: ..., options: ...}`)\n * \n * @property _droppables\n * @type {Array}\n * @private\n */\n _droppables: [],\n\n /**\n * Array of data for each draggable. (`{element: ..., data: ...}`)\n *\n * @property _draggables\n * @type {Array}\n * @private\n */\n _draggables: [],\n\n /**\n * Makes an element droppable.\n * This method adds it to the stack of droppable elements.\n * Can consider it a constructor of droppable elements, but where no Droppable object is returned.\n *\n * The onHover, onDrop, and onDropOut options below can be:\n *\n * - 'move', 'copy': Move or copy the draggable element into this droppable.\n * - 'revert': Make the draggable go back to where it came from.\n * - A function (draggableElement, droppableElement), defining what you want to do in this case.\n *\n * @method add\n * @param {String|DOMElement} element Target element\n * @param {Object} [options] Options object\n * @param {String} [options.hoverClass] Classname(s) applied when an acceptable draggable element is hovering the element\n * @param {String} [options.accept] Selector for choosing draggables which can be dropped in this droppable.\n * @param {Function} [options.onHover] Called when an acceptable element is hovering the droppable (see above for string options).\n * @param {Function|String} [options.onDrop] Called when an acceptable element is dropped (see above for string options). \n * @param {Function|String} [options.onDropOut] Called when a droppable is dropped outside this droppable (see above for string options).\n * @public\n *\n * @sample Ink_UI_Droppable_1.html\n *\n */\n add: function(element, options) {\n element = Common.elOrSelector(element, 'Droppable.add target element');\n\n var opt = Ink.extendObj({\n hoverClass: options.hoverclass /* old name */ || false,\n accept: false,\n onHover: false,\n onDrop: false,\n onDropOut: false\n }, options || {}, InkElement.data(element));\n \n if (typeof opt.hoverClass === 'string') {\n opt.hoverClass = opt.hoverClass.split(/\\s+/);\n }\n \n function cleanStyle(draggable) {\n draggable.style.position = 'inherit';\n }\n var that = this;\n var namedEventHandlers = {\n move: function (draggable, droppable/*, event*/) {\n cleanStyle(draggable);\n droppable.appendChild(draggable);\n },\n copy: function (draggable, droppable/*, event*/) {\n cleanStyle(draggable);\n droppable.appendChild(draggable.cloneNode(true));\n },\n revert: function (draggable/*, droppable, event*/) {\n that._findDraggable(draggable).originalParent.appendChild(draggable);\n cleanStyle(draggable);\n }\n };\n var name;\n\n if (typeof opt.onHover === 'string') {\n name = opt.onHover;\n opt.onHover = namedEventHandlers[name];\n if (opt.onHover === undefined) {\n throw new Error('Unknown hover event handler: ' + name);\n }\n }\n if (typeof opt.onDrop === 'string') {\n name = opt.onDrop;\n opt.onDrop = namedEventHandlers[name];\n if (opt.onDrop === undefined) {\n throw new Error('Unknown drop event handler: ' + name);\n }\n }\n if (typeof opt.onDropOut === 'string') {\n name = opt.onDropOut;\n opt.onDropOut = namedEventHandlers[name];\n if (opt.onDropOut === undefined) {\n throw new Error('Unknown dropOut event handler: ' + name);\n }\n }\n\n var elementData = {\n element: element,\n data: {},\n options: opt\n };\n this._droppables.push(elementData);\n this._update(elementData);\n },\n \n /**\n * Finds droppable data about `element`. this data is added in `.add`\n *\n * @method _findData\n * @param {DOMElement} element Needle\n * @return {object} Droppable data of the element\n * @private\n */\n _findData: function (element) {\n var elms = this._droppables;\n for (var i = 0, len = elms.length; i < len; i++) {\n if (elms[i].element === element) {\n return elms[i];\n }\n }\n },\n /**\n * Finds draggable data about `element`\n *\n * @method _findDraggable\n * @param {DOMElement} element Needle\n * @return {Object} Draggable data queried\n * @private\n */\n _findDraggable: function (element) {\n var elms = this._draggables;\n for (var i = 0, len = elms.length; i < len; i++) {\n if (elms[i].element === element) {\n return elms[i];\n }\n }\n },\n\n /**\n * Invoke every time a drag starts\n * \n * @method updateAll\n * @private\n */\n updateAll: function() {\n InkArray.each(this._droppables, Droppable._update);\n },\n\n /**\n * Updates location and size of droppable element\n * \n * @method update\n * @param {String|DOMElement} element Target element\n * @public\n */\n update: function(element) {\n this._update(this._findData(element));\n },\n\n _update: function(elementData) {\n var data = elementData.data;\n var element = elementData.element;\n data.left = InkElement.offsetLeft(element);\n data.top = InkElement.offsetTop( element);\n data.right = data.left + InkElement.elementWidth( element);\n data.bottom = data.top + InkElement.elementHeight(element);\n },\n\n /**\n * Removes an element from the droppable stack and removes the droppable behavior\n * \n * @method remove\n * @param {String|DOMElement} elOrSelector Droppable element to disable.\n * @return {Boolean} Whether the object was found and deleted\n * @public\n */\n remove: function(el) {\n el = Common.elOrSelector(el);\n var len = this._droppables.length;\n for (var i = 0; i < len; i++) {\n if (this._droppables[i].element === el) {\n this._droppables.splice(i, 1);\n break;\n }\n }\n return len !== this._droppables.length;\n },\n\n /**\n * Executes an action on a droppable\n * \n * @method action\n * @param {Object} coords Coordinates where the action happened\n * @param {String} type Type of action. 'drag' or 'drop'.\n * @param {Object} ev Event object\n * @param {Object} draggable Draggable element\n * @private\n */\n action: function(coords, type, ev, draggable) {\n // check all droppable elements\n InkArray.each(this._droppables, Ink.bind(function(elementData) {\n var data = elementData.data;\n var opt = elementData.options;\n var element = elementData.element;\n\n if (opt.accept && !Selector.matches(opt.accept, [draggable]).length) {\n return;\n }\n\n if (type === 'drag' && !this._findDraggable(draggable)) {\n this._draggables.push({\n element: draggable,\n originalParent: draggable.parentNode\n });\n }\n\n // check if our draggable is over our droppable\n if (coords.x >= data.left && coords.x <= data.right &&\n coords.y >= data.top && coords.y <= data.bottom) {\n // INSIDE\n if (type === 'drag') {\n if (opt.hoverClass) {\n InkArray.each(opt.hoverClass,\n hAddClassName(element));\n }\n if (opt.onHover) {\n opt.onHover(draggable, element);\n }\n } else if (type === 'drop') {\n if (opt.hoverClass) {\n InkArray.each(opt.hoverClass,\n hRemoveClassName(element));\n }\n if (opt.onDrop) {\n opt.onDrop(draggable, element, ev);\n }\n }\n } else {\n // OUTSIDE\n\n if (type === 'drag' && opt.hoverClass) {\n InkArray.each(opt.hoverClass, hRemoveClassName(element));\n } else if (type === 'drop') {\n if(opt.onDropOut){\n opt.onDropOut(draggable, element, ev);\n }\n }\n }\n }, this));\n }\n };\n\n return Droppable;\n});\n","/**\n * Form Validation\n * @module Ink.UI.FormValidator_1\n * @version 1\n **/\n\nInk.createModule('Ink.UI.FormValidator', '1', ['Ink.Dom.Element_1', 'Ink.Dom.Css_1','Ink.Util.Validator_1','Ink.Dom.Selector_1'], function( InkElement, Css, InkValidator , Selector) {\n 'use strict';\n\n function elementsWithSameName(elm) {\n if (!elm.name) { return []; }\n if (!elm.form) {\n return Selector.select('name=\"' + elm.name + '\"');\n }\n var ret = elm.form[elm.name];\n if(typeof(ret.length) === 'undefined') {\n ret = [ret];\n }\n return ret;\n }\n /**\n * @namespace Ink.UI.FormValidator\n * @version 1\n */\n var FormValidator = {\n\n /**\n * Specifies the version of the component\n *\n * @property version\n * @type {String}\n * @readOnly\n * @public\n */\n version: '1',\n\n /**\n * Available flags to use in the validation process.\n * The keys are the 'rules', and their values are objects with the key 'msg', determining\n * what is the error message.\n *\n * @property _flagMap\n * @type {Object}\n * @readOnly\n * @private\n */\n _flagMap: {\n //'ink-fv-required': {msg: 'Campo obrigat&oacute;rio'},\n 'ink-fv-required': {msg: 'Required field'},\n //'ink-fv-email': {msg: 'E-mail inv&aacute;lido'},\n 'ink-fv-email': {msg: 'Invalid e-mail address'},\n //'ink-fv-url': {msg: 'URL inv&aacute;lido'},\n 'ink-fv-url': {msg: 'Invalid URL'},\n //'ink-fv-number': {msg: 'N&uacute;mero inv&aacute;lido'},\n 'ink-fv-number': {msg: 'Invalid number'},\n //'ink-fv-phone_pt': {msg: 'N&uacute;mero de telefone inv&aacute;lido'},\n 'ink-fv-phone_pt': {msg: 'Invalid phone number'},\n //'ink-fv-phone_cv': {msg: 'N&uacute;mero de telefone inv&aacute;lido'},\n 'ink-fv-phone_cv': {msg: 'Invalid phone number'},\n //'ink-fv-phone_mz': {msg: 'N&uacute;mero de telefone inv&aacute;lido'},\n 'ink-fv-phone_mz': {msg: 'Invalid phone number'},\n //'ink-fv-phone_ao': {msg: 'N&uacute;mero de telefone inv&aacute;lido'},\n 'ink-fv-phone_ao': {msg: 'Invalid phone number'},\n //'ink-fv-date': {msg: 'Data inv&aacute;lida'},\n 'ink-fv-date': {msg: 'Invalid date'},\n //'ink-fv-confirm': {msg: 'Confirma&ccedil;&atilde;o inv&aacute;lida'},\n 'ink-fv-confirm': {msg: 'Confirmation does not match'},\n 'ink-fv-custom': {msg: ''}\n },\n\n /**\n * This property holds all form elements for later validation\n *\n * @property elements\n * @type {Object}\n * @public\n */\n elements: {},\n\n /**\n * This property holds the objects needed to cross-check for the 'confirm' rule\n *\n * @property confirmElms\n * @type {Object}\n * @public\n */\n confirmElms: {},\n\n /**\n * This property holds the previous elements in the confirmElms property, but with a\n * true/false specifying if it has the class ink-fv-confirm.\n *\n * @property hasConfirm\n * @type {Object}\n */\n hasConfirm: {},\n\n /**\n * Defined class name to use in error messages label\n *\n * @property _errorClassName\n * @type {String}\n * @readOnly\n * @private\n */\n _errorClassName: 'tip error',\n\n /**\n * @property _errorValidationClassName\n * @type {String}\n * @readOnly\n * @private\n */\n _errorValidationClassName: 'validaton',\n\n /**\n * @property _errorTypeWarningClassName\n * @type {String}\n * @readOnly\n * @private\n */\n _errorTypeWarningClassName: 'warning',\n\n /**\n * @property _errorTypeErrorClassName\n * @type {String}\n * @readOnly\n * @private\n */\n _errorTypeErrorClassName: 'error',\n\n /**\n * Checks if a form is valid\n * \n * @method validate\n * @param {DOMElement|String} elm DOM form element or form id\n * @param {Object} options Configuration options\n * @param {Function} [options.onSuccess] Callback to run when form is valid\n * @param {Function} [options.onError] Callback to run when form is not valid\n * @param {Array} [options.customFlag] Custom flags to use to validate form fields\n * @public\n * @return {Boolean} Whether the form is deemed valid or not.\n *\n * @sample Ink_UI_FormValidator_1.html\n */\n validate: function(elm, options) {\n this._free();\n\n options = Ink.extendObj({\n onSuccess: false,\n onError: false,\n customFlag: false,\n confirmGroup: []\n }, options || {});\n\n if(typeof(elm) === 'string') {\n elm = document.getElementById(elm);\n }\n if(elm === null){\n return false;\n }\n this.element = elm;\n\n if(typeof(this.element.id) === 'undefined' || this.element.id === null || this.element.id === '') {\n // generate a random ID\n // TODO ugly and potentially problematic, and you know Murphy's law.\n this.element.id = 'ink-fv_randomid_'+(Math.round(Math.random() * 99999));\n }\n\n this.custom = options.customFlag;\n\n this.confirmGroup = options.confirmGroup;\n\n var fail = this._validateElements();\n\n if(fail.length > 0) {\n if(options.onError) {\n options.onError(fail);\n } else {\n this._showError(elm, fail);\n }\n return false;\n } else {\n if(!options.onError) {\n this._clearError(elm);\n }\n this._clearCache();\n if(options.onSuccess) {\n options.onSuccess();\n }\n return true;\n }\n\n },\n\n /**\n * Resets previously generated validation errors\n * \n * @method reset\n * @public\n */\n reset: function()\n {\n this._clearError();\n this._clearCache();\n },\n\n /**\n * Cleans the object\n * \n * @method _free\n * @private\n */\n _free: function()\n {\n this.element = null;\n //this.elements = [];\n this.custom = false;\n this.confirmGroup = false;\n },\n\n /**\n * Cleans the properties responsible for caching\n * \n * @method _clearCache\n * @private\n */\n _clearCache: function()\n {\n this.element = null;\n this.elements = [];\n this.custom = false;\n this.confirmGroup = false;\n },\n\n /**\n * Gets the form elements and stores them in the caching properties\n * \n * @method _getElements\n * @private\n */\n _getElements: function()\n {\n //this.elements = [];\n // if(typeof(this.elements[this.element.id]) !== 'undefined') {\n // return;\n // }\n\n var elements = this.elements[this.element.id] = [];\n this.confirmElms[this.element.id] = [];\n //console.log(this.element);\n //console.log(this.element.elements);\n var formElms = Selector.select(':input', this.element);\n var curElm = false;\n for(var i=0, totalElm = formElms.length; i < totalElm; i++) {\n curElm = formElms[i];\n var type = (curElm.getAttribute('type') + '').toLowerCase();\n\n if (type === 'radio' || type === 'checkbox') {\n if(elements.length === 0 ||\n (\n curElm.getAttribute('type') !== elements[elements.length - 1].getAttribute('type') &&\n curElm.getAttribute('name') !== elements[elements.length - 1].getAttribute('name')\n )) {\n for(var flag in this._flagMap) {\n if(Css.hasClassName(curElm, flag)) {\n elements.push(curElm);\n break;\n }\n }\n }\n } else {\n for(var flag2 in this._flagMap) {\n if(Css.hasClassName(curElm, flag2) && flag2 !== 'ink-fv-confirm') {\n /*if(flag2 == 'ink-fv-confirm') {\n this.confirmElms[this.element.id].push(curElm);\n this.hasConfirm[this.element.id] = true;\n }*/\n elements.push(curElm);\n break;\n }\n }\n\n if(Css.hasClassName(curElm, 'ink-fv-confirm')) {\n this.confirmElms[this.element.id].push(curElm);\n this.hasConfirm[this.element.id] = true;\n }\n\n }\n }\n },\n\n /**\n * Runs the validation for each element\n * \n * @method _validateElements\n * @private\n */\n _validateElements: function() {\n var oGroups;\n this._getElements();\n if(this.hasConfirm[this.element.id] === true) {\n oGroups = this._makeConfirmGroups();\n }\n\n var errors = [];\n\n var curElm = false;\n var customErrors = false;\n var inArray;\n for(var i=0, totalElm = this.elements[this.element.id].length; i < totalElm; i++) {\n inArray = false;\n curElm = this.elements[this.element.id][i];\n\n if(!curElm.disabled) {\n for(var flag in this._flagMap) {\n if(Css.hasClassName(curElm, flag)) {\n if(flag !== 'ink-fv-custom' && flag !== 'ink-fv-confirm') {\n if(!this._isValid(curElm, flag)) {\n if(!inArray) {\n errors.push({elm: curElm, errors:[flag]});\n inArray = true;\n } else {\n errors[(errors.length - 1)].errors.push(flag);\n }\n }\n } else if(flag !== 'ink-fv-confirm'){\n customErrors = this._isCustomValid(curElm);\n if(customErrors.length > 0) {\n errors.push({elm: curElm, errors:[flag], custom: customErrors});\n }\n } else if(flag === 'ink-fv-confirm'){\n continue;\n }\n }\n }\n }\n }\n errors = this._validateConfirmGroups(oGroups, errors);\n //console.log(InkDumper.returnDump(errors));\n return errors;\n },\n\n /**\n * Runs the 'confirm' validation for each group of elements\n * \n * @method _validateConfirmGroups\n * @param {Array} oGroups Array/Object that contains the group of confirm objects\n * @param {Array} errors Array that will store the errors\n * @private\n * @return {Array} Array of errors that was passed as 2nd parameter (either changed, or not, depending if errors were found).\n */\n _validateConfirmGroups: function(oGroups, errors) {\n //console.log(oGroups);\n var curGroup = false;\n for(var i in oGroups) if (oGroups.hasOwnProperty(i)) {\n curGroup = oGroups[i];\n if(curGroup.length === 2) {\n if(curGroup[0].value !== curGroup[1].value) {\n errors.push({elm:curGroup[1], errors:['ink-fv-confirm']});\n }\n }\n }\n return errors;\n },\n\n /**\n * Creates the groups of 'confirm' objects\n * \n * @method _makeConfirmGroups\n * @private\n * @return {Array|Boolean} Returns the array of confirm elements or false on error.\n */\n _makeConfirmGroups: function()\n {\n var oGroups;\n if(this.confirmGroup && this.confirmGroup.length > 0) {\n oGroups = {};\n var curElm = false;\n var curGroup = false;\n //this.confirmElms[this.element.id];\n for(var i=0, total=this.confirmElms[this.element.id].length; i < total; i++) {\n curElm = this.confirmElms[this.element.id][i];\n for(var j=0, totalG=this.confirmGroup.length; j < totalG; j++) {\n curGroup = this.confirmGroup[j];\n if(Css.hasClassName(curElm, curGroup)) {\n if(typeof(oGroups[curGroup]) === 'undefined') {\n oGroups[curGroup] = [curElm];\n } else {\n oGroups[curGroup].push(curElm);\n }\n }\n }\n }\n return oGroups;\n } else {\n if(this.confirmElms[this.element.id].length === 2) {\n oGroups = {\n \"ink-fv-confirm\": [\n this.confirmElms[this.element.id][0],\n this.confirmElms[this.element.id][1]\n ]\n };\n }\n return oGroups;\n }\n return false;\n },\n\n /**\n * Validates an element with a custom validation\n * \n * @method _isCustomValid\n * @param {DOMElemenmt} elm Element to be validated\n * @private\n * @return {Array} Array of errors. If no errors are found, results in an empty array.\n */\n _isCustomValid: function(elm)\n {\n var customErrors = [];\n var curFlag = false;\n for(var i=0, tCustom = this.custom.length; i < tCustom; i++) {\n curFlag = this.custom[i];\n if(Css.hasClassName(elm, curFlag.flag)) {\n if(!curFlag.callback(elm, curFlag.msg)) {\n customErrors.push({flag: curFlag.flag, msg: curFlag.msg});\n }\n }\n }\n return customErrors;\n },\n\n /**\n * Runs the normal validation functions for a specific element\n * \n * @method _isValid\n * @param {DOMElement} elm DOMElement that will be validated\n * @param {String} fieldType Rule to be validated. This must be one of the keys present in the _flagMap property.\n * @private\n * @return {Boolean} The result of the validation.\n */\n _isValid: function(elm, fieldType) {\n var nodeName = elm.nodeName.toLowerCase();\n var inputType = (elm.getAttribute('type') || '').toLowerCase();\n var value = this._trim(elm.value);\n\n // When we're analyzing emails, telephones, etc, and the field is\n // empty, we check if it is required. If not required, it's valid.\n if (fieldType !== 'ink-fv-required' &&\n inputType !== 'checkbox' && inputType !== 'radio' &&\n value === '') {\n return !Css.hasClassName(elm, 'ink-fv-required');\n }\n\n switch(fieldType) {\n case 'ink-fv-required':\n if(nodeName === 'select') {\n if(elm.selectedIndex > 0) {\n return true;\n } else {\n return false;\n }\n }\n if(inputType !== 'checkbox' && inputType !== 'radio' &&\n value !== '') {\n return true; // A input type=text,email,etc.\n } else if(inputType === 'checkbox' || inputType === 'radio') {\n var aFormRadios = elementsWithSameName(elm);\n var isChecked = false;\n // check if any input of the radio is checked\n for(var i=0, totalRadio = aFormRadios.length; i < totalRadio; i++) {\n if(aFormRadios[i].checked === true) {\n isChecked = true;\n break;\n }\n }\n return isChecked;\n }\n return false;\n\n case 'ink-fv-email':\n return InkValidator.mail(elm.value);\n\n case 'ink-fv-url':\n return InkValidator.url(elm.value);\n\n case 'ink-fv-number':\n return !isNaN(Number(elm.value)) && isFinite(Number(elm.value));\n\n case 'ink-fv-phone_pt':\n return InkValidator.isPTPhone(elm.value);\n\n case 'ink-fv-phone_cv':\n return InkValidator.isCVPhone(elm.value);\n\n case 'ink-fv-phone_ao':\n return InkValidator.isAOPhone(elm.value);\n\n case 'ink-fv-phone_mz':\n return InkValidator.isMZPhone(elm.value);\n\n case 'ink-fv-date':\n var Element = Ink.getModule('Ink.Dom.Element',1);\n var dataset = Element.data( elm );\n var validFormat = 'yyyy-mm-dd';\n\n if( Css.hasClassName(elm, 'ink-datepicker') && ('format' in dataset) ){\n validFormat = dataset.format;\n } else if( ('validFormat' in dataset) ){\n validFormat = dataset.validFormat;\n }\n\n if( !(validFormat in InkValidator._dateParsers ) ){\n var validValues = [];\n for( var val in InkValidator._dateParsers ){\n if (InkValidator._dateParsers.hasOwnProperty(val)) {\n validValues.push(val);\n }\n }\n throw new Error(\n 'The attribute data-valid-format must be one of ' +\n 'the following values: ' + validValues.join(', '));\n }\n \n return InkValidator.isDate( validFormat, elm.value );\n case 'ink-fv-custom':\n break;\n }\n\n return false;\n },\n\n /**\n * Makes the necessary changes to the markup to show the errors of a given element\n * \n * @method _showError\n * @param {DOMElement} formElm The form element to be changed to show the errors\n * @param {Array} aFail An array with the errors found.\n * @private\n */\n _showError: function(formElm, aFail) {\n this._clearError(formElm);\n\n //ink-warning-field\n\n //console.log(aFail);\n var curElm = false;\n for(var i=0, tFail = aFail.length; i < tFail; i++) {\n curElm = aFail[i].elm;\n if (curElm) {\n this._showAnErrorOnElement(curElm, aFail[i]);\n }\n }\n },\n\n _showAnErrorOnElement: function (curElm, error) {\n /* jshint noempty:false */\n\n var controlGroupElm = InkElement.findUpwardsByClass(\n curElm, 'control-group');\n var controlElm = InkElement.findUpwardsByClass(\n curElm, 'control');\n\n var errorClasses = [\n this._errorClassName,\n this._errorTypeClassName].join(' ');\n\n var errorMsg = InkElement.create('p', {\n className: errorClasses\n });\n\n if(error.errors[0] !== 'ink-fv-custom') {\n errorMsg.innerHTML = this._flagMap[error.errors[0]].msg;\n } else {\n errorMsg.innerHTML = error.custom[0].msg;\n }\n\n var target = (controlElm || controlGroupElm);\n if (target) {\n target.appendChild(errorMsg);\n } else {\n InkElement.insertAfter(errorMsg, curElm);\n }\n\n if (controlElm) {\n if(error.errors[0] === 'ink-fv-required') {\n Css.addClassName(controlGroupElm, 'validation error');\n } else {\n Css.addClassName(controlGroupElm, 'validation warning');\n }\n }\n },\n\n /**\n * Clears the error of a given element. Normally executed before any validation, for all elements, as a reset.\n * \n * @method _clearErrors\n * @param {DOMElement} formElm Form element to be cleared.\n * @private\n */\n _clearError: function(formElm) {\n //return;\n var aErrorLabel = formElm.getElementsByTagName('p');\n\n var curElm;\n var control;\n\n for(var i = (aErrorLabel.length - 1); i >= 0; i--) {\n curElm = aErrorLabel[i];\n if(Css.hasClassName(curElm, this._errorClassName)) {\n control = InkElement.findUpwardsBySelector(curElm, '.control-group');\n if (control) {\n Css.removeClassName(control, ['validation', 'error', 'warning']);\n }\n\n if(Css.hasClassName(curElm, this._errorClassName, true /*both*/)) {\n InkElement.remove(curElm);\n }\n }\n }\n\n var aErrorLabel2 = formElm.getElementsByTagName('ul');\n for(i = (aErrorLabel2.length - 1); i >= 0; i--) {\n curElm = aErrorLabel2[i];\n if(Css.hasClassName(curElm, 'control-group')) {\n Css.removeClassName(curElm, 'validation error');\n }\n }\n },\n\n /**\n * Removes unnecessary spaces to the left or right of a string\n * \n * @method _trim\n * @param {String} stri String to be trimmed\n * @private\n * @return {String|undefined} String trimmed.\n */\n _trim: function(str)\n {\n if(typeof(str) === 'string')\n {\n return str.replace(/^\\s+|\\s+$|\\n+$/g, '');\n }\n }\n };\n\n return FormValidator;\n\n});","/**\n * Form Validation\n * @module Ink.UI.FormValidator_2\n * @version 2\n */\n\nInk.createModule('Ink.UI.FormValidator', '2', [ 'Ink.UI.Common_1','Ink.Dom.Element_1','Ink.Dom.Event_1','Ink.Dom.Selector_1','Ink.Dom.Css_1','Ink.Util.Array_1','Ink.Util.I18n_1','Ink.Util.Validator_1'], function( Common, Element, Event, Selector, Css, InkArray, I18n, InkValidator ) {\n 'use strict';\n\n /**\n * Validation Functions to be used\n *\n * Some functions are a port from PHP, others are the 'best' solutions available\n *\n * @class FormValidator.validationFunctions\n * @static\n */\n var validationFunctions = {\n\n /**\n * Checks if a value is defined and not empty\n * @method required\n * @return {Boolean} True case is defined, false if it's empty or not defined.\n */\n 'required': function( value ){\n return ( (typeof value !== 'undefined') && ( !(/^\\s*$/).test(value) ) );\n },\n\n /**\n * Checks if a value has a minimum length\n *\n * @method min_length\n * @param {String|Number} minSize Minimum number of characters.\n * @return {Boolean} True if the length of value is equal or bigger than the minimum chars defined. False if not.\n */\n 'min_length': function( value, minSize ){\n return ( (typeof value === 'string') && ( value.length >= parseInt(minSize,10) ) );\n },\n\n /**\n * Checks if a value has a maximum length\n *\n * @method max_length\n * @param {String|Number} maxSize Maximum number of characters.\n * @return {Boolean} True if the length of value is equal or smaller than the maximum chars defined. False if not.\n */\n 'max_length': function( value, maxSize ){\n return ( (typeof value === 'string') && ( value.length <= parseInt(maxSize,10) ) );\n },\n\n /**\n * Checks if a value has an exact length\n *\n * @method exact_length\n * @param {String|Number} exactSize Exact number of characters.\n * @return {Boolean} True if the length of value is equal to the size defined. False if not.\n */\n 'exact_length': function( value, exactSize ){\n return ( (typeof value === 'string') && ( value.length === parseInt(exactSize,10) ) );\n },\n\n /**\n * Checks if a value is a valid email address\n *\n * @method email\n * @return {Boolean} True if the value is a valid email address. False if not.\n */\n 'email': function( value ){\n return ( ( typeof value === 'string' ) && InkValidator.mail( value ) );\n },\n\n /**\n * Checks if a value has a valid URL\n *\n * @method url\n * @param {Boolean} fullCheck Flag to validate a full url (with the protocol).\n * @return {Boolean} True if the URL is considered valid. False if not.\n */\n 'url': function( value, fullCheck ){\n fullCheck = fullCheck || false;\n return ( (typeof value === 'string') && InkValidator.url( value, fullCheck ) );\n },\n\n /**\n * Checks if a value is a valid IP. Supports ipv4 and ipv6\n *\n * @method ip\n * @param {String} ipType Type of IP to be validated. The values are: ipv4, ipv6. By default is ipv4.\n * @return {Boolean} True if the value is a valid IP address. False if not.\n */\n 'ip': function( value, ipType ){\n if( typeof value !== 'string' ){\n return false;\n }\n\n return InkValidator.isIP(value, ipType);\n },\n\n /**\n * Checks if a value is a valid phone number.\n * Supports several countries, based in the Ink.Util.Validator class.\n *\n * @method phone\n * @param {String} phoneType Country's initials to specify the type of phone number to be validated. Ex: 'AO'.\n * @return {Boolean} True if it's a valid phone number. False if not.\n */\n 'phone': function( value, phoneType ){\n if( typeof value !== 'string' ){\n return false;\n }\n\n var countryCode = phoneType ? phoneType.toUpperCase() : '';\n\n return InkValidator['is' + countryCode + 'Phone'](value);\n },\n\n /**\n * Checks if a value is a valid credit card.\n *\n * @method credit_card\n * @param {String} cardType Type of credit card to be validated. The card types available are in the Ink.Util.Validator class.\n * @return {Boolean} True if the value is a valid credit card number. False if not.\n */\n 'credit_card': function( value, cardType ){\n if( typeof value !== 'string' ){\n return false;\n }\n\n return InkValidator.isCreditCard( value, cardType || 'default' );\n },\n\n /**\n * Checks if a value is a valid date.\n *\n * @method date\n * @param {String} format Specific format of the date.\n * @return {Boolean} True if the value is a valid date. False if not.\n */\n 'date': function( value, format ){\n return ( (typeof value === 'string' ) && InkValidator.isDate(format, value) );\n },\n\n /**\n * Checks if a value only contains alphabetical values.\n *\n * @method alpha\n * @param {Boolean} supportSpaces Allow whitespace\n * @return {Boolean} True if the value is alphabetical-only. False if not.\n */\n 'alpha': function( value, supportSpaces ){\n return InkValidator.ascii(value, {singleLineWhitespace: supportSpaces});\n },\n\n /*\n * Checks if a value contains only printable BMP unicode characters\n * Optionally allow punctuation and whitespace\n *\n * @method text\n * @return {Boolean} Whether the value only contains printable text characters\n **/\n 'text': function (value, whitespace, punctuation) {\n return InkValidator.unicode(value, {\n singleLineWhitespace: whitespace,\n unicodePunctuation: punctuation});\n },\n\n /*\n * Checks if a value contains only printable latin-1 text characters.\n * Optionally allow punctuation and whitespace.\n *\n * @method text\n * @return {Boolean} Whether the value only contains printable text characters\n **/\n 'latin': function (value, punctuation, whitespace) {\n if ( typeof value !== 'string') { return false; }\n return InkValidator.latin1(value, {latin1Punctuation: punctuation, singleLineWhitespace: whitespace});\n },\n\n /**\n * Checks if a value contains only alphabetical or numerical characters.\n *\n * @method alpha_numeric\n * @return {Boolean} True if the value is a valid alphanumerical. False if not.\n */\n 'alpha_numeric': function( value ){\n return InkValidator.ascii(value, {numbers: true});\n },\n\n /**\n * Checks if a value contains only alphabetical, dash or underscore characteres.\n *\n * @method alpha_dash\n * @return {Boolean} True if the value is a valid. False if not.\n */\n 'alpha_dash': function( value ){\n return InkValidator.ascii(value, {dash: true, underscore: true});\n },\n\n /**\n * Checks if a value is a single digit.\n *\n * @method digit\n * @return {Boolean} True if the value is a valid digit. False if not.\n */\n 'digit': function( value ){\n return ((typeof value === 'string') && /^[0-9]{1}$/.test(value));\n },\n\n /**\n * Checks if a value is a valid integer.\n *\n * @method integer\n * @param {String} positive Flag that specifies if the integer is must be positive (unsigned).\n * @return {Boolean} True if the value is a valid integer. False if not.\n */\n 'integer': function( value, positive ){\n return InkValidator.number(value, {\n negative: !positive,\n decimalPlaces: 0\n });\n },\n\n /**\n * Checks if a value is a valid decimal number.\n *\n * @method decimal\n * @param {String} decimalSeparator Character that splits the integer part from the decimal one. By default is '.'.\n * @param {String} [decimalPlaces] Maximum number of digits that the decimal part must have.\n * @param {String} [leftDigits] Maximum number of digits that the integer part must have, when provided.\n * @return {Boolean} True if the value is a valid decimal number. False if not.\n */\n 'decimal': function( value, decimalSeparator, decimalPlaces, leftDigits ){\n return InkValidator.number(value, {\n decimalSep: decimalSeparator || '.',\n decimalPlaces: +decimalPlaces || null,\n maxDigits: +leftDigits\n });\n },\n\n /**\n * Checks if a value is a numeric value.\n *\n * @method numeric\n * @param {String} decimalSeparator Checks if it's a valid decimal. Otherwise checks if it's a valid integer.\n * @param {String} [decimalPlaces] Maximum number of digits the decimal part must have.\n * @param {String} [leftDigits] Maximum number of digits the integer part must have, when provided.\n * @return {Boolean} True if the value is numeric. False if not.\n */\n 'numeric': function( value, decimalSeparator, decimalPlaces, leftDigits ){\n decimalSeparator = decimalSeparator || '.';\n if( value.indexOf(decimalSeparator) !== -1 ){\n return validationFunctions.decimal( value, decimalSeparator, decimalPlaces, leftDigits );\n } else {\n return validationFunctions.integer( value );\n }\n },\n\n /**\n * Checks if a value is in a specific range of values.\n * The parameters after the first one are used to specify the range, and are similar in function to python's range() function.\n *\n * @method range\n * @param {String} minValue Left limit of the range.\n * @param {String} maxValue Right limit of the range.\n * @param {String} [multipleOf] In case you want numbers that are only multiples of another number.\n * @return {Boolean} True if the value is within the range. False if not.\n */\n 'range': function( value, minValue, maxValue, multipleOf ){\n value = +value;\n minValue = +minValue;\n maxValue = +maxValue;\n\n if (isNaN(value) || isNaN(minValue) || isNaN(maxValue)) {\n return false;\n }\n\n if( value < minValue || value > maxValue ){\n return false;\n }\n\n if (multipleOf) {\n return (value - minValue) % multipleOf === 0;\n } else {\n return true;\n }\n },\n\n /**\n * Checks if a value is a valid color.\n *\n * @method color\n * @return {Boolean} True if the value is a valid color. False if not.\n */\n 'color': function( value ){\n return InkValidator.isColor(value);\n },\n\n /**\n * Checks if a value matches the value of a different field.\n *\n * @method matches\n * @param {String} fieldToCompare Name or ID of the field to compare.\n * @return {Boolean} True if the values match. False if not.\n */\n 'matches': function( value, fieldToCompare ){\n return ( value === this.getFormElements()[fieldToCompare][0].getValue() );\n }\n\n };\n\n /**\n * Error messages for the validation functions above\n * @private\n * @static\n */\n var validationMessages = new I18n({\n en_US: {\n 'formvalidator.required' : 'The {field} filling is mandatory',\n 'formvalidator.min_length': 'The {field} must have a minimum size of {param1} characters',\n 'formvalidator.max_length': 'The {field} must have a maximum size of {param1} characters',\n 'formvalidator.exact_length': 'The {field} must have an exact size of {param1} characters',\n 'formvalidator.email': 'The {field} must have a valid e-mail address',\n 'formvalidator.url': 'The {field} must have a valid URL',\n 'formvalidator.ip': 'The {field} does not contain a valid {param1} IP address',\n 'formvalidator.phone': 'The {field} does not contain a valid {param1} phone number',\n 'formvalidator.credit_card': 'The {field} does not contain a valid {param1} credit card',\n 'formvalidator.date': 'The {field} should contain a date in the {param1} format',\n 'formvalidator.alpha': 'The {field} should only contain letters',\n 'formvalidator.text': 'The {field} should only contain alphabetic characters',\n 'formvalidator.latin': 'The {field} should only contain alphabetic characters',\n 'formvalidator.alpha_numeric': 'The {field} should only contain letters or numbers',\n 'formvalidator.alpha_dash': 'The {field} should only contain letters or dashes',\n 'formvalidator.digit': 'The {field} should only contain a digit',\n 'formvalidator.integer': 'The {field} should only contain an integer',\n 'formvalidator.decimal': 'The {field} should contain a valid decimal number',\n 'formvalidator.numeric': 'The {field} should contain a number',\n 'formvalidator.range': 'The {field} should contain a number between {param1} and {param2}',\n 'formvalidator.color': 'The {field} should contain a valid color',\n 'formvalidator.matches': 'The {field} should match the field {param1}',\n 'formvalidator.validation_function_not_found': 'The rule {rule} has not been defined'\n },\n pt_PT: {\n 'formvalidator.required' : 'Preencher {field} é obrigatório',\n 'formvalidator.min_length': '{field} deve ter no mínimo {param1} caracteres',\n 'formvalidator.max_length': '{field} tem um tamanho máximo de {param1} caracteres',\n 'formvalidator.exact_length': '{field} devia ter exactamente {param1} caracteres',\n 'formvalidator.email': '{field} deve ser um e-mail válido',\n 'formvalidator.url': 'O {field} deve ser um URL válido',\n 'formvalidator.ip': '{field} não tem um endereço IP {param1} válido',\n 'formvalidator.phone': '{field} deve ser preenchido com um número de telefone {param1} válido.',\n 'formvalidator.credit_card': '{field} não tem um cartão de crédito {param1} válido',\n 'formvalidator.date': '{field} deve conter uma data no formato {param1}',\n 'formvalidator.alpha': 'O campo {field} deve conter apenas caracteres alfabéticos',\n 'formvalidator.text': 'O campo {field} deve conter apenas caracteres alfabéticos',\n 'formvalidator.latin': 'O campo {field} deve conter apenas caracteres alfabéticos',\n 'formvalidator.alpha_numeric': '{field} deve conter apenas letras e números',\n 'formvalidator.alpha_dash': '{field} deve conter apenas letras e traços',\n 'formvalidator.digit': '{field} destina-se a ser preenchido com apenas um dígito',\n 'formvalidator.integer': '{field} deve conter um número inteiro',\n 'formvalidator.decimal': '{field} deve conter um número válido',\n 'formvalidator.numeric': '{field} deve conter um número válido',\n 'formvalidator.range': '{field} deve conter um número entre {param1} e {param2}',\n 'formvalidator.color': '{field} deve conter uma cor válida',\n 'formvalidator.matches': '{field} deve corresponder ao campo {param1}',\n 'formvalidator.validation_function_not_found': '[A regra {rule} não foi definida]'\n }\n }, 'en_US');\n\n /**\n * A FormElement represents a single form element to be validated.\n *\n * It is constructed with a DOM form element, and options.\n *\n * This class contains methods to parse rules and apply them to its element,\n * and also formats the error messages to be displayed in case of an error.\n *\n * You don't normally call \"new FormElement\" yourself. This is done\n * internally.\n *\n * @class FormValidator.FormElement\n * @constructor\n * @param {DOMElement} element DOM Element\n * @param {Object} options Object with configuration options\n * @param {String} [options.label] Label for this element. It is used in the error message. If not specified, the text in the `label` tag in the control-group is used.\n * @param {String} [options.rules] Rules string to be parsed.\n * @param {FormValidator} options.form FormValidator instance.\n */\n function FormElement(){\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n FormElement._name = 'FormElement_1';\n\n FormElement._optionDefinition = {\n label: ['String', null],\n rules: ['String', null], // The rules to apply\n form: ['Object']\n };\n\n /**\n * FormElement's prototype\n */\n FormElement.prototype = {\n _init: function () {\n this._errors = {};\n this._rules = {};\n this._value = null;\n\n if (this._options.label === null) {\n this._options.label = this._getLabel();\n }\n },\n\n /**\n * Function to get the label that identifies the field.\n * If it can't find one, it will use the name or the id\n * (depending on what is defined)\n *\n * @method _getLabel\n * @return {String} Label to be used in the error messages\n * @private\n */\n _getLabel: function(){\n var label = Element.findUpwardsBySelector(this._element,'.control-group label');\n\n if( label ){\n return Element.textContent(label);\n } else {\n return this._element.name || this._element.id || '';\n }\n },\n\n /**\n * Function to parse a rules' string.\n * Ex: required|number|max_length[30]\n *\n * @method _parseRules\n * @param {String} rules String with the rules\n * @private\n */\n _parseRules: function( rules ){\n this._rules = {};\n rules = rules.split(\"|\");\n var i, rulesLength = rules.length, rule, params, paramStartPos ;\n if( rulesLength > 0 ){\n for( i = 0; i < rulesLength; i++ ){\n rule = rules[i];\n if( !rule ){\n continue;\n }\n\n if( ( paramStartPos = rule.indexOf('[') ) !== -1 ){\n params = rule.substr( paramStartPos+1 );\n params = params.split(']');\n params = params[0];\n params = params.split(',');\n for (var p = 0, len = params.length; p < len; p++) {\n params[p] =\n params[p] === 'true' ? true :\n params[p] === 'false' ? false :\n params[p];\n }\n params.splice(0,0,this.getValue());\n\n rule = rule.substr(0,paramStartPos);\n\n this._rules[rule] = params;\n } else {\n this._rules[rule] = [this.getValue()];\n }\n }\n }\n },\n\n /**\n * Function to add an error to the FormElement's 'errors' object.\n * It basically receives the rule where the error occurred, the parameters passed to it (if any)\n * and the error message.\n * Then it replaces some tokens in the message for a more 'custom' reading\n *\n * @method _addError\n * @param {String|null} rule Rule that failed, or null if no rule was found.\n * @private\n * @static\n */\n _addError: function(rule){\n var params = this._rules[rule] || [];\n\n var paramObj = {\n field: this._options.label,\n value: this.getValue()\n };\n\n for( var i = 1; i < params.length; i++ ){\n paramObj['param' + i] = params[i];\n }\n\n var i18nKey = 'formvalidator.' + rule;\n\n this._errors[rule] = validationMessages.text(i18nKey, paramObj);\n\n if (this._errors[rule] === i18nKey) {\n this._errors[rule] = 'Validation message not found';\n }\n },\n\n /**\n * Gets an element's value\n *\n * @method getValue\n * @return {mixed} The DOM Element's value\n * @public\n */\n getValue: function(){\n // TODO this is already implemented in FormSerialize.\n\n switch(this._element.nodeName.toLowerCase()){\n case 'select':\n return Ink.s('option:selected',this._element).value;\n case 'textarea':\n return this._element.value;\n case 'input':\n if( \"type\" in this._element ){\n if( (this._element.type === 'radio') || (this._element.type === 'checkbox') ){\n if( this._element.checked ){\n return this._element.value;\n }\n } else if( this._element.type !== 'file' ){\n return this._element.value;\n }\n } else {\n return this._element.value;\n }\n return;\n default:\n return this._element.innerHTML;\n }\n },\n\n /**\n * Gets the constructed errors' object.\n *\n * @method getErrors\n * @return {Object} Errors' object\n * @public\n */\n getErrors: function(){\n return this._errors;\n },\n\n /**\n * Gets the DOM element related to the instance.\n *\n * @method getElement\n * @return {Object} DOM Element\n * @public\n */\n getElement: function(){\n return this._element;\n },\n\n /**\n * Gets other elements in the same form.\n *\n * @method getFormElements\n * @return {Object} A mapping of keys to other elements in this form.\n * @public\n */\n getFormElements: function () {\n return this._options.form._formElements;\n },\n\n /**\n * Validates the element based on the rules defined.\n * It parses the rules defined in the _options.rules property.\n *\n * @method validate\n * @return {Boolean} True if every rule was valid. False if one fails.\n * @public\n */\n validate: function(){\n this._errors = {};\n\n if( \"rules\" in this._options || 1){\n this._parseRules( this._options.rules );\n }\n \n if( (\"required\" in this._rules) || (this.getValue() !== '') ){\n for(var rule in this._rules) {\n if (this._rules.hasOwnProperty(rule)) {\n if( (typeof validationFunctions[rule] === 'function') ){\n if( validationFunctions[rule].apply(this, this._rules[rule] ) === false ){\n\n this._addError( rule );\n return false;\n\n }\n\n } else {\n Ink.warn('Rule \"' + rule + '\" not found. Used in element:', this._element);\n this._addError( null );\n return false;\n }\n }\n }\n }\n\n return true;\n\n }\n };\n\n Common.createUIComponent(FormElement);\n\n\n /**\n * @class FormValidator_2\n * @constructor\n * @param {String|DOMElement} selector Either a CSS Selector string, or the form's DOMElement\n * @param {Object} [options] Options object, containing the following options:\n * @param {String} [options.eventTrigger] Event that will trigger the validation. Defaults to 'submit'.\n * @param {Boolean} [options.neverSubmit] Flag to cancel the submit event. Use this to avoid submitting the form.\n * @param {Selector} [options.searchFor] Selector containing the validation data-attributes. Defaults to 'input, select, textarea, .control-group'.\n * @param {Function} [options.beforeValidation] Callback to be executed before validating the form\n * @param {Function} [options.onError] Validation error callback\n * @param {Function} [options.onSuccess] Validation success callback\n *\n * @sample Ink_UI_FormValidator_2.html\n */\n function FormValidator(){\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n FormValidator._name = 'FormValidator_1';\n\n FormValidator._optionDefinition = {\n eventTrigger: ['String', 'submit'],\n neverSubmit: ['Boolean', 'false'],\n searchFor: ['String', 'input, select, textarea, .control-group'],\n beforeValidation: ['Function', undefined],\n onError: ['Function', undefined],\n onSuccess: ['Function', undefined]\n };\n\n /**\n * Sets or modifies validation functions\n *\n * @method setRule\n * @param {String} name Name of the function. E.g. 'required'\n * @param {String} errorMessage Error message to be displayed in case of returning false. E.g. 'Oops, you passed {param1} as parameter1, lorem ipsum dolor...'\n * @param {Function} cb Function to be executed when calling this rule\n * @public\n * @static\n */\n FormValidator.setRule = function( name, errorMessage, cb ){\n validationFunctions[ name ] = cb;\n if (validationMessages.getKey('formvalidator.' + name) !== errorMessage) {\n var langObj = {}; langObj['formvalidator.' + name] = errorMessage;\n var dictObj = {}; dictObj[validationMessages.lang()] = langObj;\n validationMessages.append(dictObj);\n }\n };\n\n /**\n * Gets the i18n object in charge of the error messages\n *\n * @method getI18n\n * @static\n * @return {Ink.Util.I18n} The i18n object the FormValidator is using.\n */\n FormValidator.getI18n = function () {\n return validationMessages;\n };\n\n /**\n * Sets the I18n object for validation error messages\n *\n * @method setI18n\n * @static\n * @param {Ink.Util.I18n} i18n The I18n object.\n */\n FormValidator.setI18n = function (i18n) {\n validationMessages = i18n;\n };\n\n /**\n * Add to the I18n dictionary.\n * See `Ink.Util.I18n.append()` documentation.\n *\n * @method appendI18n\n * @static\n */\n FormValidator.appendI18n = function () {\n validationMessages.append.apply(validationMessages, [].slice.call(arguments));\n };\n\n /**\n * Sets the language of the error messages.\n * pt_PT and en_US are available, but you can add new languages by using append()\n *\n * See the `Ink.Util.I18n.lang()` setter\n *\n * @method setLanguage\n * @static\n * @param language The language to set i18n to.\n */\n FormValidator.setLanguage = function (language) {\n validationMessages.lang(language);\n };\n\n /**\n * Method used to get the existing defined validation functions\n *\n * @method getRules\n * @return {Object} Object with the rules defined\n * @public\n * @static\n */\n FormValidator.getRules = function(){\n return validationFunctions;\n };\n\n FormValidator.prototype = {\n _init: function(){\n /**\n * DOMElement of the form being validated\n *\n * @property _rootElement\n * @type {DOMElement}\n */\n this._rootElement = this._element;\n\n /**\n * Object that will gather the form elements by name\n *\n * @property _formElements\n * @type {Object}\n */\n this._formElements = {};\n\n /**\n * Error message DOMElements\n * \n * @property _errorMessages\n */\n this._errorMessages = [];\n\n /**\n * Array of elements marked with validation errors\n *\n * @property _markedErrorElements\n */\n this._markedErrorElements = [];\n\n // Sets an event listener for a specific event in the form, if defined.\n // By default is the 'submit' event.\n if( typeof this._options.eventTrigger === 'string' ){\n Event.observe(\n this._rootElement,\n this._options.eventTrigger,\n Ink.bindEvent(this.validate,this) );\n }\n\n },\n\n /**\n * Searches for the elements in the form.\n * This method is based in the this._options.searchFor configuration.\n *\n * @method getElements\n * @return {Object} An object with the elements in the form, indexed by name/id\n * @public\n */\n getElements: function(){\n this._formElements = {};\n var formElements = Selector.select( this._options.searchFor, this._rootElement );\n if( formElements.length ){\n var i, element;\n for( i=0; i<formElements.length; i+=1 ){\n element = formElements[i];\n\n var dataAttrs = Element.data( element );\n\n if( !(\"rules\" in dataAttrs) ){\n continue;\n }\n\n var options = {\n form: this\n };\n\n var key;\n if( (\"name\" in element) && element.name ){\n key = element.name;\n } else if( (\"id\" in element) && element.id ){\n key = element.id;\n } else {\n key = 'element_' + Math.floor(Math.random()*100);\n element.id = key;\n }\n\n if( !(key in this._formElements) ){\n this._formElements[key] = [];\n }\n\n this._formElements[key].push( new FormElement( element, options ) );\n }\n }\n\n return this._formElements;\n },\n\n /**\n * Validates every registered FormElement \n * This method looks inside the this._formElements object for validation targets.\n * Also, based on the this._options.beforeValidation, this._options.onError, and this._options.onSuccess, this callbacks are executed when defined.\n *\n * @method validate\n * @param {Event} event Window.event object\n * @return {Boolean} Whether the form is considered valid\n * @public\n */\n validate: function( event ) {\n\n if(this._options.neverSubmit+'' === 'true' && event) {\n Event.stopDefault(event);\n }\n\n if( typeof this._options.beforeValidation === 'function' ){\n this._options.beforeValidation();\n }\n\n InkArray.each( this._markedErrorElements, function (errorElement) {\n Css.removeClassName(errorElement, ['validation', 'error']);\n });\n InkArray.each( this._errorMessages, Element.remove);\n\n this.getElements();\n var errorElements = [];\n\n for( var key in this._formElements ){\n if( this._formElements.hasOwnProperty(key) ){\n for( var counter = 0; counter < this._formElements[key].length; counter+=1 ){\n if( !this._formElements[key][counter].validate() ) {\n errorElements.push(this._formElements[key][counter]);\n }\n }\n }\n }\n \n if( errorElements.length === 0 ){\n if( typeof this._options.onSuccess === 'function' ){\n this._options.onSuccess();\n }\n\n // [3.0.0] remove this, it's a little backwards compat quirk\n if(event && this._options.cancelEventOnSuccess + '' === 'true') {\n Event.stopDefault(event);\n return false;\n }\n\n return true;\n } else {\n\n if(event) {\n Event.stopDefault(event);\n }\n\n if( typeof this._options.onError === 'function' ){\n this._options.onError( errorElements );\n }\n this._errorMessages = [];\n this._markedErrorElements = [];\n\n InkArray.each( errorElements, Ink.bind(function( formElement ){\n var controlGroupElement;\n var controlElement;\n if( Css.hasClassName(formElement.getElement(),'control-group') ){\n controlGroupElement = formElement.getElement();\n controlElement = Ink.s('.control',formElement.getElement());\n } else {\n controlGroupElement = Element.findUpwardsByClass(formElement.getElement(),'control-group');\n controlElement = Element.findUpwardsByClass(formElement.getElement(),'control');\n }\n\n if(controlGroupElement) {\n Css.addClassName( controlGroupElement, ['validation', 'error'] );\n this._markedErrorElements.push(controlGroupElement);\n }\n\n var paragraph = document.createElement('p');\n Css.addClassName(paragraph,'tip');\n if (controlElement || controlGroupElement) {\n (controlElement || controlGroupElement).appendChild(paragraph);\n } else {\n Element.insertAfter(paragraph, formElement.getElement());\n }\n\n var errors = formElement.getErrors();\n var errorArr = [];\n for (var k in errors) {\n if (errors.hasOwnProperty(k)) {\n errorArr.push(errors[k]);\n }\n }\n paragraph.innerHTML = errorArr.join('<br/>');\n this._errorMessages.push(paragraph);\n }, this));\n return false;\n }\n }\n };\n\n Common.createUIComponent(FormValidator);\n\n /**\n * Returns the FormValidator's Object\n */\n return FormValidator;\n\n});\n","/**\n * Responsive image loading\n * @module Ink.UI.ImageQuery_1\n * @version 1\n */\n \nInk.createModule('Ink.UI.ImageQuery', '1', ['Ink.UI.Common_1','Ink.Dom.Event_1','Ink.Dom.Element_1','Ink.Util.Array_1'], function(Common, Event, Element, InkArray ) {\n 'use strict';\n\n /**\n * @class Ink.UI.ImageQuery\n * @constructor\n * @version 1\n *\n * @param {String|DOMElement} selector Selector or element\n * @param {Object} [options] Options object\n * @param {String|Function} [options.src] String or Callback function (that returns a string) with the path to be used to get the images.\n * @param {String|Function} [options.retina] String or Callback function (that returns a string) with the path to be used to get RETINA specific images.\n * @param {Array} [options.queries] Array of queries\n * @param {String} [options.queries.label] Label of the query. Ex. 'small'\n * @param {Number} [options.queries.width] Min-width to use this query\n * @param {Function} [options.onLoad] Date format string\n *\n * @sample Ink_UI_ImageQuery_1.html\n */\n function ImageQuery() {\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n ImageQuery._name = 'ImageQuery_1';\n\n\tImageQuery._optionDefinition = {\n\t\tsrc: ['String'],\n\t\tretina: ['String', undefined],\n\t\tqueries: ['Object'],\n\t\tonLoad: ['Function', null]\n\t};\n\n ImageQuery.prototype = {\n\n /**\n * Init function called by the constructor\n * \n * @method _init\n * @private\n */\n _init: function(){\n // /**\n // * Get elements, create more ImageQueries if selector finds more than one\n // *\n // * [improvement] This is a useful pattern. More UI modules could use it.\n // */\n // this._element = Common.elsOrSelector(selector, 'Ink.UI.ImageQuery', /*required=*/true);\n\n // // In case we have several elements\n // for (var i = 1 /* start from second element*/; i < this._element.length; i++) {\n // new ImageQuery(this._element[i], options);\n // }\n\n // this._element = this._element[0];\n /**\n * Determining the original basename (with the querystring) of the file.\n */\n var pos;\n if( (pos=this._element.src.lastIndexOf('?')) !== -1 ){\n var search = this._element.src.substr(pos);\n this._filename = this._element.src.replace(search,'').split('/').pop()+search;\n } else {\n this._filename = this._element.src.split('/').pop();\n }\n\n if (!this._options.queries) { this._options.queries = []; }\n\n // Sort queries by width, in descendant order.\n this._options.queries = InkArray.sortMulti(this._options.queries, 'width').reverse();\n\n if( typeof this._options.onLoad === 'function' ){\n Event.observe(this._element, 'onload', Ink.bindEvent(this._onLoad, this));\n }\n\n // Imediate call to apply the right images based on the current viewport\n this._onResize();\n\n Event.observe(window, 'resize', Event.throttle(Ink.bindMethod(this, '_onResize'), 400));\n },\n\n /**\n * Handles the resize event (as specified in the _init function)\n *\n * @method _onResize\n * @private\n */\n _onResize: function(){\n if( !this._options.queries.length ){\n return;\n }\n\n var current = this._findCurrentQuery();\n\n /**\n * Choosing the right src. The rule is:\n *\n * \"If there is specifically defined in the query object, use that. Otherwise uses the global src.\"\n *\n * The above rule applies to a retina src.\n */\n var src = current.src || this._options.src;\n\n if ( window.devicePixelRatio > 1 && (this._options.retina !== undefined) ) {\n src = current.retina || this._options.retina;\n }\n\n /**\n * Injects the file variable for usage in the 'templating system' below\n */\n current.file = this._filename;\n\n /**\n * Since we allow the src to be a callback, let's run it and get the results.\n * For the inside, we're passing the element (img) being processed and the object of the selected query.\n */\n if( typeof src === 'function' ){\n src = src.apply(this,[this._element,current]);\n if( typeof src !== 'string' ){\n throw '[ImageQuery] :: \"src\" callback does not return a string';\n }\n }\n\n /**\n * Replace the values of the existing properties on the query object (except src and retina) in the\n * defined src and/or retina.\n */\n src = src.replace(/{:(.*?)}/g, function(_, prop) {\n return current[prop];\n });\n\n this._element.src = src;\n\n // Removes the injected file property\n delete current.file;\n },\n\n /**\n * Queries are in a descendant order. We want to find the query with the highest width that fits the viewport, therefore the first one.\n */\n _findCurrentQuery: function () {\n /**\n * Gets viewport width\n */\n var viewportWidth = window.innerWidth ||\n document.documentElement.clientWidth ||\n document.body.clientWidth;\n\n var queries = this._options.queries;\n var last = queries.length - 1;\n\n for( var query=0; query < last; query+=1 ){\n if (queries[query].width <= viewportWidth){\n return queries[query];\n }\n }\n\n return queries[last];\n },\n\n /**\n * Handles the element loading (img onload) event\n *\n * @method _onLoad\n * @private\n */\n _onLoad: function(){\n\n /**\n * Since we allow a callback for this let's run it.\n */\n this._options.onLoad.call(this);\n }\n\n };\n\n\tCommon.createUIComponent(ImageQuery);\n\n return ImageQuery;\n\n});\n","/**\n * Delays content loading\n * @module Ink.UI.LazyLoad_1\n * @version 1\n */\n\nInk.createModule('Ink.UI.LazyLoad', '1', ['Ink.UI.Common_1', 'Ink.Dom.Event_1', 'Ink.Dom.Element_1'], function(Common, InkEvent, InkElement) {\n'use strict';\n\nfunction LazyLoad() {\n Common.BaseUIComponent.apply(this, arguments);\n}\n\nLazyLoad._name = 'LazyLoad_1';\n\nLazyLoad._optionDefinition = {\n item: ['String', '.lazyload-item'],\n placeholder: ['String', null],\n source: ['String', 'data-src'],\n destination: ['String', 'src'],\n delay: ['Number', 100],\n delta: ['Number', 0],\n image: ['Boolean', true],\n scrollElement: ['Element', window],\n touchEvents: ['Boolean', true],\n onInsideViewport: ['Function', false],\n onAfterAttributeChange: ['Function', false],\n autoInit: ['Boolean', true]\n};\n\nLazyLoad.prototype = {\n /**\n * Stops the browser from loading a barrage of content at once.\n *\n * This delays the loading of images and other content until the corresponding elements are visible in the browser viewport.\n * This was created to load images later, but can be also used for widgets which are slow to load and are only useful when on screen.\n *\n * This works through copying the `src` attribute into `data-src`, and placing a `placeholder` string in the `src` attribute. Then, when the element is on screen, the `data-src` attribute is copied back to `src` and the content starts loading. You can use the options below to change what attributes are involved in the exchange.\n *\n * You can also provide your `onInsideViewport` callback and use it to start widgets which need javascript, such as an interactive map or an animation.\n *\n * @class Ink.UI.LazyLoad_1\n * @constructor\n *\n * @param rootElement {String|DOMElement} The element which contains the lazily-loaded items.\n * @param {Object} [options] Options object, containing:\n * @param {String} [options.item] Item selector. Defaults to '.lazyload-item'.\n * @param {String} [options.placeholder] Placeholder value for items which are not 'visible', in case they don't already have a value set.\n * @param {String} [options.source] Source attribute. When an item is 'visible', use this attribute's value to set its destination attribute. Defaults to 'data-src'.\n * @param {String} [options.destination] Destination attribute. Attribute to change when the element is 'visible'. Defaults to 'src'. \n * @param {Number} [options.delay] Milliseconds to wait before trying to load items. Defaults to 100.\n * @param {Number} [options.delta] Offset distance in pixels. Determines how far the top of an item must be from the viewport be considered 'visible'. Negative values shrink the considered 'visible' viewport while positive values enlarge it. Defaults to 0.\n * @param {Boolean} [options.image] Set to false to make this component do nothing to any elements and just give you the onInsideViewport callback.\n * @param {DOMElement} [options.scrollElement] (advanced) What element is to be listened for the scroll event. Defaults to document.window.\n * @param {Boolean} [options.touchEvents] Subscribe to touch events in addition to scroll events. Useful in mobile safari because 'scroll' events aren't frequent enough. Defaults to true.\n * @param {Function} [options.onInsideViewport] Callback function for when an `item` is 'visible'. Receives an object containing the item's element as an argument.\n * @param {Function} [options.onAfterAttributeChange] (advanced) Callback function when an item's attribute changes. Receives an object containing the item's element as an argument.\n * @param {Boolean} [options.autoInit] (advanced) Set to false if you want to start LazyLoad yourself with `reload()`. Defaults to true.\n *\n * @sample Ink_UI_LazyLoad_1.html\n */\n _init: function() {\n this._rootElm = this._element;\n\n this._aData = [];\n this._hasEvents = false;\n \n if(this._options.autoInit) {\n this._activate();\n }\n },\n\n _activate: function() \n {\n this._getData();\n if(!this._hasEvents) {\n this._addEvents(); \n }\n this._onScrollThrottled();\n },\n\n _getData: function()\n {\n var aElms = Ink.ss(this._options.item);\n var attr = null;\n for(var i=0, t=aElms.length; i < t; i++) {\n if (this._options.placeholder != null && !InkElement.hasAttribute(aElms[i], this._options.destination)) {\n aElms[i].setAttribute(this._options.destination, this._options.placeholder);\n }\n attr = aElms[i].getAttribute(this._options.source);\n if(attr !== null || !this._options.image) {\n this._aData.push({elm: aElms[i], original: attr});\n }\n }\n },\n\n _addEvents: function() \n {\n this._onScrollThrottled = InkEvent.throttle(Ink.bindEvent(this._onScroll, this), this._options.delay);\n if('ontouchmove' in document.documentElement && this._options.touchEvents) {\n InkEvent.observe(document.documentElement, 'touchmove', this._onScrollThrottled);\n }\n InkEvent.observe(this._options.scrollElement, 'scroll', this._onScrollThrottled);\n this._hasEvents = true;\n },\n\n _removeEvents: function() {\n if('ontouchmove' in document.documentElement && this._options.touchEvents) {\n InkEvent.stopObserving(document.documentElement, 'touchmove', this._onScrollThrottled);\n }\n InkEvent.stopObserving(this._options.scrollElement, 'scroll', this._onScrollThrottled);\n this._hasEvents = false;\n }, \n\n _onScroll: function() {\n var curElm;\n\n for(var i=0; i < this._aData.length; i++) {\n curElm = this._aData[i];\n\n if(InkElement.inViewport(curElm.elm, { partial: true, margin: this._options.delta })) {\n this._elInViewport(curElm);\n if (this._options.image) {\n /* [todo] a seemingly unrelated option creates a branch? Some of this belongs in another module. */\n this._aData.splice(i, 1);\n i -= 1;\n }\n }\n }\n\n if (this._aData.length === 0) {\n this._removeEvents();\n }\n },\n\n /**\n * Called when an element is detected inside the viewport\n *\n * @method _elInViewport\n * @param {LazyLoadInternalElementData} curElm\n * @private\n **/\n _elInViewport: function (curElm) {\n this._userCallback('onInsideViewport', { element: curElm.elm });\n\n if(this._options.image) {\n curElm.elm.setAttribute(this._options.destination, curElm.original);\n curElm.elm.removeAttribute(this._options.source);\n }\n\n this._userCallback('onAfterAttributeChange', { element: curElm.elm });\n },\n\n /**\n * Call a callback if it exists and its `typeof` is `\"function\"`.\n * @method _userCallback\n * @param name {String} Callback name in this._options.\n * @private\n **/\n _userCallback: function (name) {\n if (typeof this._options[name] === 'function') {\n this._options[name].apply(this, [].slice.call(arguments, 1));\n }\n },\n\n /**\n * Load or reload the component.\n * Adding the 'scroll' event listener if necessary and checks if anything needs to be loaded now.\n *\n * You can use this to manually invoke the loading logic without user action. \n *\n * @method reload\n * @public\n */\n reload: function() {\n this._activate(); \n },\n\n /**\n * Destroy this component\n * @method destroy\n * @public\n **/\n destroy: function() {\n if(this._hasEvents) {\n this._removeEvents();\n }\n Common.destroyComponent.call(this);\n }\n};\n\nCommon.createUIComponent(LazyLoad);\n\nreturn LazyLoad;\n\n});\n","/**\n * Modal dialog prompts\n * @module Ink.UI.Modal_1\n * @version 1\n */\nInk.createModule('Ink.UI.Modal', '1', ['Ink.UI.Common_1','Ink.Dom.Event_1','Ink.Dom.Css_1','Ink.Dom.Element_1','Ink.Dom.Selector_1','Ink.Util.Array_1'], function(Common, Event, Css, InkElement, Selector, InkArray ) {\n 'use strict';\n\n var opacitySupported = (function (div) {\n div.style.opacity = 'invalid';\n return div.style.opacity !== 'invalid';\n }(InkElement.create('div', {style: 'opacity: 1'})));\n\n /**\n * @class Ink.UI.Modal\n * @constructor\n * @version 1\n * @param {String|DOMElement} selector Element or ID\n * @param {Object} [options] Options object, containing:\n * @param {String} [options.width] Default/Initial width. Ex: '600px'\n * @param {String} [options.height] Default/Initial height. Ex: '400px'\n * @param {String} [options.shadeClass] Custom class to be added to the div.ink-shade\n * @param {String} [options.modalClass] Custom class to be added to the div.ink-modal\n * @param {String} [options.trigger] CSS Selector for target elements that will trigger the Modal.\n * @param {Boolean} [options.autoDisplay] Displays the Modal automatically when constructed.\n * @param {String} [options.markup] Markup to be placed in the Modal when created\n * @param {Function} [options.onShow] Callback function to run when the Modal is opened.\n * @param {Function} [options.onDismiss] Callback function to run when the Modal is closed. Return `false` to cancel dismissing the Modal.\n * @param {Boolean} [options.closeOnClick] Flag to close the modal when clicking outside of it.\n * @param {Boolean} [options.closeOnEscape] Determines if the Modal should close when \"Esc\" key is pressed. Defaults to true.\n * @param {Boolean} [options.responsive] Determines if the Modal should behave responsively (adapt to smaller viewports).\n * @param {String} [options.triggerEvent] (advanced) Trigger's event to be listened. Defaults to 'click'.\n *\n * @sample Ink_UI_Modal_1.html\n */\n\n function upName(dimension) {\n // omg IE\n var firstCharacter = dimension.match(/^./)[0];\n return firstCharacter.toUpperCase() + dimension.replace(/^./, '');\n }\n function maxName(dimension) {\n return 'max' + upName(dimension);\n }\n\n var openModals = [];\n\n function Modal() {\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n Modal._name = 'Modal_1';\n\n Modal._optionDefinition = {\n /**\n * Width, height and markup really optional, as they can be obtained by the element\n */\n width: ['String', undefined],\n height: ['String', undefined],\n\n /**\n * To add extra classes\n */\n shadeClass: ['String', undefined],\n modalClass: ['String', undefined],\n\n /**\n * Optional trigger properties\n */\n trigger: ['String', undefined],\n triggerEvent: ['String', 'click'],\n autoDisplay: ['Boolean', true],\n\n /**\n * Remaining options\n */\n markup: ['String', undefined],\n onShow: ['Function', undefined],\n onDismiss: ['Function', undefined],\n closeOnClick: ['Boolean', false],\n closeOnEscape: ['Boolean', true],\n responsive: ['Boolean', true]\n };\n\n Modal.prototype = {\n _init: function () {\n this._handlers = {\n click: Ink.bindEvent(this._onShadeClick, this),\n keyDown: Ink.bindEvent(this._onKeyDown, this),\n resize: Ink.bindEvent(this._onResize, this)\n };\n\n this._wasDismissed = false;\n\n /**\n * Modal Markup\n */\n if( this._element ){\n this._markupMode = Css.hasClassName(this._element,'ink-modal'); // Check if the full modal comes from the markup\n } else {\n this._markupMode = false;\n }\n\n if( !this._markupMode ){\n this._modalShadow = document.createElement('div');\n this._modalShadowStyle = this._modalShadow.style;\n\n this._modalDiv = document.createElement('div');\n this._modalDivStyle = this._modalDiv.style;\n\n if( !!this._element ){\n this._options.markup = this._element.innerHTML;\n }\n\n /**\n * Not in full markup mode, let's set the classes and css configurations\n */\n Css.addClassName( this._modalShadow,'ink-shade' );\n Css.addClassName( this._modalDiv,'ink-modal ink-space' );\n\n /**\n * Applying the main css styles\n */\n // this._modalDivStyle.position = 'absolute';\n this._modalShadow.appendChild( this._modalDiv);\n document.body.appendChild( this._modalShadow );\n } else {\n this._modalDiv = this._element;\n this._modalDivStyle = this._modalDiv.style;\n this._modalShadow = this._modalDiv.parentNode;\n this._modalShadowStyle = this._modalShadow.style;\n\n this._contentContainer = Selector.select(\".modal-body\", this._modalDiv)[0];\n if( !this._contentContainer){\n throw new Error('Ink.UI.Modal: Missing div with class \"modal-body\"');\n }\n\n this._options.markup = this._contentContainer.innerHTML;\n }\n\n if( !this._markupMode ){\n this.setContentMarkup(this._options.markup);\n }\n\n if( typeof this._options.shadeClass === 'string' ){\n Css.addClassName(this._modalShadow, this._options.shadeClass);\n }\n\n if( typeof this._options.modalClass === 'string' ){\n Css.addClassName(this._modalDiv, this._options.modalClass);\n }\n\n if( this._options.trigger ) {\n var triggerElements = Common.elsOrSelector(this._options.trigger, '');\n Event.observeMulti(triggerElements, this._options.triggerEvent, Ink.bindEvent(this.open, this));\n } else if ( this._options.autoDisplay.toString() === \"true\" ) {\n this.open();\n }\n },\n\n /**\n * Responsible for repositioning the modal\n * \n * @method _reposition\n * @private\n */\n _reposition: function(){\n this._modalDivStyle.marginTop = (-InkElement.elementHeight(this._modalDiv)/2) + 'px';\n this._modalDivStyle.marginLeft = (-InkElement.elementWidth(this._modalDiv)/2) + 'px';\n },\n\n /**\n * Responsible for resizing the modal\n * \n * @method _onResize\n * @param {Boolean|Event} runNow Its executed in the begining to resize/reposition accordingly to the viewport. But usually it's an event object.\n * @private\n */\n _onResize: function( runNow ){\n if( typeof runNow === 'boolean' ){\n this._timeoutResizeFunction.call(this);\n } else if( !this._resizeTimeout && (runNow && typeof runNow === 'object') ){\n this._resizeTimeout = setTimeout(Ink.bind(this._timeoutResizeFunction, this),250);\n }\n },\n\n /**\n * Timeout Resize Function\n * \n * @method _timeoutResizeFunction\n * @private\n */\n _timeoutResizeFunction: function(){\n /**\n * Getting the current viewport size\n */\n var isPercentage = {\n width: ('' + this._options.width).indexOf('%') !== -1,\n height: ('' + this._options.height).indexOf('%') !== -1\n };\n var currentViewport = {\n height: InkElement.viewportHeight(),\n width: InkElement.viewportWidth()\n };\n\n InkArray.forEach(['height', 'width'], Ink.bind(function (dimension) {\n // Not used for percentage measurements\n if (isPercentage[dimension]) { return; }\n\n if (currentViewport[dimension] > this.originalStatus[dimension]) {\n this._modalDivStyle[dimension] = this._modalDivStyle[maxName(dimension)];\n } else {\n this._modalDivStyle[dimension] = Math.round(currentViewport[dimension] * 0.9) + 'px';\n }\n }, this));\n\n this._resizeContainer();\n this._reposition();\n this._resizeTimeout = undefined;\n },\n\n /**\n * Handle clicks on the shade element.\n * \n * @method _onShadeClick\n * @param {Event} ev\n * @private\n */\n _onShadeClick: function(ev) {\n var tgtEl = Event.element(ev);\n\n if (Css.hasClassName(tgtEl, 'ink-close') || Css.hasClassName(tgtEl, 'ink-dismiss') || \n InkElement.findUpwardsBySelector(tgtEl, '.ink-close,.ink-dismiss') ||\n (\n this._options.closeOnClick &&\n (!InkElement.descendantOf(this._shadeElement, tgtEl) || (tgtEl === this._shadeElement))\n )\n ) {\n var alertsInTheModal = Selector.select('.ink-alert', this._shadeElement),\n alertsLength = alertsInTheModal.length;\n for( var i = 0; i < alertsLength; i++ ){\n if( InkElement.descendantOf(alertsInTheModal[i], tgtEl) ){\n return;\n }\n }\n\n this.dismiss();\n\n // Only stop the event if this dismisses this modal\n if (this._wasDismissed) {\n Event.stop(ev);\n }\n }\n },\n\n /**\n * Responsible for handling the escape key pressing.\n *\n * @method _onKeyDown\n * @param {Event} ev\n * @private\n */\n _onKeyDown: function(ev) {\n if (ev.keyCode !== 27 || this._wasDismissed) { return; }\n if (this._options.closeOnEscape.toString() === 'true' &&\n openModals[openModals.length - 1] === this) {\n this.dismiss();\n if (this._wasDismissed) {\n Event.stop(ev);\n }\n }\n },\n\n /**\n * Responsible for setting the size of the modal (and position) based on the viewport.\n * \n * @method _resizeContainer\n * @private\n */\n _resizeContainer: function() {\n var containerHeight = InkElement.elementHeight(this._modalDiv);\n\n this._modalHeader = Selector.select('.modal-header',this._modalDiv)[0];\n if( this._modalHeader ){\n containerHeight -= InkElement.elementHeight(this._modalHeader);\n }\n\n this._modalFooter = Selector.select('.modal-footer',this._modalDiv)[0];\n if( this._modalFooter ){\n containerHeight -= InkElement.elementHeight(this._modalFooter);\n }\n\n this._contentContainer.style.height = containerHeight + 'px';\n if( containerHeight !== InkElement.elementHeight(this._contentContainer) ){\n this._contentContainer.style.height = ~~(containerHeight - (InkElement.elementHeight(this._contentContainer) - containerHeight)) + 'px';\n }\n\n if( this._markupMode ){ return; }\n },\n\n /**************\n * PUBLIC API *\n **************/\n\n /**\n * Opens this Modal. \n * Use this if you created the modal with `autoOpen: false`\n * to open the modal when you want to.\n * @method open \n * @param {Event} [event] (internal) In case its fired by the internal trigger.\n */\n open: function(event) {\n\n if( event ){ Event.stop(event); }\n\n var elem = (document.compatMode === \"CSS1Compat\") ? document.documentElement : document.body;\n\n this._resizeTimeout = null;\n\n Css.addClassName( this._modalShadow,'ink-shade' );\n this._modalShadowStyle.display = this._modalDivStyle.display = 'block';\n setTimeout(Ink.bind(function() {\n Css.addClassName( this._modalShadow, 'visible' );\n Css.addClassName( this._modalDiv, 'visible' );\n }, this), 100);\n\n /**\n * Fallback to the old one\n */\n this._contentElement = this._modalDiv;\n this._shadeElement = this._modalShadow;\n\n if( !this._markupMode ){\n /**\n * Setting the content of the modal\n */\n this.setContentMarkup( this._options.markup );\n }\n\n /**\n * If any size has been user-defined, let's set them as max-width and max-height\n */\n\n var isPercentage = {\n width: ('' + this._options.width).indexOf('%') !== -1,\n height: ('' + this._options.height).indexOf('%') !== -1\n };\n\n InkArray.forEach(['width', 'height'], Ink.bind(function (dimension) {\n if (this._options[dimension] !== undefined) {\n this._modalDivStyle[dimension] = this._options[dimension];\n if (!isPercentage[dimension]) {\n this._modalDivStyle[maxName(dimension)] =\n InkElement['element' + upName(dimension)](this._modalDiv) + 'px';\n }\n } else {\n this._modalDivStyle[maxName(dimension)] = InkElement['element' + upName(dimension)](this._modalDiv) + 'px';\n }\n\n if (isPercentage[dimension] && parseInt(elem['client' + maxName(dimension)], 10) <= parseInt(this._modalDivStyle[dimension], 10) ) {\n this._modalDivStyle[dimension] = Math.round(parseInt(elem['client' + maxName(dimension)], 10) * 0.9) + 'px';\n }\n }, this));\n\n this.originalStatus = {\n viewportHeight: InkElement.elementHeight(elem),\n viewportWidth: InkElement.elementWidth(elem),\n height: InkElement.elementHeight(this._modalDiv),\n width: InkElement.elementWidth(this._modalDiv)\n };\n\n /**\n * Let's 'resize' it:\n */\n if( this._options.responsive.toString() === 'true' ) {\n this._onResize(true);\n Event.observe( window,'resize',this._handlers.resize );\n } else {\n this._resizeContainer();\n this._reposition();\n }\n\n if (this._options.onShow) {\n this._options.onShow(this);\n }\n\n // subscribe events\n Event.observe(this._shadeElement, 'click', this._handlers.click);\n if (this._options.closeOnEscape.toString() === 'true') {\n Event.observe(document, 'keydown', this._handlers.keyDown);\n }\n\n this._wasDismissed = false;\n openModals.push(this);\n\n Css.addClassName(document.documentElement, 'ink-modal-open');\n },\n\n /**\n * Closes the modal\n * \n * @method dismiss\n * @public\n */\n dismiss: function() {\n if (this._wasDismissed) { /* Already dismissed. WTF IE. */ return; }\n\n if (this._options.onDismiss) {\n var ret = this._options.onDismiss(this);\n if (ret === false) { return; }\n }\n\n this._wasDismissed = true;\n\n if( this._options.responsive ){\n Event.stopObserving(window, 'resize', this._handlers.resize);\n }\n\n // this._modalShadow.parentNode.removeChild(this._modalShadow);\n\n if( !this._markupMode ){\n this._modalShadow.parentNode.removeChild(this._modalShadow);\n this.destroy();\n } else {\n Css.removeClassName( this._modalDiv, 'visible' );\n Css.removeClassName( this._modalShadow, 'visible' );\n\n this._waitForFade(this._modalShadow, Ink.bind(function () {\n this._modalShadowStyle.display = 'none';\n }, this));\n }\n\n openModals = InkArray.remove(openModals, InkArray.keyValue(this, openModals), 1);\n\n if (openModals.length === 0) { // Document level stuff now there are no modals in play.\n var htmlEl = document.documentElement;\n\n // Remove the class from the HTML element.\n Css.removeClassName(htmlEl, 'ink-modal-open');\n }\n },\n\n /**\n * Utility function to listen to the onTransmissionEnd event, or wait using setTimeouts\n *\n * Specific to this._element\n */\n _waitForFade: function (elem, callback) {\n if (!opacitySupported) { return callback(); }\n\n var transitionEndEventNames = [\n 'transitionEnd', 'oTransitionEnd', 'webkitTransitionEnd'];\n var classicName;\n var evName;\n for (var i = 0, len = transitionEndEventNames.length; i < len; i++) {\n evName = transitionEndEventNames[i];\n classicName = 'on' + evName.toLowerCase();\n if (classicName in elem) {\n Event.observeOnce(elem, evName, callback);\n return;\n }\n }\n var fadeChecker = function () {\n if( +Css.getStyle(elem, 'opacity') > 0 ){\n setTimeout(fadeChecker, 250);\n } else {\n callback();\n }\n };\n setTimeout(fadeChecker, 500);\n },\n\n /**\n * Removes the modal from the DOM\n * \n * @method destroy\n * @public\n */\n destroy: function() {\n Common.unregisterInstance(this._instanceId);\n },\n\n /**\n * Returns the content DOM element\n * \n * @method getContentElement\n * @return {DOMElement} Modal main cointainer.\n * @public\n */\n getContentElement: function() {\n return this._contentContainer;\n },\n\n /**\n * Replaces the content markup\n * \n * @method setContentMarkup\n * @param {String} contentMarkup\n * @public\n */\n setContentMarkup: function(contentMarkup) {\n if( !this._markupMode ){\n this._modalDiv.innerHTML = [contentMarkup].join('');\n this._contentContainer = Selector.select(\".modal-body\",this._modalDiv);\n if( !this._contentContainer.length ){\n // throw 'Missing div with class \"modal-body\"';\n var tempHeader = Selector.select(\".modal-header\",this._modalDiv);\n var tempFooter = Selector.select(\".modal-footer\",this._modalDiv);\n\n InkArray.each(tempHeader, InkElement.remove);\n InkArray.each(tempFooter, InkElement.remove);\n\n var body = document.createElement('div');\n Css.addClassName(body,'modal-body');\n body.innerHTML = this._modalDiv.innerHTML;\n this._modalDiv.innerHTML = '';\n\n var toAdd = tempHeader.concat([body]).concat(tempFooter);\n InkArray.each(toAdd, Ink.bindMethod(this._modalDiv, 'appendChild'));\n\n this._contentContainer = Selector.select(\".modal-body\",this._modalDiv);\n }\n this._contentContainer = this._contentContainer[0];\n } else {\n this._contentContainer.innerHTML = contentMarkup;\n }\n this._contentElement = this._modalDiv;\n this._resizeContainer();\n }\n\n };\n\n Common.createUIComponent(Modal, { elementIsOptional: true });\n\n return Modal;\n\n});\n","/**\n * Pagination elements\n * @module Ink.UI.Pagination_1\n * @version 1\n */\n \nInk.createModule('Ink.UI.Pagination', '1',\n ['Ink.UI.Common_1','Ink.Dom.Event_1','Ink.Dom.Css_1','Ink.Dom.Element_1','Ink.Dom.Selector_1'],\n function(Common, Event, Css, Element, Selector ) {\n 'use strict';\n\n /**\n * Function to create the pagination anchors\n *\n * @method genAel\n * @private\n * @param {String} inner HTML to be placed inside the anchor.\n * @return {DOMElement} Anchor created\n */\n var genAEl = function(inner, index, options) {\n var aEl = document.createElement('a');\n aEl.setAttribute('href', '#');\n if (typeof index === 'number') {\n aEl.setAttribute('data-index', index);\n }\n if(options && options.wrapText) {\n var spanEl = document.createElement('span');\n aEl.appendChild(spanEl);\n spanEl.innerHTML = inner;\n } else {\n aEl.innerHTML = inner;\n }\n return aEl;\n };\n\n /**\n * @class Ink.UI.Pagination\n * @constructor\n * @version 1\n * @param {String|DOMElement} selector Selector or element\n * @param {Object} options Options\n * @param {Number} [options.size] Number of pages.\n * @param {Number} [options.totalItemCount] Total numeber of items to display\n * @param {Number} [options.itemsPerPage] Number of items per page.\n * @param {Number} [options.maxSize] If passed, only shows at most maxSize items. displays also first|prev page and next page|last buttons\n * @param {Number} [options.start] Start page. defaults to 1\n * @param {Boolean} [options.sideButtons=true] Whether to show the first, last, previous, next, previousPage and lastPage buttons. Do not use together with maxSize.\n * @param {String} [options.firstLabel] Text for the first page button. Defaults to 'First'.\n * @param {String} [options.lastLabel] Text for the last page button. Defaults to 'Last'.\n * @param {String} [options.previousLabel] Text for the previous button. Defaults to 'Previous'-\n * @param {String} [options.nextLabel] Text for the next button. Defaults to 'Next'\n * @param {String} [options.previousPageLabel] Text for the previous page button. Defaults to 'Previous {Items per page}'.\n * @param {String} [options.nextPageLabel] Text for the next page button. Defaults to 'Next {Items per page}'.\n * @param {Function} [options.onChange] Callback to be called when a page changes. Called with `(thisPaginator, newPageNumber)`.\n * @param {String} [options.hashParameter] Parameter to use on setHash. Defaults to 'page'.\n * @param {String} [options.parentTag] HTML Tag used as the parent node.\n * @param {String} [options.childTag] HTML Tag used as the child nodes.\n * @param {String} [options.wrapperClass] CSS Class used in the wrapper element\n * @param {String} [options.paginationClass] CSS Class used in the pagination element\n * @param {String} [options.activeClass] CSS Class used to mark page as active\n * @param {String} [options.disabledClass] CSS Class used to mark page as disabled\n * @param {String} [options.hideClass] CSS Class used to hide elements\n * @param {String} [options.previousClass] CSS Class used in the previous element\n * @param {String} [options.previousPageClass] CSS Class used in the previous page element\n * @param {String} [options.nextClass] CSS Class used in the next element\n * @param {String} [options.nextPageClass] CSS Class used in the next page element\n * @param {Function} [options.numberFormatter] Number formatter function. Receives a 0-indexed number and returns the text for the numbered page button.\n *\n * @sample Ink_UI_Pagination_1.html\n */\n function Pagination() {\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n Pagination._name = 'Pagination_1';\n\n Pagination._optionDefinition = {\n size: ['Integer', null],\n totalItemCount: ['Integer', null],\n itemsPerPage: ['Integer', null],\n maxSize: ['Integer', null],\n start: ['Integer', 1],\n sideButtons: ['Boolean', 1 /* actually `true` but we want to see if user is using the default or not. */],\n // TODO add pagination-type which accepts color strings, \"chevron\" and \"dotted\". Basically classes to add to the UL.\n firstLabel: ['String', 'First'],\n lastLabel: ['String', 'Last'],\n previousLabel: ['String', 'Previous'],\n nextLabel: ['String', 'Next'],\n previousPageLabel: ['String', null],\n nextPageLabel: ['String', null],\n onChange: ['Function', undefined],\n hashParameter: ['String', 'page'],\n parentTag: ['String', 'ul'],\n childTag: ['String', 'li'],\n wrapperClass: ['String', 'ink-navigation'],\n paginationClass: ['String', 'pagination'],\n activeClass: ['String', 'active'],\n disabledClass: ['String', 'disabled'],\n hideClass: ['String', 'hide-all'],\n previousClass: ['String', 'previous'],\n previousPageClass: ['String', 'previousPage'],\n nextClass: ['String', 'next'],\n nextPageClass: ['String', 'nextPage'],\n\n numberFormatter: ['Function', function(i) { return i + 1; }]\n };\n\n Pagination.prototype = {\n /**\n * Init function called by the constructor\n *\n * @method _init\n * @private\n */\n _init: function() {\n if (!this._options.previousPageLabel) {\n this._options.previousPageLabel = this._options.previousLabel + ' ' + this._options.maxSize;\n }\n\n if (!this._options.nextPageLabel) {\n this._options.nextPageLabel = this._options.nextLabel + ' ' + this._options.maxSize;\n }\n\n this._handlers = {\n click: Ink.bindEvent(this._onClick,this)\n };\n\n if (Common.isInteger(this._options.totalItemCount) && Common.isInteger(this._options.itemsPerPage)) {\n this._size = this._calculateSize(this._options.totalItemCount, this._options.itemsPerPage);\n } else if (Common.isInteger(this._options.size)) {\n this._size = this._options.size;\n } else {\n Ink.error('Ink.UI.Pagination: Please supply a size option or totalItemCount and itemsPerPage options.');\n this._size = 0;\n }\n\n this._current = this._options.start - 1;\n this._itemLiEls = [];\n\n // generate and apply DOM\n this._generateMarkup(this._element);\n\n this._updateItems();\n\n // subscribe events\n this._observe();\n },\n\n /**\n * Responsible for setting listener in the 'click' event of the Pagination element.\n *\n * @method _observe\n * @private\n */\n _observe: function() {\n Event.observeDelegated(this._element, 'click', '.' + this._options.paginationClass + ' > ' + this._options.childTag, this._handlers.click);\n },\n\n /**\n * Calculate how many pages are necessary for `count` items, and `itemsPerPage` items per page.\n *\n * @method _calculateSize\n * @param count\n * @param itemsPerPage\n * @private\n **/\n _calculateSize: function (count, itemsPerPage) {\n return Math.ceil(count / itemsPerPage);\n },\n /**\n * Updates the markup everytime there's a change in the Pagination object.\n *\n * @method _updateItems\n * @private\n */\n _updateItems: function() {\n var liEls = this._itemLiEls;\n\n var isSimpleToggle = this._size === liEls.length;\n\n var i, f, liEl;\n\n if (isSimpleToggle) {\n // just toggle active class\n for (i = 0, f = this._size; i < f; ++i) {\n Css.setClassName(liEls[i], this._options.activeClass, i === this._current);\n }\n }\n else {\n // remove old items\n for (i = liEls.length - 1; i >= 0; --i) {\n this._ulEl.removeChild(liEls[i]);\n }\n\n // add new items\n liEls = [];\n for (i = 0, f = this._size; i < f; ++i) {\n liEl = document.createElement(this._options.childTag);\n liEl.appendChild( genAEl( this._options.numberFormatter(i), i) );\n // add \"active\" class if this is the active element.\n Css.setClassName(liEl, this._options.activeClass, i === this._current);\n if (this._nextEl) {\n this._ulEl.insertBefore(liEl, this._nextEl);\n } else {\n this._ulEl.appendChild(liEl);\n }\n\n liEls.push(liEl);\n }\n this._itemLiEls = liEls;\n }\n\n if (this._options.maxSize) {\n // toggle visible items\n var page = Math.floor( this._current / this._options.maxSize );\n var pi = this._options.maxSize * page;\n var pf = pi + this._options.maxSize - 1;\n\n for (i = 0, f = this._size; i < f; ++i) {\n liEl = liEls[i];\n Css.setClassName(liEl, this._options.hideClass, i < pi || i > pf);\n }\n\n this._pageStart = pi;\n this._pageEnd = pf;\n this._page = page;\n\n Css.setClassName(this._prevPageEl, this._options.disabledClass, !this.hasPreviousPage());\n Css.setClassName(this._nextPageEl, this._options.disabledClass, !this.hasNextPage());\n\n Css.setClassName(this._firstEl, this._options.disabledClass, this.isFirst());\n Css.setClassName(this._lastEl, this._options.disabledClass, this.isLast());\n }\n\n // update prev and next\n if (this._prevEl) {\n Css.setClassName(this._prevEl, this._options.disabledClass, !this.hasPrevious());\n }\n if (this._nextEl) {\n Css.setClassName(this._nextEl, this._options.disabledClass, !this.hasNext());\n }\n },\n\n /**\n * Returns the top element for the gallery DOM representation\n *\n * @method _generateMarkup\n * @param {DOMElement} el\n * @private\n */\n _generateMarkup: function(el) {\n Css.addClassName(el, 'ink-navigation');\n\n var ulEl = Ink.s('.' + this._options.paginationClass, el);\n var hasUlAlready = false;\n\n if( !ulEl ){\n ulEl = document.createElement(this._options.parentTag);\n Css.addClassName(ulEl, this._options.paginationClass);\n } else {\n hasUlAlready = true;\n }\n\n var isChevron = Css.hasClassName(ulEl, 'chevron');\n var isDotted = Css.hasClassName(ulEl, 'dotted');\n\n // Creates <li> elements for firstPage, nextPage, first, last, etc.\n var createLiEl = Ink.bind(function (name, options) {\n var liEl = document.createElement(this._options.childTag);\n var aEl = genAEl(this._options[name + 'Label'], undefined, { wrapText: options && options.wrapText });\n Css.addClassName(liEl, this._options[name + 'Class']);\n liEl.appendChild(aEl);\n ulEl.appendChild(liEl);\n return liEl;\n }, this);\n\n if (!isDotted && this._options.maxSize) {\n this._firstEl = createLiEl('first');\n this._prevPageEl = createLiEl('previousPage');\n }\n\n // When we're dotted, the default for sideButtons is `false`. When we're note, it's `true`.\n // Since the default is actually \"1\", we do a === true check when we're dotted, and a truthish check when we're not.\n if ((isDotted && this._options.sideButtons === true) || (!isDotted && this._options.sideButtons)) {\n this._prevEl = createLiEl('previous', { wrapText: isChevron });\n this._nextEl = createLiEl('next', { wrapText: isChevron });\n }\n\n if (!isDotted && this._options.maxSize) {\n this._nextPageEl = createLiEl('nextPage');\n this._lastEl = createLiEl('last');\n }\n\n if( !hasUlAlready ){\n el.appendChild(ulEl);\n }\n\n this._ulEl = ulEl;\n },\n\n /**\n * Click handler\n *\n * @method _onClick\n * @param {Event} ev\n * @private\n */\n _onClick: function(ev) {\n Event.stop(ev);\n\n var liEl = Event.element(ev);\n if ( Css.hasClassName(liEl, this._options.activeClass) ||\n Css.hasClassName(liEl, this._options.disabledClass) ) { return; }\n\n var isPrev = Css.hasClassName(liEl, this._options.previousClass);\n var isNext = Css.hasClassName(liEl, this._options.nextClass);\n var isPrevPage = Css.hasClassName(liEl, this._options.previousPageClass);\n var isNextPage = Css.hasClassName(liEl, this._options.nextPageClass);\n var isFirst = Css.hasClassName(liEl, this._options.firstClass);\n var isLast = Css.hasClassName(liEl, this._options.lastClass);\n\n if (isFirst) {\n this.setCurrent(0);\n }\n else if (isLast) {\n this.setCurrent(this._size - 1);\n }\n else if (isPrevPage || isNextPage) {\n this.setCurrent( (isPrevPage ? -1 : 1) * this._options.maxSize, true /* relative */);\n }\n else if (isPrev || isNext) {\n this.setCurrent(isPrev ? -1 : 1, true /* relative */);\n }\n else {\n var aElem = Selector.select('[data-index]', liEl)[0];\n var nr = aElem && parseInt( aElem.getAttribute('data-index'), 10);\n this.setCurrent(nr);\n }\n },\n\n\n /**\n * Allows you to subscribe to the onChange event\n *\n * @method setOnChange\n * @param cb {Function} Callback called with `(thisPaginator, newPageNumber)`.\n */\n setOnChange: function (onChange) {\n if (onChange !== undefined && typeof onChange !== 'function') {\n throw new TypeError('onChange option must be a function!');\n }\n this._options.onChange = onChange;\n },\n\n /**************\n * PUBLIC API *\n **************/\n\n /**\n * Sets the number of pages\n *\n * @method setSize\n * @param {Number} sz number of pages\n * @public\n */\n setSize: function(sz) {\n if (!Common.isInteger(sz)) {\n throw new TypeError('1st argument must be an integer number!');\n }\n\n this._size = sz;\n this._updateItems();\n this._current = 0;\n },\n\n /**\n * Sets the number of pages, then call setSize().\n *\n * @param setSizeInItems\n * @param {Number} totalItems Total number of items\n * @param {Number} itemsPerPage Items per page\n */\n setSizeInItems: function (totalItems, itemsPerPage) {\n var pageNumber = Math.ceil(totalItems / itemsPerPage);\n this.setSize(pageNumber);\n },\n\n /**\n * Sets the current page.\n *\n * @method setCurrent\n * @param {Number} nr Sets the current page to given number.\n * @param {Boolean} isRelative Flag to change the position from absolute to relative.\n * @public\n */\n setCurrent: function(nr, isRelative) {\n if (!Common.isInteger(nr)) {\n throw new TypeError('1st argument must be an integer number!');\n }\n\n if (isRelative) {\n nr += this._current;\n }\n\n if (nr > this._size - 1) {\n nr = this._size - 1;\n }\n\n if (nr < 0) {\n nr = 0;\n }\n\n this._current = nr;\n this._updateItems();\n\n if (this._options.onChange) {\n this._options.onChange(this, nr);\n }\n\n /*if (this._options.setHash) {\n var o = {};\n o[this._options.hashParameter] = nr;\n Common.setHash(o);\n }*/ // undocumented option, removing\n },\n\n /**\n * Gets the number of pages\n *\n * @method getSize\n * @return {Number} Number of pages\n * @public\n */\n getSize: function() {\n return this._size;\n },\n\n /**\n * Gets the current page index\n *\n * @method getCurrent\n * @return {Number} Current page\n * @public\n */\n getCurrent: function() {\n return this._current;\n },\n\n /**\n * Checks if it's at the first page\n *\n * @method isFirst\n * @return {Boolean} True if at first page\n * @public\n */\n isFirst: function() {\n return this._current === 0;\n },\n\n /**\n * Checks if it's on the last page\n *\n * @method isLast\n * @return {Boolean} True if at last page\n * @public\n */\n isLast: function() {\n return this._current === this._size - 1;\n },\n\n /**\n * Checks if it has previous pages\n *\n * @method hasPrevious\n * @return {Boolean} True if has prior pages\n * @public\n */\n hasPrevious: function() {\n return this._current > 0;\n },\n\n /**\n * Checks if it has next pages\n *\n * @method hasNext\n * @return {Boolean} True if has pages ahead\n * @public\n */\n hasNext: function() {\n return this._current < this._size - 1;\n },\n\n /**\n * Checks if it has a previous set of pages\n *\n * @method hasPreviousPage\n * @return {Boolean} Returns true iif has prior set of page(s)\n * @public\n */\n hasPreviousPage: function() {\n return this._options.maxSize && this._current > this._options.maxSize - 1;\n },\n\n /**\n * Checks if it has a next set of pages\n *\n * @method hasNextPage\n * @return {Boolean} Returns true iif has set of page(s) ahead\n * @public\n */\n hasNextPage: function() {\n return this._options.maxSize && this._size - this._current >= this._options.maxSize + 1;\n },\n\n /**\n * Unregisters the component and removes its markup\n *\n * @method destroy\n * @public\n */\n destroy: Common.destroyComponent\n };\n\n Common.createUIComponent(Pagination);\n\n return Pagination;\n\n});","/**\n * Animated progress bars\n * @module Ink.UI.ProgressBar_1\n * @version 1\n */\n\nInk.createModule('Ink.UI.ProgressBar', '1', ['Ink.UI.Common_1', 'Ink.Dom.Selector_1'], function( Common, Selector ) {\n 'use strict';\n\n /**\n * Associated to a .ink-progress-bar element, it provides a setValue() method to change the element's value.\n * \n * @class Ink.UI.ProgressBar\n * @constructor\n * @version 1\n * @param {String|DOMElement} selector Element or selector\n * @param {Object} [options] Options object\n * @param {Number} [options.startValue] Percentage of the bar that is filled. Ranges between 0 and 100. Default: 0\n * @param {Function} [options.onStart] Callback called when a change of value is started\n * @param {Function} [options.onEnd] Callback called when a change of value ends\n *\n * @sample Ink_UI_ProgressBar_1.html\n */\n function ProgressBar(){\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n ProgressBar._name = 'ProgressBar_1';\n\n ProgressBar._optionDefinition = {\n startValue: ['Number', 0],\n onStart: ['Function', function () {}],\n onEnd: ['Function', function () {}]\n };\n\n ProgressBar.prototype = {\n /**\n * Init function called by the constructor\n * \n * @method _init\n * @private\n */\n _init: function(){\n this._value = this._options.startValue;\n this._elementBar = Selector.select('.bar',this._element);\n if( this._elementBar.length < 1 ){\n throw new Error('[Ink.UI.ProgressBar] :: Bar element not found');\n }\n this._elementBar = this._elementBar[0];\n\n this.setValue( this._options.startValue );\n },\n\n /**\n * Sets the value of the Progressbar\n * \n * @method setValue\n * @param {Number} newValue Numeric value, between 0 and 100, that represents the percentage of the bar.\n * @public\n */\n setValue: function( newValue ){\n this._options.onStart.call(this, this._value);\n\n newValue = parseInt(newValue,10);\n if( isNaN(newValue) || (newValue < 0) ){\n newValue = 0;\n } else if( newValue>100 ){\n newValue = 100;\n }\n this._value = newValue;\n this._elementBar.style.width = this._value + '%';\n\n this._options.onEnd.call(this, this._value);\n }\n };\n\n Common.createUIComponent(ProgressBar);\n\n return ProgressBar;\n\n});\n","/**\n * Scroll to content\n * @module Ink.UI.SmoothScroller_1\n * @version 1\n */\nInk.createModule('Ink.UI.SmoothScroller', '1', ['Ink.UI.Common_1', 'Ink.Dom.Event_1', 'Ink.Dom.Element_1', 'Ink.Dom.Selector_1','Ink.Dom.Css_1'], function(Common, Event, InkElement, Selector, Css) {\n 'use strict';\n\n var requestAnimationFrame =\n window.requestAnimationFrame ||\n function (cb) { return setTimeout(cb, 10); };\n\n var cancelAnimationFrame =\n window.cancelAnimationFrame ||\n function (id) { clearTimeout(id); };\n\n /**\n * @namespace SmoothScroller\n * @version 1\n * @static\n *\n * SmoothScroller is a component which replaces the default scroll-to behaviour of `<a>` tags which refer to IDs on the page.\n *\n * For example, when you have this:\n *\n * <a href=\"#todo\">Todo</a>\n * [...]\n * <section id=\"todo\">\n * [...]\n *\n * You can click the `<a>` and the page will scroll until the section you pointed to.\n *\n * When you use SmoothScroller, instead of immediately scrolling to the element, you get a smooth motion.\n *\n * Also, you can define the data-margin option if you have a `position:fixed` top menu ruining the behaviour.\n *\n * @example\n *\n */\n var SmoothScroller = {\n\n /**\n * The default scrolling speed. Higher is slower. Defaults to 10.\n *\n * @property speed\n * @type {Number}\n * @default 10\n * @static\n */\n speed: 10,\n\n /**\n * Change the URL hash (location.hash) when done scrolling? Defaults to true.\n *\n * @property changeHash\n * @default true\n * @type {Boolean}\n * @static\n */\n changeHash: true,\n\n /**\n * The default top margin.\n * Use this when you want the scroll motion to stop before it reaches its destination, for example when you want to add some breathing space or have a position:fixed top bar in front of your content.\n *\n * @property margin\n * @default 0\n * @type {Number}\n * @static\n */\n margin: 0,\n\n\n /**\n * Moves the scrollbar to the target element. This is the function\n * which animates the scroll position bit by bit. It calls itself in\n * the end through requestAnimationFrame\n *\n * @method scroll\n * @param {Number} d Y coordinate value to stop\n * @private\n * @static\n */\n scroll: function(d, options) {\n var a = Math.round(InkElement.scrollHeight());\n\n var endPos = Math.round(d - options.margin);\n\n if (endPos > a) {\n a += Math.ceil((endPos - a) / options.speed);\n } else {\n a = a + (endPos - a) / options.speed;\n }\n\n cancelAnimationFrame(SmoothScroller.interval);\n\n if (!((a) === endPos || SmoothScroller.offsetTop === a)) {\n SmoothScroller.interval = requestAnimationFrame(\n Ink.bindMethod(SmoothScroller, 'scroll', d, options), document.body);\n } else {\n SmoothScroller.onDone(options);\n }\n\n window.scrollTo(0, a);\n SmoothScroller.offsetTop = a;\n },\n\n\n /**\n * Has smooth scrolling applied to relevant elements upon page load.\n * Listens to the click event on the document.\n * Anything which matches the selector will be considered a \"link\" by SmoothScroller and handled as such.\n *\n * When a link is clicked, it is checked for several options:\n * - `data-margin=\"0\"` - A margin in pixels -- useful when you have a position:fixed top bar.\n * - `data-speed=\"10\"` - Inverse speed of the scrolling motion. Smaller is faster.\n * - `data-change-hash=\"true\"` - Change the URL hash (location.hash) when done scrolling.\n *\n * @method init\n * @param [selector='a.scrollableLink,a.ink-smooth-scroll'] {String} Selector string for finding links with smooth scrolling enabled.\n * @static\n * @sample Ink_UI_SmoothScroller_1.html\n */\n init: function(selector) {\n Event.on(document, 'click', selector || 'a.scrollableLink, a.ink-smooth-scroll', SmoothScroller.onClick);\n },\n\n // Deprecated. Kept around just in case someone is still calling this.\n render: function() {},\n\n /**\n * Handles clicks on link elements\n *\n * @method onClick\n * @private\n * @static\n */\n onClick: function(event) {\n var link = event.currentTarget;\n\n var thisDocument = (location + '').replace(/#.*?$/, '');\n var linkedDocument = (link.href + '').replace(/#.*?$/, '');\n\n if (linkedDocument !== thisDocument) {\n return; // It's an external link.\n }\n\n var hash = link.getAttribute('data-hash') || (link.getAttribute('href') || '')\n .replace(/^.*?#/, '');\n\n if(hash) {\n event.preventDefault();\n var activeLiSelector = 'ul > li.active > ' + selector;\n\n var selector = 'a[name=\"' + hash + '\"],#' + hash;\n var elm = Ink.s(selector);\n var activeLi = Ink.s(activeLiSelector);\n activeLi = activeLi && activeLi.parentNode;\n\n if (elm) {\n if (!Css.hasClassName(link.parentNode, 'active')) {\n if (activeLi) {\n Css.removeClassName(activeLi, 'active');\n }\n Css.addClassName(link.parentNode, 'active');\n }\n\n var options = Common.options('SmoothScroller link options', {\n margin: ['Number', SmoothScroller.margin],\n speed: ['Number', SmoothScroller.speed],\n changeHash: ['Boolean', SmoothScroller.changeHash]\n }, {}, link);\n\n SmoothScroller.hash = hash;\n \n SmoothScroller.scroll(InkElement.offsetTop(elm), options);\n }\n }\n },\n\n /**\n * Called when the scroll movement is done. Updates browser address.\n *\n * @method onDone\n * @param {Object} options Options object from the element.\n * @private\n */\n onDone: function (options) {\n if (options.changeHash === true) {\n window.location.hash = SmoothScroller.hash;\n }\n\n SmoothScroller.hash = SmoothScroller.offsetTop = null;\n }\n };\n\n return SmoothScroller;\n\n});\n","/**\n * Sortable lists\n * @module Ink.UI.SortableList_1\n * @version 1\n */\n\nInk.createModule('Ink.UI.SortableList', '1', ['Ink.UI.Common_1','Ink.Dom.Css_1','Ink.Dom.Event_1','Ink.Dom.Element_1','Ink.Dom.Selector_1'], function( Common, Css, Events, Element, Selector ) {\n 'use strict';\n var hasTouch = (('ontouchstart' in window) || // html5 browsers\n (navigator.maxTouchPoints > 0) || // future IE\n (navigator.msMaxTouchPoints > 0));\n\n /**\n * Adds sortable behaviour to any list.\n * \n * @class Ink.UI.SortableList\n * @constructor\n * @version 1\n * @param {String|DOMElement} selector\n * @param {String} [options.placeholderClass] CSS class added to the \"ghost\" element being dragged around. Defaults to 'placeholder'.\n * @param {String} [options.draggedClass] CSS class added to the original element being dragged around. Defaults to 'hide-all'.\n * @param {String} [options.draggingClass] CSS class added to the html element when the user is dragging. Defaults to 'dragging'.\n * @param {String} [options.dragSelector] CSS selector for the drag enabled nodes. Defaults to 'li'.\n * @param {String} [options.handleSelector] CSS selector for the drag handle. If present, you can only drag nodes by this selector.\n * @param {String} [options.moveSelector] CSS selector to validate a node move. If present, you can only move nodes inside this selector.\n * @param {Boolean} [options.swap] Flag to swap dragged element and target element instead of reordering it.\n * @param {Boolean} [options.cancelMouseOut] Flag to cancel draggin if mouse leaves the container element.\n * @param {Function} [options.onDrop] Callback to be executed after dropping an element. Receives { droppedElement: DOMElement } as an argument.\n *\n * @sample Ink_UI_SortableList_1.html\n */\n function SortableList() {\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n SortableList._name = 'SortableList_1';\n\n SortableList._optionDefinition = {\n 'placeholderClass': ['String', 'placeholder'],\n 'draggedClass': ['String', 'hide-all'],\n 'draggingClass': ['String', 'dragging'],\n 'dragSelector': ['String', 'li'],\n 'dragObject': ['String', null], // Deprecated. Use handleSelector instead.\n 'handleSelector': ['String', null],\n 'moveSelector': ['String', false],\n 'swap': ['Boolean', false],\n 'cancelMouseOut': ['Boolean', false],\n 'onDrop': ['Function', function(){}]\n };\n\n SortableList.prototype = {\n /**\n * Init function called by the constructor.\n * \n * @method _init\n * @private\n */\n _init: function() {\n if (this._options.dragObject != null) {\n // [3.0.0] Remove this deprecation notice and stop providing backwards compatibility\n Ink.warn('Ink.UI.SortableList: options.dragObject is now deprecated. ' +\n 'Please use options.handleSelector instead.');\n this._options.handleSelector =\n this._options.handleSelector || this._options.dragObject;\n }\n\n this._handlers = {\n down: Ink.bind(this._onDown, this),\n move: Ink.bind(this._onMove, this),\n up: Ink.bind(this._onUp, this)\n };\n\n this._isMoving = false;\n\n this._down = hasTouch ? 'touchstart mousedown' : 'mousedown';\n this._move = hasTouch ? 'touchmove mousemove' : 'mousemove';\n this._up = hasTouch ? 'touchend mouseup' : 'mouseup';\n\n this._observe();\n },\n\n /**\n * Sets the event handlers.\n * \n * @method _observe\n * @private\n */\n _observe: function() {\n Events.on(this._element, this._down, this._options.dragSelector, this._handlers.down);\n Events.on(this._element, this._move, this._options.dragSelector, this._handlers.move);\n if(this._options.cancelMouseOut) {\n Events.on(this._element, 'mouseleave', Ink.bind(this.stopMoving, this));\n }\n Events.on(document.documentElement, this._up, this._handlers.up);\n },\n\n /**\n * Mousedown or touchstart handler\n * \n * @method _onDown\n * @param {Event} ev\n * @private\n */\n _onDown: function(ev) {\n if (this._isMoving || this._placeholder) { return; }\n if(this._options.handleSelector && !Selector.matchesSelector(ev.target, this._options.handleSelector)) { return; }\n var tgtEl = ev.currentTarget;\n this._isMoving = tgtEl;\n this._placeholder = tgtEl.cloneNode(true);\n this._movePlaceholder(tgtEl);\n this._addMovingClasses();\n return false;\n },\n\n /**\n * Mousemove or touchmove handler\n * \n * @method _onMove\n * @param {Event} ev\n * @private\n */\n _onMove: function(ev) {\n var target = ev.currentTarget;\n\n // Touch events give you the element where the finger touched first,\n // not the element under it like mouse events.\n if (ev.type === 'touchmove') {\n var touch = ev.touches[0];\n target = document.elementFromPoint(touch.clientX, touch.clientY);\n target = Element.findUpwardsBySelector(target, this._options.dragSelector);\n }\n\n this.validateMove(target);\n ev.preventDefault();\n },\n\n /**\n * Mouseup or touchend handler\n * \n * @method _onUp\n * @param {Event} ev\n * @private\n */\n _onUp: function(ev) {\n if (!this._isMoving || !this._placeholder) { return; }\n if (ev.currentTarget === this._isMoving) { return; }\n if (ev.currentTarget === this._placeholder) { return; }\n Element.insertBefore(this._isMoving, this._placeholder);\n this.stopMoving();\n this._options.onDrop.call(this, { droppedElement: ev.currentTarget });\n return false;\n },\n\n /**\n * Adds the CSS classes to interactive elements\n * \n * @method _addMovingClasses\n * @private\n */\n _addMovingClasses: function(){\n Css.addClassName(this._placeholder, this._options.placeholderClass);\n Css.addClassName(this._isMoving, this._options.draggedClass);\n Css.addClassName(document.documentElement, this._options.draggingClass);\n },\n\n /**\n * Removes the CSS classes from interactive elements\n * \n * @method _removeMovingClasses\n * @private\n */\n _removeMovingClasses: function(){\n if(this._isMoving) { Css.removeClassName(this._isMoving, this._options.draggedClass); }\n if(this._placeholder) { Css.removeClassName(this._placeholder, this._options.placeholderClass); }\n Css.removeClassName(document.documentElement, this._options.draggingClass);\n },\n\n /**\n * Moves the placeholder element relative to the target element\n * \n * @method _movePlaceholder\n * @param {Element} target_position\n * @private\n */\n _movePlaceholder: function(target){\n var placeholder = this._placeholder,\n target_position,\n placeholder_position,\n from_top,\n from_left;\n if(!placeholder) {\n Element.insertAfter(placeholder, target);\n } else if(this._options.swap){\n Element.insertAfter(placeholder, target);\n Element.insertBefore(target, this._isMoving);\n Element.insertBefore(this._isMoving, placeholder);\n } else {\n target_position = Element.offset(target);\n placeholder_position = Element.offset(this._placeholder);\n from_top = target_position[1] > placeholder_position[1];\n from_left = target_position[0] > placeholder_position[0];\n if( ( from_top && from_left ) || ( !from_top && !from_left ) ) {\n Element.insertBefore(placeholder, target);\n } else {\n Element.insertAfter(placeholder, target);\n }\n Element.insertBefore(this._isMoving, placeholder);\n }\n },\n\n /**************\n * PUBLIC API *\n **************/\n\n /**\n * Unregisters the component and removes its markup\n * \n * @method destroy\n * @public\n */\n destroy: Common.destroyComponent,\n\n /**\n * Visually stops moving. \n * Removes the placeholder as well as the styling classes.\n * \n * @method _movePlaceholder\n * @public\n */\n stopMoving: function(){\n this._removeMovingClasses();\n Element.remove(this._placeholder);\n this._placeholder = false;\n this._isMoving = false;\n },\n\n /**\n * Validate a move.\n * This method is used by the move handler\n * \n * @method _movePlaceholder\n * @param {Element} elem\n * @public\n */\n validateMove: function(elem){\n if (!elem || !this._isMoving || !this._placeholder) { return; }\n if (elem === this._placeholder) { return; }\n if (elem === this._isMoving) { return; }\n if(!this._options.moveSelector || Selector.matchesSelector(elem, this._options.moveSelector)){\n this._movePlaceholder(elem);\n } else {\n this.stopMoving(); \n }\n }\n\n };\n\n Common.createUIComponent(SortableList);\n\n return SortableList;\n});","/**\n * Highlight elements as you scroll\n * @module Ink.UI.Spy_1\n * @version 1\n */\nInk.createModule('Ink.UI.Spy', '1', ['Ink.UI.Common_1','Ink.Dom.Event_1','Ink.Dom.Css_1','Ink.Dom.Element_1','Ink.Dom.Selector_1'], function(Common, Event, Css, Element, Selector ) {\n 'use strict';\n\n // Maps a spy target (EG a menu with links inside) to spied instances.\n var spyTargets = [\n // [target, [spied, spied, spied...]], ...\n ];\n\n function targetIndex(target) {\n for (var i = 0, len = spyTargets.length; i < len; i++) {\n if (spyTargets[i][0] === target) {\n return i;\n }\n }\n return null;\n }\n\n function addSpied(spied, target) {\n var index = targetIndex(target);\n\n if (index === null) {\n spyTargets.push([target, [spied]]);\n } else {\n spyTargets[index][1].push(spied);\n }\n }\n\n var observingOnScroll = false;\n function observeOnScroll() {\n if (!observingOnScroll) {\n observingOnScroll = true;\n Event.observe(document, 'scroll', Event.throttle(onScroll, 300));\n }\n }\n\n function onScroll() {\n for (var i = 0, len = spyTargets.length; i < len; i++) {\n onScrollForTarget(spyTargets[i][0], spyTargets[i][1]);\n }\n }\n\n function onScrollForTarget(target, spied) {\n var activeEl = findActiveElement(spied);\n\n // This selector finds li's to deactivate\n var toDeactivate = Selector.select('li.active', target);\n for (var i = 0, total = toDeactivate.length; i < total; i++) {\n Css.removeClassName(toDeactivate[i], 'active');\n }\n\n if (activeEl === null) {\n return;\n }\n\n // The link which should be activated has a \"href\" ending with \"#\" + name or id of the element\n var menuLinkSelector = 'a[href$=\"#' + (activeEl.name || activeEl.id) + '\"]';\n\n var toActivate = Selector.select(menuLinkSelector, target);\n for (i = 0, total = toActivate.length; i < total; i++) {\n Css.addClassName(Element.findUpwardsByTag(toActivate[i], 'li'), 'active');\n }\n }\n\n function findActiveElement(spied) {\n /* \n * Find the element above the top of the screen, but closest to it.\n * _____ \n * |_____| element 1 (active element)\n *\n * ------------------------ \n * | _____ |\n * | | | element 2 |\n * | | | |\n * | |_____| |\n * ------- Viewport ------- \n */\n\n // Remember that getBoundingClientRect returns coordinates\n // relative to the top left corner of the screen.\n //\n // So checking if it's < 0 is used to tell if\n // the element is above the top of the screen.\n var closest = -Infinity;\n var closestIndex;\n var bBox;\n for( var i = 0, total = spied.length; i < total; i++ ){\n bBox = spied[i].getBoundingClientRect();\n if (bBox.top <= 0 && bBox.top > closest) {\n closest = bBox.top;\n closestIndex = i;\n }\n }\n if (closestIndex === undefined) {\n return null;\n } else {\n return spied[closestIndex];\n }\n }\n\n /**\n * Spy is an UI component which tells the user which section is currently visible.\n * Spy can be used to highlight a menu item for the section which is visible to the user.\n * You need two things: A menu element (which contains your links inside `li` tags), and an element containing your section's content.\n\t * The links must be inside `li` tags. These will get the 'active' class, to signal which item is currently visible. In your CSS you need to add styling for this class.\n * To use Ink.UI.Spy for more than one section, loop through your sections (as you see in the sample below), or just load `autoload.js` and set add the `data-spy=\"true\"` attribute to your sections.\n * The currently visible element's corresponding link in the menu gets the 'visible' class added to it.\n *\n * @class Ink.UI.Spy\n * @constructor\n * @version 1\n * @param {String|DOMElement} selector\n * @param {Object} [options] Options\n * @param {DOMElement|String} options.target Target menu where the spy will highlight the right option.\n *\n * @sample Ink_UI_Spy_1.html\n */\n function Spy(){\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n Spy._name = 'Spy_1';\n\n Spy._optionDefinition = {\n target: ['Element', undefined],\n activeClass: ['String', 'active'] // [todo] Spy#_options.activeClass\n };\n\n Spy.prototype = {\n /**\n * Init function called by the constructor\n * \n * @method _init\n * @private\n */\n _init: function() {\n addSpied(this._element, this._options.target);\n observeOnScroll();\n onScroll();\n }\n };\n\n Common.createUIComponent(Spy);\n\n return Spy;\n\n});\n","/**\n * Stacking items in columns\n * @module Ink.UI.Stacker_1\n * @version 1\n **/\n\nInk.createModule('Ink.UI.Stacker', 1, ['Ink.UI.Common_1', 'Ink.Dom.Event_1', 'Ink.Dom.Element_1'], function(Common, InkEvent, InkElement) {\n 'use strict';\n\nfunction Stacker() {\n Common.BaseUIComponent.apply(this, arguments);\n}\n\nStacker._name = 'Stacker_1';\n\nStacker._optionDefinition = {\n column: ['String', '.stacker-column'],\n item: ['String', '.stacker-item'],\n\n // [3.0.0] review this when we have info about our breakpoints from the CSS\n customBreakPoints: ['Object', null], // Must be: {xlarge: {max: 9999, min: 1281, cols: 5}, large:{max:1280, min:1001, cols:4} medium:{max:1000, min:801,cols:3}, ...etc..}\n largeMax: ['Number', Number.MAX_VALUE],\n largeMin: ['Number', 961],\n mediumMax: ['Number', 960],\n mediumMin: ['Number', 651],\n smallMax: ['Number', 650],\n smallMin: ['Number', 0],\n\n largeCols: ['Integer', 3],\n mediumCols: ['Integer', 2],\n smallCols: ['Integer', 1],\n\n isOrdered: ['Boolean', true],\n onRunCallback: ['Function', null],\n onResizeCallback: ['Function', null],\n onAPIReloadCallback: ['Function', null]\n};\n\nStacker.prototype = {\n /**\n * This module combines several stacks of items together, in smaller screen sizes.\n *\n * The purpose is to have several stacks of items which may have different heights and as such cannot be used because of `float: left` quirks.\n *\n * For example, when you have three different columns of information:\n *\n * [col. A: 1] [col. B: 1] [col. C: 1]\n * [col. B: 2] [col. C: 2] [col. C: 2]\n *\n * and the screen resizes and you need a layout of 2 columns, Stacker reorders the stacks so that you get:\n *\n * [col. A: 1] [col. B: 1]\n * [col. C: 1] [col. A: 2]\n * [col. B: 2] [col. C: 2]\n * \n * Note: If you just want to use a different amount of columns for your items in several viewports, but these items are guaranteed to have a fixed height, don't use this module. Use the `small-*`, `medium-*` and `large-*` classes instead.\n *\n * @class Ink.UI.Stacker_1\n *\n * @constructor\n * @param {DOMElement|String} [container] Element which contains the stacks (identified by the options.column selector)\n * @param {Object} [options] Options object.\n * @param {String} [options.column] Selector for the the columns inside the container element. Defaults to '.stacker-column'.\n * @param {String} [options.item] Selector for the items in your stack. Defaults to '.stacker-item'.\n * @param {Object} [options.customBreakPoints] Options for each breakpoint name. Use this if you have more breakpoints than Ink by default (`large`, `medium`, `small`)\n * @param {Object} [options.customBreakpoints.BREAKPOINT_NAME] Custom breakpoints object.\n * @param {String} options.customBreakpoints.BREAKPOINT_NAME.max Maximum screen size as seen in your media query\n * @param {String} options.customBreakpoints.BREAKPOINT_NAME.min Minimum screen size as seen in your media query\n * @param {String} options.customBreakpoints.BREAKPOINT_NAME.cols Column count for this size.\n * @param {Number} [options.largeMax] Upper bound of `large` breakpoint\n * @param {Number} [options.largeMin] Lower bound of `large` breakpoint. Defaults to 961.\n * @param {Number} [options.mediumMax] Upper bound of `medium` breakpoint. Defaults to 960.\n * @param {Number} [options.mediumMin] Lower bound of `medium` breakpoint. Defaults to 651.\n * @param {Number} [options.smallMax] Upper bound of `small` breakpoint. Defaults to 650.\n * @param {Number} [options.smallMin] Lower bound of `small` breakpoint\n *\n * @param {Integer} [options.largeCols] Number of columns in the `large` viewport. Defaults to 3.\n * @param {Integer} [options.mediumCols] Number of columns in the `medium` viewport. Defaults to 2.\n * @param {Integer} [options.smallCols] Number of columns in the `small` viewport. Defaults to 1.\n *\n * @param {Boolean} [options.isOrdered] When false, doesn't reorder stacks when combining them.\n * @param {Function} [options.onRunCallback] Called when instantiated.\n * @param {Function} [options.onResizeCallback] Called when the window resizes.\n * @param {Function} [options.onAPIReloadCallback] Called when the reload function executes.\n *\n * @sample Ink_UI_Stacker_1.html\n **/\n _init: function() {\n this._aList = []; \n\n this._curLayout = 'large';\n\n // [todo] is this needed?\n this._runFirstTime = false;\n\n this._getPageItemsToList();\n\n if(this._canApplyLayoutChange() || !this._runFirstTime) {\n this._runFirstTime = true;\n this._applyLayoutChange();\n if(typeof(this._options.onRunCallback) === 'function') {\n this._options.onRunCallback(this._curLayout);\n }\n }\n this._addEvents();\n },\n\n /**\n * Adds an item to the end of your stacks.\n * Call `reloadItems()` when you are done adding items.\n * @method addItem\n * @param {DOMElement} item Element\n **/\n addItem: function(item) {\n this._aList.push(item);\n },\n\n /**\n * Updates the layout of your items.\n * Call this method after adding items or changing their dimensions. This method is automatically called when the window resizes.\n *\n * @method reloadItems\n **/\n reloadItems: function() {\n this._applyLayoutChange();\n if(typeof(this._options.onAPIReloadCallback) === 'function') {\n this._options.onAPIReloadCallback(this._curLayout);\n }\n },\n\n _addEvents: function() {\n InkEvent.observe(window, 'resize', Ink.bindEvent(this._onResize, this));\n },\n\n _onResize: function() {\n if(this._canApplyLayoutChange()) {\n this._removeDomItems();\n this._applyLayoutChange();\n if(typeof(this._options.onResizeCallback) === 'function') {\n this._options.onResizeCallback(this._curLayout);\n }\n }\n },\n\n _setCurLayout: function() {\n var viewportWidth = InkElement.viewportWidth();\n if(this._options.customBreakpoints && typeof(this._options.customBreakPoints) === 'object') {\n for(var prop in this._options.customBreakPoints) {\n if(this._options.customBreakPoints.hasOwnProperty(prop)) {\n if(viewportWidth >= Number(this._options.customBreakPoints[prop].min) && viewportWidth <= Number(this._options.customBreakPoints[prop].max) && this._curLayout !== prop) {\n this._curLayout = prop;\n return;\n } \n }\n }\n } else {\n if(viewportWidth <= Number(this._options.largeMax) && viewportWidth >= Number(this._options.largeMin) && this._curLayout !== 'large') {\n this._curLayout = 'large';\n } else if(viewportWidth >= Number(this._options.mediumMin) && viewportWidth <= Number(this._options.mediumMax) && this._curLayout !== 'medium') {\n this._curLayout = 'medium';\n } else if(viewportWidth >= Number(this._options.smallMin) && viewportWidth <= Number(this._options.smallMax) && this._curLayout !== 'small') {\n this._curLayout = 'small';\n }\n }\n },\n\n _getColumnsToShow: function() {\n if(this._options.customBreakPoints && typeof(this._options.customBreakPoints) === 'object') {\n return Number(this._options.customBreakPoints[this._curLayout].cols);\n } else {\n return Number(this._options[this._curLayout+'Cols']);\n }\n },\n\n _canApplyLayoutChange: function() {\n var curLayout = this._curLayout;\n this._setCurLayout();\n if(curLayout !== this._curLayout) {\n return true;\n }\n return false;\n },\n\n _getPageItemsToList: function() {\n this._aColumn = Ink.ss(this._options.column, this._element);\n var totalCols = this._aColumn.length;\n var index = 0;\n if(totalCols > 0) {\n for(var i=0; i < this._aColumn.length; i++) {\n var aItems = Ink.ss(this._options.item, this._aColumn[i]);\n for(var j=0; j < aItems.length; j++) {\n if(this._options.isOrdered) {\n index = i + (j * totalCols);\n }\n this._aList[index] = aItems[j];\n if(!this._options.isOrdered) {\n index++;\n }\n //aItems[j].style.height = (100 + (Math.random() * 100))+'px';\n aItems[j].parentNode.removeChild(aItems[j]);\n }\n }\n if(this._aList.length > 0 && this._options.isOrdered) {\n var aNewList = [];\n for(var ii=0; ii < this._aList.length; ii++) {\n if(typeof(this._aList[ii]) !== 'undefined') {\n aNewList.push(this._aList[ii]);\n }\n }\n this._aList = aNewList;\n }\n }\n }, \n\n _removeDomItems: function() {\n var totalCols = this._aColumn.length;\n if(totalCols > 0) {\n for(var i=0; i < totalCols; i++) {\n var aItems = Ink.ss(this._options.item, this._aColumn[i]);\n for(var j=aItems.length - 1; j >= 0; j--) {\n aItems[j].parentNode.removeChild(aItems[j]);\n }\n }\n }\n },\n\n _applyLayoutChange: function() {\n var totalCols = this._getColumnsToShow();\n var totalItems = this._aList.length;\n var index = 0;\n var countCol = 0;\n if(totalCols > 0) {\n while(countCol < totalCols) {\n this._aColumn[countCol].appendChild(this._aList[index]);\n index++;\n countCol++;\n if(index === totalItems) {\n return;\n }\n if(countCol === totalCols) {\n countCol = 0;\n }\n }\n }\n }\n};\n\nCommon.createUIComponent(Stacker);\n\nreturn Stacker;\n\n});\n","/**\n * Stick elements to the viewport\n * @module Ink.UI.Sticky_1\n * @version 1\n */\nInk.createModule('Ink.UI.Sticky', '1', ['Ink.UI.Common_1','Ink.Dom.Event_1','Ink.Dom.Element_1','Ink.Dom.Css_1'], function(Common, Event, Element, Css) {\n 'use strict';\n\n /**\n * Ink.UI.Sticky makes an element \"stick\" to the screen and stay in the same place as the user scrolls. To use it, just select an element as you create the Sticky. As you scroll past it, it will stick to the top of the screen.\n * The `activateInLayouts` option controls in what layouts this behaviour happens. By default, it is disabled for the `small` and `tiny` layouts. Pass a comma-separated string to choose just the layouts you need. You can use the `offsetTop` option if you want it to keep some distance from the top of the screen. To avoid it going under the footer of your page, pass a selector to your footer as the `bottomElement` option.\n *\n * @class Ink.UI.Sticky\n * @constructor\n * @version 1\n * @param {String|DOMElement} selector Element or selector\n * @param {Object} [options] Options Options object.\n * @param {Number} [options.offsetBottom] Number of pixels of distance from the bottomElement. Defaults to 0.\n * @param {Number} [options.offsetTop] Number of pixels of distance from the topElement. Defaults to 0.\n * @param {Boolean} [options.inlineDimensions] Set to false to disable setting inline CSS dimensions. Use this if you want to use CSS to define your own dimensions. Defaults to true.\n * @param {Boolean} [options.inlinePosition] Set to false to disable setting inline CSS positions. Use this if you want to use CSS to define your own positioning. Defaults to true.\n * @param {String} [options.wrapperClass] CSS class for the wrapper element. Defaults to 'ink-sticky-wrapper'.\n * @param {String} [options.stickyClass] CSS class to stick the element to the screen. Defaults to 'ink-sticky-stuck'.\n * @param {String} [options.topElement] CSS Selector that specifies a top element with which the component could collide.\n * @param {String} [options.bottomElement] CSS Selector that specifies a bottom element with which the component could collide.\n * @param {Array|String} [options.activateInLayouts] Layouts in which the sticky behaviour is present. Pass an array or comma-separated string. Defaults to 'tiny,small,medium,large,xlarge'.\n *\n * @sample Ink_UI_Sticky_1.html\n */\n function Sticky(){\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n Sticky._name = 'Sticky_1';\n\n Sticky._optionDefinition = {\n offsetBottom: ['Integer', 0],\n offsetTop: ['Integer', 0],\n topElement: ['Element', null],\n wrapperClass: ['String', 'ink-sticky-wrapper'],\n stickyClass: ['String', 'ink-sticky-stuck'],\n inlineDimensions: ['Boolean', true],\n inlinePosition: ['Boolean', true],\n bottomElement: ['Element', null],\n activateInLayouts: ['String', 'tiny,small,medium,large,xlarge']\n };\n\n Sticky.prototype = {\n\n /**\n * Init function called by the constructor\n *\n * @method _init\n * @private\n */\n _init: function() {\n // Because String#indexOf is compatible with lt IE8 but not Array#indexOf\n this._options.activateInLayouts = this._options.activateInLayouts.toString();\n\n this._dims = null; // force a recalculation of the dimensions later\n\n this._options.offsetTop = parseInt(this._options.offsetTop, 10) || 0;\n this._options.offsetBottom = parseInt(this._options.offsetBottom, 10) || 0;\n\n if (this._options.topElement) {\n this._options.topElement = Common.elOrSelector(this._options.topElement, 'Top Element');\n }\n if (this._options.bottomElement) {\n this._options.bottomElement = Common.elOrSelector(this._options.bottomElement, 'Sticky bottom Element');\n }\n\n this._wrapper = Element.create('div', { className: this._options.wrapperClass });\n Element.wrap(this._element, this._wrapper);\n\n var scrollTarget = document.addEventListener ? document : window;\n this._onScroll = Ink.bind(Event.throttle(this._onScroll, 33), this); // Because this is called directly.\n Event.observe( scrollTarget, 'scroll', this._onScroll );\n Event.observe( window, 'resize', Ink.bindEvent(Event.throttle(this._onResize, 100), this) );\n this._onScroll();\n },\n\n /**\n * Returns whether the sticky is disabled in the current view\n *\n * @method isDisabledInLayout\n * @private\n */\n _isDisabledInLayout: function () {\n var currentLayout = Common.currentLayout();\n if (!currentLayout) { return false; }\n return this._options.activateInLayouts.indexOf(currentLayout) === -1;\n },\n\n /**\n * Scroll handler.\n *\n * @method _onScroll\n * @private\n */\n _onScroll: function(){\n var dims = this._getDims();\n var scrollHeight = Element.scrollHeight();\n\n var unstick = this._isDisabledInLayout() ||\n scrollHeight <= dims.top - this._options.offsetTop ||\n (this._options.topElement && this._options.topElement.getBoundingClientRect().bottom + this._options.offsetTop > 0);\n\n if( unstick ) {\n // We're on top, no sticking. position:static is the \"normal\" position.\n this._unstick();\n return;\n }\n\n // If we stick it now, what will be its boundingClientRect.bottom ?\n var bottomOfSticky = this._options.offsetTop + dims.height + Element.scrollHeight();\n var maxBottomOfSticky = document.body.scrollHeight;\n\n if (this._options.bottomElement) {\n maxBottomOfSticky =\n this._options.bottomElement.getBoundingClientRect().top +\n Element.scrollHeight();\n }\n\n maxBottomOfSticky -= this._options.offsetBottom;\n\n if ( bottomOfSticky < maxBottomOfSticky ) {\n // Stick to screen!\n this._stickTo('screen');\n } else {\n // Stick to bottom\n this._stickTo('bottom');\n }\n },\n\n /**\n * Have the sticky stick nowhere, to the screen, or to the bottom.\n *\n * @method _stickTo\n * @private\n */\n _stickTo: function (where) {\n var style = this._element.style;\n var dims = this._getDims();\n\n Css.addClassName(this._element, this._options.stickyClass);\n this._wrapper.style.height = dims.height + 'px';\n\n this._inlineDimensions(dims.height + 'px', dims.width + 'px');\n\n if (this._options.inlinePosition === false) {\n return;\n }\n\n style.left = dims.left + 'px';\n\n if (where === 'screen') {\n style.bottom = null;\n style.top = this._options.offsetTop + 'px';\n } else if (where === 'bottom') {\n // Distance between bottom of sticky and bottom of document\n var bottom = this._getBottomOffset();\n\n // Distance between bottom of viewport and bottom of document\n var bottomOfViewport = Element.scrollHeight() + Element.viewportHeight();\n var toBottomOfDocument = Element.pageHeight() - bottomOfViewport;\n\n style.bottom = bottom - toBottomOfDocument + 'px';\n style.top = 'auto';\n }\n },\n\n /**\n * \"unstick\" the sticky from the screen or bottom of the document\n * @method _unstick\n * @private\n */\n _unstick: function () {\n Css.removeClassName(this._element, this._options.stickyClass);\n // deinline dimensions of our root element\n this._inlineDimensions(null, null);\n\n // deinline the position of our root element\n if (this._options.inlinePosition) {\n this._element.style.left = null;\n this._element.style.top = null;\n this._element.style.bottom = null;\n }\n\n // deinline dimensions of wrapper\n this._wrapper.style.height = null;\n this._wrapper.style.width = null;\n\n // Break the \"getDims\" cache\n this._dims = null;\n },\n\n /**\n * Resize handler\n *\n * @method _onResize\n * @private\n */\n _onResize: function(){\n this._dims = null; // Blow the cache so _getDims recalculates\n this._onScroll();\n },\n\n /**\n * Recalculate the \"dims\" cache, or get it.\n *\n * The \"dims\" cache is to be set to null when the element is liable to have changed dimensions\n *\n * (eg: on resize)\n *\n **/\n _getDims: function () {\n if (this._dims !== null) { return this._dims; }\n\n var style = this._element.style;\n\n // We unstick the sticky so we can measure.\n var oldPosition = style.position;\n var oldWidth = style.width;\n\n style.position = 'static'; // [todo] this should be a class toggle\n style.width = null;\n\n var dimensionsInStatic = Element.outerDimensions(this._element);\n var rect = this._wrapper.getBoundingClientRect();\n this._dims = {\n height: dimensionsInStatic[1],\n width: dimensionsInStatic[0],\n left: rect.left + Element.scrollWidth(),\n top: rect.top + Element.scrollHeight()\n };\n\n style.position = oldPosition;\n style.width = oldWidth;\n\n return this._dims;\n },\n\n /**\n * Set style.height and style.width, but not if options.inlineDimensions === false\n *\n * @method _inlineDimensions\n * @private\n */\n _inlineDimensions: function (height, width) {\n if (this._options.inlineDimensions) {\n this._element.style.height = height;\n this._element.style.width = width;\n }\n },\n\n /**\n * Get the distance between the bottom of the element and the bottom of the page\n *\n * @method _getBottomOffset\n * @private\n */\n _getBottomOffset: function () {\n var bottom = this._options.offsetBottom;\n if (this._options.bottomElement) {\n bottom += Element.pageHeight() -\n Element.offsetTop(this._options.bottomElement);\n }\n return bottom;\n }\n };\n\n Common.createUIComponent(Sticky);\n\n return Sticky;\n\n});\n","/**\n * Swipe gestures\n * @module Ink.UI.Swipe_1\n * @version 1\n */\nInk.createModule('Ink.UI.Swipe', '1', ['Ink.Dom.Event_1', 'Ink.Dom.Element_1', 'Ink.UI.Common_1'], function(InkEvent, InkElement, Common) {\n 'use strict';\n\n /**\n * Subscribe swipe gestures.\n *\n * Supports filtering swipes be any combination of the criteria supported in the options.\n *\n * -----\n *\n * Arguments received by the callbacks\n * -----------------------------------\n *\n * The `onStart`, `onMove`, and `onEnd` options receive as argument an object containing:\n *\n * - `event`: the DOMEvent object\n * - `element`: the target element\n * - `Instance`: the `Ink.UI.Swipe_1` instance\n * - `position`: `Array` with `[x, y]` coordinates of current position\n * - `dt`: Time passed between now and the first event (onMove only)\n * - `gesture`: an Array containing [x,y] coordinates of every touchmove event received (only if options.storeGesture is enabled) (onEnd only)\n * - `time`: an Array containing all the `dt` values for every touchmove event (onEnd only)\n * - `overallMovement`: X and Y distance traveled by the touch movement (`[x, y]`) (onEnd only)\n * - `overallTime`: total time passed (onEnd only)\n *\n * @class Ink.UI.Swipe\n * @constructor\n * @param {String|DOMElement} el Element or Selector\n * @param {Object} options Options Object\n * @param {Function} [options.onEnd] Callback function for the `touchend` event. Gets all the gesture information, and is filtered by min/max Dist and Duration options (see below)\n * @param {Function} [options.onStart] Callback function for `touchstart` event.\n * @param {Function} [options.onMove] Callback function for every `touchmove` event. Gets current gesture information.\n * @param {Number} [options.minDist] Minimum allowed distance, in pixels.\n * @param {Number} [options.maxDist] Maximum allowed distance, in pixels.\n * @param {Number} [options.minDuration] Minimum allowed duration, in seconds.\n * @param {Number} [options.maxDuration] Maximum allowed duration, in seconds.\n * @param {String} [options.axis] If either 'x' or 'y' is passed, only swipes where the dominant axis is the given one trigger the callback\n * @param {String} [options.storeGesture] If to store gesture information and provide it to the callback. Defaults to true.\n * @param {String} [options.stopEvents] Flag to stop (default and propagation) of the received events. Defaults to true.\n *\n *\n * @sample Ink_UI_Swipe_1.html\n */\n function Swipe() {\n if (typeof arguments[1] === 'function') {\n arguments[1] = { onEnd: arguments[1] };\n }\n\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n Swipe._name = 'Swipe_1';\n\n Swipe._optionDefinition = {\n onEnd: ['Function', undefined],\n onStart: ['Function', undefined],\n onMove: ['Function', undefined],\n minDist: ['Number', undefined], // in pixels\n maxDist: ['Number', undefined],\n minDuration: ['Number', undefined], // in seconds\n maxDuration: ['Number', undefined],\n axis: ['String', undefined], // x | y\n storeGesture: ['Boolean', false],\n stopEvents: ['Boolean', true]\n };\n\n Swipe.prototype = {\n _supported: ('ontouchstart' in document.documentElement),\n\n _init: function() {\n this._handlers = {\n down: Ink.bindEvent(this._onDown, this),\n move: Ink.bindEvent(this._onMove, this),\n up: Ink.bindEvent(this._onUp, this)\n };\n\n var db = document.body;\n InkEvent.observe(db, 'touchstart', this._handlers.down);\n if (this._options.storeGesture || this._options.onMove) {\n InkEvent.observe(db, 'touchmove', this._handlers.move);\n }\n InkEvent.observe(db, 'touchend', this._handlers.up);\n this._isOn = false;\n },\n\n _isMeOrParent: function(el, parentEl) {\n if (!el) {return;}\n do {\n if (el === parentEl) { return true; }\n el = el.parentNode;\n } while (el);\n return false;\n },\n\n _pushGesture: function (coords, dt) {\n if (this._options.storeGesture) {\n this._gesture.push(coords);\n this._time.push(dt);\n }\n },\n\n _onDown: function(event) {\n if (event.changedTouches.length !== 1) { return; }\n if (!this._isMeOrParent(event.target, this._element)) { return; }\n\n if( this._options.stopEvents === true ){\n InkEvent.stop(event);\n }\n event = event.changedTouches[0];\n this._isOn = true;\n this._target = event.target;\n\n this._t0 = +new Date();\n this._p0 = [event.pageX, event.pageY];\n\n if (this._options.storeGesture) {\n this._gesture = [];\n this._time = [];\n }\n\n this._pushGesture(this._p0, 0);\n\n if (this._options.onStart) {\n this._options.onStart({\n event: event,\n element: this._element,\n instance: this,\n position: this._p0,\n dt: 0\n });\n }\n },\n\n _onMove: function(event) {\n if (!this._isOn || event.changedTouches.length !== 1) { return; }\n if( this._options.stopEvents === true ) {\n InkEvent.stop(event);\n }\n\n event = event.changedTouches[0];\n var t1 = +new Date();\n var dt = (t1 - this._t0);\n\n var gesture = [event.pageX, event.pageY];\n\n this._pushGesture(gesture, dt);\n\n if (this._options.onMove) {\n this._options.onMove({\n event: event,\n element: this._element,\n instance: this,\n position: gesture,\n dt: dt\n });\n }\n },\n\n _onUp: function(event) {\n if (!this._isOn || event.changedTouches.length !== 1) { return; }\n\n if( this._options.stopEvents === true ){\n InkEvent.stop(event);\n }\n event = event.changedTouches[0]; // TODO SHOULD CHECK IT IS THE SAME TOUCH\n this._isOn = false;\n\n var t1 = +new Date();\n var p1 = [event.pageX, event.pageY];\n var dt = (t1 - this._t0);\n var dr = [\n p1[0] - this._p0[0],\n p1[1] - this._p0[1]\n ];\n var dist = Math.sqrt(dr[0]*dr[0] + dr[1]*dr[1]);\n var axis = Math.abs(dr[0]) > Math.abs(dr[1]) ? 'x' : 'y';\n\n var o = this._options;\n if (o.minDist && dist < o.minDist) { return; }\n if (o.maxDist && dist > o.maxDist) { return; }\n if (o.minDuration && dt < o.minDuration) { return; }\n if (o.maxDuration && dt > o.maxDuration) { return; }\n if (o.axis && axis !== o.axis) { return; }\n\n if (this._options.onEnd) {\n this._options.onEnd({\n event: event,\n element: this._element,\n instance: this,\n gesture: this._gesture,\n time: this._time,\n axis: axis,\n overallMovement: dr,\n overallTime: dt\n });\n }\n }\n };\n\n Common.createUIComponent(Swipe);\n\n return Swipe;\n});\n","/**\n * Sort and paginate tabular data\n * @module Ink.UI.Table_1\n * @version 1\n */\nInk.createModule('Ink.UI.Table', '1', ['Ink.Util.Url_1','Ink.UI.Pagination_1','Ink.Net.Ajax_1','Ink.UI.Common_1','Ink.Dom.Event_1','Ink.Dom.Css_1','Ink.Dom.Element_1','Ink.Dom.Selector_1','Ink.Util.Array_1','Ink.Util.String_1', 'Ink.Util.Json_1'], function(InkUrl,Pagination, Ajax, Common, Event, Css, Element, Selector, InkArray, InkString, Json) {\n 'use strict';\n\n var rNumber = /\\d/g;\n // Turn into a number, if we can. For sorting data which could be numeric or not.\n function maybeTurnIntoNumber(value) {\n if( !isNaN(value) && rNumber.test(value) ){\n return parseInt(value, 10);\n } else if( !isNaN(value) ){\n return parseFloat(value);\n }\n return value;\n }\n function cmp (a, b) {\n if( a === b ){\n return 0;\n }\n return ( ( a > b ) ? 1 : -1 );\n }\n // cmp function for comparing data which might be a number.\n function numberishEnabledCmp (a, b) {\n var aValue = maybeTurnIntoNumber(Element.textContent(a));\n var bValue = maybeTurnIntoNumber(Element.textContent(b));\n\n return cmp(aValue, bValue);\n }\n // Object.keys polyfill\n function keys(obj) {\n if (typeof Object.keys !== 'undefined') {\n return Object.keys(obj);\n }\n var ret = [];\n for (var k in obj) if (obj.hasOwnProperty(k)) {\n ret.push(k);\n }\n return ret;\n }\n\n /**\n * The Table component transforms the native/DOM table element into a sortable, paginated component.\n * You can use this component to display data from a JSON endpoint, or from table rows in the DOM. Displaying from the DOM is more practical, but sometimes you don't want to load everything at once (if you have a HUGE table). In those cases, you should configure Ink.UI.Table to get data from JSON endpoint.\n * To enable sorting, just set the `data-sortable` attribute of your table headers (they must be in the `thead` of the table) to \"true\". To enable pagination, you should pass either an `Ink.UI.Pagination` instance or a selector to create the Ink.UI.Pagination element on.\n *\n * @class Ink.UI.Table\n * @constructor\n * @version 1\n * @param {String|DOMElement} selector\n * @param {Object} [options] Options\n * @param {Number} [options.pageSize] Number of rows per page. Omit to avoid paginating.\n * @param {String} [options.endpoint] Endpoint to get the records via AJAX. Omit if you don't want to do AJAX\n * @param {Function} [options.createEndpointUrl] Callback to customise what URL the AJAX endpoint is at. Receives three arguments: base (the \"endpoint\" option), sort (`{ order: 'asc' or 'desc', field: fieldname }`) and page ({ page: page number, size: items per page })\n * @param {Function} [options.getDataFromEndPoint] Callback to allow the user to retrieve the data himself given an URL. Must accept two arguments: `url` and `callback`. This `callback` will take as a single argument a JavaScript object.\n * @param {Function} [options.processJSONRows] Retrieve an array of rows from the data which came from AJAX.\n * @param {Function} [options.processJSONHeaders] Get an object with all the headers' names as keys, and a { label, sortable } object as value. Example: `{col1: {label: \"Column 1\"}, col2: {label: \"Column 2\", sortable: true}`. Takes a single argument, the JSON response.\n * @param {Function} [options.processJSONRow] Process a row object before it gets on the table.\n * @param {Function} [options.processJSONField] Process the field data before putting it on the table. You can return HTML, a DOM element, or a string here. Arguments you receive: `(column, fieldData, rowIndex)`.\n * @param {Function} [options.processJSONField.FIELD_NAME] The same as processJSONField, but for a particular field.\n * @param {Function} [options.processJSONTotalRows] A callback where you have a chance to say how many rows are in the dataset (not only on this page) you have on the collection. You get as an argument the JSON response.\n * @param {Function} [options.getSortKey] A function taking a `{ columnIndex, columnName, data, element }` object and returning a value which serves as a sort key for the sorting operation. For example, if you want to sort by a `data-sort-key` atribute, set `getSortKey` to: function (cell) { return cell.element.getAttribute('data-sort-key'); }\n * @param {Function} [options.getSortKey.FIELD_NAME] Same as `options.getSortKey`, but for a particular field.\n * @param {Object} [options.tdClassNames] An object mapping each field to what classes it gets. Example: `{ name: \"large-10\", isBoss: \"hide-small\" }`\n * @param {Mixed} [options.pagination] Pagination instance, element or selector.\n * @param {Object} [options.paginationOptions] Override the options with which we instantiate the Ink.UI.Pagination.\n * @param {Boolean} [options.allowResetSorting] Allow sort order to be set to \"none\" in addition to \"ascending\" and \"descending\"\n * @param {String|Array} [options.visibleFields] Set of fields which get shown on the table\n *\n * @sample Ink_UI_Table_1.html\n */\n function Table(){\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n Table._name = 'Table_1';\n\n // Most processJSON* functions can just default to this.\n function sameSame(obj) { return obj; }\n\n Table._optionDefinition = {\n pageSize: ['Integer', null],\n caretUpClass: ['String', 'fa fa-caret-up'],\n caretDownClass: ['String', 'fa fa-caret-down'],\n endpoint: ['String', null],\n createEndpointUrl: ['Function', null /* default func uses above option */],\n getDataFromEndPoint: ['Function', null /* by default use plain ajax for JSON */],\n processJSONRows: ['Function', sameSame],\n processJSONRow: ['Function', sameSame],\n processJSONField: ['Function', sameSame],\n processJSONHeaders: ['Function', function (dt) { return dt.fields; }],\n processJSONTotalRows: ['Function', function (dt) { return dt.length || dt.totalRows; }],\n getSortKey: ['Function', null],\n pagination: ['Element', null],\n allowResetSorting: ['Boolean', false],\n visibleFields: ['String', null],\n tdClassNames: ['Object', {}],\n paginationOptions: ['Object', null]\n };\n\n Table.prototype = {\n _validate: function () {\n if( this._element.nodeName.toLowerCase() !== 'table' ){\n throw new Error('[Ink.UI.Table] :: The element is not a table');\n }\n },\n /**\n * Init function called by the constructor\n * \n * @method _init\n * @private\n */\n _init: function(){\n /**\n * Checking if it's in markup mode or endpoint mode\n */\n this._markupMode = !this._options.endpoint;\n\n if( this._options.visibleFields ){\n this._options.visibleFields = this._options.visibleFields.toString().split(/[, ]+/g);\n }\n\n this._thead = this._element.tHead || this._element.createTHead();\n this._headers = Selector.select('th', this._thead);\n\n /**\n * Initializing variables\n */\n this._handlers = {\n thClick: null\n };\n this._originalFields = [\n // field headers from the DOM\n ];\n this._sortableFields = {\n // Identifies which columns are sorted and how.\n // columnIndex: 'none'|'asc'|'desc'\n };\n this._originalData = this._data = [];\n this._pagination = null;\n this._totalRows = 0;\n\n this._handlers.thClick = Event.observeDelegated(this._element, 'click',\n 'thead th[data-sortable=\"true\"]',\n Ink.bindMethod(this, '_onThClick'));\n\n /**\n * If not is in markup mode, we have to do the initial request\n * to get the first data and the headers\n */\n if( !this._markupMode ) {\n /* Endpoint mode */\n this._getData( );\n } else /* Markup mode */ {\n this._resetSortOrder();\n this._addHeadersClasses();\n\n /**\n * Getting the table's data\n */\n this._data = Selector.select('tbody tr', this._element);\n this._originalData = this._data.slice(0);\n\n this._totalRows = this._data.length;\n\n /**\n * Set pagination if options tell us to\n */\n this._setPagination();\n }\n },\n\n /**\n * Add the classes in this._options.tdClassNames to our table headers.\n * @method _addHeadersClasses\n * @private\n */\n _addHeadersClasses: function () {\n var headerLabel;\n var classNames;\n for (var i = 0, len = this._headers.length; i < len; i++) {\n headerLabel = Element.textContent(this._headers[i]);\n classNames = this._options.tdClassNames[headerLabel];\n // TODO do not find header labels this way. But how?\n if (classNames) {\n Css.addClassName(this._headers[i], classNames);\n }\n }\n },\n\n /**\n * Click handler. This will mainly handle the sorting (when you click in the headers)\n * \n * @method _onThClick\n * @param {Event} event Event obj\n * @private\n */\n _onThClick: function( event ){\n var tgtEl = Event.element(event),\n paginated = this._options.pageSize !== undefined;\n\n Event.stop(event);\n\n var index = InkArray.keyValue(tgtEl, this._headers, true);\n var sortable = index !== false && this._sortableFields[index] !== undefined;\n\n if( !sortable ){\n return;\n }\n\n if( !this._markupMode && paginated ){\n this._invertSortOrder(index, false);\n } else {\n if ( (this._sortableFields[index] === 'desc') && this._options.allowResetSorting ) {\n this._setSortOrderOfColumn(index, null);\n this._data = this._originalData.slice(0);\n } else {\n this._invertSortOrder(index, true);\n }\n\n var tbody = Selector.select('tbody',this._element)[0];\n Common.cleanChildren(tbody);\n InkArray.each(this._data, Ink.bindMethod(tbody, 'appendChild'));\n\n if (this._pagination) {\n this._pagination.setCurrent(0);\n this._paginate(1);\n }\n }\n },\n\n _invertSortOrder: function (index, sortAndReverse) {\n var isAscending = this._sortableFields[index] === 'asc';\n\n for (var i = 0, len = this._headers.length; i < len; i++) {\n this._setSortOrderOfColumn(i, null);\n }\n\n if (sortAndReverse) {\n this._sort(index);\n if (isAscending) {\n this._data.reverse();\n }\n }\n\n this._setSortOrderOfColumn(index, !isAscending);\n },\n\n _setSortOrderOfColumn: function(index, up) {\n var header = this._headers[index];\n var caretHtml = [''];\n var order = 'none';\n\n if (up === true) {\n caretHtml = ['<i class=\"', this._options.caretUpClass, '\"></i>'];\n order = 'asc';\n } else if (up === false) {\n caretHtml = ['<i class=\"', this._options.caretDownClass, '\"></i>'];\n order = 'desc';\n }\n\n this._sortableFields[index] = order;\n header.innerHTML = Element.textContent(header) + caretHtml.join('');\n },\n\n /**\n * Applies and/or changes the CSS classes in order to show the right columns\n * \n * @method _paginate\n * @param {Number} page Current page\n * @private\n */\n _paginate: function( page ){\n if (!this._pagination) { return; }\n\n var pageSize = this._options.pageSize;\n\n // Hide everything except the items between these indices\n var firstIndex = (page - 1) * pageSize;\n var lastIndex = firstIndex + pageSize;\n\n InkArray.each(this._data, function(item, index){\n if (index >= firstIndex && index < lastIndex) {\n Css.removeClassName(item,'hide-all');\n } else {\n Css.addClassName(item,'hide-all');\n }\n });\n\n },\n\n /* register fields into this._originalFields, whether they come from JSON or a table.\n * @method _registerFieldNames\n * @private\n * @param [names] The field names in an array\n **/\n _registerFieldNames: function (names) {\n this._originalFields = [];\n\n InkArray.forEach(names, Ink.bind(function (field) {\n if( !this._fieldIsVisible(field) ){\n return; // The user deems this not to be necessary to see.\n }\n this._originalFields.push(field);\n }, this));\n },\n\n _fieldIsVisible: function (field) {\n return !this._options.visibleFields ||\n (this._options.visibleFields.indexOf(field) !== -1);\n },\n\n /**\n * Sorts by a specific column.\n * \n * @method _sort\n * @param {Number} index Column number (starting at 0)\n * @private\n */\n _sort: function( index ){\n // TODO this is THE worst way to declare field names. Incompatible with i18n and a lot of other things.\n var fieldName = Element.textContent(this._headers[index]);\n var keyFunction = this._options.getSortKey;\n\n if (keyFunction) {\n keyFunction =\n typeof keyFunction[fieldName] === 'function' ?\n keyFunction[fieldName] :\n typeof keyFunction === 'function' ?\n keyFunction :\n null;\n }\n\n var self = this;\n\n this._data.sort(function (trA, trB) {\n var elementA = Ink.ss('td', trA)[index];\n var elementB = Ink.ss('td', trB)[index];\n if (keyFunction) {\n return cmp(userKey(elementA), userKey(elementB));\n } else {\n return numberishEnabledCmp(elementA, elementB, index);\n }\n });\n\n function userKey(element) {\n return keyFunction.call(self, {\n columnIndex: index,\n columnName: fieldName,\n data: Element.textContent(element),\n element: element\n });\n }\n },\n\n /**\n * Assembles the headers markup\n *\n * @method _createHeadersFromJson\n * @param {Object} headers Key-value object that contains the fields as keys, their configuration (label and sorting ability) as value\n * @private\n */\n _createHeadersFromJson: function( headers ){\n this._registerFieldNames(keys(headers));\n\n if (this._thead.children.length) { return; }\n\n var tr = this._thead.insertRow(0);\n var th;\n\n for (var i = 0, len = headers.length; i < len; i++) {\n if (this._fieldIsVisible(headers[i])) {\n th = Element.create('th');\n th = this._createSingleHeaderFromJson(headers[i], th);\n tr.appendChild(th);\n this._headers.push(th);\n }\n }\n },\n\n _createSingleHeaderFromJson: function (header, th) {\n if (header.sortable) {\n th.setAttribute('data-sortable','true');\n }\n\n if (header.label){\n Element.setTextContent(th, header.label);\n }\n\n return th;\n },\n\n /**\n * Reset the sort order as marked on the table headers to \"none\"\n *\n * @method _resetSortOrder\n * @private\n */\n _resetSortOrder: function(){\n /**\n * Setting the sortable columns and its event listeners\n */\n for (var i = 0, len = this._headers.length; i < len; i++) {\n var dataset = Element.data( this._headers[i] );\n if (dataset.sortable && dataset.sortable.toString() === 'true') {\n this._sortableFields[i] = 'none';\n }\n }\n },\n\n /**\n * This method gets the rows from AJAX and places them as <tr> and <td>\n *\n * @method _createRowsFromJSON\n * @param {Object} rows Array of objects with the data to be showed\n * @private\n */\n _createRowsFromJSON: function( rows ){\n var tbody = Selector.select('tbody',this._element)[0];\n\n if( !tbody ){\n tbody = document.createElement('tbody');\n this._element.appendChild( tbody );\n } else {\n Element.setHTML(tbody, '');\n }\n\n this._data = [];\n var row;\n\n for (var trIndex in rows) {\n if (rows.hasOwnProperty(trIndex)) {\n row = this._options.processJSONRow(rows[trIndex]);\n this._createSingleRowFromJson(tbody, row, trIndex);\n }\n }\n\n this._originalData = this._data.slice(0);\n },\n\n _createSingleRowFromJson: function (tbody, row, rowIndex) {\n var tr = document.createElement('tr');\n tbody.appendChild( tr );\n for( var field in row ){\n if (row.hasOwnProperty(field)) {\n this._createFieldFromJson(tr, row[field], field, rowIndex);\n }\n }\n this._data.push(tr);\n },\n\n _createFieldFromJson: function (tr, fieldData, fieldName, rowIndex) {\n if (!this._fieldIsVisible(fieldName)) { return; }\n\n var processor =\n this._options.processJSONField[fieldName] || // per-field callback\n this._options.processJSONField; // generic callback\n\n var result;\n if (typeof processor === 'function') {\n result = processor(fieldData, fieldName, rowIndex);\n } else {\n result = fieldData;\n }\n var elm = this._elOrFieldData(result);\n\n var className = this._options.tdClassNames[fieldName];\n if (className) {\n Css.addClassName(elm, className);\n }\n\n tr.appendChild(elm);\n },\n\n _elOrFieldData: function (processed) {\n if (Common.isDOMElement(processed)) {\n return processed;\n }\n\n var isString = typeof processed === 'string';\n var isNumber = typeof processed === 'number';\n var elm = Element.create('td');\n\n if (isString && /^\\s*?</.test(processed)) {\n Element.setHTML(elm, processed);\n } else if (isString || isNumber) {\n Element.setTextContent(elm, processed);\n } else {\n throw new Error('Ink.UI.Table Unknown result from processJSONField: ' + processed);\n }\n\n return elm;\n },\n\n /**\n * Sets the AJAX endpoint.\n * Useful to change the endpoint in runtime.\n *\n * @method setEndpoint\n * @public\n * @param {String} endpoint New endpoint\n */\n setEndpoint: function( endpoint, currentPage ){\n if( !this._markupMode ){\n this._options.endpoint = endpoint;\n if (this._pagination) {\n this._pagination.setCurrent((!!currentPage) ? parseInt(currentPage,10) : 0 );\n }\n }\n },\n\n /**\n * Sets the instance's pagination, if necessary.\n *\n * Precondition: this._totalRows needs to be known.\n *\n * @method _setPagination\n * @private\n */\n _setPagination: function(){\n /* If user doesn't say they want pagination, bail. */\n if( this._options.pageSize == null ){ return; }\n\n /**\n * Fetch pagination from options. Can be a selector string, an element or a Pagination instance.\n */\n var paginationEl = this._options.pagination;\n\n if ( paginationEl instanceof Pagination ) {\n this._pagination = paginationEl;\n return;\n }\n\n if (!paginationEl) {\n paginationEl = Element.create('nav', {\n className: 'ink-navigation',\n insertAfter: this._element\n });\n Element.create('ul', {\n className: 'pagination',\n insertBottom: paginationEl\n });\n }\n\n var paginationOptions = Ink.extendObj({\n totalItemCount: this._totalRows,\n itemsPerPage: this._options.pageSize,\n onChange: Ink.bind(function (_, pageNo) {\n this._paginate(pageNo + 1);\n }, this)\n }, this._options.paginationOptions || {});\n\n this._pagination = new Pagination(paginationEl, paginationOptions);\n\n this._paginate(1);\n },\n\n /**\n * Method to choose which is the best way to get the data based on the endpoint:\n * - AJAX\n * - JSONP\n *\n * @method _getData\n * @private\n */\n _getData: function( ){\n var sortOrder = this._getSortOrder() || null;\n var page = null;\n\n if (this._pagination) {\n page = {\n size: this._options.pageSize,\n page: this._pagination.getCurrent() + 1\n };\n }\n\n this._getDataViaAjax( this._getUrl( sortOrder, page) );\n },\n\n /**\n * Return an object describing sort order { field: [field name] ,\n * order: [\"asc\" or \"desc\"] }, or null if there is no sorting\n * going on.\n * @method _getSortOrder\n * @private\n */\n _getSortOrder: function () {\n var index;\n for (index in this._sortableFields) if (this._sortableFields.hasOwnProperty(index)) {\n if( this._sortableFields[index] !== 'none' ){\n break;\n }\n }\n if (!index) {\n return null; // no sorting going on\n }\n return {\n field: this._originalFields[index],\n order: this._sortableFields[index]\n };\n },\n\n _getUrl: function (sort, page) {\n var urlCreator = this._options.createEndpointUrl ||\n function (endpoint, sort, page\n /* TODO implement filters too */) {\n endpoint = InkUrl.parseUrl(endpoint);\n endpoint.query = endpoint.query || {};\n\n if (sort) {\n endpoint.query.sortOrder = sort.order;\n endpoint.query.sortField = sort.field;\n }\n\n if (page) {\n endpoint.query['rows_per_page'] = page.size;\n endpoint.query['page'] = page.page;\n }\n\n return InkUrl.format(endpoint);\n };\n\n var ret = urlCreator(this._options.endpoint, sort, page);\n\n if (typeof ret !== 'string') {\n throw new TypeError('Ink.UI.Table_1: ' +\n 'createEndpointUrl did not return a string!');\n }\n\n return ret;\n },\n\n /**\n * Gets the data via AJAX and calls this._onAjaxSuccess with the response.\n * \n * Will call options.getDataFromEndpoint( Uri, callback ) if available.\n *\n * @param endpointUri Endpoint to get data from, after processing.\n */\n _getDataViaAjax: function( endpointUri ){\n var success = Ink.bind(function( JSONData ){\n this._onAjaxSuccess( JSONData );\n }, this);\n\n if (!this._options.getDataFromEndpoint) {\n new Ajax( endpointUri, {\n method: 'GET',\n contentType: 'application/json',\n sanitizeJSON: true,\n onSuccess: Ink.bind(function( response ){\n if( response.status === 200 ){\n success(Json.parse(response.responseText));\n }\n }, this)\n });\n } else {\n this._options.getDataFromEndpoint( endpointUri, success );\n }\n },\n\n _onAjaxSuccess: function (jsonResponse) {\n var paginated = this._options.pageSize != null;\n var rows = this._options.processJSONRows(jsonResponse);\n this._headers = Selector.select('th', this._thead);\n\n // If headers not in DOM, get from JSON\n if( this._headers.length === 0 ) {\n var headers = this._options.processJSONHeaders(\n jsonResponse);\n if (!headers || !headers.length || !headers[0]) {\n throw new Error('Ink.UI.Table: processJSONHeaders option must return an array of objects!');\n }\n this._createHeadersFromJson( headers );\n this._resetSortOrder();\n this._addHeadersClasses();\n }\n\n this._createRowsFromJSON( rows );\n\n this._totalRows = this._rowLength = rows.length;\n\n if( paginated ){\n this._totalRows = this._options.processJSONTotalRows(jsonResponse);\n this._setPagination( );\n }\n }\n };\n\n Common.createUIComponent(Table);\n\n return Table;\n\n});\n","/**\n * Display tabbed content\n * @module Ink.UI.Tabs_1\n * @version 1\n */\nInk.createModule('Ink.UI.Tabs', '1', ['Ink.UI.Common_1','Ink.Dom.Event_1','Ink.Dom.Css_1','Ink.Dom.Element_1','Ink.Dom.Selector_1'], function(Common, Event, Css, Element, Selector) {\n 'use strict';\n\n /**\n * The Tabs Component offers a simple way to build a tab-separated layout, allowing you to offer multiple content in the same space with intuitive navigation.\n * This component requires your markup to have:\n * - A container element (this is what you call the Ink.UI.Tabs constructor on), containing everything.\n * - An element with the `tabs-nav` class, to contain links.\n * - Your links with `href=\"#ID_OF_SECTION\"`\n * - Your sections with the corresponding `id` attributes and the `tabs-content` class.\n * - The content for each section.\n *\n * When the user clicks in the links inside `tabs-nav`, the tab with the corresponding ID is then activated. The active tab when the tab component is initialized has its hash in the browser URL. If there is no hash, then the `active` option kicks in. Otherwise, Tabs will fall back to showing the tab corresponding to the first link.\n * You can disable some (or all) tabs by passing an array for the `disabled` option.\n *\n * @class Ink.UI.Tabs\n * @constructor\n * @version 1\n * @param {String|DOMElement} selector\n * @param {Object} [options] Options\n * @param {Boolean} [options.preventUrlChange] Flag that determines if follows the link on click or stops the event\n * @param {String} [options.active] ID of the tab to activate on creation\n * @param {Array} [options.disabled] IDs of the tabs that will be disabled on creation\n * @param {Function} [options.onBeforeChange] Callback to be executed before changing tabs\n * @param {Function} [options.onChange] Callback to be executed after changing tabs\n * \n * @param {String} [options.menuSelector='.tabs-nav'] Selector to find the menu element\n * @param {String} [options.contentSelector='.tabs-content'] Selector to find the menu element\n * @param {String} [options.tabSelector='.tabs-tab'] Selector to find the menu element\n *\n * @param {Boolean} [options.triggerEventsOnLoad] Trigger the above events when the page is loaded.\n *\n * @sample Ink_UI_Tabs_1.html\n */\n function Tabs() {\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n Tabs._name = 'Tabs_1';\n\n Tabs._optionDefinition = {\n preventUrlChange: ['Boolean', false],\n active: ['String', undefined],\n disabled: ['Object', []],\n onBeforeChange: ['Function', undefined],\n onChange: ['Function', undefined],\n menuSelector: ['String', '.tabs-nav'],\n contentSelector: ['String', '.tabs-content'],\n tabSelector: ['String', '.tabs-tab'],\n triggerEventsOnLoad:['Boolean', true]\n };\n\n Tabs.prototype = {\n\n /**\n * Init function called by the constructor\n * \n * @method _init\n * @private\n */\n _init: function() {\n this._handlers = {\n resize: Ink.bindEvent(Event.throttle(this._onResize, 100),this)\n };\n\n this._menu = Selector.select(this._options.menuSelector, this._element)[0];\n\n if (!this._menu) {\n Ink.warn('Ink.UI.Tabs: An element selected by \".tabs-nav\" needs to exist inside the element!');\n return;\n }\n\n //initialization of the tabs, hides all content before setting the active tab\n this._initializeDom();\n\n // subscribe events\n this._observe();\n\n //sets the first active tab\n this._setFirstActive();\n\n this._handlers.resize();\n },\n\n /**\n * Initialization of the tabs, hides all content before setting the active tab\n * \n * @method _initializeDom\n * @private\n */\n _initializeDom: function(){\n var contentTabs = Selector.select(this._options.contentSelector, this._element);\n\n for(var i = 0; i < contentTabs.length; i++){\n Css.addClassName(contentTabs[i], 'hide-all');\n }\n },\n\n /**\n * Subscribe events\n * \n * @method _observe\n * @private\n */\n _observe: function() {\n Event.on(this._menu, 'click', 'a', Ink.bindMethod(this, '_onTabClickedGeneric'));\n Event.observe(window, 'resize', this._handlers.resize);\n },\n\n /**\n * Run at instantiation, to determine which is the first active tab\n * fallsback from window.location.href to options.active to the first not disabled tab\n * \n * @method _setFirstActive\n * @private\n */\n _setFirstActive: function() {\n var hash = window.location.hash;\n\n var activeMenuLink = this._findLinkByHref(hash) ||\n (this._options.active && this._findLinkByHref(this._options.active)) ||\n Selector.select('.active a', this._menu)[0] ||\n Selector.select('a', this._menu)[0];\n\n if (activeMenuLink) {\n this._changeTab(activeMenuLink, this._options.triggerEventsOnLoad);\n }\n },\n\n /**\n * Changes to the desired tab\n * \n * @method _changeTab\n * @param {DOMElement} link anchor linking to the content container\n * @param {boolean} runCallbacks defines if the callbacks should be run or not\n * @private\n */\n _changeTab: function(link, runCallbacks){\n if(runCallbacks && typeof this._options.onBeforeChange !== 'undefined'){\n this._options.onBeforeChange(this);\n }\n\n var selector = link.getAttribute('href');\n\n var activeTabs = Selector.select('> li.active', this._menu);\n\n for (var i = 0, len = activeTabs.length; i < len; i++) {\n if (activeTabs[i] !== link) {\n Css.removeClassName(activeTabs[i], 'active');\n }\n }\n\n if (this._activeMenuTab) {\n Css.removeClassName(this._activeMenuTab, 'active');\n Css.removeClassName(this._activeSection, 'active');\n Css.addClassName(this._activeSection, 'hide-all');\n }\n\n this._activeMenuLink = link;\n this._activeMenuTab = this._activeMenuLink.parentNode;\n this._activeSection = Selector.select(selector.substr(selector.indexOf('#')), this._element)[0];\n\n if (!this._activeSection) {\n this._activeMenuLink = this._activeMenuTab = this._activeSection = null;\n return;\n }\n\n Css.addClassName(this._activeMenuTab, 'active');\n Css.addClassName(this._activeSection, 'active');\n Css.removeClassName(this._activeSection, 'hide-all');\n\n if(runCallbacks && typeof(this._options.onChange) !== 'undefined'){\n this._options.onChange(this);\n }\n },\n\n /**\n * Generic Tab clicked handler.\n * Just calls _onTabClicked or _onDisabledTabClicked\n *\n * @private\n **/\n _onTabClickedGeneric: function (event) {\n event.preventDefault();\n if (!Css.hasClassName(event.currentTarget, 'ink-disabled')) {\n this._onTabClicked(event.currentTarget);\n }\n },\n\n /**\n * Tab clicked handler\n * \n * @method _onTabClicked\n * @param {Event} ev\n * @private\n */\n _onTabClicked: function(tabElm) {\n var href = tabElm.getAttribute('href');\n href = href.substr(href.indexOf('#'));\n\n if (!href || Ink.i(this._dehashify(href)) === null) {\n return;\n }\n\n if (!this._options.preventUrlChange) {\n window.location.hash = href;\n }\n\n if (tabElm === this._activeMenuLink) {\n return;\n }\n this.changeTab(tabElm);\n },\n\n /**\n * Resize handler\n * \n * @method _onResize\n * @private\n */\n _onResize: function(){\n var currentLayout = Common.currentLayout();\n if(currentLayout === this._lastLayout){\n return;\n }\n\n // wtf\n var smallLayout =\n currentLayout === Common.Layouts.TINY ||\n currentLayout === Common.Layouts.SMALL ||\n currentLayout === Common.Layouts.MEDIUM;\n\n if(smallLayout){\n Css.removeClassName(this._menu, 'menu');\n Css.removeClassName(this._menu, 'horizontal');\n // Css.addClassName(this._menu, 'pills');\n } else {\n Css.addClassName(this._menu, 'menu');\n Css.addClassName(this._menu, 'horizontal');\n // Css.removeClassName(this._menu, 'pills');\n }\n this._lastLayout = currentLayout;\n },\n\n /*****************\n * Aux Functions *\n *****************/\n\n /**\n * Allows the hash to be passed with or without the cardinal sign\n * \n * @method _hashify\n * @param {String} hash the string to be hashified\n * @return {String} Resulting hash\n * @private\n */\n _hashify: function(hash){\n if(!hash){\n return \"\";\n }\n return hash.indexOf('#') === 0? hash : '#' + hash;\n },\n\n /**\n * Removes the cardinal sign from the beginning of a string\n **/\n _dehashify: function(hash) {\n if (!hash) { return ''; }\n return ('' + hash).replace(/^#/, '');\n },\n\n /**\n * Returns the anchor with the desired href\n * \n * @method _findLinkBuHref\n * @param {String} href the href to be found on the returned link\n * @return {String|undefined} [description]\n * @private\n */\n _findLinkByHref: function(href){\n // If it's null or undefined, the following checks fail.\n if (!href) { return null; }\n\n // If it's a node, it could be a link or a section.\n if (href.nodeType === 1) {\n if (Element.isAncestorOf(href, this._element)) { return null; } // Element is outside the tabs element.\n\n var links = Selector.select('a', this._menu);\n var id = href.getAttribute('id');\n\n for (var i = 0, len = links.length; i < len; i++) {\n if (links[i] === href || Element.isAncestorOf(href, links[i])) {\n return links[i]; // We got a link\n } else if (id && id === this._dehashify(links[i].getAttribute('href'))) {\n return links[i]; // We got a section\n }\n }\n\n return null;\n }\n\n // Else, it's a string. It could start with \"#\" or without it.\n href = this._hashify(href);\n // Find a link which has a href ending with...\n return Selector.select('a[href$=\"' + href + '\"]', this._menu)[0] || null;\n },\n\n /**************\n * PUBLIC API *\n **************/\n\n /**\n * Changes the active tab\n *\n * Pass a selector/element identifying what tab you want\n * \n * @method changeTab\n * @param {String|DOMElement} selector Selector of the desired tab or the link that links to it\n * @public\n */\n changeTab: function(selector) {\n selector = this._findLinkByHref(selector);\n\n if(!selector || Css.hasClassName(selector, 'ink-disabled')){\n return;\n }\n\n this._changeTab(selector, true);\n },\n\n /**\n * Disables the desired tag\n * \n * @method disable\n * @param {String|DOMElement} selector the id of the desired tab or the link that links to it\n * @public\n */\n disable: function(selector){\n Css.addClassName(this._findLinkByHref(selector), 'ink-disabled');\n },\n\n /**\n * Enables the desired tag\n * \n * @method enable\n * @param {String|DOMElement} selector The id of the desired tab or the link that links to it\n * @public\n */\n enable: function(selector){\n Css.removeClassName(this._findLinkByHref(selector), 'ink-disabled');\n },\n\n /***********\n * Getters *\n ***********/\n\n /**\n * Returns the active tab id\n * \n * @method activeTab\n * @return {String} ID of the active section (use activeSection() instead to get the element).\n * @public\n */\n activeTab: function(){\n return this._activeSection.getAttribute('id');\n },\n\n /**\n *\n * Returns the parent of the currently active menu link.\n *\n * This is useful if you want to have `li` elements wrapping your links\n * and want to access the currently visible one.\n *\n * (This method is deprecated)\n * @method activeMenuTab\n * @deprecated\n * @return {DOMElement|null} Active menu LI, or `null` if there is none.\n * @public\n */\n activeMenuTab: function(){\n // [3.1.0] remove this\n Ink.warn('Ink.UI.Tabs.activeMenuTab() is deprecated');\n return this._activeMenuTab;\n },\n\n /**\n * Gets the currently active Menu link (the links which the user clicks on to change tabs)\n * \n * @method activeMenuLink\n * @return {DOMElement|null} Active menu link, or `null` if there is none.\n * @public\n */\n activeMenuLink: function(){\n return this._activeMenuLink;\n },\n\n /**\n * Gets the currently active section\n *\n * (Each section contains content for a tab, and must have an `id` attribute)\n * \n * @method activeContentTab\n * @return {DOMElement|null} Active section, or `null` if there is none.\n * @public\n */\n activeSection: function(){\n return this._activeSection;\n },\n\n activeContentTab: function () {\n // [3.1.0] remove this\n Ink.warn('Ink.UI.Tabs.activeContentTab() is deprecated. Use activeSection instead.');\n return this._activeSection();\n },\n\n /**\n * Unregisters the component and removes its markup\n * \n * @method destroy\n * @public\n */\n destroy: Common.destroyComponent\n };\n\n Common.createUIComponent(Tabs);\n\n return Tabs;\n\n});\n","/*\n * Tagging input element\n * @module Ink.UI.TagField_1\n * @version 1\n */\nInk.createModule(\"Ink.UI.TagField\",\"1\",[\"Ink.Dom.Element_1\", \"Ink.Dom.Event_1\", \"Ink.Dom.Css_1\", \"Ink.Dom.Browser_1\", \"Ink.UI.Droppable_1\", \"Ink.Util.Array_1\", \"Ink.Dom.Selector_1\", \"Ink.UI.Common_1\"],function( InkElement, InkEvent, Css, Browser, Droppable, InkArray, Selector, Common) {\n 'use strict';\n\n var enterKey = 13;\n var backspaceKey = 8;\n var isTruthy = function (val) {return !!val;};\n\n /**\n * Use this class to have a field where a user can input several tags into a single text field. A good example is allowing the user to describe a blog post or a picture through tags, for later searching.\n *\n * The markup is as follows:\n *\n * <input class=\"ink-tagfield\" type=\"text\" value=\"initial,value\">\n *\n * By applying this UI class to the above input, you get a tag field with the tags \"initial\" and \"value\". The class preserves the original input element. It remains hidden and is updated with new tag information dynamically, so regular HTML form logic still applies.\n *\n * Below \"input\" refers to the current value of the input tag (updated as the user enters text, of course), and \"output\" refers to the value which this class writes back to said input tag.\n *\n * @class Ink.UI.TagField\n * @version 1\n * @constructor\n * @param {String|DOMElement} element Selector or DOM Input Element.\n * @param {Object} [options] Options object\n * @param {String|Array} [options.tags] Initial tags in the input\n * @param {Boolean} [options.allowRepeated] Flag to allow user to input several tags. Defaults to true.\n * @param {RegExp} [options.separator] Split the input by this RegExp. Defaults to /[,;(space)]+/g (spaces, commas and semicolons)\n * @param {String} [options.outSeparator] Use this string to separate each tag from the next in the output. Defaults to ','.\n * @param {Boolean} [options.autoSplit] Flag to activate tag creation when the user types a separator. Defaults to true.\n * @param {Integer} [options.maxTags] Maximum number of tags allowed. Set to -1 for no limit. Defaults to -1.\n * @example\n */\n function TagField() {\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n TagField._name = 'TagField_1';\n\n TagField._optionDefinition = {\n tags: ['String', []],\n tagQuery: ['Object', null],\n tagQueryAsync: ['Object', null],\n allowRepeated: ['Boolean', false],\n maxTags: ['Integer', -1],\n outSeparator: ['String', ','],\n separator: ['String', /[,; ]+/g],\n autoSplit: ['Boolean', true]\n };\n\n TagField.prototype = {\n /**\n * Init function called by the constructor\n * \n * @method _init\n * @private\n */\n _init: function() {\n var o = this._options;\n if (typeof o.separator === 'string') {\n o.separator = new RegExp(o.separator, 'g');\n }\n\n if (typeof o.tags === 'string') {\n // coerce to array using the separator\n o.tags = this._readInput(o.tags);\n }\n\n Css.addClassName(this._element, 'hide-all');\n\n this._viewElm = InkElement.create('div', {\n className: 'ink-tagfield',\n insertAfter: this._element\n });\n\n this._input = InkElement.create('input', {\n type: 'text',\n className: 'new-tag-input',\n insertBottom: this._viewElm\n });\n\n var tags = [].concat(o.tags, this._tagsFromMarkup(this._element));\n\n this._tags = [];\n\n InkArray.each(tags, Ink.bindMethod(this, '_addTag'));\n\n InkEvent.observe(this._input, 'keyup', Ink.bindEvent(this._onKeyUp, this));\n InkEvent.observe(this._input, 'change', Ink.bindEvent(this._onKeyUp, this));\n InkEvent.observe(this._input, 'keydown', Ink.bindEvent(this._onKeyDown, this));\n InkEvent.observe(this._input, 'blur', Ink.bindEvent(this._onBlur, this));\n InkEvent.observe(this._viewElm, 'click', Ink.bindEvent(this._refocus, this));\n },\n\n destroy: function () {\n InkElement.remove(this._viewElm);\n Css.removeClassName(this._element, 'hide-all');\n },\n\n _tagsFromMarkup: function (element) {\n var tagname = element.tagName.toLowerCase();\n if (tagname === 'input') {\n return this._readInput(element.value);\n } else if (tagname === 'select') {\n return InkArray.map(element.getElementsByTagName('option'), function (option) {\n return InkElement.textContent(option);\n });\n } else {\n throw new Error('Cannot read tags from a ' + tagname + ' tag. Unknown tag');\n }\n },\n\n _tagsToMarkup: function (tags, element) {\n var tagname = element.tagName.toLowerCase();\n if (tagname === 'input') {\n if (this._options.separator) {\n element.value = tags.join(this._options.outSeparator);\n }\n } else if (tagname === 'select') {\n element.innerHTML = '';\n InkArray.each(tags, function (tag) {\n var opt = InkElement.create('option', {selected: 'selected'});\n InkElement.setTextContent(opt, tag);\n element.appendChild(opt);\n });\n } else {\n throw new Error('TagField: Cannot read tags from a ' + tagname + ' tag. Unknown tag');\n }\n },\n\n _addTag: function (tag) {\n if (this._options.maxTags !== -1 &&\n this._tags.length >= this._options.maxTags) {\n return;\n }\n if ((!this._options.allowRepeated &&\n InkArray.inArray(tag, this._tags, tag)) || !tag) {\n return false;\n }\n var elm = InkElement.create('span', {\n className: 'ink-tag',\n setTextContent: tag + ' '\n });\n\n var remove = InkElement.create('span', {\n className: 'remove fa fa-times',\n insertBottom: elm\n });\n InkEvent.observe(remove, 'click', Ink.bindEvent(this._removeTag, this, null));\n\n var spc = document.createTextNode(' ');\n\n this._tags.push(tag);\n this._viewElm.insertBefore(elm, this._input);\n this._viewElm.insertBefore(spc, this._input);\n this._tagsToMarkup(this._tags, this._element);\n },\n\n _readInput: function (text) {\n if (this._options.separator) {\n return InkArray.filter(text.split(this._options.separator), isTruthy);\n } else {\n return [text];\n }\n },\n\n _onKeyUp: function () { // TODO control input box size\n if (!this._options.autoSplit) {\n return;\n }\n var split = this._input.value.split(this._options.separator);\n if (split.length <= 1) {\n return;\n }\n var last = split[split.length - 1];\n split = split.splice(0, split.length - 1);\n split = InkArray.filter(split, isTruthy);\n \n InkArray.each(split, Ink.bind(this._addTag, this));\n this._input.value = last;\n },\n\n _onKeyDown: function (event) {\n if (event.which === enterKey) {\n return this._onEnterKeyDown(event);\n } else if (event.which === backspaceKey) {\n return this._onBackspaceKeyDown();\n } else if (this._removeConfirm) {\n // user pressed another key, cancel removal from a backspace key\n this._unsetRemovingVisual(this._tags.length - 1);\n }\n },\n\n /**\n * When the user presses backspace twice on the empty input, we delete the last tag on the field.\n * @method onBackspaceKeyDown\n * @private\n */\n _onBackspaceKeyDown: function () {\n if (this._input.value) { return; }\n\n if (this._removeConfirm) {\n this._unsetRemovingVisual(this._tags.length - 1);\n this._removeTag(this._tags.length - 1);\n this._removeConfirm = null;\n } else {\n this._setRemovingVisual(this._tags.length - 1);\n }\n },\n\n _onEnterKeyDown: function (event) {\n var tag = this._input.value;\n if (tag) {\n this._addTag(tag);\n this._input.value = '';\n }\n InkEvent.stopDefault(event);\n },\n\n _onBlur: function () {\n this._addTag(this._input.value);\n this._input.value = '';\n },\n\n /* For when the user presses backspace.\n * Set the style of the tag so that it seems like it's going to be removed\n * if they press backspace again. */\n _setRemovingVisual: function (tagIndex) {\n var elm = this._viewElm.children[tagIndex];\n if (!elm) { return; }\n\n Css.addClassName(elm, 'tag-deleting');\n\n this._removeRemovingVisualTimeout = setTimeout(Ink.bindMethod(this, '_unsetRemovingVisual', tagIndex), 4000);\n InkEvent.observe(this._input, 'blur', Ink.bindMethod(this, '_unsetRemovingVisual', tagIndex));\n this._removeConfirm = true;\n },\n _unsetRemovingVisual: function (tagIndex) {\n var elm = this._viewElm.children[tagIndex];\n if (elm) {\n Css.removeClassName(elm, 'tag-deleting');\n clearTimeout(this._removeRemovingVisualTimeout);\n }\n this._removeConfirm = null;\n },\n\n _removeTag: function (event) {\n var index;\n if (typeof event === 'object') { // click event on close button\n var elm = InkEvent.element(event).parentNode;\n index = InkElement.parentIndexOf(this._viewElm, elm);\n } else if (typeof event === 'number') { // manual removal\n index = event;\n }\n this._tags = InkArray.remove(this._tags, index, 1);\n InkElement.remove(this._viewElm.children[index]);\n this._tagsToMarkup(this._tags, this._element);\n },\n\n _refocus: function (event) {\n this._input.focus();\n InkEvent.stop(event);\n return false;\n }\n };\n\n Common.createUIComponent(TagField);\n\n return TagField;\n});\n","/**\n * Toggle the visibility of elements.\n * @module Ink.UI.Toggle_1\n * @version 1\n */\n\n Ink.createModule('Ink.UI.Toggle', '1', ['Ink.UI.Common_1','Ink.Dom.Event_1','Ink.Dom.Css_1','Ink.Dom.Element_1','Ink.Dom.Selector_1','Ink.Util.Array_1'], function(Common, InkEvent, Css, InkElement, Selector, InkArray ) {\n 'use strict';\n\n /**\n *\n * You need two elements to use Toggle: the `trigger` element, and the `target` element (or elements). The default behaviour is to toggle the `target`(s) when you click the `trigger`.\n *\n * The toggle has a state. It is either \"on\" or \"off\". It works by switching between the CSS classes in `classNameOn` and `classNameOff` according to the current state.\n *\n * When you initialize the Toggle, it will check if the targets are visible to figure out what the initial state is. You can force the toggle to consider itself turned \"on\" or \"off\" by setting the `initialState` option to `true` or `false`, respectively.\n *\n * You can get the current state of the Toggle by calling `getState`, or by checking if your `trigger` element has the \"active\" class.\n * The state can be changed through JavaScript. Just call `setState(true)` \n * to turn the Toggle on (or `setState(false)` to turn it off).\n *\n * @class Ink.UI.Toggle\n * @constructor\n * @version 1\n * @param {String|DOMElement} selector Trigger element. By clicking this, the target (or targets) are triggered.\n * @param {Object} [options] Options object, containing:\n *\n * @param {String} options.target CSS Selector that specifies the elements that this component will toggle\n * @param {String} [options.classNameOn] CSS class to toggle when on. Defaults to 'show-all'.\n * @param {String} [options.classNameOff] CSS class to toggle when off. Defaults to 'hide-all'.\n * @param {String} [options.triggerEvent] Event that will trigger the toggling. Defaults to 'click'.\n * @param {Boolean} [options.closeOnClick] Flag to toggle the targe off when clicking outside the toggled content. Defaults to true.\n * @param {String} [options.closeOnInsideClick] Toggle off when a child element matching this selector is clicked. Set to null to deactivate the check. Defaults to 'a[href]'.\n * @param {Boolean} [options.initialState] Flag to define initial state. false: off, true: on, null: markup. Defaults to null.\n * @param {Function} [options.onChangeState] Callback when the toggle state changes. Return `false` to cancel the event.\n *\n * @sample Ink_UI_Toggle_1_constructor.html\n */\n function Toggle(){\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n Toggle._name = 'Toggle_1';\n\n Toggle._optionDefinition = {\n target: ['Elements'],\n triggerEvent: ['String', 'click'],\n closeOnClick: ['Boolean', true],\n isAccordion: ['Boolean', false],\n initialState: ['Boolean', null], // May be true, false, or null to be what it is right now\n classNameOn: ['String', 'show-all'],\n classNameOff: ['String', 'hide-all'],\n closeOnInsideClick: ['String', 'a[href]'], // closes the toggle when a target is clicked and it is a link\n onChangeState: ['Function', null]\n };\n\n Toggle.prototype = {\n\n /**\n * Init function called by the constructor\n * \n * @method _init\n * @private\n */\n _init: function(){\n var i, len;\n\n this._targets = Common.elsOrSelector(this._options.target);\n\n // Boolean option handling\n this._options.closeOnClick = this._options.closeOnClick.toString() === 'true';\n // Actually a throolean\n if (this._options.initialState !== null){\n this._options.initialState = this._options.initialState.toString() === 'true';\n } else {\n this._options.initialState = Css.getStyle(this._targets[0], 'display') !== 'none';\n }\n\n if (this._options.classNameOn !== 'show-all' || this._options.classNameOff !== 'hide-all') {\n for (i = 0, len = this._targets.length; i < len; i++) {\n Css.removeClassName(this._targets[i], 'show-all');\n Css.removeClassName(this._targets[i], 'hide-all');\n }\n }\n\n this._accordion = ( Css.hasClassName(this._element.parentNode,'accordion') || Css.hasClassName(this._targets[0].parentNode,'accordion') );\n\n this._firstTime = true;\n\n this._bindEvents();\n\n if (this._options.initialState !== null) {\n this.setState(this._options.initialState, true);\n } else {\n // Add initial classes matching the current \"display\" of the object.\n var state = Css.getStyle(this._targets[0], 'display') !== 'none';\n this.setState(state, true);\n }\n // Aditionally, remove any inline \"display\" style.\n for (i = 0, len = this._targets.length; i < len; i++) {\n if (this._targets[i].style.display) {\n this._targets[i].style.display = ''; // becomes default\n }\n }\n\n this._element.setAttribute('data-is-toggle-trigger', 'true');\n },\n\n /**\n * @method _bindEvents\n * @private\n */\n _bindEvents: function () {\n if ( this._options.triggerEvent ) {\n InkEvent.observe(\n this._element,\n this._options.triggerEvent,\n Ink.bind(this._onTriggerEvent, this));\n }\n if( this._options.closeOnClick ){\n InkEvent.observe( document, 'click', Ink.bind(this._onOutsideClick, this));\n }\n if( this._options.closeOnInsideClick && this._options.closeOnInsideClick !== 'false') {\n var sel = this._options.closeOnInsideClick;\n if (sel.toString() === 'true') {\n sel = '*';\n }\n InkEvent.observeMulti(this._targets, 'click', Ink.bind(function (e) {\n if ( InkElement.findUpwardsBySelector(InkEvent.element(e), sel) ) {\n this.setState(false, true);\n }\n }, this));\n }\n },\n\n /**\n * Event handler. It's responsible for handling the `triggerEvent` as defined in the options.\n *\n * This will trigger the toggle.\n * \n * @method _onTriggerEvent\n * @param {Event} event\n * @private\n */\n _onTriggerEvent: function( event ){\n // When the togglee is a child of the toggler, we get the togglee's events here. We have to check that this event is for us.\n var target = InkEvent.element(event);\n\n var isAncestorOfClickedElement = InkArray.some(this._targets, function (thisOne) {\n return thisOne === target || InkElement.isAncestorOf(thisOne, target);\n });\n\n if (isAncestorOfClickedElement) {\n return;\n }\n\n if (this._accordion) {\n this._updateAccordion();\n }\n\n var has = this.getState();\n this.setState(!has, true);\n if (!has && this._firstTime) {\n this._firstTime = false;\n }\n\n InkEvent.stopDefault(event);\n },\n\n /**\n * Be compatible with accordions\n *\n * @method _updateAccordion\n **/\n _updateAccordion: function () {\n var elms, accordionElement;\n if( Css.hasClassName(this._targets[0].parentNode,'accordion') ){\n accordionElement = this._targets[0].parentNode;\n } else {\n accordionElement = this._targets[0].parentNode.parentNode;\n }\n elms = Selector.select('.toggle, .ink-toggle',accordionElement);\n for(var i=0; i<elms.length; i+=1 ){\n var dataset = InkElement.data( elms[i] ),\n targetElm = Selector.select( dataset.target,accordionElement );\n\n if( (targetElm.length > 0) && (targetElm[0] !== this._targets[0]) ){\n targetElm[0].style.display = 'none';\n }\n }\n },\n\n /**\n * Click handler. Will handle clicks outside the toggle component.\n * \n * @method _onOutsideClick\n * @param {Event} event\n * @private\n */\n _onOutsideClick: function( event ){\n var tgtEl = InkEvent.element(event),\n shades;\n\n if (InkElement.findUpwardsBySelector(tgtEl, '[data-is-toggle-trigger=\"true\"]')) return;\n\n var ancestorOfTargets = InkArray.some(this._targets, function (target) {\n return InkElement.isAncestorOf(target, tgtEl) || target === tgtEl;\n });\n\n if( (this._element === tgtEl) || InkElement.isAncestorOf(this._element, tgtEl) || ancestorOfTargets) {\n return;\n } else if( (shades = Ink.ss('.ink-shade')).length ) {\n var shadesLength = shades.length;\n\n for( var i = 0; i < shadesLength; i++ ){\n if( InkElement.isAncestorOf(shades[i],tgtEl) && InkElement.isAncestorOf(shades[i],this._element) ){\n return;\n }\n }\n }\n\n this.setState(false, true); // dismiss\n },\n\n /**\n * Sets the state of the toggle. (on/off)\n *\n * @method setState\n * @param newState {Boolean} New state (on/off)\n */\n setState: function (on, callHandler) {\n if (on === this.getState()) { return; }\n if (callHandler && typeof this._options.onChangeState === 'function') {\n var ret = this._options.onChangeState(on);\n if (ret === false) { return false; } // Canceled by the event handler\n }\n for (var i = 0, len = this._targets.length; i < len; i++) {\n Css.addRemoveClassName(this._targets[i], this._options.classNameOn, on);\n Css.addRemoveClassName(this._targets[i], this._options.classNameOff, !on);\n }\n Css.addRemoveClassName(this._element, 'active', on);\n },\n\n /**\n * Gets the state of the toggle. (on/off)\n *\n * @method getState\n *\n * @return {Boolean} whether the toggle is toggled on.\n */\n getState: function () {\n return Css.hasClassName(this._element, 'active');\n }\n };\n\n Common.createUIComponent(Toggle);\n\n return Toggle;\n});\n","/**\n * Content Tooltips\n * @module Ink.UI.Tooltip_1\n * @version 1\n */\nInk.createModule('Ink.UI.Tooltip', '1', ['Ink.UI.Common_1', 'Ink.Dom.Event_1', 'Ink.Dom.Element_1', 'Ink.Dom.Selector_1', 'Ink.Util.Array_1', 'Ink.Dom.Css_1', 'Ink.Dom.Browser_1'], function (Common, InkEvent, InkElement, Selector, InkArray, Css) {\n 'use strict';\n\n /**\n * Tooltips are useful as a means to display information about functionality while avoiding clutter.\n *\n * Tooltips show up when you hover elements which \"have\" tooltips.\n *\n * This class will \"give\" a tooltip to many elements, selected by its first argument (`target`). This is contrary to the other UI modules in Ink, which are created once per element.\n *\n * You can define options either through the second argument of the Tooltip constructor, or as data-attributes in each `target` element. Options set through data-attributes all start with \"data-tip\", and override options passed into the Tooltip constructor.\n *\n * @class Ink.UI.Tooltip\n * @constructor\n *\n * @param {DOMElement|String} target Target element or selector of elements, to display the tooltips on.\n * @param {Object} [options] Options object\n * @param {String} [options.text] Text content for the tooltip.\n * @param {String} [options.html] HTML for the tooltip. Same as above, but won't escape HTML.\n * @param {String} [options.where] Positioning for the tooltip. Options are 'up', 'down', 'left', 'right', 'mousemove' (follows the cursor), and 'mousefix' (stays fixed). Defaults to 'up'.\n * \n * @param {String} [options.color] Color of the tooltip. Options are red, orange, blue, green and black. Default is white.\n * @param {Number} [options.fade] Number of seconds to fade in/out. Defaults to 0.3.\n * @param {Boolean} [options.forever] Flag to prevent the tooltip from being erased when the mouse hovers away from the target.\n * @param {Number} [options.timeout] Number of seconds the tooltip will stay open. Useful together with options.forever. Defaults to 0.\n * @param {Number} [options.delay] Time the tooltip waits until it is displayed. Useful to avoid getting the attention of the user unnecessarily\n * @param {DOMElement|Selector} [options.template] Element or selector containing HTML to be cloned into the tooltips. Can be a hidden element, because CSS `display` is set to `block`.\n * @param {String} [options.templatefield] Selector within the template element to choose where the text is inserted into the tooltip. Useful when a wrapper DIV is required.\n * @param {Number} [options.left] Spacing from the target to the tooltip, when `where` is `mousemove` or `mousefix`. Defaults to 10.\n * @param {Number} [options.top] Spacing from the target to the tooltip, when `where` is `mousemove` or `mousefix`. Defaults to 10.\n * @param {Number} [options.spacing] Spacing between the tooltip and the target element, when `where` is not `mousemove` or `mousefix`. Defaults to 8.\n * \n * @sample Ink_UI_Tooltip_1.html\n */\n function Tooltip(element, options) {\n this._init(element, options || {});\n }\n\n function EachTooltip(root, elm) {\n this._init(root, elm);\n }\n\n var transitionDurationName,\n transitionPropertyName,\n transitionTimingFunctionName;\n (function () { // Feature detection\n var test = document.createElement('DIV');\n var names = ['transition', 'oTransition', 'msTransition', 'mozTransition',\n 'webkitTransition'];\n for (var i = 0; i < names.length; i++) {\n if (typeof test.style[names[i] + 'Duration'] !== 'undefined') {\n transitionDurationName = names[i] + 'Duration';\n transitionPropertyName = names[i] + 'Property';\n transitionTimingFunctionName = names[i] + 'TimingFunction';\n break;\n }\n }\n }());\n\n // Body or documentElement\n var bodies = document.getElementsByTagName('body');\n var body = bodies.length ? bodies[0] : document.documentElement;\n\n Tooltip.prototype = {\n _init: function(element, options) {\n var elements;\n\n this.options = Ink.extendObj({\n where: 'up',\n zIndex: 10000,\n left: 10,\n top: 10,\n spacing: 8,\n forever: 0,\n color: '',\n timeout: 0,\n delay: 0,\n template: null,\n templatefield: null,\n fade: 0.3,\n text: ''\n }, options || {});\n\n if (typeof element === 'string') {\n elements = Selector.select(element);\n } else if (typeof element === 'object') {\n elements = [element];\n } else {\n throw 'Element expected';\n }\n\n this.tooltips = [];\n\n for (var i = 0, len = elements.length; i < len; i++) {\n this.tooltips[i] = new EachTooltip(this, elements[i]);\n }\n },\n /**\n * Destroys the tooltips created by this instance\n *\n * @method destroy\n */\n destroy: function () {\n InkArray.each(this.tooltips, function (tooltip) {\n tooltip._destroy();\n });\n this.tooltips = null;\n this.options = null;\n }\n };\n\n EachTooltip.prototype = {\n _oppositeDirections: {\n left: 'right',\n right: 'left',\n up: 'down',\n down: 'up'\n },\n _init: function(root, elm) {\n InkEvent.observe(elm, 'mouseover', Ink.bindEvent(this._onMouseOver, this));\n InkEvent.observe(elm, 'mouseout', Ink.bindEvent(this._onMouseOut, this));\n InkEvent.observe(elm, 'mousemove', Ink.bindEvent(this._onMouseMove, this));\n\n this.root = root;\n this.element = elm;\n this._delayTimeout = null;\n this.tooltip = null;\n\n Common.registerInstance(this, this.element);\n },\n _makeTooltip: function (mousePosition) {\n if (!this._getOpt('text') &&\n !this._getOpt('html') &&\n !InkElement.hasAttribute(this.element, 'title')) {\n return false;\n }\n\n var tooltip = this._createTooltipElement();\n\n if (this.tooltip) {\n this._removeTooltip();\n }\n\n this.tooltip = tooltip;\n\n this._fadeInTooltipElement(tooltip);\n this._placeTooltipElement(tooltip, mousePosition);\n\n InkEvent.observe(tooltip, 'mouseover', Ink.bindEvent(this._onTooltipMouseOver, this));\n\n var timeout = this._getFloatOpt('timeout');\n if (timeout) {\n setTimeout(Ink.bind(function () {\n if (this.tooltip === tooltip) {\n this._removeTooltip();\n }\n }, this), timeout * 1000);\n }\n },\n _createTooltipElement: function () {\n var template = this._getOpt('template'), // User template instead of our HTML\n templatefield = this._getOpt('templatefield'),\n \n tooltip, // The element we float\n field; // Element where we write our message. Child or same as the above\n\n if (template) { // The user told us of a template to use. We copy it.\n var temp = document.createElement('DIV');\n temp.innerHTML = Common.elOrSelector(template, 'options.template').outerHTML;\n tooltip = temp.firstChild;\n \n if (templatefield) {\n field = Selector.select(templatefield, tooltip);\n if (field) {\n field = field[0];\n } else {\n throw 'options.templatefield must be a valid selector within options.template';\n }\n } else {\n field = tooltip; // Assume same element if user did not specify a field\n }\n } else { // We create the default structure\n tooltip = document.createElement('DIV');\n Css.addClassName(tooltip, 'ink-tooltip');\n Css.addClassName(tooltip, this._getOpt('color'));\n\n field = document.createElement('DIV');\n Css.addClassName(field, 'content');\n\n tooltip.appendChild(field);\n }\n \n if (this._getOpt('html')) {\n field.innerHTML = this._getOpt('html');\n } else if (this._getOpt('text')) {\n InkElement.setTextContent(field, this._getOpt('text'));\n } else {\n InkElement.setTextContent(field, this.element.getAttribute('title'));\n }\n tooltip.style.display = 'block';\n tooltip.style.position = 'absolute';\n tooltip.style.zIndex = this._getIntOpt('zIndex');\n\n return tooltip;\n },\n _fadeInTooltipElement: function (tooltip) {\n var fadeTime = this._getFloatOpt('fade');\n if (transitionDurationName && fadeTime) {\n tooltip.style.opacity = '0';\n tooltip.style[transitionDurationName] = fadeTime + 's';\n tooltip.style[transitionPropertyName] = 'opacity';\n tooltip.style[transitionTimingFunctionName] = 'ease-in-out';\n setTimeout(function () {\n tooltip.style.opacity = '1';\n }, 0); // Wait a tick\n }\n },\n _placeTooltipElement: function (tooltip, mousePosition) {\n var where = this._getOpt('where');\n\n if (where === 'mousemove' || where === 'mousefix') {\n var mPos = mousePosition;\n this._setPos(mPos[0], mPos[1]);\n body.appendChild(tooltip);\n } else if (where.match(/(up|down|left|right)/)) {\n body.appendChild(tooltip);\n var targetElementPos = InkElement.offset(this.element);\n var tleft = targetElementPos[0],\n ttop = targetElementPos[1];\n\n var centerh = (InkElement.elementWidth(this.element) / 2) - (InkElement.elementWidth(tooltip) / 2),\n centerv = (InkElement.elementHeight(this.element) / 2) - (InkElement.elementHeight(tooltip) / 2);\n var spacing = this._getIntOpt('spacing');\n\n var tooltipDims = InkElement.elementDimensions(tooltip);\n var elementDims = InkElement.elementDimensions(this.element);\n\n var maxX = InkElement.scrollWidth() + InkElement.viewportWidth();\n var maxY = InkElement.scrollHeight() + InkElement.viewportHeight();\n \n where = this._getWhereValueInsideViewport(where, {\n left: tleft - tooltipDims[0],\n right: tleft + tooltipDims[0],\n top: ttop + tooltipDims[1],\n bottom: ttop + tooltipDims[1]\n }, {\n right: maxX,\n bottom: maxY\n });\n \n if (where === 'up') {\n ttop -= tooltipDims[1];\n ttop -= spacing;\n tleft += centerh;\n } else if (where === 'down') {\n ttop += elementDims[1];\n ttop += spacing;\n tleft += centerh;\n } else if (where === 'left') {\n tleft -= tooltipDims[0];\n tleft -= spacing;\n ttop += centerv;\n } else if (where === 'right') {\n tleft += elementDims[0];\n tleft += spacing;\n ttop += centerv;\n }\n \n var arrow = null;\n if (where.match(/(up|down|left|right)/)) {\n arrow = document.createElement('SPAN');\n Css.addClassName(arrow, 'arrow');\n Css.addClassName(arrow, this._oppositeDirections[where]);\n tooltip.appendChild(arrow);\n }\n\n var tooltipLeft = tleft;\n var tooltipTop = ttop;\n\n var toBottom = (tooltipTop + tooltipDims[1]) - maxY;\n var toRight = (tooltipLeft + tooltipDims[0]) - maxX;\n var toLeft = 0 - tooltipLeft;\n var toTop = 0 - tooltipTop;\n\n if (toBottom > 0) {\n if (arrow) { arrow.style.top = (tooltipDims[1] / 2) + toBottom + 'px'; }\n tooltipTop -= toBottom;\n } else if (toTop > 0) {\n if (arrow) { arrow.style.top = (tooltipDims[1] / 2) - toTop + 'px'; }\n tooltipTop += toTop;\n } else if (toRight > 0) {\n if (arrow) { arrow.style.left = (tooltipDims[0] / 2) + toRight + 'px'; }\n tooltipLeft -= toRight;\n } else if (toLeft > 0) {\n if (arrow) { arrow.style.left = (tooltipDims[0] / 2) - toLeft + 'px'; }\n tooltipLeft += toLeft;\n }\n\n tooltip.style.left = tooltipLeft + 'px';\n tooltip.style.top = tooltipTop + 'px';\n }\n },\n\n /**\n * Get a value for \"where\" (left/right/up/down) which doesn't put the\n * tooltip off the screen\n *\n * @method _getWhereValueInsideViewport\n * @param where {String} \"where\" value which was given by the user and we might change\n * @param bbox {BoundingBox} A bounding box like what you get from getBoundingClientRect ({top, bottom, left, right}) with pixel positions from the top left corner of the viewport.\n * @param viewport {BoundingBox} Bounding box for the viewport. \"top\" and \"left\" are omitted because these coordinates are relative to the top-left corner of the viewport so they are zero.\n *\n * @TODO: we can't use getBoundingClientRect in this case because it returns {0,0,0,0} on our uncreated tooltip.\n */\n _getWhereValueInsideViewport: function (where, bbox, viewport) {\n if (where === 'left' && bbox.left < 0) {\n return 'right';\n } else if (where === 'right' && bbox.right > viewport.right) {\n return 'left';\n } else if (where === 'up' && bbox.top < 0) {\n return 'down';\n } else if (where === 'down' && bbox.bottom > viewport.bottom) {\n return 'up';\n }\n\n return where;\n },\n _removeTooltip: function() {\n var tooltip = this.tooltip;\n if (!tooltip) {return;}\n\n var remove = Ink.bind(InkElement.remove, {}, tooltip);\n\n if (this._getOpt('where') !== 'mousemove' && transitionDurationName) {\n tooltip.style.opacity = 0;\n // remove() will operate on correct tooltip, although this.tooltip === null then\n setTimeout(remove, this._getFloatOpt('fade') * 1000);\n } else {\n remove();\n }\n this.tooltip = null;\n },\n _getOpt: function (option) {\n var dataAttrVal = InkElement.data(this.element)[InkElement._camelCase('tip-' + option)];\n if (dataAttrVal /* either null or \"\" may signify the absense of this attribute*/) {\n return dataAttrVal;\n }\n var instanceOption = this.root.options[option];\n if (typeof instanceOption !== 'undefined') {\n return instanceOption;\n }\n },\n _getIntOpt: function (option) {\n return parseInt(this._getOpt(option), 10);\n },\n _getFloatOpt: function (option) {\n return parseFloat(this._getOpt(option), 10);\n },\n _destroy: function () {\n if (this.tooltip) {\n InkElement.remove(this.tooltip);\n }\n this.root = null; // Cyclic reference = memory leaks\n this.element = null;\n this.tooltip = null;\n },\n _onMouseOver: function(e) {\n // on IE < 10 you can't access the mouse event not even a tick after it fired\n var mousePosition = this._getMousePosition(e);\n var delay = this._getFloatOpt('delay');\n if (delay) {\n this._delayTimeout = setTimeout(Ink.bind(function () {\n if (!this.tooltip) {\n this._makeTooltip(mousePosition);\n }\n this._delayTimeout = null;\n }, this), delay * 1000);\n } else {\n this._makeTooltip(mousePosition);\n }\n },\n _onMouseMove: function(e) {\n if (this._getOpt('where') === 'mousemove' && this.tooltip) {\n var mPos = this._getMousePosition(e);\n this._setPos(mPos[0], mPos[1]);\n }\n },\n _onMouseOut: function () {\n if (!this._getIntOpt('forever')) {\n this._removeTooltip();\n }\n if (this._delayTimeout) {\n clearTimeout(this._delayTimeout);\n this._delayTimeout = null;\n }\n },\n _onTooltipMouseOver: function () {\n if (this.tooltip) { // If tooltip is already being removed, this has no effect\n this._removeTooltip();\n }\n },\n _setPos: function(left, top) {\n left += this._getIntOpt('left');\n top += this._getIntOpt('top');\n var pageDims = this._getPageXY();\n if (this.tooltip) {\n var elmDims = [InkElement.elementWidth(this.tooltip), InkElement.elementHeight(this.tooltip)];\n var scrollDim = this._getScroll();\n\n if((elmDims[0] + left - scrollDim[0]) >= (pageDims[0] - 20)) {\n left = (left - elmDims[0] - this._getIntOpt('left') - 10);\n }\n if((elmDims[1] + top - scrollDim[1]) >= (pageDims[1] - 20)) {\n top = (top - elmDims[1] - this._getIntOpt('top') - 10);\n }\n\n this.tooltip.style.left = left + 'px';\n this.tooltip.style.top = top + 'px';\n }\n },\n _getPageXY: function() {\n var cWidth = 0;\n var cHeight = 0;\n if( typeof( window.innerWidth ) === 'number' ) {\n cWidth = window.innerWidth;\n cHeight = window.innerHeight;\n } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {\n cWidth = document.documentElement.clientWidth;\n cHeight = document.documentElement.clientHeight;\n } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {\n cWidth = document.body.clientWidth;\n cHeight = document.body.clientHeight;\n }\n return [parseInt(cWidth, 10), parseInt(cHeight, 10)];\n },\n _getScroll: function() {\n var dd = document.documentElement, db = document.body;\n if (dd && (dd.scrollLeft || dd.scrollTop)) {\n return [dd.scrollLeft, dd.scrollTop];\n } else if (db) {\n return [db.scrollLeft, db.scrollTop];\n } else {\n return [0, 0];\n }\n },\n _getMousePosition: function(e) {\n return [parseInt(InkEvent.pointerX(e), 10), parseInt(InkEvent.pointerY(e), 10)];\n }\n };\n\n return Tooltip;\n});\n","/**\n * Elements in a tree structure\n * @module Ink.UI.TreeView_1\n * @version 1\n */\nInk.createModule('Ink.UI.TreeView', '1', ['Ink.UI.Common_1','Ink.Dom.Event_1','Ink.Dom.Css_1','Ink.Dom.Element_1','Ink.Dom.Selector_1','Ink.Util.Array_1'], function(Common, Event, Css, Element, Selector, InkArray ) {\n 'use strict';\n\n\n /**\n * Shows elements in a tree structure which can be expanded and contracted.\n * A TreeView is built with \"node\"s and \"children\". \"node\"s are `li` tags, and \"children\" are `ul` tags.\n * You can build your TreeView out of a regular UL and LI element structure which you already use to display lists with several levels.\n * If you want a node to be open when the TreeView is built, just add the data-open=\"true\" attribute to it.\n * \n * @class Ink.UI.TreeView\n * @constructor\n * @version 1\n * @param {String|DOMElement} selector Element or selector.\n * @param {String} [options] Options object, containing:\n * @param {String} [options.node] Selector for the nodes. Defaults to 'li'.\n * @param {String} [options.children] Selector for the children. Defaults to 'ul'.\n * @param {String} [options.parentClass] CSS classes to be added to parent nodes. Defaults to 'parent'.\n * @param {String} [options.openClass] CSS classes to be added to the icon when a parent is open. Defaults to 'fa fa-minus-circle'.\n * @param {String} [options.closedClass] CSS classes to be added to the icon when a parent is closed. Defaults to 'fa fa-plus-circle'.\n * @param {String} [options.hideClass] CSS Class to toggle visibility of the children. Defaults to 'hide-all'.\n * @param {String} [options.iconTag] The name of icon tag. The component tries to find a tag with that name as a direct child of the node. If it doesn't find it, it creates it. Defaults to 'i'.\n * @param {Boolean} [options.stopDefault] Flag to stops the default behavior of the click handler. Defaults to true.\n * @example\n * <ul class=\"ink-tree-view\">\n * <li data-open=\"true\"><a href=\"#\">root</a>\n * <ul>\n * <li><a href=\"#\">child 1</a></li>\n * <li><a href=\"#\">child 2</a>\n * <ul>\n * <li><a href=\"#\">grandchild 2a</a></li>\n * <li><a href=\"#\">grandchild 2b</a>\n * <ul>\n * <li><a href=\"#\">grandgrandchild 1bA</a></li>\n * <li><a href=\"#\">grandgrandchild 1bB</a></li>\n * </ul>\n * </li>\n * </ul>\n * </li>\n * <li><a href=\"#\">child 3</a></li>\n * </ul>\n * </li>\n * </ul>\n * <script>\n * Ink.requireModules( ['Ink.Dom.Selector_1','Ink.UI.TreeView_1'], function( Selector, TreeView ){\n * var treeViewElement = Ink.s('.ink-tree-view');\n * var treeViewObj = new TreeView( treeViewElement );\n * });\n * </script>\n * \n * @sample Ink_UI_TreeView_1.html\n */\n function TreeView() {\n Common.BaseUIComponent.apply(this, arguments);\n }\n\n TreeView._name = 'TreeView_1';\n\n TreeView._optionDefinition = {\n 'node': ['String', 'li'],\n // [3.0.1] Deprecate this terrible, terrible name\n 'child': ['String',null],\n 'children': ['String','ul'],\n 'parentClass': ['String','parent'],\n 'openNodeClass': ['String', 'open'],\n 'openClass': ['String','fa fa-minus-circle'],\n 'closedClass': ['String','fa fa-plus-circle'],\n 'hideClass': ['String','hide-all'],\n 'iconTag': ['String', 'i'],\n 'stopDefault' : ['Boolean', true]\n };\n\n TreeView.prototype = {\n /**\n * Init function called by the constructor. Sets the necessary event handlers.\n * \n * @method _init\n * @private\n */\n _init: function(){\n if (this._options.child) {\n Ink.warn('Ink.UI.TreeView: options.child is being renamed to options.children.');\n this._options.children = this._options.child;\n }\n\n this._handlers = {\n click: Ink.bindEvent(this._onClick,this)\n };\n\n Event.on(this._element, 'click', this._options.node, this._handlers.click);\n\n InkArray.each(Ink.ss(this._options.node, this._element), Ink.bind(function(item){\n if( this.isParent(item) ) {\n Css.addClassName(item, this._options.parentClass);\n\n var isOpen = this.isOpen(item);\n if( !this._getIcon(item) ){\n Element.create(this._options.iconTag, { insertTop: item });\n }\n\n this._setNodeOpen(item, isOpen);\n }\n },this));\n },\n\n _getIcon: function (node) {\n return Ink.s('> ' + this._options.iconTag, node);\n },\n\n /**\n * Checks if a node is open.\n *\n * @method isOpen\n * @param {DOMElement} node The tree node to check\n **/\n isOpen: function (node) {\n if (!this._getChild(node)) {\n throw new Error('not a node!');\n }\n\n return Element.data(node).open === 'true' ||\n Css.hasClassName(node, this._options.openNodeClass);\n },\n\n /**\n * Checks if a node is a parent.\n *\n * @method isParent\n * @param {DOMElement} node Node to check\n **/\n isParent: function (node) {\n return Css.hasClassName(node, this._options.parentClass) ||\n this._getChild(node) != null;\n },\n\n _setNodeOpen: function (node, beOpen) {\n var child = this._getChild(node);\n if (child) {\n Css.setClassName(child, this._options.hideClass, !beOpen);\n var icon = this._getIcon(node);\n\n node.setAttribute('data-open', beOpen);\n\n /*\n * Don't refactor this to\n *\n * setClassName(el, className, status); setClassName(el, className, !status);\n *\n * because it won't work with multiple classes.\n *\n * Doing:\n * setClassName(el, 'fa fa-whatever', true);setClassName(el, 'fa fa-whatever-else', false);\n *\n * will remove 'fa' although it is a class we want.\n */\n\n var toAdd = beOpen ? this._options.openClass : this._options.closedClass;\n var toRemove = beOpen ? this._options.closedClass : this._options.openClass;\n Css.removeClassName(icon, toRemove);\n Css.addClassName(icon, toAdd);\n\n Css.setClassName(node, this._options.openNodeClass, beOpen);\n } else {\n Ink.error('Ink.UI.TreeView: node', node, 'is not a node!');\n }\n },\n\n /**\n * Opens one of the tree nodes\n *\n * Make sure you pass the node's DOMElement\n * @method open\n * @param {DOMElement} node The node you wish to open.\n **/\n open: function (node) {\n this._setNodeOpen(node, true);\n },\n\n /**\n * Closes one of the tree nodes\n *\n * Make sure you pass the node's DOMElement\n * @method close\n * @param {DOMElement} node The node you wish to close.\n **/\n close: function (node) {\n this._setNodeOpen(node, false);\n },\n\n /**\n * Toggles a node state\n *\n * @method toggle\n * @param {DOMElement} node The node to toggle.\n **/\n toggle: function (node) {\n if (this.isOpen(node)) {\n this.close(node);\n } else {\n this.open(node);\n }\n },\n\n _getChild: function (node) {\n return Selector.select(this._options.children, node)[0] || null;\n },\n\n /**\n * Handles the click event (as specified in the _init function).\n * \n * @method _onClick\n * @param {Event} event\n * @private\n */\n _onClick: function(ev){\n /**\n * Summary:\n * If the clicked element is a \"node\" as defined in the options, will check if it has any \"child\".\n * If so, will toggle its state and stop the event's default behavior if the stopDefault option is true.\n **/\n\n if (!this.isParent(ev.currentTarget) ||\n Selector.matchesSelector(ev.target, this._options.node) ||\n Selector.matchesSelector(ev.target, this._options.children)) {\n return;\n }\n\n if (this._options.stopDefault){\n ev.preventDefault();\n }\n\n this.toggle(ev.currentTarget);\n }\n };\n\n Common.createUIComponent(TreeView);\n\n return TreeView;\n});\n","Ink.createModule('Ink.UI.Upload', '1', [\n 'Ink.Dom.Event_1',\n 'Ink.Dom.Element_1',\n 'Ink.Dom.Browser_1',\n 'Ink.UI.Common_1'\n], function(Event, Element, Browser, Common) {\n 'use strict';\n\n var DirectoryReader = function(options) {\n this.init(options);\n };\n\n DirectoryReader.prototype = {\n init: function(options) {\n this._options = Ink.extendObj({\n entry: undefined,\n maxDepth: 10\n }, options || {});\n\n try {\n this._read();\n } catch(e) {\n Ink.error(e);\n }\n },\n\n\n _read: function() {\n if(!this._options.entry) {\n Ink.error('You must specify the entry!');\n return;\n }\n\n try {\n this._readDirectories();\n } catch(e) {\n Ink.error(e);\n }\n },\n\n\n _readDirectories: function() {\n var entries = [],\n running = false,\n maxDepth = 0;\n\n /* TODO return as tree because much better well */\n var _readEntries = Ink.bind(function(currentEntry) {\n var dir = currentEntry.createReader();\n running = true;\n\n dir.readEntries(Ink.bind(function(res) {\n if(res.length > 0) {\n for(var i = 0, len = res.length; i<len; i++) {\n entries.push(res[i]);\n if(!res[i].isDirectory) {\n continue;\n }\n maxDepth = this.clearArray(res[i].fullPath.split('/'));\n maxDepth.shift();\n maxDepth = maxDepth.length;\n if(maxDepth <= this._options.maxDepth) {\n _readEntries(res[i]);\n }\n }\n if(this._stopActivityTimeout) {\n clearTimeout(this._stopActivityTimeout);\n }\n this._stopActivityTimeout = setTimeout(function() {\n running = false;\n }, 250);\n }\n if(!res.length) {\n running = false;\n }\n }, this), Ink.bind(function(err) {\n this._options.readError(err, currentEntry);\n }, this));\n }, this);\n\n _readEntries(this._options.entry);\n\n var activity;\n var checkActivity = function() {\n if(running) {\n return false;\n }\n clearInterval(activity);\n if(this._options.readComplete && typeof this._options.readComplete === 'function') {\n this._options.readComplete(entries);\n }\n return true;\n };\n\n activity = setInterval(Ink.bind(checkActivity, this), 250);\n },\n\n\n clearArray: function(arr) {\n for(var i = arr.length - 1; i>=0; i--) {\n if(typeof(arr[i]) === 'undefined' || arr[i] === null || arr[i] === '') {\n arr.splice(i, 1);\n }\n }\n return arr;\n }\n };\n\n var Queue = {\n lists: [],\n items: [],\n\n\n /**\n * Create new queue list\n * @function create\n * @public\n * @param {String} list name\n * @param {Function} function to iterate on items\n * @return {Object} list id\n */\n create: function(name) {\n var id;\n name = String(name);\n this.lists.push({name: name});\n id = this.lists.length - 1;\n return id;\n },\n\n\n getItems: function(parentId) {\n if(!parentId) {\n return this.items;\n }\n var items = [];\n for(var i = 0, len = this.items.length; i<len; i++) {\n if(this.items[i].parentId === parentId) {\n items.push(this.items[i]);\n }\n }\n\n return items;\n },\n\n\n /**\n * Delete list\n * @function purge\n * @public\n * @param {String} List name\n * @return {Object} removed list\n */\n purge: function(id, keepList) {\n if(typeof(id) !== 'number' || isNaN(Number(id))) {\n return false;\n }\n try {\n for(var i = this.items.length; i>=0; i--) {\n if(this.items[i] && id === this.items[i].parentId) {\n this.remove(this.items[i].parentId, this.items[i].pid);\n }\n }\n if(!keepList) {\n this.lists.splice(id, 1);\n }\n return true;\n } catch(e) {\n Ink.error('Purge: invalid id');\n return false;\n }\n },\n\n\n /**\n * add an item to a list\n * @function add\n * @public\n * @param {String} name\n * @param {Object} item\n * @return {Number} pid\n */\n add: function(parentId, item, priority) {\n if(!this.lists[parentId]) {\n return false;\n }\n if(typeof(item) !== 'object') {\n item = String(item);\n }\n\n var pid = parseInt(Math.round(Math.random() * 100000) + \"\" + Math.round(Math.random() * 100000), 10);\n priority = priority || 0;\n\n this.items.push({parentId: parentId, item: item, priority: priority || 0, pid: pid});\n return pid;\n },\n\n\n /**\n * View list\n * @function view\n * @public\n * @param {Number} list id\n * @param {Number} process id\n * @return {Object} item\n */\n view: function(parentId, pid) {\n var id = this._searchByPid(parentId, pid);\n if(id === false) {\n return false;\n }\n return this.items[id];\n },\n\n\n /**\n * Remove an item\n * @function remove\n * @public\n * @param {Object} item\n * @return {Object|Boolean} removed item or false if not found\n */\n remove: function(parentId, pid) {\n try {\n var id = this._searchByPid(parentId, pid);\n if(id === false) {\n return false;\n }\n this.items.splice(id, 1);\n return true;\n } catch(e) {\n Ink.error('Remove: invalid id');\n return false;\n }\n },\n\n _searchByPid: function(parentId, pid) {\n if(!parentId && typeof(parentId) === 'boolean' || !pid) {\n return false;\n }\n\n parentId = parseInt(parentId, 10);\n pid = parseInt(pid, 10);\n\n if(isNaN(parentId) || isNaN(pid)) {\n return false;\n }\n\n for(var i = 0, len = this.items.length; i<len; i++) {\n if(this.items[i].parentId === parentId && this.items[i].pid === pid) {\n return i;\n }\n }\n return false;\n }\n };\n\n var UI = function(Upload) {\n this.Upload = Upload;\n this.init();\n };\n\n UI.prototype = {\n init: function() {\n this._fileButton = this.Upload._options.fileButton;\n this._dropzone = this.Upload._options.dropzone;\n this._setDropEvent();\n this._setFileButton();\n },\n\n\n _setDropEvent: function() {\n var dropzones = this._dropzone;\n if (!dropzones) { return; }\n\n for(var i = 0, len = dropzones.length; i<len; i++) {\n dropzones[i].ondrop = Ink.bindEvent(this.Upload._dropEventHandler, this.Upload);\n dropzones[i].ondragleave = Ink.bindEvent(this._onDragLeave, this);\n dropzones[i].ondragend = Ink.bindEvent(this._onDragEndEventHandler, this);\n dropzones[i].ondragdrop = Ink.bindEvent(this._onDragEndEventHandler, this);\n dropzones[i].ondragenter = Ink.bindEvent(this._onDragEnterHandler, this);\n dropzones[i].ondragover = Ink.bindEvent(this._onDragOverHandler, this);\n }\n },\n\n\n _onDragEnterHandler: function(ev) {\n if(ev && ev.stopPropagation) {\n ev.stopPropagation();\n }\n if(ev && ev.preventDefault) {\n ev.preventDefault();\n }\n if(ev) {\n ev.returnValue = false;\n }\n\n this.Upload.publish('DragEnter', ev);\n return false;\n },\n\n\n _onDragOverHandler: function(ev) {\n if(!ev) {\n return false;\n }\n ev.preventDefault();\n ev.stopPropagation();\n ev.returnValue = false;\n return true;\n },\n\n\n _onDragLeave: function(ev) {\n return this.Upload.publish('DragLeave', ev);\n },\n\n\n _onDragEndEventHandler: function(ev) {\n return this.Upload.publish('DragEnd', ev);\n },\n\n\n _setFileButton: function() {\n var btns = this._fileButton;\n if (!btns) { return; }\n Event.observeMulti(btns, 'change', Ink.bindEvent(this._fileChangeHandler, this));\n },\n\n\n _fileChangeHandler: function(ev) {\n var btn = Event.element(ev);\n var files = btn.files;\n var form = Element.findUpwardsByTag(btn, 'form');\n\n if(!files || !window.FormData || !('withCredentials' in new XMLHttpRequest())) {\n form.parentNode.submit();\n return false;\n }\n this.Upload._addFilesToQueue(files);\n btn.value = \"\";\n }\n };\n\n\n\n\n\n\n var Upload = function(options) {\n this.Queue = Queue;\n this.init(options);\n this._events = {};\n };\n\n Upload.prototype = {\n //_events: {},\n \n /**\n * This component is used to enable HTML5 upload on forms easily. It\n * evens out differences between browsers which support HTML5 upload,\n * and supports chunked uploads and directory tree uploads.\n *\n * Choose a drop zone and/or a file input. When the user drops the file\n * on the drop zone element, or chooses it using the file input,\n * Ink.UI.Upload takes care of uploading it through AJAX POST.\n *\n * The name given to the file in the POST request's data is chosen\n * through the `fileFormName` option.\n *\n * On the server side, you will receive a POST with a Content-type of\n * `multipart/form-data` or `x-www-form/urlencoded` if `useChunks`\n * is `true`.\n *\n * @class Ink.UI.Upload_1\n * @constructor\n *\n * @param options {Object} Options hash, containing:\n * @param [options.dropzone] {Element} Element where the user can drop files onto.\n * @param [options.fileButton] {Element} An `input[type=\"file\"]` for the user to choose a file using a native dialog.\n * @param [options.fileFormName='Ink_Filelist'] The name of the file in the POST request.\n * @param [options.endpoint=window.location] The URL where we're POSTing the files to. Defaults to the current location, like a HTML form.\n * @param [options.maxFileSize] Maximum file size in bytes. Defaults to 300mb.\n * @param [INVALID_FILE_NAME] A regular expression to invalidate file names. For example, set this to `/\\.png$/` if you don't want files with the \".png\" extension. Remember that file extensions are just hints!\n * @param [options.extraData] Add more data to your POST request. Each key in this hash gets added to the form data sent to the server.\n * TODO chunk options, also write a bit above about chunking and the serverside of chunking.\n * TODO directory options, also write a bit above about directories and the server end of directories.\n */\n init: function(options) {\n if (typeof options === 'string') {\n options = Element.data(Common.elOrSelector(options, '1st argument'));\n }\n this._options = Ink.extendObj({\n dropzone: undefined,\n fileButton: undefined,\n fileFormName: 'Ink_Filelist', // TODO default to fileButton's [name] if available.\n endpoint: '',\n maxFilesize: 300 << 20, //300mb\n INVALID_FILE_NAME: undefined,\n extraData: {},\n // Chunks\n useChunks: false,\n chunkSize: 4194304, // 4MB\n minSizeToUseChunks: 20971520, // 20mb\n endpointChunk: '', // Where to send chunk data.\n endpointChunkCommit:'', // Where to send the \"chunk transaction\" commit.\n // Directory trees\n foldersEnabled: false,\n directoryMaxDepth: 10\n }, options || {});\n\n this._queueId = Queue.create('Ink_UPLOAD');\n this._queueRunning = false;\n this._folders = {};\n\n\n if(this._options.dropzone) {\n this._options.dropzone =\n Common.elsOrSelector(this._options.dropzone, 'Ink.UI.Upload - dropzone');\n }\n\n if(this._options.fileButton) {\n this._options.fileButton =\n Common.elsOrSelector(this._options.fileButton, 'Ink.UI.Upload - fileButton');\n }\n\n if(!this._options.dropzone && !this._options.fileButton) {\n throw new TypeError(\n 'Ink.UI.Upload: Specify a fileButton or a Dropzone!');\n }\n\n new UI(this);\n },\n\n\n _supportChunks: function(size) {\n return this._options.useChunks &&\n 'Blob' in window &&\n (new Blob()).slice &&\n size > this._options.minSizeToUseChunks;\n },\n\n\n _dropEventHandler: function(ev) {\n Event.stop(ev);\n\n this.publish('DropComplete', ev.dataTransfer);\n\n var data = ev.dataTransfer;\n\n if(!data || !data.files || !data.files.length) {\n return false;\n }\n\n this._files = data.files;\n this._files = Array.prototype.slice.call(this._files || [], 0);\n\n // check if webkitGetAsEntry exists on first item\n if(data.items && data.items[0] && data.items[0].webkitGetAsEntry) {\n if(!this._options.foldersEnabled) {\n return setTimeout(Ink.bind(this._addFilesToQueue, this, this._files), 0);\n }\n var entry, folders = [];\n for(var i = ev.dataTransfer.items.length-1; i>=0; i--) {\n entry = ev.dataTransfer.items[i].webkitGetAsEntry();\n if(entry && entry.isDirectory) {\n folders.push(entry);\n this._files[i].isDirectory = true;\n this._files.splice(i, 1);\n }\n }\n // starting callback hell\n this._addFolderToQueue(folders, Ink.bind(function() {\n setTimeout(Ink.bind(this._addFilesToQueue, this, this._files), 0);\n }, this));\n } else {\n setTimeout(Ink.bind(this._addFilesToQueue, this, this._files), 0);\n }\n\n return true;\n },\n\n\n _addFolderToQueue: function(folders, cb) {\n var files = [], invalidFolders = {};\n\n if(!folders || !folders.length) {\n cb();\n return files;\n }\n\n var getFiles = function(entries) {\n var files = [];\n for(var i = 0, len = entries.length; i<len; i++) {\n if(entries[i].isFile) {\n files.push(entries[i]);\n }\n }\n return files;\n };\n\n var convertToFile = function(cb, index) {\n var fullPath;\n index = index || 0;\n if(!this._files[index]) {\n cb();\n return files;\n }\n if(this._files[index].constructor.name.toLowerCase() !== 'fileentry') {\n return convertToFile.apply(this, [cb, ++index]);\n }\n this._files[index].file(Ink.bind(function(res) {\n fullPath = this._files[index].fullPath; // bug\n this._files[index] = res;\n this._files[index].hasParent = true;\n\n // if browser don't have it natively, set it\n if(!this._files[index].fullPath) {\n this._files[index].fullPath = fullPath;\n }\n convertToFile.apply(this, [cb, ++index]);\n }, this), Ink.bind(function() {\n this._files.splice(index, 1);\n convertToFile.apply(this, [cb, index]);\n }, this));\n };\n\n var getSubDirs = Ink.bind(function(index) {\n if(!folders[index]) {\n this._files = this._files.concat(files);\n convertToFile.call(this, cb);\n return false;\n }\n\n new DirectoryReader({\n entry: folders[index],\n maxDepth: this._options.directoryMaxDepth,\n readComplete: Ink.bind(function(entries) {\n files = files.concat(getFiles(entries));\n // adding root dirs\n if(!folders[index] || folders[index].fullPath in this._folders) {\n return;\n }\n\n this._folders[folders[index].fullPath] = {\n items: entries,\n files: files,\n length: entries.length,\n created: false,\n root: true\n };\n\n // adding sub dirs\n for(var i = 0, len = entries.length; i<len; i++) {\n if(entries[i].isFile) {\n continue;\n }\n if(entries[i].fullPath in invalidFolders) {\n delete invalidFolders[entries[i].fullPath];\n continue;\n }\n this._folders[entries[i].fullPath] = {\n created: false,\n root: false\n };\n }\n getSubDirs(++index);\n }, this),\n readError: Ink.bind(function(err, dir) {\n invalidFolders[dir.fullPath] = {};\n invalidFolders[dir.fullPath].error = err;\n }, this)\n });\n }, this);\n\n getSubDirs(0);\n return files;\n },\n\n\n _addFilesToQueue: function(files) {\n var file, fileID, o;\n for(var i = 0, len = files.length; i<len; i++) {\n file = files[i];\n\n if(!file.isDirectory) {\n // dirty hack to allow 0B files avoiding folders on GECKO\n if(file === null || (!file.type && file.size % 4096 === 0 && (!Browser.CHROME || !this._options.foldersEnabled))) {\n this.publish('InvalidFile', file, 'size');\n continue;\n }\n }\n\n if(file.size > this._options.maxFilesize) {\n this.publish('MaxSizeFailure', file, this._options.maxFilesize);\n continue;\n }\n\n fileID = parseInt(Math.round(Math.random() * 100000) + \"\" + Math.round(Math.random() * 100000), 10);\n o = { id: i, data: file, fileID: fileID, directory: file.isDirectory };\n Queue.add(this._queueId, o);\n\n this.publish('FileAddedToQueue', o);\n }\n this._processQueue(true);\n this._files = [];\n },\n\n\n _processQueue: function(internalUpload) {\n if(this._queueRunning) {\n return false;\n }\n\n this.running = 0;\n var max = 1, i = 0, items,\n queueLen = Queue.items.length;\n this._queueRunning = true;\n\n this.interval = setInterval(Ink.bind(function() {\n if(Queue.items.length === i && this.running === 0) {\n Queue.purge(this._queueId, true);\n this._queueRunning = false;\n clearInterval(this.interval);\n this.publish('QueueEnd', this._queueId, queueLen);\n }\n\n items = Queue.getItems(this._queueId);\n\n if(this.running < max && items[i]) {\n if(!items[i].canceled) {\n _doRequest.call(this, items[i].pid, items[i].item.data, items[i].item.fileID, items[i].item.directory, internalUpload);\n this.running++;\n i++;\n } else {\n var j = i;\n while(items[j] && items[j].canceled) {\n i++;\n j++;\n }\n }\n return true;\n }\n return false;\n }, this), 100);\n\n\n var _doRequest = function(pid, data, fileID, directory, internalUpload) {\n var o = {\n file: data,\n fileID: fileID,\n cb: Ink.bind(function() {\n this.running--;\n }, this)\n };\n if(internalUpload) {\n if(directory) {\n // do magic\n o.cb();\n } else {\n this._upload(o);\n }\n }\n };\n\n return true;\n },\n\n\n _upload: function(o) {\n var file = o.file,\n xhr = new XMLHttpRequest(),\n fileID = o.fileID;\n\n this.publish('BeforeUpload', file, this._options.extraData, fileID, xhr, this._supportChunks(file.size));\n\n var forceAbort = function(showError) {\n if(o.cb && typeof(o.cb === 'function')) {\n o.cb();\n }\n\n this.publish('OnProgress', {\n length: file.size,\n lengthComputable: true,\n loaded: file.size,\n total: file.size\n }, file, fileID);\n this.publish('EndUpload', file, fileID, (showError ? { error: true } : true));\n this.publish('InvalidFile', file, 'name');\n xhr.abort();\n };\n\n if(this._options.INVALID_FILE_NAME && this._options.INVALID_FILE_NAME instanceof RegExp) {\n if(this._options.INVALID_FILE_NAME.test(o.file.name)) {\n forceAbort.call(this);\n return;\n }\n }\n\n // If file was renamed, abort it\n // FU OPERA: Opera always return lastModified date as null\n if(!file.lastModifiedDate && !Ink.Dom.Browser.OPERA) {\n forceAbort.call(this, true);\n return;\n }\n\n xhr.upload.onprogress = Ink.bind(this.publish, this, 'OnProgress', file, fileID);\n\n var endpoint, method;\n if(this._supportChunks(file.size)) {\n if(file.size <= file.chunk_offset) {\n endpoint = this._options.endpointChunkCommit;\n method = 'POST';\n } else {\n endpoint = this._options.endpointChunk;\n if(file.chunk_upload_id) {\n endpoint += '?upload_id=' + file.chunk_upload_id;\n }\n if(file.chunk_offset) {\n endpoint += '&offset=' + file.chunk_offset;\n }\n method = 'PUT';\n }\n } else {\n endpoint = this._options.endpoint;\n method = 'POST';\n }\n\n xhr.open(method, endpoint, true);\n xhr.withCredentials = true;\n xhr.setRequestHeader(\"x-requested-with\", \"XMLHttpRequest\");\n if(this._supportChunks(file.size)) {\n xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');\n }\n\n var fd = new FormData(),\n blob;\n\n if(\"Blob\" in window && typeof Blob === 'function') {\n blob = new Blob([file], { type: file.type });\n if(this._supportChunks(file.size)) {\n file.chunk_offset = file.chunk_offset || 0;\n blob = blob.slice(file.chunk_offset, file.chunk_offset + this._options.chunkSize);\n } else {\n fd.append(this._options.fileFormName, blob, file.name);\n }\n } else {\n fd.append(this._options.fileFormName, file);\n }\n\n if(!this._supportChunks(file.size)) {\n for(var k in this._options.extraData) {\n if(this._options.extraData.hasOwnProperty(k)) {\n fd.append(k, this._options.extraData[k]);\n }\n }\n } else {\n fd.append('upload_id', file.chunk_upload_id);\n fd.append('path', file.upload_path);\n }\n\n if(!file.hasParent) {\n if(!this._supportChunks(file.size)) {\n xhr.send(fd);\n } else {\n if(file.size <= file.chunk_offset) {\n xhr.send('upload_id=' + file.chunk_upload_id + '&path=' + file.upload_path + '/' + file.name);\n } else {\n xhr.send(blob);\n }\n }\n } else {\n this.publish('cbCreateFolder', file.parentID, file.fullPath, this._options.extraData, this._folders, file.rootPath, Ink.bind(function() {\n if(!this._supportChunks(file.size)) {\n xhr.send(fd);\n } else {\n if(file.size <= file.chunk_offset) {\n xhr.send('upload_id=' + file.chunk_upload_id + '&path=' + file.upload_path + '/' + file.name);\n } else {\n xhr.send(blob);\n }\n }\n }, this));\n }\n\n\n xhr.onload = Ink.bindEvent(function() {\n /* jshint boss:true */\n if(this._supportChunks(file.size) && file.size > file.chunk_offset) {\n if(xhr.response) {\n var response = JSON.parse(xhr.response);\n\n // check expected offset\n var invalidOffset = file.chunk_offset && response.offset !== (file.chunk_offset + this._options.chunkSize) && file.size !== response.offset;\n if(invalidOffset) {\n if(o.cb) {\n o.cb();\n }\n this.publish('ErrorUpload', file, fileID);\n } else {\n file.chunk_upload_id = response.upload_id;\n file.chunk_offset = response.offset;\n file.chunk_expires = response.expires;\n this._upload(o);\n }\n } else {\n if(o.cb) {\n o.cb();\n }\n this.publish('ErrorUpload', file, fileID);\n }\n return (xhr = null);\n }\n\n if(o.cb) {\n o.cb();\n }\n\n if(xhr.responseText && xhr['status'] < 400) {\n this.publish('EndUpload', file, fileID, xhr.responseText);\n } else {\n this.publish('ErrorUpload', file, fileID);\n }\n return (xhr = null);\n }, this);\n\n\n xhr.onerror = Ink.bindEvent(function() {\n if(o.cb) {\n o.cb();\n }\n this.publish('ErrorUpload', file, fileID);\n }, this);\n\n xhr.onabort = Ink.bindEvent(function() {\n if(o.cb) {\n o.cb();\n }\n this.publish('AbortUpload', file, fileID, {\n abortAll: Ink.bind(this.abortAll, this),\n abortOne: Ink.bind(this.abortOne, this)\n });\n }, this);\n },\n\n\n abortAll: function() {\n if(!this._queueRunning) {\n return false;\n }\n clearInterval(this.interval);\n this._queueRunning = false;\n Queue.purge(this._queueId, true);\n return true;\n },\n\n abortOne: function(id, cb) {\n var items = Queue.getItems(0),\n o;\n for(var i = 0, len = items.length; i<len; i++) {\n if(items[i].item.fileID === id) {\n o = {\n id: items[i].item.fileID,\n name: items[i].item.data.name,\n size: items[i].item.data.size,\n hasParent: items[i].item.data.hasParent\n };\n Queue.remove(0, items[i].pid);\n if(cb) {\n cb(o);\n }\n return true;\n }\n }\n return false;\n },\n\n\n subscribe: function(eventName, fn) {\n if(!this._events[eventName]) {\n this._events[eventName] = [];\n }\n this._events[eventName].push(fn);\n return this._events[eventName];\n },\n\n\n publish: function(eventName) {\n var events = this._events[eventName],\n args = Array.prototype.slice.call(arguments || [], 0);\n\n if(!events) {\n return;\n }\n\n for(var i = 0, len = events.length; i<len; i++) {\n try {\n events[i].apply(this, args.splice(1, args.length));\n } catch(err) {\n Ink.error(eventName + \": \" + err);\n }\n }\n }\n };\n\n return Upload;\n});\n","/**\n * Array Utilities\n * @module Ink.Util.Array_1\n * @version 1\n */\n\nInk.createModule('Ink.Util.Array', '1', [], function() {\n\n 'use strict';\n\n var arrayProto = Array.prototype;\n\n /**\n * @namespace Ink.Util.Array_1\n */\n\n var InkArray = {\n\n /**\n * Checks if a value is an array\n *\n * @method isArray\n * @param testedObject {Mixed} The object we want to check\n **/\n isArray: Array.isArray || function (testedObject) {\n return {}.toString.call(testedObject) === '[object Array]';\n },\n\n /**\n * Loops through an array, grouping similar items together.\n * @method groupBy\n * @param arr {Array} The input array.\n * @param [options] {Object} options object, containing:\n * @param [options.key] {Function} A function which computes the group key by which the items are grouped.\n * @param [options.pairs] {Boolean} Set to `true` if you want to output an array of `[key, [group...]]` pairs instead of an array of groups.\n * @return {Array} An array of arrays of chunks.\n *\n * @example\n *\n * InkArray.groupBy([1, 1, 2, 2, 3, 1]) // -> [ [1, 1], [2, 2], [3], [1] ]\n * InkArray.groupBy([1.1, 1.2, 2.1], { key: Math.floor }) // -> [ [1.1, 1.2], [2.1] ]\n * InkArray.groupBy([1.1, 1.2, 2.1], { key: Math.floor, pairs: true }) // -> [ [1, [1.1, 1.2]], [2, [2.1]] ]\n *\n **/\n groupBy: function (arr, options) {\n options = options || {};\n var ret = [];\n var latestGroup;\n function eq(a, b) {\n return outKey(a) === outKey(b);\n }\n function outKey(item) {\n if (typeof options.key === 'function') {\n return options.key(item);\n } else {\n return item;\n }\n }\n\n for (var i = 0, len = arr.length; i < len; i++) {\n latestGroup = [arr[i]];\n\n // Chunkin'\n while ((i + 1 < len) && eq(arr[i], arr[i + 1])) {\n latestGroup.push(arr[i + 1]);\n i++;\n }\n\n if (options.pairs) {\n ret.push([outKey(arr[i]), latestGroup]);\n } else {\n ret.push(latestGroup);\n }\n }\n return ret;\n },\n\n /**\n * Replacement for Array.prototype.reduce.\n *\n * Produces a single result from a list of values by calling an \"aggregator\" function.\n *\n * Falls back to Array.prototype.reduce if available.\n *\n * @method reduce\n * @param array {Array} Input array to be reduced.\n * @param callback {Function} `function (previousValue, currentValue, index, all) { return {Mixed} }` to execute for each value.\n * @param initial {Mixed} Object used as the first argument to the first call of `callback`\n *\n * @example\n * var sum = InkArray.reduce([1, 2, 3], function (a, b) { return a + b; }); // -> 6\n */\n reduce: function (array, callback, initial) {\n if (arrayProto.reduce) {\n return arrayProto.reduce.apply(array, [].slice.call(arguments, 1));\n }\n\n // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce#Polyfill\n var t = Object( array ), len = t.length >>> 0, k = 0, value;\n if ( arguments.length >= 3 ) {\n value = initial;\n } else {\n while ( k < len && !(k in t) ) k++;\n if ( k >= len )\n throw new TypeError('Reduce of empty array with no initial value');\n value = t[ k++ ];\n }\n for ( ; k < len ; k++ ) {\n if ( k in t ) {\n value = callback( value, t[k], k, t );\n }\n }\n return value;\n },\n\n /**\n * Checks if a value exists in array\n *\n * @method inArray\n * @public\n * @static\n * @param {Mixed} value Value to check\n * @param {Array} arr Array to search in\n * @return {Boolean} True if value exists in the array\n * @sample Ink_Util_Array_inArray.html\n */\n inArray: function(value, arr) {\n if (typeof arr === 'object') {\n for (var i = 0, f = arr.length; i < f; ++i) {\n if (arr[i] === value) {\n return true;\n }\n }\n }\n return false;\n },\n\n /**\n * Sorts an array of objects by an object property\n *\n * @method sortMulti\n * @param {Array} arr Array of objects to sort\n * @param {String} key Property to sort by\n * @return {Array|Boolean} False if it's not an array, returns a sorted array if it's an array.\n * @public\n * @static\n * @sample Ink_Util_Array_sortMulti.html\n */\n sortMulti: function(arr, key) {\n if (typeof arr === 'undefined' || arr.constructor !== Array) { return false; }\n if (typeof key !== 'string') { return arr.sort(); }\n if (arr.length > 0) {\n if (typeof(arr[0][key]) === 'undefined') { return false; }\n arr.sort(function(a, b){\n var x = a[key];\n var y = b[key];\n return ((x < y) ? -1 : ((x > y) ? 1 : 0));\n });\n }\n return arr;\n },\n\n /**\n * Gets the indexes of a value in an array\n *\n * @method keyValue\n * @param {String} value Value to search for.\n * @param {Array} arr Array to run the search in.\n * @param {Boolean} [first] Flag to stop the search at the first match. It also returns an index number instead of an array of indexes.\n * @return {Boolean|Number|Array} False for no matches. Array of matches or first match index.\n * @public\n * @static\n * @sample Ink_Util_Array_keyValue.html\n */\n keyValue: function(value, arr, first) {\n if (typeof value !== 'undefined' && typeof arr === 'object' && this.inArray(value, arr)) {\n var aKeys = [];\n for (var i = 0, f = arr.length; i < f; ++i) {\n if (arr[i] === value) {\n if (typeof first !== 'undefined' && first === true) {\n return i;\n } else {\n aKeys.push(i);\n }\n }\n }\n return aKeys;\n }\n return false;\n },\n\n /**\n * Shuffles an array.\n *\n * @method shuffle\n * @param {Array} arr Array to shuffle\n * @return {Array|Boolean} Shuffled Array or false if not an array.\n * @public\n * @static\n * @sample Ink_Util_Array_shuffle.html\n */\n shuffle: function(arr) {\n if (typeof(arr) !== 'undefined' && arr.constructor !== Array) { return false; }\n var total = arr.length,\n tmp1 = false,\n rnd = false;\n\n while (total--) {\n rnd = Math.floor(Math.random() * (total + 1));\n tmp1 = arr[total];\n arr[total] = arr[rnd];\n arr[rnd] = tmp1;\n }\n return arr;\n },\n\n /**\n * Runs a function through each of the elements of an array\n *\n * @method forEach\n * @param {Array} arr The array to be cycled/iterated\n * @param {Function} cb The function receives as arguments the value, index and array.\n * @return {Array} Iterated array.\n * @public\n * @static\n * @sample Ink_Util_Array_forEach.html\n */\n forEach: function(array, callback, context) {\n if (arrayProto.forEach) {\n return arrayProto.forEach.call(array, callback, context);\n }\n for (var i = 0, len = array.length >>> 0; i < len; i++) {\n callback.call(context, array[i], i, array);\n }\n },\n\n /**\n * Alias for backwards compatibility. See forEach\n *\n * @method each\n */\n each: function () {\n InkArray.forEach.apply(InkArray, [].slice.call(arguments));\n },\n\n /**\n * Runs a function for each item in the array.\n * That function will receive each item as an argument and its return value will change the corresponding array item.\n * @method map\n * @param {Array} array The array to map over\n * @param {Function} map The map function. Will take `(item, index, array)` as arguments and `this` will be the `context` argument.\n * @param {Object} [context] Object to be `this` in the map function.\n *\n * @sample Ink_Util_Array_map.html\n */\n map: function (array, callback, context) {\n if (arrayProto.map) {\n return arrayProto.map.call(array, callback, context);\n }\n var mapped = new Array(len);\n for (var i = 0, len = array.length >>> 0; i < len; i++) {\n mapped[i] = callback.call(context, array[i], i, array);\n }\n return mapped;\n },\n\n /**\n * Filters an array based on a truth test.\n * This method runs a test function on all the array values and returns a new array with all the values that pass the test.\n * @method filter\n * @param {Array} array The array to filter\n * @param {Function} test A test function taking `(item, index, array)`\n * @param {Object} [context] Object to be `this` in the test function.\n * @return {Array} Returns the filtered array\n *\n * @sample Ink_Util_Array_filter.html\n */\n filter: function (array, test, context) {\n if (arrayProto.filter) {\n return arrayProto.filter.call(array, test, context);\n }\n var filtered = [],\n val = null;\n for (var i = 0, len = array.length; i < len; i++) {\n val = array[i]; // it might be mutated\n if (test.call(context, val, i, array)) {\n filtered.push(val);\n }\n }\n return filtered;\n },\n\n /**\n * Checks if some element in the array passes a truth test\n *\n * @method some\n * @param {Array} arr The array to iterate through\n * @param {Function} cb The callback to be called on the array's elements. It receives the value, the index and the array as arguments.\n * @param {Object} context Object of the callback function\n * @return {Boolean} True if the callback returns true at any point, false otherwise\n * @public\n * @static\n * @sample Ink_Util_Array_some.html\n */\n some: function(arr, cb, context){\n\n if (arr === null){\n throw new TypeError('First argument is invalid.');\n }\n\n var t = Object(arr);\n var len = t.length >>> 0;\n if (typeof cb !== \"function\"){ throw new TypeError('Second argument must be a function.'); }\n\n for (var i = 0; i < len; i++) {\n if (i in t && cb.call(context, t[i], i, t)){ return true; }\n }\n\n return false;\n },\n\n /**\n * Compares the values of two arrays and return the matches\n *\n * @method intersect\n * @param {Array} arr1 First array\n * @param {Array} arr2 Second array\n * @return {Array} Empty array if one of the arrays is false (or do not intersect) | Array with the intersected values\n * @public\n * @static\n * @sample Ink_Util_Array_intersect.html\n */\n intersect: function(arr1, arr2) {\n if (!arr1 || !arr2 || arr1 instanceof Array === false || arr2 instanceof Array === false) {\n return [];\n }\n\n var shared = [];\n for (var i = 0, I = arr1.length; i<I; ++i) {\n for (var j = 0, J = arr2.length; j < J; ++j) {\n if (arr1[i] === arr2[j]) {\n shared.push(arr1[i]);\n }\n }\n }\n\n return shared;\n },\n\n /**\n * Converts an array-like object to an array\n *\n * @method convert\n * @param {Array} arr Array to be converted\n * @return {Array} Array resulting of the conversion\n * @public\n * @static\n * @sample Ink_Util_Array_convert.html\n */\n convert: function(arr) {\n return arrayProto.slice.call(arr || [], 0);\n },\n\n /**\n * Removes duplicated values in an array.\n *\n * @method unique\n * @param {Array} arr Array to filter\n * @return {Array} Array with only unique values\n * @public\n * @static\n */\n unique: function(arr){\n if(!Array.prototype.lastIndexOf){ //IE8 slower alternative\n var newArr = [];\n\n InkArray.forEach(InkArray.convert(arr), function(i){\n if(!InkArray.inArray(i,newArr)){\n newArr.push(i);\n }\n });\n return newArr;\n }//else\n return InkArray.filter(InkArray.convert(arr), function (e, i, arr) {\n return arr.lastIndexOf(e) === i;\n });\n },\n\n /**\n * Simulates python's range(start, stop, step) function.\n *\n * Creates a list with numbers counting from start until stop, using a for loop.\n *.\n * The optional step argument defines how to step ahead. You can pass a negative number to count backwards (see the examples below).\n *\n * @method range\n * @param {Number} start The array's first element.\n * @param {Number} stop Stop counting before this number.\n * @param {Number} [step=1] Interval between numbers. You can use a negative number to count backwards.\n *\n * @sample Ink_Util_Array_1_range.html\n **/\n range: function range(a, b, step) {\n // From: https://github.com/mcandre/node-range\n if (!step) {\n step = 1;\n }\n\n var r = [];\n var x;\n\n if (step > 0) {\n for (x = a; x < b; x += step) {\n r.push(x);\n }\n } else {\n for (x = a; x > b; x += step) {\n r.push(x);\n }\n }\n\n return r;\n },\n\n /**\n * Inserts a value on a specified index\n *\n * @method insert\n * @param {Array} arr Array where the value will be inserted\n * @param {Number} idx Index of the array where the value should be inserted\n * @param {Mixed} value Value to be inserted\n * @public\n * @static\n * @sample Ink_Util_Array_insert.html\n */\n insert: function(arr, idx, value) {\n arr.splice(idx, 0, value);\n },\n\n /**\n * Removes a range of values from the array\n *\n * @method remove\n * @param {Array} arr Array where the value will be removed\n * @param {Number} from Index of the array where the removal will start removing.\n * @param {Number} rLen Number of items to be removed from the index onwards.\n * @return {Array} An array with the remaining values\n * @public\n * @static\n * @sample Ink_Util_Array_remove.html\n */\n remove: function(arr, from, rLen){\n var output = [];\n\n for(var i = 0, iLen = arr.length; i < iLen; i++){\n if(i >= from && i < from + rLen){\n continue;\n }\n\n output.push(arr[i]);\n }\n\n return output;\n }\n };\n\n return InkArray;\n\n});\n","/**\n * Binary Packing algorithm implementation\n * @module Ink.Util.BinPack_1\n * @version 1\n */\n\nInk.createModule('Ink.Util.BinPack', '1', [], function() {\n\n 'use strict';\n\n /*jshint boss:true */\n\n // https://github.com/jakesgordon/bin-packing/\n\n /*\n Copyright (c) 2011, 2012, 2013 Jake Gordon and contributors\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n */\n\n\n\n var Packer = function(w, h) {\n this.init(w, h);\n };\n\n Packer.prototype = {\n\n init: function(w, h) {\n this.root = { x: 0, y: 0, w: w, h: h };\n },\n\n fit: function(blocks) {\n var n, node, block;\n for (n = 0; n < blocks.length; ++n) {\n block = blocks[n];\n if (node = this.findNode(this.root, block.w, block.h)) {\n block.fit = this.splitNode(node, block.w, block.h);\n }\n }\n },\n\n findNode: function(root, w, h) {\n if (root.used) {\n return this.findNode(root.right, w, h) || this.findNode(root.down, w, h);\n }\n else if ((w <= root.w) && (h <= root.h)) {\n return root;\n }\n else {\n return null;\n }\n },\n\n splitNode: function(node, w, h) {\n node.used = true;\n node.down = { x: node.x, y: node.y + h, w: node.w, h: node.h - h };\n node.right = { x: node.x + w, y: node.y, w: node.w - w, h: h };\n return node;\n }\n\n };\n\n\n\n var GrowingPacker = function() {};\n\n GrowingPacker.prototype = {\n\n fit: function(blocks) {\n var n, node, block, len = blocks.length;\n var w = len > 0 ? blocks[0].w : 0;\n var h = len > 0 ? blocks[0].h : 0;\n this.root = { x: 0, y: 0, w: w, h: h };\n for (n = 0; n < len ; n++) {\n block = blocks[n];\n if (node = this.findNode(this.root, block.w, block.h)) {\n block.fit = this.splitNode(node, block.w, block.h);\n }\n else {\n block.fit = this.growNode(block.w, block.h);\n }\n }\n },\n\n findNode: function(root, w, h) {\n if (root.used) {\n return this.findNode(root.right, w, h) || this.findNode(root.down, w, h);\n }\n else if ((w <= root.w) && (h <= root.h)) {\n return root;\n }\n else {\n return null;\n }\n },\n\n splitNode: function(node, w, h) {\n node.used = true;\n node.down = { x: node.x, y: node.y + h, w: node.w, h: node.h - h };\n node.right = { x: node.x + w, y: node.y, w: node.w - w, h: h };\n return node;\n },\n\n growNode: function(w, h) {\n var canGrowDown = (w <= this.root.w);\n var canGrowRight = (h <= this.root.h);\n\n var shouldGrowRight = canGrowRight && (this.root.h >= (this.root.w + w)); // attempt to keep square-ish by growing right when height is much greater than width\n var shouldGrowDown = canGrowDown && (this.root.w >= (this.root.h + h)); // attempt to keep square-ish by growing down when width is much greater than height\n\n if (shouldGrowRight) {\n return this.growRight(w, h);\n }\n else if (shouldGrowDown) {\n return this.growDown(w, h);\n }\n else if (canGrowRight) {\n return this.growRight(w, h);\n }\n else if (canGrowDown) {\n return this.growDown(w, h);\n }\n else {\n return null; // need to ensure sensible root starting size to avoid this happening\n }\n },\n\n growRight: function(w, h) {\n this.root = {\n used: true,\n x: 0,\n y: 0,\n w: this.root.w + w,\n h: this.root.h,\n down: this.root,\n right: { x: this.root.w, y: 0, w: w, h: this.root.h }\n };\n var node;\n if (node = this.findNode(this.root, w, h)) {\n return this.splitNode(node, w, h);\n }\n else {\n return null;\n }\n },\n\n growDown: function(w, h) {\n this.root = {\n used: true,\n x: 0,\n y: 0,\n w: this.root.w,\n h: this.root.h + h,\n down: { x: 0, y: this.root.h, w: this.root.w, h: h },\n right: this.root\n };\n var node;\n if (node = this.findNode(this.root, w, h)) {\n return this.splitNode(node, w, h);\n }\n else {\n return null;\n }\n }\n\n };\n\n\n\n var sorts = {\n random: function() { return Math.random() - 0.5; },\n w: function(a, b) { return b.w - a.w; },\n h: function(a, b) { return b.h - a.h; },\n a: function(a, b) { return b.area - a.area; },\n max: function(a, b) { return Math.max(b.w, b.h) - Math.max(a.w, a.h); },\n min: function(a, b) { return Math.min(b.w, b.h) - Math.min(a.w, a.h); },\n height: function(a, b) { return sorts.msort(a, b, ['h', 'w']); },\n width: function(a, b) { return sorts.msort(a, b, ['w', 'h']); },\n area: function(a, b) { return sorts.msort(a, b, ['a', 'h', 'w']); },\n maxside: function(a, b) { return sorts.msort(a, b, ['max', 'min', 'h', 'w']); },\n msort: function(a, b, criteria) { /* sort by multiple criteria */\n var diff, n;\n for (n = 0; n < criteria.length; ++n) {\n diff = sorts[ criteria[n] ](a, b);\n if (diff !== 0) {\n return diff;\n }\n }\n return 0;\n }\n };\n\n\n\n // end of Jake's code\n\n\n\n // aux, used to display blocks in unfitted property\n var toString = function() {\n return [this.w, ' x ', this.h].join('');\n };\n\n\n\n /**\n * Binary Packing algorithm implementation\n *\n * Based on the work of Jake Gordon\n *\n * see https://github.com/jakesgordon/bin-packing/\n *\n * @namespace Ink.Util.BinPack\n * @version 1\n * @static\n */\n var BinPack = {\n\n /**\n * @method binPack\n * @param {Object} o Options\n * @param {Array} o.blocks Array of items with width and height integer attributes.\n * @param {Array} [o.dimensions] Flag to fix container dimensions\n * @param {String} [o.sorter] Sorting function. One of: random, height, width, area, maxside\n * @return {Object} Returns an object containing container dimensions, filled ratio, fitted blocks, unfitted blocks and all blocks\n * @static\n */\n binPack: function(o) {\n var i, f, bl;\n\n\n\n // calculate area if not there already\n for (i = 0, f = o.blocks.length; i < f; ++i) {\n bl = o.blocks[i];\n if (! ('area' in bl) ) {\n bl.area = bl.w * bl.h;\n }\n }\n\n\n\n // apply algorithm\n var packer = o.dimensions ? new Packer(o.dimensions[0], o.dimensions[1]) : new GrowingPacker();\n\n if (!o.sorter) { o.sorter = 'maxside'; }\n\n o.blocks.sort( sorts[ o.sorter ] );\n\n packer.fit(o.blocks);\n\n var dims2 = [packer.root.w, packer.root.h];\n\n\n\n // layout is done here, generating report data...\n var fitted = [];\n var unfitted = [];\n\n for (i = 0, f = o.blocks.length; i < f; ++i) {\n bl = o.blocks[i];\n if (bl.fit) {\n fitted.push(bl);\n }\n else {\n bl.toString = toString; // TO AID SERIALIZATION\n unfitted.push(bl);\n }\n }\n\n var area = dims2[0] * dims2[1];\n var fit = 0;\n for (i = 0, f = fitted.length; i < f; ++i) {\n bl = fitted[i];\n fit += bl.area;\n }\n\n return {\n dimensions: dims2,\n filled: fit / area,\n blocks: o.blocks,\n fitted: fitted,\n unfitted: unfitted\n };\n }\n };\n\n\n\n return BinPack;\n\n});","/**\n * Cookie Utilities\n * @module Ink.Util.Cookie_1\n * @version 1\n */\n\nInk.createModule('Ink.Util.Cookie', '1', [], function() {\n\n 'use strict';\n\n /**\n * @namespace Ink.Util.Cookie_1\n */\n var Cookie = {\n\n /**\n * Gets an object with the current page cookies.\n *\n * @method get\n * @param {String} name The cookie name.\n * @return {String|Object} If the name is specified, it returns the value of that key. Otherwise it returns the full cookie object\n * @public\n * @static\n * @sample Ink_Util_Cookie_get.html\n */\n get: function(name)\n {\n var cookie = document.cookie || false;\n\n var _Cookie = {};\n if(cookie) {\n cookie = cookie.replace(new RegExp(\"; \", \"g\"), ';');\n var aCookie = cookie.split(';');\n var aItem = [];\n if(aCookie.length > 0) {\n for(var i=0; i < aCookie.length; i++) {\n aItem = aCookie[i].split('=');\n if(aItem.length === 2) {\n _Cookie[aItem[0]] = decodeURIComponent(aItem[1]);\n }\n aItem = [];\n }\n }\n }\n if(name) {\n if(typeof(_Cookie[name]) !== 'undefined') {\n return _Cookie[name];\n } else {\n return null;\n }\n }\n return _Cookie;\n },\n\n /**\n * Sets a cookie.\n *\n * @method set\n * @param {String} name Cookie name.\n * @param {String} value Cookie value.\n * @param {Number} [expires] Number of seconds the cookie will be valid for.\n * @param {String} [path] Path for the cookie. Defaults to '/'.\n * @param {String} [domain] Domain for the cookie. Defaults to current hostname.\n * @param {Boolean} [secure] Flag for secure. Default 'false'.\n * @public\n * @static\n * @sample Ink_Util_Cookie_set.html\n */\n set: function(name, value, expires, path, domain, secure)\n {\n var sName;\n if(!name || value===false || typeof(name) === 'undefined' || typeof(value) === 'undefined') {\n return false;\n } else {\n sName = name+'='+encodeURIComponent(value);\n }\n var sExpires = false;\n var sPath = false;\n var sDomain = false;\n var sSecure = false;\n\n if(expires && typeof(expires) !== 'undefined' && !isNaN(expires)) {\n var oDate = new Date();\n var sDate = (parseInt(Number(oDate.valueOf()), 10) + (Number(parseInt(expires, 10)) * 1000));\n\n var nDate = new Date(sDate);\n var expiresString = nDate.toGMTString();\n\n var re = new RegExp(\"([^\\\\s]+)(\\\\s\\\\d\\\\d)\\\\s(\\\\w\\\\w\\\\w)\\\\s(.*)\");\n expiresString = expiresString.replace(re, \"$1$2-$3-$4\");\n\n sExpires = 'expires='+expiresString;\n } else {\n if(typeof(expires) !== 'undefined' && !isNaN(expires) && Number(parseInt(expires, 10))===0) {\n sExpires = '';\n } else {\n sExpires = 'expires=Thu, 01-Jan-2037 00:00:01 GMT';\n }\n }\n\n if(path && typeof(path) !== 'undefined') {\n sPath = 'path='+path;\n } else {\n sPath = 'path=/';\n }\n\n if(domain && typeof(domain) !== 'undefined') {\n sDomain = 'domain='+domain;\n } else {\n var portClean = new RegExp(\":(.*)\");\n sDomain = 'domain='+window.location.host;\n sDomain = sDomain.replace(portClean,\"\");\n }\n\n if(secure && typeof(secure) !== 'undefined') {\n sSecure = secure;\n } else {\n sSecure = false;\n }\n\n document.cookie = sName+'; '+sExpires+'; '+sPath+'; '+sDomain+'; '+sSecure;\n },\n\n /**\n * Deletes a cookie.\n *\n * @method remove\n * @param {String} cookieName Cookie name.\n * @param {String} [path] Path of the cookie. Defaults to '/'.\n * @param {String} [domain] Domain of the cookie. Defaults to current hostname.\n * @public\n * @static\n * @sample Ink_Util_Cookie_remove.html\n */\n remove: function(cookieName, path, domain)\n {\n //var expiresDate = 'Thu, 01-Jan-1970 00:00:01 GMT';\n var sPath = false;\n var sDomain = false;\n var expiresDate = -999999999;\n\n if(path && typeof(path) !== 'undefined') {\n sPath = path;\n } else {\n sPath = '/';\n }\n\n if(domain && typeof(domain) !== 'undefined') {\n sDomain = domain;\n } else {\n sDomain = window.location.host;\n }\n\n this.set(cookieName, 'deleted', expiresDate, sPath, sDomain);\n }\n };\n\n return Cookie;\n\n});\n","/**\n * Date utility functions\n * @module Ink.Util.Date_1\n * @version 1\n */\n\nInk.createModule('Ink.Util.Date', '1', [], function() {\n\n 'use strict';\n\n /**\n * @namespace Ink.Util.Date_1 \n */\n var InkDate = {\n\n /**\n * Function that returns the string representation of the month [PT only]\n *\n * @method _months\n * @param {Number} index Month javascript (0 to 11)\n * @return {String} The month's name\n * @private\n * @static\n * @example\n * console.log( InkDate._months(0) ); // Result: Janeiro\n */\n _months: function(index){\n var _m = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'];\n return _m[index];\n },\n\n /**\n * Function that returns the month [PT only] ( 0 to 11 )\n *\n * @method _iMonth\n * @param {String} month Month javascript (0 to 11)\n * @return {Number} The month's number\n * @private\n * @static\n * @example\n * console.log( InkDate._iMonth('maio') ); // Result: 4\n */\n _iMonth : function( month )\n {\n if ( Number( month ) ) { return +month - 1; }\n return {\n 'janeiro' : 0 ,\n 'jan' : 0 ,\n 'fevereiro' : 1 ,\n 'fev' : 1 ,\n 'março' : 2 ,\n 'mar' : 2 ,\n 'abril' : 3 ,\n 'abr' : 3 ,\n 'maio' : 4 ,\n 'mai' : 4 ,\n 'junho' : 5 ,\n 'jun' : 5 ,\n 'julho' : 6 ,\n 'jul' : 6 ,\n 'agosto' : 7 ,\n 'ago' : 7 ,\n 'setembro' : 8 ,\n 'set' : 8 ,\n 'outubro' : 9 ,\n 'out' : 9 ,\n 'novembro' : 10 ,\n 'nov' : 10 ,\n 'dezembro' : 11 ,\n 'dez' : 11\n }[ month.toLowerCase( ) ];\n } ,\n\n /**\n * Function that returns the representation the day of the week [PT Only]\n *\n * @method _wDays\n * @param {Number} index Week's day index\n * @return {String} The week's day name\n * @private\n * @static\n * @example\n * console.log( InkDate._wDays(0) ); // Result: Domingo\n */\n _wDays: function(index){\n var _d = ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'];\n return _d[index];\n },\n\n /**\n * Function that returns day of the week in javascript 1 to 7\n *\n * @method _iWeek\n * @param {String} week Week's day name\n * @return {Number} The week's day index\n * @private\n * @static\n * @example\n * console.log( InkDate._iWeek('quarta') ); // Result: 3\n */\n _iWeek: function( week )\n {\n if ( Number( week ) ) { return +week || 7; }\n return {\n 'segunda' : 1 ,\n 'seg' : 1 ,\n 'terça' : 2 ,\n 'ter' : 2 ,\n 'quarta' : 3 ,\n 'qua' : 3 ,\n 'quinta' : 4 ,\n 'qui' : 4 ,\n 'sexta' : 5 ,\n 'sex' : 5 ,\n 'sábado' : 6 ,\n 'sáb' : 6 ,\n 'domingo' : 7 ,\n 'dom' : 7\n }[ week.toLowerCase( ) ];\n },\n\n /**\n * Function that returns the number of days of a given month (m) on a given year (y)\n *\n * @method _daysInMonth\n * @param {Number} _m Month\n * @param {Number} _y Year\n * @return {Number} Number of days of a give month on a given year\n * @private\n * @static\n * @example\n * console.log( InkDate._daysInMonth(2,2013) ); // Result: 28\n */\n _daysInMonth: function(_m,_y){\n var nDays;\n\n if(_m===1 || _m===3 || _m===5 || _m===7 || _m===8 || _m===10 || _m===12)\n {\n nDays= 31;\n }\n else if ( _m===4 || _m===6 || _m===9 || _m===11)\n {\n nDays = 30;\n }\n else\n {\n if((_y%400===0) || (_y%4===0 && _y%100!==0))\n {\n nDays = 29;\n }\n else\n {\n nDays = 28;\n }\n }\n return nDays;\n },\n\n /**\n * Formats a date object.\n * This works exactly as php date() function. http://php.net/manual/en/function.date.php\n *\n * @method get\n * @param {String} format The format in which the date it will be formatted.\n * @param {Date} [_date] The date to format. Can receive unix timestamp or a date object. Defaults to current time.\n * @return {String} Formatted date\n * @public\n * @static\n * @sample Ink_Util_Date_get.html \n */\n get: function(format, _date){\n /*jshint maxcomplexity:65 */\n if(typeof(format) === 'undefined' || format === ''){\n format = \"Y-m-d\";\n }\n\n\n var iFormat = format.split(\"\");\n var result = new Array(iFormat.length);\n var escapeChar = \"\\\\\";\n var jsDate;\n\n if (typeof(_date) === 'undefined'){\n jsDate = new Date();\n } else if (typeof(_date)==='number'){\n jsDate = new Date(_date*1000);\n } else {\n jsDate = new Date(_date);\n }\n\n var jsFirstDay, jsThisDay, jsHour;\n /* This switch is presented in the same order as in php date function (PHP 5.2.2) */\n for (var i = 0; i < iFormat.length; i++) {\n switch(iFormat[i]) {\n case escapeChar:\n result[i] = iFormat[i+1];\n i++;\n break;\n\n\n /* DAY */\n case \"d\": /* Day of the month, 2 digits with leading zeros; ex: 01 to 31 */\n var jsDay = jsDate.getDate();\n result[i] = (String(jsDay).length > 1) ? jsDay : \"0\" + jsDay;\n break;\n\n case \"D\": /* A textual representation of a day, three letters; Seg to Dom */\n result[i] = this._wDays(jsDate.getDay()).substring(0, 3);\n break;\n\n case \"j\": /* Day of the month without leading zeros; ex: 1 to 31 */\n result[i] = jsDate.getDate();\n break;\n\n case \"l\": /* A full textual representation of the day of the week; Domingo to Sabado */\n result[i] = this._wDays(jsDate.getDay());\n break;\n\n case \"N\": /* ISO-8601 numeric representation of the day of the week; 1 (Segunda) to 7 (Domingo) */\n result[i] = jsDate.getDay() || 7;\n break;\n\n case \"S\": /* English ordinal suffix for the day of the month, 2 characters; st, nd, rd or th. Works well with j */\n var temp = jsDate.getDate();\n var suffixes = [\"st\", \"nd\", \"rd\"];\n var suffix = \"\";\n\n if (temp >= 11 && temp <= 13) {\n result[i] = \"th\";\n } else {\n result[i] = (suffix = suffixes[String(temp).substr(-1) - 1]) ? (suffix) : (\"th\");\n }\n break;\n\n case \"w\": /* Numeric representation of the day of the week; 0 (for Sunday) through 6 (for Saturday) */\n result[i] = jsDate.getDay();\n break;\n\n case \"z\": /* The day of the year (starting from 0); 0 to 365 */\n jsFirstDay = Date.UTC(jsDate.getFullYear(), 0, 0);\n jsThisDay = Date.UTC(jsDate.getFullYear(), jsDate.getMonth(), jsDate.getDate());\n result[i] = Math.floor((jsThisDay - jsFirstDay) / (1000 * 60 * 60 * 24));\n break;\n\n /* WEEK */\n case \"W\": /* ISO-8601 week number of year, weeks starting on Monday; ex: 42 (the 42nd week in the year) */\n var jsYearStart = new Date( jsDate.getFullYear( ) , 0 , 1 );\n jsFirstDay = jsYearStart.getDay() || 7;\n\n var days = Math.floor( ( jsDate - jsYearStart ) / ( 24 * 60 * 60 * 1000 ) + 1 );\n\n result[ i ] = Math.ceil( ( days - ( 8 - jsFirstDay ) ) / 7 ) + 1;\n break;\n\n\n /* MONTH */\n case \"F\": /* A full textual representation of a month, such as Janeiro or Marco; Janeiro a Dezembro */\n result[i] = this._months(jsDate.getMonth());\n break;\n\n case \"m\": /* Numeric representation of a month, with leading zeros; 01 to 12 */\n var jsMonth = String(jsDate.getMonth() + 1);\n result[i] = (jsMonth.length > 1) ? jsMonth : \"0\" + jsMonth;\n break;\n\n case \"M\": /* A short textual representation of a month, three letters; Jan a Dez */\n result[i] = this._months(jsDate.getMonth()).substring(0,3);\n break;\n\n case \"n\": /* Numeric representation of a month, without leading zeros; 1 a 12 */\n result[i] = jsDate.getMonth() + 1;\n break;\n\n case \"t\": /* Number of days in the given month; ex: 28 */\n result[i] = this._daysInMonth(jsDate.getMonth()+1,jsDate.getYear());\n break;\n\n /* YEAR */\n case \"L\": /* Whether it's a leap year; 1 if it is a leap year, 0 otherwise. */\n var jsYear = jsDate.getFullYear();\n result[i] = (jsYear % 4) ? false : ( (jsYear % 100) ? true : ( (jsYear % 400) ? false : true ) );\n break;\n\n case \"o\": /* ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. */\n throw '\"o\" not implemented!';\n\n case \"Y\": /* A full numeric representation of a year, 4 digits; 1999 */\n result[i] = jsDate.getFullYear();\n break;\n\n case \"y\": /* A two digit representation of a year; 99 */\n result[i] = String(jsDate.getFullYear()).substring(2);\n break;\n\n /* TIME */\n case \"a\": /* Lowercase Ante meridiem and Post meridiem; am or pm */\n result[i] = (jsDate.getHours() < 12) ? \"am\" : \"pm\";\n break;\n\n case \"A\": /* Uppercase Ante meridiem and Post meridiem; AM or PM */\n result[i] = (jsDate.getHours < 12) ? \"AM\" : \"PM\";\n break;\n\n case \"B\": /* Swatch Internet time; 000 through 999 */\n throw '\"B\" not implemented!';\n\n case \"g\": /* 12-hour format of an hour without leading zeros; 1 to 12 */\n jsHour = jsDate.getHours();\n result[i] = (jsHour <= 12) ? jsHour : (jsHour - 12);\n break;\n\n case \"G\": /* 24-hour format of an hour without leading zeros; 1 to 23 */\n result[i] = String(jsDate.getHours());\n break;\n\n case \"h\": /* 12-hour format of an hour with leading zeros; 01 to 12 */\n jsHour = String(jsDate.getHours());\n jsHour = (jsHour <= 12) ? jsHour : (jsHour - 12);\n result[i] = (jsHour.length > 1) ? jsHour : \"0\" + jsHour;\n break;\n\n case \"H\": /* 24-hour format of an hour with leading zeros; 01 to 24 */\n jsHour = String(jsDate.getHours());\n result[i] = (jsHour.length > 1) ? jsHour : \"0\" + jsHour;\n break;\n\n case \"i\": /* Minutes with leading zeros; 00 to 59 */\n var jsMinute = String(jsDate.getMinutes());\n result[i] = (jsMinute.length > 1) ? jsMinute : \"0\" + jsMinute;\n break;\n\n case \"s\": /* Seconds with leading zeros; 00 to 59; */\n var jsSecond = String(jsDate.getSeconds());\n result[i] = (jsSecond.length > 1) ? jsSecond : \"0\" + jsSecond;\n break;\n\n case \"u\": /* Microseconds */\n throw '\"u\" not implemented!';\n\n\n /* TIMEZONE */\n\n case \"e\": /* Timezone identifier */\n throw '\"e\" not implemented!';\n\n case \"I\": /* \"1\" if Daylight Savings Time, \"0\" otherwise. Works only on the northern hemisphere */\n jsFirstDay = new Date(jsDate.getFullYear(), 0, 1);\n result[i] = (jsDate.getTimezoneOffset() !== jsFirstDay.getTimezoneOffset()) ? (1) : (0);\n break;\n\n case \"O\": /* Difference to Greenwich time (GMT) in hours */\n var jsMinZone = jsDate.getTimezoneOffset();\n var jsMinutes = jsMinZone % 60;\n jsHour = String(((jsMinZone - jsMinutes) / 60) * -1);\n\n if (jsHour.charAt(0) !== \"-\") {\n jsHour = \"+\" + jsHour;\n }\n\n jsHour = (jsHour.length === 3) ? (jsHour) : (jsHour.replace(/([+\\-])(\\d)/, \"$1\" + 0 + \"$2\"));\n result[i] = jsHour + jsMinutes + \"0\";\n break;\n\n case \"P\": /* Difference to Greenwich time (GMT) with colon between hours and minutes */\n throw '\"P\" not implemented!';\n\n case \"T\": /* Timezone abbreviation */\n throw '\"T\" not implemented!';\n\n case \"Z\": /* Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. */\n result[i] = jsDate.getTimezoneOffset() * 60;\n break;\n\n\n /* FULL DATE/TIME */\n\n case \"c\": /* ISO 8601 date */\n throw '\"c\" not implemented!';\n\n case \"r\": /* RFC 2822 formatted date */\n var jsDayName = this._wDays(jsDate.getDay()).substr(0, 3);\n var jsMonthName = this._months(jsDate.getMonth()).substr(0, 3);\n result[i] = jsDayName + \", \" + jsDate.getDate() + \" \" + jsMonthName + this.get(\" Y H:i:s O\",jsDate);\n break;\n\n case \"U\": /* Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) */\n result[i] = Math.floor(jsDate.getTime() / 1000);\n break;\n\n default:\n result[i] = iFormat[i];\n }\n }\n\n return result.join('');\n\n },\n\n /**\n * Creates a date object based on a format string.\n * This works exactly as php date() function. http://php.net/manual/en/function.date.php\n *\n * @method set\n * @param {String} [format] The format in which the date will be formatted. Defaults to 'Y-m-d'\n * @param {String} str_date The date formatted.\n * @return {Date} Date object based on the formatted date and format\n * @public\n * @static\n * @sample Ink_Util_Date_set.html \n */\n set : function( format , str_date ) {\n if ( typeof str_date === 'undefined' ) { return ; }\n if ( typeof format === 'undefined' || format === '' ) { format = \"Y-m-d\"; }\n\n var iFormat = format.split(\"\");\n var result = new Array( iFormat.length );\n var escapeChar = \"\\\\\";\n var mList;\n\n var objIndex = {\n year : undefined ,\n month : undefined ,\n day : undefined ,\n dayY : undefined ,\n dayW : undefined ,\n week : undefined ,\n hour : undefined ,\n hourD : undefined ,\n min : undefined ,\n sec : undefined ,\n msec : undefined ,\n ampm : undefined ,\n diffM : undefined ,\n diffH : undefined ,\n date : undefined\n };\n\n var matches = 0;\n\n /* This switch is presented in the same order as in php date function (PHP 5.2.2) */\n for ( var i = 0; i < iFormat.length; i++) {\n switch( iFormat[ i ] ) {\n case escapeChar:\n result[i] = iFormat[ i + 1 ];\n i++;\n break;\n\n /* DAY */\n case \"d\": /* Day of the month, 2 digits with leading zeros; ex: 01 to 31 */\n result[ i ] = '(\\\\d{2})';\n objIndex.day = { original : i , match : matches++ };\n break;\n\n case \"j\": /* Day of the month without leading zeros; ex: 1 to 31 */\n result[ i ] = '(\\\\d{1,2})';\n objIndex.day = { original : i , match : matches++ };\n break;\n\n case \"D\": /* A textual representation of a day, three letters; Seg to Dom */\n result[ i ] = '([\\\\wá]{3})';\n objIndex.dayW = { original : i , match : matches++ };\n break;\n\n case \"l\": /* A full textual representation of the day of the week; Domingo to Sabado */\n result[i] = '([\\\\wá]{5,7})';\n objIndex.dayW = { original : i , match : matches++ };\n break;\n\n case \"N\": /* ISO-8601 numeric representation of the day of the week; 1 (Segunda) to 7 (Domingo) */\n result[ i ] = '(\\\\d)';\n objIndex.dayW = { original : i , match : matches++ };\n break;\n\n case \"w\": /* Numeric representation of the day of the week; 0 (for Sunday) through 6 (for Saturday) */\n result[ i ] = '(\\\\d)';\n objIndex.dayW = { original : i , match : matches++ };\n break;\n\n case \"S\": /* English ordinal suffix for the day of the month, 2 characters; st, nd, rd or th. Works well with j */\n result[ i ] = '\\\\w{2}';\n break;\n\n case \"z\": /* The day of the year (starting from 0); 0 to 365 */\n result[ i ] = '(\\\\d{1,3})';\n objIndex.dayY = { original : i , match : matches++ };\n break;\n\n /* WEEK */\n case \"W\": /* ISO-8601 week number of year, weeks starting on Monday; ex: 42 (the 42nd week in the year) */\n result[ i ] = '(\\\\d{1,2})';\n objIndex.week = { original : i , match : matches++ };\n break;\n\n /* MONTH */\n case \"F\": /* A full textual representation of a month, such as Janeiro or Marco; Janeiro a Dezembro */\n result[ i ] = '([\\\\wç]{4,9})';\n objIndex.month = { original : i , match : matches++ };\n break;\n\n case \"M\": /* A short textual representation of a month, three letters; Jan a Dez */\n result[ i ] = '(\\\\w{3})';\n objIndex.month = { original : i , match : matches++ };\n break;\n\n case \"m\": /* Numeric representation of a month, with leading zeros; 01 to 12 */\n result[ i ] = '(\\\\d{2})';\n objIndex.month = { original : i , match : matches++ };\n break;\n\n case \"n\": /* Numeric representation of a month, without leading zeros; 1 a 12 */\n result[ i ] = '(\\\\d{1,2})';\n objIndex.month = { original : i , match : matches++ };\n break;\n\n case \"t\": /* Number of days in the given month; ex: 28 */\n result[ i ] = '\\\\d{2}';\n break;\n\n /* YEAR */\n case \"L\": /* Whether it's a leap year; 1 if it is a leap year, 0 otherwise. */\n result[ i ] = '\\\\w{4,5}';\n break;\n\n case \"o\": /* ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. */\n throw '\"o\" not implemented!';\n\n case \"Y\": /* A full numeric representation of a year, 4 digits; 1999 */\n result[ i ] = '(\\\\d{4})';\n objIndex.year = { original : i , match : matches++ };\n break;\n\n case \"y\": /* A two digit representation of a year; 99 */\n result[ i ] = '(\\\\d{2})';\n if ( typeof objIndex.year === 'undefined' || iFormat[ objIndex.year.original ] !== 'Y' ) {\n objIndex.year = { original : i , match : matches++ };\n }\n break;\n\n /* TIME */\n case \"a\": /* Lowercase Ante meridiem and Post meridiem; am or pm */\n result[ i ] = '(am|pm)';\n objIndex.ampm = { original : i , match : matches++ };\n break;\n\n case \"A\": /* Uppercase Ante meridiem and Post meridiem; AM or PM */\n result[ i ] = '(AM|PM)';\n objIndex.ampm = { original : i , match : matches++ };\n break;\n\n case \"B\": /* Swatch Internet time; 000 through 999 */\n throw '\"B\" not implemented!';\n\n case \"g\": /* 12-hour format of an hour without leading zeros; 1 to 12 */\n result[ i ] = '(\\\\d{1,2})';\n objIndex.hourD = { original : i , match : matches++ };\n break;\n\n case \"G\": /* 24-hour format of an hour without leading zeros; 1 to 23 */\n result[ i ] = '(\\\\d{1,2})';\n objIndex.hour = { original : i , match : matches++ };\n break;\n\n case \"h\": /* 12-hour format of an hour with leading zeros; 01 to 12 */\n result[ i ] = '(\\\\d{2})';\n objIndex.hourD = { original : i , match : matches++ };\n break;\n\n case \"H\": /* 24-hour format of an hour with leading zeros; 01 to 24 */\n result[ i ] = '(\\\\d{2})';\n objIndex.hour = { original : i , match : matches++ };\n break;\n\n case \"i\": /* Minutes with leading zeros; 00 to 59 */\n result[ i ] = '(\\\\d{2})';\n objIndex.min = { original : i , match : matches++ };\n break;\n\n case \"s\": /* Seconds with leading zeros; 00 to 59; */\n result[ i ] = '(\\\\d{2})';\n objIndex.sec = { original : i , match : matches++ };\n break;\n\n case \"u\": /* Microseconds */\n throw '\"u\" not implemented!';\n\n /* TIMEZONE */\n case \"e\": /* Timezone identifier */\n throw '\"e\" not implemented!';\n\n case \"I\": /* \"1\" if Daylight Savings Time, \"0\" otherwise. Works only on the northern hemisphere */\n result[i] = '\\\\d';\n break;\n\n case \"O\": /* Difference to Greenwich time (GMT) in hours */\n result[ i ] = '([-+]\\\\d{4})';\n objIndex.diffH = { original : i , match : matches++ };\n break;\n\n case \"P\": /* Difference to Greenwich time (GMT) with colon between hours and minutes */\n throw '\"P\" not implemented!';\n\n case \"T\": /* Timezone abbreviation */\n throw '\"T\" not implemented!';\n\n case \"Z\": /* Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. */\n result[ i ] = '(\\\\-?\\\\d{1,5})';\n objIndex.diffM = { original : i , match : matches++ };\n break;\n\n /* FULL DATE/TIME */\n case \"c\": /* ISO 8601 date */\n throw '\"c\" not implemented!';\n\n case \"r\": /* RFC 2822 formatted date */\n result[ i ] = '([\\\\wá]{3}, \\\\d{1,2} \\\\w{3} \\\\d{4} \\\\d{2}:\\\\d{2}:\\\\d{2} [+\\\\-]\\\\d{4})';\n objIndex.date = { original : i , match : matches++ };\n break;\n\n case \"U\": /* Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) */\n result[ i ] = '(\\\\d{1,13})';\n objIndex.date = { original : i , match : matches++ };\n break;\n\n default:\n result[ i ] = iFormat[ i ];\n }\n }\n\n var pattr = new RegExp( result.join('') );\n\n try {\n mList = str_date.match( pattr );\n if ( !mList ) { return; }\n }\n catch ( e ) { return ; }\n\n var _haveDatetime = typeof objIndex.date !== 'undefined';\n\n var _haveYear = typeof objIndex.year !== 'undefined';\n\n var _haveYDay = typeof objIndex.dayY !== 'undefined';\n\n var _haveDay = typeof objIndex.day !== 'undefined';\n var _haveMonth = typeof objIndex.month !== 'undefined';\n var _haveMonthDay = _haveMonth && _haveDay;\n var _haveOnlyDay = !_haveMonth && _haveDay;\n\n var _haveWDay = typeof objIndex.dayW !== 'undefined';\n var _haveWeek = typeof objIndex.week !== 'undefined';\n var _haveWeekWDay = _haveWeek && _haveWDay;\n var _haveOnlyWDay = !_haveWeek && _haveWDay;\n\n var _validDate = _haveYDay || _haveMonthDay || !_haveYear && _haveOnlyDay || _haveWeekWDay || !_haveYear && _haveOnlyWDay;\n var _noDate = !_haveYear && !_haveYDay && !_haveDay && !_haveMonth && !_haveWDay && !_haveWeek;\n\n var _haveHour12 = typeof objIndex.hourD !== 'undefined' && typeof objIndex.ampm !== 'undefined';\n var _haveHour24 = typeof objIndex.hour !== 'undefined';\n var _haveHour = _haveHour12 || _haveHour24;\n\n var _haveMin = typeof objIndex.min !== 'undefined';\n var _haveSec = typeof objIndex.sec !== 'undefined';\n var _haveMSec = typeof objIndex.msec !== 'undefined';\n\n var _haveMoreM = !_noDate || _haveHour;\n var _haveMoreS = _haveMoreM || _haveMin;\n\n var _haveDiffM = typeof objIndex.diffM !== 'undefined';\n var _haveDiffH = typeof objIndex.diffH !== 'undefined';\n //var _haveGMT = _haveDiffM || _haveDiffH;\n var hour;\n var min;\n\n if ( _haveDatetime ) {\n if ( iFormat[ objIndex.date.original ] === 'U' ) {\n return new Date( +mList[ objIndex.date.match + 1 ] * 1000 );\n }\n\n var dList = mList[ objIndex.date.match + 1 ].match( /\\w{3}, (\\d{1,2}) (\\w{3}) (\\d{4}) (\\d{2}):(\\d{2}):(\\d{2}) ([+\\-]\\d{4})/ );\n hour = +dList[ 4 ] + ( +dList[ 7 ].slice( 0 , 3 ) );\n min = +dList[ 5 ] + ( dList[ 7 ].slice( 0 , 1 ) + dList[ 7 ].slice( 3 ) ) / 100 * 60;\n\n return new Date( dList[ 3 ] , this._iMonth( dList[ 2 ] ) , dList[ 1 ] , hour , min , dList[ 6 ] );\n }\n\n var _d = new Date( );\n var year;\n var month;\n var day;\n var sec;\n var msec;\n var gmt;\n\n if ( !_validDate && !_noDate ) { return ; }\n\n if ( _validDate ) {\n if ( _haveYear ) {\n var _y = _d.getFullYear( ) - 50 + '';\n year = mList[ objIndex.year.match + 1 ];\n if ( iFormat[ objIndex.year.original ] === 'y' ) {\n year = +_y.slice( 0 , 2 ) + ( year >= ( _y ).slice( 2 ) ? 0 : 1 ) + year;\n }\n } else {\n year = _d.getFullYear();\n }\n\n if ( _haveYDay ) {\n month = 0;\n day = mList[ objIndex.dayY.match + 1 ];\n } else if ( _haveDay ) {\n if ( _haveMonth ) {\n month = this._iMonth( mList[ objIndex.month.match + 1 ] );\n } else {\n month = _d.getMonth( );\n }\n\n day = mList[ objIndex.day.match + 1 ];\n } else {\n month = 0;\n\n var week;\n if ( _haveWeek ) {\n week = mList[ objIndex.week.match + 1 ];\n } else {\n week = this.get( 'W' , _d );\n }\n\n day = ( week - 2 ) * 7 + ( 8 - ( ( new Date( year , 0 , 1 ) ).getDay( ) || 7 ) ) + this._iWeek( mList[ objIndex.week.match + 1 ] );\n }\n\n if ( month === 0 && day > 31 ) {\n var aux = new Date( year , month , day );\n month = aux.getMonth( );\n day = aux.getDate( );\n }\n }\n else {\n year = _d.getFullYear( );\n month = _d.getMonth( );\n day = _d.getDate( );\n }\n\n if ( _haveHour12 ) { hour = +mList[ objIndex.hourD.match + 1 ] + ( mList[ objIndex.ampm.match + 1 ] === 'pm' ? 12 : 0 ); }\n else if ( _haveHour24 ) { hour = mList[ objIndex.hour.match + 1 ]; }\n else if ( _noDate ) { hour = _d.getHours( ); }\n else { hour = '00'; }\n\n if ( _haveMin ) { min = mList[ objIndex.min.match + 1 ]; }\n else if ( !_haveMoreM ) { min = _d.getMinutes( ); }\n else { min = '00'; }\n\n if ( _haveSec ) { sec = mList[ objIndex.sec.match + 1 ]; }\n else if ( !_haveMoreS ) { sec = _d.getSeconds( ); }\n else { sec = '00'; }\n\n if ( _haveMSec ) { msec = mList[ objIndex.msec.match + 1 ]; }\n else { msec = '000'; }\n\n if ( _haveDiffH ) { gmt = mList[ objIndex.diffH.match + 1 ]; }\n else if ( _haveDiffM ) { gmt = String( -1 * mList[ objIndex.diffM.match + 1 ] / 60 * 100 ).replace( /^(\\d)/ , '+$1' ).replace( /(^[\\-+])(\\d{3}$)/ , '$10$2' ); }\n else { gmt = '+0000'; }\n\n return new Date( year, month, day, hour, min, sec );\n }\n };\n\n\n return InkDate;\n\n});\n","/**\n * Dump/Profiling Utilities\n * @module Ink.Util.Dumper_1\n * @version 1\n */\n\nInk.createModule('Ink.Util.Dumper', '1', [], function() {\n\n 'use strict';\n\n /**\n * @namespace Ink.Util.Dumper_1 \n */\n\n var Dumper = {\n\n /**\n * Hex code for the 'tab'\n * \n * @property _tab\n * @type {String}\n * @private\n * @readOnly\n * @static\n *\n */\n _tab: '\\xA0\\xA0\\xA0\\xA0',\n\n /**\n * Function that returns the argument passed formatted\n *\n * @method _formatParam\n * @param {Mixed} param\n * @return {String} The argument passed formatted\n * @private\n * @static\n */\n _formatParam: function(param)\n {\n var formated = '';\n\n switch(typeof(param)) {\n case 'string':\n formated = '(string) '+param;\n break;\n case 'number':\n formated = '(number) '+param;\n break;\n case 'boolean':\n formated = '(boolean) '+param;\n break;\n case 'object':\n if(param !== null) {\n if(param.constructor === Array) {\n formated = 'Array \\n{\\n' + this._outputFormat(param, 0) + '\\n}';\n } else {\n formated = 'Object \\n{\\n' + this._outputFormat(param, 0) + '\\n}';\n }\n } else {\n formated = 'null';\n }\n break;\n default:\n formated = false;\n }\n\n return formated;\n },\n\n /**\n * Function that returns the tabs concatenated\n *\n * @method _getTabs\n * @param {Number} numberOfTabs Number of Tabs\n * @return {String} Tabs concatenated\n * @private\n * @static\n */\n _getTabs: function(numberOfTabs)\n {\n var tabs = '';\n for(var _i = 0; _i < numberOfTabs; _i++) {\n tabs += this._tab;\n }\n return tabs;\n },\n\n /**\n * Function that formats the parameter to display.\n *\n * @method _outputFormat\n * @param {Any} param\n * @param {Number} dim\n * @return {String} The parameter passed formatted to displat\n * @private\n * @static\n */\n _outputFormat: function(param, dim)\n {\n var formated = '';\n //var _strVal = false;\n var _typeof = false;\n for(var key in param) {\n if(param[key] !== null) {\n if(typeof(param[key]) === 'object' && (param[key].constructor === Array || param[key].constructor === Object)) {\n if(param[key].constructor === Array) {\n _typeof = 'Array';\n } else if(param[key].constructor === Object) {\n _typeof = 'Object';\n }\n formated += this._tab + this._getTabs(dim) + '[' + key + '] => <b>'+_typeof+'</b>\\n';\n formated += this._tab + this._getTabs(dim) + '{\\n';\n formated += this._outputFormat(param[key], dim + 1) + this._tab + this._getTabs(dim) + '}\\n';\n } else if(param[key].constructor === Function) {\n continue;\n } else {\n formated = formated + this._tab + this._getTabs(dim) + '[' + key + '] => ' + param[key] + '\\n';\n }\n } else {\n formated = formated + this._tab + this._getTabs(dim) + '[' + key + '] => null \\n';\n }\n }\n return formated;\n },\n\n /**\n * Prints variable structure.\n *\n * @method printDump\n * @param {Any} param Variable to be dumped.\n * @param {DOMElement|String} [target] Element to print the dump on.\n * @public\n * @static\n * @sample Ink_Util_Dumper_printDump.html \n */\n printDump: function(param, target)\n {\n /*jshint evil:true */\n if(!target || typeof(target) === 'undefined') {\n document.write('<pre>'+this._formatParam(param)+'</pre>');\n } else {\n if(typeof(target) === 'string') {\n document.getElementById(target).innerHTML = '<pre>' + this._formatParam(param) + '</pre>';\n } else if(typeof(target) === 'object') {\n target.innerHTML = '<pre>'+this._formatParam(param)+'</pre>';\n } else {\n throw \"TARGET must be an element or an element ID\";\n }\n }\n },\n\n /**\n * Get a variable's structure.\n *\n * @method returnDump\n * @param {Any} param Variable to get the structure.\n * @return {String} The variable's structure.\n * @public\n * @static\n * @sample Ink_Util_Dumper_returnDump.html \n */\n returnDump: function(param)\n {\n return this._formatParam(param);\n },\n\n /**\n * Alert a variable's structure.\n *\n * @method alertDump\n * @param {Any} param Variable to be dumped.\n * @public\n * @static\n * @sample Ink_Util_Dumper_alertDump.html \n */\n alertDump: function(param)\n {\n window.alert(this._formatParam(param).replace(/(<b>)(Array|Object)(<\\/b>)/g, \"$2\"));\n },\n\n /**\n * Prints the variable structure to a new window.\n *\n * @method windowDump\n * @param {Any} param Variable to be dumped.\n * @public\n * @static\n * @sample Ink_Util_Dumper_windowDump.html \n */\n windowDump: function(param)\n {\n var dumperwindow = 'dumperwindow_'+(Math.random() * 10000);\n var win = window.open('',\n dumperwindow,\n 'width=400,height=300,left=50,top=50,status,menubar,scrollbars,resizable'\n );\n win.document.open();\n win.document.write('<pre>'+this._formatParam(param)+'</pre>');\n win.document.close();\n win.focus();\n }\n\n };\n\n return Dumper;\n\n});\n","/**\n * Internationalization Utilities \n * @module Ink.Util.I18n_1\n * @version 1\n */\n\nInk.createModule('Ink.Util.I18n', '1', [], function () {\n 'use strict';\n\n var pattrText = /\\{(?:(\\{.*?})|(?:%s:)?(\\d+)|(?:%s)?|([\\w-]+))}/g;\n\n var funcOrVal = function( ret , args ) {\n if ( typeof ret === 'function' ) {\n return ret.apply(this, args);\n } else if (typeof ret !== undefined) {\n return ret;\n } else {\n return '';\n }\n };\n\n /**\n * You can use this module to internationalize your applications. It roughly emulates GNU gettext's API.\n *\n * @class Ink.Util.I18n\n * @constructor\n *\n * @param {Object} dict Object mapping language codes (in the form of `pt_PT`, `pt_BR`, `fr`, `en_US`, etc.) to their `dictionaries`\n * @param {String} [lang='pt_PT'] language code of the target language\n *\n * @sample Ink_Util_I18n_1.html\n */\n var I18n = function( dict , lang , testMode ) {\n if ( !( this instanceof I18n ) ) { return new I18n( dict , lang , testMode ); }\n\n this.reset( )\n .lang( lang )\n .testMode( testMode )\n .append( dict || { } , lang );\n };\n\n I18n.prototype = {\n reset: function( ) {\n this._dicts = [ ];\n this._dict = { };\n this._testMode = false;\n this._lang = this._gLang;\n\n return this;\n },\n /**\n * Adds translation strings for the helper to use.\n *\n * @method append\n * @param {Object} dict Object containing language objects identified by their language code\n *\n * @sample Ink_Util_I18n_1_append.html\n */\n append: function( dict ) {\n this._dicts.push( dict );\n\n this._dict = Ink.extendObj(this._dict , dict[ this._lang ] );\n\n return this;\n },\n /**\n * Gets or sets the language.\n * If there are more dictionaries available in cache, they will be loaded.\n *\n * @method lang\n * @param {String} lang Language code to set this instance to.\n */\n lang: function( lang ) {\n if ( !arguments.length ) { return this._lang; }\n\n if ( lang && this._lang !== lang ) {\n this._lang = lang;\n\n this._dict = { };\n\n for ( var i = 0, l = this._dicts.length; i < l; i++ ) {\n this._dict = Ink.extendObj( this._dict , this._dicts[ i ][ lang ] || { } );\n }\n }\n\n return this;\n },\n /**\n * Sets or unsets test mode.\n * In test mode, unknown strings are wrapped in `[ ... ]`. This is useful for debugging your application and to make sure all your translation keys are in place.\n *\n * @method testMode\n * @param {Boolean} bool Flag to set the test mode state\n */\n testMode: function( bool ) {\n if ( !arguments.length ) { return !!this._testMode; }\n\n if ( bool !== undefined ) { this._testMode = !!bool; }\n\n return this;\n },\n\n /**\n * Gest a key from the current dictionary\n *\n * @method getKey\n * @param {String} key\n * @return {Mixed} The object which happened to be in the current language dictionary on the given key.\n *\n * @sample Ink_Util_I18n_1_getKey.html\n */\n getKey: function( key ) {\n var ret;\n var gLang = this._gLang;\n var lang = this._lang;\n \n if ( key in this._dict ) {\n ret = this._dict[ key ];\n } else {\n I18n.langGlobal( lang );\n \n ret = this._gDict[ key ];\n \n I18n.langGlobal( gLang );\n }\n \n return ret;\n },\n\n /**\n * Translates a string.\n * Given a translation key, return a translated string, with replaced parameters.\n * When a translated string is not available, the original string is returned unchanged.\n *\n * @method text\n * @param {String} str Key to look for in i18n dictionary (which is returned verbatim if unknown)\n * @param {Object} [namedParms] Named replacements. Replaces {named} with values in this object.\n * @param {String} [args] Replacement #1 (replaces first {} and all {1})\n * @param {String} [arg2] Replacement #2 (replaces second {} and all {2})\n * @param {String} [argn*] Replacement #n (replaces nth {} and all {n})\n *\n * @sample Ink_Util_I18n_1_text.html\n */\n text: function( str /*, replacements...*/ ) {\n if ( typeof str !== 'string' ) { return; } // Backwards-compat\n\n var pars = Array.prototype.slice.call( arguments , 1 );\n var idx = 0;\n var isObj = typeof pars[ 0 ] === 'object';\n\n var original = this.getKey( str );\n if ( original === undefined ) { original = this._testMode ? '[' + str + ']' : str; }\n if ( typeof original === 'number' ) { original += ''; }\n\n if (typeof original === 'string') {\n original = original.replace( pattrText , function( m , $1 , $2 , $3 ) {\n var ret =\n $1 ? $1 :\n $2 ? pars[ $2 - ( isObj ? 0 : 1 ) ] :\n $3 ? pars[ 0 ][ $3 ] || '' :\n pars[ (idx++) + ( isObj ? 1 : 0 ) ];\n return funcOrVal( ret , [idx].concat(pars) );\n });\n return original;\n }\n \n return (\n typeof original === 'function' ? original.apply( this , pars ) :\n original instanceof Array ? funcOrVal( original[ pars[ 0 ] ] , pars ) :\n typeof original === 'object' ? funcOrVal( original[ pars[ 0 ] ] , pars ) :\n '');\n },\n\n /**\n * Translates and pluralizes text.\n * Given a singular string, a plural string and a number, translates either the singular or plural string.\n *\n * @method ntext\n * @return {String}\n *\n * @param {String} strSin Word to use when count is 1\n * @param {String} strPlur Word to use otherwise\n * @param {Number} count Number which defines which word to use\n * @param [args*] Extra arguments, to be passed to `text()`\n *\n * @sample Ink_Util_I18n_1_ntext.html\n */\n ntext: function( strSin , strPlur , count ) {\n var pars = Array.prototype.slice.apply( arguments );\n var original;\n\n if ( pars.length === 2 && typeof strPlur === 'number' ) {\n original = this.getKey( strSin );\n if ( !( original instanceof Array ) ) { return ''; }\n\n pars.splice( 0 , 1 );\n original = original[ strPlur === 1 ? 0 : 1 ];\n } else {\n pars.splice( 0 , 2 );\n original = count === 1 ? strSin : strPlur;\n }\n\n return this.text.apply( this , [ original ].concat( pars ) );\n },\n\n /**\n * Gets the ordinal suffix of a number.\n *\n * This works by using transforms (in the form of Objects or Functions) passed into the function or found in the special key `_ordinals` in the active language dictionary.\n *\n * @method ordinal\n *\n * @param {Number} num Input number\n * @param {Object|Function} [options]={} Dictionaries for translating. Each of these options' fallback is found in the current language's dictionary. The lookup order is the following: `exceptions`, `byLastDigit`, `default`. Each of these may be either an `Object` or a `Function`. If it's a function, it is called (with `number` and `digit` for any function except for byLastDigit, which is called with the `lastDigit` of the number in question), and if the function returns a string, that is used. If it's an object, the property is looked up using `obj[prop]`. If what is found is a string, it is used directly.\n * @param {Object|Function} [options.byLastDigit]={} If the language requires the last digit to be considered, mappings of last digits to ordinal suffixes can be created here.\n * @param {Object|Function} [options.exceptions]={} Map unique, special cases to their ordinal suffixes.\n *\n * @returns {String} Ordinal suffix for `num`.\n *\n * @sample Ink_Util_I18n_1_ordinal.html\n **/\n ordinal: function( num ) {\n if ( num === undefined ) { return ''; }\n\n var lastDig = +num.toString( ).slice( -1 );\n\n var ordDict = this.getKey( '_ordinals' );\n if ( ordDict === undefined ) { return ''; }\n\n if ( typeof ordDict === 'string' ) { return ordDict; }\n\n var ret;\n\n if ( typeof ordDict === 'function' ) {\n ret = ordDict( num , lastDig );\n\n if ( typeof ret === 'string' ) { return ret; }\n }\n\n if ( 'exceptions' in ordDict ) {\n ret = typeof ordDict.exceptions === 'function' ? ordDict.exceptions( num , lastDig ) :\n num in ordDict.exceptions ? funcOrVal( ordDict.exceptions[ num ] , [num , lastDig] ) :\n undefined;\n\n if ( typeof ret === 'string' ) { return ret; }\n }\n\n if ( 'byLastDigit' in ordDict ) {\n ret = typeof ordDict.byLastDigit === 'function' ? ordDict.byLastDigit( lastDig , num ) :\n lastDig in ordDict.byLastDigit ? funcOrVal( ordDict.byLastDigit[ lastDig ] , [lastDig , num] ) :\n undefined;\n\n if ( typeof ret === 'string' ) { return ret; }\n }\n\n if ( 'default' in ordDict ) {\n ret = funcOrVal( ordDict['default'] , [ num , lastDig ] );\n\n if ( typeof ret === 'string' ) { return ret; }\n }\n\n return '';\n },\n\n /**\n * Create an alias.\n *\n * Returns an alias to this I18n instance. It contains the I18n methods documented here, but is also a function. If you call it, it just calls `text()`. This is commonly assigned to \"_\".\n *\n * @method alias\n * @returns {Function} an alias to `text()` on this instance. You can also access the rest of the translation API through this alias.\n *\n * @sample Ink_Util_I18n_1_alias.html\n */\n alias: function( ) {\n var ret = Ink.bind( I18n.prototype.text , this );\n ret.ntext = Ink.bind( I18n.prototype.ntext , this );\n ret.append = Ink.bind( I18n.prototype.append , this );\n ret.ordinal = Ink.bind( I18n.prototype.ordinal , this );\n ret.testMode = Ink.bind( I18n.prototype.testMode , this );\n\n return ret;\n }\n };\n\n /**\n * Resets I18n global state (global dictionaries, and default language for instances)\n *\n * @method reset\n * @static\n *\n **/\n I18n.reset = function( ) {\n I18n.prototype._gDicts = [ ];\n I18n.prototype._gDict = { };\n I18n.prototype._gLang = 'pt_PT';\n };\n I18n.reset( );\n\n /**\n * Adds a dictionary to be used in all I18n instances for the corresponding language.\n *\n * @method appendGlobal\n * @static\n *\n * @param dict {Object} Dictionary to be added\n * @param lang {String} Language fo the dictionary being added\n *\n */\n I18n.appendGlobal = function( dict , lang ) {\n if ( lang ) {\n if ( !( lang in dict ) ) {\n var obj = { };\n\n obj[ lang ] = dict;\n\n dict = obj;\n }\n\n if ( lang !== I18n.prototype._gLang ) { I18n.langGlobal( lang ); }\n }\n\n I18n.prototype._gDicts.push( dict );\n\n Ink.extendObj( I18n.prototype._gDict , dict[ I18n.prototype._gLang ] );\n };\n\n I18n.append = function () {\n // [3.1.0] remove this alias\n Ink.warn('Ink.Util.I18n.append() was renamed to appendGlobal().');\n return I18n.appendGlobal.apply(I18n, [].slice.call(arguments));\n };\n\n /**\n * Gets or sets the current default language of I18n instances.\n *\n * @method langGlobal\n * @param lang the new language for all I18n instances\n *\n * @static\n *\n * @return {String} language code\n */\n I18n.langGlobal = function( lang ) {\n if ( !arguments.length ) { return I18n.prototype._gLang; }\n\n if ( lang && I18n.prototype._gLang !== lang ) {\n I18n.prototype._gLang = lang;\n\n I18n.prototype._gDict = { };\n\n for ( var i = 0, l = I18n.prototype._gDicts.length; i < l; i++ ) {\n Ink.extendObj( I18n.prototype._gDict , I18n.prototype._gDicts[ i ][ lang ] || { } );\n }\n }\n };\n\n I18n.lang = function () {\n // [3.1.0] remove this alias\n Ink.warn('Ink.Util.I18n.lang() was renamed to langGlobal().');\n return I18n.langGlobal.apply(I18n, [].slice.call(arguments));\n };\n \n return I18n;\n});","/**\n * JSON Utilities\n * @module Ink.Util.Json_1\n * @version 1\n */\n\nInk.createModule('Ink.Util.Json', '1', [], function() {\n 'use strict';\n\n var function_call = Function.prototype.call;\n var cx = /[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g;\n\n function twoDigits(n) {\n var r = '' + n;\n if (r.length === 1) {\n return '0' + r;\n } else {\n return r;\n }\n }\n\n var dateToISOString = Date.prototype.toISOString ?\n Ink.bind(function_call, Date.prototype.toISOString) :\n function(date) {\n // Adapted from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString\n return date.getUTCFullYear() +\n '-' + twoDigits( date.getUTCMonth() + 1 ) +\n '-' + twoDigits( date.getUTCDate() ) +\n 'T' + twoDigits( date.getUTCHours() ) +\n ':' + twoDigits( date.getUTCMinutes() ) +\n ':' + twoDigits( date.getUTCSeconds() ) +\n '.' + String( (date.getUTCMilliseconds()/1000).toFixed(3) ).slice( 2, 5 ) +\n 'Z';\n };\n\n /**\n * Use this class to convert JSON strings to JavaScript objects\n * `.parse()` and also to do the opposite operation `.stringify()`.\n * Internally, the standard JSON implementation is used if available\n * Otherwise, the functions mimic the standard implementation.\n *\n * Here's how to produce JSON from an existing object:\n * \n * Ink.requireModules(['Ink.Util.Json_1'], function (Json) {\n * var obj = {\n * key1: 'value1',\n * key2: 'value2',\n * keyArray: ['arrayValue1', 'arrayValue2', 'arrayValue3']\n * };\n * Json.stringify(obj); // The above object as a JSON string\n * });\n *\n * And here is how to parse JSON:\n *\n * Ink.requireModules(['Ink.Util.Json_1'], function (Json) {\n * var source = '{\"key\": \"value\", \"array\": [true, null, false]}';\n * Json.parse(source); // The above JSON string as an object\n * });\n *\n * @namespace Ink.Util.Json_1 \n * @static\n * \n */\n var InkJson = {\n _nativeJSON: window.JSON || null,\n\n _convertToUnicode: false,\n\n // Escape characters so as to embed them in JSON strings\n _escape: function (theString) {\n var _m = { '\\b': '\\\\b', '\\t': '\\\\t', '\\n': '\\\\n', '\\f': '\\\\f', '\\r': '\\\\r', '\"': '\\\\\"', '\\\\': '\\\\\\\\' };\n\n if (/[\"\\\\\\x00-\\x1f]/.test(theString)) {\n theString = theString.replace(/([\\x00-\\x1f\\\\\"])/g, function(a, b) {\n var c = _m[b];\n if (c) {\n return c;\n }\n c = b.charCodeAt();\n return '\\\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);\n });\n }\n\n return theString;\n },\n\n // A character conversion map\n _toUnicode: function (theString)\n {\n if(!this._convertToUnicode) {\n return this._escape(theString);\n } else {\n var unicodeString = '';\n var inInt = false;\n var theUnicode = false;\n var i = 0;\n var total = theString.length;\n while(i < total) {\n inInt = theString.charCodeAt(i);\n if( (inInt >= 32 && inInt <= 126) ||\n //(inInt >= 48 && inInt <= 57) ||\n //(inInt >= 65 && inInt <= 90) ||\n //(inInt >= 97 && inInt <= 122) ||\n inInt === 8 ||\n inInt === 9 ||\n inInt === 10 ||\n inInt === 12 ||\n inInt === 13 ||\n inInt === 32 ||\n inInt === 34 ||\n inInt === 47 ||\n inInt === 58 ||\n inInt === 92) {\n\n if(inInt === 34 || inInt === 92 || inInt === 47) {\n theUnicode = '\\\\'+theString.charAt(i);\n } else if(inInt === 8) {\n theUnicode = '\\\\b';\n } else if(inInt === 9) {\n theUnicode = '\\\\t';\n } else if(inInt === 10) {\n theUnicode = '\\\\n';\n } else if(inInt === 12) {\n theUnicode = '\\\\f';\n } else if(inInt === 13) {\n theUnicode = '\\\\r';\n } else {\n theUnicode = theString.charAt(i);\n }\n } else {\n if(this._convertToUnicode) {\n theUnicode = theString.charCodeAt(i).toString(16)+''.toUpperCase();\n while (theUnicode.length < 4) {\n theUnicode = '0' + theUnicode;\n }\n theUnicode = '\\\\u' + theUnicode;\n } else {\n theUnicode = theString.charAt(i);\n }\n }\n unicodeString += theUnicode;\n\n i++;\n }\n\n return unicodeString;\n }\n\n },\n\n _stringifyValue: function(param) {\n if (typeof param === 'string') {\n return '\"' + this._toUnicode(param) + '\"';\n } else if (typeof param === 'number' && (isNaN(param) || !isFinite(param))) { // Unusable numbers go null\n return 'null';\n } else if (typeof param === 'undefined' || param === null) { // And so does undefined\n return 'null';\n } else if (typeof param.toJSON === 'function') {\n var t = param.toJSON();\n if (typeof t === 'string') {\n return '\"' + this._escape(t) + '\"';\n } else {\n return this._escape(t.toString());\n }\n } else if (typeof param === 'number' || typeof param === 'boolean') { // These ones' toString methods return valid JSON.\n return '' + param;\n } else if (typeof param === 'function') {\n return 'null'; // match JSON.stringify\n } else if (param.constructor === Date) {\n return '\"' + this._escape(dateToISOString(param)) + '\"';\n } else if (param.constructor === Array) {\n var arrayString = '';\n for (var i = 0, len = param.length; i < len; i++) {\n if (i > 0) {\n arrayString += ',';\n }\n arrayString += this._stringifyValue(param[i]);\n }\n return '[' + arrayString + ']';\n } else { // Object\n var objectString = '';\n for (var k in param) {\n if ({}.hasOwnProperty.call(param, k)) {\n if (objectString !== '') {\n objectString += ',';\n }\n objectString += '\"' + this._escape(k) + '\": ' + this._stringifyValue(param[k]);\n }\n }\n return '{' + objectString + '}';\n }\n },\n\n /**\n * Serializes a JSON object into a string.\n *\n * @method stringify\n * @param {Object} input Data to be serialized into JSON\n * @param {Boolean} convertToUnicode When `true`, converts string contents to unicode \\uXXXX\n * @return {String} Serialized string\n *\n * @sample Ink_Util_Json_stringify.html \n */\n stringify: function(input, convertToUnicode) {\n this._convertToUnicode = !!convertToUnicode;\n if(!this._convertToUnicode && this._nativeJSON) {\n return this._nativeJSON.stringify(input);\n }\n return this._stringifyValue(input); // And recurse.\n },\n \n /**\n * Parses a JSON text through a function\n * \n * @method parse\n * @param text {String} Input string\n * @param reviver {Function} Function receiving `(key, value)`, and `this`=(containing object), used to walk objects.\n * \n * @return {Object} JSON object\n *\n * @sample Ink_Util_Json_parse.html \n */\n /* From https://github.com/douglascrockford/JSON-js/blob/master/json.js */\n parse: function (text, reviver) {\n /*jshint evil:true*/\n\n// The parse method takes a text and an optional reviver function, and returns\n// a JavaScript value if the text is a valid JSON text.\n\n var j;\n\n function walk(holder, key) {\n\n// The walk method is used to recursively walk the resulting structure so\n// that modifications can be made.\n\n var k, v, value = holder[key];\n if (value && typeof value === 'object') {\n for (k in value) {\n if (Object.prototype.hasOwnProperty.call(value, k)) {\n v = walk(value, k);\n if (v !== undefined) {\n value[k] = v;\n } else {\n delete value[k];\n }\n }\n }\n }\n return reviver.call(holder, key, value);\n }\n\n\n// Parsing happens in four stages. In the first stage, we replace certain\n// Unicode characters with escape sequences. JavaScript handles many characters\n// incorrectly, either silently deleting them, or treating them as line endings.\n\n text = String(text);\n cx.lastIndex = 0;\n if (cx.test(text)) {\n text = text.replace(cx, function (a) {\n return '\\\\u' +\n ('0000' + a.charCodeAt(0).toString(16)).slice(-4);\n });\n }\n\n// In the second stage, we run the text against regular expressions that look\n// for non-JSON patterns. We are especially concerned with '()' and 'new'\n// because they can cause invocation, and '=' because it can cause mutation.\n// But just to be safe, we want to reject all unexpected forms.\n\n// We split the second stage into 4 regexp operations in order to work around\n// crippling inefficiencies in IE's and Safari's regexp engines. First we\n// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we\n// replace all simple value tokens with ']' characters. Third, we delete all\n// open brackets that follow a colon or comma or that begin the text. Finally,\n// we look to see that the remaining characters are only whitespace or ']' or\n// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.\n\n if (/^[\\],:{}\\s]*$/\n .test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')\n .replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g, ']')\n .replace(/(?:^|:|,)(?:\\s*\\[)+/g, ''))) {\n\n// In the third stage we use the eval function to compile the text into a\n// JavaScript structure. The '{' operator is subject to a syntactic ambiguity\n// in JavaScript: it can begin a block or an object literal. We wrap the text\n// in parens to eliminate the ambiguity.\n\n j = eval('(' + text + ')');\n\n// In the optional fourth stage, we recursively walk the new structure, passing\n// each name/value pair to a reviver function for possible transformation.\n\n return typeof reviver === 'function' ?\n walk({'': j}, '') :\n j;\n }\n\n// If the text is not JSON parseable, then a SyntaxError is thrown.\n\n throw new SyntaxError('JSON.parse');\n }\n };\n\n return InkJson;\n});\n","/**\n * String Utilities\n * @module Ink.Util.String_1\n * @version 1\n */\n\nInk.createModule('Ink.Util.String', '1', [], function() {\n\n 'use strict';\n\n /**\n * @namespace Ink.Util.String_1 \n */\n var InkUtilString = {\n\n /**\n * List of special chars\n * \n * @property _chars\n * @type {Array}\n * @private\n * @readOnly\n * @static\n */\n _chars: ['&','à','á','â','ã','ä','å','æ','ç','è','é',\n 'ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô',\n 'õ','ö','ø','ù','ú','û','ü','ý','þ','ÿ','À',\n 'Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë',\n 'Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö',\n 'Ø','Ù','Ú','Û','Ü','Ý','Þ','€','\\\"','ß','<',\n '>','¢','£','¤','¥','¦','§','¨','©','ª','«',\n '¬','\\xad','®','¯','°','±','²','³','´','µ','¶',\n '·','¸','¹','º','»','¼','½','¾'],\n\n /**\n * List of the special characters' html entities\n * \n * @property _entities\n * @type {Array}\n * @private\n * @readOnly\n * @static\n */\n _entities: ['amp','agrave','aacute','acirc','atilde','auml','aring',\n 'aelig','ccedil','egrave','eacute','ecirc','euml','igrave',\n 'iacute','icirc','iuml','eth','ntilde','ograve','oacute',\n 'ocirc','otilde','ouml','oslash','ugrave','uacute','ucirc',\n 'uuml','yacute','thorn','yuml','Agrave','Aacute','Acirc',\n 'Atilde','Auml','Aring','AElig','Ccedil','Egrave','Eacute',\n 'Ecirc','Euml','Igrave','Iacute','Icirc','Iuml','ETH','Ntilde',\n 'Ograve','Oacute','Ocirc','Otilde','Ouml','Oslash','Ugrave',\n 'Uacute','Ucirc','Uuml','Yacute','THORN','euro','quot','szlig',\n 'lt','gt','cent','pound','curren','yen','brvbar','sect','uml',\n 'copy','ordf','laquo','not','shy','reg','macr','deg','plusmn',\n 'sup2','sup3','acute','micro','para','middot','cedil','sup1',\n 'ordm','raquo','frac14','frac12','frac34'],\n\n /**\n * List of accented chars\n * \n * @property _accentedChars\n * @type {Array}\n * @private\n * @readOnly\n * @static\n */\n _accentedChars:['à','á','â','ã','ä','å',\n 'è','é','ê','ë',\n 'ì','í','î','ï',\n 'ò','ó','ô','õ','ö',\n 'ù','ú','û','ü',\n 'ç','ñ',\n 'À','Á','Â','Ã','Ä','Å',\n 'È','É','Ê','Ë',\n 'Ì','Í','Î','Ï',\n 'Ò','Ó','Ô','Õ','Ö',\n 'Ù','Ú','Û','Ü',\n 'Ç','Ñ'],\n\n /**\n * List of the accented chars (above), but without the accents\n * \n * @property _accentedRemovedChars\n * @type {Array}\n * @private\n * @readOnly\n * @static\n */\n _accentedRemovedChars:['a','a','a','a','a','a',\n 'e','e','e','e',\n 'i','i','i','i',\n 'o','o','o','o','o',\n 'u','u','u','u',\n 'c','n',\n 'A','A','A','A','A','A',\n 'E','E','E','E',\n 'I','I','I','I',\n 'O','O','O','O','O',\n 'U','U','U','U',\n 'C','N'],\n /**\n * Object that contains the basic HTML unsafe chars, as keys, and their HTML entities as values\n * \n * @property _htmlUnsafeChars\n * @type {Object}\n * @private\n * @readOnly\n * @static\n */\n _htmlUnsafeChars:{'<':'&lt;','>':'&gt;','&':'&amp;','\"':'&quot;',\"'\":'&apos;'},\n\n /**\n * Capitalizes a word.\n * If param as more than one word, it converts first letter of all words that have more than 2 letters\n *\n * @method ucFirst\n * @param {String} string String to capitalize.\n * @param {Boolean} [firstWordOnly]=false Flag to capitalize only the first word.\n * @return {String} Camel cased string.\n * @public\n * @static\n * @sample Ink_Util_String_ucFirst.html \n */\n ucFirst: function(string, firstWordOnly) {\n var replacer = firstWordOnly ? /(^|\\s)(\\w)(\\S{2,})/ : /(^|\\s)(\\w)(\\S{2,})/g;\n return string ? String(string).replace(replacer, function(_, $1, $2, $3){\n return $1 + $2.toUpperCase() + $3.toLowerCase();\n }) : string;\n },\n\n /**\n * Trims whitespace from strings\n *\n * @method trim\n * @param {String} string String to be trimmed\n * @return {String} Trimmed string\n * @public\n * @static\n * @sample Ink_Util_String_trim.html \n */\n trim: function(string)\n {\n if (typeof string === 'string') {\n return string.replace(/^\\s+|\\s+$|\\n+$/g, '');\n }\n return string;\n },\n\n /**\n * Strips HTML tags from strings\n *\n * @method stripTags\n * @param {String} string String to strip tags from.\n * @param {String} allowed Comma separated list of allowed tags.\n * @return {String} Stripped string\n * @public\n * @static\n * @sample Ink_Util_String_stripTags.html \n */\n stripTags: function(string, allowed)\n {\n if (allowed && typeof allowed === 'string') {\n var aAllowed = InkUtilString.trim(allowed).split(',');\n var aNewAllowed = [];\n var cleanedTag = false;\n for(var i=0; i < aAllowed.length; i++) {\n if(InkUtilString.trim(aAllowed[i]) !== '') {\n cleanedTag = InkUtilString.trim(aAllowed[i].replace(/(<|\\>)/g, '').replace(/\\s/, ''));\n aNewAllowed.push('(<'+cleanedTag+'\\\\s[^>]+>|<(\\\\s|\\\\/)?(\\\\s|\\\\/)?'+cleanedTag+'>)');\n }\n }\n var strAllowed = aNewAllowed.join('|');\n var reAllowed = new RegExp(strAllowed, \"i\");\n\n var aFoundTags = string.match(new RegExp(\"<[^>]*>\", \"g\"));\n\n for(var j=0; j < aFoundTags.length; j++) {\n if(!aFoundTags[j].match(reAllowed)) {\n string = string.replace((new RegExp(aFoundTags[j], \"gm\")), '');\n }\n }\n return string;\n } else {\n return string.replace(/<[^\\>]+\\>/g, '');\n }\n },\n\n /**\n * Encodes string into HTML entities.\n *\n * @method htmlEntitiesEncode\n * @param {String} string\n * @return {String} string encoded\n * @public\n * @static\n * @sample Ink_Util_String_htmlEntitiesEncode.html \n */\n htmlEntitiesEncode: function(string)\n {\n if (string && string.replace) {\n var re = false;\n for (var i = 0; i < InkUtilString._chars.length; i++) {\n re = new RegExp(InkUtilString._chars[i], \"gm\");\n string = string.replace(re, '&' + InkUtilString._entities[i] + ';');\n }\n }\n return string;\n },\n\n /**\n * Decodes string from HTML entities.\n *\n * @method htmlEntitiesDecode\n * @param {String} string String to be decoded\n * @return {String} Decoded string\n * @public\n * @static\n * @sample Ink_Util_String_htmlEntitiesDecode.html \n */\n htmlEntitiesDecode: function(string)\n {\n if (string && string.replace) {\n var re = false;\n for (var i = 0; i < InkUtilString._entities.length; i++) {\n re = new RegExp(\"&\"+InkUtilString._entities[i]+\";\", \"gm\");\n string = string.replace(re, InkUtilString._chars[i]);\n }\n string = string.replace(/&#[^;]+;?/g, function($0){\n if ($0.charAt(2) === 'x') {\n return String.fromCharCode(parseInt($0.substring(3), 16));\n }\n else {\n return String.fromCharCode(parseInt($0.substring(2), 10));\n }\n });\n }\n return string;\n },\n\n /**\n * Encode a string to UTF-8.\n *\n * @method utf8Encode\n * @param {String} string String to be encoded\n * @return {String} string UTF-8 encoded string\n * @public\n * @static\n */\n utf8Encode: function(string) {\n /*jshint bitwise:false*/\n string = string.replace(/\\r\\n/g,\"\\n\");\n var utfstring = \"\";\n\n for (var n = 0; n < string.length; n++) {\n\n var c = string.charCodeAt(n);\n\n if (c < 128) {\n utfstring += String.fromCharCode(c);\n }\n else if((c > 127) && (c < 2048)) {\n utfstring += String.fromCharCode((c >> 6) | 192);\n utfstring += String.fromCharCode((c & 63) | 128);\n }\n else {\n utfstring += String.fromCharCode((c >> 12) | 224);\n utfstring += String.fromCharCode(((c >> 6) & 63) | 128);\n utfstring += String.fromCharCode((c & 63) | 128);\n }\n\n }\n return utfstring;\n },\n\n /**\n * Truncates a string without breaking words.\n *\n * @method shortString\n * @param {String} str String to truncate\n * @param {Number} n Number of chars of the short string\n * @return {String} \n * @public\n * @static\n * @sample Ink_Util_String_shortString.html \n */\n shortString: function(str,n) {\n var words = str.split(' ');\n var resultstr = '';\n for(var i = 0; i < words.length; i++ ){\n if((resultstr + words[i] + ' ').length>=n){\n resultstr += '&hellip;';\n break;\n }\n resultstr += words[i] + ' ';\n }\n return resultstr;\n },\n\n /**\n * Truncates a string, breaking words and adding ... at the end.\n *\n * @method truncateString\n * @param {String} str String to truncate\n * @param {Number} length Limit for the returned string, ellipsis included.\n * @return {String} Truncated String\n * @public\n * @static\n * @sample Ink_Util_String_truncateString.html \n */\n truncateString: function(str, length) {\n if(str.length - 1 > length) {\n return str.substr(0, length - 1) + \"\\u2026\";\n } else {\n return str;\n }\n },\n\n /**\n * Decodes a string from UTF-8.\n *\n * @method utf8Decode\n * @param {String} string String to be decoded\n * @return {String} Decoded string\n * @public\n * @static\n */\n utf8Decode: function(utfstring) {\n /*jshint bitwise:false*/\n var string = \"\";\n var i = 0, c = 0, c2 = 0, c3 = 0;\n\n while ( i < utfstring.length ) {\n\n c = utfstring.charCodeAt(i);\n\n if (c < 128) {\n string += String.fromCharCode(c);\n i++;\n }\n else if((c > 191) && (c < 224)) {\n c2 = utfstring.charCodeAt(i+1);\n string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));\n i += 2;\n }\n else {\n c2 = utfstring.charCodeAt(i+1);\n c3 = utfstring.charCodeAt(i+2);\n string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));\n i += 3;\n }\n\n }\n return string;\n },\n\n /**\n * Removes all accented characters from a string.\n *\n * @method removeAccentedChars\n * @param {String} string String to remove accents from\n * @return {String} String without accented chars\n * @public\n * @static\n * @sample Ink_Util_String_removeAccentedChars.html \n */\n removeAccentedChars: function(string)\n {\n var newString = string;\n var re = false;\n for (var i = 0; i < InkUtilString._accentedChars.length; i++) {\n re = new RegExp(InkUtilString._accentedChars[i], \"gm\");\n newString = newString.replace(re, '' + InkUtilString._accentedRemovedChars[i] + '');\n }\n return newString;\n },\n\n /**\n * Count the number of occurrences of a specific needle in a haystack\n *\n * @method substrCount\n * @param {String} haystack String to search in\n * @param {String} needle String to search for\n * @return {Number} Number of occurrences\n * @public\n * @static\n * @sample Ink_Util_String_substrCount.html \n */\n substrCount: function(haystack,needle)\n {\n return haystack ? haystack.split(needle).length - 1 : 0;\n },\n\n /**\n * Eval a JSON - We recommend you Ink.Util.Json\n *\n * @method evalJSON\n * @param {String} strJSON JSON string to eval\n * @param {Boolean} sanitize Flag to sanitize input\n * @return {Object} JS Object\n * @public\n * @static\n */\n evalJSON: function(strJSON, sanitize) {\n /* jshint evil:true */\n if( (typeof sanitize === 'undefined' || sanitize === null) || InkUtilString.isJSON(strJSON)) {\n try {\n if(typeof(JSON) !== \"undefined\" && typeof(JSON.parse) !== 'undefined'){\n return JSON.parse(strJSON);\n }\n return eval('('+strJSON+')');\n } catch(e) {\n throw new Error('ERROR: Bad JSON string...');\n }\n }\n },\n\n /**\n * Checks if a string is a valid JSON object (string encoded)\n *\n * @method isJSON \n * @param {String} str String to check\n * @return {Boolean}\n * @public\n * @static\n */\n isJSON: function(str)\n {\n str = str.replace(/\\\\./g, '@').replace(/\"[^\"\\\\\\n\\r]*\"/g, '');\n return (/^[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t]*$/).test(str);\n },\n\n /**\n * Escapes unsafe html chars as HTML entities\n *\n * @method htmlEscapeUnsafe\n * @param {String} str String to escape\n * @return {String} Escaped string\n * @public\n * @static\n * @sample Ink_Util_String_htmlEscapeUnsafe.html \n */\n htmlEscapeUnsafe: function(str){\n var chars = InkUtilString._htmlUnsafeChars;\n return str !== null ? String(str).replace(/[<>&'\"]/g,function(c){return chars[c];}) : str;\n },\n\n /**\n * Normalizes whitespace in string.\n * String is trimmed and sequences of whitespaces are collapsed.\n *\n * @method normalizeWhitespace\n * @param {String} str String to normalize\n * @return {String} Normalized string\n * @public\n * @static\n * @sample Ink_Util_String_normalizeWhitespace.html \n */\n normalizeWhitespace: function(str){\n return str !== null ? InkUtilString.trim(String(str).replace(/\\s+/g,' ')) : str;\n },\n\n /**\n * Converts string to unicode.\n *\n * @method toUnicode\n * @param {String} str String to convert\n * @return {String} Unicoded String\n * @public\n * @static\n * @sample Ink_Util_String_toUnicode.html \n */\n toUnicode: function(str) {\n if (typeof str === 'string') {\n var unicodeString = '';\n var inInt = false;\n var theUnicode = false;\n var total = str.length;\n var i=0;\n\n while(i < total)\n {\n inInt = str.charCodeAt(i);\n if( (inInt >= 32 && inInt <= 126) ||\n inInt === 8 ||\n inInt === 9 ||\n inInt === 10 ||\n inInt === 12 ||\n inInt === 13 ||\n inInt === 32 ||\n inInt === 34 ||\n inInt === 47 ||\n inInt === 58 ||\n inInt === 92) {\n\n /*\n if(inInt == 34 || inInt == 92 || inInt == 47) {\n theUnicode = '\\\\'+str.charAt(i);\n } else {\n }\n */\n if(inInt === 8) {\n theUnicode = '\\\\b';\n } else if(inInt === 9) {\n theUnicode = '\\\\t';\n } else if(inInt === 10) {\n theUnicode = '\\\\n';\n } else if(inInt === 12) {\n theUnicode = '\\\\f';\n } else if(inInt === 13) {\n theUnicode = '\\\\r';\n } else {\n theUnicode = str.charAt(i);\n }\n } else {\n theUnicode = str.charCodeAt(i).toString(16)+''.toUpperCase();\n while (theUnicode.length < 4) {\n theUnicode = '0' + theUnicode;\n }\n theUnicode = '\\\\u' + theUnicode;\n }\n unicodeString += theUnicode;\n\n i++;\n }\n return unicodeString;\n }\n },\n\n /**\n * Escapes a unicode character.\n *\n * @method escape\n * @param {String} c Character to escape\n * @return {String} Escaped character. Returns \\xXX if hex smaller than 0x100, otherwise \\uXXXX\n * @public\n * @static\n * @sample Ink_Util_String_escape.html \n */\n escape: function(c) {\n var hex = (c).charCodeAt(0).toString(16).split('');\n if (hex.length < 3) {\n while (hex.length < 2) { hex.unshift('0'); }\n hex.unshift('x');\n }\n else {\n while (hex.length < 4) { hex.unshift('0'); }\n hex.unshift('u');\n }\n\n hex.unshift('\\\\');\n return hex.join('');\n },\n\n /**\n * Unescapes a unicode character escape sequence\n *\n * @method unescape\n * @param {String} es Escape sequence\n * @return {String} String un-unicoded\n * @public\n * @static\n * @sample Ink_Util_String_unescape.html \n */\n unescape: function(es) {\n var idx = es.lastIndexOf('0');\n idx = idx === -1 ? 2 : Math.min(idx, 2);\n //console.log(idx);\n var hexNum = es.substring(idx);\n //console.log(hexNum);\n var num = parseInt(hexNum, 16);\n return String.fromCharCode(num);\n },\n\n /**\n * Escapes a string to unicode characters\n *\n * @method escapeText\n * @param {String} txt \n * @param {Array} [whiteList] Whitelist of characters\n * @return {String} String escaped to Unicode\n * @public\n * @static\n * @sample Ink_Util_String_escapeText.html \n */\n escapeText: function(txt, whiteList) {\n if (whiteList === undefined) {\n whiteList = ['[', ']', '\\'', ','];\n }\n var txt2 = [];\n var c, C;\n for (var i = 0, f = txt.length; i < f; ++i) {\n c = txt[i];\n C = c.charCodeAt(0);\n if (C < 32 || C > 126 && whiteList.indexOf(c) === -1) {\n c = InkUtilString.escape(c);\n }\n txt2.push(c);\n }\n return txt2.join('');\n },\n\n /**\n * Regex to check escaped strings\n *\n * @property escapedCharRegex\n * @type {Regex}\n * @public\n * @readOnly\n * @static\n */\n escapedCharRegex: /(\\\\x[0-9a-fA-F]{2})|(\\\\u[0-9a-fA-F]{4})/g,\n\n /**\n * Unescapes a string\n *\n * @method unescapeText\n * @param {String} txt\n * @return {String} Unescaped string\n * @public\n * @static\n * @sample Ink_Util_String_unescapeText.html \n */\n unescapeText: function(txt) {\n /*jshint boss:true */\n var m;\n while (m = InkUtilString.escapedCharRegex.exec(txt)) {\n m = m[0];\n txt = txt.replace(m, InkUtilString.unescape(m));\n InkUtilString.escapedCharRegex.lastIndex = 0;\n }\n return txt;\n },\n\n /**\n * Compares two strings.\n *\n * @method strcmp\n * @param {String} str1 First String\n * @param {String} str2 Second String\n * @return {Number}\n * @public\n * @static\n * @sample Ink_Util_String_strcmp.html \n */\n strcmp: function(str1, str2) {\n return ((str1 === str2) ? 0 : ((str1 > str2) ? 1 : -1));\n },\n\n /**\n * Splits a string into smaller chunks\n *\n * @method packetize\n * @param {String} str String to divide\n * @param {Number} maxLen Maximum chunk size (in characters)\n * @return {Array} Chunks of the original string\n * @public\n * @static\n * @sample Ink_Util_String_packetize.html \n */\n packetize: function(str, maxLen) {\n var len = str.length;\n var parts = new Array( Math.ceil(len / maxLen) );\n var chars = str.split('');\n var sz, i = 0;\n while (len) {\n sz = Math.min(maxLen, len);\n parts[i++] = chars.splice(0, sz).join('');\n len -= sz;\n }\n return parts;\n }\n };\n\n return InkUtilString;\n\n});\n","/**\n * URL Utilities\n * @module Ink.Util.Url_1\n * @version 1\n */\n\nInk.createModule('Ink.Util.Url', '1', [], function() {\n\n 'use strict';\n\n /**\n * @namespace Ink.Util.Url_1\n */\n var Url = {\n\n /**\n * Auxiliary string for encoding\n *\n * @property _keyStr\n * @type {String}\n * @readOnly\n * @private\n */\n _keyStr : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',\n\n\n /**\n * Gets URL of current page\n *\n * @method getUrl\n * @return Current URL\n * @public\n * @static\n * @sample Ink_Util_Url_getUrl.html \n */\n getUrl: function()\n {\n return window.location.href;\n },\n\n /**\n * Generates an URL string.\n *\n * @method genQueryString\n * @param {String} uri Base URL\n * @param {Object} params Object to transform to query string\n * @return {String} URI with query string set\n * @public\n * @static\n * @sample Ink_Util_Url_genQueryString.html \n */\n genQueryString: function(uri, params) {\n var hasQuestionMark = uri.indexOf('?') !== -1;\n var sep, pKey, pValue, parts = [uri];\n\n for (pKey in params) {\n if (params.hasOwnProperty(pKey)) {\n if (!hasQuestionMark) {\n sep = '?';\n hasQuestionMark = true;\n } else {\n sep = '&';\n }\n pValue = params[pKey];\n if (typeof pValue !== 'number' && !pValue) {\n pValue = '';\n }\n parts = parts.concat([sep, encodeURIComponent(pKey), '=', encodeURIComponent(pValue)]);\n }\n }\n\n return parts.join('');\n },\n\n /**\n * Gets an object from an URL encoded string.\n *\n * @method getQueryString\n * @param {String} [str] URL String. When not specified it uses the current URL.\n * @return {Object} Key-Value pair object\n * @public\n * @static\n * @sample Ink_Util_Url_getQueryString.html \n */\n getQueryString: function(str)\n {\n var url;\n if(str && typeof(str) !== 'undefined') {\n url = str;\n } else {\n url = this.getUrl();\n }\n var aParams = {};\n if(url.match(/\\?(.+)/i)) {\n var queryStr = url.replace(/^(.*)\\?([^\\#]+)(\\#(.*))?/g, \"$2\");\n if(queryStr.length > 0) {\n var aQueryStr = queryStr.split(/[;&]/);\n for(var i=0; i < aQueryStr.length; i++) {\n var pairVar = aQueryStr[i].split('=');\n aParams[decodeURIComponent(pairVar[0])] = (typeof(pairVar[1]) !== 'undefined' && pairVar[1]) ? decodeURIComponent(pairVar[1]) : false;\n }\n }\n }\n return aParams;\n },\n\n /**\n * Gets the URL hash value\n *\n * @method getAnchor\n * @param {String} [str] URL String. Defaults to current page URL.\n * @return {String|Boolean} Hash in the URL. If there's no hash, returns false.\n * @public\n * @static\n * @sample Ink_Util_Url_getAnchor.html \n */\n getAnchor: function(str)\n {\n var url;\n if(str && typeof(str) !== 'undefined') {\n url = str;\n } else {\n url = this.getUrl();\n }\n var anchor = false;\n if(url.match(/#(.+)/)) {\n anchor = url.replace(/([^#]+)#(.*)/, \"$2\");\n }\n return anchor;\n },\n\n /**\n * Gets the anchor string of an URL\n *\n * @method getAnchorString\n * @param {String} [string] URL to parse. Defaults to current URL.\n * @return {Object} Key-value pair object of the URL's hashtag 'variables'\n * @public\n * @static\n * @sample Ink_Util_Url_getAnchorString.html \n */\n getAnchorString: function(string)\n {\n var url;\n if(string && typeof(string) !== 'undefined') {\n url = string;\n } else {\n url = this.getUrl();\n }\n var aParams = {};\n if(url.match(/#(.+)/i)) {\n var anchorStr = url.replace(/^([^#]+)#(.*)?/g, \"$2\");\n if(anchorStr.length > 0) {\n var aAnchorStr = anchorStr.split(/[;&]/);\n for(var i=0; i < aAnchorStr.length; i++) {\n var pairVar = aAnchorStr[i].split('=');\n aParams[decodeURIComponent(pairVar[0])] = (typeof(pairVar[1]) !== 'undefined' && pairVar[1]) ? decodeURIComponent(pairVar[1]) : false;\n }\n }\n }\n return aParams;\n },\n\n\n /**\n * Parses URL string into URL parts\n *\n * @method parseUrl\n * @param {String} url URL to be parsed\n * @return {Object} Parsed URL as a key-value object.\n * @public\n * @static\n * @sample Ink_Util_Url_parseUrl.html \n */\n parseUrl: function(url) {\n var aURL = {};\n if(url && typeof url === 'string') {\n if(url.match(/^([^:]+):\\/\\//i)) {\n var re = /^([^:]+):\\/\\/([^\\/]*)\\/?([^\\?#]*)\\??([^#]*)#?(.*)/i;\n if(url.match(re)) {\n aURL.scheme = url.replace(re, \"$1\");\n aURL.host = url.replace(re, \"$2\");\n aURL.path = '/'+url.replace(re, \"$3\");\n aURL.query = url.replace(re, \"$4\") || false;\n aURL.fragment = url.replace(re, \"$5\") || false;\n }\n } else {\n var re1 = new RegExp(\"^([^\\\\?]+)\\\\?([^#]+)#(.*)\", \"i\");\n var re2 = new RegExp(\"^([^\\\\?]+)\\\\?([^#]+)#?\", \"i\");\n var re3 = new RegExp(\"^([^\\\\?]+)\\\\??\", \"i\");\n if(url.match(re1)) {\n aURL.scheme = false;\n aURL.host = false;\n aURL.path = url.replace(re1, \"$1\");\n aURL.query = url.replace(re1, \"$2\");\n aURL.fragment = url.replace(re1, \"$3\");\n } else if(url.match(re2)) {\n aURL.scheme = false;\n aURL.host = false;\n aURL.path = url.replace(re2, \"$1\");\n aURL.query = url.replace(re2, \"$2\");\n aURL.fragment = false;\n } else if(url.match(re3)) {\n aURL.scheme = false;\n aURL.host = false;\n aURL.path = url.replace(re3, \"$1\");\n aURL.query = false;\n aURL.fragment = false;\n }\n }\n if(aURL.host) {\n var regPort = /^(.*?)\\\\:(\\\\d+)$/i;\n // check for port\n if(aURL.host.match(regPort)) {\n var tmpHost1 = aURL.host;\n aURL.host = tmpHost1.replace(regPort, \"$1\");\n aURL.port = tmpHost1.replace(regPort, \"$2\");\n } else {\n aURL.port = false;\n }\n // check for user and pass\n if(aURL.host.match(/@/i)) {\n var tmpHost2 = aURL.host;\n aURL.host = tmpHost2.split('@')[1];\n var tmpUserPass = tmpHost2.split('@')[0];\n if(tmpUserPass.match(/\\:/)) {\n aURL.user = tmpUserPass.split(':')[0];\n aURL.pass = tmpUserPass.split(':')[1];\n } else {\n aURL.user = tmpUserPass;\n aURL.pass = false;\n }\n }\n }\n }\n return aURL;\n },\n\n /**\n * Formats an URL object into an URL string.\n *\n * @method format\n * @param urlObj Window.location, a.href, or parseUrl object to format\n * @return {String} Full URL.\n */\n format: function (urlObj) {\n var protocol = '';\n var host = '';\n var path = '';\n var frag = '';\n var query = '';\n\n if (typeof urlObj.protocol === 'string') {\n protocol = urlObj.protocol + '//'; // here it comes with the colon\n } else if (typeof urlObj.scheme === 'string') {\n protocol = urlObj.scheme + '://';\n }\n\n host = urlObj.host || urlObj.hostname || '';\n path = urlObj.path || '';\n\n if (typeof urlObj.query === 'string') {\n query = urlObj.query;\n } else if (typeof urlObj.search === 'string') {\n query = urlObj.search.replace(/^\\?/, '');\n }\n if (typeof urlObj.fragment === 'string') {\n frag = urlObj.fragment;\n } else if (typeof urlObj.hash === 'string') {\n frag = urlObj.hash.replace(/#$/, '');\n }\n\n return [\n protocol,\n host,\n path,\n query && '?' + query,\n frag && '#' + frag\n ].join('');\n },\n\n /**\n * Gets the last loaded script element\n *\n * @method currentScriptElement\n * @param {String} [match] String to match against the script src attribute\n * @return {DOMElement|Boolean} Returns the `script` DOM Element or false if unable to find it.\n * @public\n * @static\n * @sample Ink_Util_Url_currentScriptElement.html \n */\n currentScriptElement: function(match)\n {\n var aScripts = document.getElementsByTagName('script');\n if(typeof(match) === 'undefined') {\n if(aScripts.length > 0) {\n return aScripts[(aScripts.length - 1)];\n } else {\n return false;\n }\n } else {\n var curScript = false;\n var re = new RegExp(\"\"+match+\"\", \"i\");\n for(var i=0, total = aScripts.length; i < total; i++) {\n curScript = aScripts[i];\n if(re.test(curScript.src)) {\n return curScript;\n }\n }\n return false;\n }\n },\n\n \n /*\n base64Encode: function(string)\n {\n /**\n * --function {String} ?\n * --Convert a string to BASE 64\n * @param {String} string - string to convert\n * @return base64 encoded string\n *\n * \n if(!SAPO.Utility.String || typeof(SAPO.Utility.String) === 'undefined') {\n throw \"SAPO.Utility.Url.base64Encode depends of SAPO.Utility.String, which has not been referred.\";\n }\n\n var output = \"\";\n var chr1, chr2, chr3, enc1, enc2, enc3, enc4;\n var i = 0;\n\n var input = SAPO.Utility.String.utf8Encode(string);\n\n while (i < input.length) {\n\n chr1 = input.charCodeAt(i++);\n chr2 = input.charCodeAt(i++);\n chr3 = input.charCodeAt(i++);\n\n enc1 = chr1 >> 2;\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\n enc4 = chr3 & 63;\n\n if (isNaN(chr2)) {\n enc3 = enc4 = 64;\n } else if (isNaN(chr3)) {\n enc4 = 64;\n }\n\n output = output +\n this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +\n this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);\n }\n return output;\n },\n base64Decode: function(string)\n {\n * --function {String} ?\n * Decode a BASE 64 encoded string\n * --param {String} string base64 encoded string\n * --return string decoded\n if(!SAPO.Utility.String || typeof(SAPO.Utility.String) === 'undefined') {\n throw \"SAPO.Utility.Url.base64Decode depends of SAPO.Utility.String, which has not been referred.\";\n }\n\n var output = \"\";\n var chr1, chr2, chr3;\n var enc1, enc2, enc3, enc4;\n var i = 0;\n\n var input = string.replace(/[^A-Za-z0-9\\+\\/\\=]/g, \"\");\n\n while (i < input.length) {\n\n enc1 = this._keyStr.indexOf(input.charAt(i++));\n enc2 = this._keyStr.indexOf(input.charAt(i++));\n enc3 = this._keyStr.indexOf(input.charAt(i++));\n enc4 = this._keyStr.indexOf(input.charAt(i++));\n\n chr1 = (enc1 << 2) | (enc2 >> 4);\n chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);\n chr3 = ((enc3 & 3) << 6) | enc4;\n\n output = output + String.fromCharCode(chr1);\n\n if (enc3 !== 64) {\n output = output + String.fromCharCode(chr2);\n }\n if (enc4 !== 64) {\n output = output + String.fromCharCode(chr3);\n }\n }\n output = SAPO.Utility.String.utf8Decode(output);\n return output;\n },\n */\n\n\n /**\n * Debug function ?\n *\n * @method _debug\n * @private\n * @static\n */\n _debug: function() {}\n\n };\n\n return Url;\n\n});\n","/**\n * Validation Utilities\n * @module Ink.Util.Validator_1\n * @version 1\n */\n \nInk.createModule('Ink.Util.Validator', '1', [], function() {\n\n 'use strict';\n\n /**\n * @namespace Ink.Util.Validator_1 \n */\n var Validator = {\n\n /**\n * List of country codes avaible for the isPhone method\n *\n * @property _countryCodes\n * @type {Array}\n * @private\n * @static\n * @readOnly\n */\n _countryCodes : [\n 'AO',\n 'CV',\n 'MZ',\n 'PT'\n ],\n\n /**\n * International number for portugal\n *\n * @property _internacionalPT\n * @type {Number}\n * @private\n * @static\n * @readOnly\n *\n */\n _internacionalPT: 351,\n\n /**\n * List of all portuguese number prefixes\n *\n * @property _indicativosPT\n * @type {Object}\n * @private\n * @static\n * @readOnly\n *\n */\n _indicativosPT: {\n 21: 'lisboa',\n 22: 'porto',\n 231: 'mealhada',\n 232: 'viseu',\n 233: 'figueira da foz',\n 234: 'aveiro',\n 235: 'arganil',\n 236: 'pombal',\n 238: 'seia',\n 239: 'coimbra',\n 241: 'abrantes',\n 242: 'ponte de sôr',\n 243: 'santarém',\n 244: 'leiria',\n 245: 'portalegre',\n 249: 'torres novas',\n 251: 'valença',\n 252: 'vila nova de famalicão',\n 253: 'braga',\n 254: 'peso da régua',\n 255: 'penafiel',\n 256: 'são joão da madeira',\n 258: 'viana do castelo',\n 259: 'vila real',\n 261: 'torres vedras',\n 262: 'caldas da raínha',\n 263: 'vila franca de xira',\n 265: 'setúbal',\n 266: 'évora',\n 268: 'estremoz',\n 269: 'santiago do cacém',\n 271: 'guarda',\n 272: 'castelo branco',\n 273: 'bragança',\n 274: 'proença-a-nova',\n 275: 'covilhã',\n 276: 'chaves',\n 277: 'idanha-a-nova',\n 278: 'mirandela',\n 279: 'moncorvo',\n 281: 'tavira',\n 282: 'portimão',\n 283: 'odemira',\n 284: 'beja',\n 285: 'moura',\n 286: 'castro verde',\n 289: 'faro',\n 291: 'funchal, porto santo',\n 292: 'corvo, faial, flores, horta, pico',\n 295: 'angra do heroísmo, graciosa, são jorge, terceira',\n 296: 'ponta delgada, são miguel, santa maria',\n\n 91 : 'rede móvel 91 (Vodafone / Yorn)',\n 93 : 'rede móvel 93 (Optimus)',\n 96 : 'rede móvel 96 (TMN)',\n 92 : 'rede móvel 92 (TODOS)',\n //925 : 'rede móvel 925 (TMN 925)',\n //926 : 'rede móvel 926 (TMN 926)',\n //927 : 'rede móvel 927 (TMN 927)',\n //922 : 'rede móvel 922 (Phone-ix)',\n\n 707: 'número único',\n 760: 'número único',\n 800: 'número grátis',\n 808: 'chamada local',\n 30: 'voip'\n },\n /**\n * International number for Cabo Verde\n *\n * @property _internacionalCV\n * @type {Number}\n * @private\n * @static\n * @readOnly\n */\n _internacionalCV: 238,\n\n /**\n * List of all Cabo Verde number prefixes\n *\n * @property _indicativosCV\n * @type {Object}\n * @private\n * @static\n * @readOnly\n */\n _indicativosCV: {\n 2: 'fixo',\n 91: 'móvel 91',\n 95: 'móvel 95',\n 97: 'móvel 97',\n 98: 'móvel 98',\n 99: 'móvel 99'\n },\n /**\n * International number for Angola\n *\n * @property _internacionalAO\n * @type {Number}\n * @private\n * @static\n * @readOnly\n */\n _internacionalAO: 244,\n\n /**\n * List of all Angola number prefixes\n *\n * @property _indicativosAO\n * @type {Object}\n * @private\n * @static\n * @readOnly\n */\n _indicativosAO: {\n 2: 'fixo',\n 91: 'móvel 91',\n 92: 'móvel 92'\n },\n /**\n * International number for Mozambique\n *\n * @property _internacionalMZ\n * @type {Number}\n * @private\n * @static\n * @readOnly\n */\n _internacionalMZ: 258,\n\n /**\n * List of all Mozambique number prefixes\n *\n * @property _indicativosMZ\n * @type {Object}\n * @private\n * @static\n * @readOnly\n */\n _indicativosMZ: {\n 2: 'fixo',\n 82: 'móvel 82',\n 84: 'móvel 84'\n },\n\n /**\n * International number for Timor\n *\n * @property _internacionalTL\n * @type {Number}\n * @private\n * @static\n * @readOnly\n */\n _internacionalTL: 670,\n\n /**\n * List of all Timor number prefixes\n *\n * @property _indicativosTL\n * @type {Object}\n * @private\n * @static\n * @readOnly\n */\n _indicativosTL: {\n 3: 'fixo',\n 7: 'móvel 7'\n },\n\n /**\n * Regular expression groups for several groups of characters\n *\n * http://en.wikipedia.org/wiki/C0_Controls_and_Basic_Latin\n * http://en.wikipedia.org/wiki/Plane_%28Unicode%29#Basic_Multilingual_Plane\n * http://en.wikipedia.org/wiki/ISO_8859-1\n *\n * @property _characterGroups\n * @type {Object}\n * @private\n * @static\n * @readOnly\n */\n _characterGroups: {\n numbers: ['0-9'],\n asciiAlpha: ['a-zA-Z'],\n latin1Alpha: ['a-zA-Z', '\\u00C0-\\u00FF'],\n unicodeAlpha: ['a-zA-Z', '\\u00C0-\\u00FF', '\\u0100-\\u1FFF', '\\u2C00-\\uD7FF'],\n /* whitespace characters */\n space: [' '],\n dash: ['-'],\n underscore: ['_'],\n nicknamePunctuation: ['_.-'],\n\n singleLineWhitespace: ['\\t '],\n newline: ['\\n'],\n whitespace: ['\\t\\n\\u000B\\f\\r\\u00A0 '],\n\n asciiPunctuation: ['\\u0021-\\u002F', '\\u003A-\\u0040', '\\u005B-\\u0060', '\\u007B-\\u007E'],\n latin1Punctuation: ['\\u0021-\\u002F', '\\u003A-\\u0040', '\\u005B-\\u0060', '\\u007B-\\u007E', '\\u00A1-\\u00BF', '\\u00D7', '\\u00F7'],\n unicodePunctuation: ['\\u0021-\\u002F', '\\u003A-\\u0040', '\\u005B-\\u0060', '\\u007B-\\u007E', '\\u00A1-\\u00BF', '\\u00D7', '\\u00F7', '\\u2000-\\u206F', '\\u2E00-\\u2E7F', '\\u3000-\\u303F']\n },\n\n /**\n * Creates a regular expression for several character groups.\n *\n * @method createRegExp\n *\n * @param Groups* {Object}\n * Groups to build regular expressions for. Possible keys are:\n *\n * - **numbers**: 0-9\n * - **asciiAlpha**: a-z, A-Z\n * - **latin1Alpha**: asciiAlpha, plus printable characters in latin-1\n * - **unicodeAlpha**: unicode alphanumeric characters.\n * - **space**: ' ', the space character.\n * - **dash**: dash character.\n * - **underscore**: underscore character.\n * - **nicknamePunctuation**: dash, dot, underscore\n * - **singleLineWhitespace**: space and tab (whitespace which only spans one line).\n * - **newline**: newline character ('\\n')\n * - **whitespace**: whitespace characters in the ASCII character set.\n * - **asciiPunctuation**: punctuation characters in the ASCII character set.\n * - **latin1Punctuation**: punctuation characters in latin-1.\n * - **unicodePunctuation**: punctuation characters in unicode.\n *\n */\n createRegExp: function (groups) {\n var re = '^[';\n for (var key in groups) if (groups.hasOwnProperty(key)) {\n if (!(key in Validator._characterGroups)) {\n throw new Error('group ' + key + ' is not a valid character group');\n } else if (groups[key]) {\n re += Validator._characterGroups[key].join('');\n }\n }\n if (re === '^[') {\n // No changes\n return new RegExp('$^'); // match nothing\n }\n return new RegExp(re + ']*?$');\n },\n\n /**\n * Checks if a field has the required groups.\n *\n * @method checkCharacterGroups\n * @param {String} s The validation string\n * @param {Object} [groups]={} What groups are included. See createRegexp\n * @sample Ink_Util_Validator_checkCharacterGroups.html \n */\n checkCharacterGroups: function (s, groups) {\n return Validator.createRegExp(groups).test(s);\n },\n\n /**\n * Checks if a field contains unicode printable characters.\n *\n * @method unicode\n * @param {String} s The validation string\n * @param {Object} [options]={} Optional configuration object. See createRegexp\n */\n unicode: function (s, options) {\n return Validator.checkCharacterGroups(s, Ink.extendObj({\n unicodeAlpha: true}, options));\n },\n\n /**\n * Checks if a field only contains latin-1 alphanumeric characters. \n * Takes options for allowing singleline whitespace, cross-line whitespace and punctuation.\n *\n * @method latin1\n *\n * @param {String} s The validation string\n * @param {Object} [options]={} Optional configuration object. See createRegexp\n * @sample Ink_Util_Validator_latin1.html \n */\n latin1: function (s, options) {\n return Validator.checkCharacterGroups(s, Ink.extendObj({\n latin1Alpha: true}, options));\n },\n\n /**\n * Checks if a field only contains only ASCII alphanumeric characters. \n * Takes options for allowing singleline whitespace, cross-line whitespace and punctuation.\n *\n * @method ascii\n *\n * @param {String} s The validation string\n * @param {Object} [options]={} Optional configuration object. See createRegexp\n * @sample Ink_Util_Validator_ascii.html \n */\n ascii: function (s, options) {\n return Validator.checkCharacterGroups(s, Ink.extendObj({\n asciiAlpha: true}, options));\n },\n\n /**\n * Checks if a number is a valid\n *\n * @method number\n * @param {String} numb The number\n * @param {Object} [options] Further options\n * @param [options.decimalSep]='.' Allow decimal separator.\n * @param [options.thousandSep]=\",\" Strip this character from the number.\n * @param [options.negative]=false Allow negative numbers.\n * @param [options.decimalPlaces]=null Maximum number of decimal places. Use `0` for an integer number.\n * @param [options.max]=null Maximum number\n * @param [options.min]=null Minimum number\n * @param [options.returnNumber]=false When this option is true, return the number itself when the value is valid.\n * @sample Ink_Util_Validator_number.html \n */\n number: function (numb, inOptions) {\n numb = numb + '';\n var options = Ink.extendObj({\n decimalSep: '.',\n thousandSep: '',\n negative: true,\n decimalPlaces: null,\n maxDigits: null,\n max: null,\n min: null,\n returnNumber: false\n }, inOptions || {});\n // smart recursion thing sets up aliases for options.\n if (options.thousandSep) {\n numb = numb.replace(new RegExp('\\\\' + options.thousandSep, 'g'), '');\n options.thousandSep = '';\n return Validator.number(numb, options);\n }\n if (options.negative === false) {\n options.min = 0;\n options.negative = true;\n return Validator.number(numb, options);\n }\n if (options.decimalSep !== '.') {\n numb = numb.replace(new RegExp('\\\\' + options.decimalSep, 'g'), '.');\n }\n\n if (!/^(-)?(\\d+)?(\\.\\d+)?$/.test(numb) || numb === '') {\n return false; // forbidden character found\n }\n \n var split;\n if (options.decimalSep && numb.indexOf(options.decimalSep) !== -1) {\n split = numb.split(options.decimalSep);\n if (options.decimalPlaces !== null &&\n split[1].length > options.decimalPlaces) {\n return false;\n }\n } else {\n split = ['' + numb, ''];\n }\n \n if (options.maxDigits!== null) {\n if (split[0].replace(/-/g, '').length > options.maxDigits) {\n return split;\n }\n }\n \n // Now look at the actual float\n var ret = parseFloat(numb);\n \n if (options.maxExcl !== null && ret >= options.maxExcl ||\n options.minExcl !== null && ret <= options.minExcl) {\n return false;\n }\n if (options.max !== null && ret > options.max ||\n options.min !== null && ret < options.min) {\n return false;\n }\n \n if (options.returnNumber) {\n return ret;\n } else {\n return true;\n }\n },\n\n /**\n * Checks if a year is Leap \"Bissexto\"\n *\n * @method _isLeapYear\n * @param {Number} year Year to be checked\n * @return {Boolean} True if it is a leap year.\n * @private\n * @static\n * @example\n * Ink.requireModules(['Ink.Util.Validator_1'], function( InkValidator ){\n * console.log( InkValidator._isLeapYear( 2004 ) ); // Result: true\n * console.log( InkValidator._isLeapYear( 2006 ) ); // Result: false\n * });\n */\n _isLeapYear: function(year){\n\n var yearRegExp = /^\\d{4}$/;\n\n if(yearRegExp.test(year)){\n return ((year%4) ? false: ((year%100) ? true : ((year%400)? false : true)) );\n }\n\n return false;\n },\n\n /**\n * Object with the date formats available for validation\n *\n * @property _dateParsers\n * @type {Object}\n * @private\n * @static\n * @readOnly\n */\n _dateParsers: {\n 'yyyy-mm-dd': {day:5, month:3, year:1, sep: '-', parser: /^(\\d{4})(\\-)(\\d{1,2})(\\-)(\\d{1,2})$/},\n 'yyyy/mm/dd': {day:5, month:3, year:1, sep: '/', parser: /^(\\d{4})(\\/)(\\d{1,2})(\\/)(\\d{1,2})$/},\n 'yy-mm-dd': {day:5, month:3, year:1, sep: '-', parser: /^(\\d{2})(\\-)(\\d{1,2})(\\-)(\\d{1,2})$/},\n 'yy/mm/dd': {day:5, month:3, year:1, sep: '/', parser: /^(\\d{2})(\\/)(\\d{1,2})(\\/)(\\d{1,2})$/},\n 'dd-mm-yyyy': {day:1, month:3, year:5, sep: '-', parser: /^(\\d{1,2})(\\-)(\\d{1,2})(\\-)(\\d{4})$/},\n 'dd/mm/yyyy': {day:1, month:3, year:5, sep: '/', parser: /^(\\d{1,2})(\\/)(\\d{1,2})(\\/)(\\d{4})$/},\n 'dd-mm-yy': {day:1, month:3, year:5, sep: '-', parser: /^(\\d{1,2})(\\-)(\\d{1,2})(\\-)(\\d{2})$/},\n 'dd/mm/yy': {day:1, month:3, year:5, sep: '/', parser: /^(\\d{1,2})(\\/)(\\d{1,2})(\\/)(\\d{2})$/}\n },\n\n /**\n * Gets the number of days in a given month of a given year\n *\n * @method _daysInMonth\n * @param {Number} _m Month (1 to 12)\n * @param {Number} _y Year\n * @return {Number} Returns the number of days in a given month of a given year\n * @private\n * @static\n * @example\n * Ink.requireModules(['Ink.Util.Validator_1'], function( InkValidator ){\n * console.log( InkValidator._daysInMonth( 2, 2004 ) ); // Result: 29\n * console.log( InkValidator._daysInMonth( 2, 2006 ) ); // Result: 28\n * });\n */\n _daysInMonth: function(_m,_y){\n var nDays=0;\n\n _m = parseInt(_m, 10);\n _y = parseInt(_y, 10);\n\n if(_m===1 || _m===3 || _m===5 || _m===7 || _m===8 || _m===10 || _m===12) {\n nDays= 31;\n } else if ( _m===4 || _m===6 || _m===9 || _m===11) {\n nDays = 30;\n } else if (_m===2) {\n if((_y%400===0) || (_y%4===0 && _y%100!==0)) {\n nDays = 29;\n } else {\n nDays = 28;\n }\n }\n\n return nDays;\n },\n\n\n\n /**\n * Checks if a date is valid\n *\n * @method _isValidDate\n * @param {Number} year\n * @param {Number} month\n * @param {Number} day\n * @return {Boolean} True if valid\n * @private\n * @static\n * @example\n * Ink.requireModules(['Ink.Util.Validator_1'], function( InkValidator ){\n * console.log( InkValidator._isValidDate( 2004, 2, 29 ) ); // Result: true\n * console.log( InkValidator._isValidDate( 2006, 2, 29 ) ); // Result: false\n * });\n */\n _isValidDate: function(year, month, day){\n\n var yearRegExp = /^\\d{4}$/;\n var validOneOrTwo = /^\\d{1,2}$/;\n if(yearRegExp.test(year) && validOneOrTwo.test(month) && validOneOrTwo.test(day)){\n if(month>=1 && month<=12 && day>=1 && this._daysInMonth(month,year)>=day){\n return true;\n }\n }\n\n return false;\n },\n\n /**\n * Checks if an email is valid\n *\n * @method mail\n * @param {String} email\n * @return {Boolean} True if it's valid\n * @public\n * @static\n * @sample Ink_Util_Validator_mail.html \n */\n email: function(email)\n {\n var emailValido = new RegExp(\"^[_a-z0-9-]+((\\\\.|\\\\+)[_a-z0-9-]+)*@([\\\\w]*-?[\\\\w]*\\\\.)+[a-z]{2,4}$\", \"i\");\n if(!emailValido.test(email)) {\n return false;\n } else {\n return true;\n }\n },\n\n /**\n * Deprecated. Alias for email(). Use it instead.\n *\n * @method mail\n * @public\n * @static\n * @private\n */\n mail: function (mail) { return Validator.email(mail); },\n\n /**\n * Checks if an url is valid\n *\n * @method url\n * @param {String} url URL to be checked\n * @param {Boolean} [full] If true, validates a full URL (one that should start with 'http')\n * @return {Boolean} True if valid\n * @public\n * @static\n * @sample Ink_Util_Validator_url.html \n */\n url: function(url, full)\n {\n if(typeof full === \"undefined\" || full === false) {\n var reHTTP = new RegExp(\"(^(http\\\\:\\\\/\\\\/|https\\\\:\\\\/\\\\/)(.+))\", \"i\");\n if(reHTTP.test(url) === false) {\n url = 'http://'+url;\n }\n }\n\n var reUrl = new RegExp(\"^(http:\\\\/\\\\/|https:\\\\/\\\\/)([\\\\w]*(-?[\\\\w]*)*\\\\.)+[a-z]{2,4}\", \"i\");\n if(reUrl.test(url) === false) {\n return false;\n } else {\n return true;\n }\n },\n\n /**\n * Checks if a phone is valid in Portugal\n *\n * @method isPTPhone\n * @param {Number} phone Phone number to be checked\n * @return {Boolean} True if it's a valid Portuguese Phone\n * @public\n * @static\n * @sample Ink_Util_Validator_isPTPhone.html\n */\n isPTPhone: function(phone)\n {\n\n phone = phone.toString();\n var aInd = [];\n for(var i in this._indicativosPT) {\n if(typeof(this._indicativosPT[i]) === 'string') {\n aInd.push(i);\n }\n }\n var strInd = aInd.join('|');\n\n var re351 = /^(00351|\\+351)/;\n if(re351.test(phone)) {\n phone = phone.replace(re351, \"\");\n }\n\n var reSpecialChars = /(\\s|\\-|\\.)+/g;\n phone = phone.replace(reSpecialChars, '');\n //var reInt = new RegExp(\"\\\\d\", \"i\");\n var reInt = /[\\d]{9}/i;\n if(phone.length === 9 && reInt.test(phone)) {\n var reValid = new RegExp(\"^(\"+strInd+\")\");\n if(reValid.test(phone)) {\n return true;\n }\n }\n\n return false;\n },\n\n /**\n * Alias function for isPTPhone\n *\n * @method isPortuguesePhone\n * @param {Number} phone Phone number to be checked\n * @return {Boolean} True if it's a valid Portuguese Phone\n * @public\n * @static\n */\n isPortuguesePhone: function(phone)\n {\n return this.isPTPhone(phone);\n },\n\n /**\n * Checks if a phone is valid in Cabo Verde\n *\n * @method isCVPhone\n * @param {Number} phone Phone number to be checked\n * @return {Boolean} True if it's a valid Cape Verdean Phone\n * @public\n * @static\n * @sample Ink_Util_Validator_isCVPhone.html \n */\n isCVPhone: function(phone)\n {\n phone = phone.toString();\n var aInd = [];\n for(var i in this._indicativosCV) {\n if(typeof(this._indicativosCV[i]) === 'string') {\n aInd.push(i);\n }\n }\n var strInd = aInd.join('|');\n\n var re238 = /^(00238|\\+238)/;\n if(re238.test(phone)) {\n phone = phone.replace(re238, \"\");\n }\n\n var reSpecialChars = /(\\s|\\-|\\.)+/g;\n phone = phone.replace(reSpecialChars, '');\n //var reInt = new RegExp(\"\\\\d\", \"i\");\n var reInt = /[\\d]{7}/i;\n if(phone.length === 7 && reInt.test(phone)) {\n var reValid = new RegExp(\"^(\"+strInd+\")\");\n if(reValid.test(phone)) {\n return true;\n }\n }\n\n return false;\n },\n\n /**\n * Checks if a phone is valid in Angola\n *\n * @method isAOPhone\n * @param {Number} phone Phone number to be checked\n * @return {Boolean} True if it's a valid Angolan Phone\n * @public\n * @static\n * @sample Ink_Util_Validator_isAOPhone.html \n */\n isAOPhone: function(phone)\n {\n\n phone = phone.toString();\n var aInd = [];\n for(var i in this._indicativosAO) {\n if(typeof(this._indicativosAO[i]) === 'string') {\n aInd.push(i);\n }\n }\n var strInd = aInd.join('|');\n\n var re244 = /^(00244|\\+244)/;\n if(re244.test(phone)) {\n phone = phone.replace(re244, \"\");\n }\n\n var reSpecialChars = /(\\s|\\-|\\.)+/g;\n phone = phone.replace(reSpecialChars, '');\n //var reInt = new RegExp(\"\\\\d\", \"i\");\n var reInt = /[\\d]{9}/i;\n if(phone.length === 9 && reInt.test(phone)) {\n var reValid = new RegExp(\"^(\"+strInd+\")\");\n if(reValid.test(phone)) {\n return true;\n }\n }\n\n return false;\n },\n\n /**\n * Checks if a phone is valid in Mozambique\n *\n * @method isMZPhone\n * @param {Number} phone Phone number to be checked\n * @return {Boolean} True if it's a valid Mozambican Phone\n * @public\n * @static\n * @sample Ink_Util_Validator_isMZPhone.html \n */\n isMZPhone: function(phone)\n {\n\n phone = phone.toString();\n var aInd = [];\n for(var i in this._indicativosMZ) {\n if(typeof(this._indicativosMZ[i]) === 'string') {\n aInd.push(i);\n }\n }\n var strInd = aInd.join('|');\n var re258 = /^(00258|\\+258)/;\n if(re258.test(phone)) {\n phone = phone.replace(re258, \"\");\n }\n\n var reSpecialChars = /(\\s|\\-|\\.)+/g;\n phone = phone.replace(reSpecialChars, '');\n //var reInt = new RegExp(\"\\\\d\", \"i\");\n var reInt = /[\\d]{8,9}/i;\n if((phone.length === 9 || phone.length === 8) && reInt.test(phone)) {\n var reValid = new RegExp(\"^(\"+strInd+\")\");\n if(reValid.test(phone)) {\n if(phone.indexOf('2') === 0 && phone.length === 8) {\n return true;\n } else if(phone.indexOf('8') === 0 && phone.length === 9) {\n return true;\n }\n }\n }\n\n return false;\n },\n\n /**\n * Checks if a phone is valid in Timor\n *\n * @method isTLPhone\n * @param {Number} phone Phone number to be checked\n * @return {Boolean} True if it's a valid phone from Timor-Leste\n * @public\n * @static\n * @sample Ink_Util_Validator_isTLPhone.html \n */\n isTLPhone: function(phone)\n {\n\n phone = phone.toString();\n var aInd = [];\n for(var i in this._indicativosTL) {\n if(typeof(this._indicativosTL[i]) === 'string') {\n aInd.push(i);\n }\n }\n var strInd = aInd.join('|');\n var re670 = /^(00670|\\+670)/;\n if(re670.test(phone)) {\n phone = phone.replace(re670, \"\");\n }\n\n\n var reSpecialChars = /(\\s|\\-|\\.)+/g;\n phone = phone.replace(reSpecialChars, '');\n //var reInt = new RegExp(\"\\\\d\", \"i\");\n var reInt = /[\\d]{7}/i;\n if(phone.length === 7 && reInt.test(phone)) {\n var reValid = new RegExp(\"^(\"+strInd+\")\");\n if(reValid.test(phone)) {\n return true;\n }\n }\n\n return false;\n },\n\n /**\n * Checks if a number is a phone number.\n * This method validates the number in all country codes available the ones set in the second param\n *\n * @method isPhone\n * @param {String} phone Phone number to validate\n * @param {String|Array} [countryCode] Country code or array of countries to validate\n * @return {Boolean} True if it's a valid phone in any country available\n * @public\n * @static\n * @sample Ink_Util_Validator_isPhone.html\n */\n isPhone: function(){\n var index;\n\n if(arguments.length===0){\n return false;\n }\n\n var phone = arguments[0];\n\n if(arguments.length>1){\n if(arguments[1].constructor === Array){\n var func;\n for(index=0; index<arguments[1].length; index++ ){\n if(typeof(func=this['is' + arguments[1][index].toUpperCase() + 'Phone'])==='function'){\n if(func(phone)){\n return true;\n }\n } else {\n throw \"Invalid Country Code!\";\n }\n }\n } else if(typeof(this['is' + arguments[1].toUpperCase() + 'Phone'])==='function'){\n return this['is' + arguments[1].toUpperCase() + 'Phone'](phone);\n } else {\n throw \"Invalid Country Code!\";\n }\n } else {\n for(index=0; index<this._countryCodes.length; index++){\n if(this['is' + this._countryCodes[index] + 'Phone'](phone)){\n return true;\n }\n }\n }\n return false;\n },\n\n /**\n * Validates if a zip code is valid in Portugal\n *\n * @method codPostal\n * @param {Number|String} cp1\n * @param {optional Number|String} cp2\n * @param {optional Boolean} returnBothResults\n * @return {Boolean} True if it's a valid zip code\n * @public\n * @static\n * @sample Ink_Util_Validator_codPostal.html \n */\n codPostal: function(cp1,cp2,returnBothResults){\n\n\n var cPostalSep = /^(\\s*\\-\\s*|\\s+)$/;\n var trim = /^\\s+|\\s+$/g;\n var cPostal4 = /^[1-9]\\d{3}$/;\n var cPostal3 = /^\\d{3}$/;\n var parserCPostal = /^(.{4})(.*)(.{3})$/;\n\n\n returnBothResults = !!returnBothResults;\n\n cp1 = cp1.replace(trim,'');\n if(typeof(cp2)!=='undefined'){\n cp2 = cp2.replace(trim,'');\n if(cPostal4.test(cp1) && cPostal3.test(cp2)){\n if( returnBothResults === true ){\n return [true, true];\n } else {\n return true;\n }\n }\n } else {\n if(cPostal4.test(cp1) ){\n if( returnBothResults === true ){\n return [true,false];\n } else {\n return true;\n }\n }\n\n var cPostal = cp1.match(parserCPostal);\n\n if(cPostal!==null && cPostal4.test(cPostal[1]) && cPostalSep.test(cPostal[2]) && cPostal3.test(cPostal[3])){\n if( returnBothResults === true ){\n return [true,false];\n } else {\n return true;\n }\n }\n }\n\n if( returnBothResults === true ){\n return [false,false];\n } else {\n return false;\n }\n },\n\n /**\n * Checks if a date is valid in a given format\n *\n * @method isDate\n * @param {String} format Format defined in _dateParsers\n * @param {String} dateStr Date string\n * @return {Boolean} True if it's a valid date and in the specified format\n * @public\n * @static\n * @sample Ink_Util_Validator_isDate.html \n */\n isDate: function(format, dateStr){\n\n\n\n if(typeof(this._dateParsers[format])==='undefined'){\n return false;\n }\n var yearIndex = this._dateParsers[format].year;\n var monthIndex = this._dateParsers[format].month;\n var dayIndex = this._dateParsers[format].day;\n var dateParser = this._dateParsers[format].parser;\n var separator = this._dateParsers[format].sep;\n\n /* Trim Deactivated\n * var trim = /^\\w+|\\w+$/g;\n * dateStr = dateStr.replace(trim,\"\");\n */\n var data = dateStr.match(dateParser);\n if(data!==null){\n /* Trim Deactivated\n * for(i=1;i<=data.length;i++){\n * data[i] = data[i].replace(trim,\"\");\n *}\n */\n if(data[2]===data[4] && data[2]===separator){\n\n var _y = ((data[yearIndex].length===2) ? \"20\" + data[yearIndex].toString() : data[yearIndex] );\n\n if(this._isValidDate(_y,data[monthIndex].toString(),data[dayIndex].toString())){\n return true;\n }\n }\n }\n\n\n return false;\n },\n\n /**\n * Checks if a string is a valid color\n *\n * @method isColor\n * @param {String} str Color string to be checked\n * @return {Boolean} True if it's a valid color string\n * @public\n * @static\n * @sample Ink_Util_Validator_isColor.html \n */\n isColor: function(str){\n var match, valid = false,\n keyword = /^[a-zA-Z]+$/,\n hexa = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,\n rgb = /^rgb\\(\\s*([0-9]{1,3})(%)?\\s*,\\s*([0-9]{1,3})(%)?\\s*,\\s*([0-9]{1,3})(%)?\\s*\\)$/,\n rgba = /^rgba\\(\\s*([0-9]{1,3})(%)?\\s*,\\s*([0-9]{1,3})(%)?\\s*,\\s*([0-9]{1,3})(%)?\\s*,\\s*(1(\\.0)?|0(\\.[0-9])?)\\s*\\)$/,\n hsl = /^hsl\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})(%)?\\s*,\\s*([0-9]{1,3})(%)?\\s*\\)$/,\n hsla = /^hsla\\(\\s*([0-9]{1,3})\\s*,\\s*([0-9]{1,3})(%)?\\s*,\\s*([0-9]{1,3})(%)?\\s*,\\s*(1(\\.0)?|0(\\.[0-9])?)\\s*\\)$/;\n\n // rgb(123, 123, 132) 0 to 255\n // rgb(123%, 123%, 123%) 0 to 100\n // rgba( 4 vals) last val: 0 to 1.0\n // hsl(0 to 360, %, %)\n // hsla( ..., 0 to 1.0)\n\n if(\n keyword.test(str) ||\n hexa.test(str)\n ){\n return true;\n }\n\n var i;\n\n // rgb range check\n if((match = rgb.exec(str)) !== null || (match = rgba.exec(str)) !== null){\n i = match.length;\n\n while(i--){\n // check percentage values\n if((i===2 || i===4 || i===6) && typeof match[i] !== \"undefined\" && match[i] !== \"\"){\n if(typeof match[i-1] !== \"undefined\" && match[i-1] >= 0 && match[i-1] <= 100){\n valid = true;\n } else {\n return false;\n }\n }\n // check 0 to 255 values\n if(i===1 || i===3 || i===5 && (typeof match[i+1] === \"undefined\" || match[i+1] === \"\")){\n if(typeof match[i] !== \"undefined\" && match[i] >= 0 && match[i] <= 255){\n valid = true;\n } else {\n return false;\n }\n }\n }\n }\n\n // hsl range check\n if((match = hsl.exec(str)) !== null || (match = hsla.exec(str)) !== null){\n i = match.length;\n while(i--){\n // check percentage values\n if(i===3 || i===5){\n if(typeof match[i-1] !== \"undefined\" && typeof match[i] !== \"undefined\" && match[i] !== \"\" &&\n match[i-1] >= 0 && match[i-1] <= 100){\n valid = true;\n } else {\n return false;\n }\n }\n // check 0 to 360 value\n if(i===1){\n if(typeof match[i] !== \"undefined\" && match[i] >= 0 && match[i] <= 360){\n valid = true;\n } else {\n return false;\n }\n }\n }\n }\n\n return valid;\n },\n\n /**\n * Checks if the value is a valid IP. \n *\n * @method isIP\n * @param {String} value Value to be checked\n * @param {String} ipType Type of IP to be validated. The values are: ipv4, ipv6. By default is ipv4.\n * @return {Boolean} True if the value is a valid IP address. False if not.\n * @sample Ink_Util_Validator_isIP.html \n */\n isIP: function( value, ipType ){\n if( typeof value !== 'string' ){\n return false;\n }\n\n ipType = (ipType || 'ipv4').toLowerCase();\n\n switch( ipType ){\n case 'ipv4':\n return (/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/).test(value);\n case 'ipv6':\n return (/^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(%.+)?\\s*$/).test(value);\n default:\n return false;\n }\n },\n\n /**\n * Credit Card specifications, to be used in the credit card verification.\n *\n * @property _creditCardSpecs\n * @type {Object}\n * @private\n */\n _creditCardSpecs: {\n 'default': {\n 'length': '13,14,15,16,17,18,19',\n 'prefix': /^.+/,\n 'luhn': true\n },\n\n 'american express': {\n 'length': '15',\n 'prefix': /^3[47]/,\n 'luhn' : true\n },\n\n 'diners club': {\n 'length': '14,16',\n 'prefix': /^36|55|30[0-5]/,\n 'luhn' : true\n },\n\n 'discover': {\n 'length': '16',\n 'prefix': /^6(?:5|011)/,\n 'luhn' : true\n },\n\n 'jcb': {\n 'length': '15,16',\n 'prefix': /^3|1800|2131/,\n 'luhn' : true\n },\n\n 'maestro': {\n 'length': '16,18',\n 'prefix': /^50(?:20|38)|6(?:304|759)/,\n 'luhn' : true\n },\n\n 'mastercard': {\n 'length': '16',\n 'prefix': /^5[1-5]/,\n 'luhn' : true\n },\n\n 'visa': {\n 'length': '13,16',\n 'prefix': /^4/,\n 'luhn' : true\n }\n },\n\n /**\n * Luhn function, to be used when validating credit cards\n *\n */\n _luhn: function (num){\n\n num = parseInt(num,10);\n\n if ( (typeof num !== 'number') && (num % 1 !== 0) ){\n // Luhn can only be used on nums!\n return false;\n }\n\n num = num+'';\n // Check num length\n var length = num.length;\n\n // Checksum of the card num\n var\n i, checksum = 0\n ;\n\n for (i = length - 1; i >= 0; i -= 2)\n {\n // Add up every 2nd digit, starting from the right\n checksum += parseInt(num.substr(i, 1),10);\n }\n\n for (i = length - 2; i >= 0; i -= 2)\n {\n // Add up every 2nd digit doubled, starting from the right\n var dbl = parseInt(num.substr(i, 1) * 2,10);\n\n // Subtract 9 from the dbl where value is greater than 10\n checksum += (dbl >= 10) ? (dbl - 9) : dbl;\n }\n\n // If the checksum is a multiple of 10, the number is valid\n return (checksum % 10 === 0);\n },\n\n /**\n * Checks if a number is of a specific credit card type\n * @method isCreditCard\n * @param {String} num Number to be validates\n * @param {String|Array} creditCardType Credit card type. See _creditCardSpecs for the list of supported values.\n * @return {Boolean}\n * @sample Ink_Util_Validator_isCreditCard.html \n */\n isCreditCard: function(num, creditCardType){\n\n if ( /\\d+/.test(num) === false ){\n return false;\n }\n\n if ( typeof creditCardType === 'undefined' ){\n creditCardType = 'default';\n }\n else if ( creditCardType instanceof Array ){\n var i, ccLength = creditCardType.length;\n for ( i=0; i < ccLength; i++ ){\n // Test each type for validity\n if (this.isCreditCard(num, creditCardType[i]) ){\n return true;\n }\n }\n\n return false;\n }\n\n // Check card type\n creditCardType = creditCardType.toLowerCase();\n\n if ( typeof this._creditCardSpecs[creditCardType] === 'undefined' ){\n return false;\n }\n\n // Check card number length\n var length = num.length+'';\n\n // Validate the card length by the card type\n if ( this._creditCardSpecs[creditCardType]['length'].split(\",\").indexOf(length) === -1 ){\n return false;\n }\n\n // Check card number prefix\n if ( !this._creditCardSpecs[creditCardType]['prefix'].test(num) ){\n return false;\n }\n\n // No Luhn check required\n if (this._creditCardSpecs[creditCardType]['luhn'] === false){\n return true;\n }\n\n return this._luhn(num);\n }\n };\n\n return Validator;\n\n});\n"]}