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-ui.min.map

1 line
632 KiB
Plaintext

{"version":3,"file":"ink-ui.min.js","sources":["../../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"],"names":["Ink","createModule","Common","InkEvent","Css","Animate","BaseUIComponent","apply","this","arguments","animationPrefix","el","style","document","createElement","animationEndEventName","animation","oAnimation","msAnimation","webkitAnimation","_name","_optionDefinition","trigger","duration","removeClass","onEnd","prototype","_init","isNaN","parseInt","_options","observe","bind","animate","_element","extendObj","_animationPrefix","animationSupported","element","options","onAnimationEnd","event","target","animationName","removeClassName","removeEventListener","elOrSelector","addClassName","addEventListener","setTimeout","createUIComponent","InkElement","Pagination","Browser","limitRange","n","min","max","Math","Carousel","setTransitionProperty","newTransition","transitionProperty","oTransitionProperty","msTransitionProperty","mozTransitionProperty","webkitTransitionProperty","requestAnimationFrame","window","mozRequestAnimationFrame","webkitRequestAnimationFrame","cb","autoAdvance","axis","initialPage","spaceAfterLastSlide","hideLast","center","keyboardSupport","pagination","onChange","onInit","swipe","_handlers","paginationChange","bindMethod","windowResize","throttle","_isY","ulEl","s","_ulEl","removeTextNodeChildren","_currentPage","refit","whiteSpace","_setUpPagination","_setUpAutoAdvance","_setUpHider","call","size","elm","perpendicular","outerDimensions","_liEls","ss","numSlides","length","contRect","getBoundingClientRect","_ctnLength","bottom","top","right","left","_elLength","_slidesPerPage","floor","isFinite","numPages","ceil","numPagesChanged","_numPages","_deltaLength","_center","_updateHider","_IE7","_pagination","setSize","setPage","getPage","isDOMElement","setCurrent","self","nextPage","hiderEl","create","className","insertBottom","position","_hiderEl","gap","pad","padding","join","IE","version","split","slides","stl","prop","val","i","len","_onTouchStart","touches","_swipeData","x","pointerX","y","pointerY","ulRect","firstUlPos","inUlX","inUlY","_touchMoveIsFirstTouchMove","_onTouchMove","deltaY","abs","deltaX","undefined","_scrolling","_onAnimationFrame","stopDefault","pointerPos","swipeData","elRect","newPos","_onTouchEnd","snapToNext","relProgress","curPage","progressInPages","_onPaginationChange","pgn","_setPage","getCurrent","page","wrap","_lengthToGo","isLastPage","_itemsInLastPage","previousPage","getSlidesPerPage","getTotalPages","getStageElm","getSlidesList","getTotalSlides","Close","body","ev","findUpwardsByClass","toRemove","stop","remove","Ajax","Selector","Url","warnStub","constructor","warn","stub","obj","k","hasOwnProperty","Error","_componentOptions","elementIsOptional","error","elsOrSelector","isValidInstance","_validateInstance","e","registerInstance","_stubInstance","nothing","keys","Object","ret","push","es6WeakMapSupport","instances","WeakMap","domRegistry","get","__InkInstances","set","thing","Layouts","TINY","SMALL","MEDIUM","LARGE","XLARGE","isInteger","fieldName","t","select","required","TypeError","fieldId","defaults","overrides","optionValue","key","type","lType","toLowerCase","defaultVal","invalidThrow","_coerce_funcs","fromDataAttrs","dataAttrs","_coerce_from_string","_options_validate","invalid","quote","out","data","invalidStr","str","replace","paramName","_options_validate_types","elements","object","number","parseFloat","boolean","string","function","integer","types","round","clone","o","JSON","parse","stringify","ex","childIndex","childEl","els","parentNode","f","ajaxJSON","endpoint","params","evalJS","method","parameters","onSuccess","r","responseJSON","status","message","onFailure","currentLayout","v","detectorEl","id","setAttribute","appendChild","children","getStyle","getAttribute","hashSet","hashParams","getAnchorString","location","hash","genQueryString","substring","cleanChildren","parentEl","prevEl","lastChild","previousSibling","removeChild","storeIdAndClasses","fromEl","inObj","_id","classes","_classes","restoreIdAndClasses","toEl","indexOf","_instanceId","_warnDoubleInstantiation","newInstance","getName","getInstance","nameWithoutVersion","inst","unregisterInstance","splice","UIComponent","getInstanceFromSelector","selector","getInstanceIds","res","getInstances","destroyComponent","instance","err","_validate","_validationError","name","getOption","setOption","value","getElement","theConstructor","assert","test","msg","assertProp","propType","propVal","_oldProto","hideF","F","Event","InkArray","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","Date","_lang","_render","_listenToContainerObjectEvents","_containerObject","_renderSuperTopBar","calendarTop","_monthDescContainer","_monthPrev","href","setHTML","_monthNext","_monthContainer","_monthSelector","_renderMonthSelector","_yearSelector","_appendDatePickerToDom","_renderMonth","_monthChanger","setTextContent","_ofText","_yearChanger","inline","show","_addOpenCloseEvents","_addDateChangeHandlersToInputs","fields","observeMulti","bindEvent","_updateDate","_showDefaultView","_inline","_hide","opener","cannotBe","descendantOf","ulSelector","mon","_renderMonthButton","liMonth","data-cal-month","appendTarget","parentIsControl","matchesSelector","_wrapper","_wrapperIsControl","insertAfter","_superTopBar","_onClick","elem","hasClassName","_onRelativeChangerClick","_onAbsoluteChangerClick","_showMonthSelector","_showYearSelector","_clean","_updateDescription","changeYear","change_year_next","change_year_prev","changeMonth","change_month_next","change_month_prev","_updateCal","elemData","Number","calDay","calMonth","calYear","_changeYear","selectedIndex","blur","noLimits","_min","noMinLimit","_max","noMaxLimit","MAX_VALUE","dates","rDate","each","noLim","lim","toUpperCase","now","_daysInMonth","valid","_dateCmp","_fitDateToRange","_isValidDate","_dateWithinRange","_dateAboveMax","_dateBelowMin","oth","_dateCmpUntil","depth","props","display","childNodes","_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","d","_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","result","daysInMonth","createDocumentFragment","ul","firstDayIndex","_getDayButton","attrs","dayButton","header","parent","forEach","getElementsByTagName","_addMonthButtonClassNames","btn","toDisable","addRemoveClassName","lang","showMonth","isMonthRendered","destroy","unwrap","between","Draggable","constraint","constraintElm","handle","revert","cursor","zIndex","fps","droppableProxy","mouseAnchor","dragClass","skipChildren","onStart","onDrag","elmStartPosition","active","dragged","prevCoords","placeholder","zindex","firstDrag","deltaMs","lastRunAt","handlers","start","_onStart","dragFacade","_onDragFacade","drag","_onDrag","end","_onEnd","selectStart","stopObserving","_getCoords","ps","scrollWidth","scrollHeight","clientX","clientY","_cloneStyle","src","dst","borderWidth","width","elementWidth","height","elementHeight","elementLeft","elementTop","cssFloat","isLeftClick","button","tgtEl","pos","dims","elementDimensions","originalPosition","delta","div","marginTop","marginBottom","marginLeft","marginRight","visibility","delta2","parts","ad","applyDelta","dragHandlerName","proxy","innerWidth","documentElement","clientWidth","innerHeight","clientHeight","fs","backgroundColor","setOpacity","firstEl","firstChild","nodeType","nextSibling","insertBefore","mouseCoords","mPosX","mPosY","newX","newY","draggableSize","offset","constTop","constBottom","constLeft","constRight","pageWidth","pageHeight","Droppable","getModule","updateAll","mouseCoords2","action","pt","Loaded","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","open","preventDefault","findUpwardsBySelector","currentTarget","isLink","on","direction","one","Toggle","Dropdown","hoverOpen","dismissOnInsideClick","dismissOnOutsideClick","dismissAfter","onInsideClick","onOutsideClick","onOpen","onDismiss","_toggle","closeOnInsideClick","closeOnClick","onChangeState","newState","_openOrDismiss","_onMouseOver","getState","clearTimeout","_openTimeout","_dismissTimeout","_onMouseOut","_onInsideClick","_handlerCall","dismiss","_onOutsideClick","foundElem","findUpwardsHaving","needle","foundTarget","callHandler","doNotInformToggle","_doNotInformToggle","setState","handler","slice","hAddClassName","hRemoveClassName","debug","_droppables","_draggables","add","cleanStyle","draggable","opt","hoverClass","hoverclass","accept","onHover","onDrop","onDropOut","that","namedEventHandlers","move","droppable","copy","cloneNode","_findDraggable","originalParent","elementData","_update","_findData","elms","update","offsetLeft","offsetTop","coords","matches","InkValidator","elementsWithSameName","form","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","getElementById","random","custom","fail","_validateElements","_showError","_clearError","_clearCache","reset","_getElements","formElms","curElm","totalElm","flag","flag2","oGroups","_makeConfirmGroups","errors","customErrors","inArray","disabled","_isValid","_isCustomValid","_validateConfirmGroups","curGroup","total","j","totalG","curFlag","tCustom","callback","fieldType","nodeName","inputType","_trim","aFormRadios","isChecked","totalRadio","checked","mail","url","isPTPhone","isCVPhone","isAOPhone","isMZPhone","dataset","validFormat","validValues","isDate","formElm","aFail","tFail","_showAnErrorOnElement","controlGroupElm","controlElm","errorClasses","_errorTypeClassName","errorMsg","innerHTML","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","text","whitespace","punctuation","unicode","unicodePunctuation","latin","latin1","latin1Punctuation","alpha_numeric","numbers","alpha_dash","dash","underscore","digit","positive","negative","decimalPlaces","decimal","decimalSeparator","leftDigits","decimalSep","maxDigits","numeric","range","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","rules","_errors","_rules","_value","_getLabel","textContent","_parseRules","rulesLength","rule","paramStartPos","substr","p","_addError","paramObj","field","i18nKey","getErrors","_formElements","eventTrigger","neverSubmit","searchFor","beforeValidation","setRule","errorMessage","getKey","langObj","dictObj","append","getI18n","setI18n","i18n","appendI18n","setLanguage","language","getRules","_rootElement","_errorMessages","_markedErrorElements","getElements","formElements","errorElement","errorElements","counter","cancelEventOnSuccess","formElement","controlGroupElement","controlElement","paragraph","errorArr","ImageQuery","retina","queries","onLoad","lastIndexOf","search","_filename","pop","sortMulti","reverse","_onLoad","_onResize","current","_findCurrentQuery","devicePixelRatio","file","_","viewportWidth","last","query","LazyLoad","item","source","destination","delay","image","scrollElement","touchEvents","onInsideViewport","onAfterAttributeChange","autoInit","_rootElm","_aData","_hasEvents","_activate","_getData","_onScrollThrottled","aElms","attr","hasAttribute","original","_onScroll","_removeEvents","inViewport","partial","margin","_elInViewport","_userCallback","removeAttribute","reload","upName","dimension","firstCharacter","match","maxName","Modal","opacitySupported","opacity","openModals","shadeClass","modalClass","triggerEvent","autoDisplay","markup","onShow","closeOnEscape","responsive","_onShadeClick","keyDown","_onKeyDown","resize","_wasDismissed","_markupMode","_modalDiv","_modalDivStyle","_modalShadow","_modalShadowStyle","_contentContainer","setContentMarkup","triggerElements","toString","_reposition","runNow","_timeoutResizeFunction","_resizeTimeout","isPercentage","currentViewport","viewportHeight","originalStatus","_resizeContainer","_shadeElement","alertsInTheModal","alertsLength","keyCode","containerHeight","_modalHeader","_modalFooter","compatMode","_contentElement","_waitForFade","keyValue","htmlEl","transitionEndEventNames","classicName","evName","observeOnce","fadeChecker","getContentElement","contentMarkup","tempHeader","tempFooter","toAdd","concat","genAEl","inner","index","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","observeDelegated","count","liEls","isSimpleToggle","liEl","setClassName","_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","scroll","a","endPos","interval","onDone","scrollTo","init","onClick","render","link","thisDocument","linkedDocument","activeLiSelector","activeLi","Events","SortableList","hasTouch","navigator","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","findUpwardsByTag","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","where","_inlineDimensions","_getBottomOffset","bottomOfViewport","toBottomOfDocument","oldPosition","oldWidth","dimensionsInStatic","rect","Swipe","onMove","minDist","maxDist","minDuration","maxDuration","storeGesture","stopEvents","_supported","db","_isOn","_isMeOrParent","_pushGesture","_gesture","_time","changedTouches","_target","_t0","_p0","pageX","pageY","t1","gesture","p1","dr","dist","sqrt","time","overallMovement","overallTime","InkUrl","InkString","Json","maybeTurnIntoNumber","rNumber","cmp","b","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","tbody","_paginate","sortAndReverse","isAscending","_sort","caretHtml","order","firstIndex","lastIndex","_registerFieldNames","names","_fieldIsVisible","userKey","keyFunction","columnIndex","columnName","sort","trA","trB","elementA","elementB","_createHeadersFromJson","headers","tr","insertRow","th","_createSingleHeaderFromJson","_createRowsFromJSON","rows","row","trIndex","_createSingleRowFromJson","rowIndex","_createFieldFromJson","fieldData","processor","_elOrFieldData","processed","isString","isNumber","setEndpoint","currentPage","paginationEl","pageNo","sortOrder","_getSortOrder","_getDataViaAjax","_getUrl","urlCreator","parseUrl","sortField","endpointUri","success","JSONData","_onAjaxSuccess","getDataFromEndpoint","contentType","sanitizeJSON","response","responseText","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","isAncestorOf","links","disable","enable","activeTab","activeMenuTab","activeSection","activeContentTab","TagField","enterKey","backspaceKey","isTruthy","tags","tagQuery","tagQueryAsync","allowRepeated","maxTags","outSeparator","separator","autoSplit","RegExp","_readInput","_viewElm","_input","_tagsFromMarkup","_tags","_onKeyUp","_onBlur","_refocus","tagname","tagName","map","option","_tagsToMarkup","tag","selected","_addTag","_removeTag","spc","createTextNode","filter","which","_onEnterKeyDown","_onBackspaceKeyDown","_removeConfirm","_unsetRemovingVisual","_setRemovingVisual","tagIndex","_removeRemovingVisualTimeout","parentIndexOf","focus","isAccordion","initialState","classNameOn","classNameOff","_targets","_accordion","_firstTime","_bindEvents","state","_onTriggerEvent","sel","isAncestorOfClickedElement","some","thisOne","_updateAccordion","has","accordionElement","targetElm","shades","ancestorOfTargets","shadesLength","Tooltip","EachTooltip","root","transitionDurationName","transitionPropertyName","transitionTimingFunctionName","bodies","spacing","forever","timeout","template","templatefield","fade","tooltips","tooltip","_destroy","_oppositeDirections","_onMouseMove","_delayTimeout","_makeTooltip","mousePosition","_getOpt","_createTooltipElement","_removeTooltip","_fadeInTooltipElement","_placeTooltipElement","_onTooltipMouseOver","_getFloatOpt","temp","outerHTML","_getIntOpt","fadeTime","mPos","_setPos","targetElementPos","tleft","ttop","centerh","centerv","tooltipDims","elementDims","maxX","maxY","_getWhereValueInsideViewport","arrow","tooltipLeft","tooltipTop","toBottom","toRight","toLeft","toTop","bbox","viewport","dataAttrVal","_camelCase","instanceOption","_getMousePosition","pageDims","_getPageXY","elmDims","scrollDim","_getScroll","cWidth","cHeight","dd","scrollLeft","scrollTop","TreeView","node","child","parentClass","openNodeClass","openClass","closedClass","iconTag","isParent","isOpen","_getIcon","insertTop","_setNodeOpen","_getChild","beOpen","icon","toggle","DirectoryReader","entry","maxDepth","_read","_readDirectories","entries","running","_readEntries","currentEntry","dir","createReader","readEntries","isDirectory","clearArray","fullPath","shift","_stopActivityTimeout","readError","activity","checkActivity","clearInterval","readComplete","setInterval","arr","Queue","lists","items","String","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","stopPropagation","returnValue","publish","btns","_fileChangeHandler","files","FormData","XMLHttpRequest","_addFilesToQueue","submit","_events","fileFormName","maxFilesize","INVALID_FILE_NAME","extraData","useChunks","chunkSize","minSizeToUseChunks","endpointChunk","endpointChunkCommit","foldersEnabled","directoryMaxDepth","_queueId","_queueRunning","_folders","_supportChunks","Blob","dataTransfer","_files","Array","webkitGetAsEntry","folders","_addFolderToQueue","invalidFolders","getFiles","isFile","convertToFile","hasParent","getSubDirs","created","fileID","CHROME","directory","_processQueue","internalUpload","queueLen","canceled","_doRequest","_upload","xhr","forceAbort","showError","lengthComputable","loaded","abort","lastModifiedDate","Dom","OPERA","upload","onprogress","chunk_offset","chunk_upload_id","withCredentials","setRequestHeader","fd","blob","upload_path","parentID","rootPath","send","onload","invalidOffset","upload_id","chunk_expires","expires","onerror","onabort","abortAll","abortOne","subscribe","eventName","fn","events","args"],"mappings":"AAUAA,IAAIC,aAAa,iBAAkB,GAAI,kBAAmB,kBAAmB,iBAAkB,SAAUC,EAAQC,EAAUC,GACvH,YA8BA,SAASC,KACLH,EAAOI,gBAAgBC,MAAMC,KAAMC,WA7BvC,GAAIC,GAAmB,SAAUC,GAC7B,MAAQ,iBAAmBA,GAAGC,MAAS,YAC/B,kBAAoBD,GAAGC,MA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D,KACtBzoD,GACCA,EAAGsN,IAEA,CAGf,QAAO,GAIX0hD,UAAW,SAASC,EAAWC,GAK3B,MAJIjzD,MAAK0uD,QAAQsE,KACbhzD,KAAK0uD,QAAQsE,OAEjBhzD,KAAK0uD,QAAQsE,GAAWnlD,KAAKolD,GACtBjzD,KAAK0uD,QAAQsE,IAIxB9E,QAAS,SAAS8E,GACd,GAAIE,GAASlzD,KAAK0uD,QAAQsE,GACtBG,EAAOtD,MAAM3uD,UAAU0wB,MAAMjsB,KAAK1F,cAAiB,EAEvD,IAAIizD,EAIJ,IAAI,GAAIlqD,GAAI,EAAGC,EAAMiqD,EAAO/sD,OAAU8C,EAAFD,EAAOA,IACvC,IACIkqD,EAAOlqD,GAAGjJ,MAAMC,KAAMmzD,EAAKj+C,OAAO,EAAGi+C,EAAKhtD,SAC5C,MAAMwP,GACJnW,IAAI0N,MAAM8lD,EAAY,KAAOr9C,MAMtCk3C","sourcesContent":["/**\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"]}