2012-02-14 06:14:13 +00:00
/ *
* lib / js / lib / jquery . min . js
* //*!
* jQuery JavaScript Library v1 . 6.2
* http : //jquery.com/
*
* Copyright 2011 , John Resig
* Dual licensed under the MIT or GPL Version 2 licenses .
* http : //jquery.org/license
*
* Includes Sizzle . js
* http : //sizzlejs.com/
* Copyright 2011 , The Dojo Foundation
* Released under the MIT , BSD , and GPL Licenses .
*
* Date : Thu Jun 30 14 : 16 : 56 2011 - 0400
* /
( function ( a , b ) { function cv ( a ) { return f . isWindow ( a ) ? a : a . nodeType === 9 ? a . defaultView || a . parentWindow : ! 1 } function cs ( a ) { if ( ! cg [ a ] ) { var b = c . body , d = f ( "<" + a + ">" ) . appendTo ( b ) , e = d . css ( "display" ) ; d . remove ( ) ; if ( e === "none" || e === "" ) { ch || ( ch = c . createElement ( "iframe" ) , ch . frameBorder = ch . width = ch . height = 0 ) , b . appendChild ( ch ) ; if ( ! ci || ! ch . createElement ) ci = ( ch . contentWindow || ch . contentDocument ) . document , ci . write ( ( c . compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" ) , ci . close ( ) ; d = ci . createElement ( a ) , ci . body . appendChild ( d ) , e = f . css ( d , "display" ) , b . removeChild ( ch ) } cg [ a ] = e } return cg [ a ] } function cr ( a , b ) { var c = { } ; f . each ( cm . concat . apply ( [ ] , cm . slice ( 0 , b ) ) , function ( ) { c [ this ] = a } ) ; return c } function cq ( ) { cn = b } function cp ( ) { setTimeout ( cq , 0 ) ; return cn = f . now ( ) } function cf ( ) { try { return new a . ActiveXObject ( "Microsoft.XMLHTTP" ) } catch ( b ) { } } function ce ( ) { try { return new a . XMLHttpRequest } catch ( b ) { } } function b$ ( a , c ) { a . dataFilter && ( c = a . dataFilter ( c , a . dataType ) ) ; var d = a . dataTypes , e = { } , g , h , i = d . length , j , k = d [ 0 ] , l , m , n , o , p ; for ( g = 1 ; g < i ; g ++ ) { if ( g === 1 ) for ( h in a . converters ) typeof h == "string" && ( e [ h . toLowerCase ( ) ] = a . converters [ h ] ) ; l = k , k = d [ g ] ; if ( k === "*" ) k = l ; else if ( l !== "*" && l !== k ) { m = l + " " + k , n = e [ m ] || e [ "* " + k ] ; if ( ! n ) { p = b ; for ( o in e ) { j = o . split ( " " ) ; if ( j [ 0 ] === l || j [ 0 ] === "*" ) { p = e [ j [ 1 ] + " " + k ] ; if ( p ) { o = e [ o ] , o === ! 0 ? n = p : p === ! 0 && ( n = o ) ; break } } } } ! n && ! p && f . error ( "No conversion from " + m . replace ( " " , " to " ) ) , n !== ! 0 && ( c = n ? n ( c ) : p ( o ( c ) ) ) } } return c } function bZ ( a , c , d ) { var e = a . contents , f = a . dataTypes , g = a . responseFields , h , i , j , k ; for ( i in g ) i in d && ( c [ g [ i ] ] = d [ i ] ) ; while ( f [ 0 ] === "*" ) f . shift ( ) , h === b && ( h = a . mimeType || c . getResponseHeader ( "content-type" ) ) ; if ( h ) for ( i in e ) if ( e [ i ] && e [ i ] . test ( h ) ) { f . unshift ( i ) ; break } if ( f [ 0 ] in d ) j = f [ 0 ] ; else { for ( i in d ) { if ( ! f [ 0 ] || a . converters [ i + " " + f [ 0 ] ] ) { j = i ; break } k || ( k = i ) } j = j || k } if ( j ) { j !== f [ 0 ] && f . unshift ( j ) ; return d [ j ] } } function bY ( a , b , c , d ) { if ( f . isArray ( b ) ) f . each ( b , function ( b , e ) { c || bC . test ( a ) ? d ( a , e ) : bY ( a + "[" + ( typeof e == "object" || f . isArray ( e ) ? b : "" ) + "]" , e , c , d ) } ) ; else if ( ! c && b != null && typeof b == "object" ) for ( var e in b ) bY ( a + "[" + e + "]" , b [ e ] , c , d ) ; else d ( a , b ) } function bX ( a , c , d , e , f , g ) { f = f || c . dataTypes [ 0 ] , g = g || { } , g [ f ] = ! 0 ; var h = a [ f ] , i = 0 , j = h ? h . length : 0 , k = a === bR , l ; for ( ; i < j && ( k || ! l ) ; i ++ ) l = h [ i ] ( c , d , e ) , typeof l == "string" && ( ! k || g [ l ] ? l = b : ( c . dataTypes . unshift ( l ) , l = bX ( a , c , d , e , l , g ) ) ) ; ( k || ! l ) && ! g [ "*" ] && ( l = bX ( a , c , d , e , "*" , g ) ) ; return l } function bW ( a ) { return function ( b , c ) { typeof b != "string" && ( c = b , b = "*" ) ; if ( f . isFunction ( c ) ) { var d = b . toLowerCase ( ) . split ( bN ) , e = 0 , g = d . length , h , i , j ; for ( ; e < g ; e ++ ) h = d [ e ] , j = /^\+/ . test ( h ) , j && ( h = h . substr ( 1 ) || "*" ) , i = a [ h ] = a [ h ] || [ ] , i [ j ? "unshift" : "push" ] ( c ) } } } function bA ( a , b , c ) { var d = b === "width" ? a . offsetWidth : a . offsetHeight , e = b === "width" ? bv : bw ; if ( d > 0 ) { c !== "border" && f . each ( e , function ( ) { c || ( d -= parseFloat ( f . css ( a , "padding" + this ) ) || 0 ) , c === "margin" ? d += parseFloat ( f . css ( a , c + this ) ) || 0 : d -= parseFloat ( f . css ( a , "border" + this + "Width" ) ) || 0 } ) ; return d + "px" } d = bx ( a , b , b ) ; if ( d < 0 || d == null ) d = a . style [ b ] || 0 ; d = parseFloat ( d ) || 0 , c && f . each ( e , function ( ) { d += parseFloat ( f . css ( a , "padding" + this ) ) || 0 , c !== "padding" && ( d += parseFloat ( f . css ( a , "border" + this + "Width" ) ) || 0 ) , c === "margin" && ( d += parseFloat ( f . css ( a , c + this ) ) || 0 ) } ) ; return d + "px" } function bm ( a , b ) { b . src ? f . ajax ( { url : b . src , async : ! 1 , dataType : "script" } ) : f . globalEval ( ( b . text || b . textContent || b . innerHTML || "" ) . replace ( be , "/*$0*/" ) ) , b . parentNode && b . parentNode . removeChild ( b ) } function bl ( a ) { f . nodeName ( a , "input" ) ? bk ( a ) : "getElementsByTagName" in a && f . grep ( a . getElementsByTagName ( "input" ) , bk ) } function bk ( a ) { if ( a . type === "checkbox" || a . type === "radio" ) a . defaultChecked = a . checked } function bj ( a ) { return "getElementsByTagName" in a ? a . getElementsByTagName ( "*" ) : "querySelectorAll" in a ? a . querySelectorAll ( "*" ) : [ ] } function bi ( a , b ) { var c ; if ( b . nodeType === 1 ) { b . clearAttributes && b . clearAttributes ( ) , b . mergeAttributes && b . mergeAttributes ( a ) , c = b . nodeName . toLowerCase ( ) ; if ( c === "object" ) b . outerHTML = a . outerHTML ; else if ( c !== "input" || a . type !== "checkbox" && a . type !== "radio" ) { if ( c === "option" ) b . selected = a . defaultSelected ; else if ( c === "input" || c === "textarea" ) b . defaultValue = a . defaultValue } else a . checked && ( b . defaultChecked = b . checked = a . checked ) , b . value !== a . value && ( b . value = a . value ) ; b . removeAttribute ( f . expando ) } } function bh (
shift ( ) , i . sort ( ) ) ; if ( ! ! e && ! f . event . customEvent [ h ] || ! ! f . event . global [ h ] ) { c = typeof c == "object" ? c [ f . expando ] ? c : new f . Event ( h , c ) : new f . Event ( h ) , c . type = h , c . exclusive = j , c . namespace = i . join ( "." ) , c . namespace _re = new RegExp ( "(^|\\.)" + i . join ( "\\.(?:.*\\.)?" ) + "(\\.|$)" ) ; if ( g || ! e ) c . preventDefault ( ) , c . stopPropagation ( ) ; if ( ! e ) { f . each ( f . cache , function ( ) { var a = f . expando , b = this [ a ] ; b && b . events && b . events [ h ] && f . event . trigger ( c , d , b . handle . elem ) } ) ; return } if ( e . nodeType === 3 || e . nodeType === 8 ) return ; c . result = b , c . target = e , d = d != null ? f . makeArray ( d ) : [ ] , d . unshift ( c ) ; var k = e , l = h . indexOf ( ":" ) < 0 ? "on" + h : "" ; do { var m = f . _data ( k , "handle" ) ; c . currentTarget = k , m && m . apply ( k , d ) , l && f . acceptData ( k ) && k [ l ] && k [ l ] . apply ( k , d ) === ! 1 && ( c . result = ! 1 , c . preventDefault ( ) ) , k = k . parentNode || k . ownerDocument || k === c . target . ownerDocument && a } while ( k && ! c . isPropagationStopped ( ) ) ; if ( ! c . isDefaultPrevented ( ) ) { var n , o = f . event . special [ h ] || { } ; if ( ( ! o . _default || o . _default . call ( e . ownerDocument , c ) === ! 1 ) && ( h !== "click" || ! f . nodeName ( e , "a" ) ) && f . acceptData ( e ) ) { try { l && e [ h ] && ( n = e [ l ] , n && ( e [ l ] = null ) , f . event . triggered = h , e [ h ] ( ) ) } catch ( p ) { } n && ( e [ l ] = n ) , f . event . triggered = b } } return c . result } } , handle : function ( c ) { c = f . event . fix ( c || a . event ) ; var d = ( ( f . _data ( this , "events" ) || { } ) [ c . type ] || [ ] ) . slice ( 0 ) , e = ! c . exclusive && ! c . namespace , g = Array . prototype . slice . call ( arguments , 0 ) ; g [ 0 ] = c , c . currentTarget = this ; for ( var h = 0 , i = d . length ; h < i ; h ++ ) { var j = d [ h ] ; if ( e || c . namespace _re . test ( j . namespace ) ) { c . handler = j . handler , c . data = j . data , c . handleObj = j ; var k = j . handler . apply ( this , g ) ; k !== b && ( c . result = k , k === ! 1 && ( c . preventDefault ( ) , c . stopPropagation ( ) ) ) ; if ( c . isImmediatePropagationStopped ( ) ) break } } return c . result } , props : "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which" . split ( " " ) , fix : function ( a ) { if ( a [ f . expando ] ) return a ; var d = a ; a = f . Event ( d ) ; for ( var e = this . props . length , g ; e ; ) g = this . props [ -- e ] , a [ g ] = d [ g ] ; a . target || ( a . target = a . srcElement || c ) , a . target . nodeType === 3 && ( a . target = a . target . parentNode ) , ! a . relatedTarget && a . fromElement && ( a . relatedTarget = a . fromElement === a . target ? a . toElement : a . fromElement ) ; if ( a . pageX == null && a . clientX != null ) { var h = a . target . ownerDocument || c , i = h . documentElement , j = h . body ; a . pageX = a . clientX + ( i && i . scrollLeft || j && j . scrollLeft || 0 ) - ( i && i . clientLeft || j && j . clientLeft || 0 ) , a . pageY = a . clientY + ( i && i . scrollTop || j && j . scrollTop || 0 ) - ( i && i . clientTop || j && j . clientTop || 0 ) } a . which == null && ( a . charCode != null || a . keyCode != null ) && ( a . which = a . charCode != null ? a . charCode : a . keyCode ) , ! a . metaKey && a . ctrlKey && ( a . metaKey = a . ctrlKey ) , ! a . which && a . button !== b && ( a . which = a . button & 1 ? 1 : a . button & 2 ? 3 : a . button & 4 ? 2 : 0 ) ; return a } , guid : 1e8 , proxy : f . proxy , special : { ready : { setup : f . bindReady , teardown : f . noop } , live : { add : function ( a ) { f . event . add ( this , N ( a . origType , a . selector ) , f . extend ( { } , a , { handler : M , guid : a . handler . guid } ) ) } , remove : function ( a ) { f . event . remove ( this , N ( a . origType , a . selector ) , a ) } } , beforeunload : { setup : function ( a , b , c ) { f . isWindow ( this ) && ( this . onbeforeunload = c ) } , teardown : function ( a , b ) { this . onbeforeunload === b && ( this . onbeforeunload = null ) } } } } , f . removeEvent = c . removeEventListener ? function ( a , b , c ) { a . removeEventListener && a . removeEventListener ( b , c , ! 1 ) } : function ( a , b , c ) { a . detachEvent && a . detachEvent ( "on" + b , c ) } , f . Event = function ( a , b ) { if ( ! this . preventDefault ) return new f . Event ( a , b ) ; a && a . type ? ( this . originalEvent = a , this . type = a . type , this . isDefaultPrevented = a . defaultPrevented || a . returnValue === ! 1 || a . getPreventDefault && a . getPreventDefault ( ) ? E : D ) : this . type = a , b && f . extend ( this , b ) , this . timeStamp = f . now ( ) , this [ f . expando ] = ! 0 } , f . Event . prototype = { preventDefault : function ( ) { this . isDefaultPrevented = E ; var a = this . originalEvent ; ! a || ( a . preventDefault ? a . preventDefault ( ) : a . returnValue = ! 1 ) } , stopPropagation : function ( ) { this . isPropagationStopped = E ; var a = this . originalEvent ; ! a || ( a . stopPropagation && a . stopPropagation ( ) , a . cancelBubble = ! 0 ) } , stopImmediatePropagation : function ( ) { this . isImmediatePropagationStopped = E , this . stopPropagation ( ) } , isDefaultPrevented : D , isPropagationStopped : D
) } return this . pushStack ( d , a , e . selector ) } } ) , f . extend ( { clone : function ( a , b , c ) { var d = a . cloneNode ( ! 0 ) , e , g , h ; if ( ( ! f . support . noCloneEvent || ! f . support . noCloneChecked ) && ( a . nodeType === 1 || a . nodeType === 11 ) && ! f . isXMLDoc ( a ) ) { bi ( a , d ) , e = bj ( a ) , g = bj ( d ) ; for ( h = 0 ; e [ h ] ; ++ h ) bi ( e [ h ] , g [ h ] ) } if ( b ) { bh ( a , d ) ; if ( c ) { e = bj ( a ) , g = bj ( d ) ; for ( h = 0 ; e [ h ] ; ++ h ) bh ( e [ h ] , g [ h ] ) } } e = g = null ; return d } , clean : function ( a , b , d , e ) { var g ; b = b || c , typeof b . createElement == "undefined" && ( b = b . ownerDocument || b [ 0 ] && b [ 0 ] . ownerDocument || c ) ; var h = [ ] , i ; for ( var j = 0 , k ; ( k = a [ j ] ) != null ; j ++ ) { typeof k == "number" && ( k += "" ) ; if ( ! k ) continue ; if ( typeof k == "string" ) if ( ! ba . test ( k ) ) k = b . createTextNode ( k ) ; else { k = k . replace ( Z , "<$1></$2>" ) ; var l = ( $ . exec ( k ) || [ "" , "" ] ) [ 1 ] . toLowerCase ( ) , m = bf [ l ] || bf . _default , n = m [ 0 ] , o = b . createElement ( "div" ) ; o . innerHTML = m [ 1 ] + k + m [ 2 ] ; while ( n -- ) o = o . lastChild ; if ( ! f . support . tbody ) { var p = _ . test ( k ) , q = l === "table" && ! p ? o . firstChild && o . firstChild . childNodes : m [ 1 ] === "<table>" && ! p ? o . childNodes : [ ] ; for ( i = q . length - 1 ; i >= 0 ; -- i ) f . nodeName ( q [ i ] , "tbody" ) && ! q [ i ] . childNodes . length && q [ i ] . parentNode . removeChild ( q [ i ] ) } ! f . support . leadingWhitespace && Y . test ( k ) && o . insertBefore ( b . createTextNode ( Y . exec ( k ) [ 0 ] ) , o . firstChild ) , k = o . childNodes } var r ; if ( ! f . support . appendChecked ) if ( k [ 0 ] && typeof ( r = k . length ) == "number" ) for ( i = 0 ; i < r ; i ++ ) bl ( k [ i ] ) ; else bl ( k ) ; k . nodeType ? h . push ( k ) : h = f . merge ( h , k ) } if ( d ) { g = function ( a ) { return ! a . type || bd . test ( a . type ) } ; for ( j = 0 ; h [ j ] ; j ++ ) if ( e && f . nodeName ( h [ j ] , "script" ) && ( ! h [ j ] . type || h [ j ] . type . toLowerCase ( ) === "text/javascript" ) ) e . push ( h [ j ] . parentNode ? h [ j ] . parentNode . removeChild ( h [ j ] ) : h [ j ] ) ; else { if ( h [ j ] . nodeType === 1 ) { var s = f . grep ( h [ j ] . getElementsByTagName ( "script" ) , g ) ; h . splice . apply ( h , [ j + 1 , 0 ] . concat ( s ) ) } d . appendChild ( h [ j ] ) } } return h } , cleanData : function ( a ) { var b , c , d = f . cache , e = f . expando , g = f . event . special , h = f . support . deleteExpando ; for ( var i = 0 , j ; ( j = a [ i ] ) != null ; i ++ ) { if ( j . nodeName && f . noData [ j . nodeName . toLowerCase ( ) ] ) continue ; c = j [ f . expando ] ; if ( c ) { b = d [ c ] && d [ c ] [ e ] ; if ( b && b . events ) { for ( var k in b . events ) g [ k ] ? f . event . remove ( j , k ) : f . removeEvent ( j , k , b . handle ) ; b . handle && ( b . handle . elem = null ) } h ? delete j [ f . expando ] : j . removeAttribute && j . removeAttribute ( f . expando ) , delete d [ c ] } } } } ) ; var bn = /alpha\([^)]*\)/i , bo = /opacity=([^)]*)/ , bp = /([A-Z]|^ms)/g , bq = /^-?\d+(?:px)?$/i , br = /^-?\d/ , bs = /^[+\-]=/ , bt = /[^+\-\.\de]+/g , bu = { position : "absolute" , visibility : "hidden" , display : "block" } , bv = [ "Left" , "Right" ] , bw = [ "Top" , "Bottom" ] , bx , by , bz ; f . fn . css = function ( a , c ) { if ( arguments . length === 2 && c === b ) return this ; return f . access ( this , a , c , ! 0 , function ( a , c , d ) { return d !== b ? f . style ( a , c , d ) : f . css ( a , c ) } ) } , f . extend ( { cssHooks : { opacity : { get : function ( a , b ) { if ( b ) { var c = bx ( a , "opacity" , "opacity" ) ; return c === "" ? "1" : c } return a . style . opacity } } } , cssNumber : { fillOpacity : ! 0 , fontWeight : ! 0 , lineHeight : ! 0 , opacity : ! 0 , orphans : ! 0 , widows : ! 0 , zIndex : ! 0 , zoom : ! 0 } , cssProps : { "float" : f . support . cssFloat ? "cssFloat" : "styleFloat" } , style : function ( a , c , d , e ) { if ( ! ! a && a . nodeType !== 3 && a . nodeType !== 8 && ! ! a . style ) { var g , h , i = f . camelCase ( c ) , j = a . style , k = f . cssHooks [ i ] ; c = f . cssProps [ i ] || i ; if ( d === b ) { if ( k && "get" in k && ( g = k . get ( a , ! 1 , e ) ) !== b ) return g ; return j [ c ] } h = typeof d ; if ( h === "number" && isNaN ( d ) || d == null ) return ; h === "string" && bs . test ( d ) && ( d = + d . replace ( bt , "" ) + parseFloat ( f . css ( a , c ) ) , h = "number" ) , h === "number" && ! f . cssNumber [ i ] && ( d += "px" ) ; if ( ! k || ! ( "set" in k ) || ( d = k . set ( a , d ) ) !== b ) try { j [ c ] = d } catch ( l ) { } } } , css : function ( a , c , d ) { var e , g ; c = f . camelCase ( c ) , g = f . cssHooks [ c ] , c = f . cssProps [ c ] || c , c === "cssFloat" && ( c = "float" ) ; if ( g && "get" in g && ( e = g . get ( a , ! 0 , d ) ) !== b ) return e ; if ( bx ) return bx ( a , c ) } , swap : function ( a , b , c ) { var d = { } ; for ( var e in b ) d [ e ] = a . style [ e ] , a . style [ e ] = b [ e ] ; c . call ( a ) ; for ( e in b ) a . style [ e ] = d [ e ] } } ) , f . curCSS = f . css , f . each ( [ "height" , "width" ] , function ( a , b ) { f . cssHooks [ b ] = { get : function ( a , c , d ) { var e ; if ( c ) { if ( a . offsetWidth !== 0 ) return bA ( a , b , d ) ; f . swap ( a , bu , function ( ) { e = bA ( a , b , d ) } ) ; return e } } , set : function ( a , b ) { if ( ! bq . test ( b ) ) return b ; b = parseFloat ( b ) ; if ( b >= 0 ) return b + "px" } } } ) , f . support . opacity || ( f . cssHooks . opacity = { get : function ( a , b ) { return bo . test ( ( b && a . currentStyle ? a . currentStyle . filter : a . style . filter ) || "" ) ? parseFloat ( RegExp . $1 ) / 100 + "" : b ? "1" : "" } , set : function ( a , b ) { var c = a . style , d = a . currentStyle ; c . zoom = 1 ; var e = f . isNaN ( b ) ? "" : "alpha(opacity=" + b * 100 + ")" ,
/ *
* lib / js / lib / history / history . min . js
* //*
* jQuery hashchange event - v1 . 3 - 7 / 21 / 2010
* http : //benalman.com/projects/jquery-hashchange-plugin/
*
* Copyright ( c ) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses .
* http : //benalman.com/about/license/
* /
( function ( $ , e , b ) { var c = "hashchange" , h = document , f , g = $ . event . special , i = h . documentMode , d = "on" + c in e && ( i === b || i > 7 ) ; function a ( j ) { j = j || location . href ; return "#" + j . replace ( /^[^#]*#?(.*)$/ , "$1" ) } $ . fn [ c ] = function ( j ) { return j ? this . bind ( c , j ) : this . trigger ( c ) } ; $ . fn [ c ] . delay = 50 ; g [ c ] = $ . extend ( g [ c ] , { setup : function ( ) { if ( d ) { return false } $ ( f . start ) } , teardown : function ( ) { if ( d ) { return false } $ ( f . stop ) } } ) ; f = ( function ( ) { var j = { } , p , m = a ( ) , k = function ( q ) { return q } , l = k , o = k ; j . start = function ( ) { p || n ( ) } ; j . stop = function ( ) { p && clearTimeout ( p ) ; p = b } ; function n ( ) { var r = a ( ) , q = o ( m ) ; if ( r !== m ) { l ( m = r , q ) ; $ ( e ) . trigger ( c ) } else { if ( q !== m ) { location . href = location . href . replace ( /#.*/ , "" ) + q } } p = setTimeout ( n , $ . fn [ c ] . delay ) } $ . browser . msie && ! d && ( function ( ) { var q , r ; j . start = function ( ) { if ( ! q ) { r = $ . fn [ c ] . src ; r = r && r + a ( ) ; q = $ ( '<iframe tabindex="-1" title="empty"/>' ) . hide ( ) . one ( "load" , function ( ) { r || l ( a ( ) ) ; n ( ) } ) . attr ( "src" , r || "javascript:0" ) . insertAfter ( "body" ) [ 0 ] . contentWindow ; h . onpropertychange = function ( ) { try { if ( event . propertyName === "title" ) { q . document . title = h . title } } catch ( s ) { } } } } ; j . stop = k ; o = function ( ) { return a ( q . location . href ) } ; l = function ( v , s ) { var u = q . document , t = $ . fn [ c ] . domain ; if ( v !== s ) { u . title = h . title ; u . open ( ) ; t && u . write ( '<script>document.domain="' + t + '"<\/script>' ) ; u . close ( ) ; q . location . hash = v } } } ) ( ) ; return j } ) ( ) } ) ( jQuery , this ) ;
// manage history
// load pages via ajax
// setup the history adapter
// if settings no_history is set, no history will be bound
// this can be used to make it work with legacy
$ ( document ) . bind ( 'ready' , function ( ) {
// standard page openener
$ ( window ) . bind ( 'hashchange' , function ( ) {
if ( wn . settings . no _history )
return ;
// load the state on the browser
wn . page . set ( location . hash ) ;
} ) ;
} )
2012-02-14 06:33:02 +00:00
/ *
* lib / js / legacy / jquery / jquery - ui . min . js
* //*
* jQuery UI 1.7 . 3
*
* Copyright ( c ) 2009 AUTHORS . txt ( http : //jqueryui.com/about)
* Dual licensed under the MIT ( MIT - LICENSE . txt )
* and GPL ( GPL - LICENSE . txt ) licenses .
*
* http : //docs.jquery.com/UI
* /
jQuery . ui || ( function ( c ) { var i = c . fn . remove , d = c . browser . mozilla && ( parseFloat ( c . browser . version ) < 1.9 ) ; c . ui = { version : "1.7.3" , plugin : { add : function ( k , l , n ) { var m = c . ui [ k ] . prototype ; for ( var j in n ) { m . plugins [ j ] = m . plugins [ j ] || [ ] ; m . plugins [ j ] . push ( [ l , n [ j ] ] ) } } , call : function ( j , l , k ) { var n = j . plugins [ l ] ; if ( ! n || ! j . element [ 0 ] . parentNode ) { return } for ( var m = 0 ; m < n . length ; m ++ ) { if ( j . options [ n [ m ] [ 0 ] ] ) { n [ m ] [ 1 ] . apply ( j . element , k ) } } } } , contains : function ( k , j ) { return document . compareDocumentPosition ? k . compareDocumentPosition ( j ) & 16 : k !== j && k . contains ( j ) } , hasScroll : function ( m , k ) { if ( c ( m ) . css ( "overflow" ) == "hidden" ) { return false } var j = ( k && k == "left" ) ? "scrollLeft" : "scrollTop" , l = false ; if ( m [ j ] > 0 ) { return true } m [ j ] = 1 ; l = ( m [ j ] > 0 ) ; m [ j ] = 0 ; return l } , isOverAxis : function ( k , j , l ) { return ( k > j ) && ( k < ( j + l ) ) } , isOver : function ( o , k , n , m , j , l ) { return c . ui . isOverAxis ( o , n , j ) && c . ui . isOverAxis ( k , m , l ) } , keyCode : { BACKSPACE : 8 , CAPS _LOCK : 20 , COMMA : 188 , CONTROL : 17 , DELETE : 46 , DOWN : 40 , END : 35 , ENTER : 13 , ESCAPE : 27 , HOME : 36 , INSERT : 45 , LEFT : 37 , NUMPAD _ADD : 107 , NUMPAD _DECIMAL : 110 , NUMPAD _DIVIDE : 111 , NUMPAD _ENTER : 108 , NUMPAD _MULTIPLY : 106 , NUMPAD _SUBTRACT : 109 , PAGE _DOWN : 34 , PAGE _UP : 33 , PERIOD : 190 , RIGHT : 39 , SHIFT : 16 , SPACE : 32 , TAB : 9 , UP : 38 } } ; if ( d ) { var f = c . attr , e = c . fn . removeAttr , h = "http://www.w3.org/2005/07/aaa" , a = /^aria-/ , b = /^wairole:/ ; c . attr = function ( k , j , l ) { var m = l !== undefined ; return ( j == "role" ? ( m ? f . call ( this , k , j , "wairole:" + l ) : ( f . apply ( this , arguments ) || "" ) . replace ( b , "" ) ) : ( a . test ( j ) ? ( m ? k . setAttributeNS ( h , j . replace ( a , "aaa:" ) , l ) : f . call ( this , k , j . replace ( a , "aaa:" ) ) ) : f . apply ( this , arguments ) ) ) } ; c . fn . removeAttr = function ( j ) { return ( a . test ( j ) ? this . each ( function ( ) { this . removeAttributeNS ( h , j . replace ( a , "" ) ) } ) : e . call ( this , j ) ) } } c . fn . extend ( { remove : function ( j , k ) { return this . each ( function ( ) { if ( ! k ) { if ( ! j || c . filter ( j , [ this ] ) . length ) { c ( "*" , this ) . add ( this ) . each ( function ( ) { c ( this ) . triggerHandler ( "remove" ) } ) } } return i . call ( c ( this ) , j , k ) } ) } , enableSelection : function ( ) { return this . attr ( "unselectable" , "off" ) . css ( "MozUserSelect" , "" ) . unbind ( "selectstart.ui" ) } , disableSelection : function ( ) { return this . attr ( "unselectable" , "on" ) . css ( "MozUserSelect" , "none" ) . bind ( "selectstart.ui" , function ( ) { return false } ) } , scrollParent : function ( ) { var j ; if ( ( c . browser . msie && ( /(static|relative)/ ) . test ( this . css ( "position" ) ) ) || ( /absolute/ ) . test ( this . css ( "position" ) ) ) { j = this . parents ( ) . filter ( function ( ) { return ( /(relative|absolute|fixed)/ ) . test ( c . curCSS ( this , "position" , 1 ) ) && ( /(auto|scroll)/ ) . test ( c . curCSS ( this , "overflow" , 1 ) + c . curCSS ( this , "overflow-y" , 1 ) + c . curCSS ( this , "overflow-x" , 1 ) ) } ) . eq ( 0 ) } else { j = this . parents ( ) . filter ( function ( ) { return ( /(auto|scroll)/ ) . test ( c . curCSS ( this , "overflow" , 1 ) + c . curCSS ( this , "overflow-y" , 1 ) + c . curCSS ( this , "overflow-x" , 1 ) ) } ) . eq ( 0 ) } return ( /fixed/ ) . test ( this . css ( "position" ) ) || ! j . length ? c ( document ) : j } } ) ; c . extend ( c . expr [ ":" ] , { data : function ( l , k , j ) { return ! ! c . data ( l , j [ 3 ] ) } , focusable : function ( k ) { var l = k . nodeName . toLowerCase ( ) , j = c . attr ( k , "tabindex" ) ; return ( /input|select|textarea|button|object/ . test ( l ) ? ! k . disabled : "a" == l || "area" == l ? k . href || ! isNaN ( j ) : ! isNaN ( j ) ) && ! c ( k ) [ "area" == l ? "parents" : "closest" ] ( ":hidden" ) . length } , tabbable : function ( k ) { var j = c . attr ( k , "tabindex" ) ; return ( isNaN ( j ) || j >= 0 ) && c ( k ) . is ( ":focusable" ) } } ) ; function g ( m , n , o , l ) { function k ( q ) { var p = c [ m ] [ n ] [ q ] || [ ] ; return ( typeof p == "string" ? p . split ( /,?\s+/ ) : p ) } var j = k ( "getter" ) ; if ( l . length == 1 && typeof l [ 0 ] == "string" ) { j = j . concat ( k ( "getterSetter" ) ) } return ( c . inArray ( o , j ) != - 1 ) } c . widget = function ( k , j ) { var l = k . split ( "." ) [ 0 ] ; k = k . split ( "." ) [ 1 ] ; c . fn [ k ] = function ( p ) { var n = ( typeof p == "string" ) , o = Array . prototype . slice . call ( arguments , 1 ) ; if ( n && p . substring ( 0 , 1 ) == "_" ) { return this } if ( n && g ( l , k , p , o ) ) { var m = c . data ( this [ 0 ] , k ) ; return ( m ? m [ p ] . apply ( m , o ) : undefined ) } return this . each ( function ( ) { var q = c . data ( this , k ) ; ( ! q && ! n && c . data ( this , k , new c [ l ] [ k ] ( this , p ) ) . _init ( ) ) ; ( q && n && c . isFunction ( q [ p ] ) && q [ p ] . apply ( q , o ) ) } ) } ; c [ l ] = c [ l ] || { } ; c [ l ] [ k ] = function ( o , n ) { var m = this ; this . namespace = l ; this . widgetName = k ; this . widgetEventPrefix = c [ l ] [ k ] . eventPrefix || k ; this . widgetBaseClass = l + "-" + k ; this . options = c . extend ( { } , c . widget . defaults , c [ l ] [ k ] . defaults , c . metadata && c . metadata . get ( o ) [ k ] , n ) ; this . element = c ( o ) . bind ( "setData." + k , function ( q , p , r ) { if ( q . target == o ) { return m . _setData
* jQuery UI Draggable 1.7 . 3
*
* Copyright ( c ) 2009 AUTHORS . txt ( http : //jqueryui.com/about)
* Dual licensed under the MIT ( MIT - LICENSE . txt )
* and GPL ( GPL - LICENSE . txt ) licenses .
*
* http : //docs.jquery.com/UI/Draggables
*
* Depends :
* ui . core . js
* /
( function ( a ) { a . widget ( "ui.draggable" , a . extend ( { } , a . ui . mouse , { _init : function ( ) { if ( this . options . helper == "original" && ! ( /^(?:r|a|f)/ ) . test ( this . element . css ( "position" ) ) ) { this . element [ 0 ] . style . position = "relative" } ( this . options . addClasses && this . element . addClass ( "ui-draggable" ) ) ; ( this . options . disabled && this . element . addClass ( "ui-draggable-disabled" ) ) ; this . _mouseInit ( ) } , destroy : function ( ) { if ( ! this . element . data ( "draggable" ) ) { return } this . element . removeData ( "draggable" ) . unbind ( ".draggable" ) . removeClass ( "ui-draggable ui-draggable-dragging ui-draggable-disabled" ) ; this . _mouseDestroy ( ) } , _mouseCapture : function ( b ) { var c = this . options ; if ( this . helper || c . disabled || a ( b . target ) . is ( ".ui-resizable-handle" ) ) { return false } this . handle = this . _getHandle ( b ) ; if ( ! this . handle ) { return false } return true } , _mouseStart : function ( b ) { var c = this . options ; this . helper = this . _createHelper ( b ) ; this . _cacheHelperProportions ( ) ; if ( a . ui . ddmanager ) { a . ui . ddmanager . current = this } this . _cacheMargins ( ) ; this . cssPosition = this . helper . css ( "position" ) ; this . scrollParent = this . helper . scrollParent ( ) ; this . offset = this . element . offset ( ) ; this . offset = { top : this . offset . top - this . margins . top , left : this . offset . left - this . margins . left } ; a . extend ( this . offset , { click : { left : b . pageX - this . offset . left , top : b . pageY - this . offset . top } , parent : this . _getParentOffset ( ) , relative : this . _getRelativeOffset ( ) } ) ; this . originalPosition = this . _generatePosition ( b ) ; this . originalPageX = b . pageX ; this . originalPageY = b . pageY ; if ( c . cursorAt ) { this . _adjustOffsetFromHelper ( c . cursorAt ) } if ( c . containment ) { this . _setContainment ( ) } this . _trigger ( "start" , b ) ; this . _cacheHelperProportions ( ) ; if ( a . ui . ddmanager && ! c . dropBehaviour ) { a . ui . ddmanager . prepareOffsets ( this , b ) } this . helper . addClass ( "ui-draggable-dragging" ) ; this . _mouseDrag ( b , true ) ; return true } , _mouseDrag : function ( b , d ) { this . position = this . _generatePosition ( b ) ; this . positionAbs = this . _convertPositionTo ( "absolute" ) ; if ( ! d ) { var c = this . _uiHash ( ) ; this . _trigger ( "drag" , b , c ) ; this . position = c . position } if ( ! this . options . axis || this . options . axis != "y" ) { this . helper [ 0 ] . style . left = this . position . left + "px" } if ( ! this . options . axis || this . options . axis != "x" ) { this . helper [ 0 ] . style . top = this . position . top + "px" } if ( a . ui . ddmanager ) { a . ui . ddmanager . drag ( this , b ) } return false } , _mouseStop : function ( c ) { var d = false ; if ( a . ui . ddmanager && ! this . options . dropBehaviour ) { d = a . ui . ddmanager . drop ( this , c ) } if ( this . dropped ) { d = this . dropped ; this . dropped = false } if ( ( this . options . revert == "invalid" && ! d ) || ( this . options . revert == "valid" && d ) || this . options . revert === true || ( a . isFunction ( this . options . revert ) && this . options . revert . call ( this . element , d ) ) ) { var b = this ; a ( this . helper ) . animate ( this . originalPosition , parseInt ( this . options . revertDuration , 10 ) , function ( ) { b . _trigger ( "stop" , c ) ; b . _clear ( ) } ) } else { this . _trigger ( "stop" , c ) ; this . _clear ( ) } return false } , _getHandle : function ( b ) { var c = ! this . options . handle || ! a ( this . options . handle , this . element ) . length ? true : false ; a ( this . options . handle , this . element ) . find ( "*" ) . andSelf ( ) . each ( function ( ) { if ( this == b . target ) { c = true } } ) ; return c } , _createHelper : function ( c ) { var d = this . options ; var b = a . isFunction ( d . helper ) ? a ( d . helper . apply ( this . element [ 0 ] , [ c ] ) ) : ( d . helper == "clone" ? this . element . clone ( ) : this . element ) ; if ( ! b . parents ( "body" ) . length ) { b . appendTo ( ( d . appendTo == "parent" ? this . element [ 0 ] . parentNode : d . appendTo ) ) } if ( b [ 0 ] != this . element [ 0 ] && ! ( /(fixed|absolute)/ ) . test ( b . css ( "position" ) ) ) { b . css ( "position" , "absolute" ) } return b } , _adjustOffsetFromHelper : function ( b ) { if ( b . left != undefined ) { this . offset . click . left = b . left + this . margins . left } if ( b . right != undefined ) { this . offset . click . left = this . helperProportions . width - b . right + this . margins . left } if ( b . top != undefined ) { this . offset . click . top = b . top + this . margins . top } if ( b . bottom != undefined ) { this . offset . click . top = this . helperProportions . height - b . bottom + this . margins . top } } , _getParentOffset : function ( ) { this . offsetParent = this . helper . offsetParent ( ) ; var b = this . offsetParent . offset ( ) ; if ( this . cssPosition == "absolute" && this . scrollParent [ 0 ] != document && a . ui . contains ( this . scrollParent [ 0 ] , this . offsetParent [ 0 ] ) ) { b . left += this . scrollParent . scrollLeft ( ) ; b . top += this . scrollParent . scrollTop ( ) } if ( ( this . offsetParent [ 0 ] == document . body ) || ( this . offsetParent [ 0 ] . tagName && thi
* jQuery UI Droppable 1.7 . 3
*
* Copyright ( c ) 2009 AUTHORS . txt ( http : //jqueryui.com/about)
* Dual licensed under the MIT ( MIT - LICENSE . txt )
* and GPL ( GPL - LICENSE . txt ) licenses .
*
* http : //docs.jquery.com/UI/Droppables
*
* Depends :
* ui . core . js
* ui . draggable . js
* /
( function ( a ) { a . widget ( "ui.droppable" , { _init : function ( ) { var c = this . options , b = c . accept ; this . isover = 0 ; this . isout = 1 ; this . options . accept = this . options . accept && a . isFunction ( this . options . accept ) ? this . options . accept : function ( e ) { return e . is ( b ) } ; this . proportions = { width : this . element [ 0 ] . offsetWidth , height : this . element [ 0 ] . offsetHeight } ; a . ui . ddmanager . droppables [ this . options . scope ] = a . ui . ddmanager . droppables [ this . options . scope ] || [ ] ; a . ui . ddmanager . droppables [ this . options . scope ] . push ( this ) ; ( this . options . addClasses && this . element . addClass ( "ui-droppable" ) ) } , destroy : function ( ) { var b = a . ui . ddmanager . droppables [ this . options . scope ] ; for ( var c = 0 ; c < b . length ; c ++ ) { if ( b [ c ] == this ) { b . splice ( c , 1 ) } } this . element . removeClass ( "ui-droppable ui-droppable-disabled" ) . removeData ( "droppable" ) . unbind ( ".droppable" ) } , _setData : function ( b , c ) { if ( b == "accept" ) { this . options . accept = c && a . isFunction ( c ) ? c : function ( e ) { return e . is ( c ) } } else { a . widget . prototype . _setData . apply ( this , arguments ) } } , _activate : function ( c ) { var b = a . ui . ddmanager . current ; if ( this . options . activeClass ) { this . element . addClass ( this . options . activeClass ) } ( b && this . _trigger ( "activate" , c , this . ui ( b ) ) ) } , _deactivate : function ( c ) { var b = a . ui . ddmanager . current ; if ( this . options . activeClass ) { this . element . removeClass ( this . options . activeClass ) } ( b && this . _trigger ( "deactivate" , c , this . ui ( b ) ) ) } , _over : function ( c ) { var b = a . ui . ddmanager . current ; if ( ! b || ( b . currentItem || b . element ) [ 0 ] == this . element [ 0 ] ) { return } if ( this . options . accept . call ( this . element [ 0 ] , ( b . currentItem || b . element ) ) ) { if ( this . options . hoverClass ) { this . element . addClass ( this . options . hoverClass ) } this . _trigger ( "over" , c , this . ui ( b ) ) } } , _out : function ( c ) { var b = a . ui . ddmanager . current ; if ( ! b || ( b . currentItem || b . element ) [ 0 ] == this . element [ 0 ] ) { return } if ( this . options . accept . call ( this . element [ 0 ] , ( b . currentItem || b . element ) ) ) { if ( this . options . hoverClass ) { this . element . removeClass ( this . options . hoverClass ) } this . _trigger ( "out" , c , this . ui ( b ) ) } } , _drop : function ( c , d ) { var b = d || a . ui . ddmanager . current ; if ( ! b || ( b . currentItem || b . element ) [ 0 ] == this . element [ 0 ] ) { return false } var e = false ; this . element . find ( ":data(droppable)" ) . not ( ".ui-draggable-dragging" ) . each ( function ( ) { var f = a . data ( this , "droppable" ) ; if ( f . options . greedy && a . ui . intersect ( b , a . extend ( f , { offset : f . element . offset ( ) } ) , f . options . tolerance ) ) { e = true ; return false } } ) ; if ( e ) { return false } if ( this . options . accept . call ( this . element [ 0 ] , ( b . currentItem || b . element ) ) ) { if ( this . options . activeClass ) { this . element . removeClass ( this . options . activeClass ) } if ( this . options . hoverClass ) { this . element . removeClass ( this . options . hoverClass ) } this . _trigger ( "drop" , c , this . ui ( b ) ) ; return this . element } return false } , ui : function ( b ) { return { draggable : ( b . currentItem || b . element ) , helper : b . helper , position : b . position , absolutePosition : b . positionAbs , offset : b . positionAbs } } } ) ; a . extend ( a . ui . droppable , { version : "1.7.3" , eventPrefix : "drop" , defaults : { accept : "*" , activeClass : false , addClasses : true , greedy : false , hoverClass : false , scope : "default" , tolerance : "intersect" } } ) ; a . ui . intersect = function ( q , j , o ) { if ( ! j . offset ) { return false } var e = ( q . positionAbs || q . position . absolute ) . left , d = e + q . helperProportions . width , n = ( q . positionAbs || q . position . absolute ) . top , m = n + q . helperProportions . height ; var g = j . offset . left , c = g + j . proportions . width , p = j . offset . top , k = p + j . proportions . height ; switch ( o ) { case "fit" : return ( g < e && d < c && p < n && m < k ) ; break ; case "intersect" : return ( g < e + ( q . helperProportions . width / 2 ) && d - ( q . helperProportions . width / 2 ) < c && p < n + ( q . helperProportions . height / 2 ) && m - ( q . helperProportions . height / 2 ) < k ) ; break ; case "pointer" : var h = ( ( q . positionAbs || q . position . absolute ) . left + ( q . clickOffset || q . offset . click ) . left ) , i = ( ( q . positionAbs || q . position . absolute ) . top + ( q . clickOffset || q . offset . click ) . top ) , f = a . ui . isOver ( i , h , p , g , j . proportions . height , j . proportions . width ) ; return f ; break ; case "touch" : return ( ( n >= p && n <= k ) || ( m >= p && m <= k ) || ( n < p && m > k ) ) && ( ( e >= g && e <= c ) || ( d >= g && d <= c ) || ( e < g && d > c ) ) ; break ; default : return false ; break } } ; a . ui . ddmanager = { current : null , droppables : { "default" : [ ] } , prepareOffsets : function ( e , g ) { var b = a . ui . ddmanager . droppables [ e . options . scope ] ; var f = g ? g . type : null ; var h = ( e . currentItem || e . element ) . find ( ":data(droppable)" ) . andSelf ( ) ; droppablesLoop : for ( var d = 0 ; d < b . length ; d ++
* jQuery UI Selectable 1.7 . 3
*
* Copyright ( c ) 2009 AUTHORS . txt ( http : //jqueryui.com/about)
* Dual licensed under the MIT ( MIT - LICENSE . txt )
* and GPL ( GPL - LICENSE . txt ) licenses .
*
* http : //docs.jquery.com/UI/Selectables
*
* Depends :
* ui . core . js
* /
( function ( a ) { a . widget ( "ui.selectable" , a . extend ( { } , a . ui . mouse , { _init : function ( ) { var b = this ; this . element . addClass ( "ui-selectable" ) ; this . dragged = false ; var c ; this . refresh = function ( ) { c = a ( b . options . filter , b . element [ 0 ] ) ; c . each ( function ( ) { var d = a ( this ) ; var e = d . offset ( ) ; a . data ( this , "selectable-item" , { element : this , $element : d , left : e . left , top : e . top , right : e . left + d . outerWidth ( ) , bottom : e . top + d . outerHeight ( ) , startselected : false , selected : d . hasClass ( "ui-selected" ) , selecting : d . hasClass ( "ui-selecting" ) , unselecting : d . hasClass ( "ui-unselecting" ) } ) } ) } ; this . refresh ( ) ; this . selectees = c . addClass ( "ui-selectee" ) ; this . _mouseInit ( ) ; this . helper = a ( document . createElement ( "div" ) ) . css ( { border : "1px dotted black" } ) . addClass ( "ui-selectable-helper" ) } , destroy : function ( ) { this . element . removeClass ( "ui-selectable ui-selectable-disabled" ) . removeData ( "selectable" ) . unbind ( ".selectable" ) ; this . _mouseDestroy ( ) } , _mouseStart : function ( d ) { var b = this ; this . opos = [ d . pageX , d . pageY ] ; if ( this . options . disabled ) { return } var c = this . options ; this . selectees = a ( c . filter , this . element [ 0 ] ) ; this . _trigger ( "start" , d ) ; a ( c . appendTo ) . append ( this . helper ) ; this . helper . css ( { "z-index" : 100 , position : "absolute" , left : d . clientX , top : d . clientY , width : 0 , height : 0 } ) ; if ( c . autoRefresh ) { this . refresh ( ) } this . selectees . filter ( ".ui-selected" ) . each ( function ( ) { var e = a . data ( this , "selectable-item" ) ; e . startselected = true ; if ( ! d . metaKey ) { e . $element . removeClass ( "ui-selected" ) ; e . selected = false ; e . $element . addClass ( "ui-unselecting" ) ; e . unselecting = true ; b . _trigger ( "unselecting" , d , { unselecting : e . element } ) } } ) ; a ( d . target ) . parents ( ) . andSelf ( ) . each ( function ( ) { var e = a . data ( this , "selectable-item" ) ; if ( e ) { e . $element . removeClass ( "ui-unselecting" ) . addClass ( "ui-selecting" ) ; e . unselecting = false ; e . selecting = true ; e . selected = true ; b . _trigger ( "selecting" , d , { selecting : e . element } ) ; return false } } ) } , _mouseDrag : function ( i ) { var c = this ; this . dragged = true ; if ( this . options . disabled ) { return } var e = this . options ; var d = this . opos [ 0 ] , h = this . opos [ 1 ] , b = i . pageX , g = i . pageY ; if ( d > b ) { var f = b ; b = d ; d = f } if ( h > g ) { var f = g ; g = h ; h = f } this . helper . css ( { left : d , top : h , width : b - d , height : g - h } ) ; this . selectees . each ( function ( ) { var j = a . data ( this , "selectable-item" ) ; if ( ! j || j . element == c . element [ 0 ] ) { return } var k = false ; if ( e . tolerance == "touch" ) { k = ( ! ( j . left > b || j . right < d || j . top > g || j . bottom < h ) ) } else { if ( e . tolerance == "fit" ) { k = ( j . left > d && j . right < b && j . top > h && j . bottom < g ) } } if ( k ) { if ( j . selected ) { j . $element . removeClass ( "ui-selected" ) ; j . selected = false } if ( j . unselecting ) { j . $element . removeClass ( "ui-unselecting" ) ; j . unselecting = false } if ( ! j . selecting ) { j . $element . addClass ( "ui-selecting" ) ; j . selecting = true ; c . _trigger ( "selecting" , i , { selecting : j . element } ) } } else { if ( j . selecting ) { if ( i . metaKey && j . startselected ) { j . $element . removeClass ( "ui-selecting" ) ; j . selecting = false ; j . $element . addClass ( "ui-selected" ) ; j . selected = true } else { j . $element . removeClass ( "ui-selecting" ) ; j . selecting = false ; if ( j . startselected ) { j . $element . addClass ( "ui-unselecting" ) ; j . unselecting = true } c . _trigger ( "unselecting" , i , { unselecting : j . element } ) } } if ( j . selected ) { if ( ! i . metaKey && ! j . startselected ) { j . $element . removeClass ( "ui-selected" ) ; j . selected = false ; j . $element . addClass ( "ui-unselecting" ) ; j . unselecting = true ; c . _trigger ( "unselecting" , i , { unselecting : j . element } ) } } } } ) ; return false } , _mouseStop : function ( d ) { var b = this ; this . dragged = false ; var c = this . options ; a ( ".ui-unselecting" , this . element [ 0 ] ) . each ( function ( ) { var e = a . data ( this , "selectable-item" ) ; e . $element . removeClass ( "ui-unselecting" ) ; e . unselecting = false ; e . startselected = false ; b . _trigger ( "unselected" , d , { unselected : e . element } ) } ) ; a ( ".ui-selecting" , this . element [ 0 ] ) . each ( function ( ) { var e = a . data ( this , "selectable-item" ) ; e . $element . removeClass ( "ui-selecting" ) . addClass ( "ui-selected" ) ; e . selecting = false ; e . selected = true ; e . startselected = true ; b . _trigger ( "selected" , d , { selected : e . element } ) } ) ; this . _trigger ( "stop" , d ) ; this . helper . remove ( ) ; return false } } ) ) ; a . extend ( a . ui . selectable , { version : "1.7.3" , defaults : { appendTo : "body" , autoRefresh : true , cancel : ":input,option" , delay : 0 , distance : 0 , filter : "*" , tolerance : "touch" } } ) } ) ( jQuery ) ; ; / *
* jQuery UI Datepicker 1.7 . 3
*
* Copyright ( c ) 2009 AUTHORS . txt ( http : //jqueryui.com/about)
* Dual licensed under the MIT ( MIT - LICENSE . txt )
* and GPL ( GPL - LICENSE . txt ) licenses .
*
* http : //docs.jquery.com/UI/Datepicker
*
* Depends :
* ui . core . js
* /
( function ( $ ) { $ . extend ( $ . ui , { datepicker : { version : "1.7.3" } } ) ; var PROP _NAME = "datepicker" ; function Datepicker ( ) { this . debug = false ; this . _curInst = null ; this . _keyEvent = false ; this . _disabledInputs = [ ] ; this . _datepickerShowing = false ; this . _inDialog = false ; this . _mainDivId = "ui-datepicker-div" ; this . _inlineClass = "ui-datepicker-inline" ; this . _appendClass = "ui-datepicker-append" ; this . _triggerClass = "ui-datepicker-trigger" ; this . _dialogClass = "ui-datepicker-dialog" ; this . _disableClass = "ui-datepicker-disabled" ; this . _unselectableClass = "ui-datepicker-unselectable" ; this . _currentClass = "ui-datepicker-current-day" ; this . _dayOverClass = "ui-datepicker-days-cell-over" ; this . regional = [ ] ; this . regional [ "" ] = { closeText : "Done" , prevText : "Prev" , nextText : "Next" , currentText : "Today" , monthNames : [ "January" , "February" , "March" , "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December" ] , monthNamesShort : [ "Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" , "Jul" , "Aug" , "Sep" , "Oct" , "Nov" , "Dec" ] , dayNames : [ "Sunday" , "Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday" , "Saturday" ] , dayNamesShort : [ "Sun" , "Mon" , "Tue" , "Wed" , "Thu" , "Fri" , "Sat" ] , dayNamesMin : [ "Su" , "Mo" , "Tu" , "We" , "Th" , "Fr" , "Sa" ] , dateFormat : "mm/dd/yy" , firstDay : 0 , isRTL : false } ; this . _defaults = { showOn : "focus" , showAnim : "show" , showOptions : { } , defaultDate : null , appendText : "" , buttonText : "..." , buttonImage : "" , buttonImageOnly : false , hideIfNoPrevNext : false , navigationAsDateFormat : false , gotoCurrent : false , changeMonth : false , changeYear : false , showMonthAfterYear : false , yearRange : "-10:+10" , showOtherMonths : false , calculateWeek : this . iso8601Week , shortYearCutoff : "+10" , minDate : null , maxDate : null , duration : "normal" , beforeShowDay : null , beforeShow : null , onSelect : null , onChangeMonthYear : null , onClose : null , numberOfMonths : 1 , showCurrentAtPos : 0 , stepMonths : 1 , stepBigMonths : 12 , altField : "" , altFormat : "" , constrainInput : true , showButtonPanel : false } ; $ . extend ( this . _defaults , this . regional [ "" ] ) ; this . dpDiv = $ ( '<div id="' + this . _mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible"></div>' ) } $ . extend ( Datepicker . prototype , { markerClassName : "hasDatepicker" , log : function ( ) { if ( this . debug ) { console . log . apply ( "" , arguments ) } } , setDefaults : function ( settings ) { extendRemove ( this . _defaults , settings || { } ) ; return this } , _attachDatepicker : function ( target , settings ) { var inlineSettings = null ; for ( var attrName in this . _defaults ) { var attrValue = target . getAttribute ( "date:" + attrName ) ; if ( attrValue ) { inlineSettings = inlineSettings || { } ; try { inlineSettings [ attrName ] = eval ( attrValue ) } catch ( err ) { inlineSettings [ attrName ] = attrValue } } } var nodeName = target . nodeName . toLowerCase ( ) ; var inline = ( nodeName == "div" || nodeName == "span" ) ; if ( ! target . id ) { target . id = "dp" + ( ++ this . uuid ) } var inst = this . _newInst ( $ ( target ) , inline ) ; inst . settings = $ . extend ( { } , settings || { } , inlineSettings || { } ) ; if ( nodeName == "input" ) { this . _connectDatepicker ( target , inst ) } else { if ( inline ) { this . _inlineDatepicker ( target , inst ) } } } , _newInst : function ( target , inline ) { var id = target [ 0 ] . id . replace ( /([:\[\]\.])/g , "\\\\$1" ) ; return { id : id , input : target , selectedDay : 0 , selectedMonth : 0 , selectedYear : 0 , drawMonth : 0 , drawYear : 0 , inline : inline , dpDiv : ( ! inline ? this . dpDiv : $ ( '<div class="' + this . _inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>' ) ) } } , _connectDatepicker : function ( target , inst ) { var input = $ ( target ) ; inst . append = $ ( [ ] ) ; inst . trigger = $ ( [ ] ) ; if ( input . hasClass ( this . markerClassName ) ) { return } var appendText = this . _get ( inst , "appendText" ) ; var isRTL = this . _get ( inst , "isRTL" ) ; if ( appendText ) { inst . append = $ ( '<span class="' + this . _appendClass + '">' + appendText + "</span>" ) ; input [ isRTL ? "before" : "after" ] ( inst . append ) } var showOn = this . _get ( inst , "showOn" ) ; if ( showOn == "focus" || showOn == "both" ) { input . focus ( this . _showDatepicker ) } if ( showOn == "button" || showOn == "both" ) { var buttonText = this . _get ( inst , "buttonText" ) ; var buttonImage = this . _get ( inst , "buttonImage" ) ; inst . trigger = $ ( this . _get ( inst , "buttonImageOnly" ) ? $ ( "<img/>" ) . addClass ( this . _triggerClass ) . attr ( { src : buttonImage , alt : buttonText , title : buttonText } ) : $ ( '<button type="button"></button>' ) . addClass ( this . _triggerClass ) . html ( buttonImage == "" ? buttonText : $ ( "<img/>" ) . attr ( { src : b
/ *
* jquery . qtip . The jQuery tooltip plugin
*
* Copyright ( c ) 2009 Craig Thompson
* http : //craigsworks.com
*
* Licensed under MIT
* http : //www.opensource.org/licenses/mit-license.php
*
* Launch : February 2009
* Version : 1.0 . 0 - rc3
* Released : Tuesday 12 th May , 2009 - 00 : 00
* Debug : jquery . qtip . debug . js
* /
( function ( f ) { f . fn . qtip = function ( B , u ) { var y , t , A , s , x , w , v , z ; if ( typeof B == "string" ) { if ( typeof f ( this ) . data ( "qtip" ) !== "object" ) { f . fn . qtip . log . error . call ( self , 1 , f . fn . qtip . constants . NO _TOOLTIP _PRESENT , false ) } if ( B == "api" ) { return f ( this ) . data ( "qtip" ) . interfaces [ f ( this ) . data ( "qtip" ) . current ] } else { if ( B == "interfaces" ) { return f ( this ) . data ( "qtip" ) . interfaces } } } else { if ( ! B ) { B = { } } if ( typeof B . content !== "object" || ( B . content . jquery && B . content . length > 0 ) ) { B . content = { text : B . content } } if ( typeof B . content . title !== "object" ) { B . content . title = { text : B . content . title } } if ( typeof B . position !== "object" ) { B . position = { corner : B . position } } if ( typeof B . position . corner !== "object" ) { B . position . corner = { target : B . position . corner , tooltip : B . position . corner } } if ( typeof B . show !== "object" ) { B . show = { when : B . show } } if ( typeof B . show . when !== "object" ) { B . show . when = { event : B . show . when } } if ( typeof B . show . effect !== "object" ) { B . show . effect = { type : B . show . effect } } if ( typeof B . hide !== "object" ) { B . hide = { when : B . hide } } if ( typeof B . hide . when !== "object" ) { B . hide . when = { event : B . hide . when } } if ( typeof B . hide . effect !== "object" ) { B . hide . effect = { type : B . hide . effect } } if ( typeof B . style !== "object" ) { B . style = { name : B . style } } B . style = c ( B . style ) ; s = f . extend ( true , { } , f . fn . qtip . defaults , B ) ; s . style = a . call ( { options : s } , s . style ) ; s . user = f . extend ( true , { } , B ) } return f ( this ) . each ( function ( ) { if ( typeof B == "string" ) { w = B . toLowerCase ( ) ; A = f ( this ) . qtip ( "interfaces" ) ; if ( typeof A == "object" ) { if ( u === true && w == "destroy" ) { while ( A . length > 0 ) { A [ A . length - 1 ] . destroy ( ) } } else { if ( u !== true ) { A = [ f ( this ) . qtip ( "api" ) ] } for ( y = 0 ; y < A . length ; y ++ ) { if ( w == "destroy" ) { A [ y ] . destroy ( ) } else { if ( A [ y ] . status . rendered === true ) { if ( w == "show" ) { A [ y ] . show ( ) } else { if ( w == "hide" ) { A [ y ] . hide ( ) } else { if ( w == "focus" ) { A [ y ] . focus ( ) } else { if ( w == "disable" ) { A [ y ] . disable ( true ) } else { if ( w == "enable" ) { A [ y ] . disable ( false ) } } } } } } } } } } } else { v = f . extend ( true , { } , s ) ; v . hide . effect . length = s . hide . effect . length ; v . show . effect . length = s . show . effect . length ; if ( v . position . container === false ) { v . position . container = f ( document . body ) } if ( v . position . target === false ) { v . position . target = f ( this ) } if ( v . show . when . target === false ) { v . show . when . target = f ( this ) } if ( v . hide . when . target === false ) { v . hide . when . target = f ( this ) } t = f . fn . qtip . interfaces . length ; for ( y = 0 ; y < t ; y ++ ) { if ( typeof f . fn . qtip . interfaces [ y ] == "undefined" ) { t = y ; break } } x = new d ( f ( this ) , v , t ) ; f . fn . qtip . interfaces [ t ] = x ; if ( typeof f ( this ) . data ( "qtip" ) == "object" ) { if ( typeof f ( this ) . attr ( "qtip" ) === "undefined" ) { f ( this ) . data ( "qtip" ) . current = f ( this ) . data ( "qtip" ) . interfaces . length } f ( this ) . data ( "qtip" ) . interfaces . push ( x ) } else { f ( this ) . data ( "qtip" , { current : 0 , interfaces : [ x ] } ) } if ( v . content . prerender === false && v . show . when . event !== false && v . show . ready !== true ) { v . show . when . target . bind ( v . show . when . event + ".qtip-" + t + "-create" , { qtip : t } , function ( C ) { z = f . fn . qtip . interfaces [ C . data . qtip ] ; z . options . show . when . target . unbind ( z . options . show . when . event + ".qtip-" + C . data . qtip + "-create" ) ; z . cache . mouse = { x : C . pageX , y : C . pageY } ; p . call ( z ) ; z . options . show . when . target . trigger ( z . options . show . when . event ) } ) } else { x . cache . mouse = { x : v . show . when . target . offset ( ) . left , y : v . show . when . target . offset ( ) . top } ; p . call ( x ) } } } ) } ; function d ( u , t , v ) { var s = this ; s . id = v ; s . options = t ; s . status = { animated : false , rendered : false , disabled : false , focused : false } ; s . elements = { target : u . addClass ( s . options . style . classes . target ) , tooltip : null , wrapper : null , content : null , contentWrapper : null , title : null , button : null , tip : null , bgiframe : null } ; s . cache = { mouse : { } , position : { } , toggle : 0 } ; s . timers = { } ; f . extend ( s , s . options . api , { show : function ( y ) { var x , z ; if ( ! s . status . rendered ) { return f . fn . qtip . log . error . call ( s , 2 , f . fn . qtip . constants . TOOLTIP _NOT _RENDERED , "show" ) } if ( s . elements . tooltip . css ( "display" ) !== "none" ) { return s } s . elements . tooltip . stop ( true , false ) ; x = s . beforeShow . call ( s , y ) ; if ( x === false ) { return s } function w ( ) { if ( s . options . position . type !== "static" ) { s . focus ( ) } s . onShow . call ( s , y ) ; if ( f . browser . msie ) { s . elements . tooltip . get ( 0 ) . style . removeAttribute ( "filter" ) } } s . cache . toggle = 1 ; if ( s . options . position . type !== "static" ) { s . updatePosition ( y , ( s . options . show . effect . length > 0 ) ) } if ( typeof s . options . show . solo == "object" ) { z = f ( s . options . show . solo ) } else { if ( s . options . show . solo === true ) { z = f ( "div.qtip" ) . not ( s . elements . tooltip ) } } if ( z ) {
2012-02-14 06:42:13 +00:00
/ *
* lib / js / legacy / tiny _mce _33 / jquery . tinymce . js
* /(function(b){var e,d,a=[],c=window;b.fn.tinymce=function(j){var p=this,g,k,h,m,i,l="",n="";if(!p.length){return p}if(!j){return tinyMCE.get(p[0].id)}function o(){var r=[],q=0;if(f){f();f=null}p.each(function(t,u){var s,w=u.id,v=j.oninit;if(!w){u.id=w=tinymce.DOM.uniqueId()}s=new tinymce.Editor(w,j);r.push(s);if(v){s.onInit.add(function(){var x,y=v;if(++q==r.length){if(tinymce.is(y,"string")){x=(y.indexOf(".")===-1)?null:tinymce.resolve(y.replace(/ \ . \ w + $ / , "" ) ) ; y = tinymce . resolve ( y ) } y . apply ( x || tinymce , r ) } } ) } } ) ; b . each ( r , function ( t , s ) { s . render ( ) } ) } if ( ! c . tinymce && ! d && ( g = j . script _url ) ) { d = 1 ; h = g . substring ( 0 , g . lastIndexOf ( "/" ) ) ; if ( /_(src|dev)\.js/g . test ( g ) ) { n = "_src" } m = g . lastIndexOf ( "?" ) ; if ( m != - 1 ) { l = g . substring ( m + 1 ) } c . tinyMCEPreInit = c . tinyMCEPreInit || { base : h , suffix : n , query : l } ; if ( g . indexOf ( "gzip" ) != - 1 ) { i = j . language || "en" ; g = g + ( /\?/ . test ( g ) ? "&" : "?" ) + "js=true&core=true&suffix=" + escape ( n ) + "&themes=" + escape ( j . theme ) + "&plugins=" + escape ( j . plugins ) + "&languages=" + i ; if ( ! c . tinyMCE _GZ ) { tinyMCE _GZ = { start : function ( ) { tinymce . suffix = n ; function q ( r ) { tinymce . ScriptLoader . markDone ( tinyMCE . baseURI . toAbsolute ( r ) ) } q ( "langs/" + i + ".js" ) ; q ( "themes/" + j . theme + "/editor_template" + n + ".js" ) ; q ( "themes/" + j . theme + "/langs/" + i + ".js" ) ; b . each ( j . plugins . split ( "," ) , function ( s , r ) { if ( r ) { q ( "plugins/" + r + "/editor_plugin" + n + ".js" ) ; q ( "plugins/" + r + "/langs/" + i + ".js" ) } } ) } , end : function ( ) { } } } } b . ajax ( { type : "GET" , url : g , dataType : "script" , cache : true , success : function ( ) { tinymce . dom . Event . domLoaded = 1 ; d = 2 ; if ( j . script _loaded ) { j . script _loaded ( ) } o ( ) ; b . each ( a , function ( q , r ) { r ( ) } ) } } ) } else { if ( d === 1 ) { a . push ( o ) } else { o ( ) } } return p } ; b . extend ( b . expr [ ":" ] , { tinymce : function ( g ) { return g . id && ! ! tinyMCE . get ( g . id ) } } ) ; function f ( ) { function i ( l ) { if ( l === "remove" ) { this . each ( function ( n , o ) { var m = h ( o ) ; if ( m ) { m . remove ( ) } } ) } this . find ( "span.mceEditor,div.mceEditor" ) . each ( function ( n , o ) { var m = tinyMCE . get ( o . id . replace ( /_parent$/ , "" ) ) ; if ( m ) { m . remove ( ) } } ) } function k ( n ) { var m = this , l ; if ( n !== e ) { i . call ( m ) ; m . each ( function ( p , q ) { var o ; if ( o = tinyMCE . get ( q . id ) ) { o . setContent ( n ) } } ) } else { if ( m . length > 0 ) { if ( l = tinyMCE . get ( m [ 0 ] . id ) ) { return l . getContent ( ) } } } } function h ( m ) { var l = null ; ( m ) && ( m . id ) && ( c . tinymce ) && ( l = tinyMCE . get ( m . id ) ) ; return l } function g ( l ) { return ! ! ( ( l ) && ( l . length ) && ( c . tinymce ) && ( l . is ( ":tinymce" ) ) ) } var j = { } ; b . each ( [ "text" , "html" , "val" ] , function ( n , l ) { var o = j [ l ] = b . fn [ l ] , m = ( l === "text" ) ; b . fn [ l ] = function ( s ) { var p = this ; if ( ! g ( p ) ) { return o . apply ( p , arguments ) } if ( s !== e ) { k . call ( p . filter ( ":tinymce" ) , s ) ; o . apply ( p . not ( ":tinymce" ) , arguments ) ; return p } else { var r = "" ; var q = arguments ; ( m ? p : p . eq ( 0 ) ) . each ( function ( u , v ) { var t = h ( v ) ; r += t ? ( m ? t . getContent ( ) . replace ( /<(?:"[^"]*"|'[^']*'|[^'">])*>/g , "" ) : t . getContent ( ) ) : o . apply ( b ( v ) , q ) } ) ; return r } } } ) ; b . each ( [ "append" , "prepend" ] , function ( n , m ) { var o = j [ m ] = b . fn [ m ] , l = ( m === "prepend" ) ; b . fn [ m ] = function ( q ) { var p = this ; if ( ! g ( p ) ) { return o . apply ( p , arguments ) } if ( q !== e ) { p . filter ( ":tinymce" ) . each ( function ( s , t ) { var r = h ( t ) ; r && r . setContent ( l ? q + r . getContent ( ) : r . getContent ( ) + q ) } ) ; o . apply ( p . not ( ":tinymce" ) , arguments ) ; return p } } } ) ; b . each ( [ "remove" , "replaceWith" , "replaceAll" , "empty" ] , function ( m , l ) { var n = j [ l ] = b . fn [ l ] ; b . fn [ l ] = function ( ) { i . call ( this , l ) ; return n . apply ( this , arguments ) } } ) ; j . attr = b . fn . attr ; b . fn . attr = function ( n , q , o ) { var m = this ; if ( ( ! n ) || ( n !== "value" ) || ( ! g ( m ) ) ) { return j . attr . call ( m , n , q , o ) } if ( q !== e ) { k . call ( m . filter ( ":tinymce" ) , q ) ; j . attr . call ( m . not ( ":tinymce" ) , n , q , o ) ; return m } else { var p = m [ 0 ] , l = h ( p ) ; return l ? l . getContent ( ) : j . attr . call ( b ( p ) , n , q , o ) } } } } ) ( jQuery ) ;
2012-02-14 06:14:13 +00:00
/ *
* lib / js / core . min . js
* /
/ *
* lib / js / wn / class . js
* / ; ( f u n c t i o n ( ) { v a r i n i t i a l i z i n g = f a l s e , f n T e s t = / x y z / . t e s t ( f u n c t i o n ( ) { x y z ; } ) ? / \ b _ s u p e r \ b / : / . * / ; t h i s . C l a s s = f u n c t i o n ( ) { } ; C l a s s . e x t e n d = f u n c t i o n ( p r o p ) { v a r _ s u p e r = t h i s . p r o t o t y p e ; i n i t i a l i z i n g = t r u e ; v a r p r o t o t y p e = n e w t h i s ( ) ; i n i t i a l i z i n g = f a l s e ; f o r ( v a r n a m e i n p r o p ) { p r o t o t y p e [ n a m e ] = t y p e o f p r o p [ n a m e ] = = " f u n c t i o n " & & t y p e o f _ s u p e r [ n a m e ] = = " f u n c t i o n " & & f n T e s t . t e s t ( p r o p [ n a m e ] ) ? ( f u n c t i o n ( n a m e , f n ) { r e t u r n f u n c t i o n ( ) { v a r t m p = t h i s . _ s u p e r ; t h i s . _ s u p e r = _ s u p e r [ n a m e ] ; v a r r e t = f n . a p p l y ( t h i s , a r g u m e n t s ) ; t h i s . _ s u p e r = t m p ; r e t u r n r e t ; } ; } ) ( n a m e , p r o p [ n a m e ] ) : p r o p [ n a m e ] ; }
function Class ( ) { if ( ! initializing && this . init )
this . init . apply ( this , arguments ) ; }
Class . prototype = prototype ; Class . prototype . constructor = Class ; Class . extend = arguments . callee ; return Class ; } ; } ) ( ) ;
/ *
* lib / js / wn / provide . js
* /
if ( ! window . wn ) wn = { }
wn . provide = function ( namespace ) { var nsl = namespace . split ( '.' ) ; var l = nsl . length ; var parent = window ; for ( var i = 0 ; i < l ; i ++ ) { var n = nsl [ i ] ; if ( ! parent [ n ] ) { parent [ n ] = { } }
parent = parent [ n ] ; } }
wn . provide ( 'wn.settings' ) ; wn . provide ( 'wn.ui' ) ;
/ *
* lib / js / wn / xmlhttp . js
* /
wn . xmlhttp = { request : function ( ) { if ( window . XMLHttpRequest )
return new XMLHttpRequest ( ) ; else if ( window . ActiveXObject )
return new ActiveXObject ( "MsXml2.XmlHttp" ) ; } , complete : function ( req , callback , url ) { if ( req . status == 200 || req . status == 304 ) { callback ( req . responseText ) ; } else { alert ( url + ' request error: ' + req . statusText + ' (' + req . status + ')' ) ; } } , get : function ( url , callback , args , async ) { if ( async === null ) async = true ; var req = wn . xmlhttp . request ( ) ; req . onreadystatechange = function ( ) { if ( req . readyState == 4 ) { wn . xmlhttp . complete ( req , callback , url ) } }
var sep = ( ( args && args . indexOf ( '?' ) ) == - 1 ) ? '?' : '&' ; var u = args ? ( url + sep + args ) : url ; req . open ( 'GET' , u , async ) ; req . send ( null ) ; if ( ! async ) { wn . xmlhttp . complete ( req , callback , url ) } } }
/ *
* lib / js / wn / versions . js
* /
wn . versions = { check : function ( ) { if ( localStorage ) { if ( window . _version _number == - 1 || parseInt ( localStorage . _version _number ) != parseInt ( window . _version _number ) ) { var localversion = localStorage . _version _number ; localStorage . clear ( ) ; console . log ( "Cache cleared - version: " + localversion
+ ' to ' + _version _number ) }
localStorage . setItem ( '_version_number' , window . _version _number ) ; } } }
/ *
* lib / js / wn / assets . js
* /
wn . assets = { executed _ : { } , exists : function ( src ) { if ( 'localStorage' in window && localStorage . getItem ( src ) )
return true } , add : function ( src , txt ) { if ( 'localStorage' in window ) { localStorage . setItem ( src , txt ) ; } } , get : function ( src ) { return localStorage . getItem ( src ) ; } , extn : function ( src ) { if ( src . indexOf ( '?' ) != - 1 ) { src = src . split ( '?' ) . slice ( - 1 ) [ 0 ] ; }
return src . split ( '.' ) . slice ( - 1 ) [ 0 ] ; } , load : function ( src ) { var t = src ; wn . xmlhttp . get ( t , function ( txt ) { wn . assets . add ( src , txt ) ; } , 'q=' + Math . floor ( Math . random ( ) * 1000 ) , false ) } , execute : function ( src ) { if ( ! wn . assets . exists ( src ) ) { wn . assets . load ( src ) ; }
var type = wn . assets . extn ( src ) ; if ( wn . assets . handler [ type ] ) { wn . assets . handler [ type ] ( wn . assets . get ( src ) , src ) ; wn . assets . executed _ [ src ] = 1 ; } } , handler : { js : function ( txt , src ) { wn . dom . eval ( txt ) ; } , css : function ( txt , src ) { var se = document . createElement ( 'style' ) ; se . type = "text/css" ; if ( se . styleSheet ) { se . styleSheet . cssText = txt ; } else { se . appendChild ( document . createTextNode ( txt ) ) ; }
document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( se ) ; } , cgi : function ( txt , src ) { wn . dom . eval ( txt ) } } }
/ *
* lib / js / wn / require . js
* /
wn . require = function ( items ) { if ( typeof items === "string" ) { items = [ items ] ; }
var l = items . length ; for ( var i = 0 ; i < l ; i ++ ) { var src = items [ i ] ; if ( ! ( src in wn . assets . executed _ ) ) { wn . assets . execute ( src ) ; } } }
/ *
* lib / js / wn / dom . js
* /
wn . provide ( 'wn.dom' ) ; wn . dom . by _id = function ( id ) { return document . getElementById ( id ) ; }
wn . dom . eval = function ( txt ) { var el = document . createElement ( 'script' ) ; el . appendChild ( document . createTextNode ( txt ) ) ; document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( el ) ; }
wn . dom . add = function ( parent , newtag , className , cs , innerHTML , onclick ) { if ( parent && parent . substr ) parent = wn . dom . by _id ( parent ) ; var c = document . createElement ( newtag ) ; if ( parent )
parent . appendChild ( c ) ; if ( className ) { if ( newtag . toLowerCase ( ) == 'img' )
c . src = className
else
c . className = className ; }
if ( cs ) wn . dom . css ( c , cs ) ; if ( innerHTML ) c . innerHTML = innerHTML ; if ( onclick ) c . onclick = onclick ; return c ; }
wn . dom . css = function ( ele , s ) { if ( ele && s ) { for ( var i in s ) ele . style [ i ] = s [ i ] ; } ; return ele ; }
wn . dom . hide = function ( ele ) { ele . style . display = 'none' ; }
wn . dom . show = function ( ele , value ) { if ( ! value ) value = 'block' ; ele . style . display = value ; }
/ *
* lib / js / wn / page . js
* /
wn . page = { set : function ( src ) { var new _selection = $ ( '.inner div.content[_src="' + src + '"]' ) ; if ( ! new _selection . length ) { wn . assets . execute ( src ) ; new _selection = $ ( '.inner div.content[_src="' + src + '"]' ) ; }
$ ( '.inner .current_page' ) . removeClass ( 'current_page' ) ; new _selection . addClass ( 'current_page' ) ; var title = $ ( 'nav ul li a[href*="' + src + '"]' ) . attr ( 'title' ) || 'No Title'
state = window . location . hash ; if ( state != src ) { window . location . hash = state ; }
else { document . title = title ; } } }
/ *
* lib / js / lib / json2 . js
* /
var JSON ; if ( ! JSON ) { JSON = { } ; }
( function ( ) { "use strict" ; function f ( n ) { return n < 10 ? '0' + n : n ; }
if ( typeof Date . prototype . toJSON !== 'function' ) { Date . prototype . toJSON = function ( key ) { return isFinite ( this . valueOf ( ) ) ? this . getUTCFullYear ( ) + '-' +
f ( this . getUTCMonth ( ) + 1 ) + '-' +
f ( this . getUTCDate ( ) ) + 'T' +
f ( this . getUTCHours ( ) ) + ':' +
f ( this . getUTCMinutes ( ) ) + ':' +
f ( this . getUTCSeconds ( ) ) + 'Z' : null ; } ; String . prototype . toJSON = Number . prototype . toJSON = Boolean . prototype . toJSON = function ( key ) { return this . valueOf ( ) ; } ; }
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g , escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g , gap , indent , meta = { '\b' : '\\b' , '\t' : '\\t' , '\n' : '\\n' , '\f' : '\\f' , '\r' : '\\r' , '"' : '\\"' , '\\' : '\\\\' } , rep ; function quote ( string ) { escapable . lastIndex = 0 ; return escapable . test ( string ) ? '"' + string . replace ( escapable , function ( a ) { var c = meta [ a ] ; return typeof c === 'string' ? c : '\\u' + ( '0000' + a . charCodeAt ( 0 ) . toString ( 16 ) ) . slice ( - 4 ) ; } ) + '"' : '"' + string + '"' ; }
function str ( key , holder ) { var i , k , v , length , mind = gap , partial , value = holder [ key ] ; if ( value && typeof value === 'object' && typeof value . toJSON === 'function' ) { value = value . toJSON ( key ) ; }
if ( typeof rep === 'function' ) { value = rep . call ( holder , key , value ) ; }
switch ( typeof value ) { case 'string' : return quote ( value ) ; case 'number' : return isFinite ( value ) ? String ( value ) : 'null' ; case 'boolean' : case 'null' : return String ( value ) ; case 'object' : if ( ! value ) { return 'null' ; }
gap += indent ; partial = [ ] ; if ( Object . prototype . toString . apply ( value ) === '[object Array]' ) { length = value . length ; for ( i = 0 ; i < length ; i += 1 ) { partial [ i ] = str ( i , value ) || 'null' ; }
v = partial . length === 0 ? '[]' : gap ? '[\n' + gap + partial . join ( ',\n' + gap ) + '\n' + mind + ']' : '[' + partial . join ( ',' ) + ']' ; gap = mind ; return v ; }
if ( rep && typeof rep === 'object' ) { length = rep . length ; for ( i = 0 ; i < length ; i += 1 ) { if ( typeof rep [ i ] === 'string' ) { k = rep [ i ] ; v = str ( k , value ) ; if ( v ) { partial . push ( quote ( k ) + ( gap ? ': ' : ':' ) + v ) ; } } } } else { for ( k in value ) { if ( Object . prototype . hasOwnProperty . call ( value , k ) ) { v = str ( k , value ) ; if ( v ) { partial . push ( quote ( k ) + ( gap ? ': ' : ':' ) + v ) ; } } } }
v = partial . length === 0 ? '{}' : gap ? '{\n' + gap + partial . join ( ',\n' + gap ) + '\n' + mind + '}' : '{' + partial . join ( ',' ) + '}' ; gap = mind ; return v ; } }
if ( typeof JSON . stringify !== 'function' ) { JSON . stringify = function ( value , replacer , space ) { var i ; gap = '' ; indent = '' ; if ( typeof space === 'number' ) { for ( i = 0 ; i < space ; i += 1 ) { indent += ' ' ; } } else if ( typeof space === 'string' ) { indent = space ; }
rep = replacer ; if ( replacer && typeof replacer !== 'function' && ( typeof replacer !== 'object' || typeof replacer . length !== 'number' ) ) { throw new Error ( 'JSON.stringify' ) ; }
return str ( '' , { '' : value } ) ; } ; }
if ( typeof JSON . parse !== 'function' ) { JSON . parse = function ( text , reviver ) { var j ; function walk ( holder , key ) { var k , v , value = holder [ key ] ; if ( value && typeof value === 'object' ) { for ( k in value ) { if ( Object . prototype . hasOwnProperty . call ( value , k ) ) { v = walk ( value , k ) ; if ( v !== undefined ) { value [ k ] = v ; } else { delete value [ k ] ; } } } }
return reviver . call ( holder , key , value ) ; }
text = String ( text ) ; cx . lastIndex = 0 ; if ( cx . test ( text ) ) { text = text . replace ( cx , function ( a ) { return '\\u' +
( '0000' + a . charCodeAt ( 0 ) . toString ( 16 ) ) . slice ( - 4 ) ; } ) ; }
if ( /^[\],:{}\s]*$/ . test ( text . replace ( /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g , '@' ) . replace ( /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g , ']' ) . replace ( /(?:^|:|,)(?:\s*\[)+/g , '' ) ) ) { j = eval ( '(' + text + ')' ) ; return typeof reviver === 'function' ? walk ( { '' : j } , '' ) : j ; }
throw new SyntaxError ( 'JSON.parse' ) ; } ; } } ( ) ) ;
/ *
* lib / js / core . js
* /
wn . versions . check ( ) ; $ ( document ) . bind ( 'ready' , function ( ) { var base = window . location . href . split ( '#' ) [ 0 ] ; $ . each ( $ ( 'a[softlink!="false"]' ) , function ( i , v ) { if ( v . href . substr ( 0 , base . length ) == base ) { var path = ( v . href . substr ( base . length ) ) ; if ( path . substr ( 0 , 1 ) != '#' ) { v . href = base + '#' + path ; } } } ) ; if ( ! wn . settings . no _history && window . location . hash ) { wn . page . set ( window . location . hash . substr ( 1 ) ) ; } } ) ;
/ *
* lib / js / legacy / globals . js
* /
wn . provide ( 'wn.widgets.form' ) ; wn . provide ( 'wn.widgets.report' ) ; wn . provide ( 'wn.utils' ) ; wn . provide ( 'wn.model' ) ; wn . provide ( 'wn.profile' ) ; wn . provide ( 'wn.session' ) ; wn . provide ( '_f' ) ; wn . provide ( '_p' ) ; wn . provide ( '_r' ) ; wn . provide ( '_c' ) ; wn . provide ( '_e' ) ; wn . provide ( '_startup_data' )
2012-02-17 08:34:55 +00:00
wn . settings . no _history = 1 ; var NEWLINE = '\n' ; var login _file = '' ; var version = 'v170' ; var profile = null ; var session = { } ; var is _testing = false ; var user = null ; var user _defaults = null ; var user _roles = null ; var user _fullname = null ; var user _email = null ; var user _img = { } ; var home _page = null ; var hide _autosuggest = null ; var page _body = null ; var pscript = { } ; var selector = null ; var top _index = 91 ; var _f = { } ; var _p = { } ; var _e = { } ; var _r = { } ; var FILTER _SEP = '\1' ; var _c = { } ; var widget _files = { '_f.FrmContainer' : 'form.compressed.js' , '_c.CalendarPopup' : 'widgets/form/date_picker.js' , '_r.ReportContainer' : 'report.compressed.js' , '_p.PrintQuery' : 'widgets/print_query.js' , 'Calendar' : 'widgets/calendar.js' , 'Recommendation' : 'widgets/recommend.js' , 'RatingWidget' : 'widgets/rating.js' }
2012-02-15 08:32:20 +00:00
var frms = { } ; var cur _frm = null ; var pscript = { } ; var validated = true ; var validation _message = '' ; var tinymce _loaded = null ; var cur _autosug = null ; if ( ! console ) { var console = { log : function ( txt ) { errprint ( txt ) ; } } }
2012-02-14 06:14:13 +00:00
/ *
* lib / js / legacy / utils / datatype . js
* /
var startup _list = [ ] ; wn . utils . full _name = function ( fn , ln ) { return fn + ( ln ? ' ' : '' ) + ( ln ? ln : '' ) }
function fmt _money ( v ) { if ( v == null || v == '' ) return '0.00' ; v = ( v + '' ) . replace ( /,/g , '' ) ; v = parseFloat ( v ) ; if ( isNaN ( v ) ) { return '' ; } else { var cp = wn . control _panel ; var val = 2 ; if ( cp . currency _format == 'Millions' ) val = 3 ; v = v . toFixed ( 2 ) ; var delimiter = "," ; amount = v + '' ; var a = amount . split ( '.' , 2 )
var d = a [ 1 ] ; var i = parseInt ( a [ 0 ] ) ; if ( isNaN ( i ) ) { return '' ; }
var minus = '' ; if ( v < 0 ) { minus = '-' ; }
i = Math . abs ( i ) ; var n = new String ( i ) ; var a = [ ] ; if ( n . length > 3 )
{ var nn = n . substr ( n . length - 3 ) ; a . unshift ( nn ) ; n = n . substr ( 0 , n . length - 3 ) ; while ( n . length > val )
{ var nn = n . substr ( n . length - val ) ; a . unshift ( nn ) ; n = n . substr ( 0 , n . length - val ) ; } }
if ( n . length > 0 ) { a . unshift ( n ) ; }
n = a . join ( delimiter ) ; if ( d . length < 1 ) { amount = n ; }
else { amount = n + '.' + d ; }
amount = minus + amount ; return amount ; } }
function toTitle ( str ) { var word _in = str . split ( " " ) ; var word _out = [ ] ; for ( w in word _in ) { word _out [ w ] = word _in [ w ] . charAt ( 0 ) . toUpperCase ( ) + word _in [ w ] . slice ( 1 ) ; }
return word _out . join ( " " ) ; }
function is _null ( v ) { if ( v == null ) { return 1 } else if ( v == 0 ) { if ( ( v + '' ) . length >= 1 ) return 0 ; else return 1 ; } else { return 0 } }
function $s ( ele , v , ftype , fopt ) { if ( v == null ) v = '' ; if ( ftype == 'Text' || ftype == 'Small Text' ) { ele . innerHTML = v ? v . replace ( /\n/g , '<br>' ) : '' ; } else if ( ftype == 'Date' ) { v = dateutil . str _to _user ( v ) ; if ( v == null ) v = ''
ele . innerHTML = v ; } else if ( ftype == 'Link' && fopt ) { ele . innerHTML = '' ; doc _link ( ele , fopt , v ) ; } else if ( ftype == 'Currency' ) { ele . style . textAlign = 'right' ; if ( is _null ( v ) )
ele . innerHTML = '' ; else
ele . innerHTML = fmt _money ( v ) ; } else if ( ftype == 'Int' ) { ele . style . textAlign = 'right' ; ele . innerHTML = v ; } else if ( ftype == 'Check' ) { if ( v ) ele . innerHTML = '<img src="lib/images/ui/tick.gif">' ; else ele . innerHTML = '' ; } else { ele . innerHTML = v ; } }
function clean _smart _quotes ( s ) { if ( s ) { s = s . replace ( /\u2018/g , "'" ) ; s = s . replace ( /\u2019/g , "'" ) ; s = s . replace ( /\u201c/g , '"' ) ; s = s . replace ( /\u201d/g , '"' ) ; s = s . replace ( /\u2013/g , '-' ) ; s = s . replace ( /\u2014/g , '--' ) ; }
return s ; }
function copy _dict ( d ) { var n = { } ; for ( var k in d ) n [ k ] = d [ k ] ; return n ; }
function $p ( ele , top , left ) { ele . style . position = 'absolute' ; ele . style . top = top + 'px' ; ele . style . left = left + 'px' ; }
function replace _newlines ( t ) { return t ? t . replace ( /\n/g , '<br>' ) : '' ; }
function cstr ( s ) { if ( s == null ) return '' ; return s + '' ; }
function flt ( v , decimals ) { if ( v == null || v == '' ) return 0 ; v = ( v + '' ) . replace ( /,/g , '' ) ; v = parseFloat ( v ) ; if ( isNaN ( v ) )
v = 0 ; if ( decimals != null )
return v . toFixed ( decimals ) ; return v ; }
function esc _quotes ( s ) { if ( s == null ) s = '' ; return s . replace ( /'/ , "\'" ) ; }
var crop = function ( s , len ) { if ( s . length > len )
return s . substr ( 0 , len - 3 ) + '...' ; else
return s ; }
var strip = function ( s , chars ) { var s = lstrip ( s , chars )
s = rstrip ( s , chars ) ; return s ; }
var lstrip = function ( s , chars ) { if ( ! chars ) chars = [ '\n' , '\t' , ' ' ] ; var first _char = s . substr ( 0 , 1 ) ; while ( in _list ( chars , first _char ) ) { var s = s . substr ( 1 ) ; first _char = s . substr ( 0 , 1 ) ; }
return s ; }
var rstrip = function ( s , chars ) { if ( ! chars ) chars = [ '\n' , '\t' , ' ' ] ; var last _char = s . substr ( s . length - 1 ) ; while ( in _list ( chars , last _char ) ) { var s = s . substr ( 0 , this . length - 1 ) ; last _char = s . substr ( this . length - 1 ) ; }
return s ; }
function repl _all ( s , s1 , s2 ) { var idx = s . indexOf ( s1 ) ; while ( idx != - 1 ) { s = s . replace ( s1 , s2 ) ; idx = s . indexOf ( s1 ) ; }
return s ; }
function repl ( s , dict ) { if ( s == null ) return '' ; for ( key in dict ) s = repl _all ( s , '%(' + key + ')s' , dict [ key ] ) ; return s ; }
function keys ( obj ) { var mykeys = [ ] ; for ( key in obj ) mykeys [ mykeys . length ] = key ; return mykeys ; }
function values ( obj ) { var myvalues = [ ] ; for ( key in obj ) myvalues [ myvalues . length ] = obj [ key ] ; return myvalues ; }
function in _list ( list , item ) { for ( var i = 0 ; i < list . length ; i ++ )
if ( list [ i ] == item ) return true ; return false ; }
function has _common ( list1 , list2 ) { if ( ! list1 || ! list2 ) return false ; for ( var i = 0 ; i < list1 . length ; i ++ ) { if ( in _list ( list2 , list1 [ i ] ) ) return true ; }
return false ; }
var inList = in _list ; function add _lists ( l1 , l2 ) { var l = [ ] ; for ( var k in l1 ) l . push ( l1 [ k ] ) ; for ( var k in l2 ) l . push ( l2 [ k ] ) ; return l ; }
function docstring ( obj ) { var l = [ ] ; for ( key in obj ) { var v = obj [ key ] ; if ( v != null ) { if ( typeof ( v ) == typeof ( 1 ) ) { l [ l . length ] = "'" + key + "':" + ( v + '' ) ; } else { v = v + '' ; l [ l . length ] = "'" + key + "':'" + v . replace ( /'/g , "\\'" ) . replace ( /\n/g , "\\n" ) + "'" ; } } }
return "{" + l . join ( ',' ) + '}' ; }
function DocLink ( p , doctype , name , onload ) { var a = $a ( p , 'span' , 'link_type' ) ; a . innerHTML = a . dn = name ; a . dt = doctype ; a . onclick = function ( ) { loaddoc ( this . dt , this . dn , onload ) } ; return a ; }
var doc _link = DocLink ; var known _numbers = { 0 : 'zero' , 1 : 'one' , 2 : 'two' , 3 : 'three' , 4 : 'four' , 5 : 'five' , 6 : 'six' , 7 : 'seven' , 8 : 'eight' , 9 : 'nine' , 10 : 'ten' , 11 : 'eleven' , 12 : 'twelve' , 13 : 'thirteen' , 14 : 'fourteen' , 15 : 'fifteen' , 16 : 'sixteen' , 17 : 'seventeen' , 18 : 'eighteen' , 19 : 'nineteen' , 20 : 'twenty' , 30 : 'thirty' , 40 : 'forty' , 50 : 'fifty' , 60 : 'sixty' , 70 : 'seventy' , 80 : 'eighty' , 90 : 'ninety' }
function in _words ( n ) { var is _million = wn . control _panel . currency _format == 'Millions' ? 1 : 0 ; n = cint ( n )
if ( known _numbers [ n ] ) return known _numbers [ n ] ; var bestguess = n + '' ; var remainder = 0
if ( n <= 20 )
alert ( 'Error while converting to words' ) ; else if ( n < 100 ) { return in _words ( Math . floor ( n / 10 ) * 10 ) + '-' + in _words ( n % 10 ) ; } else if ( n < 1000 ) { bestguess = in _words ( Math . floor ( n / 100 ) ) + ' ' + 'hundred' ; remainder = n % 100 ; } else if ( ! is _million ) { if ( n < 100000 ) { bestguess = in _words ( Math . floor ( n / 1000 ) ) + ' ' + 'thousand' ; remainder = n % 1000 ; } else if ( n < 10000000 ) { bestguess = in _words ( Math . floor ( n / 100000 ) ) + ' ' + 'lakh' ; remainder = n % 100000 ; } else { bestguess = in _words ( Math . floor ( n / 10000000 ) ) + ' ' + 'crore'
remainder = n % 10000000 } } else { if ( n < 1000000 ) { bestguess = in _words ( Math . floor ( n / 1000 ) ) + ' ' + 'thousand' ; remainder = n % 1000 ; } else if ( n < 1000000000 ) { bestguess = in _words ( Math . floor ( n / 1000000 ) ) + ' ' + 'million' ; remainder = n % 1000000 ; } else { bestguess = in _words ( Math . floor ( n / 1000000000 ) ) + ' ' + 'billion'
remainder = n % 1000000000 } }
if ( remainder ) { if ( remainder >= 100 ) comma = ','
else comma = ''
return bestguess + comma + ' ' + in _words ( remainder ) ; } else { return bestguess ; } }
function roundNumber ( num , dec ) { var result = Math . round ( num * Math . pow ( 10 , dec ) ) / Math . pow ( 10 , dec ) ; return result ; }
/ *
* lib / js / legacy / utils / browser _detect . js
* /
var appVer = navigator . appVersion . toLowerCase ( ) ; var is _minor = parseFloat ( appVer ) ; var is _major = parseInt ( is _minor ) ; var iePos = appVer . indexOf ( 'msie' ) ; if ( iePos != - 1 ) { is _minor = parseFloat ( appVer . substring ( iePos + 5 , appVer . indexOf ( ';' , iePos ) ) )
is _major = parseInt ( is _minor ) ; }
var isIE = ( iePos != - 1 ) ; var isIE6 = ( isIE && is _major <= 6 ) ; var isIE7 = ( isIE && is _major >= 7 ) ; if ( /Firefox[\/\s](\d+\.\d+)/ . test ( navigator . userAgent ) ) { var isFF = 1 ; var ffversion = new Number ( RegExp . $1 )
if ( ffversion >= 3 ) var isFF3 = 1 ; else if ( ffversion >= 2 ) var isFF2 = 1 ; else if ( ffversion >= 1 ) var isFF1 = 1 ; }
var isSafari = navigator . userAgent . indexOf ( 'Safari' ) != - 1 ? 1 : 0 ; var isChrome = navigator . userAgent . indexOf ( 'Chrome' ) != - 1 ? 1 : 0 ;
/ *
* lib / js / legacy / utils / datetime . js
* /
function same _day ( d1 , d2 ) { if ( d1 . getFullYear ( ) == d2 . getFullYear ( ) && d1 . getMonth ( ) == d2 . getMonth ( ) && d1 . getDate ( ) == d2 . getDate ( ) ) return true ; else return false ; }
var month _list = [ 'Jan' , 'Feb' , 'Mar' , 'Apr' , 'May' , 'Jun' , 'Jul' , 'Aug' , 'Sep' , 'Oct' , 'Nov' , 'Dec' ] ; var month _last = { 1 : 31 , 2 : 28 , 3 : 31 , 4 : 30 , 5 : 31 , 6 : 30 , 7 : 31 , 8 : 31 , 9 : 30 , 10 : 31 , 11 : 30 , 12 : 31 }
var month _list _full = [ 'January' , 'February' , 'March' , 'April' , 'May' , 'June' , 'July' , 'August' , 'September' , 'October' , 'November' , 'December' ] ; var week _list = [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thu' , 'Fri' , 'Sat' ] ; var week _list _full = [ 'Sunday' , 'Monday' , 'Tuesday' , 'Wednesday' , 'Thursday' , 'Friday' , 'Saturday' ] ; function int _to _str ( i , len ) { i = '' + i ; if ( i . length < len ) for ( c = 0 ; c < ( len - i . length ) ; c ++ ) i = '0' + i ; return i }
wn . datetime = { str _to _obj : function ( d ) { if ( ! d ) return new Date ( ) ; var tm = [ null , null ] ; if ( d . search ( ' ' ) != - 1 ) { var tm = d . split ( ' ' ) [ 1 ] . split ( ':' ) ; var d = d . split ( ' ' ) [ 0 ] ; }
if ( d . search ( '-' ) != - 1 ) { var t = d . split ( '-' ) ; return new Date ( t [ 0 ] , t [ 1 ] - 1 , t [ 2 ] , tm [ 0 ] , tm [ 1 ] ) ; } else if ( d . search ( '/' ) != - 1 ) { var t = d . split ( '/' ) ; return new Date ( t [ 0 ] , t [ 1 ] - 1 , t [ 2 ] , tm [ 0 ] , tm [ 1 ] ) ; } else { return new Date ( ) ; } } , obj _to _str : function ( d ) { return d . getFullYear ( ) + '-' + int _to _str ( d . getMonth ( ) + 1 , 2 ) + '-' + int _to _str ( d . getDate ( ) , 2 ) ; } , obj _to _user : function ( d ) { return dateutil . str _to _user ( dateutil . obj _to _str ( d ) ) ; } , get _diff : function ( d1 , d2 ) { return ( ( d1 - d2 ) / 86400000 ) ; } , add _days : function ( d , days ) { d . setTime ( d . getTime ( ) + ( days * 24 * 60 * 60 * 1000 ) ) ; return d } , add _months : function ( d , months ) { dt = dateutil . str _to _obj ( d )
new _dt = new Date ( dt . getFullYear ( ) , dt . getMonth ( ) + months , dt . getDate ( ) )
if ( new _dt . getDate ( ) != dt . getDate ( ) ) { return dateutil . month _end ( new Date ( dt . getFullYear ( ) , dt . getMonth ( ) + months , 1 ) ) }
return dateutil . obj _to _str ( new _dt ) ; } , month _start : function ( ) { var d = new Date ( ) ; return d . getFullYear ( ) + '-' + int _to _str ( d . getMonth ( ) + 1 , 2 ) + '-01' ; } , month _end : function ( d ) { if ( ! d ) var d = new Date ( ) ; var m = d . getMonth ( ) + 1 ; var y = d . getFullYear ( ) ; last _date = month _last [ m ] ; if ( m == 2 && ( y % 4 ) == 0 && ( ( y % 100 ) != 0 || ( y % 400 ) == 0 ) )
last _date = 29 ; return y + '-' + int _to _str ( m , 2 ) + '-' + last _date ; } , get _user _fmt : function ( ) { var t = wn . control _panel . date _format ; if ( ! t ) t = 'dd-mm-yyyy' ; return t ; } , str _to _user : function ( val , no _time _str ) { var user _fmt = dateutil . get _user _fmt ( ) ; var time _str = '' ; if ( val == null || val == '' ) return null ; if ( val . search ( ':' ) != - 1 ) { var tmp = val . split ( ' ' ) ; if ( tmp [ 1 ] )
time _str = ' ' + tmp [ 1 ] ; var d = tmp [ 0 ] ; } else { var d = val ; }
if ( no _time _str ) time _str = '' ; d = d . split ( '-' ) ; if ( d . length == 3 ) { if ( user _fmt == 'dd-mm-yyyy' )
val = d [ 2 ] + '-' + d [ 1 ] + '-' + d [ 0 ] + time _str ; else if ( user _fmt == 'dd/mm/yyyy' )
val = d [ 2 ] + '/' + d [ 1 ] + '/' + d [ 0 ] + time _str ; else if ( user _fmt == 'yyyy-mm-dd' )
val = d [ 0 ] + '-' + d [ 1 ] + '-' + d [ 2 ] + time _str ; else if ( user _fmt == 'mm/dd/yyyy' )
val = d [ 1 ] + '/' + d [ 2 ] + '/' + d [ 0 ] + time _str ; else if ( user _fmt == 'mm-dd-yyyy' )
val = d [ 1 ] + '-' + d [ 2 ] + '-' + d [ 0 ] + time _str ; }
return val ; } , full _str : function ( ) { var d = new Date ( ) ; return d . getFullYear ( ) + '-' + ( d . getMonth ( ) + 1 ) + '-' + d . getDate ( ) + ' '
+ d . getHours ( ) + ':' + d . getMinutes ( ) + ':' + d . getSeconds ( ) ; } , user _to _str : function ( d ) { var user _fmt = this . get _user _fmt ( ) ; if ( user _fmt == 'dd-mm-yyyy' ) { var d = d . split ( '-' ) ; return d [ 2 ] + '-' + d [ 1 ] + '-' + d [ 0 ] ; }
else if ( user _fmt == 'dd/mm/yyyy' ) { var d = d . split ( '/' ) ; return d [ 2 ] + '-' + d [ 1 ] + '-' + d [ 0 ] ; }
else if ( user _fmt == 'yyyy-mm-dd' ) { return d ; }
else if ( user _fmt == 'mm/dd/yyyy' ) { var d = d . split ( '/' ) ; return d [ 2 ] + '-' + d [ 0 ] + '-' + d [ 1 ] ; }
else if ( user _fmt == 'mm-dd-yyyy' ) { var d = d . split ( '-' ) ; return d [ 2 ] + '-' + d [ 0 ] + '-' + d [ 1 ] ; } } , global _date _format : function ( d ) { if ( d . substr ) d = this . str _to _obj ( d ) ; return d . getDate ( ) + ' ' + month _list _full [ d . getMonth ( ) ] + ' ' + d . getFullYear ( ) ; } , get _today : function ( ) { var today = new Date ( ) ; var m = ( today . getMonth ( ) + 1 ) + '' ; if ( m . length == 1 ) m = '0' + m ; var d = today . getDate ( ) + '' ; if ( d . length == 1 ) d = '0' + d ; return today . getFullYear ( ) + '-' + m + '-' + d ; } , get _cur _time : function ( ) { var d = new Date ( ) ; var hh = d . getHours ( ) + ''
var mm = cint ( d . getMinutes ( ) / 5 ) * 5 + ''
return ( hh . length == 1 ? '0' + hh : hh ) + ':' + ( mm . length == 1 ? '0' + mm : mm ) ; } }
wn . datetime . only _date = function ( val ) { if ( val == null || val == '' ) return null ; if ( val . search ( ':' ) != - 1 ) { var tmp = val . split ( ' ' ) ; var d = tmp [ 0 ] . split ( '-' ) ; } else { var d = val . split ( '-' ) ; }
if ( d . length == 3 )
val = d [ 2 ] + '-' + d [ 1 ] + '-' + d [ 0 ] ; return val ; }
wn . datetime . time _to _ampm = function ( v ) { if ( ! v ) { var d = new Date ( ) ; var t = [ d . getHours ( ) , cint ( d . getMinutes ( ) / 5 ) * 5 ] } else { var t = v . split ( ':' ) ; }
if ( t . length != 2 ) { show _alert ( '[set_time] Incorect time format' ) ; return ; }
if ( cint ( t [ 0 ] ) == 0 ) var ret = [ '12' , t [ 1 ] , 'AM' ] ; else if ( cint ( t [ 0 ] ) < 12 ) var ret = [ cint ( t [ 0 ] ) + '' , t [ 1 ] , 'AM' ] ; else if ( cint ( t [ 0 ] ) == 12 ) var ret = [ '12' , t [ 1 ] , 'PM' ] ; else var ret = [ ( cint ( t [ 0 ] ) - 12 ) + '' , t [ 1 ] , 'PM' ] ; return ret ; }
wn . datetime . time _to _hhmm = function ( hh , mm , am ) { if ( am == 'AM' && hh == '12' ) { hh = '00' ; } else if ( am == 'PM' && hh != '12' ) { hh = cint ( hh ) + 12 ; }
return hh + ':' + mm ; }
function prettyDate ( time ) { if ( ! time ) return ''
var date = new Date ( ( time || "" ) . replace ( /-/g , "/" ) . replace ( /[TZ]/g , " " ) . replace ( /\.[0-9]*/ , "" ) ) , diff = ( ( ( new Date ( ) ) . getTime ( ) - date . getTime ( ) ) / 1000 ) , day _diff = Math . floor ( diff / 86400 ) ; if ( isNaN ( day _diff ) || day _diff < 0 )
return '' ; return day _diff == 0 && ( diff < 60 && "just now" || diff < 120 && "1 minute ago" || diff < 3600 && Math . floor ( diff / 60 ) + " minutes ago" || diff < 7200 && "1 hour ago" || diff < 86400 && Math . floor ( diff / 3600 ) + " hours ago" ) || day _diff == 1 && "Yesterday" || day _diff < 7 && day _diff + " days ago" || day _diff < 31 && Math . ceil ( day _diff / 7 ) + " weeks ago" || day _diff < 365 && Math . ceil ( day _diff / 30 ) + " months ago" || "more than " + Math . floor ( day _diff / 365 ) + " year(s) ago" ; }
if ( typeof jQuery != "undefined" )
jQuery . fn . prettyDate = function ( ) { return this . each ( function ( ) { var date = prettyDate ( this . title ) ; if ( date )
jQuery ( this ) . text ( date ) ; } ) ; } ; var comment _when = prettyDate ; wn . datetime . comment _when = prettyDate ; var date = dateutil = wn . datetime ; var get _today = wn . datetime . get _today
var time _to _ampm = wn . datetime . time _to _ampm ; var time _to _hhmm = wn . datetime . time _to _hhmm ; var only _date = wn . datetime . only _date ;
/ *
* lib / js / legacy / utils / dom . js
* /
wn . dom . set _unique _id = function ( ele ) { var id = 'unique-' + wn . dom . id _count ; ele . setAttribute ( 'id' , id ) ; wn . dom . id _count ++ ; return id ; }
wn . tinymce = { add _simple : function ( ele , height ) { if ( ele . myid ) { tinyMCE . execCommand ( 'mceAddControl' , true , ele . myid ) ; return ; }
ele . myid = wn . dom . set _unique _id ( ele ) ; $ ( ele ) . tinymce ( { script _url : 'lib/js/legacy/tiny_mce_33/tiny_mce.js' , height : height ? height : '200px' , theme : "advanced" , theme _advanced _buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,link,unlink,forecolor,backcolor,code," , theme _advanced _buttons2 : "" , theme _advanced _buttons3 : "" , theme _advanced _toolbar _location : "top" , theme _advanced _toolbar _align : "left" , theme _advanced _path : false , theme _advanced _resizing : false } ) ; } , remove : function ( ele ) { tinyMCE . execCommand ( 'mceRemoveControl' , true , ele . myid ) ; } , get _value : function ( ele ) { return tinymce . get ( ele . myid ) . getContent ( ) ; } }
wn . ele = { link : function ( args ) { var span = $a ( args . parent , 'span' , 'link_type' , args . style ) ; span . loading _img = $a ( args . parent , 'img' , '' , { margin : '0px 4px -2px 4px' , display : 'none' } ) ; span . loading _img . src = 'lib/images/ui/button-load.gif' ; span . innerHTML = args . label ; span . user _onclick = args . onclick ; span . onclick = function ( ) { if ( ! this . disabled ) this . user _onclick ( this ) ; }
span . set _working = function ( ) { this . disabled = 1 ; $di ( this . loading _img ) ; }
span . done _working = function ( ) { this . disabled = 0 ; $dh ( this . loading _img ) ; }
return span ; } }
function $ln ( parent , label , onclick , style ) { return wn . ele . link ( { parent : parent , label : label , onclick : onclick , style : style } ) }
function $btn ( parent , label , onclick , style , css _class , is _ajax ) { wn . require ( 'lib/js/wn/ui/button.js' ) ; if ( css _class === 'green' ) css _class = 'primary' ; return new wn . ui . Button ( { parent : parent , label : label , onclick : onclick , style : style , is _ajax : is _ajax , css _class : css _class } ) . btn ; }
$item _normal = function ( ele ) { $y ( ele , { padding : '6px 8px' , cursor : 'pointer' , marginRight : '8px' , whiteSpace : 'nowrap' , overflow : 'hidden' , borderBottom : '1px solid #DDD' } ) ; $bg ( ele , '#FFF' ) ; $fg ( ele , '#000' ) ; }
$item _active = function ( ele ) { $bg ( ele , '#FE8' ) ; $fg ( ele , '#000' ) ; }
$item _selected = function ( ele ) { $bg ( ele , '#777' ) ; $fg ( ele , '#FFF' ) ; }
$item _pressed = function ( ele ) { $bg ( ele , '#F90' ) ; $fg ( ele , '#FFF' ) ; } ; ( function ( $ ) { $ . fn . set _working = function ( ) { var ele = this . get ( 0 ) ; if ( ele . loading _img ) { $di ( ele . loading _img ) } else { ele . disabled = 1 ; ele . loading _img = $a ( ele . parentNode , 'img' , '' , { marginLeft : '4px' , marginBottom : '-2px' , display : 'inline' } ) ; ele . loading _img . src = 'lib/images/ui/button-load.gif' ; } }
$ . fn . done _working = function ( ) { var ele = this . get ( 0 ) ; ele . disabled = 0 ; if ( ele . loading _img ) { $dh ( ele . loading _img ) } ; } } ) ( jQuery ) ; function set _opacity ( ele , ieop ) { var op = ieop / 100 ; if ( ele . filters ) { try { ele . filters . item ( "DXImageTransform.Microsoft.Alpha" ) . opacity = ieop ; } catch ( e ) { ele . style . filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + ieop + ')' ; } } else { ele . style . opacity = op ; } }
$br = function ( ele , r , corners ) { if ( corners ) { var cl = [ 'top-left' , 'top-right' , 'bottom-right' , 'bottom-left' ] ; for ( var i = 0 ; i < 4 ; i ++ ) { if ( corners [ i ] ) { $ ( ele ) . css ( '-moz-border-radius-' + cl [ i ] . replace ( '-' , '' ) , r ) . css ( '-webkit-' + cl [ i ] + '-border-radius' , r ) ; } } } else { $ ( ele ) . css ( '-moz-border-radius' , r ) . css ( '-webkit-border-radius' , r ) . css ( 'border-radius' , r ) ; } }
$bs = function ( ele , r ) { $ ( ele ) . css ( '-moz-box-shadow' , r ) . css ( '-webkit-box-shadow' , r ) . css ( 'box-shadow' , r ) ; }
function empty _select ( s ) { if ( s . custom _select ) { s . empty ( ) ; return ; }
if ( s . inp ) s = s . inp ; if ( s ) { var tmplen = s . length ; for ( var i = 0 ; i < tmplen ; i ++ ) s . options [ 0 ] = null ; } }
function sel _val ( s ) { if ( s . custom _select ) { return s . inp . value ? s . inp . value : '' ; }
if ( s . inp ) s = s . inp ; try { if ( s . selectedIndex < s . options . length ) return s . options [ s . selectedIndex ] . value ; else return '' ; } catch ( err ) { return '' ; } }
function add _sel _options ( s , list , sel _val , o _style ) { if ( s . custom _select ) { s . set _options ( list )
if ( sel _val ) s . inp . value = sel _val ; return ; }
if ( s . inp ) s = s . inp ; for ( var i = 0 , len = list . length ; i < len ; i ++ ) { var o = new Option ( list [ i ] , list [ i ] , false , ( list [ i ] == sel _val ? true : false ) ) ; if ( o _style ) $y ( o , o _style ) ; s . options [ s . options . length ] = o ; } }
function cint ( v , def ) { v = v + '' ; v = lstrip ( v , [ '0' ] ) ; v = parseInt ( v ) ; if ( isNaN ( v ) ) v = def ? def : 0 ; return v ; }
function validate _email ( id ) { if ( strip ( id ) . search ( "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?" ) == - 1 ) return 0 ; else return 1 ; }
function validate _spl _chars ( txt ) { if ( txt . search ( /^[a-zA-Z0-9_\- ]*$/ ) == - 1 ) return 1 ; else return 0 ; }
function d2h ( d ) { return cint ( d ) . toString ( 16 ) ; }
function h2d ( h ) { return parseInt ( h , 16 ) ; }
var $n = '\n' ; function set _title ( t ) { document . title = ( wn . title _prefix ? ( wn . title _prefix + ' - ' ) : '' ) + t ; }
function $a ( parent , newtag , className , cs , innerHTML , onclick ) { if ( parent && parent . substr ) parent = $i ( parent ) ; var c = document . createElement ( newtag ) ; if ( parent )
parent . appendChild ( c ) ; if ( className ) { if ( newtag . toLowerCase ( ) == 'img' )
c . src = className
else
c . className = className ; }
if ( cs ) $y ( c , cs ) ; if ( innerHTML ) c . innerHTML = innerHTML ; if ( onclick ) c . onclick = onclick ; return c ; }
2012-02-17 08:34:55 +00:00
function $a _input ( p , in _type , attributes , cs ) { if ( ! attributes ) attributes = { } ; var $input = $ ( p ) . append ( '<input type="' + in _type + '">' ) . find ( 'input:last' ) ; for ( key in attributes )
$input . attr ( key , attributes [ key ] ) ; var input = $input . get ( 0 ) ; if ( cs )
$y ( input , cs ) ; return input ; }
2012-02-14 06:14:13 +00:00
function $dh ( d ) { if ( d && d . substr ) d = $i ( d ) ; if ( d && d . style . display . toLowerCase ( ) != 'none' ) d . style . display = 'none' ; }
function $ds ( d ) { if ( d && d . substr ) d = $i ( d ) ; var t = 'block' ; if ( d && in _list ( [ 'span' , 'img' , 'button' ] , d . tagName . toLowerCase ( ) ) )
t = 'inline'
if ( d && d . style . display . toLowerCase ( ) != t )
d . style . display = t ; }
function $di ( d ) { if ( d && d . substr ) d = $i ( d ) ; if ( d ) d . style . display = 'inline' ; }
function $i ( id ) { if ( ! id ) return null ; if ( id && id . appendChild ) return id ; return document . getElementById ( id ) ; }
function $t ( parent , txt ) { if ( parent . substr ) parent = $i ( parent ) ; return parent . appendChild ( document . createTextNode ( txt ) ) ; }
function $w ( e , w ) { if ( e && e . style && w ) e . style . width = w ; }
function $h ( e , h ) { if ( e && e . style && h ) e . style . height = h ; }
function $bg ( e , w ) { if ( e && e . style && w ) e . style . backgroundColor = w ; }
function $fg ( e , w ) { if ( e && e . style && w ) e . style . color = w ; }
function $op ( e , w ) { if ( e && e . style && w ) { set _opacity ( e , w ) ; } }
function $y ( ele , s ) { if ( ele && s ) { for ( var i in s ) ele . style [ i ] = s [ i ] ; } ; return ele ; }
function $yt ( tab , r , c , s ) { var rmin = r ; var rmax = r ; if ( r == '*' ) { rmin = 0 ; rmax = tab . rows . length - 1 ; }
if ( r . search && r . search ( '-' ) != - 1 ) { r = r . split ( '-' ) ; rmin = cint ( r [ 0 ] ) ; rmax = cint ( r [ 1 ] ) ; }
var cmin = c ; var cmax = c ; if ( c == '*' ) { cmin = 0 ; cmax = tab . rows [ 0 ] . cells . length - 1 ; }
if ( c . search && c . search ( '-' ) != - 1 ) { c = c . split ( '-' ) ; rmin = cint ( c [ 0 ] ) ; rmax = cint ( c [ 1 ] ) ; }
for ( var ri = rmin ; ri <= rmax ; ri ++ ) { for ( var ci = cmin ; ci <= cmax ; ci ++ )
$y ( $td ( tab , ri , ci ) , s ) ; } }
function set _style ( txt ) { var se = document . createElement ( 'style' ) ; se . type = "text/css" ; if ( se . styleSheet ) { se . styleSheet . cssText = txt ; } else { se . appendChild ( document . createTextNode ( txt ) ) ; }
document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( se ) ; }
function make _table ( parent , nr , nc , table _width , widths , cell _style , table _style ) { var t = $a ( parent , 'table' ) ; t . style . borderCollapse = 'collapse' ; if ( table _width ) t . style . width = table _width ; if ( cell _style ) t . cell _style = cell _style ; for ( var ri = 0 ; ri < nr ; ri ++ ) { var r = t . insertRow ( ri ) ; for ( var ci = 0 ; ci < nc ; ci ++ ) { var c = r . insertCell ( ci ) ; if ( ri == 0 && widths && widths [ ci ] ) { c . style . width = widths [ ci ] ; }
if ( cell _style ) { for ( var s in cell _style ) c . style [ s ] = cell _style [ s ] ; } } }
t . append _row = function ( ) { return append _row ( this ) ; }
if ( table _style ) $y ( t , table _style ) ; return t ; }
function append _row ( t , at , style ) { var r = t . insertRow ( at ? at : t . rows . length ) ; if ( t . rows . length > 1 ) { for ( var i = 0 ; i < t . rows [ 0 ] . cells . length ; i ++ ) { var c = r . insertCell ( i ) ; if ( style ) $y ( c , style ) ; } }
return r }
function $td ( t , r , c ) { if ( r < 0 ) r = t . rows . length + r ; if ( c < 0 ) c = t . rows [ 0 ] . cells . length + c ; return t . rows [ r ] . cells [ c ] ; }
function $sum ( t , cidx ) { var s = 0 ; if ( cidx < 1 ) cidx = t . rows [ 0 ] . cells . length + cidx ; for ( var ri = 0 ; ri < t . rows . length ; ri ++ ) { var c = t . rows [ ri ] . cells [ cidx ] ; if ( c . div ) s += flt ( c . div . innerHTML ) ; else if ( c . value ) s += flt ( c . value ) ; else s += flt ( c . innerHTML ) ; }
return s ; }
function objpos ( obj ) { if ( obj . substr ) obj = $i ( obj ) ; var p = $ ( obj ) . offset ( ) ; return { x : cint ( p . left ) , y : cint ( p . top ) } }
function get _screen _dims ( ) { var d = { } ; d . w = 0 ; d . h = 0 ; if ( typeof ( window . innerWidth ) == 'number' ) { d . w = window . innerWidth ; d . h = window . innerHeight ; } else if ( document . documentElement && ( document . documentElement . clientWidth || document . documentElement . clientHeight ) ) { d . w = document . documentElement . clientWidth ; d . h = document . documentElement . clientHeight ; } else if ( document . body && ( document . body . clientWidth || document . body . clientHeight ) ) { d . w = document . body . clientWidth ; d . h = document . body . clientHeight ; }
return d }
function get _page _size ( ) { return [ $ ( document ) . height ( ) , $ ( document ) . width ( ) ] ; }
function get _scroll _top ( ) { var st = 0 ; if ( document . documentElement && document . documentElement . scrollTop )
st = document . documentElement . scrollTop ; else if ( document . body && document . body . scrollTop )
st = document . body . scrollTop ; return st ; }
function get _cookie ( c ) { var t = "" + document . cookie ; var ind = t . indexOf ( c ) ; if ( ind == - 1 || c == "" ) return "" ; var ind1 = t . indexOf ( ';' , ind ) ; if ( ind1 == - 1 ) ind1 = t . length ; return unescape ( t . substring ( ind + c . length + 1 , ind1 ) ) ; }
wn . urllib = { get _arg : function ( name ) { name = name . replace ( /[\[]/ , "\\\[" ) . replace ( /[\]]/ , "\\\]" ) ; var regexS = "[\\?&]" + name + "=([^&#]*)" ; var regex = new RegExp ( regexS ) ; var results = regex . exec ( window . location . href ) ; if ( results == null )
return "" ; else
return decodeURIComponent ( results [ 1 ] ) ; } , get _dict : function ( ) { var d = { }
var t = window . location . href . split ( '?' ) [ 1 ] ; if ( ! t ) return d ; if ( t . indexOf ( '#' ) != - 1 ) t = t . split ( '#' ) [ 0 ] ; if ( ! t ) return d ; t = t . split ( '&' ) ; for ( var i = 0 ; i < t . length ; i ++ ) { var a = t [ i ] . split ( '=' ) ; d [ decodeURIComponent ( a [ 0 ] ) ] = decodeURIComponent ( a [ 1 ] ) ; }
return d ; } , get _base _url : function ( ) { var url = window . location . href . split ( '#' ) [ 0 ] . split ( '?' ) [ 0 ] . split ( 'index.html' ) [ 0 ] ; if ( url . substr ( url . length - 1 , 1 ) == '/' ) url = url . substr ( 0 , url . length - 1 )
2012-02-17 05:08:49 +00:00
return url } , get _file _url : function ( file _id ) { return repl ( 'files/%(fn)s' , { fn : file _id } ) } }
2012-02-14 06:14:13 +00:00
get _url _arg = wn . urllib . get _arg ; get _url _dict = wn . urllib . get _dict ; var user _img = { }
var user _img _queue = { } ; var user _img _loading = [ ] ; set _user _img = function ( img , username , get _latest , img _id ) { function set _it ( i ) { if ( user _img [ username ] == 'no_img_m' )
i . src = 'lib/images/ui/no_img_m.gif' ; else if ( user _img [ username ] == 'no_img_f' )
i . src = 'lib/images/ui/no_img_f.gif' ; else { ac _id = wn . control _panel . account _id ; i . src = repl ( 'cgi-bin/getfile.cgi?ac=%(ac)s&name=%(fn)s' , { fn : user _img [ username ] , ac : ac _id } ) ; } }
if ( img _id ) { user _img [ username ] = img _id ; set _it ( img ) ; return ; }
if ( user _img [ username ] && ! get _latest ) { set _it ( img ) ; } else { if ( in _list ( user _img _loading , username ) ) { if ( ! user _img _queue [ username ] )
user _img _queue [ username ] = [ ] ; user _img _queue [ username ] . push ( img ) ; return ; }
$c ( 'webnotes.profile.get_user_img' , { username : username } , function ( r , rt ) { delete user _img _loading [ user _img _loading . indexOf ( username ) ] ; user _img [ username ] = r . message ; if ( user _img _queue [ username ] ) { var q = user _img _queue [ username ] ; for ( var i in q ) { set _it ( q [ i ] ) ; } }
set _it ( img ) ; } , null , 1 ) ; user _img _loading . push ( username ) ; } }
/ *
* lib / js / legacy / utils / handler . js
* /
var outUrl = "index.cgi" ; var NULL _CHAR = '^\5*' ; function checkResponse ( r , on _timeout , no _spinner , freeze _msg ) { try { if ( r . readyState == 4 && r . status == 200 ) return true ; else return false ; } catch ( e ) { msgprint ( "error:Request timed out, try again" ) ; if ( on _timeout )
on _timeout ( ) ; hide _loading ( ) ; if ( freeze _msg )
unfreeze ( ) ; return false ; } }
var pending _req = 0 ; function newHttpReq ( ) { if ( ! isIE )
var r = new XMLHttpRequest ( ) ; else if ( window . ActiveXObject )
var r = new ActiveXObject ( "Microsoft.XMLHTTP" ) ; return r ; }
function $c ( command , args , fn , on _timeout , no _spinner , freeze _msg , btn ) { var req = newHttpReq ( ) ; ret _fn = function ( ) { if ( checkResponse ( req , on _timeout , no _spinner , freeze _msg ) ) { if ( btn ) $ ( btn ) . done _working ( ) ; if ( ! no _spinner )
hide _loading ( ) ; var rtxt = req . responseText ; try { var r = JSON . parse ( rtxt ) ; } catch ( e ) { msgprint ( 'Handler Exception:' + rtxt ) ; return ; }
if ( freeze _msg ) unfreeze ( ) ; if ( ! validate _session ( r , rtxt ) ) return ; if ( r . exc ) { errprint ( r . exc ) ; console . log ( r . exc ) ; } ; if ( r . server _messages ) { msgprint ( r . server _messages ) ; } ; if ( r . docs ) { LocalDB . sync ( r . docs ) ; }
saveAllowed = true ; if ( fn ) fn ( r , rtxt ) ; } }
if ( btn ) $ ( btn ) . set _working ( ) ; req . onreadystatechange = ret _fn ; req . open ( "POST" , outUrl , true ) ; req . setRequestHeader ( "ENCTYPE" , "multipart/form-data" ) ; req . setRequestHeader ( "Content-Type" , "application/x-www-form-urlencoded; charset=UTF-8" ) ; args [ 'cmd' ] = command ; req . send ( makeArgString ( args ) ) ; if ( ! no _spinner ) set _loading ( ) ; if ( freeze _msg ) freeze ( freeze _msg , 1 ) ; }
function validate _session ( r , rt ) { if ( r . message == 'Logged In' ) { start _sid = get _cookie ( 'sid' ) ; return true ; }
if ( start _sid && start _sid != get _cookie ( 'sid' ) && user && user != 'Guest' ) { page _body . set _session _changed ( ) ; return ; }
if ( r . exc && r . session _status == 'Session Expired' ) { resume _session ( ) ; return ; }
if ( r . exc && r . session _status == 'Logged Out' ) { msgprint ( 'You have been logged out' ) ; setTimeout ( 'redirect_to_login()' , 3000 ) ; return ; }
if ( r . exc && r . exc _type && r . exc _type == 'PermissionError' ) { loadpage ( '_home' ) ; }
return true ; }
function $c _obj ( doclist , method , arg , call _back , no _spinner , freeze _msg , btn ) { var args = { 'method' : method , 'arg' : ( typeof arg == 'string' ? arg : JSON . stringify ( arg ) ) }
if ( typeof doclist == 'string' ) args . doctype = doclist ; else args . docs = compress _doclist ( doclist )
$c ( 'runserverobj' , args , call _back , null , no _spinner , freeze _msg , btn ) ; }
function $c _page ( module , page , method , arg , call _back , no _spinner , freeze _msg , btn ) { if ( arg && ! arg . substr ) arg = JSON . stringify ( arg ) ; $c ( module + '.page.' + page + '.' + page + '.' + method , { 'arg' : arg } , call _back , null , no _spinner , freeze _msg , btn ) ; }
wn . call = function ( args ) { if ( args . module && args . page ) { $c _page ( args . module , args . page , args . method , args . args , args . callback , args . no _spinner , false , args . btn ) ; } else if ( args . docs ) { $c _obj ( args . doc , args . method , args . args , args . callback , args . no _spinner , false , args . btn ) ; } else { $c ( args . method , args . args , args . callback , false , args . no _spinner , false , args . btn ) ; } }
function $c _obj _csv ( doclist , method , arg ) { var args = { }
args . cmd = 'runserverobj' ; args . as _csv = 1 ; args . method = method ; args . arg = arg ; if ( doclist . substr )
args . doctype = doclist ; else
args . docs = compress _doclist ( doclist ) ; open _url _post ( outUrl , args ) ; }
function my _eval ( co ) { var w = window ; if ( ! w . execScript ) { if ( /Gecko/ . test ( navigator . userAgent ) ) { eval ( co , w ) ; } else { eval . call ( w , co ) ; } } else { w . execScript ( co ) ; } }
function makeArgString ( dict ) { var varList = [ ] ; for ( key in dict ) { varList [ varList . length ] = key + '=' + encodeURIComponent ( dict [ key ] ) ; }
return varList . join ( '&' ) ; }
function open _url _post ( URL , PARAMS , new _window ) { var temp = document . createElement ( "form" ) ; temp . action = URL ; temp . method = "POST" ; temp . style . display = "none" ; if ( new _window ) { temp . target = '_blank' ; }
for ( var x in PARAMS ) { var opt = document . createElement ( "textarea" ) ; opt . name = x ; opt . value = PARAMS [ x ] ; temp . appendChild ( opt ) ; }
document . body . appendChild ( temp ) ; temp . submit ( ) ; return temp ; }
/ *
* lib / js / legacy / utils / msgprint . js
* /
var msg _dialog ; function msgprint ( msg , issmall , callback ) { if ( ! msg ) return ; if ( typeof ( msg ) != 'string' )
msg = JSON . stringify ( msg ) ; if ( issmall ) { show _alert ( msg ) ; return ; }
if ( msg . substr ( 0 , 8 ) == '__small:' ) { show _alert ( msg . substr ( 8 ) ) ; return ; }
if ( ! msg _dialog ) { msg _dialog = new Dialog ( 500 , 200 , "Message" ) ; msg _dialog . make _body ( [ [ 'HTML' , 'Msg' ] ] )
msg _dialog . onhide = function ( ) { msg _dialog . msg _area . innerHTML = '' ; $dh ( msg _dialog . msg _icon ) ; if ( msg _dialog . custom _onhide ) msg _dialog . custom _onhide ( ) ; }
$y ( msg _dialog . rows [ 'Msg' ] , { fontSize : '14px' , lineHeight : '1.5em' , padding : '16px' } )
var t = make _table ( msg _dialog . rows [ 'Msg' ] , 1 , 2 , '100%' , [ '20px' , '250px' ] , { padding : '2px' , verticalAlign : 'Top' } ) ; msg _dialog . msg _area = $td ( t , 0 , 1 ) ; msg _dialog . msg _icon = $a ( $td ( t , 0 , 0 ) , 'img' ) ; }
if ( ! msg _dialog . display ) msg _dialog . show ( ) ; var has _msg = msg _dialog . msg _area . innerHTML ? 1 : 0 ; var m = $a ( msg _dialog . msg _area , 'div' , '' ) ; if ( has _msg ) $y ( m , { marginTop : '4px' } ) ; $dh ( msg _dialog . msg _icon ) ; if ( msg . substr ( 0 , 6 ) . toLowerCase ( ) == 'error:' ) { msg _dialog . msg _icon . src = 'lib/images/icons/error.gif' ; $di ( msg _dialog . msg _icon ) ; msg = msg . substr ( 6 ) ; } else if ( msg . substr ( 0 , 8 ) . toLowerCase ( ) == 'message:' ) { msg _dialog . msg _icon . src = 'lib/images/icons/application.gif' ; $di ( msg _dialog . msg _icon ) ; msg = msg . substr ( 8 ) ; } else if ( msg . substr ( 0 , 3 ) . toLowerCase ( ) == 'ok:' ) { msg _dialog . msg _icon . src = 'lib/images/icons/accept.gif' ; $di ( msg _dialog . msg _icon ) ; msg = msg . substr ( 3 ) ; }
m . innerHTML = replace _newlines ( msg ) ; if ( m . offsetHeight > 200 ) { $y ( m , { height : '200px' , width : '400px' , overflow : 'auto' } ) }
msg _dialog . custom _onhide = callback ; }
var growl _area ; function show _alert ( txt ) { if ( ! growl _area ) { growl _area = $a ( popup _cont , 'div' , '' , { position : 'fixed' , bottom : '8px' , right : '8px' , width : '320px' , zIndex : 10 } ) ; }
var wrapper = $a ( growl _area , 'div' , '' , { position : 'relative' } ) ; var body = $a ( wrapper , 'div' , 'notice' ) ; var c = $a ( body , 'div' , 'wn-icon ic-round_delete' , { cssFloat : 'right' } ) ; $ ( c ) . click ( function ( ) { $dh ( this . wrapper ) } ) ; c . wrapper = wrapper ; var t = $a ( body , 'div' , '' , { color : '#FFF' } ) ; $ ( t ) . html ( txt ) ; $ ( wrapper ) . hide ( ) . fadeIn ( 1000 ) ; }
/ *
* lib / js / legacy / utils / shortcut . js
* /
( function ( jQuery ) { jQuery . hotkeys = { version : "0.8" , specialKeys : { 8 : "backspace" , 9 : "tab" , 13 : "return" , 16 : "shift" , 17 : "ctrl" , 18 : "alt" , 19 : "pause" , 20 : "capslock" , 27 : "esc" , 32 : "space" , 33 : "pageup" , 34 : "pagedown" , 35 : "end" , 36 : "home" , 37 : "left" , 38 : "up" , 39 : "right" , 40 : "down" , 45 : "insert" , 46 : "del" , 96 : "0" , 97 : "1" , 98 : "2" , 99 : "3" , 100 : "4" , 101 : "5" , 102 : "6" , 103 : "7" , 104 : "8" , 105 : "9" , 106 : "*" , 107 : "+" , 109 : "-" , 110 : "." , 111 : "/" , 112 : "f1" , 113 : "f2" , 114 : "f3" , 115 : "f4" , 116 : "f5" , 117 : "f6" , 118 : "f7" , 119 : "f8" , 120 : "f9" , 121 : "f10" , 122 : "f11" , 123 : "f12" , 144 : "numlock" , 145 : "scroll" , 191 : "/" , 224 : "meta" } , shiftNums : { "`" : "~" , "1" : "!" , "2" : "@" , "3" : "#" , "4" : "$" , "5" : "%" , "6" : "^" , "7" : "&" , "8" : "*" , "9" : "(" , "0" : ")" , "-" : "_" , "=" : "+" , ";" : ": " , "'" : "\"" , "," : "<" , "." : ">" , "/" : "?" , "\\" : "|" } } ; function keyHandler ( handleObj ) { if ( typeof handleObj . data !== "string" ) { return ; }
var origHandler = handleObj . handler , keys = handleObj . data . toLowerCase ( ) . split ( " " ) ; handleObj . handler = function ( event ) { if ( this !== event . target && ( /textarea|select/i . test ( event . target . nodeName ) || event . target . type === "text" ) ) { return ; }
var special = event . type !== "keypress" && jQuery . hotkeys . specialKeys [ event . which ] , character = String . fromCharCode ( event . which ) . toLowerCase ( ) , key , modif = "" , possible = { } ; if ( event . altKey && special !== "alt" ) { modif += "alt+" ; }
if ( event . ctrlKey && special !== "ctrl" ) { modif += "ctrl+" ; }
if ( event . metaKey && ! event . ctrlKey && special !== "meta" ) { modif += "meta+" ; }
if ( event . shiftKey && special !== "shift" ) { modif += "shift+" ; }
if ( special ) { possible [ modif + special ] = true ; } else { possible [ modif + character ] = true ; possible [ modif + jQuery . hotkeys . shiftNums [ character ] ] = true ; if ( modif === "shift+" ) { possible [ jQuery . hotkeys . shiftNums [ character ] ] = true ; } }
for ( var i = 0 , l = keys . length ; i < l ; i ++ ) { if ( possible [ keys [ i ] ] ) { return origHandler . apply ( this , arguments ) ; } } } ; }
jQuery . each ( [ "keydown" , "keyup" , "keypress" ] , function ( ) { jQuery . event . special [ this ] = { add : keyHandler } ; } ) ; } ) ( jQuery ) ;
/ *
* lib / js / legacy / utils / printElement . js
* / ; ( f u n c t i o n ( w i n d o w , u n d e f i n e d ) { v a r d o c u m e n t = w i n d o w [ " d o c u m e n t " ] ; v a r $ = w i n d o w [ " j Q u e r y " ] ; $ . f n [ " p r i n t E l e m e n t " ] = f u n c t i o n ( o p t i o n s ) { v a r m a i n O p t i o n s = $ . e x t e n d ( { } , $ . f n [ " p r i n t E l e m e n t " ] [ " d e f a u l t s " ] , o p t i o n s ) ; i f ( m a i n O p t i o n s [ " p r i n t M o d e " ] = = ' i f r a m e ' ) { i f ( $ . b r o w s e r . o p e r a | | ( / c h r o m e / . t e s t ( n a v i g a t o r . u s e r A g e n t . t o L o w e r C a s e ( ) ) ) )
mainOptions [ "printMode" ] = 'popup' ; }
$ ( "[id^='printElement_']" ) . remove ( ) ; return this . each ( function ( ) { var opts = $ . meta ? $ . extend ( { } , mainOptions , $ ( this ) . data ( ) ) : mainOptions ; _printElement ( $ ( this ) , opts ) ; } ) ; } ; $ . fn [ "printElement" ] [ "defaults" ] = { "printMode" : 'iframe' , "pageTitle" : '' , "overrideElementCSS" : null , "printBodyOptions" : { "styleToAdd" : 'padding:10px;margin:10px;' , "classNameToAdd" : '' } , "leaveOpen" : false , "iframeElementOptions" : { "styleToAdd" : 'border:none;position:absolute;width:0px;height:0px;bottom:0px;left:0px;' , "classNameToAdd" : '' } } ; $ . fn [ "printElement" ] [ "cssElement" ] = { "href" : '' , "media" : '' } ; function _printElement ( element , opts ) { var html = _getMarkup ( element , opts ) ; var popupOrIframe = null ; var documentToWriteTo = null ; if ( opts [ "printMode" ] . toLowerCase ( ) == 'popup' ) { popupOrIframe = window . open ( 'about:blank' , 'printElementWindow' , 'width=650,height=440,scrollbars=yes' ) ; documentToWriteTo = popupOrIframe . document ; }
else { var printElementID = "printElement_" + ( Math . round ( Math . random ( ) * 99999 ) ) . toString ( ) ; var iframe = document . createElement ( 'IFRAME' ) ; $ ( iframe ) . attr ( { style : opts [ "iframeElementOptions" ] [ "styleToAdd" ] , id : printElementID , className : opts [ "iframeElementOptions" ] [ "classNameToAdd" ] , frameBorder : 0 , scrolling : 'no' , src : 'about:blank' } ) ; document . body . appendChild ( iframe ) ; documentToWriteTo = ( iframe . contentWindow || iframe . contentDocument ) ; if ( documentToWriteTo . document )
documentToWriteTo = documentToWriteTo . document ; iframe = document . frames ? document . frames [ printElementID ] : document . getElementById ( printElementID ) ; popupOrIframe = iframe . contentWindow || iframe ; }
focus ( ) ; documentToWriteTo . open ( ) ; documentToWriteTo . write ( html ) ; documentToWriteTo . close ( ) ; _callPrint ( popupOrIframe ) ; } ; function _callPrint ( element ) { if ( element && element [ "printPage" ] )
element [ "printPage" ] ( ) ; else
setTimeout ( function ( ) { _callPrint ( element ) ; } , 50 ) ; }
function _getElementHTMLIncludingFormElements ( element ) { var $element = $ ( element ) ; var elementHtml = $ ( '<div></div>' ) . append ( $element . clone ( ) ) . html ( ) ; return elementHtml ; }
function _getBaseHref ( ) { var port = ( window . location . port ) ? ':' + window . location . port : '' ; return window . location . protocol + '//' + window . location . hostname + port + window . location . pathname ; }
function _getMarkup ( element , opts ) { var $element = $ ( element ) ; var elementHtml = _getElementHTMLIncludingFormElements ( element ) ; var html = new Array ( ) ; html . push ( '<html><head><title>' + opts [ "pageTitle" ] + '</title>' ) ; if ( opts [ "overrideElementCSS" ] ) { if ( opts [ "overrideElementCSS" ] . length > 0 ) { for ( var x = 0 ; x < opts [ "overrideElementCSS" ] . length ; x ++ ) { var current = opts [ "overrideElementCSS" ] [ x ] ; if ( typeof ( current ) == 'string' )
html . push ( '<link type="text/css" rel="stylesheet" href="' + current + '" >' ) ; else
html . push ( '<link type="text/css" rel="stylesheet" href="' + current [ "href" ] + '" media="' + current [ "media" ] + '" >' ) ; } } }
else { $ ( "link" , document ) . filter ( function ( ) { return $ ( this ) . attr ( "rel" ) . toLowerCase ( ) == "stylesheet" ; } ) . each ( function ( ) { html . push ( '<link type="text/css" rel="stylesheet" href="' + $ ( this ) . attr ( "href" ) + '" media="' + $ ( this ) . attr ( 'media' ) + '" >' ) ; } ) ; }
html . push ( '<base href="' + _getBaseHref ( ) + '" />' ) ; html . push ( '</head><body style="' + opts [ "printBodyOptions" ] [ "styleToAdd" ] + '" class="' + opts [ "printBodyOptions" ] [ "classNameToAdd" ] + '">' ) ; html . push ( '<div class="' + $element . attr ( 'class' ) + '">' + elementHtml + '</div>' ) ; html . push ( '<script type="text/javascript">function printPage(){focus();print();' + ( ( ! $ . browser . opera && ! opts [ "leaveOpen" ] && opts [ "printMode" ] . toLowerCase ( ) == 'popup' ) ? 'close();' : '' ) + '}</script>' ) ; html . push ( '</body></html>' ) ; return html . join ( '' ) ; } ; } ) ( window ) ;
/ *
* lib / js / legacy / widgets / form / fields . js
* /
var no _value _fields = [ 'Section Break' , 'Column Break' , 'HTML' , 'Table' , 'FlexTable' , 'Button' , 'Image' ] ; var codeid = 0 ; var code _editors = { } ; function Field ( ) { this . with _label = 1 ; }
Field . prototype . make _body = function ( ) { var ischk = ( this . df . fieldtype == 'Check' ? 1 : 0 ) ; if ( this . parent )
this . wrapper = $a ( this . parent , 'div' ) ; else
this . wrapper = document . createElement ( 'div' ) ; this . label _area = $a ( this . wrapper , 'div' , '' , { margin : '8px 0px 2px 0px' } ) ; if ( ischk && ! this . in _grid ) { this . input _area = $a ( this . label _area , 'span' , '' , { marginRight : '4px' } ) ; this . disp _area = $a ( this . label _area , 'span' , '' , { marginRight : '4px' } ) ; }
if ( this . with _label ) { this . label _span = $a ( this . label _area , 'span' , 'field_label' )
this . label _icon = $a ( this . label _area , 'img' , '' , { margin : '-3px 4px -3px 4px' } ) ; $dh ( this . label _icon ) ; this . label _icon . src = 'lib/images/icons/error.gif' ; this . label _icon . title = 'Mandatory value needs to be entered' ; this . suggest _icon = $a ( this . label _area , 'img' , '' , { margin : '-3px 4px -3px 0px' } ) ; $dh ( this . suggest _icon ) ; this . suggest _icon . src = 'lib/images/icons/bullet_arrow_down.png' ; this . suggest _icon . title = 'With suggestions' ; } else { this . label _span = $a ( this . label _area , 'span' , '' , { marginRight : '4px' } )
$dh ( this . label _area ) ; }
if ( ! this . input _area ) { this . input _area = $a ( this . wrapper , 'div' ) ; this . disp _area = $a ( this . wrapper , 'div' ) ; }
if ( this . in _grid ) { if ( this . label _area ) $dh ( this . label _area ) ; } else { this . input _area . className = 'input_area' ; $y ( this . wrapper , { marginBottom : '4px' } ) ; this . set _description ( ) ; }
if ( this . onmake ) this . onmake ( ) ; }
Field . prototype . set _max _width = function ( ) { var no _max = [ 'Code' , 'Text Editor' , 'Text' , 'Table' , 'HTML' ]
if ( this . wrapper && this . layout _cell && this . layout _cell . parentNode . cells && this . layout _cell . parentNode . cells . length == 1 && ! in _list ( no _max , this . df . fieldtype ) ) { $y ( this . wrapper , { paddingRight : '50%' } ) ; } }
Field . prototype . set _label = function ( ) { if ( this . with _label && this . label _area && this . label != this . df . label ) { this . label _span . innerHTML = this . df . label ; this . label = this . df . label ; } }
Field . prototype . set _description = function ( ) { if ( this . df . description ) { var p = in _list ( [ 'Text Editor' , 'Code' , 'Check' ] , this . df . fieldtype ) ? this . label _area : this . wrapper ; this . desc _area = $a ( p , 'div' , 'field_description' , '' , this . df . description )
if ( in _list ( [ 'Text Editor' , 'Code' ] , this . df . fieldtype ) )
$ ( this . desc _area ) . addClass ( 'field_description_top' ) ; } }
Field . prototype . get _status = function ( ) { if ( this . in _filter ) this . not _in _form = this . in _filter ; if ( this . not _in _form ) { return 'Write' ; }
var fn = this . df . fieldname ? this . df . fieldname : this . df . label ; this . df = get _field ( this . doctype , fn , this . docname ) ; if ( ! this . df . permlevel ) this . df . permlevel = 0 ; var p = this . perm [ this . df . permlevel ] ; var ret ; if ( cur _frm . editable && p && p [ WRITE ] ) ret = 'Write' ; else if ( p && p [ READ ] ) ret = 'Read' ; else ret = 'None' ; if ( this . df . fieldtype == 'Binary' )
ret = 'None' ; if ( cint ( this . df . hidden ) )
ret = 'None' ; if ( ret == 'Write' && cint ( cur _frm . doc . docstatus ) > 0 ) ret = 'Read' ; var a _o _s = cint ( this . df . allow _on _submit ) ; if ( a _o _s && ( this . in _grid || ( this . frm && this . frm . not _in _container ) ) ) { a _o _s = null ; if ( this . in _grid ) a _o _s = this . grid . field . df . allow _on _submit ; if ( this . frm && this . frm . not _in _container ) { a _o _s = cur _grid . field . df . allow _on _submit ; } }
if ( cur _frm . editable && a _o _s && cint ( cur _frm . doc . docstatus ) > 0 && ! this . df . hidden ) { tmp _perm = get _perm ( cur _frm . doctype , cur _frm . docname , 1 ) ; if ( tmp _perm [ this . df . permlevel ] && tmp _perm [ this . df . permlevel ] [ WRITE ] ) ret = 'Write' ; }
return ret ; }
Field . prototype . set _style _mandatory = function ( add ) { if ( add ) { $ ( this . txt ? this . txt : this . input ) . addClass ( 'input-mandatory' ) ; if ( this . disp _area ) $ ( this . disp _area ) . addClass ( 'input-mandatory' ) ; } else { $ ( this . txt ? this . txt : this . input ) . removeClass ( 'input-mandatory' ) ; if ( this . disp _area ) $ ( this . disp _area ) . removeClass ( 'input-mandatory' ) ; } }
Field . prototype . refresh _mandatory = function ( ) { if ( this . in _filter ) return ; if ( this . df . reqd ) { if ( this . label _area ) this . label _area . style . color = "#d22" ; this . set _style _mandatory ( 1 ) ; } else { if ( this . label _area ) this . label _area . style . color = "#222" ; this . set _style _mandatory ( 0 ) ; }
this . refresh _label _icon ( )
this . set _reqd = this . df . reqd ; }
Field . prototype . refresh _display = function ( ) { if ( ! this . set _status || this . set _status != this . disp _status ) { if ( this . disp _status == 'Write' ) { if ( this . make _input && ( ! this . input ) ) { this . make _input ( ) ; if ( this . onmake _input ) this . onmake _input ( ) ; }
if ( this . show ) this . show ( )
else { $ds ( this . wrapper ) ; }
if ( this . input ) { $ds ( this . input _area ) ; $dh ( this . disp _area ) ; if ( this . input . refresh ) this . input . refresh ( ) ; } else { $dh ( this . input _area ) ; $ds ( this . disp _area ) ; } } else if ( this . disp _status == 'Read' ) { if ( this . show ) this . show ( )
else { $ds ( this . wrapper ) ; }
$dh ( this . input _area ) ; $ds ( this . disp _area ) ; } else { if ( this . hide ) this . hide ( ) ; else $dh ( this . wrapper ) ; }
this . set _status = this . disp _status ; } }
Field . prototype . refresh = function ( ) { this . disp _status = this . get _status ( ) ; if ( this . in _grid && this . table _refresh && this . disp _status == 'Write' )
{ this . table _refresh ( ) ; return ; }
2012-02-17 06:36:33 +00:00
this . set _label ( ) ; this . refresh _display ( ) ; if ( this . onrefresh )
this . onrefresh ( ) ; if ( this . input ) { if ( this . input . refresh ) this . input . refresh ( this . df ) ; }
if ( this . wrapper ) { this . wrapper . fieldobj = this ; $ ( this . wrapper ) . trigger ( 'refresh' ) ; }
if ( ! this . not _in _form )
2012-02-14 06:14:13 +00:00
this . set _input ( _f . get _value ( this . doctype , this . docname , this . df . fieldname ) ) ; this . refresh _mandatory ( ) ; this . set _max _width ( ) ; }
Field . prototype . refresh _label _icon = function ( ) { if ( this . df . reqd ) { if ( this . get _value && is _null ( this . get _value ( ) ) ) { if ( this . label _icon ) $ds ( this . label _icon ) ; $ ( this . txt ? this . txt : this . input ) . addClass ( 'field-to-update' ) } else { if ( this . label _icon ) $dh ( this . label _icon ) ; $ ( this . txt ? this . txt : this . input ) . removeClass ( 'field-to-update' ) } } }
Field . prototype . set = function ( val ) { if ( this . not _in _form )
return ; if ( ( ! this . docname ) && this . grid ) { this . docname = this . grid . add _newrow ( ) ; }
if ( in _list ( [ 'Data' , 'Text' , 'Small Text' , 'Code' ] , this . df . fieldtype ) )
val = clean _smart _quotes ( val ) ; var set _val = val ; if ( this . validate ) set _val = this . validate ( val ) ; _f . set _value ( this . doctype , this . docname , this . df . fieldname , set _val ) ; this . value = val ; }
Field . prototype . set _input = function ( val ) { this . value = val ; if ( this . input && this . input . set _input ) { if ( val == null ) this . input . set _input ( '' ) ; else this . input . set _input ( val ) ; }
var disp _val = val ; if ( val == null ) disp _val = '' ; this . set _disp ( disp _val ) ; }
Field . prototype . run _trigger = function ( ) { this . refresh _label _icon ( ) ; if ( this . df . reqd && this . get _value && ! is _null ( this . get _value ( ) ) && this . set _as _error )
this . set _as _error ( 0 ) ; if ( this . not _in _form ) { return ; }
if ( cur _frm . cscript [ this . df . fieldname ] )
cur _frm . runclientscript ( this . df . fieldname , this . doctype , this . docname ) ; cur _frm . refresh _dependency ( ) ; }
Field . prototype . set _disp _html = function ( t ) { if ( this . disp _area ) { $ ( this . disp _area ) . addClass ( 'disp_area' ) ; this . disp _area . innerHTML = ( t == null ? '' : t ) ; if ( ! t ) $ ( this . disp _area ) . addClass ( 'disp_area_no_val' ) ; } }
Field . prototype . set _disp = function ( val ) { this . set _disp _html ( val ) ; }
Field . prototype . set _as _error = function ( set ) { if ( this . in _grid || this . in _filter ) return ; var w = this . txt ? this . txt : this . input ; if ( set ) { $y ( w , { border : '2px solid RED' } ) ; } else { $y ( w , { border : '1px solid #888' } ) ; } }
2012-02-17 08:34:55 +00:00
Field . prototype . activate = function ( docname ) { this . docname = docname ; this . refresh ( ) ; if ( this . input ) { var v = _f . get _value ( this . doctype , this . docname , this . df . fieldname ) ; this . last _value = v ; if ( this . input . onchange && this . input . get _value && this . input . get _value ( ) != v ) { if ( this . validate )
2012-02-14 06:14:13 +00:00
this . input . set _value ( this . validate ( v ) ) ; else
this . input . set _value ( ( v == null ) ? '' : v ) ; if ( this . format _input )
this . format _input ( ) ; }
if ( this . input . focus ) { try { this . input . focus ( ) ; } catch ( e ) { } } }
if ( this . txt ) { try { this . txt . focus ( ) ; } catch ( e ) { }
2012-02-17 08:34:55 +00:00
this . txt . field _object = this ; } }
2012-02-17 10:20:07 +00:00
function DataField ( ) { } DataField . prototype = new Field ( ) ; DataField . prototype . make _input = function ( ) { var me = this ; this . input = $a _input ( this . input _area , this . df . fieldtype == 'Password' ? 'password' : 'text' ) ; this . get _value = function ( ) { var v = this . input . value ; if ( this . validate ) v = this . validate ( v ) ; return v ; }
2012-02-14 06:14:13 +00:00
this . input . name = this . df . fieldname ; this . input . onchange = function ( ) { if ( ! me . last _value ) me . last _value = '' ; if ( me . validate )
me . input . value = me . validate ( me . input . value ) ; me . set ( me . input . value ) ; if ( me . format _input )
me . format _input ( ) ; if ( in _list ( [ 'Currency' , 'Float' , 'Int' ] , me . df . fieldtype ) ) { if ( flt ( me . last _value ) == flt ( me . input . value ) ) { me . last _value = me . input . value ; return ; } }
me . last _value = me . input . value ; me . run _trigger ( ) ; }
this . input . set _input = function ( val ) { if ( val == null ) val = '' ; me . input . value = val ; if ( me . format _input ) me . format _input ( ) ; }
if ( this . df . options == 'Suggest' ) { wn . require ( 'lib/js/legacy/widgets/autosuggest.js' ) ; if ( this . suggest _icon ) $di ( this . suggest _icon ) ; this . set _get _query = function ( ) { }
this . get _query = function ( doc , dt , dn ) { return repl ( 'SELECT DISTINCT `%(fieldname)s` FROM `tab%(dt)s` WHERE `%(fieldname)s` LIKE "%s" LIMIT 50' , { fieldname : me . df . fieldname , dt : me . df . parent } ) }
var opts = { script : '' , json : true , maxresults : 10 , link _field : this } ; this . as = new AutoSuggest ( this . input , opts ) ; } }
DataField . prototype . validate = function ( v ) { if ( this . df . options == 'Phone' ) { if ( v + '' == '' ) return '' ; v1 = ''
v = v . replace ( / /g , '' ) . replace ( /-/g , '' ) . replace ( /\(/g , '' ) . replace ( /\)/g , '' ) ; if ( v && v . substr ( 0 , 1 ) == '+' ) { v1 = '+' ; v = v . substr ( 1 ) ; }
if ( v && v . substr ( 0 , 2 ) == '00' ) { v1 += '00' ; v = v . substr ( 2 ) ; }
if ( v && v . substr ( 0 , 1 ) == '0' ) { v1 += '0' ; v = v . substr ( 1 ) ; }
v1 += cint ( v ) + '' ; return v1 ; } else if ( this . df . options == 'Email' ) { if ( v + '' == '' ) return '' ; if ( ! validate _email ( v ) ) { msgprint ( this . df . label + ': ' + v + ' is not a valid email id' ) ; return '' ; } else
return v ; } else { return v ; } }
DataField . prototype . onrefresh = function ( ) { if ( this . input && this . df . colour ) { var col = '#' + this . df . colour . split ( ':' ) [ 1 ] ; $bg ( this . input , col ) ; } }
function ReadOnlyField ( ) { }
ReadOnlyField . prototype = new Field ( ) ; function HTMLField ( ) { }
HTMLField . prototype = new Field ( ) ; HTMLField . prototype . with _label = 0 ; HTMLField . prototype . set _disp = function ( val ) { this . disp _area . innerHTML = val ; }
HTMLField . prototype . set _input = function ( val ) { if ( val ) this . set _disp ( val ) ; }
HTMLField . prototype . onrefresh = function ( ) { this . set _disp ( this . df . options ? this . df . options : '' ) ; }
var datepicker _active = 0 ; function DateField ( ) { } DateField . prototype = new Field ( ) ; DateField . prototype . make _input = function ( ) { var me = this ; this . user _fmt = wn . control _panel . date _format ; if ( ! this . user _fmt ) this . user _fmt = 'dd-mm-yy' ; this . input = $a ( this . input _area , 'input' ) ; wn . require ( 'lib/css/legacy/jquery-ui.css' ) ; $ ( this . input ) . datepicker ( { dateFormat : me . user _fmt . replace ( 'yyyy' , 'yy' ) , altFormat : 'yy-mm-dd' , changeYear : true , beforeShow : function ( input , inst ) { datepicker _active = 1 } , onClose : function ( dateText , inst ) { datepicker _active = 0 ; if ( _f . cur _grid _cell )
_f . cur _grid _cell . grid . cell _deselect ( ) ; } } ) ; var me = this ; me . input . onchange = function ( ) { if ( this . value == null ) this . value = '' ; if ( ! this . not _in _form )
me . set ( dateutil . user _to _str ( me . input . value ) ) ; me . run _trigger ( ) ; }
me . input . set _input = function ( val ) { if ( val == null ) val = '' ; else val = dateutil . str _to _user ( val ) ; me . input . value = val ; }
me . get _value = function ( ) { if ( me . input . value )
return dateutil . user _to _str ( me . input . value ) ; } }
DateField . prototype . set _disp = function ( val ) { var v = dateutil . str _to _user ( val ) ; if ( v == null ) v = '' ; this . set _disp _html ( v ) ; }
DateField . prototype . validate = function ( v ) { if ( ! v ) return ; var me = this ; this . clear = function ( ) { msgprint ( "Date must be in format " + this . user _fmt ) ; me . input . set _input ( '' ) ; return '' ; }
var t = v . split ( '-' ) ; if ( t . length != 3 ) { return this . clear ( ) ; }
else if ( cint ( t [ 1 ] ) > 12 || cint ( t [ 1 ] ) < 1 ) { return this . clear ( ) ; }
else if ( cint ( t [ 2 ] ) > 31 || cint ( t [ 2 ] ) < 1 ) { return this . clear ( ) ; }
return v ; } ; var _link _onchange _flag = null ; function LinkField ( ) { } LinkField . prototype = new Field ( ) ; LinkField . prototype . make _input = function ( ) { var me = this ; if ( me . df . no _buttons ) { this . txt = $a ( this . input _area , 'input' ) ; this . input = this . txt ; } else { makeinput _popup ( this , 'ic-zoom' , 'ic-sq_next' , 'ic-sq_plus' ) ; me . setup _buttons ( ) ; me . onrefresh = function ( ) { if ( me . can _create && cur _frm . doc . docstatus == 0 ) $ds ( me . btn2 ) ; else $dh ( me . btn2 ) ; } }
me . txt . field _object = this ; me . set _onchange ( ) ; me . input . set _input = function ( val ) { if ( val == undefined ) val = '' ; me . txt . value = val ; }
me . get _value = function ( ) { return me . txt . value ; }
wn . require ( 'lib/js/legacy/widgets/autosuggest.js' ) ; var opts = { script : '' , json : true , maxresults : 10 , link _field : me } ; this . as = new AutoSuggest ( me . txt , opts ) ; }
LinkField . prototype . setup _buttons = function ( ) { var me = this ; me . btn . onclick = function ( ) { selector . set ( me , me . df . options , me . df . label ) ; selector . show ( me . txt ) ; }
if ( me . btn1 ) me . btn1 . onclick = function ( ) { if ( me . txt . value && me . df . options ) { loaddoc ( me . df . options , me . txt . value ) ; } }
me . can _create = 0 ; if ( ( ! me . not _in _form ) && in _list ( profile . can _create , me . df . options ) ) { me . can _create = 1 ; me . btn2 . onclick = function ( ) { var on _save _callback = function ( new _rec ) { if ( new _rec ) { var d = _f . calling _doc _stack . pop ( ) ; locals [ d [ 0 ] ] [ d [ 1 ] ] [ me . df . fieldname ] = new _rec ; me . refresh ( ) ; if ( me . grid ) me . grid . refresh ( ) ; me . run _trigger ( ) ; } }
_f . calling _doc _stack . push ( [ me . doctype , me . docname ] ) ; new _doc ( me . df . options , me . on _new , 1 , on _save _callback , me . doctype , me . docname , me . frm . not _in _container ) ; } } else { $dh ( me . btn2 ) ; $y ( $td ( me . tab , 0 , 2 ) , { width : '0px' } ) ; } }
LinkField . prototype . set _onchange = function ( ) { var me = this ; me . txt . onchange = function ( e ) { if ( cur _autosug ) return ; if ( _link _onchange _flag ) { return ; }
_link _onchange _flag = 1 ; me . refresh _label _icon ( ) ; if ( me . not _in _form ) { _link _onchange _flag = 0 ; return ; }
if ( cur _frm ) { if ( me . txt . value == locals [ me . doctype ] [ me . docname ] [ me . df . fieldname ] ) { me . set ( me . txt . value ) ; me . run _trigger ( ) ; setTimeout ( '_link_onchange_flag = 0' , 500 ) ; return ; } }
me . set ( me . txt . value ) ; if ( _f . cur _grid _cell )
_f . cur _grid _cell . grid . cell _deselect ( ) ; if ( ! me . txt . value ) { me . run _trigger ( ) ; setTimeout ( '_link_onchange_flag = 0' , 500 ) ; return ; }
var fetch = '' ; if ( cur _frm . fetch _dict [ me . df . fieldname ] )
fetch = cur _frm . fetch _dict [ me . df . fieldname ] . columns . join ( ', ' ) ; $c ( 'webnotes.widgets.form.utils.validate_link' , { 'value' : me . txt . value , 'options' : me . df . options , 'fetch' : fetch } , function ( r , rt ) { setTimeout ( '_link_onchange_flag = 0' , 500 ) ; if ( selector && selector . display ) return ; if ( r . message == 'Ok' ) { if ( r . fetch _values ) me . set _fetch _values ( r . fetch _values ) ; me . run _trigger ( ) ; } else { var astr = '' ; if ( in _list ( profile . can _create , me . df . options ) ) astr = repl ( '<br><br><span class="link_type" onclick="newdoc(\'%(dt)s\')">Click here</span> to create a new %(dtl)s' , { dt : me . df . options , dtl : get _doctype _label ( me . df . options ) } )
msgprint ( repl ( 'error:<b>%(val)s</b> is not a valid %(dt)s.<br><br>You must first create a new %(dt)s <b>%(val)s</b> and then select its value. To find an existing %(dt)s, click on the magnifying glass next to the field.%(add)s' , { val : me . txt . value , dt : get _doctype _label ( me . df . options ) , add : astr } ) ) ; me . txt . value = '' ; me . set ( '' ) ; } } ) ; } }
LinkField . prototype . set _fetch _values = function ( fetch _values ) { var fl = cur _frm . fetch _dict [ this . df . fieldname ] . fields ; var changed _fields = [ ] ; for ( var i = 0 ; i < fl . length ; i ++ ) { if ( locals [ this . doctype ] [ this . docname ] [ fl [ i ] ] != fetch _values [ i ] ) { locals [ this . doctype ] [ this . docname ] [ fl [ i ] ] = fetch _values [ i ] ; if ( ! this . grid ) { refresh _field ( fl [ i ] ) ; changed _fields . push ( fl [ i ] ) ; } } }
for ( i = 0 ; i < changed _fields . length ; i ++ ) { if ( cur _frm . fields _dict [ changed _fields [ i ] ] )
cur _frm . fields _dict [ changed _fields [ i ] ] . run _trigger ( ) ; }
if ( this . grid ) this . grid . refresh ( ) ; }
LinkField . prototype . set _get _query = function ( ) { if ( this . get _query ) return ; if ( this . grid ) { var f = this . grid . get _field ( this . df . fieldname ) ; if ( f . get _query ) this . get _query = f . get _query ; } }
LinkField . prototype . set _disp = function ( val ) { var t = null ; if ( val ) t = "<a href=\'javascript:loaddoc(\"" + this . df . options + "\", \"" + val + "\")\'>" + val + "</a>" ; this . set _disp _html ( t ) ; }
function IntField ( ) { } IntField . prototype = new DataField ( ) ; IntField . prototype . validate = function ( v ) { if ( isNaN ( parseInt ( v ) ) ) return null ; return cint ( v ) ; } ; IntField . prototype . format _input = function ( ) { if ( this . input . value == null ) this . input . value = '' ; }
function FloatField ( ) { } FloatField . prototype = new DataField ( ) ; FloatField . prototype . validate = function ( v ) { var v = parseFloat ( v ) ; if ( isNaN ( v ) ) return null ; return v ; } ; FloatField . prototype . format _input = function ( ) { if ( this . input . value == null ) this . input . value = '' ; }
function CurrencyField ( ) { } CurrencyField . prototype = new DataField ( ) ; CurrencyField . prototype . format _input = function ( ) { var v = fmt _money ( this . input . value ) ; if ( this . not _in _form ) { if ( ! flt ( this . input . value ) ) v = '' ; }
this . input . value = v ; }
CurrencyField . prototype . validate = function ( v ) { if ( v == null || v == '' )
return 0 ; return flt ( v , 2 ) ; }
CurrencyField . prototype . set _disp = function ( val ) { var v = fmt _money ( val ) ; this . set _disp _html ( v ) ; }
CurrencyField . prototype . onmake _input = function ( ) { if ( ! this . input ) return ; this . input . onfocus = function ( ) { if ( flt ( this . value ) == 0 ) this . select ( ) ; } }
function CheckField ( ) { } CheckField . prototype = new Field ( ) ; CheckField . prototype . validate = function ( v ) { var v = parseInt ( v ) ; if ( isNaN ( v ) ) return 0 ; return v ; } ; CheckField . prototype . onmake = function ( ) { this . checkimg = $a ( this . disp _area , 'div' ) ; var img = $a ( this . checkimg , 'img' ) ; img . src = 'lib/images/ui/tick.gif' ; $dh ( this . checkimg ) ; }
2012-02-17 08:34:55 +00:00
CheckField . prototype . make _input = function ( ) { var me = this ; this . input = $a _input ( this . input _area , 'checkbox' ) ; $y ( this . input , { width : "16px" , border : '0px' , margin : '2px' } ) ; $ ( this . input ) . click ( function ( ) { me . set ( this . checked ? 1 : 0 ) ; me . run _trigger ( ) ; } )
2012-02-14 06:14:13 +00:00
this . input . set _input = function ( v ) { v = parseInt ( v ) ; if ( isNaN ( v ) ) v = 0 ; if ( v ) me . input . checked = true ; else me . input . checked = false ; }
this . get _value = function ( ) { return this . input . checked ? 1 : 0 ; } }
CheckField . prototype . set _disp = function ( val ) { if ( val ) { $ds ( this . checkimg ) ; }
else { $dh ( this . checkimg ) ; } }
function TextField ( ) { } TextField . prototype = new Field ( ) ; TextField . prototype . set _disp = function ( val ) { this . disp _area . innerHTML = replace _newlines ( val ) ; }
TextField . prototype . make _input = function ( ) { var me = this ; if ( this . in _grid )
return ; this . input = $a ( this . input _area , 'textarea' ) ; if ( this . df . fieldtype == 'Small Text' )
this . input . style . height = "80px" ; this . input . set _input = function ( v ) { me . input . value = v ; }
this . input . onchange = function ( ) { me . set ( me . input . value ) ; me . run _trigger ( ) ; }
this . get _value = function ( ) { return this . input . value ; } }
var text _dialog ; function make _text _dialog ( ) { var d = new Dialog ( 520 , 410 , 'Edit Text' ) ; d . make _body ( [ [ 'Text' , 'Enter Text' ] , [ 'HTML' , 'Description' ] , [ 'Button' , 'Update' ] ] ) ; d . widgets [ 'Update' ] . onclick = function ( ) { var t = this . dialog ; t . field . set ( t . widgets [ 'Enter Text' ] . value ) ; t . hide ( ) ; }
d . onshow = function ( ) { this . widgets [ 'Enter Text' ] . style . height = '300px' ; var v = _f . get _value ( this . field . doctype , this . field . docname , this . field . df . fieldname ) ; this . widgets [ 'Enter Text' ] . value = v == null ? '' : v ; this . widgets [ 'Enter Text' ] . focus ( ) ; this . widgets [ 'Description' ] . innerHTML = ''
if ( this . field . df . description )
$a ( this . widgets [ 'Description' ] , 'div' , 'field_description' , '' , this . field . df . description ) ; }
d . onhide = function ( ) { if ( _f . cur _grid _cell )
_f . cur _grid _cell . grid . cell _deselect ( ) ; }
text _dialog = d ; }
TextField . prototype . table _refresh = function ( ) { if ( ! this . text _dialog )
make _text _dialog ( ) ; text _dialog . set _title ( 'Enter text for "' + this . df . label + '"' ) ; text _dialog . field = this ; text _dialog . show ( ) ; }
function SelectField ( ) { } SelectField . prototype = new Field ( ) ; SelectField . prototype . make _input = function ( ) { var me = this ; var opt = [ ] ; if ( this . in _filter && ( ! this . df . single _select ) ) { this . input = $a ( this . input _area , 'select' ) ; this . input . multiple = true ; this . input . style . height = '4em' ; this . input . lab = $a ( this . input _area , 'div' , { fontSize : '9px' , color : '#999' } ) ; this . input . lab . innerHTML = '(Use Ctrl+Click to select multiple or de-select)' } else { this . input = $a ( this . input _area , 'select' ) ; this . input . onchange = function ( ) { if ( me . validate )
2012-02-17 08:34:55 +00:00
me . validate ( ) ; me . set ( sel _val ( this ) ) ; me . run _trigger ( ) ; }
2012-02-14 06:14:13 +00:00
if ( this . df . options == 'attach_files:' ) { this . file _attach = true ; } }
this . set _as _single = function ( ) { var i = this . input ; i . multiple = false ; i . style . height = null ; if ( i . lab ) $dh ( i . lab ) }
this . refresh _options = function ( options ) { if ( options )
me . df . options = options ; if ( this . file _attach )
this . set _attach _options ( ) ; me . options _list = me . df . options ? me . df . options . split ( '\n' ) : [ ] ; empty _select ( this . input ) ; if ( me . in _filter && me . options _list [ 0 ] != '' ) { me . options _list = add _lists ( [ '' ] , me . options _list ) ; }
add _sel _options ( this . input , me . options _list ) ; }
this . onrefresh = function ( ) { this . refresh _options ( ) ; if ( this . not _in _form ) { this . input . value = '' ; return ; }
if ( _f . get _value )
var v = _f . get _value ( this . doctype , this . docname , this . df . fieldname ) ; else { if ( this . options _list && this . options _list . length )
var v = this . options _list [ 0 ] ; else
var v = null ; }
this . input . set _input ( v ) ; }
this . input . set _input = function ( v ) { if ( ! v ) { if ( ! me . input . multiple ) { if ( me . docname ) { if ( me . options _list && me . options _list . length ) { me . set ( me . options _list [ 0 ] ) ; me . input . value = me . options _list [ 0 ] ; } else { me . input . value = '' ; } } } } else { if ( me . options _list ) { if ( me . input . multiple ) { for ( var i = 0 ; i < me . input . options . length ; i ++ ) { me . input . options [ i ] . selected = 0 ; if ( me . input . options [ i ] . value && inList ( v . split ( "," ) , me . input . options [ i ] . value ) )
me . input . options [ i ] . selected = 1 ; } } else if ( in _list ( me . options _list , v ) ) { me . input . value = v ; } } } }
this . get _value = function ( ) { if ( me . input . multiple ) { var l = [ ] ; for ( var i = 0 ; i < me . input . options . length ; i ++ ) { if ( me . input . options [ i ] . selected ) l [ l . length ] = me . input . options [ i ] . value ; }
return l ; } else { if ( me . input . options ) { var val = sel _val ( me . input ) ; if ( ! val && ! me . input . selectedIndex )
val = me . input . options [ 0 ] . value ; return val ; }
return me . input . value ; } }
this . set _attach _options = function ( ) { if ( ! cur _frm ) return ; var fl = cur _frm . doc . file _list ; if ( fl ) { this . df . options = '' ; var fl = fl . split ( '\n' ) ; for ( var i in fl ) { this . df . options += '\n' + fl [ i ] . split ( ',' ) [ 1 ] ; } } else { this . df . options = '' } }
this . refresh ( ) ; }
function TimeField ( ) { } TimeField . prototype = new Field ( ) ; TimeField . prototype . get _time = function ( ) { return time _to _hhmm ( sel _val ( this . input _hr ) , sel _val ( this . input _mn ) , sel _val ( this . input _am ) ) ; }
TimeField . prototype . set _time = function ( v ) { ret = time _to _ampm ( v ) ; this . input _hr . inp . value = ret [ 0 ] ; this . input _mn . inp . value = ret [ 1 ] ; this . input _am . inp . value = ret [ 2 ] ; }
TimeField . prototype . set _style _mandatory = function ( ) { }
TimeField . prototype . set _as _error = function ( ) { }
2012-02-17 08:34:55 +00:00
TimeField . prototype . make _input = function ( ) { var me = this ; this . input = $a ( this . input _area , 'div' , 'time_field' ) ; var t = make _table ( this . input , 1 , 3 , '200px' ) ; var opt _hr = [ '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '10' , '11' , '12' ] ; var opt _mn = [ '00' , '05' , '10' , '15' , '20' , '25' , '30' , '35' , '40' , '45' , '50' , '55' ] ; var opt _am = [ 'AM' , 'PM' ] ; this . input _hr = new SelectWidget ( $td ( t , 0 , 0 ) , opt _hr , '50px' ) ; this . input _mn = new SelectWidget ( $td ( t , 0 , 1 ) , opt _mn , '50px' ) ; this . input _am = new SelectWidget ( $td ( t , 0 , 2 ) , opt _am , '50px' ) ; var onchange _fn = function ( ) { me . set ( me . get _time ( ) ) ; me . run _trigger ( ) ; }
2012-02-14 06:14:13 +00:00
this . input _hr . inp . onchange = onchange _fn ; this . input _mn . inp . onchange = onchange _fn ; this . input _am . inp . onchange = onchange _fn ; this . onrefresh = function ( ) { var v = _f . get _value ? _f . get _value ( me . doctype , me . docname , me . df . fieldname ) : null ; me . set _time ( v ) ; if ( ! v )
me . set ( me . get _time ( ) ) ; }
this . input . set _input = function ( v ) { if ( v == null ) v = '' ; me . set _time ( v ) ; }
this . get _value = function ( ) { return this . get _time ( ) ; }
this . refresh ( ) ; }
TimeField . prototype . set _disp = function ( v ) { var t = time _to _ampm ( v ) ; var t = t [ 0 ] + ':' + t [ 1 ] + ' ' + t [ 2 ] ; this . set _disp _html ( t ) ; }
function makeinput _popup ( me , iconsrc , iconsrc1 , iconsrc2 ) { me . input = $a ( me . input _area , 'div' ) ; if ( ! me . not _in _form )
$y ( me . input , { width : '80%' } ) ; me . input . set _width = function ( w ) { $y ( me . input , { width : ( w - 2 ) + 'px' } ) ; }
var tab = $a ( me . input , 'table' ) ; me . tab = tab ; $y ( tab , { width : '100%' , borderCollapse : 'collapse' , tableLayout : 'fixed' } ) ; var c0 = tab . insertRow ( 0 ) . insertCell ( 0 ) ; var c1 = tab . rows [ 0 ] . insertCell ( 1 ) ; $y ( c1 , { width : '20px' } ) ; me . txt = $a ( $a ( $a ( c0 , 'div' , '' , { paddingRight : '8px' } ) , 'div' ) , 'input' , '' , { width : '100%' } ) ; me . btn = $a ( c1 , 'div' , 'wn-icon ' + iconsrc , { width : '16px' } ) ; if ( iconsrc1 )
me . btn . setAttribute ( 'title' , 'Search' ) ; else
me . btn . setAttribute ( 'title' , 'Select Date' ) ; if ( iconsrc1 ) { var c2 = tab . rows [ 0 ] . insertCell ( 2 ) ; $y ( c2 , { width : '20px' } ) ; me . btn1 = $a ( c2 , 'div' , 'wn-icon ' + iconsrc1 , { width : '16px' } ) ; me . btn1 . setAttribute ( 'title' , 'Open Link' ) ; }
if ( iconsrc2 ) { var c3 = tab . rows [ 0 ] . insertCell ( 3 ) ; $y ( c3 , { width : '20px' } ) ; me . btn2 = $a ( c3 , 'div' , 'wn-icon ' + iconsrc2 , { width : '16px' } ) ; me . btn2 . setAttribute ( 'title' , 'Create New' ) ; $dh ( me . btn2 ) ; }
if ( me . df . colour )
me . txt . style . background = '#' + me . df . colour . split ( ':' ) [ 1 ] ; me . txt . name = me . df . fieldname ; me . setdisabled = function ( tf ) { me . txt . disabled = tf ; } }
var tmpid = 0 ; _f . ButtonField = function ( ) { } ; _f . ButtonField . prototype = new Field ( ) ; _f . ButtonField . prototype . with _label = 0 ; _f . ButtonField . prototype . init = function ( ) { this . prev _button = null ; if ( ! this . frm ) return ; if ( cur _frm && cur _frm . fields [ cur _frm . fields . length - 1 ] && cur _frm . fields [ cur _frm . fields . length - 1 ] . df . fieldtype == 'Button' ) { this . make _body = function ( ) { this . prev _button = cur _frm . fields [ cur _frm . fields . length - 1 ] ; if ( ! this . prev _button . prev _button ) { this . prev _button . button _area = $a ( this . prev _button . input _area , 'span' ) ; }
this . wrapper = this . prev _button . wrapper ; this . input _area = this . prev _button . input _area ; this . disp _area = this . prev _button . disp _area ; this . button _area = $a ( this . prev _button . input _area , 'span' ) ; } } }
_f . ButtonField . prototype . make _input = function ( ) { var me = this ; if ( ! this . prev _button ) { $y ( this . input _area , { marginTop : '4px' , marginBottom : '4px' } ) ; }
if ( ! this . button _area )
this . button _area = $a ( this . input _area , 'span' , '' , { marginRight : '4px' } ) ; this . input = $btn ( this . button _area , me . df . label . substr ( 0 , 20 ) + ( ( me . df . label . length > 20 ) ? '..' : '' ) , null , { maxWidth : '170px' , fontWeight : 'bold' } , null , 1 )
this . input . onclick = function ( ) { if ( me . not _in _form ) return ; this . disabled = 'disabled' ; if ( cur _frm . cscript [ me . df . label ] && ( ! me . in _filter ) ) { cur _frm . runclientscript ( me . df . label , me . doctype , me . docname ) ; this . disabled = false ; } else { cur _frm . runscript ( me . df . options , me ) ; this . disabled = false ; } } }
_f . ButtonField . prototype . hide = function ( ) { $dh ( this . button _area ) ; } ; _f . ButtonField . prototype . show = function ( ) { $ds ( this . button _area ) ; } ; _f . ButtonField . prototype . set = function ( v ) { } ; _f . ButtonField . prototype . set _disp = function ( val ) { }
function make _field ( docfield , doctype , parent , frm , in _grid , hide _label ) { switch ( docfield . fieldtype . toLowerCase ( ) ) { case 'data' : var f = new DataField ( ) ; break ; case 'password' : var f = new DataField ( ) ; break ; case 'int' : var f = new IntField ( ) ; break ; case 'float' : var f = new FloatField ( ) ; break ; case 'currency' : var f = new CurrencyField ( ) ; break ; case 'read only' : var f = new ReadOnlyField ( ) ; break ; case 'link' : var f = new LinkField ( ) ; break ; case 'date' : var f = new DateField ( ) ; break ; case 'time' : var f = new TimeField ( ) ; break ; case 'html' : var f = new HTMLField ( ) ; break ; case 'check' : var f = new CheckField ( ) ; break ; case 'text' : var f = new TextField ( ) ; break ; case 'small text' : var f = new TextField ( ) ; break ; case 'select' : var f = new SelectField ( ) ; break ; case 'button' : var f = new _f . ButtonField ( ) ; break ; case 'code' : var f = new _f . CodeField ( ) ; break ; case 'text editor' : var f = new _f . CodeField ( ) ; break ; case 'table' : var f = new _f . TableField ( ) ; break ; case 'section break' : var f = new _f . SectionBreak ( ) ; break ; case 'column break' : var f = new _f . ColumnBreak ( ) ; break ; case 'image' : var f = new _f . ImageField ( ) ; break ; }
f . parent = parent ; f . doctype = doctype ; f . df = docfield ; f . perm = frm ? frm . perm : [ [ 1 , 1 , 1 ] ] ; if ( _f )
f . col _break _width = _f . cur _col _break _width ; if ( in _grid ) { f . in _grid = true ; f . with _label = 0 ; }
if ( hide _label ) { f . with _label = 0 ; }
if ( frm ) { f . frm = frm ; if ( parent )
f . layout _cell = parent . parentNode ; }
if ( f . init ) f . init ( ) ; f . make _body ( ) ; return f ; }
/ *
* lib / js / wn / ui / dialog . js
* /
wn . widgets . FieldGroup = function ( ) { this . first _button = false ; this . make _fields = function ( body , fl ) { $y ( this . body , { padding : '11px' } ) ; this . fields _dict = { } ; for ( var i = 0 ; i < fl . length ; i ++ ) { var df = fl [ i ] ; var div = $a ( body , 'div' , '' , { margin : '6px 0px' } )
f = make _field ( df , null , div , null ) ; f . not _in _form = 1 ; this . fields _dict [ df . fieldname ] = f
f . refresh ( ) ; if ( df . fieldtype == 'Button' && ! this . first _button ) { $ ( f . input ) . addClass ( 'primary' ) ; this . first _button = true ; } } }
this . get _values = function ( ) { var ret = { } ; var errors = [ ] ; for ( var key in this . fields _dict ) { var f = this . fields _dict [ key ] ; var v = f . get _value ? f . get _value ( ) : null ; if ( f . df . reqd && ! v )
errors . push ( f . df . label + ' is mandatory' ) ; if ( v ) ret [ f . df . fieldname ] = v ; }
if ( errors . length ) { msgprint ( '<b>Please check the following Errors</b>\n' + errors . join ( '\n' ) ) ; return null ; }
return ret ; }
this . set _value = function ( key , val ) { var f = this . fields _dict [ key ] ; if ( f ) { f . set _input ( val ) ; f . refresh _mandatory ( ) ; } }
this . set _values = function ( dict ) { for ( var key in dict ) { if ( this . fields _dict [ key ] ) { this . set _value ( key , dict [ key ] ) ; } } }
this . clear = function ( ) { for ( key in this . fields _dict ) { var f = this . fields _dict [ key ] ; if ( f ) { f . set _input ( f . df [ 'default' ] || '' ) ; } } } }
wn . widgets . Dialog = function ( opts ) { this . opts = opts ; this . display = false ; this . make = function ( opts ) { if ( opts )
this . opts = opts ; if ( ! this . opts . width ) this . opts . width = 480 ; this . wrapper = $a ( popup _cont , 'div' , 'dialog_wrapper' ) ; if ( this . opts . width )
this . wrapper . style . width = this . opts . width + 'px' ; this . make _head ( ) ; this . body = $a ( this . wrapper , 'div' , 'dialog_body' ) ; if ( this . opts . fields )
this . make _fields ( this . body , this . opts . fields ) ; }
this . make _head = function ( ) { var me = this ; this . head = $a ( this . wrapper , 'div' , 'dialog_head' ) ; var t = make _table ( this . head , 1 , 2 , '100%' , [ '100%' , '16px' ] , { padding : '2px' } ) ; $y ( $td ( t , 0 , 0 ) , { paddingLeft : '16px' , fontWeight : 'bold' , fontSize : '14px' , textAlign : 'center' } ) ; $y ( $td ( t , 0 , 1 ) , { textAlign : 'right' } ) ; var img = $a ( $td ( t , 0 , 01 ) , 'img' , '' , { cursor : 'pointer' } ) ; img . src = 'lib/images/icons/close.gif' ; this . title _text = $td ( t , 0 , 0 ) ; this . set _title ( this . opts . title ) ; img . onclick = function ( ) { if ( me . oncancel ) me . oncancel ( ) ; me . hide ( ) ; }
this . cancel _img = img ; }
this . set _title = function ( t ) { this . title _text . innerHTML = t ? t : '' ; }
this . set _postion = function ( ) { var d = get _screen _dims ( ) ; this . wrapper . style . left = ( ( d . w - cint ( this . wrapper . style . width ) ) / 2 ) + 'px' ; this . wrapper . style . top = ( get _scroll _top ( ) + 60 ) + 'px' ; top _index ++ ; $y ( this . wrapper , { zIndex : top _index } ) ; }
this . show = function ( ) { if ( this . display ) return ; this . set _postion ( )
$ds ( this . wrapper ) ; freeze ( ) ; this . display = true ; cur _dialog = this ; if ( this . onshow ) this . onshow ( ) ; }
this . hide = function ( ) { if ( this . onhide ) this . onhide ( ) ; unfreeze ( ) ; $dh ( this . wrapper ) ; if ( cur _autosug ) cur _autosug . clearSuggestions ( ) ; this . display = false ; cur _dialog = null ; }
this . no _cancel = function ( ) { $dh ( this . cancel _img ) ; }
if ( opts ) this . make ( ) ; }
2012-02-17 08:34:55 +00:00
wn . widgets . Dialog . prototype = new wn . widgets . FieldGroup ( ) ; $ ( document ) . bind ( 'keydown' , function ( e ) { if ( cur _dialog && ! cur _dialog . no _cancel _flag && e . which == 27 ) { cur _dialog . hide ( ) ; } } ) ;
2012-02-14 06:14:13 +00:00
/ *
* lib / js / legacy / widgets / dialog . js
* /
var cur _dialog ; var top _index = 91 ; function Dialog ( w , h , title , content ) { this . make ( { width : w , title : title } ) ; if ( content ) this . make _body ( content ) ; this . onshow = '' ; this . oncancel = '' ; this . no _cancel _flag = 0 ; this . display = false ; this . first _button = false ; }
Dialog . prototype = new wn . widgets . Dialog ( )
Dialog . prototype . make _body = function ( content ) { this . rows = { } ; this . widgets = { } ; for ( var i in content ) this . make _row ( content [ i ] ) ; }
Dialog . prototype . clear _inputs = function ( d ) { for ( var wid in this . widgets ) { var w = this . widgets [ wid ] ; var tn = w . tagName ? w . tagName . toLowerCase ( ) : '' ; if ( tn == 'input' || tn == 'textarea' ) { w . value = '' ; } else if ( tn == 'select' ) { sel _val ( w . options [ 0 ] . value ) ; } else if ( w . txt ) { w . txt . value = '' ; } else if ( w . input ) { w . input . value = '' ; } } }
Dialog . prototype . make _row = function ( d ) { var me = this ; this . rows [ d [ 1 ] ] = $a ( this . body , 'div' , 'dialog_row' ) ; var row = this . rows [ d [ 1 ] ] ; if ( d [ 0 ] != 'HTML' ) { var t = make _table ( row , 1 , 2 , '100%' , [ '30%' , '70%' ] ) ; row . tab = t ; var c1 = $td ( t , 0 , 0 ) ; var c2 = $td ( t , 0 , 1 ) ; if ( d [ 0 ] != 'Check' && d [ 0 ] != 'Button' )
$t ( c1 , d [ 1 ] ) ; }
if ( d [ 0 ] == 'HTML' ) { if ( d [ 2 ] ) row . innerHTML = d [ 2 ] ; this . widgets [ d [ 1 ] ] = row ; }
else if ( d [ 0 ] == 'Check' ) { var i = $a _input ( c2 , 'checkbox' , '' , { width : '20px' } ) ; c1 . innerHTML = d [ 1 ] ; this . widgets [ d [ 1 ] ] = i ; }
else if ( d [ 0 ] == 'Data' ) { c1 . innerHTML = d [ 1 ] ; c2 . style . overflow = 'auto' ; this . widgets [ d [ 1 ] ] = $a _input ( c2 , 'text' ) ; if ( d [ 2 ] ) $a ( c2 , 'div' , 'field_description' ) . innerHTML = d [ 2 ] ; }
else if ( d [ 0 ] == 'Link' ) { c1 . innerHTML = d [ 1 ] ; var f = make _field ( { fieldtype : 'Link' , 'label' : d [ 1 ] , 'options' : d [ 2 ] } , '' , c2 , this , 0 , 1 ) ; f . not _in _form = 1 ; f . dialog = this ; f . refresh ( ) ; this . widgets [ d [ 1 ] ] = f . input ; }
else if ( d [ 0 ] == 'Date' ) { c1 . innerHTML = d [ 1 ] ; var f = make _field ( { fieldtype : 'Date' , 'label' : d [ 1 ] , 'options' : d [ 2 ] } , '' , c2 , this , 0 , 1 ) ; f . not _in _form = 1 ; f . refresh ( ) ; f . dialog = this ; this . widgets [ d [ 1 ] ] = f . input ; }
else if ( d [ 0 ] == 'Password' ) { c1 . innerHTML = d [ 1 ] ; c2 . style . overflow = 'auto' ; this . widgets [ d [ 1 ] ] = $a _input ( c2 , 'password' ) ; if ( d [ 3 ] ) $a ( c2 , 'div' , 'field_description' ) . innerHTML = d [ 3 ] ; }
else if ( d [ 0 ] == 'Select' ) { c1 . innerHTML = d [ 1 ] ; this . widgets [ d [ 1 ] ] = $a ( c2 , 'select' , '' , { width : '160px' } )
if ( d [ 2 ] ) $a ( c2 , 'div' , 'field_description' ) . innerHTML = d [ 2 ] ; if ( d [ 3 ] ) add _sel _options ( this . widgets [ d [ 1 ] ] , d [ 3 ] , d [ 3 ] [ 0 ] ) ; }
else if ( d [ 0 ] == 'Text' ) { c1 . innerHTML = d [ 1 ] ; c2 . style . overflow = 'auto' ; this . widgets [ d [ 1 ] ] = $a ( c2 , 'textarea' ) ; if ( d [ 2 ] ) $a ( c2 , 'div' , 'field_description' ) . innerHTML = d [ 2 ] ; }
else if ( d [ 0 ] == 'Button' ) { c2 . style . height = '32px' ; var b = $btn ( c2 , d [ 1 ] , function ( btn ) { if ( btn . _onclick ) btn . _onclick ( me ) } , null , null , 1 ) ; b . dialog = me ; if ( ! this . first _button ) { $ ( b ) . addClass ( 'primary' ) ; this . first _button = true ; }
if ( d [ 2 ] ) { b . _onclick = d [ 2 ] ; }
this . widgets [ d [ 1 ] ] = b ; } }
/ *
* lib / js / legacy / widgets / listing . js
* /
list _opts = { cell _style : { padding : '3px 2px' } , alt _cell _style : { } , head _style : { height : '20px' , overflow : 'hidden' , verticalAlign : 'middle' , fontWeight : 'bold' , padding : '1px' , fontSize : '13px' } , head _main _style : { padding : '0px' } , hide _export : 1 , hide _print : 1 , hide _refresh : 0 , hide _rec _label : 0 , show _calc : 1 , show _empty _tab : 0 , no _border : 1 , append _records : 1 , table _width : null } ; function Listing ( head _text , no _index , no _loading ) { this . start = 0 ; this . page _len = 20 ; this . filters _per _line = 7 ; this . cell _idx = 0 ; this . head _text = head _text ? head _text : 'Result' ; this . keyword = 'records' ; this . no _index = no _index ; this . underline = 1 ; this . no _rec _message = 'No Result' ; this . show _cell = null ; this . show _result = null ; this . colnames = null ; this . colwidths = null ; this . coltypes = null ; this . coloptions = null ; this . filters = { } ; this . sort _list = { } ; this . sort _order _dict = { } ; this . sort _heads = { } ; this . is _std _query = false ; this . server _call = null ; this . no _loading = no _loading ; this . opts = copy _dict ( list _opts ) ; }
Listing . prototype . make = function ( parent ) { var me = this ; this . wrapper = parent ; this . filter _wrapper = $a ( parent , 'div' , 'srs_filter_wrapper' ) ; this . filter _area = $a ( this . filter _wrapper , 'div' , 'srs_filter_area' ) ; $dh ( this . filter _wrapper ) ; this . btn _area = $a ( parent , 'div' , '' , { margin : '8px 0px' } ) ; this . body _area = $a ( parent , 'div' , 'srs_body_area' ) ; if ( ! this . opts . hide _rec _label )
this . rec _label = $a ( this . body _area , 'div' , '' , { margin : '4px 0px' , color : '#888' } ) ; this . results = $a ( $a ( this . body _area , 'div' , 'srs_results_area' ) , 'div' ) ; this . fetching _area = $a ( this . body _area , 'div' , '' , { height : '120px' , background : 'url("lib/images/ui/square_loading.gif") center no-repeat' , display : 'none' } ) ; this . show _no _records = $a ( this . body _area , 'div' , '' , { margin : '200px 0px' , textAlign : 'center' , fontSize : '14px' , color : '#888' , display : 'none' } ) ; this . show _no _records . innerHTML = 'No Result' ; if ( this . opts . show _empty _tab )
this . make _result _tab ( ) ; this . bottom _div = $a ( this . body _area , 'div' , '' , { paddingTop : '8px' } ) ; this . make _toolbar ( ) ; }
Listing . prototype . make _toolbar = function ( ) { var me = this ; this . buttons = { } ; var make _btn = function ( label , icon , onclick , bold ) { var btn = $btn ( me . btn _area , label , onclick , { marginRight : '4px' } ) ; if ( bold ) $y ( btn , { fontWeight : 'bold' } ) ; me . buttons [ label ] = btn ; }
if ( ! this . opts . hide _refresh ) { make _btn ( 'Refresh' , 'ui-icon-refresh' , function ( btn ) { me . start = 0 ; me . run ( ) ; } , 1 ) ; }
if ( this . opts . show _new ) { make _btn ( 'New ' , 'ui-icon-document' , function ( ) { new _doc ( me . dt ) ; } , 1 ) ; }
if ( this . opts . show _report ) { make _btn ( 'Report Builder' , 'ui-icon-clipboard' , function ( ) { loadreport ( me . dt , null , null , null , 1 ) ; } , 0 ) ; }
if ( ! this . opts . hide _export ) { make _btn ( 'Export' , 'ui-icon-circle-arrow-e' , function ( ) { me . do _export ( ) ; } ) ; }
if ( ! this . opts . hide _print ) { make _btn ( 'Print' , 'ui-icon-print' , function ( ) { me . do _print ( ) ; } ) ; }
if ( this . opts . show _calc ) { make _btn ( 'Calc' , 'ui-icon-calculator' , function ( ) { me . do _calc ( ) ; } ) ; $dh ( me . buttons [ 'Calc' ] ) }
this . loading _img = $a ( this . btn _area , 'img' , '' , { display : 'none' , marginBottom : '-2px' } ) ; this . loading _img . src = 'lib/images/ui/button-load.gif' ; if ( ! keys ( this . buttons ) . length )
$dh ( this . btn _area ) ; }
Listing . prototype . do _print = function ( ) { this . build _query ( ) ; if ( ! this . query ) { alert ( 'No Query!' ) ; return ; }
args = { query : this . query , title : this . head _text , colnames : this . colnames , colwidths : this . colwidths , coltypes : this . coltypes , has _index : ( this . no _index ? 0 : 1 ) , has _headings : 1 , check _limit : 1 , is _simple : 1 }
wn . require ( 'lib/js/legacy/widgets/print_query.js' ) ; _p . print _query = new _p . PrintQuery ( ) ; _p . print _query . show _dialog ( args ) ; }
Listing . prototype . do _calc = function ( ) { show _calc ( this . result _tab , this . colnames , this . coltypes , 0 ) }
Listing . prototype . add _filter = function ( label , ftype , options , tname , fname , cond ) { if ( ! this . filter _area ) { alert ( '[Listing] make() must be called before add_filter' ) ; }
var me = this ; if ( ! this . filter _set ) { var h = $a ( this . filter _area , 'div' , '' , { fontSize : '14px' , fontWeight : 'bold' , marginBottom : '4px' } ) ; h . innerHTML = 'Filter your search' ; this . filter _area . div = $a ( this . filter _area , 'div' ) ; this . perm = [ [ 1 , 1 ] , ]
this . filters = { } ; }
$ds ( this . filter _wrapper ) ; if ( ( ! this . inp _tab ) || ( this . cell _idx == this . filters _per _line ) ) { this . inp _tab = $a ( this . filter _area . div , 'table' , '' , { width : '100%' , tableLayout : 'fixed' } ) ; this . inp _tab . insertRow ( 0 ) ; for ( var i = 0 ; i < this . filters _per _line ; i ++ ) { this . inp _tab . rows [ 0 ] . insertCell ( i ) ; }
this . cell _idx = 0 ; }
var c = this . inp _tab . rows [ 0 ] . cells [ this . cell _idx ] ; this . cell _idx ++ ; $y ( c , { width : cint ( 100 / this . filters _per _line ) + '%' , textAlign : 'left' , verticalAlign : 'top' } ) ; var d1 = $a ( c , 'div' , '' , { fontSize : '11px' , marginBottom : '2px' } ) ; d1 . innerHTML = label ; if ( ftype == 'Link' ) d1 . innerHTML += ' <img src="lib/images/icons/link.png" style="margin-bottom:-5px" title="Link">' ; var d2 = $a ( c , 'div' ) ; if ( in _list ( [ 'Text' , 'Small Text' , 'Code' , 'Text Editor' , 'Read Only' ] , ftype ) )
ftype = 'Data' ; if ( ftype == 'Select' && ! in _list ( options . split ( '\n' ) , '' ) ) options = '\n' + options
var inp = make _field ( { fieldtype : ftype , 'label' : label , 'options' : options , no _buttons : 1 } , '' , d2 , this , 0 , 1 ) ; inp . not _in _form = 1 ; inp . report = this ; inp . df . single _select = 1 ; inp . parent _cell = c ; inp . parent _tab = this . input _tab ; $y ( inp . wrapper , { width : '95%' } ) ; inp . refresh ( ) ; inp . tn = tname ; inp . fn = fname ; inp . condition = ftype == 'Data' ? 'like' : cond ; var me = this ; inp . onchange = function ( ) { me . start = 0 ; }
this . filters [ label ] = inp ; this . filter _set = 1 ; }
Listing . prototype . remove _filter = function ( label ) { var inp = this . filters [ label ] ; inp . parent _tab . rows [ 0 ] . deleteCell ( inp . parent _cell . cellIndex ) ; delete this . filters [ label ] ; }
Listing . prototype . remove _all _filters = function ( ) { for ( var k in this . filters ) this . remove _filter ( k ) ; $dh ( this . filter _wrapper ) ; }
Listing . prototype . add _sort = function ( ci , fname ) { this . sort _list [ ci ] = fname ; }
Listing . prototype . has _data = function ( ) { return this . n _records ; }
Listing . prototype . set _default _sort = function ( fname , sort _order ) { this . sort _order = sort _order ; this . sort _order _dict [ fname ] = sort _order ; this . sort _by = fname ; if ( this . sort _heads [ fname ] )
this . sort _heads [ fname ] . set _sorting _as ( sort _order ) ; }
Listing . prototype . set _sort = function ( cell , ci , fname ) { var me = this ; $y ( cell . sort _cell , { width : '18px' } ) ; cell . sort _img = $a ( cell . sort _cell , 'img' ) ; cell . fname = fname ; $dh ( cell . sort _img ) ; cell . set _sort _img = function ( order ) { var t = 'images/icons/sort_desc.gif' ; if ( order == 'ASC' ) { t = 'images/icons/sort_asc.gif' ; }
this . sort _img . src = t ; }
cell . set _sorting _as = function ( order ) { me . sort _order = order ; me . sort _by = this . fname
me . sort _order _dict [ this . fname ] = order ; this . set _sort _img ( order )
if ( me . cur _sort ) { $y ( me . cur _sort , { backgroundColor : "#FFF" } ) ; $dh ( me . cur _sort . sort _img ) ; }
me . cur _sort = this ; $y ( this , { backgroundColor : "#DDF" } ) ; $di ( this . sort _img ) ; }
$y ( cell . label _cell , { color : '#44A' , cursor : 'pointer' } ) ; cell . set _sort _img ( me . sort _order _dict [ fname ] ? me . sort _order _dict [ fname ] : 'ASC' ) ; cell . onmouseover = function ( ) { $di ( this . sort _img ) ; }
cell . onmouseout = function ( ) { if ( this != me . cur _sort )
$dh ( this . sort _img ) ; }
cell . onclick = function ( ) { this . set _sorting _as ( ( me . sort _order _dict [ fname ] == 'ASC' ) ? 'DESC' : 'ASC' ) ; me . run ( ) ; }
this . sort _heads [ fname ] = cell ; }
Listing . prototype . do _export = function ( ) { this . build _query ( ) ; var me = this ; me . cn = [ ] ; if ( this . no _index )
me . cn = this . colnames ; else { for ( var i = 1 ; i < this . colnames . length ; i ++ )
me . cn . push ( this . colnames [ i ] ) ; }
var q = export _query ( this . query , function ( query ) { export _csv ( query , me . head _text , null , 1 , null , me . cn ) ; } ) ; }
Listing . prototype . build _query = function ( ) { if ( this . get _query ) this . get _query ( this ) ; if ( ! this . query ) { alert ( 'No Query!' ) ; return ; }
if ( ! this . prefix ) this . prefix = 'tab' ; var cond = [ ] ; for ( var i in this . filters ) { var f = this . filters [ i ] ; var val = f . get _value ( ) ; var c = f . condition ; if ( ! c ) c = '=' ; if ( val && c . toLowerCase ( ) == 'like' ) val += '%' ; if ( f . tn && val && ! in _list ( [ 'All' , 'Select...' , '' ] , val ) )
cond . push ( repl ( ' AND `%(prefix)s%(dt)s`.%(fn)s %(condition)s "%(val)s"' , { prefix : this . prefix , dt : f . tn , fn : f . fn , condition : c , val : val } ) ) ; }
if ( cond ) { this . query += NEWLINE + cond . join ( NEWLINE )
if ( this . query _max )
this . query _max += NEWLINE + cond . join ( NEWLINE ) }
if ( this . group _by )
this . query += ' ' + this . group _by + ' ' ; if ( this . sort _by && this . sort _order ) { this . query += NEWLINE + ' ORDER BY `' + this . sort _by + '` ' + this . sort _order ; }
if ( this . show _query ) msgprint ( this . query ) ; }
Listing . prototype . set _rec _label = function ( total , cur _page _len ) { if ( this . opts . hide _rec _label )
return ; else if ( total == - 1 )
this . rec _label . innerHTML = 'Fetching...'
else if ( total > 0 )
this . rec _label . innerHTML = repl ( 'Total %(total)s %(keyword)s. Showing %(start)s to %(end)s' , { total : total , start : cint ( this . start ) + 1 , end : cint ( this . start ) + cint ( cur _page _len ) , keyword : this . keyword } ) ; else if ( total == null )
this . rec _label . innerHTML = ''
else if ( total == 0 )
this . rec _label . innerHTML = this . no _rec _message ; }
Listing . prototype . run = function ( run _callback ) { this . build _query ( ) ; var q = this . query ; var me = this ; if ( this . max _len && this . start >= this . max _len ) this . start -= this . page _len ; q += ' LIMIT ' + this . start + ',' + this . page _len ; var call _back = function ( r , rt ) { $dh ( me . loading _img ) ; me . max _len = r . n _values ; if ( r . values && r . values . length ) { me . n _records = r . values . length ; var nc = r . values [ 0 ] . length ; if ( me . colwidths ) nc = me . colwidths . length - ( me . no _index ? 0 : 1 ) ; if ( me . opts . append _records && me . start != 0 ) { me . append _rows ( r . values . length ) ; } else { me . clear _tab ( ) ; if ( ! me . show _empty _tab ) { me . remove _result _tab ( ) ; me . make _result _tab ( r . values . length ) ; } }
me . refresh ( r . values . length , nc , r . values , r . n _values ) ; me . total _records = r . n _values ; me . set _rec _label ( r . n _values , r . values . length ) ; } else { me . n _records = 0 ; me . set _rec _label ( 0 ) ; me . clear _tab ( ) ; if ( ! me . opts . append _records ) { if ( me . show _empty _tab ) { me . clear _tab ( ) ; } else { me . remove _result _tab ( ) ; me . make _result _tab ( 0 ) ; if ( me . opts . show _no _records _label ) { $ds ( me . show _no _records ) ; } } } }
$ds ( me . results ) ; if ( run _callback ) run _callback ( ) ; if ( me . onrun ) me . onrun ( ) ; }
$dh ( me . show _no _records ) ; this . set _rec _label ( - 1 ) ; $di ( this . loading _img ) ; if ( this . server _call ) { this . server _call ( this , call _back ) ; } else { args = { query _max : ( this . query _max ? this . query _max : '' ) }
if ( this . is _std _query ) args . query = q ; else args . simple _query = q ; if ( this . opts . formatted ) args . formatted = 1 ; $c ( 'webnotes.widgets.query_builder.runquery' , args , call _back , null , this . no _loading ) ; } }
Listing . prototype . remove _result _tab = function ( ) { if ( ! this . result _tab ) return ; this . result _tab . parentNode . removeChild ( this . result _tab ) ; delete this . result _tab ; }
Listing . prototype . reset _tab = function ( ) { this . remove _result _tab ( ) ; this . make _result _tab ( ) ; }
Listing . prototype . make _result _tab = function ( nr ) { if ( this . result _tab ) return ; if ( ! this . colwidths ) alert ( "Listing: Must specify column widths" ) ; var has _headrow = this . colnames ? 1 : 0 ; if ( nr == null ) nr = this . page _len ; nr += has _headrow ; var nc = this . colwidths . length ; var t = make _table ( this . results , nr , nc , ( this . opts . table _width ? this . opts . table _width : '100%' ) , this . colwidths , { padding : '0px' } ) ; t . className = 'srs_result_tab' ; this . result _tab = t ; $y ( t , { borderCollapse : 'collapse' } ) ; if ( this . opts . table _width ) { $y ( this . results , { overflowX : 'auto' } ) ; $y ( t , { tableLayout : 'fixed' } ) ; }
if ( has _headrow ) { this . make _headings ( t , nr , nc ) ; if ( this . sort _by && this . sort _heads [ this . sort _by ] ) { this . sort _heads [ this . sort _by ] . set _sorting _as ( this . sort _order ) ; } }
this . set _table _style ( ) ; if ( this . opts . no _border == 1 ) { $y ( t , { border : '0px' } ) ; }
this . result _tab = t ; }
Listing . prototype . set _table _style = function ( ) { var t = this . result _tab ; for ( var ri = ( this . colnames ? 1 : 0 ) ; ri < t . rows . length ; ri ++ ) { for ( var ci = 0 ; ci < t . rows [ ri ] . cells . length ; ci ++ ) { if ( this . opts . cell _style ) $y ( $td ( t , ri , ci ) , this . opts . cell _style ) ; if ( this . opts . alt _cell _style && ( ri % 2 ) ) $y ( $td ( t , ri , ci ) , this . opts . alt _cell _style ) ; if ( this . opts . show _empty _tab && ! $td ( t , ri , ci ) . innerHTML ) $td ( t , ri , ci ) . innerHTML = ' ' ; } } }
Listing . prototype . append _rows = function ( nr ) { for ( var i = 0 ; i < nr ; i ++ ) { append _row ( this . result _tab ) ; }
this . set _table _style ( ) ; }
Listing . prototype . clear _tab = function ( ) { $dh ( this . results ) ; if ( this . result _tab ) { var nr = this . result _tab . rows . length ; var nc = this . result _tab . rows [ 0 ] . cells . length ; for ( var ri = ( this . colnames ? 1 : 0 ) ; ri < nr ; ri ++ )
for ( var ci = 0 ; ci < nc ; ci ++ )
$td ( this . result _tab , ri , ci ) . innerHTML = ( this . opts . show _empty _tab ? ' ' : '' ) ; } }
Listing . prototype . clear = function ( ) { this . rec _label . innerHTML = '' ; this . clear _tab ( ) ; }
Listing . prototype . refresh _calc = function ( ) { if ( ! this . opts . show _calc ) return ; if ( has _common ( this . coltypes , [ 'Currency' , 'Int' , 'Float' ] ) ) { $di ( this . buttons [ 'Calc' ] ) ; } else { $dh ( this . buttons [ 'Calc' ] ) ; } }
Listing . prototype . refresh = function ( nr , nc , d , n _values ) { this . refresh _more _button ( nr , n _values ) ; this . refresh _calc ( ) ; if ( this . show _result )
this . show _result ( ) ; else { if ( nr ) { var start = this . result _tab . rows . length - nr ; for ( var ri = start ; ri < start + nr ; ri ++ ) { var c0 = $td ( this . result _tab , ri , 0 ) ; if ( ! this . no _index ) { c0 . innerHTML = cint ( this . start ) + cint ( ri - start ) + 1 ; }
for ( var ci = 0 ; ci < nc ; ci ++ ) { var c = $td ( this . result _tab , ri , ci + ( this . no _index ? 0 : 1 ) ) ; if ( c ) { c . innerHTML = '' ; if ( this . show _cell ) this . show _cell ( c , ri - start , ci , d ) ; else this . std _cell ( c , ri - start , ci , d ) ; } } } } } }
Listing . prototype . refresh _more _button = function ( nr , n _values ) { var me = this ; if ( this . more _btn ) { $dh ( this . more _btn ) ; }
if ( ( this . start + nr ) == this . max _len || ( ! this . max _len && nr < this . page _len ) ) { } else if ( nr ) { if ( ! this . more _btn ) { $y ( this . bottom _div , { margin : '8px 0px 16px 0px' , textAlign : 'center' } ) ; this . more _btn = $btn ( this . bottom _div , 'Show more results...' , function ( ) { me . start = me . start + me . page _len ; me . more _btn . set _working ( ) ; me . run ( function ( ) { me . more _btn . done _working ( ) ; } ) ; } , { fontSize : '14px' } , 0 , 1 ) ; $y ( this . more _btn . loading _img , { marginBottom : '0px' } ) ; }
$di ( this . more _btn ) ; } }
Listing . prototype . make _headings = function ( t , nr , nc ) { for ( var ci = 0 ; ci < nc ; ci ++ ) { var tmp = make _table ( $td ( t , 0 , ci ) , 1 , 2 , '100%' , [ '' , '0px' ] , this . opts . head _style ) ; $y ( tmp , { tableLayout : 'fixed' , borderCollapse : 'collapse' } ) ; $y ( $td ( t , 0 , ci ) , this . opts . head _main _style ) ; $td ( t , 0 , ci ) . sort _cell = $td ( tmp , 0 , 1 ) ; $td ( t , 0 , ci ) . label _cell = $td ( tmp , 0 , 0 ) ; $td ( tmp , 0 , 1 ) . style . padding = '0px' ; $td ( tmp , 0 , 0 ) . innerHTML = this . colnames [ ci ] ? this . colnames [ ci ] : ' ' ; if ( this . sort _list [ ci ] ) this . set _sort ( $td ( t , 0 , ci ) , ci , this . sort _list [ ci ] ) ; var div = $a ( $td ( t , 0 , ci ) , 'div' ) ; $td ( t , 0 , ci ) . style . borderBottom = '1px solid #CCC' ; if ( this . coltypes && this . coltypes [ ci ] && in _list ( [ 'Currency' , 'Float' , 'Int' ] , this . coltypes [ ci ] ) ) $y ( $td ( t , 0 , ci ) . label _cell , { textAlign : 'right' } ) } }
Listing . prototype . std _cell = function ( cell , ri , ci , d ) { var has _headrow = this . colnames ? 1 : 0 ; cell . div = $a ( cell , 'div' ) ; $s ( cell . div , d [ ri ] [ ci ] , this . coltypes ? this . coltypes [ ci + ( this . no _index ? 0 : 1 ) ] : null , this . coloptions ? this . coloptions [ ci + ( this . no _index ? 0 : 1 ) ] : null ) ; }
/ *
* lib / js / wn / ui / listing . js
* /
wn . widgets . Listing = function ( opts ) { this . opts = opts ; this . page _length = 20 ; this . btns = { } ; this . start = 0 ; var me = this ; this . make = function ( opts ) { this . wrapper = $a ( this . opts . parent , 'div' ) ; this . filters _area = $a ( this . wrapper , 'div' , 'listing-filters' ) ; this . toolbar _area = $a ( this . wrapper , 'div' , 'listing-toolbar' ) ; this . results _area = $a ( this . wrapper , 'div' , 'listing-results' ) ; this . more _button _area = $a ( this . wrapper , 'div' , 'listing-more' ) ; this . no _results _area = $a ( this . wrapper , 'div' , 'help_box' , { display : 'none' } , ( this . opts . no _result _message ? this . opts . no _result _message : 'No results' ) ) ; if ( opts ) this . opts = opts ; this . page _length = this . opts . page _length ? this . opts . page _length : this . page _length ; this . make _toolbar ( ) ; this . make _filters ( ) ; this . make _more _button ( ) ; }
this . make _filters = function ( ) { if ( this . opts . filters ) { $ds ( this . filters _area ) ; this . filters = new wn . widgets . FieldGroup ( this . filters _area , this . opts . fields ) ; } }
this . make _toolbar = function ( ) { if ( ! this . opts . hide _refresh ) { this . ref _img = $a ( this . toolbar _area , 'span' , 'link_type' , { color : '#888' } , '[refresh]' ) ; this . ref _img . onclick = function ( ) { me . run ( ) ; }
this . loading _img = $a ( this . toolbar _area , 'img' , 'lib/images/ui/button-load.gif' , { display : 'none' , marginLeft : '3px' , marginBottom : '-2px' } ) ; }
if ( this . opts . new _doctype ) { this . new _btn = $btn ( this . toolbar _area , 'New ' + get _doctype _label ( this . opts . new _doctype ) , function ( ) { newdoc ( me . opts . new _doctype , me . opts . new _doc _onload , me . opts . new _doc _indialog , me . opts . new _doc _onsave ) ; } , { marginLeft : '7px' } ) ; } }
this . make _more _button = function ( ) { this . more _btn = $btn ( this . more _button _area , 'More...' , function ( ) { me . more _btn . set _working ( ) ; me . run ( function ( ) { me . more _btn . done _working ( ) ; } , 1 ) ; } , '' , 0 , 1 ) ; $y ( this . more _btn . loading _img , { marginBottom : '0px' } ) ; }
this . clear = function ( ) { this . results _area . innerHTML = '' ; this . table = null ; $ds ( this . results _area ) ; $dh ( this . no _results _area ) ; }
this . make _results = function ( r , rt ) { if ( this . start == 0 ) this . clear ( ) ; $dh ( this . more _button _area ) ; if ( this . loading _img ) $dh ( this . loading _img )
if ( r . values && r . values . length ) { this . values = r . values ; var m = Math . min ( r . values . length , this . page _length ) ; for ( var i = 0 ; i < m ; i ++ ) { var row = this . add _row ( ) ; this . opts . render _row ( row , r . values [ i ] , this , i ) ; }
this . start += m ; if ( r . values . length > this . page _length ) $ds ( this . more _button _area ) ; } else { if ( this . start == 0 ) { $dh ( this . results _area ) ; $ds ( this . no _results _area ) ; } }
if ( this . onrun ) this . onrun ( ) ; if ( this . opts . onrun ) this . opts . onrun ( ) ; }
this . add _row = function ( ) { return $a ( this . results _area , 'div' , '' , ( opts . cell _style ? opts . cell _style : { padding : '3px 0px' } ) ) ; }
this . run = function ( callback , append ) { if ( callback )
this . onrun = callback ; if ( ! append )
this . start = 0 ; this . query = this . opts . get _query ? this . opts . get _query ( ) : this . opts . query ; this . add _limits ( ) ; args = { query _max : this . query _max || this . opts . query _max || '' }
args . simple _query = this . query ; args . as _dict = 1 ; if ( this . loading _img ) $di ( this . loading _img ) ; wn . call ( { method : 'webnotes.widgets.query_builder.runquery' , args : args , callback : function ( r , rt ) { me . make _results ( r , rt ) } , no _spinner : this . opts . no _loading , btn : this . opts . run _btn } ) ; }
this . refresh = this . run ; this . add _limits = function ( ) { this . query += ' LIMIT ' + this . start + ',' + ( this . page _length + 1 ) ; }
if ( opts ) this . make ( ) ; }
/ *
* lib / js / legacy / widgets / layout . js
* /
function Layout ( parent , width ) { if ( parent && parent . substr ) { parent = $i ( parent ) ; }
this . wrapper = $a ( parent , 'div' , '' , { display : 'none' } ) ; if ( width ) { this . width = this . wrapper . style . width ; }
this . myrows = [ ] ; }
Layout . prototype . addrow = function ( ) { this . cur _row = new LayoutRow ( this , this . wrapper ) ; this . myrows [ this . myrows . length ] = this . cur _row ; return this . cur _row }
Layout . prototype . addsubrow = function ( ) { this . cur _row = new LayoutRow ( this , this . cur _row . main _body ) ; this . myrows [ this . myrows . length ] = this . cur _row ; return this . cur _row }
Layout . prototype . addcell = function ( width ) { return this . cur _row . addCell ( width ) ; }
Layout . prototype . setcolour = function ( col ) { $bg ( cc , col ) ; }
Layout . prototype . show = function ( ) { $ds ( this . wrapper ) ; }
Layout . prototype . hide = function ( ) { $dh ( this . wrapper ) ; }
Layout . prototype . close _borders = function ( ) { if ( this . with _border ) { this . myrows [ this . myrows . length - 1 ] . wrapper . style . borderBottom = '1px solid #000' ; } }
function LayoutRow ( layout , parent ) { this . layout = layout ; this . wrapper = $a ( parent , 'div' ) ; this . main _head = $a ( this . wrapper , 'div' ) ; this . main _body = $a ( this . wrapper , 'div' ) ; if ( layout . with _border ) { this . wrapper . style . border = '1px solid #000' ; this . wrapper . style . borderBottom = '0px' ; }
this . header = $a ( this . main _body , 'div' , '' , { padding : ( layout . with _border ? '0px 8px' : '0px' ) } ) ; this . body = $a ( this . main _body , 'div' ) ; this . table = $a ( this . body , 'table' , '' , { width : '100%' , borderCollapse : 'collapse' } ) ; this . row = this . table . insertRow ( 0 ) ; this . mycells = [ ] ; }
LayoutRow . prototype . hide = function ( ) { $dh ( this . wrapper ) ; }
LayoutRow . prototype . show = function ( ) { $ds ( this . wrapper ) ; }
LayoutRow . prototype . addCell = function ( wid ) { var lc = new LayoutCell ( this . layout , this , wid ) ; this . mycells [ this . mycells . length ] = lc ; return lc ; }
function LayoutCell ( layout , layoutRow , width ) { if ( width ) { var w = width + '' ; if ( w . substr ( w . length - 2 , 2 ) != 'px' ) { if ( w . substr ( w . length - 1 , 1 ) != "%" ) { width = width + '%' } ; } }
this . width = width ; this . layout = layout ; var cidx = layoutRow . row . cells . length ; this . cell = layoutRow . row . insertCell ( cidx ) ; this . cell . style . verticalAlign = 'top' ; this . set _width ( layoutRow . row , width ) ; var h = $a ( this . cell , 'div' , '' , { padding : ( layout . with _border ? '0px 8px' : '0px' ) } ) ; this . wrapper = $a ( this . cell , 'div' , '' , { padding : ( layout . with _border ? '8px' : '8px 0px' ) } ) ; layout . cur _cell = this . wrapper ; layout . cur _cell . header = h ; }
LayoutCell . prototype . set _width = function ( row , width ) { var w = 100 ; var n _cells = row . cells . length ; var cells _with _no _width = n _cells ; if ( width ) { $y ( row . cells [ n _cells - 1 ] , { width : cint ( width ) + '%' } ) } else { row . cells [ n _cells - 1 ] . estimated _width = 1 ; }
for ( var i = 0 ; i < n _cells ; i ++ ) { if ( ! row . cells [ i ] . estimated _width ) { w = w - cint ( row . cells [ i ] . style . width ) ; cells _with _no _width -- ; } }
for ( var i = 0 ; i < n _cells ; i ++ ) { if ( row . cells [ i ] . estimated _width )
$y ( row . cells [ i ] , { width : cint ( w / cells _with _no _width ) + '%' } ) } }
LayoutCell . prototype . show = function ( ) { $ds ( this . wrapper ) ; }
LayoutCell . prototype . hide = function ( ) { $dh ( this . wrapper ) ; }
/ *
* lib / js / legacy / widgets / tabbedpage . js
* /
function TabbedPage ( parent , only _labels ) { this . tabs = { } ; this . items = this . tabs
this . cur _tab = null ; this . label _wrapper = $a ( parent , 'div' , 'box_label_wrapper' , { marginTop : '16px' } ) ; this . label _body = $a ( this . label _wrapper , 'div' , 'box_label_body' ) ; this . label _area = $a ( this . label _body , 'ul' , 'box_tabs' ) ; if ( ! only _labels ) this . body _area = $a ( parent , 'div' , '' , { backgroundColor : '#FFF' } ) ; else this . body _area = null ; this . add _item = function ( label , onclick , no _body , with _heading ) { this . add _tab ( label , onclick , no _body , with _heading ) ; return this . items [ label ] ; } }
TabbedPage . prototype . add _tab = function ( n , onshow , no _body , with _heading ) { var tab = $a ( this . label _area , 'li' ) ; tab . label = $a ( tab , 'a' ) ; tab . label . innerHTML = n ; if ( this . body _area && ! no _body ) { tab . tab _body = $a ( this . body _area , 'div' ) ; $dh ( tab . tab _body ) ; tab . body = tab . tab _body ; } else { tab . tab _body = null ; }
tab . onshow = onshow ; var me = this ; tab . collapse = function ( ) { if ( this . tab _body ) $dh ( this . tab _body ) ; this . className = '' ; if ( hide _autosuggest )
hide _autosuggest ( ) ; }
tab . set _selected = function ( ) { if ( me . cur _tab ) me . cur _tab . collapse ( ) ; this . className = 'box_tab_selected' ; $op ( this , 100 ) ; me . cur _tab = this ; }
tab . expand = function ( arg ) { this . set _selected ( ) ; if ( this . tab _body ) $ds ( this . tab _body ) ; if ( this . onshow ) this . onshow ( arg ) ; }
tab . onmouseover = function ( ) { if ( me . cur _tab != this ) this . className = 'box_tab_mouseover' ; }
tab . onmouseout = function ( ) { if ( me . cur _tab != this ) this . className = '' }
tab . hide = function ( ) { this . collapse ( ) ; $dh ( this ) ; }
tab . show = function ( ) { $ds ( this ) ; }
tab . onclick = function ( ) { this . expand ( ) ; }
this . tabs [ n ] = tab ; return tab ; }
function TrayPage ( parent , height , width , width _body ) { var me = this ; if ( ! width ) width = ( 100 / 8 ) + '%' ; this . body _style = { margin : '4px 8px' }
this . cur _item = null ; this . items = { } ; this . tabs = this . items
this . tab = make _table ( $a ( parent , 'div' ) , 1 , 2 , '100%' , [ width , width _body ] ) ; $y ( $td ( this . tab , 0 , 0 ) , { backgroundColor : this . tray _bg , width : width } ) ; this . body = $a ( $td ( this . tab , 0 , 1 ) , 'div' ) ; if ( height ) { $y ( this . body , { height : height , overflow : 'auto' } ) ; }
this . add _item = function ( label , onclick , no _body , with _heading ) { this . items [ label ] = new TrayItem ( me , label , onclick , no _body , with _heading ) ; return this . items [ label ] ; } }
function TrayItem ( tray , label , onclick , no _body , with _heading ) { this . label = label ; this . onclick = onclick ; var me = this ; this . ldiv = $a ( $td ( tray . tab , 0 , 0 ) , 'div' ) ; $item _normal ( this . ldiv ) ; if ( ! no _body ) { this . wrapper = $a ( tray . body , 'div' , '' , tray . body _style ) ; if ( with _heading ) { this . header = $a ( this . wrapper , 'div' , 'sectionHeading' , { marginBottom : '16px' , paddingBottom : '0px' } ) ; this . header . innerHTML = label ; }
this . body = $a ( this . wrapper , 'div' ) ; this . tab _body = this . body ; $dh ( this . wrapper ) ; }
$ ( this . ldiv ) . html ( label ) . hover ( function ( ) { if ( tray . cur _item . label != this . label ) $item _active ( this ) ; } , function ( ) { if ( tray . cur _item . label != this . label ) $item _normal ( this ) ; } ) . click ( function ( ) { me . expand ( ) ; } )
this . ldiv . label = label ; this . ldiv . setAttribute ( 'title' , label ) ; this . ldiv . onmousedown = function ( ) { $item _pressed ( this ) ; }
this . ldiv . onmouseup = function ( ) { $item _selected ( this ) ; }
this . expand = function ( ) { if ( tray . cur _item ) tray . cur _item . collapse ( ) ; if ( me . wrapper ) $ds ( me . wrapper ) ; if ( me . onclick ) me . onclick ( me . label ) ; me . show _as _expanded ( ) ; }
this . show _as _expanded = function ( ) { $item _selected ( me . ldiv ) ; tray . cur _item = me ; }
this . collapse = function ( ) { if ( me . wrapper ) $dh ( me . wrapper ) ; $item _normal ( me . ldiv ) ; }
this . hide = function ( ) { me . collapse ( ) ; $dh ( me . ldiv ) ; }
this . show = function ( ) { $ds ( me . ldiv ) ; } }
/ *
* lib / js / legacy / webpage / page _header . js
* /
var def _ph _style = { wrapper : { marginBottom : '16px' , backgroundColor : '#EEE' } , main _heading : { } , sub _heading : { marginBottom : '8px' , color : '#555' , display : 'none' } , separator : { borderTop : '3px solid #444' } , toolbar _area : { padding : '3px 0px' , display : 'none' , borderBottom : '1px solid #AAA' } }
function PageHeader ( parent , main _text , sub _text ) { this . wrapper = $a ( parent , 'div' , 'page_header' ) ; this . t1 = make _table ( $a ( this . wrapper , 'div' , '' , def _ph _style . wrapper . backgroundColor ) , 1 , 2 , '100%' , [ null , '100px' ] , { padding : '2px' } ) ; $y ( this . t1 , { borderCollapse : 'collapse' } )
this . lhs = $td ( this . t1 , 0 , 0 ) ; this . main _head = $a ( this . lhs , 'h1' , '' , def _ph _style . main _heading ) ; this . sub _head = $a ( this . lhs , 'h4' , '' , def _ph _style . sub _heading ) ; this . separator = $a ( this . wrapper , 'div' , '' , def _ph _style . separator ) ; this . toolbar _area = $a ( this . wrapper , 'div' , '' , def _ph _style . toolbar _area ) ; this . padding _area = $a ( this . wrapper , 'div' , '' , { padding : '3px' } ) ; $y ( $td ( this . t1 , 0 , 1 ) , { textAlign : 'right' , padding : '3px' } ) ; this . close _btn = $a ( $td ( this . t1 , 0 , 1 ) , 'span' , 'close' , { } , '×' ) ; this . close _btn . onclick = function ( ) { nav _obj . show _last _open ( ) ; } ; if ( main _text ) this . main _head . innerHTML = main _text ; if ( sub _text ) this . sub _head . innerHTML = sub _text ; this . buttons = { } ; this . buttons2 = { } ; }
PageHeader . prototype . add _button = function ( label , fn , bold , icon , green ) { var tb = this . toolbar _area ; if ( this . buttons [ label ] ) return ; var btn = $btn ( tb , label , fn , { marginRight : '4px' } , ( green ? 'primary' : '' ) ) ; if ( bold ) $y ( btn , { fontWeight : 'bold' } ) ; this . buttons [ label ] = btn ; $ds ( this . toolbar _area ) ; return btn ; }
PageHeader . prototype . clear _toolbar = function ( ) { this . toolbar _area . innerHTML = '' ; this . buttons = { } ; }
PageHeader . prototype . make _buttonset = function ( ) { $ ( this . toolbar _area ) . buttonset ( ) ; }
/ *
* lib / js / legacy / widgets / select . js
* /
function SelectWidget ( parent , options , width , editable , bg _color ) { var me = this ; this . inp = $a ( parent , 'select' ) ; if ( options ) add _sel _options ( this . inp , options ) ; if ( width ) $y ( this . inp , { width : width } ) ; this . set _width = function ( w ) { $y ( this . inp , { width : w } ) } ; this . set _options = function ( o ) { add _sel _options ( this . inp , o ) ; }
this . inp . onchange = function ( ) { if ( me . onchange ) me . onchange ( this ) ; }
return ; }
/ *
* lib / js / legacy / widgets / tags . js
* /
_tags = { dialog : null , color _map : { } , all _tags : [ ] , colors : { 'Default' : '#add8e6' } }
TagList = function ( parent , start _list , dt , dn , static , onclick ) { this . start _list = start _list ? start _list : [ ] ; this . tag _list = [ ] ; this . dt = dt ; this . onclick = onclick ; this . dn = dn ; this . static ; this . parent = parent ; this . make _body ( ) ; }
TagList . prototype . make = function ( parent ) { for ( var i = 0 ; i < this . start _list . length ; i ++ ) { if ( this . start _list [ i ] )
new SingleTag ( { parent : this . body , label : this . start _list [ i ] , dt : this . dt , dn : this . dn , fieldname : '_user_tags' , static : this . static , taglist : this , onclick : this . onclick } ) ; } }
TagList . prototype . make _body = function ( ) { var div = $a ( this . parent , 'span' , '' , { margin : '3px 0px' , padding : '3px 0px' } ) ; this . body = $a ( div , 'span' , '' , { marginRight : '4px' } ) ; this . add _tag _area = $a ( div , 'span' ) ; this . make _add _tag ( ) ; this . make ( ) ; }
TagList . prototype . add _tag = function ( label , static , fieldname , color ) { if ( ! label ) return ; if ( in _list ( this . tag _list , label ) ) return ; var tag = new SingleTag ( { parent : this . body , label : label , dt : this . dt , dn : this . dn , fieldname : fieldname , static : static , taglist : this , color : color , onclick : this . onclick } ) ; }
TagList . prototype . make _add _tag = function ( ) { var me = this ; this . add _tag _span = $a ( this . add _tag _area , 'span' , '' , { color : '#888' , textDecoration : 'underline' , cursor : 'pointer' , marginLeft : '4px' , fontSize : '11px' } ) ; this . add _tag _span . innerHTML = 'Add tag' ; this . add _tag _span . onclick = function ( ) { me . new _tag ( ) ; } }
TagList . prototype . make _tag _dialog = function ( ) { var me = this ; var d = new wn . widgets . Dialog ( { title : 'Add a tag' , width : 400 , fields : [ { fieldtype : 'Link' , fieldname : 'tag' , label : 'Tag' , options : 'Tag' , reqd : 1 , description : 'Max chars (20)' , no _buttons : 1 } , { fieldtype : 'Button' , fieldname : 'add' , label : 'Add' } ] } )
$ ( d . fields _dict . tag . input ) . attr ( 'maxlength' , 20 ) ; d . fields _dict . add . input . onclick = function ( ) { me . save _tag ( d ) ; }
return d ; }
TagList . prototype . is _text _okay = function ( val ) { if ( ! val ) { msgprint ( "Please type something" ) ; return ; }
if ( validate _spl _chars ( val ) ) { msgprint ( "Special charaters, commas etc not allowed in tags" ) ; return ; }
return 1 }
TagList . prototype . add _to _locals = function ( tag ) { if ( locals [ this . dt ] && locals [ this . dt ] [ this . dn ] ) { var doc = locals [ this . dt ] [ this . dn ] ; if ( ! doc . _user _tags ) { doc . _user _tags = '' }
var tl = doc . _user _tags . split ( ',' )
tl . push ( tag )
doc . _user _tags = tl . join ( ',' ) ; } }
TagList . prototype . remove _from _locals = function ( tag ) { if ( locals [ this . dt ] && locals [ this . dt ] [ this . dn ] ) { var doc = locals [ this . dt ] [ this . dn ] ; var tl = doc . _user _tags . split ( ',' ) ; var new _tl = [ ] ; for ( var i = 0 ; i < tl . length ; i ++ ) { if ( tl [ i ] != tag ) new _tl . push ( tl [ i ] ) ; }
doc . _user _tags = new _tl . join ( ',' ) ; } }
TagList . prototype . save _tag = function ( d ) { var val = d . get _values ( ) ; if ( val ) val = val . tag ; var me = this ; if ( ! this . is _text _okay ( val ) ) return ; var callback = function ( r , rt ) { var d = me . dialog ; d . fields _dict . add . input . done _working ( ) ; d . fields _dict . tag . input . set _input ( '' ) ; d . hide ( ) ; me . add _to _locals ( val )
if ( ! r . message ) return ; me . add _tag ( r . message , 0 , '_user_tags' ) ; }
me . dialog . fields _dict . add . input . set _working ( ) ; $c ( 'webnotes.widgets.tags.add_tag' , { 'dt' : me . dt , 'dn' : me . dn , 'tag' : val , 'color' : 'na' } , callback ) ; }
TagList . prototype . new _tag = function ( ) { var me = this ; if ( ! this . dialog ) { this . dialog = this . make _tag _dialog ( ) ; }
this . dialog . show ( ) ; }
TagList . prototype . refresh _tags = function ( ) { }
function SingleTag ( opts ) { $ . extend ( this , opts ) ; if ( ! this . color ) this . color = '#add8e6' ; if ( this . taglist && ! in _list ( this . taglist . tag _list , this . label ) )
this . taglist . tag _list . push ( this . label ) ; this . make _body ( this . parent ) ; }
SingleTag . prototype . make _body = function ( parent ) { var me = this ; this . body = $a ( parent , 'span' , '' , { padding : '2px 4px' , backgroundColor : this . color , color : '#226' , marginRight : '4px' } ) ; $br ( this . body , '3px' ) ; if ( this . onclick ) $y ( this . body , { cursor : 'pointer' } ) ; $ ( this . body ) . hover ( function ( ) { $op ( this , 60 ) ; } , function ( ) { $op ( this , 100 ) ; } ) ; this . make _label ( ) ; if ( ! this . static ) this . make _remove _btn ( ) ; _tags . all _tags . push ( this ) ; }
SingleTag . prototype . make _remove _btn = function ( ) { var me = this ; var span = $a ( this . body , 'span' ) ; span . innerHTML += ' |' ; var span = $a ( this . body , 'span' , '' , { cursor : 'pointer' } ) ; span . innerHTML = ' x'
span . onclick = function ( ) { me . remove ( me ) ; } }
SingleTag . prototype . make _label = function ( ) { var me = this ; this . label _span = $a ( this . body , 'span' , 'social' , null , this . label ) ; this . label _span . onclick = function ( ) { if ( me . onclick ) me . onclick ( me ) ; } }
SingleTag . prototype . remove _tag _body = function ( ) { $dh ( this . body ) ; var nl = [ ] ; for ( var i in this . tag _list )
if ( this . tag _list [ i ] != this . label )
nl . push ( this . tag _list [ i ] ) ; if ( this . taglist )
this . taglist . tag _list = nl ; }
SingleTag . prototype . remove = function ( ) { var me = this ; var callback = function ( r , rt ) { me . remove _tag _body ( )
me . taglist . remove _from _locals ( me . label ) ; }
$c ( 'webnotes.widgets.tags.remove_tag' , { 'dt' : me . dt , 'dn' : me . dn , 'tag' : me . label } , callback )
$bg ( me . body , '#DDD' ) ; }
wn . widgets . TagCloud = function ( parent , doctype , onclick ) { var me = this ; this . make = function ( r , rt ) { parent . innerHTML = '' ; if ( r . message && r . message . length ) { me . tab = make _table ( parent , r . message . length , 2 , '100%' , [ '40px' , null ] , { padding : '5px 3px 5px 0px' } )
$y ( $td ( me . tab , 0 , 0 ) , { textAlign : 'right' } ) ; for ( var i = 0 ; i < r . message . length ; i ++ ) { new wn . widgets . TagCloud . Tag ( { parent : $td ( me . tab , i , 1 ) , label : r . message [ i ] [ 0 ] , onclick : onclick , fieldname : r . message [ i ] [ 2 ] } , $td ( me . tab , i , 0 ) , r . message [ i ] ) } } else { me . set _no _tags ( ) ; }
me . refresh = $ln ( $a ( parent , 'div' ) , 'refresh' , function ( ) { me . refresh . set _working ( ) ; me . render ( 1 ) ; } , { fontSize : '11px' , margin : '3px 0px' , color : '#888' } , 1 ) ; }
this . set _no _tags = function ( ) { $a ( parent , 'div' , 'social comment' , { fontSize : '11px' , margin : '3px 0px' } , '<i>No tags yet!, please start tagging</i>' ) ; }
this . render = function ( refresh ) { $c ( 'webnotes.widgets.tags.get_top_tags' , { doctype : doctype , refresh : ( refresh ? 1 : 0 ) } , this . make ) ; }
this . render ( ) ; }
wn . widgets . TagCloud . Tag = function ( args , count _cell , det ) { $ ( count _cell ) . css ( 'text-align' , 'right' ) . html ( det [ 1 ] + ' x' ) ; args . static = 1 ; this . tag = new SingleTag ( args ) }
/ *
* lib / js / legacy / widgets / export _query . js
* /
var export _dialog ; function export _query ( query , callback ) { if ( ! export _dialog ) { var d = new Dialog ( 400 , 300 , "Export..." ) ; d . make _body ( [ [ 'Data' , 'Max rows' , 'Blank to export all rows' ] , [ 'Button' , 'Go' ] , ] ) ; d . widgets [ 'Go' ] . onclick = function ( ) { export _dialog . hide ( ) ; n = export _dialog . widgets [ 'Max rows' ] . value ; if ( cint ( n ) )
export _dialog . query += ' LIMIT 0,' + cint ( n ) ; callback ( export _dialog . query ) ; }
d . onshow = function ( ) { this . widgets [ 'Max rows' ] . value = '500' ; }
export _dialog = d ; }
export _dialog . query = query ; export _dialog . show ( ) ; }
function export _csv ( q , report _name , sc _id , is _simple , filter _values , colnames ) { var args = { }
args . cmd = 'webnotes.widgets.query_builder.runquery_csv' ; if ( is _simple )
args . simple _query = q ; else
args . query = q ; args . sc _id = sc _id ? sc _id : '' ; args . filter _values = filter _values ? filter _values : '' ; if ( colnames )
args . colnames = colnames . join ( ',' ) ; args . report _name = report _name ? report _name : '' ; open _url _post ( outUrl , args ) ; }
/ *
* lib / js / legacy / webpage / history . js
* /
var nav _obj = { }
nav _obj . observers = [ ] ; nav _obj . add _observer = function ( o ) { nav _obj . observers . push ( o ) ; }
nav _obj . ol = [ ] ; nav _obj . open _notify = function ( t , dt , dn , no _history ) { if ( nav _obj . ol . length ) { var tmp = nav _obj . ol [ nav _obj . ol . length - 1 ] ; if ( tmp && tmp [ 0 ] == t && tmp [ 1 ] == dt && tmp [ 2 ] == dn ) return ; }
if ( ! no _history ) { var tmp = [ ] ; for ( var i in nav _obj . ol )
if ( ! ( nav _obj . ol [ i ] [ 0 ] == t && nav _obj . ol [ i ] [ 1 ] == dt && nav _obj . ol [ i ] [ 2 ] == dn ) ) tmp . push ( nav _obj . ol [ i ] ) ; nav _obj . ol = tmp ; nav _obj . ol . push ( [ t , dt , dn ] )
en _t = encodeURIComponent ( t ) ; en _dt = encodeURIComponent ( dt ) ; en _dn = dn ? encodeURIComponent ( dn ) : '' ; if ( en _t == 'Page' ) { var id = en _dt + ( dn ? ( '/' + en _dn ) : '' ) } else { var id = en _t + '/' + en _dt + ( dn ? ( '/' + en _dn ) : '' ) }
if ( nav _obj . on _open )
nav _obj . on _open ( id ) ; if ( window . location . hash != '!' + id ) { window . location . hash = '!' + id ; } }
2012-02-14 11:55:31 +00:00
nav _obj . notify _observers ( t , dt , dn ) ; if ( wn . boot . analytics _code ) { try { eval ( wn . boot . analytics _code ) ; } catch ( e ) { console . log ( e ) ; } } }
2012-02-14 06:14:13 +00:00
nav _obj . notify _observers = function ( t , dt , dn ) { for ( var i = 0 ; i < nav _obj . observers . length ; i ++ ) { var o = nav _obj . observers [ i ] ; if ( o && o . notify ) o . notify ( t , dt , dn ) ; } }
nav _obj . rename _notify = function ( dt , oldn , newn ) { for ( var i = 0 ; i < nav _obj . ol . length ; i ++ ) { var o = nav _obj . ol [ i ] ; if ( o [ 1 ] == dt && o [ 2 ] == oldn ) o [ 2 ] = newn ; } }
nav _obj . show _last _open = function ( ) { var l = nav _obj . ol [ nav _obj . ol . length - 2 ] ; delete nav _obj . ol [ nav _obj . ol . length - 1 ] ; if ( ! l ) loadpage ( '_home' ) ; else if ( l [ 0 ] == 'Page' ) { loadpage ( l [ 1 ] ) ; } else if ( l [ 0 ] == 'Report' ) { loadreport ( l [ 1 ] , l [ 2 ] ) ; } else if ( l [ 0 ] == 'Form' ) { loaddoc ( l [ 1 ] , l [ 2 ] ) ; } else if ( l [ 0 ] == 'DocBrowser' || l [ 0 ] == 'List' ) { loaddocbrowser ( l [ 1 ] ) ; } }
var _history _current ; function history _get _name ( t ) { var parts = [ ] ; if ( t . length >= 3 ) { for ( var i = 2 ; i < t . length ; i ++ ) { parts . push ( t [ i ] ) ; } }
return parts . join ( '/' ) }
nav _obj . get _page = function ( loc ) { if ( ! loc ) loc = window . location . hash ; if ( loc . substr ( 0 , 1 ) == '#' ) { loc = loc . substr ( 1 ) ; }
if ( loc . substr ( 0 , 1 ) == '!' ) { loc = loc . substr ( 1 ) ; }
if ( ! in _list ( [ 'Page/' , 'Form/' , 'Repor' , 'DocBr' , 'List/' ] , loc . substr ( 0 , 5 ) ) ) { loc = 'Page/' + loc ; }
return loc . split ( '/' ) ; }
function historyChange ( newLocation ) { var t = nav _obj . get _page ( newLocation )
for ( var i = 0 ; i < t . length ; i ++ )
t [ i ] = decodeURIComponent ( t [ i ] ) ; if ( nav _obj . ol . length ) { var c = nav _obj . ol [ nav _obj . ol . length - 1 ] ; if ( t . length == 2 ) { if ( c [ 0 ] == t [ 0 ] && c [ 1 ] == t [ 1 ] ) return ; } else { if ( c [ 0 ] == t [ 0 ] && c [ 1 ] == t [ 1 ] && c [ 2 ] == t [ 2 ] ) return ; } }
if ( t [ 2 ] )
var docname = history _get _name ( t ) ; if ( t [ 0 ] == 'Form' ) { _history _current = newLocation ; if ( docname . substr ( 0 , 3 ) == 'New' && ! ( locals [ t [ 1 ] ] && locals [ t [ 1 ] ] [ docname ] ) ) { newdoc ( t [ 1 ] ) ; } else { loaddoc ( t [ 1 ] , docname ) ; } } else if ( t [ 0 ] == 'Report' ) { _history _current = newLocation ; loadreport ( t [ 1 ] , docname ) ; } else if ( t [ 0 ] == 'Page' ) { _history _current = newLocation ; loadpage ( t [ 1 ] ) ; } else if ( t [ 0 ] == 'Application' ) { _history _current = newLocation ; loadapp ( t [ 1 ] ) ; } else if ( t [ 0 ] == 'DocBrowser' || t [ 0 ] == 'List' ) { _history _current = newLocation ; loaddocbrowser ( t [ 1 ] ) ; } } ; $ ( window ) . bind ( 'hashchange' , function ( ) { historyChange ( location . hash ) ; } ) ;
/ *
* lib / js / legacy / webpage / search . js
* /
search _fields = { } ; function setlinkvalue ( name ) { selector . input . set _input ( name ) ; selector . hide ( ) ; }
function makeselector ( ) { var d = new Dialog ( 540 , 440 , 'Search' ) ; d . make _body ( [ [ 'Data' , 'Beginning With' , 'Tip: You can use wildcard "%"' ] , [ 'Select' , 'Search By' ] , [ 'Button' , 'Search' ] , [ 'HTML' , 'Help' ] , [ 'HTML' , 'Result' ] ] ) ; var inp = d . widgets [ 'Beginning With' ] ; var field _sel = d . widgets [ 'Search By' ] ; var btn = d . widgets [ 'Search' ] ; d . sel _type = '' ; d . values _len = 0 ; d . set = function ( input , type , label ) { d . sel _type = type ; d . input = input ; if ( d . style != 'Link' ) { d . rows [ 'Result' ] . innerHTML = '' ; d . values _len = 0 ; }
d . style = 'Link' ; d . set _query _description ( )
if ( ! d . sel _type ) d . sel _type = 'Value' ; d . set _title ( 'Select a "' + d . sel _type + '" for field "' + label + '"' ) ; }
d . set _search = function ( dt ) { if ( d . style != 'Search' ) { d . rows [ 'Result' ] . innerHTML = '' ; d . values _len = 0 ; }
d . style = 'Search' ; if ( d . input ) { d . input = null ; sel _type = null ; }
d . sel _type = get _label _doctype ( dt ) ; d . set _title ( 'Quick Search for ' + dt ) ; }
2012-02-17 08:34:55 +00:00
$ ( inp ) . keydown ( function ( e ) { if ( e . which == 13 ) { if ( ! btn . disabled ) btn . onclick ( ) ; } } )
2012-02-14 06:14:13 +00:00
d . set _query _description = function ( ) { if ( d . input && d . input . query _description ) { d . rows [ 'Help' ] . innerHTML = '<div class="help_box">' + d . input . query _description + '</div>' ; } else { d . rows [ 'Help' ] . innerHTML = '' } }
d . onshow = function ( ) { if ( d . set _doctype != d . sel _type ) { d . rows [ 'Result' ] . innerHTML = '' ; d . values _len = 0 ; }
inp . value = '' ; if ( d . input && d . input . txt . value ) { inp . value = d . input . txt . value ; }
try { inp . focus ( ) ; } catch ( e ) { }
if ( d . input ) d . input . set _get _query ( ) ; var get _sf _list = function ( dt ) { var l = [ ] ; var lf = search _fields [ dt ] ; for ( var i = 0 ; i < lf . length ; i ++ ) l . push ( lf [ i ] [ 1 ] ) ; return l ; }
$ds ( d . rows [ 'Search By' ] ) ; if ( search _fields [ d . sel _type ] ) { empty _select ( field _sel ) ; add _sel _options ( field _sel , get _sf _list ( d . sel _type ) , 'ID' ) ; } else { empty _select ( field _sel ) ; add _sel _options ( field _sel , [ 'ID' ] , 'ID' ) ; $c ( 'webnotes.widgets.search.getsearchfields' , { 'doctype' : d . sel _type } , function ( r , rt ) { search _fields [ d . sel _type ] = r . searchfields ; empty _select ( field _sel ) ; add _sel _options ( field _sel , get _sf _list ( d . sel _type ) ) ; field _sel . selectedIndex = 0 ; } ) ; } }
d . onhide = function ( ) { if ( d . input && d . input . txt )
d . input . txt . onchange ( ) }
btn . onclick = function ( ) { if ( this . disabled ) return ; this . args . is _ajax = true ; this . set _working ( ) ; d . set _doctype = d . sel _type ; var q = '' ; args = { } ; if ( d . input && d . input . get _query ) { var doc = { } ; args . is _simple = 1 ; if ( cur _frm ) doc = locals [ cur _frm . doctype ] [ cur _frm . docname ] ; var q = d . input . get _query ( doc , d . input . doctype , d . input . docname ) ; if ( ! q ) { return '' ; } }
var get _sf _fieldname = function ( v ) { var lf = search _fields [ d . sel _type ] ; if ( ! lf )
return 'name'
for ( var i = 0 ; i < lf . length ; i ++ ) if ( lf [ i ] [ 1 ] == v ) return lf [ i ] [ 0 ] ; }
$ . extend ( args , { 'txt' : strip ( inp . value ) , 'doctype' : d . sel _type , 'query' : q , 'searchfield' : get _sf _fieldname ( sel _val ( field _sel ) ) } ) ; $c ( 'webnotes.widgets.search.search_widget' , args , function ( r , rtxt ) { btn . done _working ( ) ; if ( r . coltypes ) r . coltypes [ 0 ] = 'Link' ; d . values _len = r . values . length ; d . set _result ( r ) ; } , function ( ) { btn . done _working ( ) ; } ) ; }
d . set _result = function ( r ) { d . rows [ 'Result' ] . innerHTML = '' ; var c = $a ( d . rows [ 'Result' ] , 'div' , 'comment' , { paddingBottom : '4px' , marginBottom : '4px' , borderBottom : '1px solid #CCC' , marginLeft : '4px' } ) ; if ( r . values . length == 50 )
c . innerHTML = 'Showing max 50 results. Use filters to narrow down your search' ; else
c . innerHTML = 'Showing ' + r . values . length + ' resuts.' ; var w = $a ( d . rows [ 'Result' ] , 'div' , '' , { height : '240px' , overflow : 'auto' , margin : '4px' } ) ; for ( var i = 0 ; i < r . values . length ; i ++ ) { var div = $a ( w , 'div' , '' , { marginBottom : '4px' , paddingBottom : '4px' , borderBottom : '1px dashed #CCC' } ) ; var l = $a ( $a ( div , 'div' ) , 'span' , 'link_type' ) ; l . innerHTML = r . values [ i ] [ 0 ] ; l . link _name = r . values [ i ] [ 0 ] ; l . dt = r . coloptions [ 0 ] ; if ( d . input )
l . onclick = function ( ) { setlinkvalue ( this . link _name ) ; }
else
l . onclick = function ( ) { loaddoc ( this . dt , this . link _name ) ; d . hide ( ) ; }
var cl = [ ]
for ( var j = 1 ; j < r . values [ i ] . length ; j ++ ) cl . push ( r . values [ i ] [ j ] ) ; var c = $a ( div , 'div' , 'comment' , { marginTop : '2px' } ) ; c . innerHTML = cl . join ( ', ' ) ; } }
selector = d ; }
/ *
* lib / js / legacy / webpage / spinner . js
* /
function set _loading ( ) { pending _req ++ ; $ ( '#spinner' ) . css ( 'visibility' , 'visible' ) ; $ ( 'body' ) . css ( 'cursor' , 'progress' ) ; }
function hide _loading ( ) { pending _req -- ; if ( ! pending _req ) { $ ( 'body' ) . css ( 'cursor' , 'default' ) ; $ ( '#spinner' ) . css ( 'visibility' , 'hidden' ) ; } }
/ *
* lib / js / legacy / webpage / freeze _page . js
* /
var fcount = 0 ; var frozen = 0 ; var dialog _message ; var dialog _back ; function freeze ( msg , do _freeze ) { if ( ! dialog _back ) { dialog _back = $a ( $i ( 'body_div' ) , 'div' , 'dialog_back' ) ; if ( isIE ) dialog _back . style [ 'filter' ] = 'alpha(opacity=60)' ; }
$ds ( dialog _back ) ; fcount ++ ; frozen = 1 ; }
function unfreeze ( ) { if ( dialog _message )
$dh ( dialog _message ) ; if ( ! fcount ) return ; fcount -- ; if ( ! fcount ) { $dh ( dialog _back ) ; frozen = 0 ; } }
/ *
* lib / js / legacy / webpage / error _console . js
* /
var err _console ; var err _list = [ ] ; function errprint ( t ) { err _list [ err _list . length ] = ( '<pre style="font-family: Courier, Fixed; font-size: 11px; border-bottom: 1px solid #AAA; overflow: auto; width: 90%;">' + t + '</pre>' ) ; }
function setup _err _console ( ) { err _console = new Dialog ( 640 , 480 , 'Error Console' )
err _console . make _body ( [ [ 'HTML' , 'Error List' ] , [ 'Button' , 'Clear' ] , [ 'HTML' , 'Error Report' ] ] ) ; var span = $a ( err _console . widgets [ 'Error Report' ] , 'span' , 'link_type' ) ; span . innerHTML = 'Send Error Report' ; span . onclick = function ( ) { msg = prompt ( 'How / where did you get the error [optional]' )
var call _back = function ( r , rt ) { err _console . hide ( ) ; msgprint ( "Error Report Sent" ) }
$c ( 'webnotes.utils.send_error_report' , { 'err_msg' : err _console . rows [ 'Error List' ] . innerHTML , 'msg' : msg } , call _back ) ; }
err _console . widgets [ 'Clear' ] . onclick = function ( ) { err _list = [ ] ; err _console . rows [ 'Error List' ] . innerHTML = '' ; err _console . hide ( ) ; }
err _console . onshow = function ( ) { err _console . rows [ 'Error List' ] . innerHTML = '<div style="padding: 16px; height: 360px; width: 90%; overflow: auto;">'
+ err _list . join ( '<div style="height: 10px; margin-bottom: 10px; border-bottom: 1px solid #AAA"></div>' ) + '</div>' ; } }
startup _list . push ( setup _err _console ) ;
/ *
* lib / js / legacy / webpage / loaders . js
* /
function loadreport ( dt , rep _name , onload , menuitem , reset _report ) { wn . require ( 'lib/js/legacy/report.compressed.js' ) ; dt = get _label _doctype ( dt ) ; var show _report _builder = function ( ) { if ( ! _r . rb _con ) { _r . rb _con = new _r . ReportContainer ( ) ; }
_r . rb _con . set _dt ( dt , function ( rb ) { if ( rep _name ) { var t = rb . current _loaded ; rb . load _criteria ( rep _name ) ; if ( onload )
onload ( rb ) ; if ( ( rb . dt ) && ( ! rb . dt . has _data ( ) || rb . current _loaded != t ) )
rb . dt . run ( ) ; } else { if ( reset _report ) { rb . reset _report ( ) ; } }
if ( ! rb . forbidden ) { page _body . change _to ( 'Report Builder' ) ; nav _obj . open _notify ( 'Report' , dt , rep _name ) ; } } ) ; }
show _report _builder ( ) ; }
var load _doc = loaddoc ; function loaddoc ( doctype , name , onload , menuitem , from _archive ) { doctype = get _label _doctype ( doctype ) ; if ( frms [ 'DocType' ] && frms [ 'DocType' ] . opendocs [ doctype ] ) { msgprint ( "Cannot open an instance of \"" + doctype + "\" when the DocType is open." ) ; return ; }
if ( doctype == 'DocType' && frms [ name ] ) { msgprint ( "Cannot open DocType \"" + name + "\" when its instance is open." ) ; return ; }
var show _form = function ( f ) { if ( ! _f . frm _con ) { _f . frm _con = new _f . FrmContainer ( ) ; }
if ( ! frms [ doctype ] ) { _f . add _frm ( doctype , show _doc , name , from _archive ) ; } else if ( LocalDB . is _doc _loaded ( doctype , name ) ) { show _doc ( ) ; } else { $c ( 'webnotes.widgets.form.load.getdoc' , { 'name' : name , 'doctype' : doctype , 'user' : user , 'from_archive' : ( from _archive ? 1 : 0 ) } , show _doc , null , null ) ; } }
var show _doc = function ( r , rt ) { if ( locals [ doctype ] && locals [ doctype ] [ name ] ) { page _body . set _status ( 'Done' ) ; var frm = frms [ doctype ] ; frm . refresh ( name ) ; if ( ! frm . in _dialog )
nav _obj . open _notify ( 'Form' , doctype , name ) ; if ( onload ) onload ( ) ; } else { if ( r . exc ) { msgprint ( 'There were errors while loading ' + doctype + ' ' + name ) ; }
loadpage ( '_home' ) ; } }
show _form ( ) ; }
function new _doc ( doctype , onload , in _dialog , on _save _callback , cdt , cdn , cnic ) { doctype = get _label _doctype ( doctype ) ; if ( ! doctype ) { if ( cur _frm ) doctype = cur _frm . doctype ; else return ; }
var show _doc = function ( ) { frm = frms [ doctype ] ; if ( frm . perm [ 0 ] [ CREATE ] == 1 ) { if ( frm . meta . issingle ) { var dn = doctype ; LocalDB . set _default _values ( locals [ doctype ] [ doctype ] ) ; } else
var dn = LocalDB . create ( doctype ) ; if ( onload ) onload ( dn ) ; if ( frm . in _dialog ) { var fd = _f . frm _dialog ; fd . cdt = cdt ; fd . cdn = cdn ; fd . cnic = cnic ; fd . on _save _callback = on _save _callback ; } else { nav _obj . open _notify ( 'Form' , doctype , dn ) ; }
frm . refresh ( dn ) ; } else { msgprint ( 'error:Not Allowed To Create ' + doctype + '\nContact your Admin for help' ) ; } }
var show _form = function ( ) { if ( ! _f . frm _con ) { _f . frm _con = new _f . FrmContainer ( ) ; }
if ( ! frms [ doctype ] )
_f . add _frm ( doctype , show _doc ) ; else
show _doc ( frms [ doctype ] ) ; }
show _form ( ) ; }
var newdoc = new _doc ; var pscript = { } ; var cur _page ; function loadpage ( page _name , call _back , no _history ) { if ( ! page _name ) return ; if ( page _name == '_home' )
page _name = home _page ; var fn = function ( r , rt ) { page _body . set _status ( 'Done' ) ; if ( page _body . pages [ page _name ] ) { var p = page _body . pages [ page _name ]
page _body . change _to ( page _name ) ; } else { var p = render _page ( page _name ) ; if ( ! p ) return ; }
cur _page = page _name ; if ( call _back ) call _back ( ) ; scroll ( 0 , 0 ) ; pscript . update _page _history ( page _name , no _history )
try { if ( pscript [ 'refresh_' + page _name ] ) pscript [ 'refresh_' + page _name ] ( ) ; } catch ( e ) { console . log ( e ) ; } }
if ( get _local ( 'Page' , page _name ) || page _body . pages [ page _name ] )
fn ( ) ; else { args = get _url _dict ( ) ; args . name = page _name ; $c ( 'webnotes.widgets.page.getpage' , args , fn ) ; } }
pscript . update _page _history = function ( page _name , no _history ) { var arg = null ; var t = null ; if ( window . location . hash ) { var t = nav _obj . get _page ( window . location . hash ) } else if ( get _url _arg ( 'page' ) ) { var t = nav _obj . get _page ( get _url _arg ( 'page' ) ) }
if ( t && t [ 1 ] == page _name ) arg = t [ 2 ] ; nav _obj . open _notify ( 'Page' , page _name , arg , no _history ) ; }
function loadscript ( src , call _back ) { set _loading ( ) ; var script = $a ( 'head' , 'script' ) ; script . type = 'text/javascript' ; script . src = src ; script . onload = function ( ) { if ( call _back ) call _back ( ) ; hide _loading ( ) ; }
script . onreadystatechange = function ( ) { if ( this . readyState == 'complete' || this . readyState == 'loaded' ) { hide _loading ( ) ; call _back ( ) ; } } }
var doc _browser _page ; function loaddocbrowser ( dt , label , fields ) { wn . require ( 'lib/js/legacy/webpage/docbrowser.js' ) ; dt = get _label _doctype ( dt ) ; if ( ! doc _browser _page )
doc _browser _page = new ItemBrowserPage ( ) ; doc _browser _page . show ( dt , label , fields ) ; nav _obj . open _notify ( 'List' , dt , '' ) ; }
/ *
* lib / js / legacy / webpage / uploader . js
* /
var uploaders = { } ; var upload _frame _count = 0 ; Uploader = function ( parent , args , callback ) { var id = 'frame' + upload _frame _count ; upload _frame _count ++ ; this . callback = callback ; var div = $a ( parent , 'div' ) ; div . innerHTML = '<iframe id="' + id + '" name="' + id + ' " src=" blank . html " \
style = "width:0px; height:0px; border:0px" > < / i f r a m e > ' ; v a r d i v = $ a ( p a r e n t , ' d i v ' ) ; d i v . i n n e r H T M L = ' < f o r m m e t h o d = " P O S T " e n c t y p e = " m u l t i p a r t / f o r m - d a t a " a c t i o n = " ' + o u t U r l + ' " t a r g e t = " ' + i d + ' " > < / f o r m > ' ; v a r u l _ f o r m = d i v . c h i l d N o d e s [ 0 ] ; v a r f _ l i s t = [ ] ; v a r i n p _ f d a t a = $ a _ i n p u t ( $ a ( u l _ f o r m , ' s p a n ' ) , ' f i l e ' , { n a m e : ' f i l e d a t a ' } , { m a r g i n L e f t : ' 7 p x ' } ) ; i f ( ! ( ' c m d ' i n a r g s ) ) { v a r i n p = $ a _ i n p u t ( $ a ( u l _ f o r m , ' s p a n ' ) , ' h i d d e n ' , { n a m e : ' c m d ' } ) ; i n p . v a l u e = ' u p l o a d f i l e ' ; }
var inp = $a _input ( $a ( ul _form , 'span' ) , 'hidden' , { name : 'uploader_id' } ) ; inp . value = id ; var inp = $a _input ( $a ( ul _form , 'span' ) , 'submit' , null , { marginLeft : '7px' } ) ; inp . value = 'Upload' ; $y ( inp , { width : '80px' } ) ; for ( var key in args ) { var inp = $a _input ( $a ( ul _form , 'span' ) , 'hidden' , { name : key } ) ; inp . value = args [ key ] ; }
uploaders [ id ] = this ; }
function upload _callback ( id , fid ) { uploaders [ id ] . callback ( fid ) ; }
/ *
* lib / js / legacy / webpage / page . js
* /
var pages = [ ] ; var stylesheets = [ ] ; function Page ( page _name , content ) { var me = this ; this . name = page _name ; this . trigger = function ( event ) { try { if ( pscript [ event + '_' + this . name ] )
pscript [ event + '_' + this . name ] ( this . wrapper ) ; } catch ( e ) { console . log ( e ) ; } }
this . onshow = function ( ) { set _title ( me . doc . title ? me . doc . title : me . name ) ; if ( ! me . onload _complete ) { me . trigger ( 'onload' ) ; me . onload _complete = true ; }
me . trigger ( 'onshow' ) ; cur _frm = null ; }
this . wrapper = page _body . add _page ( page _name , this . onshow ) ; this . cont = this . wrapper
if ( content )
this . wrapper . innerHTML = content ; if ( page _name == home _page )
pages [ '_home' ] = this ; return this ; }
function render _page ( page _name , menuitem ) { if ( ! page _name ) return ; if ( ( ! locals [ 'Page' ] ) || ( ! locals [ 'Page' ] [ page _name ] ) ) { loadpage ( '_home' ) ; return ; }
var pdoc = locals [ 'Page' ] [ page _name ] ; if ( pdoc . style ) set _style ( pdoc . style )
if ( pdoc . stylesheet ) { set _style ( locals . Stylesheet [ pdoc . stylesheet ] . stylesheet ) ; stylesheets . push ( pdoc . stylesheet ) ; }
var p = new Page ( page _name , pdoc . _Page _ _content ? pdoc . _Page _ _content : pdoc . content ) ; var script = pdoc . _ _script ? pdoc . _ _script : pdoc . script ; p . doc = pdoc ; if ( script ) { eval ( script ) ; }
page _body . change _to ( page _name ) ; return p ; }
function refresh _page ( page _name ) { var fn = function ( r , rt ) { render _page ( page _name ) }
$c ( 'webnotes.widgets.page.getpage' , { 'name' : page _name , stylesheets : JSON . stringify ( stylesheets ) } , fn ) ; }
/ *
* lib / js / legacy / wn / page _layout . js
* /
wn . PageLayout = function ( args ) { $ . extend ( this , args )
this . wrapper = $a ( this . parent , 'div' ) ; this . wtab = make _table ( this . wrapper , 1 , 2 , '100%' , [ this . main _width , this . sidebar _width ] ) ; this . main = $a ( $td ( this . wtab , 0 , 0 ) , 'div' , 'layout_wrapper' ) ; this . sidebar _area = $a ( $td ( this . wtab , 0 , 1 ) , 'div' ) ; this . head = $a ( this . main , 'div' ) ; this . toolbar _area = $a ( this . main , 'div' ) ; this . body = $a ( this . main , 'div' ) ; this . footer = $a ( this . main , 'div' ) ; if ( this . heading ) { this . page _head = new PageHeader ( this . head , this . heading ) ; } }
/ *
* lib / js / legacy / wn / widgets / page _sidebar . js
* /
wn . widgets . PageSidebar = function ( parent , opts ) { this . opts = opts
this . sections = { }
this . wrapper = $a ( parent , 'div' , 'psidebar-wrapper' )
this . refresh = function ( ) { this . wrapper . innerHTML = ''
if ( this . opts . title )
this . make _head ( ) ; for ( var i = 0 ; i < this . opts . sections . length ; i ++ ) { var section = this . opts . sections [ i ] ; if ( ( section . display && section . display ( ) ) || ! section . display ) { this . sections [ section . title ] = new wn . widgets . PageSidebarSection ( this , section ) ; } }
if ( this . opts . onrefresh ) { this . opts . onrefresh ( this ) } }
this . make _head = function ( ) { this . head = $a ( this . wrapper , 'div' , 'psidebar-head' , '' , this . opts . title ) ; }
this . refresh ( ) ; }
wn . widgets . PageSidebarSection = function ( sidebar , opts ) { this . items = [ ] ; this . sidebar = sidebar ; this . wrapper = $a ( sidebar . wrapper , 'div' , 'psidebar-section' ) ; this . head = $a ( this . wrapper , 'div' , 'psidebar-section-head' , '' , opts . title ) ; this . body = $a ( this . wrapper , 'div' , 'psidebar-section-body' ) ; $br ( this . wrapper , '5px' ) ; this . opts = opts ; this . make _items = function ( ) { for ( var i = 0 ; i < this . opts . items . length ; i ++ ) { var item = this . opts . items [ i ] ; if ( ( item . display && item . display ( ) ) || ! item . display ) { var div = $a ( this . body , 'div' , 'psidebar-section-item' ) ; this . make _one _item ( item , div ) ; } } }
this . make _one _item = function ( item , div ) { if ( item . type . toLowerCase ( ) == 'link' )
this . items [ item . label ] = new wn . widgets . PageSidebarLink ( this , item , div ) ; else if ( item . type . toLowerCase ( ) == 'button' )
this . items [ item . label ] = new wn . widgets . PageSidebarButton ( this , this . opts . items [ i ] , div ) ; else if ( item . type . toLowerCase ( ) == 'html' )
this . items [ item . label ] = new wn . widgets . PageSidebarHTML ( this , this . opts . items [ i ] , div ) ; }
this . add _icon = function ( parent , icon ) { if ( icon . substr ( 0 , 3 ) == 'ic-' ) { var img = $a ( parent , 'div' , 'wn-icon ' + icon , { cssFloat : 'left' , marginRight : '7px' , marginBottom : '-3px' } ) ; } else { var img = $a ( parent , 'img' , '' , { marginRight : '7px' , marginBottom : '-3px' } ) ; img . src = 'lib/images/icons/' + icon ; } }
this . refresh = function ( ) { this . body . innerHTML = '' ; if ( this . opts . render ) { this . opts . render ( this . body ) ; }
else
this . make _items ( ) ; }
this . refresh ( ) ; }
wn . widgets . PageSidebarLink = function ( section , opts , wrapper ) { this . wrapper = wrapper ; this . section = section ; this . opts = opts ; var me = this ; if ( opts . icon ) { section . add _icon ( this . wrapper , opts . icon ) ; }
this . ln = $a ( this . wrapper , 'span' , 'link_type psidebar-section-link' , opts . style , opts . label ) ; this . ln . onclick = function ( ) { me . opts . onclick ( me ) } ; }
wn . widgets . PageSidebarButton = function ( section , opts , wrapper ) { this . wrapper = wrapper ; this . section = section ; this . opts = opts ; var me = this ; this . btn = $btn ( this . wrapper , opts . label , opts . onclick , opts . style , opts . color ) ; }
wn . widgets . PageSidebarHTML = function ( section , opts , wrapper ) { wrapper . innerHTML = opts . content }
/ *
* lib / js / legacy / wn / widgets / footer . js
* /
wn . widgets . Footer = function ( args ) { $ . extend ( this , args ) ; this . make = function ( ) { this . wrapper = $a ( this . parent , 'div' , 'std-footer' ) ; this . table = make _table ( this . wrapper , 1 , this . columns , [ ] , { width : 100 / this . columns + '%' } ) ; this . render _items ( ) ; }
this . render _items = function ( ) { for ( var i = 0 ; i < this . items . length ; i ++ ) { var item = this . items [ i ] ; var div = $a ( $td ( this . table , 0 , item . column ) , 'div' , 'std-footer-item' ) ; div . label = $a ( $a ( div , 'div' ) , 'span' , 'link_type' , '' , item . label ) ; div . label . onclick = item . onclick ; if ( item . description ) { div . description = $a ( div , 'div' , 'field_description' , '' , item . description ) ; } } }
if ( this . items )
this . make ( ) ; }
/ *
* lib / js / legacy / model / local _data . js
* /
var locals = { 'DocType' : { } } ; var fields = { } ; var fields _list = { } ; var LocalDB = { } ; var READ = 0 ; var WRITE = 1 ; var CREATE = 2 ; var SUBMIT = 3 ; var CANCEL = 4 ; var AMEND = 5 ; LocalDB . getchildren = function ( child _dt , parent , parentfield , parenttype ) { var l = [ ] ; for ( var key in locals [ child _dt ] ) { var d = locals [ child _dt ] [ key ] ; if ( ( d . parent == parent ) && ( d . parentfield == parentfield ) ) { if ( parenttype ) { if ( d . parenttype == parenttype ) l . push ( d ) ; } else { l . push ( d ) ; } } }
l . sort ( function ( a , b ) { return ( cint ( a . idx ) - cint ( b . idx ) ) } ) ; return l ; }
LocalDB . add = function ( dt , dn ) { if ( ! locals [ dt ] ) locals [ dt ] = { } ; if ( locals [ dt ] [ dn ] ) delete locals [ dt ] [ dn ] ; locals [ dt ] [ dn ] = { 'name' : dn , 'doctype' : dt , 'docstatus' : 0 } ; return locals [ dt ] [ dn ] ; }
LocalDB . delete _doc = function ( dt , dn ) { var doc = get _local ( dt , dn ) ; for ( var ndt in locals ) { if ( locals [ ndt ] ) { for ( var ndn in locals [ ndt ] ) { var doc = locals [ ndt ] [ ndn ] ; if ( doc && doc . parenttype == dt && ( doc . parent == dn || doc . _ _oldparent == dn ) ) { delete locals [ ndt ] [ ndn ] ; } } } }
delete locals [ dt ] [ dn ] ; }
function get _local ( dt , dn ) { return locals [ dt ] ? locals [ dt ] [ dn ] : null ; }
LocalDB . sync = function ( list ) { if ( list . _kl ) list = expand _doclist ( list ) ; for ( var i = 0 ; i < list . length ; i ++ ) { var d = list [ i ] ; if ( ! d . name )
d . name = LocalDB . get _localname ( d . doctype ) ; LocalDB . add ( d . doctype , d . name ) ; locals [ d . doctype ] [ d . name ] = d ; if ( d . doctype == 'DocType' ) { fields _list [ d . name ] = [ ] ; } else if ( d . doctype == 'DocField' ) { if ( ! d . parent ) { alert ( 'Error: No parent specified for field "' + d . label + '"' ) ; }
if ( ! fields _list [ d . parent ] ) fields _list [ d . parent ] = [ ] ; fields _list [ d . parent ] [ fields _list [ d . parent ] . length ] = d ; if ( ! fields [ d . parent ] )
fields [ d . parent ] = { } ; if ( d . fieldname ) { fields [ d . parent ] [ d . fieldname ] = d ; } else if ( d . label ) { fields [ d . parent ] [ d . label ] = d ; } } else if ( d . doctype == 'Event' ) { if ( ( ! d . localname ) && _c . calendar && ( ! _c . calendar . has _event [ d . name ] ) )
_c . calendar . set _event ( d ) ; }
if ( d . localname )
notify _rename _observers ( d . doctype , d . localname , d . name ) ; } }
local _name _idx = { } ; LocalDB . get _localname = function ( doctype ) { if ( ! local _name _idx [ doctype ] ) local _name _idx [ doctype ] = 1 ; var n = 'New ' + get _doctype _label ( doctype ) + ' ' + local _name _idx [ doctype ] ; local _name _idx [ doctype ] ++ ; return n ; }
LocalDB . set _default _values = function ( doc ) { var doctype = doc . doctype ; var docfields = fields _list [ doctype ] ; if ( ! docfields ) { return ; }
var fields _to _refresh = [ ] ; for ( var fid = 0 ; fid < docfields . length ; fid ++ ) { var f = docfields [ fid ] ; if ( ! in _list ( no _value _fields , f . fieldtype ) && doc [ f . fieldname ] == null ) { var v = LocalDB . get _default _value ( f . fieldname , f . fieldtype , f [ 'default' ] ) ; if ( v ) { doc [ f . fieldname ] = v ; fields _to _refresh . push ( f . fieldname ) ; } } }
return fields _to _refresh ; }
LocalDB . is _doc _loaded = function ( dt , dn ) { var exists = false ; if ( locals [ dt ] && locals [ dt ] [ dn ] ) exists = true ; if ( exists && dt == 'DocType' && ! locals [ dt ] [ dn ] . _ _islocal && ! frms [ dt ] )
exists = false ; return exists ; }
function check _perm _match ( p , dt , dn ) { if ( ! dn ) return true ; var out = false ; if ( p . match ) { if ( user _defaults [ p . match ] ) { for ( var i = 0 ; i < user _defaults [ p . match ] . length ; i ++ ) { if ( user _defaults [ p . match ] [ i ] == locals [ dt ] [ dn ] [ p . match ] ) { return true ; } }
return false ; } else if ( ! locals [ dt ] [ dn ] [ p . match ] ) { return true ; } else { return false ; } } else { return true ; } }
function get _perm ( doctype , dn , ignore _submit ) { var perm = [ [ 0 , 0 ] , ] ; if ( in _list ( user _roles , 'Administrator' ) ) perm [ 0 ] [ READ ] = 1 ; var plist = getchildren ( 'DocPerm' , doctype , 'permissions' , 'DocType' ) ; for ( var pidx in plist ) { var p = plist [ pidx ] ; var pl = cint ( p . permlevel ? p . permlevel : 0 ) ; if ( in _list ( user _roles , p . role ) ) { if ( check _perm _match ( p , doctype , dn ) ) { if ( ! perm [ pl ] ) perm [ pl ] = [ ] ; if ( ! perm [ pl ] [ READ ] ) { if ( cint ( p . read ) ) perm [ pl ] [ READ ] = 1 ; else perm [ pl ] [ READ ] = 0 ; }
if ( ! perm [ pl ] [ WRITE ] ) { if ( cint ( p . write ) ) { perm [ pl ] [ WRITE ] = 1 ; perm [ pl ] [ READ ] = 1 ; } else perm [ pl ] [ WRITE ] = 0 ; }
if ( ! perm [ pl ] [ CREATE ] ) { if ( cint ( p . create ) ) perm [ pl ] [ CREATE ] = 1 ; else perm [ pl ] [ CREATE ] = 0 ; }
if ( ! perm [ pl ] [ SUBMIT ] ) { if ( cint ( p . submit ) ) perm [ pl ] [ SUBMIT ] = 1 ; else perm [ pl ] [ SUBMIT ] = 0 ; }
if ( ! perm [ pl ] [ CANCEL ] ) { if ( cint ( p . cancel ) ) perm [ pl ] [ CANCEL ] = 1 ; else perm [ pl ] [ CANCEL ] = 0 ; }
if ( ! perm [ pl ] [ AMEND ] ) { if ( cint ( p . amend ) ) perm [ pl ] [ AMEND ] = 1 ; else perm [ pl ] [ AMEND ] = 0 ; } } } }
if ( ( ! ignore _submit ) && dn && locals [ doctype ] [ dn ] . docstatus > 0 ) { for ( pl in perm )
perm [ pl ] [ WRITE ] = 0 ; }
return perm ; }
LocalDB . create = function ( doctype , n ) { if ( ! n ) n = LocalDB . get _localname ( doctype ) ; var doc = LocalDB . add ( doctype , n )
doc . _ _islocal = 1 ; doc . owner = user ; LocalDB . set _default _values ( doc ) ; return n ; }
LocalDB . delete _record = function ( dt , dn ) { var d = locals [ dt ] [ dn ] ; if ( ! d . _ _islocal )
d . _ _oldparent = d . parent ; d . parent = 'old_parent:' + d . parent ; d . docstatus = 2 ; d . _ _deleted = 1 ; }
LocalDB . get _default _value = function ( fn , ft , df ) { if ( df == '_Login' || df == '__user' )
return user ; else if ( df == '_Full Name' )
return user _fullname ; else if ( ft == 'Date' && ( df == 'Today' || df == '__today' ) ) { return get _today ( ) ; }
else if ( df )
return df ; else if ( user _defaults [ fn ] )
return user _defaults [ fn ] [ 0 ] ; else if ( sys _defaults [ fn ] )
return sys _defaults [ fn ] ; }
LocalDB . add _child = function ( doc , childtype , parentfield ) { var n = LocalDB . create ( childtype ) ; var d = locals [ childtype ] [ n ] ; d . parent = doc . name ; d . parentfield = parentfield ; d . parenttype = doc . doctype ; return d ; }
LocalDB . no _copy _list = [ 'amended_from' , 'amendment_date' , 'cancel_reason' ] ; LocalDB . copy = function ( dt , dn , from _amend ) { var newdoc = LocalDB . create ( dt ) ; for ( var key in locals [ dt ] [ dn ] ) { if ( key !== 'name' && key . substr ( 0 , 2 ) != '__' ) { locals [ dt ] [ newdoc ] [ key ] = locals [ dt ] [ dn ] [ key ] ; }
var df = get _field ( dt , key ) ; if ( df && ( ( ! from _amend && cint ( df . no _copy ) == 1 ) || in _list ( LocalDB . no _copy _list , df . fieldname ) ) ) { locals [ dt ] [ newdoc ] [ key ] = '' ; } }
return locals [ dt ] [ newdoc ] ; }
function make _doclist ( dt , dn , deleted ) { var dl = [ ] ; dl [ 0 ] = locals [ dt ] [ dn ] ; for ( var ndt in locals ) { if ( locals [ ndt ] ) { for ( var ndn in locals [ ndt ] ) { var doc = locals [ ndt ] [ ndn ] ; if ( doc && doc . parenttype == dt && ( doc . parent == dn || ( deleted && doc . _ _oldparent == dn ) ) ) { dl [ dl . length ] = doc ; } } } }
return dl ; }
var rename _observers = [ ] ; function notify _rename _observers ( dt , old _name , new _name ) { try { var old = locals [ dt ] [ old _name ] ; old . parent = null ; old . _ _deleted = 1 ; } catch ( e ) { alert ( "[rename_from_local] No Document for: " + old _name ) ; }
for ( var i = 0 ; i < rename _observers . length ; i ++ ) { if ( rename _observers [ i ] )
rename _observers [ i ] . rename _notify ( dt , old _name , new _name ) ; } }
var Meta = { } ; var local _dt = { } ; Meta . make _local _dt = function ( dt , dn ) { var dl = make _doclist ( 'DocType' , dt ) ; if ( ! local _dt [ dt ] ) local _dt [ dt ] = { } ; if ( ! local _dt [ dt ] [ dn ] ) local _dt [ dt ] [ dn ] = { } ; for ( var i = 0 ; i < dl . length ; i ++ ) { var d = dl [ i ] ; if ( d . doctype == 'DocField' ) { var key = d . fieldname ? d . fieldname : d . label ; local _dt [ dt ] [ dn ] [ key ] = copy _dict ( d ) ; } } }
Meta . get _field = function ( dt , fn , dn ) { if ( dn && local _dt [ dt ] && local _dt [ dt ] [ dn ] ) { return local _dt [ dt ] [ dn ] [ fn ] ; } else { if ( fields [ dt ] ) var d = fields [ dt ] [ fn ] ; if ( d ) return d ; }
return { } ; }
Meta . set _field _property = function ( fn , key , val , doc ) { if ( ! doc && ( cur _frm . doc ) ) doc = cur _frm . doc ; try { local _dt [ doc . doctype ] [ doc . name ] [ fn ] [ key ] = val ; refresh _field ( fn ) ; } catch ( e ) { alert ( "Client Script Error: Unknown values for " + doc . name + ',' + fn + '.' + key + '=' + val ) ; } }
function get _doctype _label ( dt ) { if ( session . dt _labels && session . dt _labels [ dt ] )
return session . dt _labels [ dt ]
else
return dt }
function get _label _doctype ( label ) { if ( session . rev _dt _labels && session . rev _dt _labels [ label ] )
return session . rev _dt _labels [ label ]
else
return label }
var getchildren = LocalDB . getchildren ; var get _field = Meta . get _field ; var createLocal = LocalDB . create ;
/ *
* lib / js / legacy / model / doclist . js
* /
function compress _doclist ( list ) { var kl = { } ; var vl = [ ] ; var flx = { } ; for ( var i = 0 ; i < list . length ; i ++ ) { var o = list [ i ] ; var fl = [ ] ; if ( ! kl [ o . doctype ] ) { var tfl = [ 'doctype' , 'name' , 'docstatus' , 'owner' , 'parent' , 'parentfield' , 'parenttype' , 'idx' , 'creation' , 'modified' , 'modified_by' , '__islocal' , '__deleted' , '__newname' , '__modified' , '_user_tags' ] ; var fl = [ 'doctype' , 'name' , 'docstatus' , 'owner' , 'parent' , 'parentfield' , 'parenttype' , 'idx' , 'creation' , 'modified' , 'modified_by' , '__islocal' , '__deleted' , '__newname' , '__modified' , '_user_tags' ] ; for ( key in fields [ o . doctype ] ) { if ( ! in _list ( fl , key ) && ! in _list ( no _value _fields , fields [ o . doctype ] [ key ] . fieldtype ) && ! fields [ o . doctype ] [ key ] . no _column ) { fl [ fl . length ] = key ; tfl [ tfl . length ] = key } }
flx [ o . doctype ] = fl ; kl [ o . doctype ] = tfl }
var nl = [ ] ; var fl = flx [ o . doctype ] ; for ( var j = 0 ; j < fl . length ; j ++ ) { var v = o [ fl [ j ] ] ; nl . push ( v ) ; }
vl . push ( nl ) ; }
return JSON . stringify ( { '_vl' : vl , '_kl' : kl } ) ; }
function expand _doclist ( docs ) { var l = [ ] ; for ( var i = 0 ; i < docs . _vl . length ; i ++ )
l [ l . length ] = zip ( docs . _kl [ docs . _vl [ i ] [ 0 ] ] , docs . _vl [ i ] ) ; return l ; }
function zip ( k , v ) { var obj = { } ; for ( var i = 0 ; i < k . length ; i ++ ) { obj [ k [ i ] ] = v [ i ] ; }
return obj ; }
function save _doclist ( dt , dn , save _action , onsave , onerr ) { var doc = locals [ dt ] [ dn ] ; var doctype = locals [ 'DocType' ] [ dt ] ; var tmplist = [ ] ; var doclist = make _doclist ( dt , dn , 1 ) ; var all _clear = true ; if ( save _action != 'Cancel' ) { for ( var n in doclist ) { var tmp = check _required ( doclist [ n ] . doctype , doclist [ n ] . name , doclist [ 0 ] . doctype ) ; if ( doclist [ n ] . docstatus + '' != '2' && all _clear )
all _clear = tmp ; } }
var f = frms [ dt ] ; if ( f && ! all _clear ) { if ( f ) f . savingflag = false ; return 'Error' ; }
var _save = function ( ) { page _body . set _status ( 'Saving...' )
$c ( 'webnotes.widgets.form.save.savedocs' , { 'docs' : compress _doclist ( doclist ) , 'docname' : dn , 'action' : save _action , 'user' : user } , function ( r , rtxt ) { if ( f ) { f . savingflag = false ; }
if ( r . saved ) { if ( onsave ) onsave ( r ) ; } else { if ( onerr ) onerr ( r ) ; } } , function ( ) { if ( f ) { f . savingflag = false ; } } , 0 , ( f ? 'Saving...' : '' ) ) ; }
if ( doc . _ _islocal && ( doctype && doctype . autoname && doctype . autoname . toLowerCase ( ) == 'prompt' ) ) { var newname = prompt ( 'Enter the name of the new ' + dt , '' ) ; if ( newname ) { doc . _ _newname = strip ( newname ) ; _save ( ) ; } else { msgprint ( 'Not Saved' ) ; onerr ( ) ; } } else { _save ( ) ; } }
function check _required ( dt , dn , parent _dt ) { var doc = locals [ dt ] [ dn ] ; if ( doc . docstatus > 1 ) return true ; var fl = fields _list [ dt ] ; if ( ! fl ) return true ; var all _clear = true ; var errfld = [ ] ; for ( var i = 0 ; i < fl . length ; i ++ ) { var key = fl [ i ] . fieldname ; var v = doc [ key ] ; if ( fl [ i ] . reqd && is _null ( v ) && fl [ i ] . fieldname ) { errfld [ errfld . length ] = fl [ i ] . label ; if ( cur _frm ) { var f = cur _frm . fields _dict [ fl [ i ] . fieldname ] ; if ( f ) { if ( f . set _as _error ) f . set _as _error ( 1 ) ; if ( ! cur _frm . error _in _section && f . parent _section ) { cur _frm . set _section ( f . parent _section . sec _id ) ; cur _frm . error _in _section = 1 ; } } }
if ( all _clear ) all _clear = false ; } }
if ( errfld . length ) msgprint ( '<b>Mandatory fields required in ' +
( doc . parenttype ? ( fields [ doc . parenttype ] [ doc . parentfield ] . label + ' (Table)' ) : get _doctype _label ( doc . doctype ) ) + ':</b>\n' + errfld . join ( '\n' ) ) ; return all _clear ; }
/ *
* lib / js / bootstrap / bootstrap - dropdown . js
* //* ============================================================
* bootstrap - dropdown . js v1 . 4.0
* http : //twitter.github.com/bootstrap/javascript.html#dropdown
* === === === === === === === === === === === === === === === === === === === ===
* Copyright 2011 Twitter , Inc .
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* You may obtain a copy of the License at
*
* http : //www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing , software
* distributed under the License is distributed on an "AS IS" BASIS ,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
* See the License for the specific language governing permissions and
* limitations under the License .
* === === === === === === === === === === === === === === === === === === === === * /
! function ( $ ) {
"use strict"
/ * D R O P D O W N P L U G I N D E F I N I T I O N
* === === === === === === === === == * /
$ . fn . dropdown = function ( selector ) {
return this . each ( function ( ) {
$ ( this ) . delegate ( selector || d , 'click' , function ( e ) {
var li = $ ( this ) . parent ( 'li' )
, isActive = li . hasClass ( 'open' )
clearMenus ( )
! isActive && li . toggleClass ( 'open' )
return false
} )
} )
}
/ * A P P L Y T O S T A N D A R D D R O P D O W N E L E M E N T S
* === === === === === === === === === === === == * /
var d = 'a.menu, .dropdown-toggle'
function clearMenus ( ) {
$ ( d ) . parent ( 'li' ) . removeClass ( 'open' )
}
$ ( function ( ) {
$ ( 'html' ) . bind ( "click" , clearMenus )
$ ( 'body' ) . dropdown ( '[data-dropdown] a.menu, [data-dropdown] .dropdown-toggle' )
} )
} ( window . jQuery || window . ender ) ;
/ *
* lib / js / wn / ui / toolbar . min . js
* /
/ *
* lib / js / wn / ui / toolbar / selector _dialog . js
* /
wn . provide ( 'wn.ui.toolbar' ) ; wn . ui . toolbar . SelectorDialog = Class . extend ( { init : function ( opts ) { this . opts = opts ; try { this . make _dialog ( ) ; } catch ( e ) { console . log ( e ) ; }
this . bind _events ( ) ; } , make _dialog : function ( ) { this . dialog = new wn . widgets . Dialog ( { title : this . opts . title , width : 300 , fields : [ { fieldtype : 'Select' , fieldname : 'doctype' , options : 'Select...' , label : 'Select Type' } , { fieldtype : 'Button' , label : 'Go' , fieldname : 'go' } ] } ) ; } , bind _events : function ( ) { var me = this ; $ ( this . dialog . fields _dict . go . input ) . click ( function ( ) { if ( ! me . dialog . display ) return ; me . dialog . hide ( ) ; me . opts . execute ( me . dialog . fields _dict . doctype . get _value ( ) ) ; } ) ; $ ( this . dialog . fields _dict . doctype . input ) . change ( function ( ) { me . dialog . fields _dict . go . input . click ( ) ; } ) . keypress ( function ( ev ) { if ( ev . which == 13 ) { me . dialog . fields _dict . go . input . click ( ) ; } } ) ; } , show : function ( ) { this . dialog . show ( ) ; this . dialog . fields _dict . doctype . input . focus ( ) ; return false ; } , set _values : function ( lst ) { for ( var i = 0 ; i < lst . length ; i ++ )
lst [ i ] = get _doctype _label ( lst [ i ] ) ; var sel = this . dialog . fields _dict . doctype . input ; $ ( sel ) . empty ( ) ; add _sel _options ( sel , lst . sort ( ) ) ; } } )
/ *
* lib / js / wn / ui / toolbar / new . js
* /
wn . ui . toolbar . NewDialog = wn . ui . toolbar . SelectorDialog . extend ( { init : function ( ) { this . _super ( { title : "New Record" , execute : function ( val ) { new _doc ( val ) ; } , } ) ; this . set _values ( profile . can _create . join ( ',' ) . split ( ',' ) ) ; } } ) ;
/ *
* lib / js / wn / ui / toolbar / search . js
* /
wn . ui . toolbar . Search = wn . ui . toolbar . SelectorDialog . extend ( { init : function ( ) { this . _super ( { title : "Search" , execute : function ( val ) { selector . set _search ( val ) ; selector . show ( ) ; } , } ) ; this . set _values ( profile . can _read . join ( ',' ) . split ( ',' ) ) ; makeselector ( ) ; } } ) ;
/ *
* lib / js / wn / ui / toolbar / report . js
* /
wn . ui . toolbar . Report = wn . ui . toolbar . SelectorDialog . extend ( { init : function ( ) { this . _super ( { title : "Start Report For" , execute : function ( val ) { loadreport ( val , null , null , null , 1 ) ; } , } ) ; this . set _values ( profile . can _get _report . join ( ',' ) . split ( ',' ) ) ; } } ) ;
/ *
* lib / js / wn / ui / toolbar / recent . js
* /
wn . ui . toolbar . RecentDocs = Class . extend ( { init : function ( ) { $ ( '.topbar .nav:first' ) . append ( ' < li class = "dropdown" > \
< a class = "dropdown-toggle" href = "#" onclick = "return false;" > Recent < / a > \
< ul class = "dropdown-menu" id = "toolbar-recent" > < / u l > \
< /li>');this.setup();this.bind_events();},bind_events:function(){rename_observers.push(this);},rename_notify:function(dt,old,name){this.remove(dt,old);this.add(dt,name,1);},add:function(dt,dn,on_top){if(this.istable(dt))return;this.remove(dt,dn);var html=repl('<li data-docref="%(dt)s/ % ( dn ) s " > \
< a href = "#Form/%(dt)s/%(dn)s" > \
< span class = "help" > % ( dt ) s : < / s p a n > % ( d n ) s \
< / a > < / l i > ' , { d t : d t , d n : d n } ) ; i f ( o n _ t o p ) { $ ( ' # t o o l b a r - r e c e n t ' ) . p r e p e n d ( h t m l ) ; } e l s e { $ ( ' # t o o l b a r - r e c e n t ' ) . a p p e n d ( h t m l ) ; } } , i s t a b l e : f u n c t i o n ( d t ) { r e t u r n l o c a l s . D o c T y p e [ d t ] & & l o c a l s . D o c T y p e [ d t ] . i s t a b l e | | f a l s e ; } , r e m o v e : f u n c t i o n ( d t , d n ) { $ ( r e p l ( ' # t o o l b a r - r e c e n t l i [ d a t a - d o c r e f = " % ( d t ) s / % ( d n ) s " ] ' , { d t : d t , d n : d n } ) ) . r e m o v e ( ) ; } , s e t u p : f u n c t i o n ( ) { t r y { v a r r l i s t = J S O N . p a r s e ( p r o f i l e . r e c e n t ) ; }
catch ( e ) { return ; }
var m = rlist . length ; if ( m > 15 ) m = 15 ; for ( var i = 0 ; i < m ; i ++ ) { var rd = rlist [ i ]
if ( rd [ 1 ] ) { var dt = rd [ 0 ] ; var dn = rd [ 1 ] ; this . add ( dt , dn , 0 ) ; } } } } ) ;
/ *
* lib / js / wn / ui / toolbar / toolbar . js
* /
wn . ui . toolbar . Toolbar = Class . extend ( { init : function ( ) { this . make ( ) ; this . make _home ( ) ; this . make _new ( ) ; this . make _search ( ) ; this . make _report ( ) ; wn . ui . toolbar . recent = new wn . ui . toolbar . RecentDocs ( ) ; if ( in _list ( user _roles , 'Administrator' ) )
this . make _options ( ) ; this . make _tools ( ) ; this . set _user _name ( ) ; this . make _logout ( ) ; $ ( '.topbar' ) . dropdown ( ) ; $ ( document ) . trigger ( 'toolbar_setup' ) ; } , make : function ( ) { $ ( 'header' ) . append ( ' < div class = "topbar" > \
< div class = "topbar-inner" > \
< div class = "container" > \
< a class = "brand" > < / a > \
< ul class = "nav" > \
< / u l > \
< img src = "lib/images/ui/spinner.gif" id = "spinner" / > \
< ul class = "nav secondary-nav" > \
< li class = "dropdown" > \
< a class = "dropdown-toggle" href = "#" onclick = "return false;" id = "toolbar-user-link" > < / a > \
< ul class = "dropdown-menu" id = "toolbar-user" > \
< / u l > \
< / l i > \
< / u l > \
< / d i v > \
< / d i v > \
< / d i v > ' ) ; } , m a k e _ h o m e : f u n c t i o n ( ) { $ ( ' . t o p b a r . n a v : f i r s t ' ) . a p p e n d ( ' < l i > < a h r e f = " # ' + h o m e _ p a g e + ' " > H o m e < / a > < / l i > ' ) } , m a k e _ n e w : f u n c t i o n ( ) { w n . u i . t o o l b a r . n e w _ d i a l o g = n e w w n . u i . t o o l b a r . N e w D i a l o g ( ) ; $ ( ' . t o p b a r . n a v : f i r s t ' ) . a p p e n d ( ' < l i > < a h r e f = " # " \
onclick = "return wn.ui.toolbar.new_dialog.show();" > New < / a > < / l i > ' ) ; } , m a k e _ s e a r c h : f u n c t i o n ( ) { w n . u i . t o o l b a r . s e a r c h = n e w w n . u i . t o o l b a r . S e a r c h ( ) ; $ ( ' . t o p b a r . n a v : f i r s t ' ) . a p p e n d ( ' < l i > < a h r e f = " # " \
onclick = "return wn.ui.toolbar.search.show();" > Search < / a > < / l i > ' ) ; } , m a k e _ r e p o r t : f u n c t i o n ( ) { w n . u i . t o o l b a r . r e p o r t = n e w w n . u i . t o o l b a r . R e p o r t ( ) ; $ ( ' . t o p b a r . n a v : f i r s t ' ) . a p p e n d ( ' < l i > < a h r e f = " # " \
onclick = "return wn.ui.toolbar.report.show();" > Report < / a > < / l i > ' ) ; } , m a k e _ t o o l s : f u n c t i o n ( ) { $ ( ' . t o p b a r . n a v : f i r s t ' ) . a p p e n d ( ' < l i c l a s s = " d r o p d o w n " > \
< a class = "dropdown-toggle" href = "#" onclick = "return false;" > Tools < / a > \
< ul class = "dropdown-menu" id = "toolbar-tools" > \
< li > < a href = "#" onclick = "return err_console.show();" > Error Console < / a > < / l i > \
< li > < a href = "#" onclick = "return wn.ui.toolbar.clear_cache();" > Clear Cache < / a > < / l i > \
< li > < a href = "#" onclick = "return wn.ui.toolbar.show_about();" > About < / a > < / l i > \
< / u l > \
< / l i > ' ) ; i f ( h a s _ c o m m o n ( u s e r _ r o l e s , [ ' A d m i n i s t r a t o r ' , ' S y s t e m M a n a g e r ' ] ) ) { $ ( ' # t o o l b a r - t o o l s ' ) . a p p e n d ( ' < l i > < a h r e f = " # " \
onclick = "return wn.ui.toolbar.download_backup();" > \
Download Backup < / a > < / l i > ' ) ; } } , m a k e _ o p t i o n s : f u n c t i o n ( ) { $ ( ' . t o p b a r . n a v : f i r s t ' ) . a p p e n d ( ' < l i c l a s s = " d r o p d o w n " > \
< a class = "dropdown-toggle" href = "#" onclick = "return false;" > Options < / a > \
< ul class = "dropdown-menu" id = "toolbar-options" > \
< / u l > \
< / l i > ' ) ; p r o f i l e . s t a r t _ i t e m s . s o r t ( f u n c t i o n ( a , b ) { r e t u r n ( a [ 4 ] - b [ 4 ] ) } ) ; f o r ( v a r i = 0 ; i < p r o f i l e . s t a r t _ i t e m s . l e n g t h ; i + + ) { v a r d = p r o f i l e . s t a r t _ i t e m s [ i ] ; v a r i s p a g e = d [ 0 ] = = ' P a g e ' ; $ ( ' # t o o l b a r - o p t i o n s ' ) . a p p e n d ( r e p l ( ' < l i > < a h r e f = " # % ( t y p e ) s % ( d t ) s % ( d n ) s " > \
% ( dn ) s < / a > < / l i > ' , { t y p e : ( i s p a g e ? ' ' : ' F o r m / ' ) , d t : ( i s p a g e ? ' ' : ( d [ 0 ] + ' / ' ) ) , d n : d [ 5 ] | | d [ 1 ] } ) ) ; } } , s e t _ u s e r _ n a m e : f u n c t i o n ( ) { v a r f n = u s e r _ f u l l n a m e ; i f ( f n . l e n g t h > 1 5 ) f n = f n . s u b s t r ( 0 , 1 2 ) + ' . . . ' ; $ ( ' # t o o l b a r - u s e r - l i n k ' ) . h t m l ( f n ) ; } , m a k e _ l o g o u t : f u n c t i o n ( ) { $ ( ' # t o o l b a r - u s e r ' ) . a p p e n d ( ' < l i > < a h r e f = " # " o n c l i c k = " r e t u r n l o g o u t ( ) ; " > L o g o u t < / a > < / l i > ' ) ; } } ) ; w n . u i . t o o l b a r . c l e a r _ c a c h e = f u n c t i o n ( ) { l o c a l S t o r a g e & & l o c a l S t o r a g e . c l e a r ( ) ; $ c ( ' w e b n o t e s . s e s s i o n _ c a c h e . c l e a r ' , { } , f u n c t i o n ( r , r t ) { s h o w _ a l e r t ( r . m e s s a g e ) ; } ) ; r e t u r n f a l s e ; }
wn . ui . toolbar . download _backup = function ( ) { $c ( 'webnotes.utils.backups.get_backup' , { } , function ( r , rt ) { } ) ; return false ; }
wn . ui . toolbar . show _about = function ( ) { try { wn . require ( 'lib/js/wn/misc/about.js' ) ; wn . ui . misc . about ( ) ; } catch ( e ) { console . log ( e ) ; }
return false ; }
/ *
* lib / js / legacy / webpage / body . js
* /
function Body ( ) { this . left _sidebar = null ; this . right _sidebar = null ; this . status _area = null ; var me = this ; page _body = this ; this . no _of _columns = function ( ) { var n = 2 ; if ( cint ( me && me . cp && me . cp . right _sidebar _width ) )
n = n + 1 ; return n ; }
this . ready = function ( ) { $dh ( 'startup_div' ) ; $ds ( 'body_div' ) ; }
this . setup _page _areas = function ( ) { var n = this . no _of _columns ( ) ; this . body _table = make _table ( this . body , 1 , n , '100%' ) ; $y ( this . body _table , { tableLayout : 'fixed' } ) ; var c = 0 ; this . left _sidebar = $td ( this . body _table , 0 , c ) ; $y ( this . left _sidebar , { width : cint ( this . cp . left _sidebar _width ) + 'px' } ) ; c ++ ; this . center = $a ( $td ( this . body _table , 0 , c ) , 'div' ) ; c ++ ; if ( cint ( this . cp . right _sidebar _width ) ) { this . right _sidebar = $td ( this . body _table , 0 , c ) ; $y ( this . right _sidebar , { width : cint ( this . cp . right _sidebar _width ) + 'px' } )
c ++ ; }
this . center . header = $a ( this . center , 'div' ) ; this . center . body = $a ( this . center , 'div' ) ; this . center . loading = $a ( this . center , 'div' , '' , { margin : '200px 0px' , fontSize : '14px' , color : '#999' , textAlign : 'center' } ) ; this . center . loading . innerHTML = 'Loading...' }
this . setup _sidebar _menu = function ( ) { if ( this . left _sidebar && this . cp . show _sidebar _menu ) { sidebar _menu = new SidebarMenu ( ) ; sidebar _menu . make _menu ( '' ) ; } }
this . run _startup _code = function ( ) { $ ( document ) . trigger ( 'startup' ) ; try { if ( this . cp . custom _startup _code )
eval ( this . cp . custom _startup _code ) ; } catch ( e ) { errprint ( e ) ; } }
2012-02-15 08:32:20 +00:00
this . setup = function ( ) { this . cp = wn . control _panel ; this . wrapper = $a ( $i ( 'body_div' ) , 'div' ) ; this . body = $a ( this . wrapper , 'div' ) ; this . setup _page _areas ( ) ; if ( user == 'Guest' ) user _defaults . hide _webnotes _toolbar = 1 ; if ( ! cint ( user _defaults . hide _webnotes _toolbar ) || user == 'Administrator' ) { this . wntoolbar = new wn . ui . toolbar . Toolbar ( ) ; }
2012-02-14 06:14:13 +00:00
if ( this . cp . page _width ) $y ( this . wrapper , { width : cint ( this . cp . page _width ) + 'px' } ) ; }
this . pages = { } ; this . cur _page = null ; this . add _page = function ( label , onshow , onhide ) { var c = $a ( this . center . body , 'div' ) ; if ( onshow )
c . onshow = onshow ; if ( onhide )
c . onhide = onhide ; this . pages [ label ] = c ; $dh ( c ) ; return c ; }
this . change _to = function ( label ) { $dh ( this . center . loading ) ; if ( me . cur _page && me . pages [ label ] != me . cur _page ) { if ( me . cur _page . onhide )
me . cur _page . onhide ( ) ; $dh ( me . cur _page ) ; }
me . cur _page = me . pages [ label ] ; me . cur _page _label = label ; $ ( me . cur _page ) . fadeIn ( ) ; if ( me . cur _page . onshow )
me . cur _page . onshow ( me . cur _page ) ; }
this . set _status = function ( txt ) { if ( this . status _area )
this . status _area . innerHTML = txt ; }
this . set _session _changed = function ( ) { if ( this . session _message _set ) return ; var div = $a ( $i ( 'body_div' ) . parentNode , 'div' , '' , { textAlign : 'center' , fontSize : '14px' , margin : '150px auto' } ) ; $dh ( 'body_div' ) ; div . innerHTML = 'This session has been changed. Please <span class="link_type" onclick="window.location.reload()">refresh</span> to continue' ; this . session _message _set = 1 ; }
this . setup ( ) ; }
/ *
* lib / js / legacy / widgets / form / fields . js
* /
var no _value _fields = [ 'Section Break' , 'Column Break' , 'HTML' , 'Table' , 'FlexTable' , 'Button' , 'Image' ] ; var codeid = 0 ; var code _editors = { } ; function Field ( ) { this . with _label = 1 ; }
Field . prototype . make _body = function ( ) { var ischk = ( this . df . fieldtype == 'Check' ? 1 : 0 ) ; if ( this . parent )
this . wrapper = $a ( this . parent , 'div' ) ; else
this . wrapper = document . createElement ( 'div' ) ; this . label _area = $a ( this . wrapper , 'div' , '' , { margin : '8px 0px 2px 0px' } ) ; if ( ischk && ! this . in _grid ) { this . input _area = $a ( this . label _area , 'span' , '' , { marginRight : '4px' } ) ; this . disp _area = $a ( this . label _area , 'span' , '' , { marginRight : '4px' } ) ; }
if ( this . with _label ) { this . label _span = $a ( this . label _area , 'span' , 'field_label' )
this . label _icon = $a ( this . label _area , 'img' , '' , { margin : '-3px 4px -3px 4px' } ) ; $dh ( this . label _icon ) ; this . label _icon . src = 'lib/images/icons/error.gif' ; this . label _icon . title = 'Mandatory value needs to be entered' ; this . suggest _icon = $a ( this . label _area , 'img' , '' , { margin : '-3px 4px -3px 0px' } ) ; $dh ( this . suggest _icon ) ; this . suggest _icon . src = 'lib/images/icons/bullet_arrow_down.png' ; this . suggest _icon . title = 'With suggestions' ; } else { this . label _span = $a ( this . label _area , 'span' , '' , { marginRight : '4px' } )
$dh ( this . label _area ) ; }
if ( ! this . input _area ) { this . input _area = $a ( this . wrapper , 'div' ) ; this . disp _area = $a ( this . wrapper , 'div' ) ; }
if ( this . in _grid ) { if ( this . label _area ) $dh ( this . label _area ) ; } else { this . input _area . className = 'input_area' ; $y ( this . wrapper , { marginBottom : '4px' } ) ; this . set _description ( ) ; }
if ( this . onmake ) this . onmake ( ) ; }
Field . prototype . set _max _width = function ( ) { var no _max = [ 'Code' , 'Text Editor' , 'Text' , 'Table' , 'HTML' ]
if ( this . wrapper && this . layout _cell && this . layout _cell . parentNode . cells && this . layout _cell . parentNode . cells . length == 1 && ! in _list ( no _max , this . df . fieldtype ) ) { $y ( this . wrapper , { paddingRight : '50%' } ) ; } }
Field . prototype . set _label = function ( ) { if ( this . with _label && this . label _area && this . label != this . df . label ) { this . label _span . innerHTML = this . df . label ; this . label = this . df . label ; } }
Field . prototype . set _description = function ( ) { if ( this . df . description ) { var p = in _list ( [ 'Text Editor' , 'Code' , 'Check' ] , this . df . fieldtype ) ? this . label _area : this . wrapper ; this . desc _area = $a ( p , 'div' , 'field_description' , '' , this . df . description )
if ( in _list ( [ 'Text Editor' , 'Code' ] , this . df . fieldtype ) )
$ ( this . desc _area ) . addClass ( 'field_description_top' ) ; } }
Field . prototype . get _status = function ( ) { if ( this . in _filter ) this . not _in _form = this . in _filter ; if ( this . not _in _form ) { return 'Write' ; }
var fn = this . df . fieldname ? this . df . fieldname : this . df . label ; this . df = get _field ( this . doctype , fn , this . docname ) ; if ( ! this . df . permlevel ) this . df . permlevel = 0 ; var p = this . perm [ this . df . permlevel ] ; var ret ; if ( cur _frm . editable && p && p [ WRITE ] ) ret = 'Write' ; else if ( p && p [ READ ] ) ret = 'Read' ; else ret = 'None' ; if ( this . df . fieldtype == 'Binary' )
ret = 'None' ; if ( cint ( this . df . hidden ) )
ret = 'None' ; if ( ret == 'Write' && cint ( cur _frm . doc . docstatus ) > 0 ) ret = 'Read' ; var a _o _s = cint ( this . df . allow _on _submit ) ; if ( a _o _s && ( this . in _grid || ( this . frm && this . frm . not _in _container ) ) ) { a _o _s = null ; if ( this . in _grid ) a _o _s = this . grid . field . df . allow _on _submit ; if ( this . frm && this . frm . not _in _container ) { a _o _s = cur _grid . field . df . allow _on _submit ; } }
if ( cur _frm . editable && a _o _s && cint ( cur _frm . doc . docstatus ) > 0 && ! this . df . hidden ) { tmp _perm = get _perm ( cur _frm . doctype , cur _frm . docname , 1 ) ; if ( tmp _perm [ this . df . permlevel ] && tmp _perm [ this . df . permlevel ] [ WRITE ] ) ret = 'Write' ; }
return ret ; }
Field . prototype . set _style _mandatory = function ( add ) { if ( add ) { $ ( this . txt ? this . txt : this . input ) . addClass ( 'input-mandatory' ) ; if ( this . disp _area ) $ ( this . disp _area ) . addClass ( 'input-mandatory' ) ; } else { $ ( this . txt ? this . txt : this . input ) . removeClass ( 'input-mandatory' ) ; if ( this . disp _area ) $ ( this . disp _area ) . removeClass ( 'input-mandatory' ) ; } }
Field . prototype . refresh _mandatory = function ( ) { if ( this . in _filter ) return ; if ( this . df . reqd ) { if ( this . label _area ) this . label _area . style . color = "#d22" ; this . set _style _mandatory ( 1 ) ; } else { if ( this . label _area ) this . label _area . style . color = "#222" ; this . set _style _mandatory ( 0 ) ; }
this . refresh _label _icon ( )
this . set _reqd = this . df . reqd ; }
Field . prototype . refresh _display = function ( ) { if ( ! this . set _status || this . set _status != this . disp _status ) { if ( this . disp _status == 'Write' ) { if ( this . make _input && ( ! this . input ) ) { this . make _input ( ) ; if ( this . onmake _input ) this . onmake _input ( ) ; }
if ( this . show ) this . show ( )
else { $ds ( this . wrapper ) ; }
if ( this . input ) { $ds ( this . input _area ) ; $dh ( this . disp _area ) ; if ( this . input . refresh ) this . input . refresh ( ) ; } else { $dh ( this . input _area ) ; $ds ( this . disp _area ) ; } } else if ( this . disp _status == 'Read' ) { if ( this . show ) this . show ( )
else { $ds ( this . wrapper ) ; }
$dh ( this . input _area ) ; $ds ( this . disp _area ) ; } else { if ( this . hide ) this . hide ( ) ; else $dh ( this . wrapper ) ; }
this . set _status = this . disp _status ; } }
Field . prototype . refresh = function ( ) { this . disp _status = this . get _status ( ) ; if ( this . in _grid && this . table _refresh && this . disp _status == 'Write' )
{ this . table _refresh ( ) ; return ; }
2012-02-17 06:36:33 +00:00
this . set _label ( ) ; this . refresh _display ( ) ; if ( this . onrefresh )
this . onrefresh ( ) ; if ( this . input ) { if ( this . input . refresh ) this . input . refresh ( this . df ) ; }
if ( this . wrapper ) { this . wrapper . fieldobj = this ; $ ( this . wrapper ) . trigger ( 'refresh' ) ; }
if ( ! this . not _in _form )
2012-02-14 06:14:13 +00:00
this . set _input ( _f . get _value ( this . doctype , this . docname , this . df . fieldname ) ) ; this . refresh _mandatory ( ) ; this . set _max _width ( ) ; }
Field . prototype . refresh _label _icon = function ( ) { if ( this . df . reqd ) { if ( this . get _value && is _null ( this . get _value ( ) ) ) { if ( this . label _icon ) $ds ( this . label _icon ) ; $ ( this . txt ? this . txt : this . input ) . addClass ( 'field-to-update' ) } else { if ( this . label _icon ) $dh ( this . label _icon ) ; $ ( this . txt ? this . txt : this . input ) . removeClass ( 'field-to-update' ) } } }
Field . prototype . set = function ( val ) { if ( this . not _in _form )
return ; if ( ( ! this . docname ) && this . grid ) { this . docname = this . grid . add _newrow ( ) ; }
if ( in _list ( [ 'Data' , 'Text' , 'Small Text' , 'Code' ] , this . df . fieldtype ) )
val = clean _smart _quotes ( val ) ; var set _val = val ; if ( this . validate ) set _val = this . validate ( val ) ; _f . set _value ( this . doctype , this . docname , this . df . fieldname , set _val ) ; this . value = val ; }
Field . prototype . set _input = function ( val ) { this . value = val ; if ( this . input && this . input . set _input ) { if ( val == null ) this . input . set _input ( '' ) ; else this . input . set _input ( val ) ; }
var disp _val = val ; if ( val == null ) disp _val = '' ; this . set _disp ( disp _val ) ; }
Field . prototype . run _trigger = function ( ) { this . refresh _label _icon ( ) ; if ( this . df . reqd && this . get _value && ! is _null ( this . get _value ( ) ) && this . set _as _error )
this . set _as _error ( 0 ) ; if ( this . not _in _form ) { return ; }
if ( cur _frm . cscript [ this . df . fieldname ] )
cur _frm . runclientscript ( this . df . fieldname , this . doctype , this . docname ) ; cur _frm . refresh _dependency ( ) ; }
Field . prototype . set _disp _html = function ( t ) { if ( this . disp _area ) { $ ( this . disp _area ) . addClass ( 'disp_area' ) ; this . disp _area . innerHTML = ( t == null ? '' : t ) ; if ( ! t ) $ ( this . disp _area ) . addClass ( 'disp_area_no_val' ) ; } }
Field . prototype . set _disp = function ( val ) { this . set _disp _html ( val ) ; }
Field . prototype . set _as _error = function ( set ) { if ( this . in _grid || this . in _filter ) return ; var w = this . txt ? this . txt : this . input ; if ( set ) { $y ( w , { border : '2px solid RED' } ) ; } else { $y ( w , { border : '1px solid #888' } ) ; } }
2012-02-17 08:34:55 +00:00
Field . prototype . activate = function ( docname ) { this . docname = docname ; this . refresh ( ) ; if ( this . input ) { var v = _f . get _value ( this . doctype , this . docname , this . df . fieldname ) ; this . last _value = v ; if ( this . input . onchange && this . input . get _value && this . input . get _value ( ) != v ) { if ( this . validate )
2012-02-14 06:14:13 +00:00
this . input . set _value ( this . validate ( v ) ) ; else
this . input . set _value ( ( v == null ) ? '' : v ) ; if ( this . format _input )
this . format _input ( ) ; }
if ( this . input . focus ) { try { this . input . focus ( ) ; } catch ( e ) { } } }
if ( this . txt ) { try { this . txt . focus ( ) ; } catch ( e ) { }
2012-02-17 08:34:55 +00:00
this . txt . field _object = this ; } }
2012-02-17 10:20:07 +00:00
function DataField ( ) { } DataField . prototype = new Field ( ) ; DataField . prototype . make _input = function ( ) { var me = this ; this . input = $a _input ( this . input _area , this . df . fieldtype == 'Password' ? 'password' : 'text' ) ; this . get _value = function ( ) { var v = this . input . value ; if ( this . validate ) v = this . validate ( v ) ; return v ; }
2012-02-14 06:14:13 +00:00
this . input . name = this . df . fieldname ; this . input . onchange = function ( ) { if ( ! me . last _value ) me . last _value = '' ; if ( me . validate )
me . input . value = me . validate ( me . input . value ) ; me . set ( me . input . value ) ; if ( me . format _input )
me . format _input ( ) ; if ( in _list ( [ 'Currency' , 'Float' , 'Int' ] , me . df . fieldtype ) ) { if ( flt ( me . last _value ) == flt ( me . input . value ) ) { me . last _value = me . input . value ; return ; } }
me . last _value = me . input . value ; me . run _trigger ( ) ; }
this . input . set _input = function ( val ) { if ( val == null ) val = '' ; me . input . value = val ; if ( me . format _input ) me . format _input ( ) ; }
if ( this . df . options == 'Suggest' ) { wn . require ( 'lib/js/legacy/widgets/autosuggest.js' ) ; if ( this . suggest _icon ) $di ( this . suggest _icon ) ; this . set _get _query = function ( ) { }
this . get _query = function ( doc , dt , dn ) { return repl ( 'SELECT DISTINCT `%(fieldname)s` FROM `tab%(dt)s` WHERE `%(fieldname)s` LIKE "%s" LIMIT 50' , { fieldname : me . df . fieldname , dt : me . df . parent } ) }
var opts = { script : '' , json : true , maxresults : 10 , link _field : this } ; this . as = new AutoSuggest ( this . input , opts ) ; } }
DataField . prototype . validate = function ( v ) { if ( this . df . options == 'Phone' ) { if ( v + '' == '' ) return '' ; v1 = ''
v = v . replace ( / /g , '' ) . replace ( /-/g , '' ) . replace ( /\(/g , '' ) . replace ( /\)/g , '' ) ; if ( v && v . substr ( 0 , 1 ) == '+' ) { v1 = '+' ; v = v . substr ( 1 ) ; }
if ( v && v . substr ( 0 , 2 ) == '00' ) { v1 += '00' ; v = v . substr ( 2 ) ; }
if ( v && v . substr ( 0 , 1 ) == '0' ) { v1 += '0' ; v = v . substr ( 1 ) ; }
v1 += cint ( v ) + '' ; return v1 ; } else if ( this . df . options == 'Email' ) { if ( v + '' == '' ) return '' ; if ( ! validate _email ( v ) ) { msgprint ( this . df . label + ': ' + v + ' is not a valid email id' ) ; return '' ; } else
return v ; } else { return v ; } }
DataField . prototype . onrefresh = function ( ) { if ( this . input && this . df . colour ) { var col = '#' + this . df . colour . split ( ':' ) [ 1 ] ; $bg ( this . input , col ) ; } }
function ReadOnlyField ( ) { }
ReadOnlyField . prototype = new Field ( ) ; function HTMLField ( ) { }
HTMLField . prototype = new Field ( ) ; HTMLField . prototype . with _label = 0 ; HTMLField . prototype . set _disp = function ( val ) { this . disp _area . innerHTML = val ; }
HTMLField . prototype . set _input = function ( val ) { if ( val ) this . set _disp ( val ) ; }
HTMLField . prototype . onrefresh = function ( ) { this . set _disp ( this . df . options ? this . df . options : '' ) ; }
var datepicker _active = 0 ; function DateField ( ) { } DateField . prototype = new Field ( ) ; DateField . prototype . make _input = function ( ) { var me = this ; this . user _fmt = wn . control _panel . date _format ; if ( ! this . user _fmt ) this . user _fmt = 'dd-mm-yy' ; this . input = $a ( this . input _area , 'input' ) ; wn . require ( 'lib/css/legacy/jquery-ui.css' ) ; $ ( this . input ) . datepicker ( { dateFormat : me . user _fmt . replace ( 'yyyy' , 'yy' ) , altFormat : 'yy-mm-dd' , changeYear : true , beforeShow : function ( input , inst ) { datepicker _active = 1 } , onClose : function ( dateText , inst ) { datepicker _active = 0 ; if ( _f . cur _grid _cell )
_f . cur _grid _cell . grid . cell _deselect ( ) ; } } ) ; var me = this ; me . input . onchange = function ( ) { if ( this . value == null ) this . value = '' ; if ( ! this . not _in _form )
me . set ( dateutil . user _to _str ( me . input . value ) ) ; me . run _trigger ( ) ; }
me . input . set _input = function ( val ) { if ( val == null ) val = '' ; else val = dateutil . str _to _user ( val ) ; me . input . value = val ; }
me . get _value = function ( ) { if ( me . input . value )
return dateutil . user _to _str ( me . input . value ) ; } }
DateField . prototype . set _disp = function ( val ) { var v = dateutil . str _to _user ( val ) ; if ( v == null ) v = '' ; this . set _disp _html ( v ) ; }
DateField . prototype . validate = function ( v ) { if ( ! v ) return ; var me = this ; this . clear = function ( ) { msgprint ( "Date must be in format " + this . user _fmt ) ; me . input . set _input ( '' ) ; return '' ; }
var t = v . split ( '-' ) ; if ( t . length != 3 ) { return this . clear ( ) ; }
else if ( cint ( t [ 1 ] ) > 12 || cint ( t [ 1 ] ) < 1 ) { return this . clear ( ) ; }
else if ( cint ( t [ 2 ] ) > 31 || cint ( t [ 2 ] ) < 1 ) { return this . clear ( ) ; }
return v ; } ; var _link _onchange _flag = null ; function LinkField ( ) { } LinkField . prototype = new Field ( ) ; LinkField . prototype . make _input = function ( ) { var me = this ; if ( me . df . no _buttons ) { this . txt = $a ( this . input _area , 'input' ) ; this . input = this . txt ; } else { makeinput _popup ( this , 'ic-zoom' , 'ic-sq_next' , 'ic-sq_plus' ) ; me . setup _buttons ( ) ; me . onrefresh = function ( ) { if ( me . can _create && cur _frm . doc . docstatus == 0 ) $ds ( me . btn2 ) ; else $dh ( me . btn2 ) ; } }
me . txt . field _object = this ; me . set _onchange ( ) ; me . input . set _input = function ( val ) { if ( val == undefined ) val = '' ; me . txt . value = val ; }
me . get _value = function ( ) { return me . txt . value ; }
wn . require ( 'lib/js/legacy/widgets/autosuggest.js' ) ; var opts = { script : '' , json : true , maxresults : 10 , link _field : me } ; this . as = new AutoSuggest ( me . txt , opts ) ; }
LinkField . prototype . setup _buttons = function ( ) { var me = this ; me . btn . onclick = function ( ) { selector . set ( me , me . df . options , me . df . label ) ; selector . show ( me . txt ) ; }
if ( me . btn1 ) me . btn1 . onclick = function ( ) { if ( me . txt . value && me . df . options ) { loaddoc ( me . df . options , me . txt . value ) ; } }
me . can _create = 0 ; if ( ( ! me . not _in _form ) && in _list ( profile . can _create , me . df . options ) ) { me . can _create = 1 ; me . btn2 . onclick = function ( ) { var on _save _callback = function ( new _rec ) { if ( new _rec ) { var d = _f . calling _doc _stack . pop ( ) ; locals [ d [ 0 ] ] [ d [ 1 ] ] [ me . df . fieldname ] = new _rec ; me . refresh ( ) ; if ( me . grid ) me . grid . refresh ( ) ; me . run _trigger ( ) ; } }
_f . calling _doc _stack . push ( [ me . doctype , me . docname ] ) ; new _doc ( me . df . options , me . on _new , 1 , on _save _callback , me . doctype , me . docname , me . frm . not _in _container ) ; } } else { $dh ( me . btn2 ) ; $y ( $td ( me . tab , 0 , 2 ) , { width : '0px' } ) ; } }
LinkField . prototype . set _onchange = function ( ) { var me = this ; me . txt . onchange = function ( e ) { if ( cur _autosug ) return ; if ( _link _onchange _flag ) { return ; }
_link _onchange _flag = 1 ; me . refresh _label _icon ( ) ; if ( me . not _in _form ) { _link _onchange _flag = 0 ; return ; }
if ( cur _frm ) { if ( me . txt . value == locals [ me . doctype ] [ me . docname ] [ me . df . fieldname ] ) { me . set ( me . txt . value ) ; me . run _trigger ( ) ; setTimeout ( '_link_onchange_flag = 0' , 500 ) ; return ; } }
me . set ( me . txt . value ) ; if ( _f . cur _grid _cell )
_f . cur _grid _cell . grid . cell _deselect ( ) ; if ( ! me . txt . value ) { me . run _trigger ( ) ; setTimeout ( '_link_onchange_flag = 0' , 500 ) ; return ; }
var fetch = '' ; if ( cur _frm . fetch _dict [ me . df . fieldname ] )
fetch = cur _frm . fetch _dict [ me . df . fieldname ] . columns . join ( ', ' ) ; $c ( 'webnotes.widgets.form.utils.validate_link' , { 'value' : me . txt . value , 'options' : me . df . options , 'fetch' : fetch } , function ( r , rt ) { setTimeout ( '_link_onchange_flag = 0' , 500 ) ; if ( selector && selector . display ) return ; if ( r . message == 'Ok' ) { if ( r . fetch _values ) me . set _fetch _values ( r . fetch _values ) ; me . run _trigger ( ) ; } else { var astr = '' ; if ( in _list ( profile . can _create , me . df . options ) ) astr = repl ( '<br><br><span class="link_type" onclick="newdoc(\'%(dt)s\')">Click here</span> to create a new %(dtl)s' , { dt : me . df . options , dtl : get _doctype _label ( me . df . options ) } )
msgprint ( repl ( 'error:<b>%(val)s</b> is not a valid %(dt)s.<br><br>You must first create a new %(dt)s <b>%(val)s</b> and then select its value. To find an existing %(dt)s, click on the magnifying glass next to the field.%(add)s' , { val : me . txt . value , dt : get _doctype _label ( me . df . options ) , add : astr } ) ) ; me . txt . value = '' ; me . set ( '' ) ; } } ) ; } }
LinkField . prototype . set _fetch _values = function ( fetch _values ) { var fl = cur _frm . fetch _dict [ this . df . fieldname ] . fields ; var changed _fields = [ ] ; for ( var i = 0 ; i < fl . length ; i ++ ) { if ( locals [ this . doctype ] [ this . docname ] [ fl [ i ] ] != fetch _values [ i ] ) { locals [ this . doctype ] [ this . docname ] [ fl [ i ] ] = fetch _values [ i ] ; if ( ! this . grid ) { refresh _field ( fl [ i ] ) ; changed _fields . push ( fl [ i ] ) ; } } }
for ( i = 0 ; i < changed _fields . length ; i ++ ) { if ( cur _frm . fields _dict [ changed _fields [ i ] ] )
cur _frm . fields _dict [ changed _fields [ i ] ] . run _trigger ( ) ; }
if ( this . grid ) this . grid . refresh ( ) ; }
LinkField . prototype . set _get _query = function ( ) { if ( this . get _query ) return ; if ( this . grid ) { var f = this . grid . get _field ( this . df . fieldname ) ; if ( f . get _query ) this . get _query = f . get _query ; } }
LinkField . prototype . set _disp = function ( val ) { var t = null ; if ( val ) t = "<a href=\'javascript:loaddoc(\"" + this . df . options + "\", \"" + val + "\")\'>" + val + "</a>" ; this . set _disp _html ( t ) ; }
function IntField ( ) { } IntField . prototype = new DataField ( ) ; IntField . prototype . validate = function ( v ) { if ( isNaN ( parseInt ( v ) ) ) return null ; return cint ( v ) ; } ; IntField . prototype . format _input = function ( ) { if ( this . input . value == null ) this . input . value = '' ; }
function FloatField ( ) { } FloatField . prototype = new DataField ( ) ; FloatField . prototype . validate = function ( v ) { var v = parseFloat ( v ) ; if ( isNaN ( v ) ) return null ; return v ; } ; FloatField . prototype . format _input = function ( ) { if ( this . input . value == null ) this . input . value = '' ; }
function CurrencyField ( ) { } CurrencyField . prototype = new DataField ( ) ; CurrencyField . prototype . format _input = function ( ) { var v = fmt _money ( this . input . value ) ; if ( this . not _in _form ) { if ( ! flt ( this . input . value ) ) v = '' ; }
this . input . value = v ; }
CurrencyField . prototype . validate = function ( v ) { if ( v == null || v == '' )
return 0 ; return flt ( v , 2 ) ; }
CurrencyField . prototype . set _disp = function ( val ) { var v = fmt _money ( val ) ; this . set _disp _html ( v ) ; }
CurrencyField . prototype . onmake _input = function ( ) { if ( ! this . input ) return ; this . input . onfocus = function ( ) { if ( flt ( this . value ) == 0 ) this . select ( ) ; } }
function CheckField ( ) { } CheckField . prototype = new Field ( ) ; CheckField . prototype . validate = function ( v ) { var v = parseInt ( v ) ; if ( isNaN ( v ) ) return 0 ; return v ; } ; CheckField . prototype . onmake = function ( ) { this . checkimg = $a ( this . disp _area , 'div' ) ; var img = $a ( this . checkimg , 'img' ) ; img . src = 'lib/images/ui/tick.gif' ; $dh ( this . checkimg ) ; }
2012-02-17 08:34:55 +00:00
CheckField . prototype . make _input = function ( ) { var me = this ; this . input = $a _input ( this . input _area , 'checkbox' ) ; $y ( this . input , { width : "16px" , border : '0px' , margin : '2px' } ) ; $ ( this . input ) . click ( function ( ) { me . set ( this . checked ? 1 : 0 ) ; me . run _trigger ( ) ; } )
2012-02-14 06:14:13 +00:00
this . input . set _input = function ( v ) { v = parseInt ( v ) ; if ( isNaN ( v ) ) v = 0 ; if ( v ) me . input . checked = true ; else me . input . checked = false ; }
this . get _value = function ( ) { return this . input . checked ? 1 : 0 ; } }
CheckField . prototype . set _disp = function ( val ) { if ( val ) { $ds ( this . checkimg ) ; }
else { $dh ( this . checkimg ) ; } }
function TextField ( ) { } TextField . prototype = new Field ( ) ; TextField . prototype . set _disp = function ( val ) { this . disp _area . innerHTML = replace _newlines ( val ) ; }
TextField . prototype . make _input = function ( ) { var me = this ; if ( this . in _grid )
return ; this . input = $a ( this . input _area , 'textarea' ) ; if ( this . df . fieldtype == 'Small Text' )
this . input . style . height = "80px" ; this . input . set _input = function ( v ) { me . input . value = v ; }
this . input . onchange = function ( ) { me . set ( me . input . value ) ; me . run _trigger ( ) ; }
this . get _value = function ( ) { return this . input . value ; } }
var text _dialog ; function make _text _dialog ( ) { var d = new Dialog ( 520 , 410 , 'Edit Text' ) ; d . make _body ( [ [ 'Text' , 'Enter Text' ] , [ 'HTML' , 'Description' ] , [ 'Button' , 'Update' ] ] ) ; d . widgets [ 'Update' ] . onclick = function ( ) { var t = this . dialog ; t . field . set ( t . widgets [ 'Enter Text' ] . value ) ; t . hide ( ) ; }
d . onshow = function ( ) { this . widgets [ 'Enter Text' ] . style . height = '300px' ; var v = _f . get _value ( this . field . doctype , this . field . docname , this . field . df . fieldname ) ; this . widgets [ 'Enter Text' ] . value = v == null ? '' : v ; this . widgets [ 'Enter Text' ] . focus ( ) ; this . widgets [ 'Description' ] . innerHTML = ''
if ( this . field . df . description )
$a ( this . widgets [ 'Description' ] , 'div' , 'field_description' , '' , this . field . df . description ) ; }
d . onhide = function ( ) { if ( _f . cur _grid _cell )
_f . cur _grid _cell . grid . cell _deselect ( ) ; }
text _dialog = d ; }
TextField . prototype . table _refresh = function ( ) { if ( ! this . text _dialog )
make _text _dialog ( ) ; text _dialog . set _title ( 'Enter text for "' + this . df . label + '"' ) ; text _dialog . field = this ; text _dialog . show ( ) ; }
function SelectField ( ) { } SelectField . prototype = new Field ( ) ; SelectField . prototype . make _input = function ( ) { var me = this ; var opt = [ ] ; if ( this . in _filter && ( ! this . df . single _select ) ) { this . input = $a ( this . input _area , 'select' ) ; this . input . multiple = true ; this . input . style . height = '4em' ; this . input . lab = $a ( this . input _area , 'div' , { fontSize : '9px' , color : '#999' } ) ; this . input . lab . innerHTML = '(Use Ctrl+Click to select multiple or de-select)' } else { this . input = $a ( this . input _area , 'select' ) ; this . input . onchange = function ( ) { if ( me . validate )
2012-02-17 08:34:55 +00:00
me . validate ( ) ; me . set ( sel _val ( this ) ) ; me . run _trigger ( ) ; }
2012-02-14 06:14:13 +00:00
if ( this . df . options == 'attach_files:' ) { this . file _attach = true ; } }
this . set _as _single = function ( ) { var i = this . input ; i . multiple = false ; i . style . height = null ; if ( i . lab ) $dh ( i . lab ) }
this . refresh _options = function ( options ) { if ( options )
me . df . options = options ; if ( this . file _attach )
this . set _attach _options ( ) ; me . options _list = me . df . options ? me . df . options . split ( '\n' ) : [ ] ; empty _select ( this . input ) ; if ( me . in _filter && me . options _list [ 0 ] != '' ) { me . options _list = add _lists ( [ '' ] , me . options _list ) ; }
add _sel _options ( this . input , me . options _list ) ; }
this . onrefresh = function ( ) { this . refresh _options ( ) ; if ( this . not _in _form ) { this . input . value = '' ; return ; }
if ( _f . get _value )
var v = _f . get _value ( this . doctype , this . docname , this . df . fieldname ) ; else { if ( this . options _list && this . options _list . length )
var v = this . options _list [ 0 ] ; else
var v = null ; }
this . input . set _input ( v ) ; }
this . input . set _input = function ( v ) { if ( ! v ) { if ( ! me . input . multiple ) { if ( me . docname ) { if ( me . options _list && me . options _list . length ) { me . set ( me . options _list [ 0 ] ) ; me . input . value = me . options _list [ 0 ] ; } else { me . input . value = '' ; } } } } else { if ( me . options _list ) { if ( me . input . multiple ) { for ( var i = 0 ; i < me . input . options . length ; i ++ ) { me . input . options [ i ] . selected = 0 ; if ( me . input . options [ i ] . value && inList ( v . split ( "," ) , me . input . options [ i ] . value ) )
me . input . options [ i ] . selected = 1 ; } } else if ( in _list ( me . options _list , v ) ) { me . input . value = v ; } } } }
this . get _value = function ( ) { if ( me . input . multiple ) { var l = [ ] ; for ( var i = 0 ; i < me . input . options . length ; i ++ ) { if ( me . input . options [ i ] . selected ) l [ l . length ] = me . input . options [ i ] . value ; }
return l ; } else { if ( me . input . options ) { var val = sel _val ( me . input ) ; if ( ! val && ! me . input . selectedIndex )
val = me . input . options [ 0 ] . value ; return val ; }
return me . input . value ; } }
this . set _attach _options = function ( ) { if ( ! cur _frm ) return ; var fl = cur _frm . doc . file _list ; if ( fl ) { this . df . options = '' ; var fl = fl . split ( '\n' ) ; for ( var i in fl ) { this . df . options += '\n' + fl [ i ] . split ( ',' ) [ 1 ] ; } } else { this . df . options = '' } }
this . refresh ( ) ; }
function TimeField ( ) { } TimeField . prototype = new Field ( ) ; TimeField . prototype . get _time = function ( ) { return time _to _hhmm ( sel _val ( this . input _hr ) , sel _val ( this . input _mn ) , sel _val ( this . input _am ) ) ; }
TimeField . prototype . set _time = function ( v ) { ret = time _to _ampm ( v ) ; this . input _hr . inp . value = ret [ 0 ] ; this . input _mn . inp . value = ret [ 1 ] ; this . input _am . inp . value = ret [ 2 ] ; }
TimeField . prototype . set _style _mandatory = function ( ) { }
TimeField . prototype . set _as _error = function ( ) { }
2012-02-17 08:34:55 +00:00
TimeField . prototype . make _input = function ( ) { var me = this ; this . input = $a ( this . input _area , 'div' , 'time_field' ) ; var t = make _table ( this . input , 1 , 3 , '200px' ) ; var opt _hr = [ '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '10' , '11' , '12' ] ; var opt _mn = [ '00' , '05' , '10' , '15' , '20' , '25' , '30' , '35' , '40' , '45' , '50' , '55' ] ; var opt _am = [ 'AM' , 'PM' ] ; this . input _hr = new SelectWidget ( $td ( t , 0 , 0 ) , opt _hr , '50px' ) ; this . input _mn = new SelectWidget ( $td ( t , 0 , 1 ) , opt _mn , '50px' ) ; this . input _am = new SelectWidget ( $td ( t , 0 , 2 ) , opt _am , '50px' ) ; var onchange _fn = function ( ) { me . set ( me . get _time ( ) ) ; me . run _trigger ( ) ; }
2012-02-14 06:14:13 +00:00
this . input _hr . inp . onchange = onchange _fn ; this . input _mn . inp . onchange = onchange _fn ; this . input _am . inp . onchange = onchange _fn ; this . onrefresh = function ( ) { var v = _f . get _value ? _f . get _value ( me . doctype , me . docname , me . df . fieldname ) : null ; me . set _time ( v ) ; if ( ! v )
me . set ( me . get _time ( ) ) ; }
this . input . set _input = function ( v ) { if ( v == null ) v = '' ; me . set _time ( v ) ; }
this . get _value = function ( ) { return this . get _time ( ) ; }
this . refresh ( ) ; }
TimeField . prototype . set _disp = function ( v ) { var t = time _to _ampm ( v ) ; var t = t [ 0 ] + ':' + t [ 1 ] + ' ' + t [ 2 ] ; this . set _disp _html ( t ) ; }
function makeinput _popup ( me , iconsrc , iconsrc1 , iconsrc2 ) { me . input = $a ( me . input _area , 'div' ) ; if ( ! me . not _in _form )
$y ( me . input , { width : '80%' } ) ; me . input . set _width = function ( w ) { $y ( me . input , { width : ( w - 2 ) + 'px' } ) ; }
var tab = $a ( me . input , 'table' ) ; me . tab = tab ; $y ( tab , { width : '100%' , borderCollapse : 'collapse' , tableLayout : 'fixed' } ) ; var c0 = tab . insertRow ( 0 ) . insertCell ( 0 ) ; var c1 = tab . rows [ 0 ] . insertCell ( 1 ) ; $y ( c1 , { width : '20px' } ) ; me . txt = $a ( $a ( $a ( c0 , 'div' , '' , { paddingRight : '8px' } ) , 'div' ) , 'input' , '' , { width : '100%' } ) ; me . btn = $a ( c1 , 'div' , 'wn-icon ' + iconsrc , { width : '16px' } ) ; if ( iconsrc1 )
me . btn . setAttribute ( 'title' , 'Search' ) ; else
me . btn . setAttribute ( 'title' , 'Select Date' ) ; if ( iconsrc1 ) { var c2 = tab . rows [ 0 ] . insertCell ( 2 ) ; $y ( c2 , { width : '20px' } ) ; me . btn1 = $a ( c2 , 'div' , 'wn-icon ' + iconsrc1 , { width : '16px' } ) ; me . btn1 . setAttribute ( 'title' , 'Open Link' ) ; }
if ( iconsrc2 ) { var c3 = tab . rows [ 0 ] . insertCell ( 3 ) ; $y ( c3 , { width : '20px' } ) ; me . btn2 = $a ( c3 , 'div' , 'wn-icon ' + iconsrc2 , { width : '16px' } ) ; me . btn2 . setAttribute ( 'title' , 'Create New' ) ; $dh ( me . btn2 ) ; }
if ( me . df . colour )
me . txt . style . background = '#' + me . df . colour . split ( ':' ) [ 1 ] ; me . txt . name = me . df . fieldname ; me . setdisabled = function ( tf ) { me . txt . disabled = tf ; } }
var tmpid = 0 ; _f . ButtonField = function ( ) { } ; _f . ButtonField . prototype = new Field ( ) ; _f . ButtonField . prototype . with _label = 0 ; _f . ButtonField . prototype . init = function ( ) { this . prev _button = null ; if ( ! this . frm ) return ; if ( cur _frm && cur _frm . fields [ cur _frm . fields . length - 1 ] && cur _frm . fields [ cur _frm . fields . length - 1 ] . df . fieldtype == 'Button' ) { this . make _body = function ( ) { this . prev _button = cur _frm . fields [ cur _frm . fields . length - 1 ] ; if ( ! this . prev _button . prev _button ) { this . prev _button . button _area = $a ( this . prev _button . input _area , 'span' ) ; }
this . wrapper = this . prev _button . wrapper ; this . input _area = this . prev _button . input _area ; this . disp _area = this . prev _button . disp _area ; this . button _area = $a ( this . prev _button . input _area , 'span' ) ; } } }
_f . ButtonField . prototype . make _input = function ( ) { var me = this ; if ( ! this . prev _button ) { $y ( this . input _area , { marginTop : '4px' , marginBottom : '4px' } ) ; }
if ( ! this . button _area )
this . button _area = $a ( this . input _area , 'span' , '' , { marginRight : '4px' } ) ; this . input = $btn ( this . button _area , me . df . label . substr ( 0 , 20 ) + ( ( me . df . label . length > 20 ) ? '..' : '' ) , null , { maxWidth : '170px' , fontWeight : 'bold' } , null , 1 )
this . input . onclick = function ( ) { if ( me . not _in _form ) return ; this . disabled = 'disabled' ; if ( cur _frm . cscript [ me . df . label ] && ( ! me . in _filter ) ) { cur _frm . runclientscript ( me . df . label , me . doctype , me . docname ) ; this . disabled = false ; } else { cur _frm . runscript ( me . df . options , me ) ; this . disabled = false ; } } }
_f . ButtonField . prototype . hide = function ( ) { $dh ( this . button _area ) ; } ; _f . ButtonField . prototype . show = function ( ) { $ds ( this . button _area ) ; } ; _f . ButtonField . prototype . set = function ( v ) { } ; _f . ButtonField . prototype . set _disp = function ( val ) { }
function make _field ( docfield , doctype , parent , frm , in _grid , hide _label ) { switch ( docfield . fieldtype . toLowerCase ( ) ) { case 'data' : var f = new DataField ( ) ; break ; case 'password' : var f = new DataField ( ) ; break ; case 'int' : var f = new IntField ( ) ; break ; case 'float' : var f = new FloatField ( ) ; break ; case 'currency' : var f = new CurrencyField ( ) ; break ; case 'read only' : var f = new ReadOnlyField ( ) ; break ; case 'link' : var f = new LinkField ( ) ; break ; case 'date' : var f = new DateField ( ) ; break ; case 'time' : var f = new TimeField ( ) ; break ; case 'html' : var f = new HTMLField ( ) ; break ; case 'check' : var f = new CheckField ( ) ; break ; case 'text' : var f = new TextField ( ) ; break ; case 'small text' : var f = new TextField ( ) ; break ; case 'select' : var f = new SelectField ( ) ; break ; case 'button' : var f = new _f . ButtonField ( ) ; break ; case 'code' : var f = new _f . CodeField ( ) ; break ; case 'text editor' : var f = new _f . CodeField ( ) ; break ; case 'table' : var f = new _f . TableField ( ) ; break ; case 'section break' : var f = new _f . SectionBreak ( ) ; break ; case 'column break' : var f = new _f . ColumnBreak ( ) ; break ; case 'image' : var f = new _f . ImageField ( ) ; break ; }
f . parent = parent ; f . doctype = doctype ; f . df = docfield ; f . perm = frm ? frm . perm : [ [ 1 , 1 , 1 ] ] ; if ( _f )
f . col _break _width = _f . cur _col _break _width ; if ( in _grid ) { f . in _grid = true ; f . with _label = 0 ; }
if ( hide _label ) { f . with _label = 0 ; }
if ( frm ) { f . frm = frm ; if ( parent )
f . layout _cell = parent . parentNode ; }
if ( f . init ) f . init ( ) ; f . make _body ( ) ; return f ; }
/ *
* lib / js / legacy / widgets / form / form _container . js
* /
_f . FrmContainer = function ( ) { this . wrapper = page _body . add _page ( "Forms" , function ( ) { } , function ( ) { } ) ; this . last _displayed = null ; $dh ( this . wrapper ) ; this . body = $a ( this . wrapper , 'div' , 'frm_container' ) ; _f . frm _dialog = new _f . FrmDialog ( ) ; }
_f . frm _dialog = null ; _f . calling _doc _stack = [ ] ; _f . temp _access = { } ; _f . FrmDialog = function ( ) { var me = this ; this . last _displayed = null ; var d = new Dialog ( 640 , null , 'Edit Row' ) ; this . body = $a ( d . body , 'div' , 'dialog_frm' ) ; $y ( d . body , { backgroundColor : '#EEE' } ) ; d . done _btn _area = $a ( d . body , 'div' , '' , { margin : '8px' } ) ; me . on _complete = function ( ) { if ( me . table _form ) { me . dialog . hide ( ) ; } else { var callback = function ( r ) { var dn = cur _frm . docname ; if ( ! r . exc ) { me . dialog . hide ( ) ; }
if ( me . on _save _callback )
me . on _save _callback ( dn ) ; }
cur _frm . save ( 'Save' , callback ) ; } }
d . onshow = function ( ) { d . done _btn _area . innerHTML = '' ; d . done _btn = $btn ( d . done _btn _area , 'Save' , null , null , 'green' ) ; d . done _btn . onclick = function ( ) { me . on _complete ( ) } ; if ( me . table _form ) { d . set _title ( "Editing Row #" + ( _f . cur _grid _ridx + 1 ) ) ; d . done _btn . innerHTML = 'Done Editing' ; } else { d . set _title ( cur _frm . doctype == cur _frm . doctype ? ( cur _frm . doctype ) : ( cur _frm . doctype + ': ' + cur _frm . docname ) ) ; d . done _btn . innerHTML = 'Save' ; } }
d . onhide = function ( ) { if ( _f . cur _grid )
_f . cur _grid . refresh _row ( _f . cur _grid _ridx , me . dn ) ; if ( page _body . cur _page _label = 'Forms' ) { cur _frm = _f . frm _con . cur _frm ; } }
this . dialog = d ; }
_f . add _frm = function ( doctype , onload , opt _name , from _archive ) { if ( frms [ 'DocType' ] && frms [ 'DocType' ] . opendocs [ doctype ] ) { msgprint ( "error:Cannot create an instance of \"" + doctype + "\" when the DocType is open." ) ; return ; }
if ( frms [ doctype ] ) { return frms [ doctype ] ; }
var callback = function ( r , rt ) { page _body . set _status ( 'Done' )
if ( ! locals [ 'DocType' ] [ doctype ] ) { if ( r . exc ) { msgprint ( "Did not load " + doctype , 1 ) ; }
loadpage ( '_home' ) ; return ; }
if ( r . print _access ) { if ( ! _f . temp _access [ doctype ] )
_f . temp _access [ doctype ] = { } ; _f . temp _access [ doctype ] [ opt _name ] = 1 ; }
var meta = locals [ 'DocType' ] [ doctype ] ; var in _dialog = false ; if ( meta . istable ) meta . in _dialog = 1 ; if ( cint ( meta . in _dialog ) ) { var parent = _f . frm _dialog ; in _dialog = true ; } else { var parent = _f . frm _con ; }
var f = new _f . Frm ( doctype , parent ) ; f . in _dialog = in _dialog ; if ( onload ) onload ( r , rt ) ; }
var is _new = 0 ; if ( opt _name && locals [ doctype ] && locals [ doctype ] [ opt _name ] && locals [ doctype ] [ opt _name ] . _ _islocal ) { is _new = 1 ; }
if ( opt _name && ! is _new ) { var args = { 'name' : opt _name , 'doctype' : doctype , 'getdoctype' : 1 , 'user' : user } ; if ( get _url _arg ( 'akey' ) ) args [ 'akey' ] = get _url _arg ( 'akey' ) ; if ( from _archive ) args [ 'from_archive' ] = 1 ; $c ( 'webnotes.widgets.form.load.getdoc' , args , callback ) ; } else { $c ( 'webnotes.widgets.form.load.getdoctype' , args = { 'doctype' : doctype } , callback ) ; } }
/ *
* lib / js / legacy / widgets / form / form _header . js
* /
_f . FrmHeader = function ( parent , frm ) { var me = this ; this . wrapper = $a ( parent , 'div' ) ; if ( frm . meta . in _dialog ) $y ( this . wrapper , { marginLeft : '8px' , marginRight : '8px' } ) ; this . page _head = new PageHeader ( this . wrapper ) ; this . dt _area = $a ( this . page _head . main _head , 'h1' , '' , { marginRight : '8px' , display : 'inline' } )
var div = $a ( null , 'div' , '' , { marginBottom : '4px' } ) ; this . page _head . lhs . insertBefore ( div , this . page _head . sub _head ) ; this . dn _area = $a ( div , 'span' , '' , { fontSize : '14px' , fontWeight : 'normal' , marginRight : '8px' } )
this . status _area = $a ( div , 'span' , '' , { marginRight : '8px' , marginBottom : '2px' , cursor : 'pointer' , textShadow : 'none' } )
this . timestamp _area = $a ( $a ( div , 'div' , '' , { marginTop : '3px' } ) , 'span' , 'field_description' , { fontSize : '11px' } ) ; }
_f . FrmHeader . prototype . show = function ( ) { $ds ( this . wrapper ) ; }
_f . FrmHeader . prototype . hide = function ( ) { $dh ( this . wrapper ) ; }
_f . FrmHeader . prototype . refresh = function ( ) { var me = this ; var p = cur _frm . get _doc _perms ( ) ; this . page _head . clear _toolbar ( ) ; if ( cur _frm . meta . read _only _onload && ! cur _frm . doc . _ _islocal ) { if ( ! cur _frm . editable )
this . page _head . add _button ( 'Edit' , function ( ) { cur _frm . edit _doc ( ) ; } , 1 , 'ui-icon-document' , 1 ) ; else
this . page _head . add _button ( 'Print View' , function ( ) { cur _frm . is _editable [ cur _frm . docname ] = 0 ; cur _frm . refresh ( ) ; } , 1 , 'ui-icon-document' ) ; }
if ( cur _frm . editable && cint ( cur _frm . doc . docstatus ) == 0 && p [ WRITE ] )
this . page _head . add _button ( 'Save' , function ( ) { cur _frm . save ( 'Save' ) ; } , 1 , 'ui-icon-disk' , 1 ) ; if ( cint ( cur _frm . doc . docstatus ) == 0 && p [ SUBMIT ] && ( ! cur _frm . doc . _ _islocal ) )
this . page _head . add _button ( 'Submit' , function ( ) { cur _frm . savesubmit ( ) ; } , 0 , 'ui-icon-locked' ) ; if ( cint ( cur _frm . doc . docstatus ) == 1 && p [ SUBMIT ] ) { this . update _btn = this . page _head . add _button ( 'Update' , function ( ) { cur _frm . saveupdate ( ) ; } , 1 , 'ui-icon-disk' , 1 ) ; if ( ! cur _frm . doc . _ _unsaved ) $dh ( this . update _btn ) ; }
if ( cint ( cur _frm . doc . docstatus ) == 1 && p [ CANCEL ] )
this . page _head . add _button ( 'Cancel' , function ( ) { cur _frm . savecancel ( ) } , 0 , 'ui-icon-closethick' ) ; if ( cint ( cur _frm . doc . docstatus ) == 2 && p [ AMEND ] )
this . page _head . add _button ( 'Amend' , function ( ) { cur _frm . amend _doc ( ) } , 0 , 'ui-icon-scissors' ) ; }
_f . FrmHeader . prototype . show _toolbar = function ( ) { $ds ( this . wrapper ) ; this . refresh ( ) ; }
_f . FrmHeader . prototype . hide _toolbar = function ( ) { $dh ( this . wrapper ) ; }
_f . FrmHeader . prototype . refresh _toolbar = function ( ) { var m = cur _frm . meta ; if ( m . hide _heading || cur _frm . in _dialog ) { this . hide ( ) ; } else { this . show ( ) ; if ( m . hide _toolbar ) { this . hide _toolbar ( ) ; } else { this . show _toolbar ( ) ; } } }
_f . FrmHeader . prototype . get _timestamp = function ( doc ) { var scrub _date = function ( d ) { if ( d ) t = d . split ( ' ' ) ; else return '' ; return dateutil . str _to _user ( t [ 0 ] ) + ' ' + t [ 1 ] ; }
return repl ( "Created: %(c_by)s %(c_on)s %(m_by)s %(m_on)s" , { c _by : doc . owner , c _on : scrub _date ( doc . creation ? doc . creation : '' ) , m _by : doc . modified _by ? ( ' | Modified: ' + doc . modified _by ) : '' , m _on : doc . modified ? ( 'on ' + scrub _date ( doc . modified ) ) : '' } ) ; }
_f . FrmHeader . prototype . get _status _tags = function ( doc , f ) { var make _tag = function ( label , col ) { var s = $a ( null , 'span' , '' , { padding : '2px' , backgroundColor : col , color : '#FFF' , fontWeight : 'bold' , marginLeft : ( f . meta . issingle ? '0px' : '8px' ) , fontSize : '11px' } ) ; $ ( s ) . css ( '-moz-border-radius' , '3px' ) . css ( '-webkit-border-radius' , '3px' )
s . innerHTML = label ; return s ; }
var sp1 = null ; var sp2 = null ; if ( doc . _ _islocal ) { label = 'Unsaved Draft' ; col = '#F81' ; } else if ( cint ( doc . _ _unsaved ) ) { label = 'Not Saved' ; col = '#F81' ; if ( doc . docstatus == 1 && this . update _btn ) $ds ( this . update _btn ) ; } else if ( cint ( doc . docstatus ) == 0 ) { label = 'Saved' ; col = '#0A1' ; if ( f . get _doc _perms ( ) [ SUBMIT ] ) { sp2 = make _tag ( 'To Be Submitted' , '#888' ) ; } } else if ( cint ( doc . docstatus ) == 1 ) { label = 'Submitted' ; col = '#44F' ; } else if ( cint ( doc . docstatus ) == 2 ) { label = 'Cancelled' ; col = '#F44' ; }
sp1 = make _tag ( label , col ) ; this . set _in _recent ( doc , col ) ; return [ sp1 , sp2 ] ; }
_f . FrmHeader . prototype . set _in _recent = function ( doc , col ) { var tn = $i ( 'rec_' + doc . doctype + '-' + doc . name ) ; if ( tn )
$y ( tn , { backgroundColor : col } ) ; }
_f . FrmHeader . prototype . set _save _submit _color = function ( doc ) { var save _btn = this . page _head . buttons [ 'Save' ] ; var submit _btn = this . page _head . buttons [ 'Submit' ] ; if ( cint ( doc . docstatus ) == 0 && submit _btn && save _btn ) { if ( cint ( doc . _ _unsaved ) ) { $ ( save _btn ) . addClass ( 'primary' ) ; $ ( submit _btn ) . removeClass ( 'primary' ) ; } else { $ ( submit _btn ) . addClass ( 'primary' ) ; $ ( save _btn ) . removeClass ( 'primary' ) ; } } }
_f . FrmHeader . prototype . refresh _labels = function ( f ) { var ph = this . page _head ; var me = this ; this . dt _area . innerHTML = get _doctype _label ( f . doctype ) ; this . dn _area . innerHTML = '' ; if ( ! f . meta . issingle )
this . dn _area . innerHTML = f . docname ; var doc = locals [ f . doctype ] [ f . docname ] ; var sl = this . get _status _tags ( doc , f ) ; this . set _save _submit _color ( doc ) ; var t = this . status _area ; t . innerHTML = '' ; t . appendChild ( sl [ 0 ] ) ; if ( sl [ 1 ] ) t . appendChild ( sl [ 1 ] ) ; this . timestamp _area . innerHTML = me . get _timestamp ( doc ) ; }
/ *
* lib / js / legacy / widgets / form / form . js
* /
wn . provide ( '_f' ) ; _f . edit _record = function ( dt , dn ) { d = _f . frm _dialog ; var show _dialog = function ( ) { var f = frms [ dt ] ; if ( f . meta . istable ) { f . parent _doctype = cur _frm . doctype ; f . parent _docname = cur _frm . docname ; }
d . cur _frm = f ; d . dn = dn ; d . table _form = f . meta . istable ; f . refresh ( dn ) ; }
if ( ! frms [ dt ] ) { _f . add _frm ( dt , show _dialog , null ) ; } else { show _dialog ( ) ; } }
_f . Frm = function ( doctype , parent ) { this . docname = '' ; this . doctype = doctype ; this . display = 0 ; var me = this ; this . is _editable = { } ; this . opendocs = { } ; this . cur _section = { } ; this . sections = [ ] ; this . sections _by _label = { } ; this . section _count ; this . grids = [ ] ; this . cscript = { } ; this . pformat = { } ; this . fetch _dict = { } ; this . parent = parent ; this . tinymce _id _list = [ ] ; frms [ doctype ] = this ; this . setup _meta ( doctype ) ; rename _observers . push ( this ) ; }
_f . Frm . prototype . setup = function ( ) { var me = this ; this . fields = [ ] ; this . fields _dict = { } ; this . wrapper = $a ( this . parent . body , 'div' ) ; this . setup _print _layout ( ) ; this . saved _wrapper = $a ( this . wrapper , 'div' ) ; this . setup _std _layout ( ) ; this . setup _client _script ( ) ; this . setup _done = true ; }
_f . Frm . prototype . setup _print _layout = function ( ) { this . print _wrapper = $a ( this . wrapper , 'div' ) ; this . print _head = $a ( this . print _wrapper , 'div' ) ; this . print _body = $a ( this . print _wrapper , 'div' , 'layout_wrapper' , { padding : '23px' } ) ; var t = make _table ( this . print _head , 1 , 2 , '100%' , [ ] , { padding : '6px' } ) ; this . view _btn _wrapper = $a ( $td ( t , 0 , 0 ) , 'span' , 'green_buttons' ) ; this . view _btn = $btn ( this . view _btn _wrapper , 'View Details' , function ( ) { cur _frm . edit _doc ( ) } , { marginRight : '4px' } , 'green' ) ; this . print _btn = $btn ( $td ( t , 0 , 0 ) , 'Print' , function ( ) { cur _frm . print _doc ( ) } ) ; $y ( $td ( t , 0 , 1 ) , { textAlign : 'right' } ) ; this . print _close _btn = $btn ( $td ( t , 0 , 1 ) , 'Close' , function ( ) { nav _obj . show _last _open ( ) ; } ) ; }
_f . Frm . prototype . onhide = function ( ) { if ( _f . cur _grid _cell ) _f . cur _grid _cell . grid . cell _deselect ( ) ; }
_f . Frm . prototype . setup _std _layout = function ( ) { this . page _layout = new wn . PageLayout ( { parent : this . wrapper , main _width : this . in _dialog ? '100%' : '75%' , sidebar _width : this . in _dialog ? '0%' : '25%' } )
this . meta . section _style = 'Simple' ; this . layout = new Layout ( this . page _layout . body , '100%' ) ; if ( ! this . in _dialog ) { this . setup _sidebar ( ) ; }
this . setup _footer ( ) ; if ( ! ( this . meta . istable || user == 'Guest' ) ) this . frm _head = new _f . FrmHeader ( this . page _layout . head , this ) ; if ( this . frm _head && this . meta . in _dialog ) $dh ( this . frm _head . page _head . close _btn ) ; if ( this . meta . colour )
this . layout . wrapper . style . backgroundColor = '#' + this . meta . colour . split ( ':' ) [ 1 ] ; this . setup _fields _std ( ) ; if ( this . meta . description )
this . add _description ( ) ; }
_f . Frm . prototype . add _description = function ( ) { if ( ! wn . md2html ) { wn . require ( 'lib/js/lib/showdown.js' ) ; wn . md2html = new Showdown . converter ( ) ; }
this . description _wrapper = $a ( this . page _layout . footer . help _area , 'div' , 'info-box' , { marginTop : '10px' } , wn . md2html . makeHtml ( '#### Help\n\n' + this . meta . description ) ) ; }
_f . Frm . prototype . setup _print = function ( ) { var fl = getchildren ( 'DocFormat' , this . meta . name , 'formats' , 'DocType' ) ; var l = [ ] ; this . default _format = 'Standard' ; if ( fl . length ) { this . default _format = fl [ 0 ] . format ; for ( var i = 0 ; i < fl . length ; i ++ )
l . push ( fl [ i ] . format ) ; }
if ( this . meta . default _print _format )
this . default _format = this . meta . default _print _format ; l . push ( 'Standard' ) ; this . print _sel = $a ( null , 'select' , '' , { width : '160px' } ) ; add _sel _options ( this . print _sel , l ) ; this . print _sel . value = this . default _format ; }
_f . Frm . prototype . print _doc = function ( ) { if ( this . doc . docstatus == 2 ) { msgprint ( "Cannot Print Cancelled Documents." ) ; return ; }
_p . show _dialog ( ) ; }
_f . Frm . prototype . email _doc = function ( ) { if ( ! _e . dialog ) _e . make ( ) ; sel = this . print _sel ; var c = $td ( _e . dialog . rows [ 'Format' ] . tab , 0 , 1 ) ; if ( c . cur _sel ) { c . removeChild ( c . cur _sel ) ; c . cur _sel = null ; }
c . appendChild ( this . print _sel ) ; c . cur _sel = this . print _sel ; _e . dialog . widgets [ 'Send With Attachments' ] . checked = 0 ; if ( cur _frm . doc . file _list ) { $ds ( _e . dialog . rows [ 'Send With Attachments' ] ) ; } else { $dh ( _e . dialog . rows [ 'Send With Attachments' ] ) ; }
_e . dialog . widgets [ 'Subject' ] . value = get _doctype _label ( this . meta . name ) + ': ' + this . docname ; _e . dialog . show ( ) ; }
_f . Frm . prototype . rename _notify = function ( dt , old , name ) { if ( this . doctype != dt ) return ; this . cur _section [ name ] = this . cur _section [ old ] ; delete this . cur _section [ old ] ; this . is _editable [ name ] = this . is _editable [ old ] ; delete this . is _editable [ old ] ; if ( this . docname == old )
this . docname = name ; if ( this && this . opendocs [ old ] ) { local _dt [ dt ] [ name ] = local _dt [ dt ] [ old ] ; local _dt [ dt ] [ old ] = null ; }
this . opendocs [ old ] = false ; this . opendocs [ name ] = true ; }
_f . Frm . prototype . set _heading = function ( ) { if ( ! this . meta . istable && this . frm _head ) this . frm _head . refresh _labels ( this ) ; }
_f . Frm . prototype . set _section = function ( sec _id ) { if ( ! this . sections [ sec _id ] || ! this . sections [ sec _id ] . expand )
return ; if ( this . sections [ this . cur _section [ this . docname ] ] )
this . sections [ this . cur _section [ this . docname ] ] . collapse ( ) ; this . sections [ sec _id ] . expand ( ) ; this . cur _section [ this . docname ] = sec _id ; }
_f . Frm . prototype . setup _meta = function ( ) { this . meta = get _local ( 'DocType' , this . doctype ) ; this . perm = get _perm ( this . doctype ) ; this . setup _print ( ) ; }
_f . Frm . prototype . setup _sidebar = function ( ) { this . sidebar = new wn . widgets . form . sidebar . Sidebar ( this ) ; }
_f . Frm . prototype . setup _footer = function ( ) { var me = this ; var f = this . page _layout . footer ; f . save _area = $a ( this . page _layout . footer , 'div' , '' , { display : 'none' } ) ; f . help _area = $a ( this . page _layout . footer , 'div' ) ; var b = $btn ( f . save _area , 'Save' , function ( ) { cur _frm . save ( 'Save' ) ; } , { marginLeft : '0px' } , 'green' ) ; f . show _save = function ( ) { $ds ( me . page _layout . footer . save _area ) ; }
f . hide _save = function ( ) { $dh ( me . page _layout . footer . save _area ) ; } }
_f . Frm . prototype . setup _fields _std = function ( ) { var fl = fields _list [ this . doctype ] ; fl . sort ( function ( a , b ) { return a . idx - b . idx } ) ; if ( fl [ 0 ] && fl [ 0 ] . fieldtype != "Section Break" || get _url _arg ( 'embed' ) ) { this . layout . addrow ( ) ; if ( fl [ 0 ] . fieldtype != "Column Break" ) { var c = this . layout . addcell ( ) ; $y ( c . wrapper , { padding : '8px' } ) ; } }
var sec ; for ( var i = 0 ; i < fl . length ; i ++ ) { var f = fl [ i ] ; if ( get _url _arg ( 'embed' ) && ( in _list ( [ 'Section Break' , 'Column Break' ] , f . fieldtype ) ) ) continue ; if ( f . fieldtype == 'Section Break' && fl [ i + 1 ] && fl [ i + 1 ] . fieldtype == 'Section Break' ) continue ; var fn = f . fieldname ? f . fieldname : f . label ; var fld = make _field ( f , this . doctype , this . layout . cur _cell , this ) ; this . fields [ this . fields . length ] = fld ; this . fields _dict [ fn ] = fld ; if ( this . meta . section _style != 'Simple' )
fld . parent _section = sec ; if ( f . fieldtype == 'Section Break' && f . options != 'Simple' )
sec = fld ; if ( ( f . fieldtype == 'Section Break' ) && ( fl [ i + 1 ] ) && ( fl [ i + 1 ] . fieldtype != 'Column Break' ) ) { var c = this . layout . addcell ( ) ; $y ( c . wrapper , { padding : '8px' } ) ; } } }
_f . Frm . prototype . add _custom _button = function ( label , fn , icon ) { this . frm _head . page _head . add _button ( label , fn , 1 ) ; }
_f . Frm . prototype . clear _custom _buttons = function ( ) { }
_f . Frm . prototype . add _fetch = function ( link _field , src _field , tar _field ) { if ( ! this . fetch _dict [ link _field ] ) { this . fetch _dict [ link _field ] = { 'columns' : [ ] , 'fields' : [ ] } }
this . fetch _dict [ link _field ] . columns . push ( src _field ) ; this . fetch _dict [ link _field ] . fields . push ( tar _field ) ; }
_f . Frm . prototype . setup _client _script = function ( ) { if ( this . meta . client _script _core || this . meta . client _script || this . meta . _ _js ) { this . runclientscript ( 'setup' , this . doctype , this . docname ) ; } }
_f . Frm . prototype . set _parent = function ( parent ) { if ( parent ) { this . parent = parent ; if ( this . wrapper && this . wrapper . parentNode != parent )
parent . appendChild ( this . wrapper ) ; } }
_f . Frm . prototype . refresh _print _layout = function ( ) { $ds ( this . print _wrapper ) ; $dh ( this . page _layout . wrapper ) ; var me = this ; var print _callback = function ( print _html ) { me . print _body . innerHTML = print _html ; }
if ( cur _frm . doc . select _print _heading )
cur _frm . set _print _heading ( cur _frm . doc . select _print _heading )
if ( user != 'Guest' ) { $di ( this . view _btn _wrapper ) ; if ( cur _frm . doc . _ _archived ) { $dh ( this . view _btn _wrapper ) ; } } else { $dh ( this . view _btn _wrapper ) ; $dh ( this . print _close _btn ) ; }
_p . build ( this . default _format , print _callback , null , 1 ) ; }
_f . Frm . prototype . hide = function ( ) { $dh ( this . wrapper ) ; this . display = 0 ; if ( hide _autosuggest )
hide _autosuggest ( ) ; }
_f . Frm . prototype . show _the _frm = function ( ) { if ( this . parent . last _displayed && this . parent . last _displayed != this ) { this . parent . last _displayed . defocus _rest ( ) ; this . parent . last _displayed . hide ( ) ; }
if ( this . wrapper && this . wrapper . style . display . toLowerCase ( ) == 'none' ) { $ds ( this . wrapper ) ; this . display = 1 ; }
if ( this . meta . in _dialog && ! this . parent . dialog . display ) { if ( ! this . meta . istable )
this . parent . table _form = false ; this . parent . dialog . show ( ) ; }
this . parent . last _displayed = this ; }
_f . Frm . prototype . set _print _heading = function ( txt ) { this . pformat [ cur _frm . docname ] = txt ; }
_f . Frm . prototype . defocus _rest = function ( ) { if ( _f . cur _grid _cell ) _f . cur _grid _cell . grid . cell _deselect ( ) ; cur _page = null ; }
_f . Frm . prototype . get _doc _perms = function ( ) { var p = [ 0 , 0 , 0 , 0 , 0 , 0 ] ; for ( var i = 0 ; i < this . perm . length ; i ++ ) { if ( this . perm [ i ] ) { if ( this . perm [ i ] [ READ ] ) p [ READ ] = 1 ; if ( this . perm [ i ] [ WRITE ] ) p [ WRITE ] = 1 ; if ( this . perm [ i ] [ SUBMIT ] ) p [ SUBMIT ] = 1 ; if ( this . perm [ i ] [ CANCEL ] ) p [ CANCEL ] = 1 ; if ( this . perm [ i ] [ AMEND ] ) p [ AMEND ] = 1 ; } }
return p ; }
_f . Frm . prototype . refresh _header = function ( ) { if ( ! this . meta . in _dialog ) { set _title ( this . meta . issingle ? this . doctype : this . docname ) ; }
if ( this . frm _head ) this . frm _head . refresh _toolbar ( ) ; if ( wn . ui . toolbar . recent ) wn . ui . toolbar . recent . add ( this . doctype , this . docname , 1 ) ; this . set _heading ( ) ; }
_f . Frm . prototype . check _doc _perm = function ( ) { var dt = this . parent _doctype ? this . parent _doctype : this . doctype ; var dn = this . parent _docname ? this . parent _docname : this . docname ; this . perm = get _perm ( dt , dn ) ; this . orig _perm = get _perm ( dt , dn , 1 ) ; if ( ! this . perm [ 0 ] [ READ ] ) { if ( user == 'Guest' ) { if ( _f . temp _access [ dt ] && _f . temp _access [ dt ] [ dn ] ) { this . perm = [ [ 1 , 0 , 0 ] ]
return 1 ; } }
nav _obj . show _last _open ( ) ; return 0 ; }
return 1 }
_f . Frm . prototype . refresh = function ( docname ) { if ( docname ) { if ( this . docname != docname && ! this . meta . in _dialog && ! this . meta . istable ) scroll ( 0 , 0 ) ; this . docname = docname ; }
if ( ! this . meta . istable ) { cur _frm = this ; this . parent . cur _frm = this ; }
if ( this . docname ) { if ( ! this . check _doc _perm ( ) ) return ; if ( ! this . setup _done ) this . setup ( ) ; this . runclientscript ( 'set_perm' , this . doctype , this . docname ) ; this . doc = get _local ( this . doctype , this . docname ) ; var is _onload = false ; if ( ! this . opendocs [ this . docname ] ) { is _onload = true ; this . setnewdoc ( this . docname ) ; }
if ( this . doc . _ _islocal )
this . is _editable [ this . docname ] = 1 ; this . editable = this . is _editable [ this . docname ] ; if ( ! this . doc . _ _archived && ( this . editable || ( ! this . editable && this . meta . istable ) ) ) { if ( this . print _wrapper ) { $dh ( this . print _wrapper ) ; $ds ( this . page _layout . wrapper ) ; }
if ( ! this . meta . istable ) { this . refresh _header ( ) ; this . sidebar && this . sidebar . refresh ( ) ; }
this . runclientscript ( 'refresh' ) ; $ ( document ) . trigger ( 'form_refresh' )
this . refresh _tabs ( ) ; this . refresh _fields ( ) ; this . refresh _dependency ( ) ; this . refresh _footer ( ) ; if ( this . layout ) this . layout . show ( ) ; if ( is _onload )
this . runclientscript ( 'onload_post_render' , this . doctype , this . docname ) ; } else { this . refresh _header ( ) ; if ( this . print _wrapper ) { this . refresh _print _layout ( ) ; }
this . runclientscript ( 'edit_status_changed' ) ; }
if ( ! this . display ) this . show _the _frm ( ) ; if ( ! this . meta . in _dialog ) page _body . change _to ( 'Forms' ) ; $ ( cur _frm . wrapper ) . trigger ( 'render_complete' ) ; } }
_f . Frm . prototype . refresh _tabs = function ( ) { var me = this ; if ( me . meta . section _style == 'Tray' || me . meta . section _style == 'Tabbed' ) { for ( var i in me . sections ) { me . sections [ i ] . collapse ( ) ; }
me . set _section ( me . cur _section [ me . docname ] ) ; } }
_f . Frm . prototype . refresh _footer = function ( ) { var f = this . page _layout . footer ; if ( f . save _area ) { if ( get _url _arg ( 'embed' ) || ( this . editable && ! this . meta . in _dialog && this . doc . docstatus == 0 && ! this . meta . istable && this . get _doc _perms ( ) [ WRITE ] ) ) { f . show _save ( ) ; } else { f . hide _save ( ) ; } } }
_f . Frm . prototype . refresh _fields = function ( ) { for ( var i = 0 ; i < this . fields . length ; i ++ ) { var f = this . fields [ i ] ; f . perm = this . perm ; f . docname = this . docname ; if ( f . refresh ) f . refresh ( ) ; }
this . cleanup _refresh ( this ) ; }
_f . Frm . prototype . cleanup _refresh = function ( ) { var me = this ; if ( me . fields _dict [ 'amended_from' ] ) { if ( me . doc . amended _from ) { unhide _field ( 'amended_from' ) ; unhide _field ( 'amendment_date' ) ; } else { hide _field ( 'amended_from' ) ; hide _field ( 'amendment_date' ) ; } }
if ( me . fields _dict [ 'trash_reason' ] ) { if ( me . doc . trash _reason && me . doc . docstatus == 2 ) { unhide _field ( 'trash_reason' ) ; } else { hide _field ( 'trash_reason' ) ; } }
if ( me . meta . autoname && me . meta . autoname . substr ( 0 , 6 ) == 'field:' && ! me . doc . _ _islocal ) { var fn = me . meta . autoname . substr ( 6 ) ; set _field _permlevel ( fn , 1 ) ; } }
_f . Frm . prototype . refresh _dependency = function ( ) { var me = this ; var doc = locals [ this . doctype ] [ this . docname ] ; var dep _dict = { } ; var has _dep = false ; for ( fkey in me . fields ) { var f = me . fields [ fkey ] ; f . dependencies _clear = true ; var guardian = f . df . depends _on ; if ( guardian ) { if ( ! dep _dict [ guardian ] )
dep _dict [ guardian ] = [ ] ; dep _dict [ guardian ] [ dep _dict [ guardian ] . length ] = f ; has _dep = true ; } }
if ( ! has _dep ) return ; for ( var i = me . fields . length - 1 ; i >= 0 ; i -- ) { var f = me . fields [ i ] ; f . guardian _has _value = true ; if ( f . df . depends _on ) { var v = doc [ f . df . depends _on ] ; if ( f . df . depends _on . substr ( 0 , 5 ) == 'eval:' ) { f . guardian _has _value = eval ( f . df . depends _on . substr ( 5 ) ) ; } else if ( f . df . depends _on . substr ( 0 , 3 ) == 'fn:' ) { f . guardian _has _value = me . runclientscript ( f . df . depends _on . substr ( 3 ) , me . doctype , me . docname ) ; } else { if ( v || ( v == 0 && ! v . substr ) ) { } else { f . guardian _has _value = false ; } }
if ( f . guardian _has _value ) { if ( f . grid ) f . grid . show ( ) ; else $ds ( f . wrapper ) ; } else { if ( f . grid ) f . grid . hide ( ) ; else $dh ( f . wrapper ) ; } } } }
_f . Frm . prototype . setnewdoc = function ( docname ) { if ( this . opendocs [ docname ] ) { this . docname = docname ; return ; }
Meta . make _local _dt ( this . doctype , docname ) ; this . docname = docname ; var me = this ; var viewname = docname ; if ( this . meta . issingle ) viewname = this . doctype ; this . runclientscript ( 'onload' , this . doctype , this . docname ) ; this . is _editable [ docname ] = 1 ; if ( this . meta . read _only _onload ) this . is _editable [ docname ] = 0 ; if ( this . meta . section _style == 'Tray' || this . meta . section _style == 'Tabbed' ) { this . cur _section [ docname ] = 0 ; }
this . opendocs [ docname ] = true ; }
_f . Frm . prototype . edit _doc = function ( ) { this . is _editable [ this . docname ] = true ; this . refresh ( ) ; }
_f . Frm . prototype . show _doc = function ( dn ) { this . refresh ( dn ) ; }
var validated ; _f . Frm . prototype . save = function ( save _action , call _back ) { if ( ! save _action ) save _action = 'Save' ; var me = this ; if ( this . savingflag ) { msgprint ( "Document is currently saving...." ) ; return ; }
if ( save _action == 'Submit' ) { locals [ this . doctype ] [ this . docname ] . submitted _on = dateutil . full _str ( ) ; locals [ this . doctype ] [ this . docname ] . submitted _by = user ; }
if ( save _action == 'Trash' ) { var reason = prompt ( 'Reason for trash (mandatory)' , '' ) ; if ( ! strip ( reason ) ) { msgprint ( 'Reason is mandatory, not trashed' ) ; return ; }
locals [ this . doctype ] [ this . docname ] . trash _reason = reason ; }
if ( save _action == 'Cancel' ) { var reason = prompt ( 'Reason for cancellation (mandatory)' , '' ) ; if ( ! strip ( reason ) ) { msgprint ( 'Reason is mandatory, not cancelled' ) ; return ; }
locals [ this . doctype ] [ this . docname ] . cancel _reason = reason ; locals [ this . doctype ] [ this . docname ] . cancelled _on = dateutil . full _str ( ) ; locals [ this . doctype ] [ this . docname ] . cancelled _by = user ; } else if ( save _action == 'Update' ) { } else { validated = true ; if ( this . cscript . validate )
this . runclientscript ( 'validate' , this . doctype , this . docname ) ; if ( ! validated ) { this . savingflag = false ; return 'Error' ; } }
var ret _fn = function ( r ) { if ( user == 'Guest' && ! r . exc ) { $dh ( me . page _layout . wrapper ) ; $ds ( me . saved _wrapper ) ; me . saved _wrapper . innerHTML = '<div style="padding: 150px 16px; text-align: center; font-size: 14px;">'
+ ( cur _frm . message _after _save ? cur _frm . message _after _save : 'Your information has been sent. Thank you!' )
+ '</div>' ; return ; }
if ( ! me . meta . istable ) { me . refresh ( ) ; }
if ( call _back ) { if ( call _back == 'home' ) { loadpage ( '_home' ) ; return ; }
call _back ( r ) ; } }
var me = this ; var ret _fn _err = function ( r ) { var doc = locals [ me . doctype ] [ me . docname ] ; me . savingflag = false ; ret _fn ( r ) ; }
this . savingflag = true ; if ( this . docname && validated ) { scroll ( 0 , 0 ) ; return this . savedoc ( save _action , ret _fn , ret _fn _err ) ; } }
_f . Frm . prototype . runscript = function ( scriptname , callingfield , onrefresh ) { var me = this ; if ( this . docname ) { var doclist = compress _doclist ( make _doclist ( this . doctype , this . docname ) ) ; if ( callingfield ) callingfield . input . disabled = true ; $c ( 'runserverobj' , { 'docs' : doclist , 'method' : scriptname } , function ( r , rtxt ) { if ( onrefresh )
onrefresh ( r , rtxt ) ; me . refresh _fields ( ) ; me . refresh _dependency ( ) ; if ( callingfield ) callingfield . input . done _working ( ) ; } ) ; } }
_f . Frm . prototype . runclientscript = function ( caller , cdt , cdn ) { var _dt = this . parent _doctype ? this . parent _doctype : this . doctype ; var _dn = this . parent _docname ? this . parent _docname : this . docname ; var doc = get _local ( _dt , _dn ) ; if ( ! cdt ) cdt = this . doctype ; if ( ! cdn ) cdn = this . docname ; var ret = null ; try { if ( this . cscript [ caller ] )
ret = this . cscript [ caller ] ( doc , cdt , cdn ) ; if ( this . cscript [ 'custom_' + caller ] )
ret += this . cscript [ 'custom_' + caller ] ( doc , cdt , cdn ) ; } catch ( e ) { console . log ( e ) ; }
if ( caller && caller . toLowerCase ( ) == 'setup' ) { var doctype = get _local ( 'DocType' , this . doctype ) ; var cs = doctype . _ _js || ( doctype . client _script _core + doctype . client _script ) ; if ( cs ) { try { var tmp = eval ( cs ) ; } catch ( e ) { console . log ( e ) ; } }
if ( doctype . _ _css ) set _style ( doctype . _ _css )
if ( doctype . client _string ) { this . cstring = { } ; var elist = doctype . client _string . split ( '---' ) ; for ( var i = 1 ; i < elist . length ; i = i + 2 ) { this . cstring [ strip ( elist [ i ] ) ] = elist [ i + 1 ] ; } } }
return ret ; }
_f . Frm . prototype . copy _doc = function ( onload , from _amend ) { if ( ! this . perm [ 0 ] [ CREATE ] ) { msgprint ( 'You are not allowed to create ' + this . meta . name ) ; return ; }
var dn = this . docname ; var newdoc = LocalDB . copy ( this . doctype , dn , from _amend ) ; if ( this . meta . allow _attach && newdoc . file _list )
newdoc . file _list = null ; var dl = make _doclist ( this . doctype , dn ) ; var tf _dict = { } ; for ( var d in dl ) { d1 = dl [ d ] ; if ( ! tf _dict [ d1 . parentfield ] ) { tf _dict [ d1 . parentfield ] = get _field ( d1 . parenttype , d1 . parentfield ) ; }
if ( d1 . parent == dn && cint ( tf _dict [ d1 . parentfield ] . no _copy ) != 1 ) { var ch = LocalDB . copy ( d1 . doctype , d1 . name , from _amend ) ; ch . parent = newdoc . name ; ch . docstatus = 0 ; ch . owner = user ; ch . creation = '' ; ch . modified _by = user ; ch . modified = '' ; } }
newdoc . _ _islocal = 1 ; newdoc . docstatus = 0 ; newdoc . owner = user ; newdoc . creation = '' ; newdoc . modified _by = user ; newdoc . modified = '' ; if ( onload ) onload ( newdoc ) ; loaddoc ( newdoc . doctype , newdoc . name ) ; }
_f . Frm . prototype . reload _doc = function ( ) { var me = this ; if ( frms [ 'DocType' ] && frms [ 'DocType' ] . opendocs [ me . doctype ] ) { msgprint ( "error:Cannot refresh an instance of \"" + me . doctype + "\" when the DocType is open." ) ; return ; }
var ret _fn = function ( r , rtxt ) { page _body . set _status ( 'Done' )
me . runclientscript ( 'setup' , me . doctype , me . docname ) ; me . refresh ( ) ; }
page _body . set _status ( 'Reloading...' )
if ( me . doc . _ _islocal ) { $c ( 'webnotes.widgets.form.load.getdoctype' , { 'doctype' : me . doctype } , ret _fn , null , null , 'Refreshing ' + me . doctype + '...' ) ; } else { var gl = me . grids ; for ( var i = 0 ; i < gl . length ; i ++ ) { var dt = gl [ i ] . df . options ; for ( var dn in locals [ dt ] ) { if ( locals [ dt ] [ dn ] . _ _islocal && locals [ dt ] [ dn ] . parent == me . docname ) { var d = locals [ dt ] [ dn ] ; d . parent = '' ; d . docstatus = 2 ; d . _ _deleted = 1 ; } } }
$c ( 'webnotes.widgets.form.load.getdoc' , { 'name' : me . docname , 'doctype' : me . doctype , 'getdoctype' : 1 , 'user' : user } , ret _fn , null , null , 'Refreshing ' + me . docname + '...' ) ; } }
_f . Frm . prototype . savedoc = function ( save _action , onsave , onerr ) { this . error _in _section = 0 ; save _doclist ( this . doctype , this . docname , save _action , onsave , onerr ) ; }
_f . Frm . prototype . saveupdate = function ( ) { this . save ( 'Update' ) ; }
_f . Frm . prototype . savesubmit = function ( ) { var answer = confirm ( "Permanently Submit " + this . docname + "?" ) ; var me = this ; if ( answer ) { this . save ( 'Submit' , function ( r ) { if ( ! r . exc && me . cscript . on _submit ) { me . runclientscript ( 'on_submit' , me . doctype , me . docname ) ; } } ) ; } }
_f . Frm . prototype . savecancel = function ( ) { var answer = confirm ( "Permanently Cancel " + this . docname + "?" ) ; if ( answer ) this . save ( 'Cancel' ) ; }
_f . Frm . prototype . savetrash = function ( ) { var me = this ; var answer = confirm ( "Permanently Delete " + this . docname + "? This action cannot be reversed" ) ; if ( answer ) { $c ( 'webnotes.model.delete_doc' , { dt : this . doctype , dn : this . docname } , function ( r , rt ) { if ( r . message == 'okay' ) { LocalDB . delete _doc ( me . doctype , me . docname ) ; if ( wn . ui . toolbar . recent ) wn . ui . toolbar . recent . remove ( me . doctype , me . docname ) ; nav _obj . show _last _open ( ) ; } } ) } }
_f . Frm . prototype . amend _doc = function ( ) { if ( ! this . fields _dict [ 'amended_from' ] ) { alert ( '"amended_from" field must be present to do an amendment.' ) ; return ; }
var me = this ; var fn = function ( newdoc ) { newdoc . amended _from = me . docname ; if ( me . fields _dict && me . fields _dict [ 'amendment_date' ] )
newdoc . amendment _date = dateutil . obj _to _str ( new Date ( ) ) ; }
this . copy _doc ( fn , 1 ) ; }
_f . get _value = function ( dt , dn , fn ) { if ( locals [ dt ] && locals [ dt ] [ dn ] )
return locals [ dt ] [ dn ] [ fn ] ; }
_f . set _value = function ( dt , dn , fn , v ) { var d = locals [ dt ] [ dn ] ; if ( ! d ) { errprint ( 'error:Trying to set a value for "' + dt + ',' + dn + '" which is not found' ) ; return ; }
var changed = d [ fn ] != v ; if ( changed && ( d [ fn ] == null || v == null ) && ( cstr ( d [ fn ] ) == cstr ( v ) ) ) changed = 0 ; if ( changed ) { d [ fn ] = v ; d . _ _unsaved = 1 ; var frm = frms [ d . doctype ] ; try { if ( d . parent && d . parenttype ) { locals [ d . parenttype ] [ d . parent ] . _ _unsaved = 1 ; frm = frms [ d . parenttype ] ; } } catch ( e ) { if ( d . parent && d . parenttype )
errprint ( 'Setting __unsaved error:' + d . name + ',' + d . parent + ',' + d . parenttype ) ; }
if ( frm && frm == cur _frm ) { frm . set _heading ( ) ; } } }
_f . Frm . prototype . show _comments = function ( ) { if ( ! cur _frm . comments ) { cur _frm . comments = new Dialog ( 540 , 400 , 'Comments' ) ; cur _frm . comments . comment _body = $a ( cur _frm . comments . body , 'div' , 'dialog_frm' ) ; $y ( cur _frm . comments . body , { backgroundColor : '#EEE' } ) ; cur _frm . comments . list = new CommentList ( cur _frm . comments . comment _body ) ; }
cur _frm . comments . list . dt = cur _frm . doctype ; cur _frm . comments . list . dn = cur _frm . docname ; cur _frm . comments . show ( ) ; cur _frm . comments . list . run ( ) ; }
/ *
* lib / js / legacy / widgets / form / form _fields . js
* /
_f . ColumnBreak = function ( ) { this . set _input = function ( ) { } ; }
_f . ColumnBreak . prototype . make _body = function ( ) { if ( ( ! this . perm [ this . df . permlevel ] ) || ( ! this . perm [ this . df . permlevel ] [ READ ] ) || this . df . hidden ) { return ; }
this . cell = this . frm . layout . addcell ( this . df . width ) ; $y ( this . cell . wrapper , { padding : '8px' } ) ; _f . cur _col _break _width = this . df . width ; var fn = this . df . fieldname ? this . df . fieldname : this . df . label ; if ( this . df && this . df . label ) { this . label = $a ( this . cell . wrapper , 'h3' , '' , '' , this . df . label ) ; } }
_f . ColumnBreak . prototype . refresh = function ( layout ) { if ( ! this . cell ) return ; var fn = this . df . fieldname ? this . df . fieldname : this . df . label ; if ( fn ) { this . df = get _field ( this . doctype , fn , this . docname ) ; if ( this . set _hidden != this . df . hidden ) { if ( this . df . hidden )
this . cell . hide ( ) ; else
this . cell . show ( ) ; this . set _hidden = this . df . hidden ; } } }
_f . SectionBreak = function ( ) { this . set _input = function ( ) { } ; }
_f . SectionBreak . prototype . make _row = function ( ) { this . row = this . df . label ? this . frm . layout . addrow ( ) : this . frm . layout . addsubrow ( ) ; }
_f . SectionBreak . prototype . make _collapsible = function ( head ) { var me = this ; var div = $a ( head , 'div' , '' , { paddingBottom : '3px' , borderBottom : '1px solid #AAA' } ) ; if ( cur _frm . meta . in _dialog ) $y ( div , { marginLeft : '8px' } ) ; this . chk = $a _input ( div , 'checkbox' , null , { marginRight : '8px' } )
if ( this . df . label ) { this . label = $a ( div , 'h3' , '' , { display : 'inline' } , this . df . label ) ; }
var d = this . df . description ; if ( d ) { this . desc _area = $a ( div , 'span' , 'field_description' , { marginLeft : '8px' } ) ; this . desc _area . innerHTML = d . substr ( 0 , 50 ) + ( d . length > 50 ? '...' : '' ) ; }
var span = $a ( div , 'div' , 'wn-icon ic-arrow_top' , { cssFloat : 'right' , marginRight : '8px' , cursor : 'pointer' , marginTop : '7px' } )
span . title = 'Go to top' ; span . onclick = function ( ) { scroll ( 0 , 0 ) ; }
this . chk . onclick = function ( ) { if ( this . checked ) me . expand ( ) ; else me . collapse ( ) ; }
this . expand = function ( ) { $ ( me . row . main _body ) . slideDown ( ) ; }
this . collapse = function ( ) { $ ( me . row . main _body ) . slideUp ( ) ; }
if ( me . frm . section _count ) { $dh ( this . row . main _body ) ; } else { this . chk . checked = true ; } }
_f . SectionBreak . prototype . make _simple _section = function ( with _header ) { this . wrapper = $a ( this . row . main _head , 'div' , '' , { margin : '8px 8px 0px 0px' } ) ; var me = this ; if ( this . df . colour ) { var col = this . df . colour . split ( ':' ) [ 1 ] ; if ( col != 'FFF' ) { $y ( this . row . sub _wrapper , { margin : '8px' , padding : '0px' , backgroundColor : ( '#' + col ) } ) ; } }
if ( with _header ) { if ( this . df . label && this . df . options != 'Simple' ) { this . make _collapsible ( this . wrapper ) ; } else { $y ( this . wrapper , { paddingBottom : '4px' } ) ; if ( this . df . label ) { $a ( this . wrapper , 'h3' , '' , { } , this . df . label ) ; } } }
$y ( this . row . body , { marginLeft : '17px' } ) ; }
_f . SectionBreak . prototype . add _to _sections = function ( ) { this . sec _id = this . frm . sections . length ; this . frm . sections [ this . sec _id ] = this ; this . frm . sections _by _label [ this . df . label ] = this ; }
_f . cur _sec _header = null ; _f . SectionBreak . prototype . make _body = function ( ) { if ( ( ! this . perm [ this . df . permlevel ] ) || ( ! this . perm [ this . df . permlevel ] [ READ ] ) || this . df . hidden ) { return ; }
var me = this ; if ( this . df ) { this . make _row ( ) ; this . make _simple _section ( 1 , 1 ) ; } }
_f . SectionBreak . prototype . refresh = function ( layout ) { var fn = this . df . fieldname ? this . df . fieldname : this . df . label ; if ( fn )
this . df = get _field ( this . doctype , fn , this . docname ) ; if ( this . set _hidden != this . df . hidden ) { if ( this . df . hidden ) { if ( this . frm . meta . section _style == 'Tabbed' ) { $dh ( this . mytab ) ; } else if ( this . tray _item )
this . tray _item . hide ( ) ; if ( this . row ) this . row . hide ( ) ; } else { if ( this . frm . meta . section _style == 'Tabbed' ) { $di ( this . mytab ) ; } else if ( this . tray _item )
this . tray _item . show ( ) ; if ( this . expanded ) this . row . show ( ) ; }
this . set _hidden = this . df . hidden ; } }
_f . ImageField = function ( ) { this . images = { } ; }
_f . ImageField . prototype = new Field ( ) ; _f . ImageField . prototype . onmake = function ( ) { this . no _img = $a ( this . wrapper , 'div' , 'no_img' ) ; this . no _img . innerHTML = "No Image" ; $dh ( this . no _img ) ; }
_f . ImageField . prototype . get _image _src = function ( doc ) { if ( doc . file _list ) { file = doc . file _list . split ( ',' ) ; extn = file [ 0 ] . split ( '.' ) ; extn = extn [ extn . length - 1 ] . toLowerCase ( ) ; var img _extn _list = [ 'gif' , 'jpg' , 'bmp' , 'jpeg' , 'jp2' , 'cgm' , 'ief' , 'jpm' , 'jpx' , 'png' , 'tiff' , 'jpe' , 'tif' ] ; if ( in _list ( img _extn _list , extn ) ) { var src = outUrl + "?cmd=downloadfile&file_id=" + file [ 1 ] ; } } else { var src = "" ; }
return src ; }
_f . ImageField . prototype . onrefresh = function ( ) { var me = this ; if ( ! this . images [ this . docname ] ) this . images [ this . docname ] = $a ( this . wrapper , 'img' ) ; else $di ( this . images [ this . docname ] ) ; var img = this . images [ this . docname ]
for ( var dn in this . images ) if ( dn != this . docname ) $dh ( this . images [ dn ] ) ; var doc = locals [ this . frm . doctype ] [ this . frm . docname ] ; if ( ! this . df . options ) var src = this . get _image _src ( doc ) ; else var src = outUrl + '?cmd=get_file&fname=' + this . df . options + "&__account=" + account _id + ( _ _sid150 ? ( "&sid150=" + _ _sid150 ) : '' ) ; if ( src ) { $dh ( this . no _img ) ; if ( img . getAttribute ( 'src' ) != src ) img . setAttribute ( 'src' , src ) ; canvas = this . wrapper ; canvas . img = this . images [ this . docname ] ; canvas . style . overflow = "auto" ; $w ( canvas , "100%" ) ; if ( ! this . col _break _width ) this . col _break _width = '100%' ; var allow _width = cint ( 1000 * ( cint ( this . col _break _width ) - 10 ) / 100 ) ; if ( ( ! img . naturalWidth ) || cint ( img . naturalWidth ) > allow _width )
$w ( img , allow _width + 'px' ) ; } else { $ds ( this . no _img ) ; } }
_f . ImageField . prototype . set _disp = function ( val ) { }
_f . ImageField . prototype . set = function ( val ) { }
_f . TableField = function ( ) { } ; _f . TableField . prototype = new Field ( ) ; _f . TableField . prototype . with _label = 0 ; _f . TableField . prototype . make _body = function ( ) { if ( this . perm [ this . df . permlevel ] && this . perm [ this . df . permlevel ] [ READ ] ) { if ( this . df . description ) { this . desc _area = $a ( this . parent , 'div' , 'field_description' , '' , this . df . description ) }
this . grid = new _f . FormGrid ( this ) ; if ( this . frm ) this . frm . grids [ this . frm . grids . length ] = this ; this . grid . make _buttons ( ) ; } }
_f . TableField . prototype . refresh = function ( ) { if ( ! this . grid ) return ; var st = this . get _status ( ) ; if ( ! this . df [ 'default' ] )
this . df [ 'default' ] = '' ; this . grid . can _add _rows = false ; this . grid . can _edit = false
if ( st == 'Write' ) { if ( cur _frm . editable && this . perm [ this . df . permlevel ] && this . perm [ this . df . permlevel ] [ WRITE ] ) { this . grid . can _edit = true ; if ( this . df [ 'default' ] . toLowerCase ( ) != 'no toolbar' )
this . grid . can _add _rows = true ; }
if ( cur _frm . editable && cur _frm . doc . docstatus > 0 ) { if ( this . df . allow _on _submit && cur _frm . doc . docstatus == 1 ) { this . grid . can _edit = true ; if ( this . df [ 'default' ] . toLowerCase ( ) == 'no toolbar' ) { this . grid . can _add _rows = false ; } else { this . grid . can _add _rows = true ; } } else { this . grid . can _add _rows = false ; this . grid . can _edit = false ; } }
if ( this . df [ 'default' ] . toLowerCase ( ) == 'no add rows' ) { this . grid . can _add _rows = false ; } }
2012-02-14 06:33:02 +00:00
if ( st == 'Write' ) { this . grid . show ( ) ; } else if ( st == 'Read' ) { this . grid . show ( ) ; } else { this . grid . hide ( ) ; }
2012-02-14 06:14:13 +00:00
this . grid . refresh ( ) ; }
_f . TableField . prototype . set = function ( v ) { } ; _f . TableField . prototype . set _input = function ( v ) { } ; _f . CodeField = function ( ) { } ; _f . CodeField . prototype = new Field ( ) ; _f . CodeField . prototype . make _input = function ( ) { var me = this ; this . label _span . innerHTML = this . df . label ; this . input = $a ( this . input _area , 'textarea' , 'code_text' , { fontSize : '12px' } ) ; this . myid = wn . dom . set _unique _id ( this . input ) ; this . input . set _input = function ( v ) { if ( me . editor ) { me . editor . setContent ( v ) ; } else { me . input . value = v ; me . input . innerHTML = v ; } }
this . input . onchange = function ( ) { if ( me . editor ) { } else { me . set ( me . input . value ) ; }
me . run _trigger ( ) ; }
this . get _value = function ( ) { if ( me . editor ) { return me . editor . getContent ( ) ; } else { return this . input . value ; } }
if ( this . df . fieldtype == 'Text Editor' ) { $ ( me . input ) . tinymce ( { script _url : 'lib/js/legacy/tiny_mce_33/tiny_mce.js' , theme : "advanced" , plugins : "style,inlinepopups,table" , extended _valid _elements : "div[id|dir|class|align|style]" , width : '100%' , height : '360px' , theme _advanced _buttons1 : "bold,italic,underline,strikethrough,hr,|,justifyleft,justifycenter,justifyright,|,formatselect,fontselect,fontsizeselect" , theme _advanced _buttons2 : "bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,code,|,forecolor,backcolor,|,tablecontrols" , theme _advanced _buttons3 : "" , theme _advanced _toolbar _location : "top" , theme _advanced _toolbar _align : "left" , content _css : "js/tiny_mce_33/custom_content.css" , oninit : function ( ) { me . init _editor ( ) ; } } ) ; } else { $y ( me . input , { fontFamily : 'Courier, Fixed' } ) ; } }
_f . CodeField . prototype . init _editor = function ( ) { var me = this ; this . editor = tinymce . get ( this . myid ) ; this . editor . onKeyUp . add ( function ( ed , e ) { me . set ( ed . getContent ( ) ) ; } ) ; this . editor . onPaste . add ( function ( ed , e ) { me . set ( ed . getContent ( ) ) ; } ) ; this . editor . onSetContent . add ( function ( ed , e ) { me . set ( ed . getContent ( ) ) ; } ) ; var c = locals [ cur _frm . doctype ] [ cur _frm . docname ] [ this . df . fieldname ] ; if ( cur _frm && c ) { this . editor . setContent ( c ) ; } }
_f . CodeField . prototype . set _disp = function ( val ) { $y ( this . disp _area , { width : '90%' } )
if ( this . df . fieldtype == 'Text Editor' ) { this . disp _area . innerHTML = val ; } else { this . disp _area . innerHTML = '<textarea class="code_text" readonly=1>' + val + '</textarea>' ; } }
/ *
* lib / js / legacy / widgets / form / grid . js
* /
_f . cur _grid _cell = null ; _f . Grid = function ( parent ) { }
2012-02-17 08:34:55 +00:00
_f . Grid . prototype . init = function ( parent , row _height ) { var me = this ; this . col _idx _by _name = { }
this . alt _row _bg = '#F2F2FF' ; this . row _height = row _height ; if ( ! row _height ) this . row _height = '26px' ; this . make _ui ( parent ) ; this . insert _column ( '' , '' , 'Int' , 'Sr' , '50px' , '' , [ 1 , 0 , 0 ] ) ; if ( this . oninit ) this . oninit ( ) ; $ ( this . wrapper ) . bind ( 'keydown' , function ( e ) { me . notify _keypress ( e , e . which ) ; } )
$ ( cur _frm . wrapper ) . bind ( 'render_complete' , function ( ) { me . set _ht ( ) ; } ) ; }
_f . Grid . prototype . make _ui = function ( parent ) { var ht = make _table ( $a ( parent , 'div' ) , 1 , 2 , '100%' , [ '60%' , '40%' ] ) ; this . main _title = $td ( ht , 0 , 0 ) ; this . main _title . className = 'columnHeading' ; $td ( ht , 0 , 1 ) . style . textAlign = 'right' ; this . tbar _div = $a ( $td ( ht , 0 , 1 ) , 'div' , 'grid_tbarlinks' ) ; this . tbar _tab = make _table ( this . tbar _div , 1 , 4 , '100%' , [ '25%' , '25%' , '25%' , '25%' ] ) ; this . wrapper = $a ( parent , 'div' , 'grid_wrapper' ) ; this . head _wrapper = $a ( this . wrapper , 'div' , 'grid_head_wrapper' ) ; this . head _tab = $a ( this . head _wrapper , 'table' , 'grid_head_table' ) ; this . head _row = this . head _tab . insertRow ( 0 ) ; this . tab _wrapper = $a ( this . wrapper , 'div' , 'grid_tab_wrapper' ) ; this . tab = $a ( this . tab _wrapper , 'table' , 'grid_table' ) ; var me = this ; this . wrapper . onscroll = function ( ) { me . head _wrapper . style . top = me . wrapper . scrollTop + 'px' ; } }
2012-02-14 06:14:13 +00:00
_f . Grid . prototype . show = function ( ) { if ( this . can _edit && this . field . df [ 'default' ] . toLowerCase ( ) != 'no toolbar' ) { $ds ( this . tbar _div ) ; if ( this . can _add _rows ) { $td ( this . tbar _tab , 0 , 0 ) . style . display = 'table-cell' ; $td ( this . tbar _tab , 0 , 1 ) . style . display = 'table-cell' ; } else { $td ( this . tbar _tab , 0 , 0 ) . style . display = 'none' ; $td ( this . tbar _tab , 0 , 1 ) . style . display = 'none' ; } } else { $dh ( this . tbar _div ) ; }
$ds ( this . wrapper ) ; }
_f . Grid . prototype . hide = function ( ) { $dh ( this . wrapper ) ; $dh ( this . tbar _div ) ; }
_f . Grid . prototype . insert _column = function ( doctype , fieldname , fieldtype , label , width , options , perm , reqd ) { var idx = this . head _row . cells . length ; if ( ! width ) width = '100px' ; if ( ( width + '' ) . slice ( - 2 ) != 'px' ) { width = width + 'px' ; }
var col = this . head _row . insertCell ( idx ) ; col . doctype = doctype ; col . fieldname = fieldname ; col . fieldtype = fieldtype ; col . innerHTML = '<div>' + label + '</div>' ; col . label = label ; if ( reqd )
col . childNodes [ 0 ] . style . color = "#D22" ; col . style . width = width ; col . options = options ; col . perm = perm ; this . col _idx _by _name [ fieldname ] = idx ; }
_f . Grid . prototype . reset _table _width = function ( ) { var w = 0 ; for ( var i = 0 , len = this . head _row . cells . length ; i < len ; i ++ ) { w += cint ( this . head _row . cells [ i ] . style . width ) ; }
this . head _tab . style . width = w + 'px' ; this . tab . style . width = w + 'px' ; }
_f . Grid . prototype . set _column _disp = function ( fieldname , show ) { var cidx = this . col _idx _by _name [ fieldname ] ; if ( ! cidx ) { msgprint ( 'Trying to hide unknown column: ' + fieldname ) ; return ; }
var disp = show ? 'table-cell' : 'none' ; this . head _row . cells [ cidx ] . style . display = disp ; for ( var i = 0 , len = this . tab . rows . length ; i < len ; i ++ ) { var cell = this . tab . rows [ i ] . cells [ cidx ] ; cell . style . display = disp ; }
this . reset _table _width ( ) ; }
_f . Grid . prototype . append _row = function ( idx , docname ) { if ( ! idx ) idx = this . tab . rows . length ; var row = this . tab . insertRow ( idx ) ; row . docname = docname ; if ( idx % 2 ) var odd = true ; else var odd = false ; var me = this ; for ( var i = 0 ; i < this . head _row . cells . length ; i ++ ) { var cell = row . insertCell ( i ) ; var hc = this . head _row . cells [ i ] ; cell . style . width = hc . style . width ; cell . style . display = hc . style . display ; cell . row = row ; cell . grid = this ; cell . className = 'grid_cell' ; cell . div = $a ( cell , 'div' , 'grid_cell_div' ) ; if ( this . row _height ) { cell . div . style . height = this . row _height ; }
2012-02-17 08:34:55 +00:00
cell . div . cell = cell ; cell . div . onclick = function ( e ) { me . cell _select ( this . cell ) ; }
2012-02-14 06:14:13 +00:00
if ( odd ) { $bg ( cell , this . alt _row _bg ) ; cell . is _odd = 1 ; cell . div . style . border = '2px solid ' + this . alt _row _bg ; } else $bg ( cell , '#FFF' ) ; if ( ! hc . fieldname ) cell . div . style . cursor = 'default' ; }
this . set _ht ( ) ; return row ; }
_f . Grid . prototype . refresh _cell = function ( docname , fieldname ) { for ( var r = 0 ; r < this . tab . rows . length ; r ++ ) { if ( this . tab . rows [ r ] . docname == docname ) { for ( var c = 0 ; c < this . head _row . cells . length ; c ++ ) { var hc = this . head _row . cells [ c ] ; if ( hc . fieldname == fieldname ) { this . set _cell _value ( this . tab . rows [ r ] . cells [ c ] ) ; } } } } }
_f . cur _grid ; _f . cur _grid _ridx ; _f . Grid . prototype . set _cell _value = function ( cell ) { if ( cell . row . is _newrow ) return ; var hc = this . head _row . cells [ cell . cellIndex ] ; if ( hc . fieldname ) { var v = locals [ hc . doctype ] [ cell . row . docname ] [ hc . fieldname ] ; } else { var v = ( cell . row . rowIndex + 1 ) ; }
if ( v == null ) { v = '' ; }
var me = this ; if ( cell . cellIndex ) { var ft = hc . fieldtype ; if ( ft == 'Link' && cur _frm . doc . docstatus < 1 ) ft = 'Data' ; $s ( cell . div , v , ft , hc . options ) ; } else { cell . div . style . padding = '2px' ; cell . div . style . textAlign = 'left' ; cell . innerHTML = '' ; var t = make _table ( cell , 1 , 3 , '60px' , [ '20px' , '20px' , '20px' ] , { verticalAlign : 'middle' , padding : '2px' } ) ; $y ( $td ( t , 0 , 0 ) , { paddingLeft : '4px' } ) ; $td ( t , 0 , 0 ) . innerHTML = cell . row . rowIndex + 1 ; if ( cur _frm . editable && this . can _edit ) { var ed = $a ( $td ( t , 0 , 1 ) , 'div' , 'wn-icon ic-doc_edit' , { cursor : 'pointer' } ) ; ed . cell = cell ; ed . title = 'Edit Row' ; ed . onclick = function ( ) { _f . cur _grid = me ; _f . cur _grid _ridx = this . cell . row . rowIndex ; _f . edit _record ( me . doctype , this . cell . row . docname , 1 ) ; } } else { cell . div . innerHTML = ( cell . row . rowIndex + 1 ) ; cell . div . style . cursor = 'default' ; cell . div . onclick = function ( ) { } } } }
2012-02-17 08:34:55 +00:00
$ ( document ) . bind ( 'click' , function ( e ) { var is _target _toolbar = function ( ) { return $ ( e . target ) . parents ( '.grid_tbarlinks' ) . length ; }
var is _target _input = function ( ) { return $ ( e . target ) . parents ( ) . get ( ) . indexOf ( _f . cur _grid _cell ) != - 1 ; }
if ( _f . cur _grid _cell && ! is _target _input ( ) && ! is _target _toolbar ( ) ) { if ( ! ( text _dialog && text _dialog . display ) && ! datepicker _active && ! ( selector && selector . display ) && ! ( cur _autosug ) ) { _f . cur _grid _cell . grid . cell _deselect ( ) ; } } } ) ; _f . Grid . prototype . cell _deselect = function ( ) { if ( _f . cur _grid _cell ) { var c = _f . cur _grid _cell ; c . grid . remove _template ( c ) ; c . div . className = 'grid_cell_div' ; if ( c . is _odd ) c . div . style . border = '2px solid ' + c . grid . alt _row _bg ; else c . div . style . border = '2px solid #FFF' ; _f . cur _grid _cell = null ; _f . cur _grid = null ; } }
2012-02-14 06:14:13 +00:00
_f . Grid . prototype . cell _select = function ( cell , ri , ci ) { if ( ri != null && ci != null )
cell = this . tab . rows [ ri ] . cells [ ci ] ; var hc = this . head _row . cells [ cell . cellIndex ] ; if ( ! hc . template ) { this . make _template ( hc ) ; }
2012-02-17 08:34:55 +00:00
hc . template . perm = this . field ? this . field . perm : hc . perm ; if ( hc . fieldname && hc . template . get _status ( ) == 'Write' ) { this . cell _deselect ( ) ; cell . div . style . border = '2px solid #88F' ; _f . cur _grid _cell = cell ; this . add _template ( cell ) ; } }
_f . Grid . prototype . add _template = function ( cell ) { if ( ! cell . row . docname && this . add _newrow ) { this . add _newrow ( ) ; this . cell _select ( cell ) ; } else { var hc = this . head _row . cells [ cell . cellIndex ] ; cell . div . innerHTML = '' ; cell . div . appendChild ( hc . template . wrapper ) ; hc . template . activate ( cell . row . docname ) ; hc . template . activated = 1 ; if ( hc . template . input && hc . template . input . set _width ) { hc . template . input . set _width ( $ ( cell ) . width ( ) ) ; } } }
2012-02-14 06:14:13 +00:00
_f . Grid . prototype . get _field = function ( fieldname ) { for ( var i = 0 ; i < this . head _row . cells . length ; i ++ ) { var hc = this . head _row . cells [ i ] ; if ( hc . fieldname == fieldname ) { if ( ! hc . template ) { this . make _template ( hc ) ; }
return hc . template ; } }
return { } }
_f . grid _date _cell = '' ; _f . grid _refresh _date = function ( ) { _f . grid _date _cell . grid . set _cell _value ( _f . grid _date _cell ) ; }
_f . grid _refresh _field = function ( temp , input ) { if ( input . value != _f . get _value ( temp . doctype , temp . docname , temp . df . fieldname ) )
if ( input . onchange ) input . onchange ( ) ; }
_f . Grid . prototype . remove _template = function ( cell ) { var hc = this . head _row . cells [ cell . cellIndex ] ; if ( ! hc . template ) return ; if ( ! hc . template . activated ) return ; if ( hc . template . txt ) { if ( hc . template . df . fieldtype == 'Date' ) { _f . grid _date _cell = cell ; setTimeout ( '_f.grid_refresh_date()' , 100 ) ; }
if ( hc . template . txt . value )
_f . grid _refresh _field ( hc . template , hc . template . txt ) ; } else if ( hc . template . input ) { _f . grid _refresh _field ( hc . template , hc . template . input ) ; }
if ( hc . template && hc . template . wrapper . parentNode )
2012-02-17 08:34:55 +00:00
cell . div . removeChild ( hc . template . wrapper ) ; this . set _cell _value ( cell ) ; hc . template . activated = 0 ; }
2012-02-14 06:14:13 +00:00
_f . Grid . prototype . notify _keypress = function ( e , keycode ) { if ( keycode >= 37 && keycode <= 40 && e . shiftKey ) { if ( text _dialog && text _dialog . display ) { return ; } } else
return ; if ( ! _f . cur _grid _cell ) return ; if ( _f . cur _grid _cell . grid != this ) return ; var ri = _f . cur _grid _cell . row . rowIndex ; var ci = _f . cur _grid _cell . cellIndex ; switch ( keycode ) { case 38 : if ( ri > 0 ) { this . cell _select ( '' , ri - 1 , ci ) ; } break ; case 40 : if ( ri < ( this . tab . rows . length - 1 ) ) { this . cell _select ( '' , ri + 1 , ci ) ; } break ; case 39 : if ( ci < ( this . head _row . cells . length - 1 ) ) { this . cell _select ( '' , ri , ci + 1 ) ; } break ; case 37 : if ( ci > 1 ) { this . cell _select ( '' , ri , ci - 1 ) ; } break ; } }
_f . Grid . prototype . make _template = function ( hc ) { hc . template = make _field ( get _field ( hc . doctype , hc . fieldname ) , hc . doctype , '' , this . field . frm , true ) ; hc . template . grid = this ; }
_f . Grid . prototype . append _rows = function ( n ) { for ( var i = 0 ; i < n ; i ++ ) this . append _row ( ) ; }
_f . Grid . prototype . truncate _rows = function ( n ) { for ( var i = 0 ; i < n ; i ++ ) this . tab . deleteRow ( this . tab . rows . length - 1 ) ; }
_f . Grid . prototype . set _data = function ( data ) { this . cell _deselect ( ) ; this . reset _table _width ( ) ; if ( data . length > this . tab . rows . length )
this . append _rows ( data . length - this . tab . rows . length ) ; if ( data . length < this . tab . rows . length )
this . truncate _rows ( this . tab . rows . length - data . length ) ; for ( var ridx = 0 ; ridx < data . length ; ridx ++ ) { this . refresh _row ( ridx , data [ ridx ] ) ; }
if ( this . can _add _rows && this . make _newrow ) { this . make _newrow ( ) ; }
if ( this . wrapper . onscroll ) this . wrapper . onscroll ( ) ; }
_f . Grid . prototype . set _ht = function ( ) { var max _ht = cint ( 0.37 * screen . width ) ; var ht = $ ( this . tab ) . height ( ) + $ ( this . head _tab ) . height ( ) + 30 ; if ( ht < 100 )
ht = 100 ; if ( ht > max _ht ) ht = max _ht ; ht += 4 ; $y ( this . wrapper , { height : ht + 'px' } ) ; }
_f . Grid . prototype . refresh _row = function ( ridx , docname ) { var row = this . tab . rows [ ridx ] ; row . docname = docname ; row . is _newrow = false ; for ( var cidx = 0 ; cidx < row . cells . length ; cidx ++ ) { this . set _cell _value ( row . cells [ cidx ] ) ; } }
/ *
* lib / js / legacy / widgets / form / form _grid . js
* /
_f . FormGrid = function ( field ) { this . field = field ; this . doctype = field . df . options ; if ( ! this . doctype ) { show _alert ( 'No Options for table ' + field . df . label ) ; }
this . col _break _width = cint ( this . field . col _break _width ) ; if ( ! this . col _break _width ) this . col _break _width = 100 ; $y ( field . parent , { marginTop : '8px' } ) ; this . init ( field . parent , field . df . width ) ; this . setup ( ) ; }
_f . FormGrid . prototype = new _f . Grid ( ) ; _f . FormGrid . prototype . setup = function ( ) { this . make _columns ( ) ; }
_f . FormGrid . prototype . make _tbar _link = function ( parent , label , fn , icon ) { var div = $a ( parent , 'div' , '' , { cursor : 'pointer' } ) ; var t = make _table ( div , 1 , 2 , '90%' , [ '20px' , null ] ) ; var img = $a ( $td ( t , 0 , 0 ) , 'div' , 'wn-icon ' + icon ) ; $y ( $td ( t , 0 , 0 ) , { textAlign : 'right' } ) ; var l = $a ( $td ( t , 0 , 1 ) , 'span' , 'link_type' , { color : '#333' } ) ; l . style . fontSize = '11px' ; l . innerHTML = label ; div . onclick = fn ; div . show = function ( ) { $ds ( this ) ; }
div . hide = function ( ) { $dh ( this ) ; }
$td ( t , 0 , 0 ) . isactive = 1 ; $td ( t , 0 , 1 ) . isactive = 1 ; l . isactive = 1 ; div . isactive = 1 ; img . isactive = 1 ; return div ; }
_f . FormGrid . prototype . make _buttons = function ( ) { var me = this ; this . tbar _btns = { } ; this . tbar _btns [ 'Del' ] = this . make _tbar _link ( $td ( this . tbar _tab , 0 , 0 ) , 'Del' , function ( ) { me . delete _row ( ) ; } , 'ic-round_minus' ) ; this . tbar _btns [ 'Ins' ] = this . make _tbar _link ( $td ( this . tbar _tab , 0 , 1 ) , 'Ins' , function ( ) { me . insert _row ( ) ; } , 'ic-round_plus' ) ; this . tbar _btns [ 'Up' ] = this . make _tbar _link ( $td ( this . tbar _tab , 0 , 2 ) , 'Up' , function ( ) { me . move _row ( true ) ; } , 'ic-arrow_top' ) ; this . tbar _btns [ 'Dn' ] = this . make _tbar _link ( $td ( this . tbar _tab , 0 , 3 ) , 'Dn' , function ( ) { me . move _row ( false ) ; } , 'ic-arrow_bottom' ) ; for ( var i in this . btns )
this . btns [ i ] . isactive = true ; }
_f . FormGrid . prototype . make _columns = function ( ) { var gl = fields _list [ this . field . df . options ] ; if ( ! gl ) { alert ( 'Table details not found "' + this . field . df . options + '"' ) ; }
gl . sort ( function ( a , b ) { return a . idx - b . idx } ) ; var p = this . field . perm ; for ( var i = 0 ; i < gl . length ; i ++ ) { if ( p [ this . field . df . permlevel ] && p [ this . field . df . permlevel ] [ READ ] ) { this . insert _column ( this . field . df . options , gl [ i ] . fieldname , gl [ i ] . fieldtype , gl [ i ] . label , gl [ i ] . width , gl [ i ] . options , this . field . perm , gl [ i ] . reqd ) ; if ( gl [ i ] . hidden ) { this . set _column _disp ( gl [ i ] . fieldname , false ) ; } } } }
_f . FormGrid . prototype . set _column _label = function ( fieldname , label ) { for ( var i = 0 ; i < this . head _row . cells . length ; i ++ ) { var c = this . head _row . cells [ i ] ; if ( c . fieldname == fieldname ) { c . innerHTML = '<div class="grid_head_div">' + label + '</div>' ; c . cur _label = label ; break ; } } }
_f . FormGrid . prototype . refresh = function ( ) { var docset = getchildren ( this . doctype , this . field . frm . docname , this . field . df . fieldname , this . field . frm . doctype ) ; var data = [ ] ; for ( var i = 0 ; i < docset . length ; i ++ ) { locals [ this . doctype ] [ docset [ i ] . name ] . idx = i + 1 ; data [ data . length ] = docset [ i ] . name ; }
this . set _data ( data ) ; }
_f . FormGrid . prototype . set _unsaved = function ( ) { locals [ cur _frm . doctype ] [ cur _frm . docname ] . _ _unsaved = 1 ; cur _frm . set _heading ( ) ; }
_f . FormGrid . prototype . insert _row = function ( ) { var d = this . new _row _doc ( ) ; var ci = _f . cur _grid _cell . cellIndex ; var row _idx = _f . cur _grid _cell . row . rowIndex ; d . idx = row _idx + 1 ; for ( var ri = row _idx ; ri < this . tab . rows . length ; ri ++ ) { var r = this . tab . rows [ ri ] ; if ( r . docname )
locals [ this . doctype ] [ r . docname ] . idx ++ ; }
this . refresh ( ) ; this . cell _select ( '' , row _idx , ci ) ; this . set _unsaved ( ) ; }
_f . FormGrid . prototype . new _row _doc = function ( ) { var n = LocalDB . create ( this . doctype ) ; var d = locals [ this . doctype ] [ n ] ; d . parent = this . field . frm . docname ; d . parentfield = this . field . df . fieldname ; d . parenttype = this . field . frm . doctype ; return d ; }
_f . FormGrid . prototype . add _newrow = function ( ) { var r = this . tab . rows [ this . tab . rows . length - 1 ] ; if ( ! r . is _newrow )
show _alert ( 'fn: add_newrow: Adding a row which is not flagged as new' ) ; var d = this . new _row _doc ( ) ; d . idx = r . rowIndex + 1 ; r . docname = d . name ; r . is _newrow = false ; this . set _cell _value ( r . cells [ 0 ] ) ; this . make _newrow ( ) ; this . refresh _row ( r . rowIndex , d . name ) ; if ( this . onrowadd ) this . onrowadd ( cur _frm . doc , d . doctype , d . name ) ; return d . name ; }
_f . FormGrid . prototype . make _newrow = function ( from _add _btn ) { if ( ! this . can _add _rows )
return ; if ( this . tab . rows . length ) { var r = this . tab . rows [ this . tab . rows . length - 1 ] ; if ( r . is _newrow )
return ; }
var r = this . append _row ( ) ; r . cells [ 0 ] . div . innerHTML = '<b style="font-size: 18px;">*</b>' ; r . is _newrow = true ; }
_f . FormGrid . prototype . check _selected = function ( ) { if ( ! _f . cur _grid _cell ) { show _alert ( 'Select a cell first' ) ; return false ; }
if ( _f . cur _grid _cell . grid != this ) { show _alert ( 'Select a cell first' ) ; return false ; }
return true ; }
_f . FormGrid . prototype . delete _row = function ( dt , dn ) { if ( dt && dn ) { LocalDB . delete _record ( dt , dn ) ; this . refresh ( ) ; } else { if ( ! this . check _selected ( ) ) return ; var r = _f . cur _grid _cell . row ; if ( r . is _newrow ) return ; var ci = _f . cur _grid _cell . cellIndex ; var ri = _f . cur _grid _cell . row . rowIndex ; LocalDB . delete _record ( this . doctype , r . docname ) ; this . refresh ( ) ; if ( ri < ( this . tab . rows . length - 2 ) )
this . cell _select ( null , ri , ci ) ; else _f . cur _grid _cell = null ; }
this . set _unsaved ( ) ; }
_f . FormGrid . prototype . move _row = function ( up ) { if ( ! this . check _selected ( ) ) return ; var r = _f . cur _grid _cell . row ; if ( r . is _newrow ) return ; if ( up && r . rowIndex > 0 ) { var swap _row = this . tab . rows [ r . rowIndex - 1 ] ; } else if ( ! up ) { var len = this . tab . rows . length ; if ( this . tab . rows [ len - 1 ] . is _newrow )
len = len - 1 ; if ( r . rowIndex < ( len - 1 ) )
var swap _row = this . tab . rows [ r . rowIndex + 1 ] ; }
if ( swap _row ) { var cidx = _f . cur _grid _cell . cellIndex ; this . cell _deselect ( ) ; var aidx = locals [ this . doctype ] [ r . docname ] . idx ; locals [ this . doctype ] [ r . docname ] . idx = locals [ this . doctype ] [ swap _row . docname ] . idx ; locals [ this . doctype ] [ swap _row . docname ] . idx = aidx ; var adocname = swap _row . docname ; this . refresh _row ( swap _row . rowIndex , r . docname ) ; this . refresh _row ( r . rowIndex , adocname ) ; this . cell _select ( this . tab . rows [ swap _row . rowIndex ] . cells [ cidx ] ) ; this . set _unsaved ( ) ; } }
/ *
* lib / js / legacy / widgets / form / print _format . js
* /
$ . extend ( _p , { show _dialog : function ( ) { if ( ! _p . dialog ) { _p . make _dialog ( ) ; }
_p . dialog . show ( ) ; } , make _dialog : function ( ) { var d = new Dialog ( 360 , 140 , 'Print Formats' , [ [ 'HTML' , 'Select' ] , [ 'Check' , 'No Letterhead' ] , [ 'HTML' , 'Buttons' ] ] ) ; $btn ( d . widgets . Buttons , 'Print' , function ( ) { _p . build ( sel _val ( cur _frm . print _sel ) , _p . go , d . widgets [ 'No Letterhead' ] . checked ) ; } , { cssFloat : 'right' , marginBottom : '16px' , marginLeft : '7px' } , 'green' ) ; $btn ( d . widgets . Buttons , 'Preview' , function ( ) { _p . build ( sel _val ( cur _frm . print _sel ) , _p . preview , d . widgets [ 'No Letterhead' ] . checked ) ; } , { cssFloat : 'right' , marginBottom : '16px' } , '' ) ; d . onshow = function ( ) { var c = _p . dialog . widgets [ 'Select' ] ; if ( c . cur _sel && c . cur _sel . parentNode == c ) { c . removeChild ( c . cur _sel ) ; }
c . appendChild ( cur _frm . print _sel ) ; c . cur _sel = cur _frm . print _sel ; }
_p . dialog = d ; } , formats : { } , build : function ( fmtname , onload , no _letterhead , only _body ) { args = { fmtname : fmtname , onload : onload , no _letterhead : no _letterhead , only _body : only _body } ; if ( ! cur _frm ) { alert ( 'No Document Selected' ) ; return ; }
var doc = locals [ cur _frm . doctype ] [ cur _frm . docname ] ; if ( args . fmtname == 'Standard' ) { args . onload ( _p . render ( { body : _p . print _std ( args . no _letterhead ) , style : _p . print _style , doc : doc , title : doc . name , no _letterhead : args . no _letterhead , only _body : args . only _body } ) ) ; } else { if ( ! _p . formats [ args . fmtname ] ) { var build _args = args ; $c ( command = 'webnotes.widgets.form.print_format.get' , args = { 'name' : build _args . fmtname } , fn = function ( r , rt ) { _p . formats [ build _args . fmtname ] = r . message ; build _args . onload ( _p . render ( { body : _p . formats [ build _args . fmtname ] , style : '' , doc : doc , title : doc . name , no _letterhead : build _args . no _letterhead , only _body : build _args . only _body } ) ) ; } ) ; } else { args . onload ( _p . render ( { body : _p . formats [ args . fmtname ] , style : '' , doc : doc , title : doc . name , no _letterhead : args . no _letterhead , only _body : args . only _body } ) ) ; } } } , render : function ( args ) { var container = document . createElement ( 'div' ) ; var stat = '' ; stat += _p . show _draft ( args ) ; stat += _p . show _archived ( args ) ; stat += _p . show _cancelled ( args ) ; container . innerHTML = args . body ; _p . show _letterhead ( container , args ) ; _p . run _embedded _js ( container , args . doc ) ; var style = _p . consolidate _css ( container , args ) ; _p . render _header _on _break ( container , args ) ; return _p . render _final ( style , stat , container , args ) ; } , head _banner _format : function ( ) { return " \
< div style = ' \
text - align : center ; \
padding : 8 px ; \
background - color : # CCC ; ' > \
< div style = ' \
font - size : 20 px ; \
font - weight : bold ; ' > \
{ { HEAD } } \
< / d i v > \
{ { DESCRIPTION } } \
< / d i v > " } , s h o w _ d r a f t : f u n c t i o n ( a r g s ) { v a r i s _ d o c t y p e _ s u b m i t t a b l e = 0 ; v a r p l i s t = l o c a l s [ ' D o c P e r m ' ] ; f o r ( v a r p e r m i n p l i s t ) { v a r p = p l i s t [ p e r m ] ; i f ( ( p . p a r e n t = = a r g s . d o c . d o c t y p e ) & & ( p . s u b m i t = = 1 ) ) { i s _ d o c t y p e _ s u b m i t t a b l e = 1 ; b r e a k ; } }
if ( args . doc && cint ( args . doc . docstatus ) == 0 && is _doctype _submittable ) { draft = _p . head _banner _format ( ) ; draft = draft . replace ( "{{HEAD}}" , "DRAFT" ) ; draft = draft . replace ( "{{DESCRIPTION}}" , "This box will go away after the document is submitted." ) ; return draft ; } else { return "" ; } } , show _archived : function ( args ) { if ( args . doc && args . doc . _ _archived ) { archived = _p . head _banner _format ( ) ; archived = archived . replace ( "{{HEAD}}" , "ARCHIVED" ) ; archived = archived . replace ( "{{DESCRIPTION}}" , "You must restore this document to make it editable." ) ; return archived ; } else { return "" ; } } , show _cancelled : function ( args ) { if ( args . doc && args . doc . docstatus == 2 ) { cancelled = _p . head _banner _format ( ) ; cancelled = cancelled . replace ( "{{HEAD}}" , "CANCELLED" ) ; cancelled = cancelled . replace ( "{{DESCRIPTION}}" , "You must amend this document to make it editable." ) ; return cancelled ; } else { return "" ; } } , consolidate _css : function ( container , args ) { var body _style = '' ; var style _list = container . getElementsByTagName ( 'style' ) ; while ( style _list && style _list . length > 0 ) { for ( i in style _list ) { if ( style _list [ i ] && style _list [ i ] . innerHTML ) { body _style += style _list [ i ] . innerHTML ; var parent = style _list [ i ] . parentNode ; if ( parent ) { parent . removeChild ( style _list [ i ] ) ; } else { container . removeChild ( style _list [ i ] ) ; } } }
style _list = container . getElementsByTagName ( 'style' ) ; }
style _concat = ( args . only _body ? '' : _p . def _print _style _body )
+ _p . def _print _style _other + args . style + body _style ; return style _concat ; } , run _embedded _js : function ( container , doc ) { var jslist = container . getElementsByTagName ( 'script' ) ; while ( jslist && jslist . length > 0 ) { for ( i in jslist ) { if ( jslist [ i ] && jslist [ i ] . innerHTML ) { var code = jslist [ i ] . innerHTML ; var parent = jslist [ i ] . parentNode ; var span = $a ( parent , 'span' ) ; parent . replaceChild ( span , jslist [ i ] ) ; var val = code ? eval ( code ) : '' ; if ( ! val || typeof ( val ) == 'object' ) { val = '' ; }
span . innerHTML = val ; } }
jslist = container . getElementsByTagName ( 'script' ) ; } } , show _letterhead : function ( container , args ) { if ( ! ( args . no _letterhead || args . only _body ) ) { container . innerHTML = '<div>' + _p . get _letter _head ( ) + '</div>'
+ container . innerHTML ; } } , render _header _on _break : function ( container , args ) { var page _set = container . getElementsByClassName ( 'page-settings' ) ; if ( page _set . length ) { for ( var i = 0 ; i < page _set . length ; i ++ ) { var tmp = '' ; tmp += _p . show _draft ( args ) ; tmp += _p . show _archived ( args ) ; _p . show _letterhead ( page _set [ i ] , args ) ; page _set [ i ] . innerHTML = tmp + page _set [ i ] . innerHTML ; } } } , render _final : function ( style , stat , container , args ) { var header = '<div class="page-settings">\n' ; var footer = '\n</div>' ; if ( ! args . only _body ) { header = ' < ! DOCTYPE html > \ n \
< html > \
< head > \
< title > '+args.title+' < / t i t l e > \
< style > '+style+' < / s t y l e > \
< / h e a d > \
< body > \ n '+header;footer=footer+' \ n < / b o d y > \ n \
< / h t m l > ' ; }
var finished = header
+ stat
+ container . innerHTML . replace ( /<div/g , '\n<div' ) . replace ( /<td/g , '\n<td' )
+ footer ; return finished ; } , get _letter _head : function ( ) { var cp = wn . control _panel ; var lh = '' ; if ( cur _frm . doc . letter _head ) { lh = cstr ( _p . letter _heads [ cur _frm . doc . letter _head ] ) ; } else if ( cp . letter _head ) { lh = cp . letter _head ; }
return lh ; } , print _style : " \
. datalabelcell { \
padding : 2 px 0 px ; \
width : 38 % ; \
vertical - align : top ; \
} \
. datainputcell { \
padding : 2 px 0 px ; \
width : 62 % ; \
text - align : left ; \
} \
. sectionHeading { \
font - size : 16 px ; \
font - weight : bold ; \
margin : 8 px 0 px ; \
} \
. columnHeading { \
font - size : 14 px ; \
font - weight : bold ; \
margin : 8 px 0 px ; \
} " , print _std : function ( no _letterhead ) { var docname = cur _frm . docname ; var doctype = cur _frm . doctype ; var data = getchildren ( 'DocField' , doctype , 'fields' , 'DocType' ) ; var layout = _p . add _layout ( doctype ) ; this . pf _list = [ layout ] ; var me = this ; me . layout = layout ; $ . extend ( this , { build _head : function ( doctype , docname ) { var h1 _style = { fontSize : '22px' , marginBottom : '8px' }
var h1 = $a ( me . layout . cur _row . header , 'h1' , '' , h1 _style ) ; h1 . innerHTML = cur _frm . pformat [ docname ] ? cur _frm . pformat [ docname ] : get _doctype _label ( doctype ) ; var h2 _style = { fontSize : '16px' , color : '#888' , marginBottom : '8px' , paddingBottom : '8px' , borderBottom : ( me . layout . with _border ? '0px' : '1px solid #000' ) }
var h2 = $a ( me . layout . cur _row . header , 'div' , '' , h2 _style ) ; h2 . innerHTML = docname ; } , build _data : function ( data , doctype , docname ) { if ( data [ 0 ] && data [ 0 ] . fieldtype != "Section Break" ) { me . layout . addrow ( ) ; if ( data [ 0 ] . fieldtype != "Column Break" ) { me . layout . addcell ( ) ; } }
$ . extend ( this , { generate _custom _html : function ( field , doctype , docname ) { var container = $a ( me . layout . cur _cell , 'div' ) ; container . innerHTML = cur _frm . pformat [ field . fieldname ] ( locals [ doctype ] [ docname ] ) ; } , render _normal : function ( field , data , i ) { switch ( field . fieldtype ) { case 'Section Break' : me . layout . addrow ( ) ; if ( data [ i + 1 ] && data [ i + 1 ] . fieldtype != 'Column Break' ) { me . layout . addcell ( ) ; }
break ; case 'Column Break' : me . layout . addcell ( field . width , field . label ) ; break ; case 'Table' : var table = print _table ( doctype , docname , field . fieldname , field . options , null , null , null , null ) ; me . layout = _p . print _std _add _table ( table , me . layout , me . pf _list , doctype , no _letterhead ) ; break ; case 'HTML' : var div = $a ( me . layout . cur _cell , 'div' ) ; div . innerHTML = field . options ; break ; case 'Code' : var div = $a ( me . layout . cur _cell , 'div' ) ; var val = _f . get _value ( doctype , docname , field . fieldname ) ; div . innerHTML = '<div>' + field . label + ': </div><pre style="font-family: Courier, Fixed;">' + ( val ? val : '' ) + '</pre>' ; break ; case 'Text Editor' : var div = $a ( me . layout . cur _cell , 'div' ) ; var val = _f . get _value ( doctype , docname , field . fieldname ) ; div . innerHTML = val ? val : '' ; break ; default : _p . print _std _add _field ( doctype , docname , field , me . layout ) ; break ; } } } ) ; for ( var i = 0 ; i < data . length ; i ++ ) { var fieldname = data [ i ] . fieldname ? data [ i ] . fieldname : data [ i ] . label ; var field = fieldname ? get _field ( doctype , fieldname , docname ) : data [ i ] ; if ( ! field . print _hide ) { if ( cur _frm . pformat [ field . fieldname ] ) { this . generate _custom _html ( field , doctype , docname ) ; } else { this . render _normal ( field , data , i ) ; } } }
me . layout . close _borders ( ) ; } , build _html : function ( ) { var html = '' ; for ( var i = 0 ; i < me . pf _list . length ; i ++ ) { if ( me . pf _list [ i ] . wrapper ) { html += me . pf _list [ i ] . wrapper . innerHTML ; } else if ( me . pf _list [ i ] . innerHTML ) { html += me . pf _list [ i ] . innerHTML ; } else { html += me . pf _list [ i ] ; } }
this . pf _list = [ ] ; return html ; } } ) ; this . build _head ( doctype , docname ) ; this . build _data ( data , doctype , docname ) ; var html = this . build _html ( ) ; return html ; } , add _layout : function ( doctype ) { var layout = new Layout ( ) ; layout . addrow ( ) ; if ( locals [ 'DocType' ] [ doctype ] . print _outline == 'Yes' ) { layout . with _border = 1 }
return layout ; } , print _std _add _table : function ( t , layout , pf _list , dt , no _letterhead ) { if ( t . appendChild ) { layout . cur _cell . appendChild ( t ) ; } else { page _break = ' \ n \
< div style = "page-break-after: always;" \
class = "page_break" > < / d i v > < d i v c l a s s = " p a g e - s e t t i n g s " > < / d i v > ' ; f o r ( v a r i = 0 ; i < t . l e n g t h - 1 ; i + + ) { l a y o u t . c u r _ c e l l . a p p e n d C h i l d ( t [ i ] ) ; l a y o u t . c l o s e _ b o r d e r s ( ) ; p f _ l i s t . p u s h ( p a g e _ b r e a k ) ; l a y o u t = _ p . a d d _ l a y o u t ( d t , n o _ l e t t e r h e a d ) ; p f _ l i s t . p u s h ( l a y o u t ) ; l a y o u t . a d d r o w ( ) ; l a y o u t . a d d c e l l ( ) ; v a r d i v = $ a ( l a y o u t . c u r _ c e l l , ' d i v ' ) ; d i v . i n n e r H T M L = ' C o n t i n u e d f r o m p r e v i o u s p a g e . . . ' ; d i v . s t y l e . p a d d i n g = ' 4 p x ' ; }
layout . cur _cell . appendChild ( t [ t . length - 1 ] ) ; }
return layout ; } , print _std _add _field : function ( dt , dn , f , layout ) { var val = _f . get _value ( dt , dn , f . fieldname ) ; if ( f . fieldtype != 'Button' ) { if ( val || in _list ( [ 'Float' , 'Int' , 'Currency' ] , f . fieldtype ) ) { row = _p . field _tab ( layout . cur _cell ) ; row . cells [ 0 ] . innerHTML = f . label ? f . label : f . fieldname ; $s ( row . cells [ 1 ] , val , f . fieldtype ) ; if ( f . fieldtype == 'Currency' ) { $y ( row . cells [ 1 ] , { textAlign : 'left' } ) ; } } } } , field _tab : function ( layout _cell ) { var tab = $a ( layout _cell , 'table' , '' , { width : '100%' } ) ; var row = tab . insertRow ( 0 ) ; _p . row = row ; row . insertCell ( 0 ) ; row . insertCell ( 1 ) ; row . cells [ 0 ] . className = 'datalabelcell' ; row . cells [ 1 ] . className = 'datainputcell' ; return row ; } } ) ; print _table = function ( dt , dn , fieldname , tabletype , cols , head _labels , widths , condition , cssClass , modifier , hide _empty ) { var me = this ; $ . extend ( this , { flist : ( function ( ) { var f _list = [ ] ; var fl = fields _list [ tabletype ] ; if ( fl ) { for ( var i = 0 ; i < fl . length ; i ++ ) { f _list . push ( copy _dict ( fl [ i ] ) ) ; } }
return f _list ; } ) ( ) , data : function ( ) { var children = getchildren ( tabletype , dn , fieldname , dt ) ; var data = [ ]
for ( var i = 0 ; i < children . length ; i ++ ) { data . push ( copy _dict ( children [ i ] ) ) ; }
return data ; } ( ) , cell _style : { border : '1px solid #000' , padding : '2px' , verticalAlign : 'top' } , head _cell _style : { border : '1px solid #000' , padding : '2px' , verticalAlign : 'top' , backgroundColor : '#ddd' , fontWeight : 'bold' } , table _style : { width : '100%' , borderCollapse : 'collapse' , marginBottom : '10px' } , remove _empty _cols : function ( flist ) { var non _empty _cols = [ ]
for ( var i = 0 ; i < me . data . length ; i ++ ) { for ( var c = 0 ; c < flist . length ; c ++ ) { if ( flist [ c ] . print _hide || ! inList ( [ '' , null ] , me . data [ i ] [ flist [ c ] . fieldname ] ) ) { if ( ! inList ( non _empty _cols , flist [ c ] ) ) { non _empty _cols . push ( flist [ c ] ) ; } } } }
for ( var c = 0 ; c < flist . length ; c ++ ) { if ( ! inList ( non _empty _cols , flist [ c ] ) ) { flist . splice ( c , 1 ) ; c = c - 1 ; } } } , prepare _col _heads : function ( flist ) { var new _flist = [ ] ; if ( ! cols || ( cols && cols . length && hide _empty ) ) { me . remove _empty _cols ( flist ) ; }
if ( cols && cols . length ) { if ( cols [ 0 ] == 'SR' ) { new _flist . push ( 'SR' ) }
for ( var i = 0 ; i < cols . length ; i ++ ) { for ( var j = 0 ; j < flist . length ; j ++ ) { if ( flist [ j ] . fieldname == cols [ i ] ) { new _flist . push ( flist [ j ] ) ; break ; } } } } else { new _flist . push ( 'SR' ) ; for ( var i = 0 ; i < flist . length ; i ++ ) { if ( ! flist [ i ] . print _hide ) { new _flist . push ( flist [ i ] ) ; } } }
me . flist = new _flist ; } , make _print _table : function ( flist ) { var wrapper = document . createElement ( 'div' ) ; var table = $a ( wrapper , 'table' , '' , me . table _style ) ; table . wrapper = wrapper ; table . insertRow ( 0 ) ; var col _start = 0 ; if ( flist [ 0 ] == 'SR' ) { var cell = table . rows [ 0 ] . insertCell ( 0 ) ; cell . innerHTML = head _labels ? head _labels [ 0 ] : '<b>SR</b>' ; $y ( cell , { width : '30px' } ) ; $y ( cell , me . head _cell _style ) ; col _start ++ ; }
for ( var c = col _start ; c < flist . length ; c ++ ) { var cell = table . rows [ 0 ] . insertCell ( c ) ; $y ( cell , me . head _cell _style ) ; cell . innerHTML = head _labels ? head _labels [ c ] : flist [ c ] . label ; if ( flist [ c ] . width ) { $y ( cell , { width : flist [ c ] . width } ) ; }
if ( widths ) { $y ( cell , { width : widths [ c ] } ) ; }
if ( in _list ( [ 'Currency' , 'Float' ] , flist [ c ] . fieldtype ) ) { $y ( cell , { textAlign : 'right' } ) ; } }
return table ; } , populate _table : function ( table , data ) { for ( var r = 0 ; r < data . length ; r ++ ) { if ( ( ! condition ) || ( condition ( data [ r ] ) ) ) { if ( data [ r ] . page _break ) { table = me . make _print _table ( me . flist ) ; me . table _list . push ( table . wrapper ) ; }
var row = table . insertRow ( table . rows . length ) ; if ( me . flist [ 0 ] == 'SR' ) { var cell = row . insertCell ( 0 ) ; cell . innerHTML = r + 1 ; $y ( cell , me . cell _style ) ; }
for ( var c = me . flist . indexOf ( 'SR' ) + 1 ; c < me . flist . length ; c ++ ) { var cell = row . insertCell ( c ) ; $y ( cell , me . cell _style ) ; if ( modifier && me . flist [ c ] . fieldname in modifier ) { data [ r ] [ me . flist [ c ] . fieldname ] = modifier [ me . flist [ c ] . fieldname ] ( data [ r ] ) ; }
$s ( cell , data [ r ] [ me . flist [ c ] . fieldname ] , me . flist [ c ] . fieldtype ) ; if ( in _list ( [ 'Currency' , 'Float' ] , me . flist [ c ] . fieldtype ) ) { cell . style . textAlign = 'right' ; } } } } } } ) ; if ( ! this . data . length ) { return document . createElement ( 'div' ) ; }
this . prepare _col _heads ( this . flist ) ; var table = me . make _print _table ( this . flist ) ; this . table _list = [ table . wrapper ] ; this . populate _table ( table , this . data ) ; return ( me . table _list . length > 1 ) ? me . table _list : me . table _list [ 0 ] ; }
/ *
* lib / js / legacy / widgets / form / email . js
* /
_e . email _as _field = 'email_id' ; _e . email _as _dt = 'Contact' ; _e . email _as _in = 'email_id,contact_name' ; sendmail = function ( emailto , emailfrom , cc , subject , message , fmt , with _attachments ) { var fn = function ( html ) { $c ( 'webnotes.utils.email_lib.send_form' , { 'sendto' : emailto , 'sendfrom' : emailfrom ? emailfrom : '' , 'cc' : cc ? cc : '' , 'subject' : subject , 'message' : replace _newlines ( message ) , 'body' : html , 'full_domain' : wn . urllib . get _base _url ( ) , 'with_attachments' : with _attachments ? 1 : 0 , 'dt' : cur _frm . doctype , 'dn' : cur _frm . docname } , function ( r , rtxt ) { } ) ; }
_p . build ( fmt , fn ) ; }
_e . make = function ( ) { var d = new Dialog ( 440 , 440 , "Send Email" ) ; var email _go = function ( ) { var emailfrom = d . widgets [ 'From' ] . value ; var emailto = d . widgets [ 'To' ] . value ; if ( ! emailfrom )
emailfrom = user _email ; var email _list = emailto . split ( /[,|;]/ ) ; var valid = 1 ; for ( var i = 0 ; i < email _list . length ; i ++ ) { if ( ! validate _email ( email _list [ i ] ) ) { msgprint ( 'error:' + email _list [ i ] + ' is not a valid email id' ) ; valid = 0 ; } }
if ( emailfrom && ! validate _email ( emailfrom ) ) { msgprint ( 'error:' + emailfrom + ' is not a valid email id. To change the default please click on Profile on the top right of the screen and change it.' ) ; return ; }
if ( ! valid ) return ; var cc = emailfrom ; if ( ! emailfrom ) { emailfrom = wn . control _panel . auto _email _id ; cc = '' ; }
sendmail ( emailto , emailfrom , emailfrom , d . widgets [ 'Subject' ] . value , d . widgets [ 'Message' ] . value , sel _val ( cur _frm . print _sel ) , d . widgets [ 'Send With Attachments' ] . checked ) ; _e . dialog . hide ( ) ; }
d . onhide = function ( ) { hide _autosuggest ( ) ; }
d . make _body ( [ [ 'Data' , 'To' , 'Example: abc@hotmail.com, xyz@yahoo.com' ] , [ 'Select' , 'Format' ] , [ 'Data' , 'Subject' ] , [ 'Data' , 'From' , 'Optional' ] , [ 'Check' , 'Send With Attachments' , 'Will send all attached documents (if any)' ] , [ 'Text' , 'Message' ] , [ 'Button' , 'Send' , email _go ] ] ) ; d . widgets [ 'From' ] . value = ( user _email ? user _email : '' ) ; $td ( d . rows [ 'Format' ] . tab , 0 , 1 ) . cur _sel = d . widgets [ 'Format' ] ; var opts = { script : '' , json : true , maxresults : 10 } ; wn . require ( 'lib/js/legacy/widgets/autosuggest.js' ) ; var as = new AutoSuggest ( d . widgets [ 'To' ] , opts ) ; as . custom _select = function ( txt , sel ) { var r = '' ; var tl = txt . split ( ',' ) ; for ( var i = 0 ; i < tl . length - 1 ; i ++ ) r = r + tl [ i ] + ',' ; r = r + ( r ? ' ' : '' ) + sel ; if ( r [ r . length - 1 ] == NEWLINE ) r = substr ( 0 , r . length - 1 ) ; return r ; }
var emailto = d . widgets [ 'To' ]
as . set _input _value = function ( new _txt ) { if ( emailto . value && emailto . value . indexOf ( ',' ) != - 1 ) { var txt = emailto . value . split ( ',' ) ; txt . splice ( txt . length - 1 , 1 , new _txt ) ; for ( var i = 0 ; i < txt . length - 1 ; i ++ ) txt [ i ] = strip ( txt [ i ] ) ; emailto . value = txt . join ( ', ' ) ; } else { emailto . value = new _txt ; } }
as . doAjaxRequest = function ( txt ) { var pointer = as ; var q = '' ; var last _txt = txt . split ( ',' ) ; last _txt = last _txt [ last _txt . length - 1 ] ; var call _back = function ( r , rt ) { as . aSug = [ ] ; if ( ! r . cl ) return ; for ( var i = 0 ; i < r . cl . length ; i ++ ) { as . aSug . push ( { 'id' : r . cl [ i ] , 'value' : r . cl [ i ] , 'info' : '' } ) ; }
as . createList ( as . aSug ) ; }
$c ( 'webnotes.utils.email_lib.get_contact_list' , { 'select' : _e . email _as _field , 'from' : _e . email _as _dt , 'where' : _e . email _as _in , 'txt' : ( last _txt ? strip ( last _txt ) : '%' ) } , call _back ) ; return ; }
var sel ; _e . dialog = d ; }
/ *
* lib / js / legacy / widgets / form / clientscriptAPI . js
* /
$c _get _values = function ( args , doc , dt , dn , user _callback ) { var call _back = function ( r , rt ) { if ( ! r . message ) return ; if ( user _callback ) user _callback ( r . message ) ; var fl = args . fields . split ( ',' ) ; for ( var i in fl ) { locals [ dt ] [ dn ] [ fl [ i ] ] = r . message [ fl [ i ] ] ; if ( args . table _field )
refresh _field ( fl [ i ] , dn , args . table _field ) ; else
refresh _field ( fl [ i ] ) ; } }
$c ( 'webnotes.widgets.form.utils.get_fields' , args , call _back ) ; }
get _server _fields = function ( method , arg , table _field , doc , dt , dn , allow _edit , call _back ) { if ( ! allow _edit ) freeze ( 'Fetching Data...' ) ; $c ( 'runserverobj' , args = { 'method' : method , 'docs' : compress _doclist ( [ doc ] ) , 'arg' : arg } , function ( r , rt ) { if ( r . message ) { var d = locals [ dt ] [ dn ] ; var field _dict = r . message ; for ( var key in field _dict ) { d [ key ] = field _dict [ key ] ; if ( table _field ) refresh _field ( key , d . name , table _field ) ; else refresh _field ( key ) ; } }
if ( call _back ) { doc = locals [ doc . doctype ] [ doc . name ] ; call _back ( doc , dt , dn ) ; }
if ( ! allow _edit ) unfreeze ( ) ; } ) ; }
set _multiple = function ( dt , dn , dict , table _field ) { var d = locals [ dt ] [ dn ] ; for ( var key in dict ) { d [ key ] = dict [ key ] ; if ( table _field ) refresh _field ( key , d . name , table _field ) ; else refresh _field ( key ) ; } }
refresh _many = function ( flist , dn , table _field ) { for ( var i in flist ) { if ( table _field ) refresh _field ( flist [ i ] , dn , table _field ) ; else refresh _field ( flist [ i ] ) ; } }
set _field _tip = function ( n , txt ) { var df = get _field ( cur _frm . doctype , n , cur _frm . docname ) ; if ( df ) df . description = txt ; if ( cur _frm && cur _frm . fields _dict ) { if ( cur _frm . fields _dict [ n ] )
cur _frm . fields _dict [ n ] . comment _area . innerHTML = replace _newlines ( txt ) ; else
errprint ( '[set_field_tip] Unable to set field tip: ' + n ) ; } }
refresh _field = function ( n , docname , table _field ) { if ( typeof n == typeof [ ] ) refresh _many ( n , docname , table _field ) ; if ( table _field ) { if ( _f . frm _dialog && _f . frm _dialog . display ) { if ( _f . frm _dialog . cur _frm . fields _dict [ n ] && _f . frm _dialog . cur _frm . fields _dict [ n ] . refresh )
_f . frm _dialog . cur _frm . fields _dict [ n ] . refresh ( ) ; } else { var g = _f . cur _grid _cell ; if ( g ) var hc = g . grid . head _row . cells [ g . cellIndex ] ; if ( g && hc && hc . fieldname == n && g . row . docname == docname ) { hc . template . refresh ( ) ; } else { cur _frm . fields _dict [ table _field ] . grid . refresh _cell ( docname , n ) ; } } } else if ( cur _frm && cur _frm . fields _dict ) { if ( cur _frm . fields _dict [ n ] && cur _frm . fields _dict [ n ] . refresh )
cur _frm . fields _dict [ n ] . refresh ( ) ; } }
set _field _options = function ( n , txt ) { var df = get _field ( cur _frm . doctype , n , cur _frm . docname ) ; if ( df ) df . options = txt ; refresh _field ( n ) ; }
set _field _permlevel = function ( n , level ) { var df = get _field ( cur _frm . doctype , n , cur _frm . docname ) ; if ( df ) df . permlevel = level ; refresh _field ( n ) ; }
hide _field = function ( n ) { function _hide _field ( n , hidden ) { var df = get _field ( cur _frm . doctype , n , cur _frm . docname ) ; if ( df ) df . hidden = hidden ; refresh _field ( n ) ; }
if ( cur _frm ) { if ( n . substr ) _hide _field ( n , 1 ) ; else { for ( var i in n ) _hide _field ( n [ i ] , 1 ) } } }
unhide _field = function ( n ) { function _hide _field ( n , hidden ) { var df = get _field ( cur _frm . doctype , n , cur _frm . docname ) ; if ( df ) df . hidden = hidden ; refresh _field ( n ) ; }
if ( cur _frm ) { if ( n . substr ) _hide _field ( n , 0 ) ; else { for ( var i in n ) _hide _field ( n [ i ] , 0 ) } } }
get _field _obj = function ( fn ) { return cur _frm . fields _dict [ fn ] ; }
/ *
* lib / js / legacy / widgets / form / form _comments . js
* /
wn . widgets . form . comments = { n _comments : { } , comment _list : { } , sync : function ( dt , dn , r ) { var f = wn . widgets . form . comments ; f . n _comments [ dn ] = r . n _comments ; f . comment _list [ dn ] = r . comment _list ; } , add : function ( input , dt , dn , callback ) { $c ( 'webnotes.widgets.form.comments.add_comment' , wn . widgets . form . comments . get _args ( input , dt , dn ) , function ( r , rt ) { wn . widgets . form . comments . update _comment _list ( input , dt , dn ) ; input . value = '' ; callback ( input , dt , dn ) ; } ) ; } , remove : function ( dt , dn , comment _id , callback ) { $c ( 'webnotes.widgets.form.comments.remove_comment' , { id : comment _id , dt : dt , dn : dn } , callback ) ; } , get _args : function ( input , dt , dn ) { return { comment : input . value , comment _by : user , comment _by _fullname : user _fullname , comment _doctype : dt , comment _docname : dn } } , update _comment _list : function ( input , dt , dn ) { var f = wn . widgets . form . comments ; f . n _comments [ dn ] = cint ( f . n _comments [ dn ] ) + 1 ; f . comment _list [ dn ] = add _lists ( [ f . get _args ( input , dt , dn ) ] , f . comment _list [ dn ] ) ; } }
CommentList = function ( parent , dt , dn ) { this . wrapper = $a ( parent , 'div' , '' , { margin : '16px' } ) ; this . input _area = $a ( this . wrapper , 'div' , '' , { margin : '2px' } ) ; this . lst _area = $a ( this . wrapper , 'div' , '' , { margin : '2px' } ) ; this . make _input ( ) ; this . make _lst ( ) ; this . dt ; this . dn ; }
CommentList . prototype . run = function ( ) { this . lst . run ( ) ; }
CommentList . prototype . make _input = function ( ) { var me = this ; this . input = $a ( this . input _area , 'textarea' , '' , { height : '60px' , width : '300px' , fontSize : '14px' } ) ; this . btn = $btn ( $a ( this . input _area , 'div' ) , 'Post' , function ( ) { me . add _comment ( ) ; } , { marginTop : '8px' } ) ; }
CommentList . prototype . add _comment = function ( ) { var me = this ; var callback = function ( input , dt , dn ) { me . lst . run ( ) ; }
wn . widgets . form . comments . add ( this . input , cur _frm . docname , cur _frm . doctype , callback ) }
CommentList . prototype . make _lst = function ( ) { if ( ! this . lst ) { var l = new Listing ( 'Comments' , 1 ) ; var me = this ; l . colwidths = [ '100%' ] ; l . opts . hide _export = 1 ; l . opts . hide _print = 1 ; l . opts . hide _refresh = 1 ; l . opts . no _border = 1 ; l . opts . hide _rec _label = 0 ; l . opts . show _calc = 0 ; l . opts . round _corners = 0 ; l . opts . alt _cell _style = { } ; l . opts . cell _style = { padding : '3px' } ; l . no _rec _message = 'No comments yet. Be the first one to comment!' ; l . get _query = function ( ) { this . query = repl ( " select t1 . name , t1 . comment , t1 . comment _by , '' , \
t1 . creation , t1 . comment _doctype , t1 . comment _docname , \
ifnull ( concat _ws ( ' ' , ifnull ( t2 . first _name , '' ) , ifnull ( t2 . middle _name , '' ) , \
ifnull ( t2 . last _name , '' ) ) , '' ) , '' , \
DAYOFMONTH ( t1 . creation ) , MONTHNAME ( t1 . creation ) , YEAR ( t1 . creation ) , \
hour ( t1 . creation ) , minute ( t1 . creation ) , second ( t1 . creation ) \
from ` tabComment Widget Record ` t1 , ` tabProfile ` t2 \
where t1 . comment _doctype = '%(dt)s' and t1 . comment _docname = '%(dn)s' \
and t1 . comment _by = t2 . name order by t1 . creation desc ",{dt:me.dt,dn:me.dn});this.query_max=repl(" select count ( name ) from ` tabComment Widget Record ` where \
comment _doctype = '%(dt)s' and comment _docname = '%(dn)s' " , { 'dt' : me . dt , 'dn' : me . dn } ) ; }
l . show _cell = function ( cell , ri , ci , d ) { new CommentItem ( cell , ri , ci , d , me ) }
this . lst = l ; this . lst . make ( this . lst _area ) ; } }
CommentItem = function ( cell , ri , ci , d , comment ) { this . comment = comment ; $y ( cell , { padding : '4px 0px' } )
var t = make _table ( cell , 1 , 3 , '100%' , [ '15%' , '65%' , '20%' ] , { padding : '4px' } ) ; this . img = $a ( $td ( t , 0 , 0 ) , 'img' , '' , { width : '40px' } ) ; this . cmt _by = $a ( $td ( t , 0 , 0 ) , 'div' ) ; this . set _picture ( d , ri ) ; this . cmt _dtl = $a ( $td ( t , 0 , 1 ) , 'div' , 'comment' , { fontSize : '11px' } ) ; this . cmt = $a ( $td ( t , 0 , 1 ) , 'div' , '' , { fontSize : '14px' } ) ; this . show _cmt ( $td ( t , 0 , 1 ) , ri , ci , d ) ; this . cmt _delete ( $td ( t , 0 , 2 ) , ri , ci , d ) ; }
CommentItem . prototype . set _picture = function ( d , ri ) { set _user _img ( this . img , user )
this . cmt _by . innerHTML = d [ ri ] [ 7 ] ? d [ ri ] [ 7 ] : d [ ri ] [ 2 ] ; }
CommentItem . prototype . show _cmt = function ( cell , ri , ci , d ) { if ( d [ ri ] [ 4 ] ) { hr = d [ ri ] [ 12 ] ; min = d [ ri ] [ 13 ] ; sec = d [ ri ] [ 14 ] ; if ( parseInt ( hr ) > 12 ) { time = ( parseInt ( hr ) - 12 ) + ':' + min + ' PM' }
else { time = hr + ':' + min + ' AM' } }
this . cmt _dtl . innerHTML = 'On ' + d [ ri ] [ 10 ] . substring ( 0 , 3 ) + ' ' + d [ ri ] [ 9 ] + ', ' + d [ ri ] [ 11 ] + ' at ' + time ; this . cmt . innerHTML = replace _newlines ( d [ ri ] [ 1 ] ) ; }
CommentItem . prototype . cmt _delete = function ( cell , ri , ci , d ) { var me = this ; if ( d [ ri ] [ 2 ] == user || d [ ri ] [ 3 ] == user ) { del = $a ( cell , 'div' , 'wn-icon ic-trash' , { cursor : 'pointer' } ) ; del . cmt _id = d [ ri ] [ 0 ] ; del . onclick = function ( ) { wn . widgets . form . comments . remove ( cur _frm . doctype , cur _frm . docname , this . cmt _id , function ( ) { me . comment . lst . run ( ) ; } ) } } }
/ *
* lib / js / legacy / wn / widgets / form / sidebar . js
* /
wn . widgets . form . sidebar = { Sidebar : function ( form ) { var me = this ; this . form = form ; this . opts = { sections : [ { title : 'Actions' , items : [ { type : 'link' , label : 'New' , icon : 'ic-doc_new' , display : function ( ) { return in _list ( profile . can _create , form . doctype ) } , onclick : function ( ) { new _doc ( me . form . doctype ) } } , { type : 'link' , label : 'Refresh' , icon : 'ic-playback_reload' , onclick : function ( ) { me . form . reload _doc ( ) } } , { type : 'link' , label : 'Print' , display : function ( ) { return ! ( me . form . doc . _ _islocal || me . form . meta . allow _print ) ; } , icon : 'ic-print' , onclick : function ( ) { me . form . print _doc ( ) } } , { type : 'link' , label : 'Email' , display : function ( ) { return ! ( me . form . doc . _ _islocal || me . form . meta . allow _email ) ; } , icon : 'ic-mail' , onclick : function ( ) { me . form . email _doc ( ) } } , { type : 'link' , label : 'Copy' , display : function ( ) { return in _list ( profile . can _create , me . form . doctype ) && ! me . form . meta . allow _copy } , icon : 'ic-clipboard_copy' , onclick : function ( ) { me . form . copy _doc ( ) } } , { type : 'link' , label : 'Delete' , display : function ( ) { return me . form . meta . allow _trash && cint ( me . form . doc . docstatus ) != 2 && ( ! me . form . doc . _ _islocal ) && me . form . perm [ 0 ] [ CANCEL ] } , icon : 'ic-trash' , onclick : function ( ) { me . form . savetrash ( ) } } ] } , { title : 'Assign To' , render : function ( wrapper ) { me . form . assign _to = new wn . widgets . form . sidebar . AssignTo ( wrapper , me , me . form . doctype , me . form . docname ) ; } , display : function ( ) { if ( me . form . doc . _ _local ) return false ; else return true ; } } , { title : 'Attachments' , render : function ( wrapper ) { me . form . attachments = new wn . widgets . form . sidebar . Attachments ( wrapper , me , me . form . doctype , me . form . docname ) ; } , display : function ( ) { return me . form . meta . allow _attach } } , { title : 'Comments' , render : function ( wrapper ) { new wn . widgets . form . sidebar . Comments ( wrapper , me , me . form . doctype , me . form . docname ) ; } , display : function ( ) { return ! me . form . doc . _ _islocal } } , { title : 'Tags' , render : function ( wrapper ) { me . form . taglist = new TagList ( wrapper , me . form . doc . _user _tags ? me . form . doc . _user _tags . split ( ',' ) : [ ] , me . form . doctype , me . form . docname , 0 , function ( ) { } ) ; } , display : function ( ) { return ! me . form . doc . _ _islocal } } ] }
this . refresh = function ( ) { var parent = this . form . page _layout . sidebar _area ; if ( ! this . sidebar ) { $y ( parent , { paddingTop : '37px' } )
this . sidebar = new wn . widgets . PageSidebar ( parent , this . opts ) ; } else { this . sidebar . refresh ( ) ; } } } }
/ *
* lib / js / legacy / wn / widgets / form / comments . js
* /
wn . widgets . form . sidebar . Comments = function ( parent , sidebar , doctype , docname ) { var me = this ; this . sidebar = sidebar ; this . doctype = doctype ; this . docname = docname ; this . refresh = function ( ) { $c ( 'webnotes.widgets.form.comments.get_comments' , { dt : me . doctype , dn : me . docname , limit : 5 } , function ( r , rt ) { wn . widgets . form . comments . sync ( me . doctype , me . docname , r ) ; me . make _body ( ) ; } ) ; }
this . make _body = function ( ) { if ( this . wrapper ) this . wrapper . innerHTML = '' ; else this . wrapper = $a ( parent , 'div' , 'sidebar-comment-wrapper' ) ; this . input = $a _input ( this . wrapper , 'text' ) ; this . btn = $btn ( this . wrapper , 'Post' , function ( ) { me . add _comment ( ) } , { marginLeft : '8px' } ) ; this . render _comments ( ) }
this . render _comments = function ( ) { var f = wn . widgets . form . comments ; var cl = f . comment _list [ me . docname ]
this . msg = $a ( this . wrapper , 'div' , 'sidebar-comment-message' ) ; if ( cl ) { this . msg . innerHTML = cl . length + ' out of ' + f . n _comments [ me . docname ] + ' comments' ; if ( f . n _comments [ me . docname ] > cl . length ) { this . msg . innerHTML += ' <span class="link_type" onclick="cur_frm.show_comments()">Show all</span>' }
for ( var i = 0 ; i < cl . length ; i ++ ) { this . render _one _comment ( cl [ i ] ) ; } } else { this . msg . innerHTML = 'Be the first one to comment.' } }
this . render _one _comment = function ( det ) { $a ( this . wrapper , 'div' , 'social sidebar-comment-text' , '' , det . comment ) ; $a ( this . wrapper , 'div' , 'sidebar-comment-info' , '' , comment _when ( det . creation ) + ' by ' + det . comment _by _fullname ) ; }
this . add _comment = function ( ) { if ( ! this . input . value ) return ; this . btn . set _working ( ) ; wn . widgets . form . comments . add ( this . input , me . doctype , me . docname , function ( ) { me . btn . done _working ( ) ; me . make _body ( ) ; } ) ; }
this . refresh ( ) ; }
/ *
* lib / js / legacy / wn / widgets / form / attachments . js
* /
wn . widgets . form . sidebar . Attachments = function ( parent , sidebar , doctype , docname ) { var me = this ; this . frm = sidebar . form ; this . make = function ( ) { if ( this . wrapper ) this . wrapper . innerHTML = '' ; else this . wrapper = $a ( parent , 'div' , 'sidebar-comment-wrapper' ) ; this . attach _wrapper = $a ( this . wrapper , 'div' ) ; if ( this . frm . doc . _ _islocal ) { this . attach _wrapper . innerHTML = 'Attachments can be uploaded after saving'
return ; }
var n = this . frm . doc . file _list ? this . frm . doc . file _list . split ( '\n' ) . length : 0 ; if ( n < this . frm . meta . max _attachments || ! this . frm . meta . max _attachments ) { this . btn = $btn ( $a ( this . wrapper , 'div' , 'sidebar-comment-message' ) , 'Add' , function ( ) { me . add _attachment ( ) } ) ; }
this . render ( ) ; }
this . render = function ( ) { this . attach _wrapper . innerHTML = ''
var doc = locals [ me . frm . doctype ] [ me . frm . docname ] ; var fl = doc . file _list ? doc . file _list . split ( '\n' ) : [ ] ; for ( var i = 0 ; i < fl . length ; i ++ ) { new wn . widgets . form . sidebar . Attachment ( this . attach _wrapper , fl [ i ] , me . frm ) } }
this . add _attachment = function ( ) { if ( ! this . dialog ) { this . dialog = new wn . widgets . Dialog ( { title : 'Add Attachment' , width : 400 } )
$y ( this . dialog . body , { margin : '13px' } )
this . dialog . make ( ) ; }
this . dialog . body . innerHTML = '' ; this . dialog . show ( ) ; this . uploader = new Uploader ( this . dialog . body , { from _form : 1 , doctype : doctype , docname : docname , at _id : this . at _id } , wn . widgets . form . file _upload _done ) ; }
this . make ( ) ; }
wn . widgets . form . sidebar . Attachment = function ( parent , filedet , frm ) { filedet = filedet . split ( ',' )
this . filename = filedet [ 0 ] ; this . fileid = filedet [ 1 ] ; this . frm = frm ; var me = this ; this . wrapper = $a ( parent , 'div' , 'sidebar-comment-message' ) ; this . remove _fileid = function ( ) { var doc = locals [ me . frm . doctype ] [ me . frm . docname ] ; var fl = doc . file _list . split ( '\n' ) ; new _fl = [ ] ; for ( var i = 0 ; i < fl . length ; i ++ ) { if ( fl [ i ] . split ( ',' ) [ 1 ] != me . fileid ) new _fl . push ( fl [ i ] ) ; }
doc . file _list = new _fl . join ( '\n' ) ; }
2012-02-16 10:05:05 +00:00
var display _name = this . fileid ; if ( this . fileid . substr ( 0 , 8 ) == 'FileData' )
display _name = this . filename ; this . ln = $a ( this . wrapper , 'a' , 'link_type' , { fontSize : '11px' } , display _name ) ; this . ln . href = 'files/' + this . fileid ; this . ln . target = '_blank' ; this . del = $a ( this . wrapper , 'span' , 'close' , '' , '×' ) ; this . del . onclick = function ( ) { var yn = confirm ( "Are you sure you want to delete the attachment?" )
2012-02-14 06:14:13 +00:00
if ( yn ) { var callback = function ( r , rt ) { locals [ me . frm . doctype ] [ me . frm . docname ] . modified = r . message ; $dh ( me . wrapper ) ; me . remove _fileid ( ) ; frm . refresh ( ) ; }
$c ( 'webnotes.widgets.form.utils.remove_attach' , args = { 'fid' : me . fileid , dt : me . frm . doctype , dn : me . frm . docname } , callback ) ; } } }
wn . widgets . form . file _upload _done = function ( doctype , docname , fileid , filename , at _id , new _timestamp ) { var at _id = cint ( at _id ) ; var doc = locals [ doctype ] [ docname ] ; if ( doc . file _list ) { var fl = doc . file _list . split ( '\n' )
fl . push ( filename + ',' + fileid )
doc . file _list = fl . join ( '\n' ) ; }
else
doc . file _list = filename + ',' + fileid ; doc . modified = new _timestamp ; var frm = frms [ doctype ] ; frm . attachments . dialog . hide ( ) ; msgprint ( 'File Uploaded Sucessfully.' ) ; frm . refresh ( ) ; }
/ *
* lib / js / legacy / wn / widgets / form / assign _to . js
* /
wn . widgets . form . sidebar . AssignTo = Class . extend ( { init : function ( parent , sidebar , doctype , docname ) { var me = this ; this . doctype = doctype ; this . name = docname ; this . wrapper = $a ( parent , 'div' , 'sidebar-comment-wrapper' ) ; this . body = $a ( this . wrapper , 'div' ) ; this . add _btn = $btn ( $a ( this . wrapper , 'div' , 'sidebar-comment-message' ) , 'Assign' , function ( ) { me . add ( ) ; } )
this . refresh ( ) ; } , refresh : function ( ) { var me = this ; $c ( 'webnotes.widgets.form.assign_to.get' , { doctype : me . doctype , name : me . name } , function ( r , rt ) { me . render ( r . message ) } ) } , render : function ( d ) { var me = this ; $ ( this . body ) . empty ( ) ; if ( this . dialog ) { this . dialog . hide ( ) ; }
for ( var i = 0 ; i < d . length ; i ++ ) { $ ( this . body ) . append ( repl ( ' < div > % ( owner ) s \
< a class = "close" href = "#" data - owner = "%(owner)s" > & # 215 < / a > < / d i v > ' , d [ i ] ) ) }
$ ( this . body ) . find ( 'a.close' ) . click ( function ( ) { $c ( 'webnotes.widgets.form.assign_to.remove' , { doctype : me . doctype , name : me . name , assign _to : $ ( this ) . attr ( 'data-owner' ) } , function ( r , rt ) { me . render ( r . message ) ; } ) ; return false ; } ) ; } , add : function ( ) { var me = this ; if ( ! me . dialog ) { me . dialog = new wn . widgets . Dialog ( { title : 'Add to To Do' , width : 350 , fields : [ { fieldtype : 'Link' , fieldname : 'assign_to' , options : 'Profile' , label : 'Assign To' , description : 'Add to To Do List of' , reqd : true } , { fieldtype : 'Data' , fieldname : 'description' , label : 'Comment' , 'default' : 'Assigned by ' + user } , { fieldtype : 'Date' , fieldname : 'date' , label : 'Complete By' } , { fieldtype : 'Select' , fieldname : 'priority' , label : 'Priority' , options : 'Low\nMedium\nHigh' , 'default' : 'Medium' } , { fieldtype : 'Button' , label : 'Add' , fieldname : 'add_btn' } ] } ) ; me . dialog . fields _dict . add _btn . input . onclick = function ( ) { var assign _to = me . dialog . fields _dict . assign _to . get _value ( ) ; if ( assign _to ) { $c ( 'webnotes.widgets.form.assign_to.add' , { doctype : me . doctype , name : me . name , assign _to : assign _to , description : me . dialog . fields _dict . description . get _value ( ) , priority : me . dialog . fields _dict . priority . get _value ( ) , date : me . dialog . fields _dict . date . get _value ( ) } , function ( r , rt ) { me . render ( r . message ) ; } ) ; } } }
me . dialog . clear ( ) ; me . dialog . show ( ) ; } } ) ;
/ *
* lib / js / legacy / app . js
* /
var popup _cont ; var session = { } ; var start _sid = null ; if ( ! wn ) var wn = { } ; function startup ( ) { start _sid = get _cookie ( 'sid' ) ; popup _cont = $a ( document . getElementsByTagName ( 'body' ) [ 0 ] , 'div' ) ; var setup _globals = function ( r ) { wn . boot = r ; profile = r . profile ; user = r . profile . name ; user _fullname = profile . first _name + ( r . profile . last _name ? ( ' ' + r . profile . last _name ) : '' ) ; user _defaults = profile . defaults ; user _roles = profile . roles ; user _email = profile . email ; profile . start _items = r . start _items ; home _page = r . home _page ; _p . letter _heads = r . letter _heads ; sys _defaults = r . sysdefaults ; session . rt = profile . can _read ; if ( r . ipinfo ) session . ipinfo = r . ipinfo ; session . dt _labels = r . dt _labels ; session . rev _dt _labels = { }
if ( r . dt _labels ) { for ( key in r . dt _labels ) session . rev _dt _labels [ r . dt _labels [ key ] ] = key ; }
wn . control _panel = r . control _panel ; }
var setup _history = function ( r ) { rename _observers . push ( nav _obj ) ; }
2012-02-17 08:34:55 +00:00
var callback = function ( r , rt ) { if ( r . exc ) console . log ( r . exc ) ; setup _globals ( r ) ; setup _history ( ) ; var a = new Body ( ) ; page _body . run _startup _code ( ) ; page _body . setup _sidebar _menu ( ) ; for ( var i = 0 ; i < startup _list . length ; i ++ ) { startup _list [ i ] ( ) ; }
2012-02-14 06:14:13 +00:00
if ( get _url _arg ( 'embed' ) ) { newdoc ( get _url _arg ( 'embed' ) ) ; return ; }
var t = to _open ( ) ; if ( t ) { historyChange ( t ) ; } else if ( home _page ) { loadpage ( home _page ) ; }
page _body . ready ( ) ; }
if ( wn . boot ) { LocalDB . sync ( wn . boot . docs ) ; callback ( wn . boot , '' ) ; if ( wn . boot . error _messages )
console . log ( wn . boot . error _messages )
if ( wn . boot . server _messages )
msgprint ( wn . boot . server _messages ) ; } else { if ( $i ( 'startup_div' ) )
$c ( 'startup' , { } , callback , null , 1 ) ; } }
function to _open ( ) { if ( get _url _arg ( 'page' ) )
return get _url _arg ( 'page' ) ; var h = location . hash ; if ( h ) { return h . substr ( 1 ) ; } }
function logout ( ) { $c ( 'logout' , args = { } , function ( r , rt ) { if ( r . exc ) { msgprint ( r . exc ) ; return ; }
redirect _to _login ( ) ; } ) ; }
function redirect _to _login ( ) { if ( login _file )
window . location . href = login _file ; else { window . location . reload ( ) ; } }
_p . def _print _style _body = "html, body, div, span, td { font-family: Arial, Helvetica; font-size: 12px; }" + "\npre { margin:0; padding:0;}"
_p . def _print _style _other = "\n.simpletable, .noborder { border-collapse: collapse; margin-bottom: 10px;}"
+ "\n.simpletable td {border: 1pt solid #000; vertical-align: top; padding: 2px; }"
+ "\n.noborder td { vertical-align: top; }"
_p . go = function ( html ) { var d = document . createElement ( 'div' )
d . innerHTML = html
$ ( d ) . printElement ( ) ; }
_p . preview = function ( html ) { var w = window . open ( '' ) ; w . document . write ( html )
w . document . close ( ) ; }
function setup _calendar ( ) { var p = new Page ( '_calendar' ) ; p . wrapper . style . height = '100%' ; p . wrapper . onshow = function ( ) { wn . require ( 'lib/js/legacy/widgets/calendar.js' ) ; if ( ! _c . calendar ) { _c . calendar = new Calendar ( ) ; _c . calendar . init ( p . cont ) ; rename _observers . push ( _c . calendar ) ; } } }
startup _list . push ( setup _calendar ) ; var resize _observers = [ ]
function set _resize _observer ( fn ) { if ( resize _observers . indexOf ( fn ) == - 1 ) resize _observers . push ( fn ) ; }
window . onresize = function ( ) { return ; var ht = get _window _height ( ) ; for ( var i = 0 ; i < resize _observers . length ; i ++ ) { resize _observers [ i ] ( ht ) ; } }
get _window _height = function ( ) { var ht = window . innerHeight ? window . innerHeight : document . documentElement . offsetHeight ? document . documentElement . offsetHeight : document . body . offsetHeight ; return ht ; }
/ *
* js / app . js
* /
wn . app = { name : 'ERPNext' , license : 'GNU/GPL - Usage Condition: All "erpnext" branding must be kept as it is' , source : 'https://github.com/webnotes/erpnext' , publisher : 'Web Notes Technologies Pvt Ltd, Mumbai' , copyright : '© Web Notes Technologies Pvt Ltd' , version : '2.' + window . _version _number }
wn . modules _path = 'erpnext' ; wn . settings . no _history = true ; $ ( document ) . bind ( 'ready' , function ( ) { startup ( ) ; } ) ; $ ( document ) . bind ( 'toolbar_setup' , function ( ) { $ ( '.brand' ) . html ( '<b>erp</b>next' ) ; } )
/ *
* erpnext / startup / startup . js
* /
var current _module ; var is _system _manager = 0 ; var module _content _dict = { } ; var user _full _nm = { } ; wn . provide ( 'erpnext.startup' ) ; erpnext . startup . set _globals = function ( ) { pscript . is _erpnext _saas = cint ( wn . control _panel . sync _with _gateway )
if ( inList ( user _roles , 'System Manager' ) ) is _system _manager = 1 ; }
erpnext . startup . start = function ( ) { $ ( '#startup_div' ) . html ( 'Starting up...' ) . toggle ( true ) ; erpnext . startup . set _globals ( ) ; if ( user == 'Guest' ) { $dh ( page _body . left _sidebar ) ; if ( wn . boot . custom _css ) { set _style ( wn . boot . custom _css ) ; }
if ( wn . boot . website _settings . title _prefix ) { wn . title _prefix = wn . boot . website _settings . title _prefix ; } } else { pscript . startup _make _sidebar ( ) ; erpnext . toolbar . setup ( ) ; $ ( 'footer' ) . html ( ' < div class = "erpnext-footer" > \
Powered by < a href = "https://erpnext.com" > ERPNext < / a > < / d i v > ' ) ; }
$ ( '#startup_div' ) . toggle ( false ) ; }
show _chart _browser = function ( nm , chart _type ) { var call _back = function ( ) { if ( nm == 'Sales Browser' ) { var sb _obj = new SalesBrowser ( ) ; sb _obj . set _val ( chart _type ) ; }
else if ( nm == 'Accounts Browser' )
pscript . make _chart ( chart _type ) ; }
loadpage ( nm , call _back ) ; }
ModulePage = function ( parent , module _name , module _label , help _page , callback ) { this . parent = parent ; page _body . cur _page . module _page = this ; this . wrapper = $a ( parent , 'div' ) ; this . module _name = module _name ; this . transactions = [ ] ; this . page _head = new PageHeader ( this . wrapper , module _label ) ; if ( help _page ) { var btn = this . page _head . add _button ( 'Help' , function ( ) { loadpage ( this . help _page ) } , 1 , 'ui-icon-help' )
btn . help _page = help _page ; }
if ( callback ) this . callback = function ( ) { callback ( ) ; } }
$ ( document ) . bind ( 'startup' , function ( ) { erpnext . startup . start ( ) ; } ) ;
/ *
* erpnext / startup / modules . js
* /
pscript . startup _make _sidebar = function ( ) { $y ( page _body . left _sidebar , { width : ( 100 / 6 ) + '%' , paddingTop : '8px' } ) ; var callback = function ( r , rt ) { var ml = r . message ; page _body . left _sidebar . innerHTML = '' ; for ( var m = 0 ; m < ml . length ; m ++ ) { if ( ml [ m ] ) { new SidebarItem ( ml [ m ] ) ; } }
nav _obj . observers . push ( { notify : function ( t , dt , dn ) { pscript . select _sidebar _menu ( t , dt , dn ) ; } } ) ; var no = nav _obj . ol [ nav _obj . ol . length - 1 ] ; if ( no && menu _item _map [ decodeURIComponent ( no [ 0 ] ) ] [ decodeURIComponent ( no [ 1 ] ) ] )
pscript . select _sidebar _menu ( decodeURIComponent ( no [ 0 ] ) , decodeURIComponent ( no [ 1 ] ) ) ; }
$c _obj ( 'Home Control' , 'get_modules' , '' , callback ) ; }
cur _menu _pointer = null ; var menu _item _map = { 'Form' : { } , 'Page' : { } , 'Report' : { } , 'List' : { } }
pscript . select _sidebar _menu = function ( t , dt , dn ) { if ( menu _item _map [ t ] [ dt ] ) { menu _item _map [ t ] [ dt ] . select ( ) ; } else { if ( cur _menu _pointer )
cur _menu _pointer . deselect ( ) ; } }
var body _background = '#e2e2e2' ; MenuPointer = function ( parent , label ) { var me = this ; this . wrapper = $a ( parent , 'div' , '' , { padding : '0px' , cursor : 'pointer' , margin : '2px 0px' } ) ; $br ( this . wrapper , '3px' ) ; this . tab = make _table ( $a ( this . wrapper , 'div' ) , 1 , 2 , '100%' , [ '' , '11px' ] , { height : '22px' , verticalAlign : 'middle' , padding : '0px' } , { borderCollapse : 'collapse' , tableLayout : 'fixed' } ) ; $y ( $td ( this . tab , 0 , 0 ) , { padding : '0px 4px' , color : '#444' , whiteSpace : 'nowrap' } ) ; this . tab . triangle _div = $a ( $td ( this . tab , 0 , 1 ) , 'div' , '' , { borderColor : body _background + ' ' + body _background + ' ' + body _background + ' ' + 'transparent' , borderWidth : '11px' , borderStyle : 'solid' , height : '0px' , width : '0px' , marginRight : '-11px' } ) ; this . label _area = $a ( $td ( this . tab , 0 , 0 ) , 'span' , '' , '' , label ) ; $ ( this . wrapper ) . hover ( function ( ) { if ( ! me . selected )
$bg ( this , '#eee' ) ; } , function ( ) { if ( ! me . selected )
$bg ( this , body _background ) ; } )
$y ( $td ( this . tab , 0 , 0 ) , { borderBottom : '1px solid #ddd' } ) ; }
MenuPointer . prototype . select = function ( grey ) { $y ( $td ( this . tab , 0 , 0 ) , { color : '#fff' , borderBottom : '0px solid #000' } ) ; $ ( this . wrapper ) . css ( 'background-color' , '#999' ) ; this . selected = 1 ; if ( cur _menu _pointer && cur _menu _pointer != this )
cur _menu _pointer . deselect ( ) ; cur _menu _pointer = this ; }
MenuPointer . prototype . deselect = function ( ) { $y ( $td ( this . tab , 0 , 0 ) , { color : '#444' , borderBottom : '1px solid #ddd' } ) ; $ ( this . wrapper ) . css ( 'background-color' , body _background ) ; this . selected = 0 ; }
var cur _sidebar _item = null ; SidebarItem = function ( det ) { var me = this ; this . det = det ; this . wrapper = $a ( page _body . left _sidebar , 'div' , '' , { marginRight : '12px' } ) ; this . body = $a ( this . wrapper , 'div' ) ; this . tab = make _table ( this . body , 1 , 2 , '100%' , [ '24px' , null ] , { verticalAlign : 'middle' } , { tableLayout : 'fixed' } ) ; var ic = $a ( $td ( this . tab , 0 , 0 ) , 'div' , 'module-icons module-icons-' + det . module _label . toLowerCase ( ) , { marginLeft : '3px' , marginBottom : '-2px' } ) ; this . pointer = new MenuPointer ( $td ( this . tab , 0 , 1 ) , det . module _label ) ; $y ( $td ( this . pointer . tab , 0 , 0 ) , { fontWeight : 'bold' } ) ; if ( det . module _page ) { menu _item _map . Page [ det . module _page ] = this . pointer ; }
this . items _area = $a ( this . wrapper , 'div' ) ; this . body . onclick = function ( ) { me . onclick ( ) ; } }
SidebarItem . prototype . onclick = function ( ) { var me = this ; if ( this . det . module _page ) { this . pointer . select ( ) ; $ ( me . pointer . label _area ) . set _working ( ) ; loadpage ( this . det . module _page , function ( ) { $ ( me . pointer . label _area ) . done _working ( ) ; } ) ; } else { this . toggle ( ) ; } }
SidebarItem . prototype . collapse = function ( ) { $ ( this . items _area ) . slideUp ( ) ; this . is _open = 0 ; $fg ( this . pointer . label _area , '#444' ) }
SidebarItem . prototype . toggle = function ( ) { if ( this . loading ) return ; if ( this . is _open ) { this . collapse ( ) ; } else { if ( this . loaded ) $ ( this . items _area ) . slideDown ( ) ; else this . show _items ( ) ; this . is _open = 1 ; $fg ( this . pointer . label _area , '#000' )
if ( cur _sidebar _item && cur _sidebar _item != this ) { cur _sidebar _item . collapse ( ) ; }
cur _sidebar _item = this ; } }
SidebarItem . prototype . show _items = function ( ) { this . loading = 1 ; var me = this ; $ ( this . pointer . label _area ) . set _working ( ) ; var callback = function ( r , rt ) { me . loaded = 1 ; me . loading = 0 ; var smi = null ; var has _reports = 0 ; var has _tools = 0 ; $ ( me . pointer . label _area ) . done _working ( ) ; if ( r . message . il ) { me . il = r . message . il ; for ( var i = 0 ; i < me . il . length ; i ++ ) { if ( me . il [ i ] . doc _type == 'Forms' ) { if ( in _list ( profile . can _read , me . il [ i ] . doc _name ) ) { var smi = new SidebarModuleItem ( me , me . il [ i ] ) ; menu _item _map [ 'Form' ] [ me . il [ i ] . doc _name ] = smi . pointer ; menu _item _map [ 'List' ] [ me . il [ i ] . doc _name ] = smi . pointer ; } }
if ( me . il [ i ] . doc _type == 'Reports' ) has _reports = 1 ; if ( in _list ( [ 'Single DocType' , 'Pages' , 'Setup Forms' ] , me . il [ i ] . doc _type ) )
has _tools = 1 ; }
if ( has _reports ) { var smi = new SidebarModuleItem ( me , { doc _name : 'Reports' , doc _type : 'Reports' } ) ; menu _item _map [ 'Page' ] [ me . det . module _label + ' Reports' ] = smi . pointer ; }
if ( has _tools ) { var smi = new SidebarModuleItem ( me , { doc _name : 'Tools' , doc _type : 'Tools' } ) ; menu _item _map [ 'Page' ] [ me . det . module _label + ' Tools' ] = smi . pointer ; }
if ( r . message . custom _reports . length ) { me . il = add _lists ( r . message . il , r . message . custom _reports ) ; var smi = new SidebarModuleItem ( me , { doc _name : 'Custom Reports' , doc _type : 'Custom Reports' } ) ; menu _item _map [ 'Page' ] [ me . det . module _label + ' Custom Reports' ] = smi . pointer ; } }
$ ( me . items _area ) . slideDown ( ) ; var no = nav _obj . ol [ nav _obj . ol . length - 1 ] ; if ( no && menu _item _map [ decodeURIComponent ( no [ 0 ] ) ] [ decodeURIComponent ( no [ 1 ] ) ] )
pscript . select _sidebar _menu ( decodeURIComponent ( no [ 0 ] ) , decodeURIComponent ( no [ 1 ] ) ) ; }
$c _obj ( 'Home Control' , 'get_module_details' , me . det . name , callback ) ; }
SidebarItem . prototype . show _section = function ( sec _type ) { var me = this ; var label = this . det . module _label + ' ' + sec _type ; var type _map = { 'Reports' : 'Reports' , 'Custom Reports' : 'Custom Reports' , 'Pages' : 'Tools' , 'Single DocType' : 'Tools' , 'Setup Forms' : 'Tools' }
if ( page _body . pages [ label ] ) { loadpage ( label , null , 1 ) ; } else { var page = page _body . add _page ( label ) ; this . wrapper = $a ( page , 'div' , 'layout_wrapper' ) ; this . head = new PageHeader ( this . wrapper , label ) ; this . body1 = $a ( this . wrapper , 'div' , '' , { marginTop : '16px' } ) ; var add _link = function ( det ) { var div = $a ( me . body1 , 'div' , '' , { marginBottom : '6px' } ) ; var span = $a ( div , 'span' , 'link_type' ) ; span . innerHTML = det . display _name ; span . det = det ; if ( sec _type == 'Reports' || sec _type == 'Custom Reports' ) { span . onclick = function ( ) { loadreport ( this . det . doc _name , this . det . display _name ) ; } } else { if ( det . doc _type == 'Pages' ) { if ( det . click _function ) { span . onclick = function ( ) { eval ( this . det . click _function ) }
span . click _function = det . click _function ; } else { span . onclick = function ( ) { loadpage ( this . det . doc _name ) ; } } } else if ( det . doc _type == 'Setup Forms' ) { span . onclick = function ( ) { loaddocbrowser ( this . det . doc _name ) ; } } else { span . onclick = function ( ) { loaddoc ( this . det . doc _name , this . det . doc _name ) ; } } } }
for ( var i = 0 ; i < me . il . length ; i ++ ) { if ( type _map [ me . il [ i ] . doc _type ] == sec _type ) { add _link ( me . il [ i ] ) ; } }
loadpage ( label , null , 1 ) ; } }
SidebarModuleItem = function ( si , det ) { this . det = det ; var me = this ; this . pointer = new MenuPointer ( si . items _area , get _doctype _label ( det . doc _name ) ) ; $y ( si . items _area , { marginLeft : '32px' } )
$y ( $td ( this . pointer . tab , 0 , 0 ) , { fontSize : '11px' } ) ; this . pointer . wrapper . onclick = function ( ) { if ( me . det . doc _type == 'Forms' )
loaddocbrowser ( det . doc _name ) ; else
si . show _section ( me . det . doc _type ) ; } }
/ *
* erpnext / startup / toolbar . js
* /
wn . provide ( 'erpnext.toolbar' ) ; erpnext . toolbar . setup = function ( ) { $ ( '#toolbar-user' ) . append ( '<li><a href="#profile-settings">Profile Settings</a></li>' )
$ ( '.topbar .secondary-nav' ) . append ( ' < li class = "dropdown" > \
< a class = "dropdown-toggle" href = "#" onclick = "return false;" > Help < / a > \
< ul class = "dropdown-menu" id = "toolbar-help" > \
< / u l > < / l i > ' )
$ ( '#toolbar-help' ) . append ( ' < li > < a href = "http://erpnext.blogspot.com/2011/03/erpnext-help.html" target = "_blank" > \
Documentation < / a > < / l i > ' )
$ ( '#toolbar-help' ) . append ( ' < li > < a href = "http://groups.google.com/group/erpnext-user-forum" target = "_blank" > \
Forum < / a > < / l i > ' )
$ ( '#toolbar-help' ) . append ( ' < li > < a href = "http://www.providesupport.com?messenger=iwebnotes" target = "_blank" > \
Live Chat ( Office Hours ) < / a > < / l i > ' )
if ( pscript . is _erpnext _saas && is _system _manager ) { $ ( '#toolbar-user' ) . append ( '<li><a href="#billing">Billing</a></li>' ) } }
/ *
* erpnext / startup / feature _setup . js
* /
2012-02-14 07:15:55 +00:00
pscript . feature _dict = { 'fs_projects' : { 'Bill Of Materials' : { 'fields' : [ 'project_name' ] } , 'Delivery Note' : { 'fields' : [ 'project_name' ] } , 'Payable Voucher' : { 'fields' : [ 'project_name' ] } , 'Production Order' : { 'fields' : [ 'project_name' ] } , 'Purchase Order' : { 'fields' : [ 'project_name' ] } , 'Purchase Receipt' : { 'fields' : [ 'project_name' ] } , 'Receivable Voucher' : { 'fields' : [ 'project_name' ] } , 'Sales Order' : { 'fields' : [ 'project_name' ] } , 'Stock Entry' : { 'fields' : [ 'project_name' ] } , 'Timesheet' : { 'timesheet_details' : [ 'project_name' ] } } , 'fs_packing_details' : { } , 'fs_discounts' : { 'Delivery Note' : { 'delivery_note_details' : [ 'adj_rate' ] } , 'Quotation' : { 'quotation_details' : [ 'adj_rate' ] } , 'Receivable Voucher' : { 'entries' : [ 'adj_rate' ] } , 'Sales Order' : { 'sales_order_details' : [ 'adj_rate' , 'ref_rate' ] } } , 'fs_purchase_discounts' : { 'Purchase Order' : { 'po_details' : [ 'purchase_ref_rate' , 'discount_rate' , 'import_ref_rate' ] } , 'Purchase Receipt' : { 'purchase_receipt_details' : [ 'purchase_ref_rate' , 'discount_rate' , 'import_ref_rate' ] } , 'Payable Voucher' : { 'entries' : [ 'purchase_ref_rate' , 'discount_rate' , 'import_ref_rate' ] } } , 'fs_brands' : { 'Delivery Note' : { 'delivery_note_details' : [ 'brand' ] } , 'Indent' : { 'indent_details' : [ 'brand' ] } , 'Item' : { 'fields' : [ 'brand' ] } , 'Purchase Order' : { 'po_details' : [ 'brand' ] } , 'Payable Voucher' : { 'entries' : [ 'brand' ] } , 'Quotation' : { 'quotation_details' : [ 'brand' ] } , 'Receivable Voucher' : { 'entries' : [ 'brand' ] } , 'Sales BOM' : { 'fields' : [ 'new_item_brand' ] } , 'Sales Order' : { 'sales_order_details' : [ 'brand' ] } , 'Serial No' : { 'fields' : [ 'brand' ] } } , 'fs_after_sales_installations' : { 'Delivery Note' : { 'fields' : [ 'installation_status' , 'per_installed' ] , 'delivery_note_details' : [ 'installed_qty' ] } } , 'fs_item_batch_nos' : { 'Delivery Note' : { 'delivery_note_details' : [ 'batch_no' ] } , 'Item' : { 'fields' : [ 'has_batch_no' ] } , 'Purchase Receipt' : { 'purchase_receipt_details' : [ 'batch_no' ] } , 'QA Inspection Report' : { 'fields' : [ 'batch_no' ] } , 'Sales and Pruchase Return Wizard' : { 'return_details' : [ 'batch_no' ] } , 'Receivable Voucher' : { 'entries' : [ 'batch_no' ] } , 'Stock Entry' : { 'mtn_details' : [ 'batch_no' ] } , 'Stock Ledger Entry' : { 'fields' : [ 'batch_no' ] } } , 'fs_item_serial_nos' : { 'Customer Issue' : { 'fields' : [ 'serial_no' ] } , 'Delivery Note' : { 'delivery_note_details' : [ 'serial_no' ] , 'packing_details' : [ 'serial_no' ] } , 'Installation Note' : { 'installed_item_details' : [ 'serial_no' ] } , 'Item' : { 'fields' : [ 'has_serial_no' ] } , 'Maintenance Schedule' : { 'item_maintenance_details' : [ 'serial_no' ] , 'maintenance_schedule_details' : [ 'serial_no' ] } , 'Maintenance Visit' : { 'maintenance_visit_details' : [ 'serial_no' ] } , 'Purchase Receipt' : { 'purchase_receipt_details' : [ 'serial_no' ] } , 'QA Inspection Report' : { 'fields' : [ 'item_serial_no' ] } , 'Sales and Pruchase Return Wizard' : { 'return_details' : [ 'serial_no' ] } , 'Receivable Voucher' : { 'entries' : [ 'serial_no' ] } , 'Stock Entry' : { 'mtn_details' : [ 'serial_no' ] } , 'Stock Ledger Entry' : { 'fields' : [ 'serial_no' ] } } , 'fs_item_group_in_details' : { 'Delivery Note' : { 'delivery_note_details' : [ 'item_group' ] } , 'Enquiry' : { 'enquiry_details' : [ 'item_group' ] } , 'Indent' : { 'indent_details' : [ 'item_group' ] } , 'Item' : { 'fields' : [ 'item_group' ] } , 'Manage Account' : { 'fields' : [ 'default_item_group' ] } , 'Purchase Order' : { 'po_details' : [ 'item_group' ] } , 'Purchase Receipt' : { 'purchase_receipt_details' : [ 'item_group' ] } , 'Purchase Voucher' : { 'entries' : [ 'item_group' ] } , 'Quotation' : { 'quotation_details' : [ 'item_group' ] } , 'Receivable Voucher' : { 'entries' : [ 'item_group' ] } , 'Sales BOM' : { 'fields' : [ 'serial_no' ] } , 'Sales Order' : { 'sales_order_details' : [ 'item_group' ] } , 'Serial No' : { 'fields' : [ 'item_group' ] } , 'Sales Partner' : { 'partner_target_details' : [ 'item_group' ] } , 'Sales Person' : { 'target_details' : [ 'item_group' ] } , 'Territory' : { 'target_details' : [ 'item_group' ] } } , 'fs_page_break' : { 'Delivery Note' : { 'delivery_note_details' : [ 'page_break' ] , 'packing_details' : [ 'page_break' ] } , 'Indent' : { 'indent_details' : [ 'page_break' ] } , 'Purchase Order' : { 'po_details' : [ 'page_break' ] } , 'Purchase Receipt' : { 'purchase_receipt_details' : [ 'page_break' ] } , 'Purchase Voucher' : { 'entries' : [ 'page_break' ] } , 'Quotation' : { 'quotation_details' : [ 'page_break' ] } , 'Receivable Voucher' : { 'entries' : [ 'page_break' ] } , 'Sales Order' : { 'sales_order_details' : [ 'page_break' ] } } , 'fs_exports' : { 'Delivery Note' : { 'fields' : [ 'Note' , ' conversion _
2012-02-14 06:14:13 +00:00
$ ( document ) . bind ( 'form_refresh' , function ( ) { for ( sys _feat in sys _defaults )
{ if ( sys _defaults [ sys _feat ] == '0' && ( sys _feat in pscript . feature _dict ) )
{ if ( cur _frm . doc . doctype in pscript . feature _dict [ sys _feat ] )
{ for ( fort in pscript . feature _dict [ sys _feat ] [ cur _frm . doc . doctype ] )
{ if ( fort == 'fields' )
hide _field ( pscript . feature _dict [ sys _feat ] [ cur _frm . doc . doctype ] [ fort ] ) ; else if ( cur _frm . fields _dict [ fort ] )
{ for ( grid _field in pscript . feature _dict [ sys _feat ] [ cur _frm . doc . doctype ] [ fort ] )
cur _frm . fields _dict [ fort ] . grid . set _column _disp ( pscript . feature _dict [ sys _feat ] [ cur _frm . doc . doctype ] [ fort ] [ grid _field ] , false ) ; }
else
msgprint ( 'Grid "' + fort + '" does not exists' ) ; } } } } } )