/*! * jQuery JavaScript Library v1.11.1 * http://jquery.com/ * * Includes Sizzle.js * http://sizzlejs.com/ * * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors * Released under the MIT license * http://jquery.org/license * * Date: 2014-05-01T17:42Z */ (function( global, factory ) { if ( typeof module === "object" && typeof module.exports === "object" ) { // For CommonJS and CommonJS-like environments where a proper window is present, // execute the factory and get jQuery // For environments that do not inherently posses a window with a document // (such as Node.js), expose a jQuery-making factory as module.exports // This accentuates the need for the creation of a real window // e.g. var jQuery = require("jquery")(window); // See ticket #14549 for more info module.exports = global.document ? factory( global, true ) : function( w ) { if ( !w.document ) { throw new Error( "jQuery requires a window with a document" ); } return factory( w ); }; } else { factory( global ); } // Pass this if window is not defined yet }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { // Can't do this because several apps including ASP.NET trace // the stack via arguments.caller.callee and Firefox dies if // you try to trace through "use strict" call chains. (#13335) // Support: Firefox 18+ // var deletedIds = []; var slice = deletedIds.slice; var concat = deletedIds.concat; var push = deletedIds.push; var indexOf = deletedIds.indexOf; var class2type = {}; var toString = class2type.toString; var hasOwn = class2type.hasOwnProperty; var support = {}; var version = "1.11.1", // Define a local copy of jQuery jQuery = function( selector, context ) { // The jQuery object is actually just the init constructor 'enhanced' // Need init if jQuery is called (just allow error to be thrown if not included) return new jQuery.fn.init( selector, context ); }, // Support: Android<4.1, IE<9 // Make sure we trim BOM and NBSP rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, // Matches dashed string for camelizing rmsPrefix = /^-ms-/, rdashAlpha = /-([\da-z])/gi, // Used by jQuery.camelCase as callback to replace() fcamelCase = function( all, letter ) { return letter.toUpperCase(); }; jQuery.fn = jQuery.prototype = { // The current version of jQuery being used jquery: version, constructor: jQuery, // Start with an empty selector selector: "", // The default length of a jQuery object is 0 length: 0, toArray: function() { return slice.call( this ); }, // Get the Nth element in the matched element set OR // Get the whole matched element set as a clean array get: function( num ) { return num != null ? // Return just the one element from the set ( num < 0 ? this[ num + this.length ] : this[ num ] ) : // Return all the elements in a clean array slice.call( this ); }, // Take an array of elements and push it onto the stack // (returning the new matched element set) pushStack: function( elems ) { // Build a new jQuery matched element set var ret = jQuery.merge( this.constructor(), elems ); // Add the old object onto the stack (as a reference) ret.prevObject = this; ret.context = this.context; // Return the newly-formed element set return ret; }, // Execute a callback for every element in the matched set. // (You can seed the arguments with an array of args, but this is // only used internally.) each: function( callback, args ) { return jQuery.each( this, callback, args ); }, map: function( callback ) { return this.pushStack( jQuery.map(this, function( elem, i ) { return callback.call( elem, i, elem ); })); }, slice: function() { return this.pushStack( slice.apply( this, arguments ) ); }, first: function() { return this.eq( 0 ); }, last: function() { return this.eq( -1 ); }, eq: function( i ) { var len = this.length, j = +i + ( i < 0 ? len : 0 ); return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] ); }, end: function() { return this.prevObject || this.constructor(null); }, // For internal use only. // Behaves like an Array's method, not like a jQuery method. push: push, sort: deletedIds.sort, splice: deletedIds.splice }; jQuery.extend = jQuery.fn.extend = function() { var src, copyIsArray, copy, name, options, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; // Handle a deep copy situation if ( typeof target === "boolean" ) { deep = target; // skip the boolean and the target target = arguments[ i ] || {}; i++; } // Handle case when target is a string or something (possible in deep copy) if ( typeof target !== "object" && !jQuery.isFunction(target) ) { target = {}; } // extend jQuery itself if only one argument is passed if ( i === length ) { target = this; i--; } for ( ; i < length; i++ ) { // Only deal with non-null/undefined values if ( (options = arguments[ i ]) != null ) { // Extend the base object for ( name in options ) { src = target[ name ]; copy = options[ name ]; // Prevent never-ending loop if ( target === copy ) { continue; } // Recurse if we're merging plain objects or arrays if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { if ( copyIsArray ) { copyIsArray = false; clone = src && jQuery.isArray(src) ? src : []; } else { clone = src && jQuery.isPlainObject(src) ? src : {}; } // Never move original objects, clone them target[ name ] = jQuery.extend( deep, clone, copy ); // Don't bring in undefined values } else if ( copy !== undefined ) { target[ name ] = copy; } } } } // Return the modified object return target; }; jQuery.extend({ // Unique for each copy of jQuery on the page expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), // Assume jQuery is ready without the ready module isReady: true, error: function( msg ) { throw new Error( msg ); }, noop: function() {}, // See test/unit/core.js for details concerning isFunction. // Since version 1.3, DOM methods and functions like alert // aren't supported. They return false on IE (#2968). isFunction: function( obj ) { return jQuery.type(obj) === "function"; }, isArray: Array.isArray || function( obj ) { return jQuery.type(obj) === "array"; }, isWindow: function( obj ) { /* jshint eqeqeq: false */ return obj != null && obj == obj.window; }, isNumeric: function( obj ) { // parseFloat NaNs numeric-cast false positives (null|true|false|"") // ...but misinterprets leading-number strings, particularly hex literals ("0x...") // subtraction forces infinities to NaN return !jQuery.isArray( obj ) && obj - parseFloat( obj ) >= 0; }, isEmptyObject: function( obj ) { var name; for ( name in obj ) { return false; } return true; }, isPlainObject: function( obj ) { var key; // Must be an Object. // Because of IE, we also have to check the presence of the constructor property. // Make sure that DOM nodes and window objects don't pass through, as well if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { return false; } try { // Not own constructor property must be Object if ( obj.constructor && !hasOwn.call(obj, "constructor") && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { return false; } } catch ( e ) { // IE8,9 Will throw exceptions on certain host objects #9897 return false; } // Support: IE<9 // Handle iteration over inherited properties before own properties. if ( support.ownLast ) { for ( key in obj ) { return hasOwn.call( obj, key ); } } // Own properties are enumerated firstly, so to speed up, // if last one is own, then all properties are own. for ( key in obj ) {} return key === undefined || hasOwn.call( obj, key ); }, type: function( obj ) { if ( obj == null ) { return obj + ""; } return typeof obj === "object" || typeof obj === "function" ? class2type[ toString.call(obj) ] || "object" : typeof obj; }, // Evaluates a script in a global context // Workarounds based on findings by Jim Driscoll // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context globalEval: function( data ) { if ( data && jQuery.trim( data ) ) { // We use execScript on Internet Explorer // We use an anonymous function so that context is window // rather than jQuery in Firefox ( window.execScript || function( data ) { window[ "eval" ].call( window, data ); } )( data ); } }, // Convert dashed to camelCase; used by the css and data modules // Microsoft forgot to hump their vendor prefix (#9572) camelCase: function( string ) { return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); }, nodeName: function( elem, name ) { return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); }, // args is for internal usage only each: function( obj, callback, args ) { var value, i = 0, length = obj.length, isArray = isArraylike( obj ); if ( args ) { if ( isArray ) { for ( ; i < length; i++ ) { value = callback.apply( obj[ i ], args ); if ( value === false ) { break; } } } else { for ( i in obj ) { value = callback.apply( obj[ i ], args ); if ( value === false ) { break; } } } // A special, fast, case for the most common use of each } else { if ( isArray ) { for ( ; i < length; i++ ) { value = callback.call( obj[ i ], i, obj[ i ] ); if ( value === false ) { break; } } } else { for ( i in obj ) { value = callback.call( obj[ i ], i, obj[ i ] ); if ( value === false ) { break; } } } } return obj; }, // Support: Android<4.1, IE<9 trim: function( text ) { return text == null ? "" : ( text + "" ).replace( rtrim, "" ); }, // results is for internal usage only makeArray: function( arr, results ) { var ret = results || []; if ( arr != null ) { if ( isArraylike( Object(arr) ) ) { jQuery.merge( ret, typeof arr === "string" ? [ arr ] : arr ); } else { push.call( ret, arr ); } } return ret; }, inArray: function( elem, arr, i ) { var len; if ( arr ) { if ( indexOf ) { return indexOf.call( arr, elem, i ); } len = arr.length; i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; for ( ; i < len; i++ ) { // Skip accessing in sparse arrays if ( i in arr && arr[ i ] === elem ) { return i; } } } return -1; }, merge: function( first, second ) { var len = +second.length, j = 0, i = first.length; while ( j < len ) { first[ i++ ] = second[ j++ ]; } // Support: IE<9 // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists) if ( len !== len ) { while ( second[j] !== undefined ) { first[ i++ ] = second[ j++ ]; } } first.length = i; return first; }, grep: function( elems, callback, invert ) { var callbackInverse, matches = [], i = 0, length = elems.length, callbackExpect = !invert; // Go through the array, only saving the items // that pass the validator function for ( ; i < length; i++ ) { callbackInverse = !callback( elems[ i ], i ); if ( callbackInverse !== callbackExpect ) { matches.push( elems[ i ] ); } } return matches; }, // arg is for internal usage only map: function( elems, callback, arg ) { var value, i = 0, length = elems.length, isArray = isArraylike( elems ), ret = []; // Go through the array, translating each of the items to their new values if ( isArray ) { for ( ; i < length; i++ ) { value = callback( elems[ i ], i, arg ); if ( value != null ) { ret.push( value ); } } // Go through every key on the object, } else { for ( i in elems ) { value = callback( elems[ i ], i, arg ); if ( value != null ) { ret.push( value ); } } } // Flatten any nested arrays return concat.apply( [], ret ); }, // A global GUID counter for objects guid: 1, // Bind a function to a context, optionally partially applying any // arguments. proxy: function( fn, context ) { var args, proxy, tmp; if ( typeof context === "string" ) { tmp = fn[ context ]; context = fn; fn = tmp; } // Quick check to determine if target is callable, in the spec // this throws a TypeError, but we will just return undefined. if ( !jQuery.isFunction( fn ) ) { return undefined; } // Simulated bind args = slice.call( arguments, 2 ); proxy = function() { return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); }; // Set the guid of unique handler to the same of original handler, so it can be removed proxy.guid = fn.guid = fn.guid || jQuery.guid++; return proxy; }, now: function() { return +( new Date() ); }, // jQuery.support is not used in Core but other projects attach their // properties to it so it needs to exist. support: support }); // Populate the class2type map jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { class2type[ "[object " + name + "]" ] = name.toLowerCase(); }); function isArraylike( obj ) { var length = obj.length, type = jQuery.type( obj ); if ( type === "function" || jQuery.isWindow( obj ) ) { return false; } if ( obj.nodeType === 1 && length ) { return true; } return type === "array" || length === 0 || typeof length === "number" && length > 0 && ( length - 1 ) in obj; } var Sizzle = /*! * Sizzle CSS Selector Engine v1.10.19 * http://sizzlejs.com/ * * Copyright 2013 jQuery Foundation, Inc. and other contributors * Released under the MIT license * http://jquery.org/license * * Date: 2014-04-18 */ (function( window ) { var i, support, Expr, getText, isXML, tokenize, compile, select, outermostContext, sortInput, hasDuplicate, // Local document vars setDocument, document, docElem, documentIsHTML, rbuggyQSA, rbuggyMatches, matches, contains, // Instance-specific data expando = "sizzle" + -(new Date()), preferredDoc = window.document, dirruns = 0, done = 0, classCache = createCache(), tokenCache = createCache(), compilerCache = createCache(), sortOrder = function( a, b ) { if ( a === b ) { hasDuplicate = true; } return 0; }, // General-purpose constants strundefined = typeof undefined, MAX_NEGATIVE = 1 << 31, // Instance methods hasOwn = ({}).hasOwnProperty, arr = [], pop = arr.pop, push_native = arr.push, push = arr.push, slice = arr.slice, // Use a stripped-down indexOf if we can't use a native one indexOf = arr.indexOf || function( elem ) { var i = 0, len = this.length; for ( ; i < len; i++ ) { if ( this[i] === elem ) { return i; } } return -1; }, booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", // Regular expressions // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace whitespace = "[\\x20\\t\\r\\n\\f]", // http://www.w3.org/TR/css3-syntax/#characters characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", // Loosely modeled on CSS identifier characters // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier identifier = characterEncoding.replace( "w", "w#" ), // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace + // Operator (capture 2) "*([*^$|!~]?=)" + whitespace + // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]" "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + "*\\]", pseudos = ":(" + characterEncoding + ")(?:\\((" + // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: // 1. quoted (capture 3; capture 4 or capture 5) "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + // 2. simple (capture 6) "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + // 3. anything else (capture 2) ".*" + ")\\)|)", // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), rpseudo = new RegExp( pseudos ), ridentifier = new RegExp( "^" + identifier + "$" ), matchExpr = { "ID": new RegExp( "^#(" + characterEncoding + ")" ), "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), "ATTR": new RegExp( "^" + attributes ), "PSEUDO": new RegExp( "^" + pseudos ), "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), // For use in libraries implementing .is() // We use this for POS matching in `select` "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) }, rinputs = /^(?:input|select|textarea|button)$/i, rheader = /^h\d$/i, rnative = /^[^{]+\{\s*\[native \w/, // Easily-parseable/retrievable ID or TAG or CLASS selectors rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, rsibling = /[+~]/, rescape = /'|\\/g, // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), funescape = function( _, escaped, escapedWhitespace ) { var high = "0x" + escaped - 0x10000; // NaN means non-codepoint // Support: Firefox<24 // Workaround erroneous numeric interpretation of +"0x" return high !== high || escapedWhitespace ? escaped : high < 0 ? // BMP codepoint String.fromCharCode( high + 0x10000 ) : // Supplemental Plane codepoint (surrogate pair) String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); }; // Optimize for push.apply( _, NodeList ) try { push.apply( (arr = slice.call( preferredDoc.childNodes )), preferredDoc.childNodes ); // Support: Android<4.0 // Detect silently failing push.apply arr[ preferredDoc.childNodes.length ].nodeType; } catch ( e ) { push = { apply: arr.length ? // Leverage slice if possible function( target, els ) { push_native.apply( target, slice.call(els) ); } : // Support: IE<9 // Otherwise append directly function( target, els ) { var j = target.length, i = 0; // Can't trust NodeList.length while ( (target[j++] = els[i++]) ) {} target.length = j - 1; } }; } function Sizzle( selector, context, results, seed ) { var match, elem, m, nodeType, // QSA vars i, groups, old, nid, newContext, newSelector; if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { setDocument( context ); } context = context || document; results = results || []; if ( !selector || typeof selector !== "string" ) { return results; } if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { return []; } if ( documentIsHTML && !seed ) { // Shortcuts if ( (match = rquickExpr.exec( selector )) ) { // Speed-up: Sizzle("#ID") if ( (m = match[1]) ) { if ( nodeType === 9 ) { elem = context.getElementById( m ); // Check parentNode to catch when Blackberry 4.6 returns // nodes that are no longer in the document (jQuery #6963) if ( elem && elem.parentNode ) { // Handle the case where IE, Opera, and Webkit return items // by name instead of ID if ( elem.id === m ) { results.push( elem ); return results; } } else { return results; } } else { // Context is not a document if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && contains( context, elem ) && elem.id === m ) { results.push( elem ); return results; } } // Speed-up: Sizzle("TAG") } else if ( match[2] ) { push.apply( results, context.getElementsByTagName( selector ) ); return results; // Speed-up: Sizzle(".CLASS") } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) { push.apply( results, context.getElementsByClassName( m ) ); return results; } } // QSA path if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { nid = old = expando; newContext = context; newSelector = nodeType === 9 && selector; // qSA works strangely on Element-rooted queries // We can work around this by specifying an extra ID on the root // and working up from there (Thanks to Andrew Dupont for the technique) // IE 8 doesn't work on object elements if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { groups = tokenize( selector ); if ( (old = context.getAttribute("id")) ) { nid = old.replace( rescape, "\\$&" ); } else { context.setAttribute( "id", nid ); } nid = "[id='" + nid + "'] "; i = groups.length; while ( i-- ) { groups[i] = nid + toSelector( groups[i] ); } newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context; newSelector = groups.join(","); } if ( newSelector ) { try { push.apply( results, newContext.querySelectorAll( newSelector ) ); return results; } catch(qsaError) { } finally { if ( !old ) { context.removeAttribute("id"); } } } } } // All others return select( selector.replace( rtrim, "$1" ), context, results, seed ); } /** * Create key-value caches of limited size * @returns {Function(string, Object)} Returns the Object data after storing it on itself with * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) * deleting the oldest entry */ function createCache() { var keys = []; function cache( key, value ) { // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) if ( keys.push( key + " " ) > Expr.cacheLength ) { // Only keep the most recent entries delete cache[ keys.shift() ]; } return (cache[ key + " " ] = value); } return cache; } /** * Mark a function for special use by Sizzle * @param {Function} fn The function to mark */ function markFunction( fn ) { fn[ expando ] = true; return fn; } /** * Support testing using an element * @param {Function} fn Passed the created div and expects a boolean result */ function assert( fn ) { var div = document.createElement("div"); try { return !!fn( div ); } catch (e) { return false; } finally { // Remove from its parent by default if ( div.parentNode ) { div.parentNode.removeChild( div ); } // release memory in IE div = null; } } /** * Adds the same handler for all of the specified attrs * @param {String} attrs Pipe-separated list of attributes * @param {Function} handler The method that will be applied */ function addHandle( attrs, handler ) { var arr = attrs.split("|"), i = attrs.length; while ( i-- ) { Expr.attrHandle[ arr[i] ] = handler; } } /** * Checks document order of two siblings * @param {Element} a * @param {Element} b * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b */ function siblingCheck( a, b ) { var cur = b && a, diff = cur && a.nodeType === 1 && b.nodeType === 1 && ( ~b.sourceIndex || MAX_NEGATIVE ) - ( ~a.sourceIndex || MAX_NEGATIVE ); // Use IE sourceIndex if available on both nodes if ( diff ) { return diff; } // Check if b follows a if ( cur ) { while ( (cur = cur.nextSibling) ) { if ( cur === b ) { return -1; } } } return a ? 1 : -1; } /** * Returns a function to use in pseudos for input types * @param {String} type */ function createInputPseudo( type ) { return function( elem ) { var name = elem.nodeName.toLowerCase(); return name === "input" && elem.type === type; }; } /** * Returns a function to use in pseudos for buttons * @param {String} type */ function createButtonPseudo( type ) { return function( elem ) { var name = elem.nodeName.toLowerCase(); return (name === "input" || name === "button") && elem.type === type; }; } /** * Returns a function to use in pseudos for positionals * @param {Function} fn */ function createPositionalPseudo( fn ) { return markFunction(function( argument ) { argument = +argument; return markFunction(function( seed, matches ) { var j, matchIndexes = fn( [], seed.length, argument ), i = matchIndexes.length; // Match elements found at the specified indexes while ( i-- ) { if ( seed[ (j = matchIndexes[i]) ] ) { seed[j] = !(matches[j] = seed[j]); } } }); }); } /** * Checks a node for validity as a Sizzle context * @param {Element|Object=} context * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value */ function testContext( context ) { return context && typeof context.getElementsByTagName !== strundefined && context; } // Expose support vars for convenience support = Sizzle.support = {}; /** * Detects XML nodes * @param {Element|Object} elem An element or a document * @returns {Boolean} True iff elem is a non-HTML XML node */ isXML = Sizzle.isXML = function( elem ) { // documentElement is verified for cases where it doesn't yet exist // (such as loading iframes in IE - #4833) var documentElement = elem && (elem.ownerDocument || elem).documentElement; return documentElement ? documentElement.nodeName !== "HTML" : false; }; /** * Sets document-related variables once based on the current document * @param {Element|Object} [doc] An element or document object to use to set the document * @returns {Object} Returns the current document */ setDocument = Sizzle.setDocument = function( node ) { var hasCompare, doc = node ? node.ownerDocument || node : preferredDoc, parent = doc.defaultView; // If no document and documentElement is available, return if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { return document; } // Set our document document = doc; docElem = doc.documentElement; // Support tests documentIsHTML = !isXML( doc ); // Support: IE>8 // If iframe document is assigned to "document" variable and if iframe has been reloaded, // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936 // IE6-8 do not support the defaultView property so parent will be undefined if ( parent && parent !== parent.top ) { // IE11 does not have attachEvent, so all must suffer if ( parent.addEventListener ) { parent.addEventListener( "unload", function() { setDocument(); }, false ); } else if ( parent.attachEvent ) { parent.attachEvent( "onunload", function() { setDocument(); }); } } /* Attributes ---------------------------------------------------------------------- */ // Support: IE<8 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans) support.attributes = assert(function( div ) { div.className = "i"; return !div.getAttribute("className"); }); /* getElement(s)By* ---------------------------------------------------------------------- */ // Check if getElementsByTagName("*") returns only elements support.getElementsByTagName = assert(function( div ) { div.appendChild( doc.createComment("") ); return !div.getElementsByTagName("*").length; }); // Check if getElementsByClassName can be trusted support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) { div.innerHTML = "
"; // Support: Safari<4 // Catch class over-caching div.firstChild.className = "i"; // Support: Opera<10 // Catch gEBCN failure to find non-leading classes return div.getElementsByClassName("i").length === 2; }); // Support: IE<10 // Check if getElementById returns elements by name // The broken getElementById methods don't pick up programatically-set names, // so use a roundabout getElementsByName test support.getById = assert(function( div ) { docElem.appendChild( div ).id = expando; return !doc.getElementsByName || !doc.getElementsByName( expando ).length; }); // ID find and filter if ( support.getById ) { Expr.find["ID"] = function( id, context ) { if ( typeof context.getElementById !== strundefined && documentIsHTML ) { var m = context.getElementById( id ); // Check parentNode to catch when Blackberry 4.6 returns // nodes that are no longer in the document #6963 return m && m.parentNode ? [ m ] : []; } }; Expr.filter["ID"] = function( id ) { var attrId = id.replace( runescape, funescape ); return function( elem ) { return elem.getAttribute("id") === attrId; }; }; } else { // Support: IE6/7 // getElementById is not reliable as a find shortcut delete Expr.find["ID"]; Expr.filter["ID"] = function( id ) { var attrId = id.replace( runescape, funescape ); return function( elem ) { var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); return node && node.value === attrId; }; }; } // Tag Expr.find["TAG"] = support.getElementsByTagName ? function( tag, context ) { if ( typeof context.getElementsByTagName !== strundefined ) { return context.getElementsByTagName( tag ); } } : function( tag, context ) { var elem, tmp = [], i = 0, results = context.getElementsByTagName( tag ); // Filter out possible comments if ( tag === "*" ) { while ( (elem = results[i++]) ) { if ( elem.nodeType === 1 ) { tmp.push( elem ); } } return tmp; } return results; }; // Class Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) { return context.getElementsByClassName( className ); } }; /* QSA/matchesSelector ---------------------------------------------------------------------- */ // QSA and matchesSelector support // matchesSelector(:active) reports false when true (IE9/Opera 11.5) rbuggyMatches = []; // qSa(:focus) reports false when true (Chrome 21) // We allow this because of a bug in IE8/9 that throws an error // whenever `document.activeElement` is accessed on an iframe // So, we allow :focus to pass through QSA all the time to avoid the IE error // See http://bugs.jquery.com/ticket/13378 rbuggyQSA = []; if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { // Build QSA regex // Regex strategy adopted from Diego Perini assert(function( div ) { // Select is set to empty string on purpose // This is to test IE's treatment of not explicitly // setting a boolean content attribute, // since its presence should be enough // http://bugs.jquery.com/ticket/12359 div.innerHTML = ""; // Support: IE8, Opera 11-12.16 // Nothing should be selected when empty strings follow ^= or $= or *= // The test attribute must be unknown in Opera but "safe" for WinRT // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section if ( div.querySelectorAll("[msallowclip^='']").length ) { rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); } // Support: IE8 // Boolean attributes and "value" are not treated correctly if ( !div.querySelectorAll("[selected]").length ) { rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); } // Webkit/Opera - :checked should return selected option elements // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked // IE8 throws error here and will not see later tests if ( !div.querySelectorAll(":checked").length ) { rbuggyQSA.push(":checked"); } }); assert(function( div ) { // Support: Windows 8 Native Apps // The type and name attributes are restricted during .innerHTML assignment var input = doc.createElement("input"); input.setAttribute( "type", "hidden" ); div.appendChild( input ).setAttribute( "name", "D" ); // Support: IE8 // Enforce case-sensitivity of name attribute if ( div.querySelectorAll("[name=d]").length ) { rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); } // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) // IE8 throws error here and will not see later tests if ( !div.querySelectorAll(":enabled").length ) { rbuggyQSA.push( ":enabled", ":disabled" ); } // Opera 10-11 does not throw on post-comma invalid pseudos div.querySelectorAll("*,:x"); rbuggyQSA.push(",.*:"); }); } if ( (support.matchesSelector = rnative.test( (matches = docElem.matches || docElem.webkitMatchesSelector || docElem.mozMatchesSelector || docElem.oMatchesSelector || docElem.msMatchesSelector) )) ) { assert(function( div ) { // Check to see if it's possible to do matchesSelector // on a disconnected node (IE 9) support.disconnectedMatch = matches.call( div, "div" ); // This should fail with an exception // Gecko does not error, returns false instead matches.call( div, "[s!='']:x" ); rbuggyMatches.push( "!=", pseudos ); }); } rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); /* Contains ---------------------------------------------------------------------- */ hasCompare = rnative.test( docElem.compareDocumentPosition ); // Element contains another // Purposefully does not implement inclusive descendent // As in, an element does not contain itself contains = hasCompare || rnative.test( docElem.contains ) ? function( a, b ) { var adown = a.nodeType === 9 ? a.documentElement : a, bup = b && b.parentNode; return a === bup || !!( bup && bup.nodeType === 1 && ( adown.contains ? adown.contains( bup ) : a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 )); } : function( a, b ) { if ( b ) { while ( (b = b.parentNode) ) { if ( b === a ) { return true; } } } return false; }; /* Sorting ---------------------------------------------------------------------- */ // Document order sorting sortOrder = hasCompare ? function( a, b ) { // Flag for duplicate removal if ( a === b ) { hasDuplicate = true; return 0; } // Sort on method existence if only one input has compareDocumentPosition var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; if ( compare ) { return compare; } // Calculate position if both inputs belong to the same document compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? a.compareDocumentPosition( b ) : // Otherwise we know they are disconnected 1; // Disconnected nodes if ( compare & 1 || (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { // Choose the first element that is related to our preferred document if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { return -1; } if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { return 1; } // Maintain original order return sortInput ? ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : 0; } return compare & 4 ? -1 : 1; } : function( a, b ) { // Exit early if the nodes are identical if ( a === b ) { hasDuplicate = true; return 0; } var cur, i = 0, aup = a.parentNode, bup = b.parentNode, ap = [ a ], bp = [ b ]; // Parentless nodes are either documents or disconnected if ( !aup || !bup ) { return a === doc ? -1 : b === doc ? 1 : aup ? -1 : bup ? 1 : sortInput ? ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : 0; // If the nodes are siblings, we can do a quick check } else if ( aup === bup ) { return siblingCheck( a, b ); } // Otherwise we need full lists of their ancestors for comparison cur = a; while ( (cur = cur.parentNode) ) { ap.unshift( cur ); } cur = b; while ( (cur = cur.parentNode) ) { bp.unshift( cur ); } // Walk down the tree looking for a discrepancy while ( ap[i] === bp[i] ) { i++; } return i ? // Do a sibling check if the nodes have a common ancestor siblingCheck( ap[i], bp[i] ) : // Otherwise nodes in our document sort first ap[i] === preferredDoc ? -1 : bp[i] === preferredDoc ? 1 : 0; }; return doc; }; Sizzle.matches = function( expr, elements ) { return Sizzle( expr, null, null, elements ); }; Sizzle.matchesSelector = function( elem, expr ) { // Set document vars if needed if ( ( elem.ownerDocument || elem ) !== document ) { setDocument( elem ); } // Make sure that attribute selectors are quoted expr = expr.replace( rattributeQuotes, "='$1']" ); if ( support.matchesSelector && documentIsHTML && ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { try { var ret = matches.call( elem, expr ); // IE 9's matchesSelector returns false on disconnected nodes if ( ret || support.disconnectedMatch || // As well, disconnected nodes are said to be in a document // fragment in IE 9 elem.document && elem.document.nodeType !== 11 ) { return ret; } } catch(e) {} } return Sizzle( expr, document, null, [ elem ] ).length > 0; }; Sizzle.contains = function( context, elem ) { // Set document vars if needed if ( ( context.ownerDocument || context ) !== document ) { setDocument( context ); } return contains( context, elem ); }; Sizzle.attr = function( elem, name ) { // Set document vars if needed if ( ( elem.ownerDocument || elem ) !== document ) { setDocument( elem ); } var fn = Expr.attrHandle[ name.toLowerCase() ], // Don't get fooled by Object.prototype properties (jQuery #13807) val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? fn( elem, name, !documentIsHTML ) : undefined; return val !== undefined ? val : support.attributes || !documentIsHTML ? elem.getAttribute( name ) : (val = elem.getAttributeNode(name)) && val.specified ? val.value : null; }; Sizzle.error = function( msg ) { throw new Error( "Syntax error, unrecognized expression: " + msg ); }; /** * Document sorting and removing duplicates * @param {ArrayLike} results */ Sizzle.uniqueSort = function( results ) { var elem, duplicates = [], j = 0, i = 0; // Unless we *know* we can detect duplicates, assume their presence hasDuplicate = !support.detectDuplicates; sortInput = !support.sortStable && results.slice( 0 ); results.sort( sortOrder ); if ( hasDuplicate ) { while ( (elem = results[i++]) ) { if ( elem === results[ i ] ) { j = duplicates.push( i ); } } while ( j-- ) { results.splice( duplicates[ j ], 1 ); } } // Clear input after sorting to release objects // See https://github.com/jquery/sizzle/pull/225 sortInput = null; return results; }; /** * Utility function for retrieving the text value of an array of DOM nodes * @param {Array|Element} elem */ getText = Sizzle.getText = function( elem ) { var node, ret = "", i = 0, nodeType = elem.nodeType; if ( !nodeType ) { // If no nodeType, this is expected to be an array while ( (node = elem[i++]) ) { // Do not traverse comment nodes ret += getText( node ); } } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { // Use textContent for elements // innerText usage removed for consistency of new lines (jQuery #11153) if ( typeof elem.textContent === "string" ) { return elem.textContent; } else { // Traverse its children for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { ret += getText( elem ); } } } else if ( nodeType === 3 || nodeType === 4 ) { return elem.nodeValue; } // Do not include comment or processing instruction nodes return ret; }; Expr = Sizzle.selectors = { // Can be adjusted by the user cacheLength: 50, createPseudo: markFunction, match: matchExpr, attrHandle: {}, find: {}, relative: { ">": { dir: "parentNode", first: true }, " ": { dir: "parentNode" }, "+": { dir: "previousSibling", first: true }, "~": { dir: "previousSibling" } }, preFilter: { "ATTR": function( match ) { match[1] = match[1].replace( runescape, funescape ); // Move the given value to match[3] whether quoted or unquoted match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape ); if ( match[2] === "~=" ) { match[3] = " " + match[3] + " "; } return match.slice( 0, 4 ); }, "CHILD": function( match ) { /* matches from matchExpr["CHILD"] 1 type (only|nth|...) 2 what (child|of-type) 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) 4 xn-component of xn+y argument ([+-]?\d*n|) 5 sign of xn-component 6 x of xn-component 7 sign of y-component 8 y of y-component */ match[1] = match[1].toLowerCase(); if ( match[1].slice( 0, 3 ) === "nth" ) { // nth-* requires argument if ( !match[3] ) { Sizzle.error( match[0] ); } // numeric x and y parameters for Expr.filter.CHILD // remember that false/true cast respectively to 0/1 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); // other types prohibit arguments } else if ( match[3] ) { Sizzle.error( match[0] ); } return match; }, "PSEUDO": function( match ) { var excess, unquoted = !match[6] && match[2]; if ( matchExpr["CHILD"].test( match[0] ) ) { return null; } // Accept quoted arguments as-is if ( match[3] ) { match[2] = match[4] || match[5] || ""; // Strip excess characters from unquoted arguments } else if ( unquoted && rpseudo.test( unquoted ) && // Get excess from tokenize (recursively) (excess = tokenize( unquoted, true )) && // advance to the next closing parenthesis (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { // excess is a negative index match[0] = match[0].slice( 0, excess ); match[2] = unquoted.slice( 0, excess ); } // Return only captures needed by the pseudo filter method (type and argument) return match.slice( 0, 3 ); } }, filter: { "TAG": function( nodeNameSelector ) { var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); return nodeNameSelector === "*" ? function() { return true; } : function( elem ) { return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; }; }, "CLASS": function( className ) { var pattern = classCache[ className + " " ]; return pattern || (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && classCache( className, function( elem ) { return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" ); }); }, "ATTR": function( name, operator, check ) { return function( elem ) { var result = Sizzle.attr( elem, name ); if ( result == null ) { return operator === "!="; } if ( !operator ) { return true; } result += ""; return operator === "=" ? result === check : operator === "!=" ? result !== check : operator === "^=" ? check && result.indexOf( check ) === 0 : operator === "*=" ? check && result.indexOf( check ) > -1 : operator === "$=" ? check && result.slice( -check.length ) === check : operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : false; }; }, "CHILD": function( type, what, argument, first, last ) { var simple = type.slice( 0, 3 ) !== "nth", forward = type.slice( -4 ) !== "last", ofType = what === "of-type"; return first === 1 && last === 0 ? // Shortcut for :nth-*(n) function( elem ) { return !!elem.parentNode; } : function( elem, context, xml ) { var cache, outerCache, node, diff, nodeIndex, start, dir = simple !== forward ? "nextSibling" : "previousSibling", parent = elem.parentNode, name = ofType && elem.nodeName.toLowerCase(), useCache = !xml && !ofType; if ( parent ) { // :(first|last|only)-(child|of-type) if ( simple ) { while ( dir ) { node = elem; while ( (node = node[ dir ]) ) { if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { return false; } } // Reverse direction for :only-* (if we haven't yet done so) start = dir = type === "only" && !start && "nextSibling"; } return true; } start = [ forward ? parent.firstChild : parent.lastChild ]; // non-xml :nth-child(...) stores cache data on `parent` if ( forward && useCache ) { // Seek `elem` from a previously-cached index outerCache = parent[ expando ] || (parent[ expando ] = {}); cache = outerCache[ type ] || []; nodeIndex = cache[0] === dirruns && cache[1]; diff = cache[0] === dirruns && cache[2]; node = nodeIndex && parent.childNodes[ nodeIndex ]; while ( (node = ++nodeIndex && node && node[ dir ] || // Fallback to seeking `elem` from the start (diff = nodeIndex = 0) || start.pop()) ) { // When found, cache indexes on `parent` and break if ( node.nodeType === 1 && ++diff && node === elem ) { outerCache[ type ] = [ dirruns, nodeIndex, diff ]; break; } } // Use previously-cached element index if available } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { diff = cache[1]; // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...) } else { // Use the same loop as above to seek `elem` from the start while ( (node = ++nodeIndex && node && node[ dir ] || (diff = nodeIndex = 0) || start.pop()) ) { if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { // Cache the index of each encountered element if ( useCache ) { (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; } if ( node === elem ) { break; } } } } // Incorporate the offset, then check against cycle size diff -= last; return diff === first || ( diff % first === 0 && diff / first >= 0 ); } }; }, "PSEUDO": function( pseudo, argument ) { // pseudo-class names are case-insensitive // http://www.w3.org/TR/selectors/#pseudo-classes // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters // Remember that setFilters inherits from pseudos var args, fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || Sizzle.error( "unsupported pseudo: " + pseudo ); // The user may use createPseudo to indicate that // arguments are needed to create the filter function // just as Sizzle does if ( fn[ expando ] ) { return fn( argument ); } // But maintain support for old signatures if ( fn.length > 1 ) { args = [ pseudo, pseudo, "", argument ]; return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? markFunction(function( seed, matches ) { var idx, matched = fn( seed, argument ), i = matched.length; while ( i-- ) { idx = indexOf.call( seed, matched[i] ); seed[ idx ] = !( matches[ idx ] = matched[i] ); } }) : function( elem ) { return fn( elem, 0, args ); }; } return fn; } }, pseudos: { // Potentially complex pseudos "not": markFunction(function( selector ) { // Trim the selector passed to compile // to avoid treating leading and trailing // spaces as combinators var input = [], results = [], matcher = compile( selector.replace( rtrim, "$1" ) ); return matcher[ expando ] ? markFunction(function( seed, matches, context, xml ) { var elem, unmatched = matcher( seed, null, xml, [] ), i = seed.length; // Match elements unmatched by `matcher` while ( i-- ) { if ( (elem = unmatched[i]) ) { seed[i] = !(matches[i] = elem); } } }) : function( elem, context, xml ) { input[0] = elem; matcher( input, null, xml, results ); return !results.pop(); }; }), "has": markFunction(function( selector ) { return function( elem ) { return Sizzle( selector, elem ).length > 0; }; }), "contains": markFunction(function( text ) { return function( elem ) { return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; }; }), // "Whether an element is represented by a :lang() selector // is based solely on the element's language value // being equal to the identifier C, // or beginning with the identifier C immediately followed by "-". // The matching of C against the element's language value is performed case-insensitively. // The identifier C does not have to be a valid language name." // http://www.w3.org/TR/selectors/#lang-pseudo "lang": markFunction( function( lang ) { // lang value must be a valid identifier if ( !ridentifier.test(lang || "") ) { Sizzle.error( "unsupported lang: " + lang ); } lang = lang.replace( runescape, funescape ).toLowerCase(); return function( elem ) { var elemLang; do { if ( (elemLang = documentIsHTML ? elem.lang : elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { elemLang = elemLang.toLowerCase(); return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; } } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); return false; }; }), // Miscellaneous "target": function( elem ) { var hash = window.location && window.location.hash; return hash && hash.slice( 1 ) === elem.id; }, "root": function( elem ) { return elem === docElem; }, "focus": function( elem ) { return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); }, // Boolean properties "enabled": function( elem ) { return elem.disabled === false; }, "disabled": function( elem ) { return elem.disabled === true; }, "checked": function( elem ) { // In CSS3, :checked should return both checked and selected elements // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked var nodeName = elem.nodeName.toLowerCase(); return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); }, "selected": function( elem ) { // Accessing this property makes selected-by-default // options in Safari work properly if ( elem.parentNode ) { elem.parentNode.selectedIndex; } return elem.selected === true; }, // Contents "empty": function( elem ) { // http://www.w3.org/TR/selectors/#empty-pseudo // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), // but not by others (comment: 8; processing instruction: 7; etc.) // nodeType < 6 works because attributes (2) do not appear as children for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { if ( elem.nodeType < 6 ) { return false; } } return true; }, "parent": function( elem ) { return !Expr.pseudos["empty"]( elem ); }, // Element/input types "header": function( elem ) { return rheader.test( elem.nodeName ); }, "input": function( elem ) { return rinputs.test( elem.nodeName ); }, "button": function( elem ) { var name = elem.nodeName.toLowerCase(); return name === "input" && elem.type === "button" || name === "button"; }, "text": function( elem ) { var attr; return elem.nodeName.toLowerCase() === "input" && elem.type === "text" && // Support: IE<8 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); }, // Position-in-collection "first": createPositionalPseudo(function() { return [ 0 ]; }), "last": createPositionalPseudo(function( matchIndexes, length ) { return [ length - 1 ]; }), "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { return [ argument < 0 ? argument + length : argument ]; }), "even": createPositionalPseudo(function( matchIndexes, length ) { var i = 0; for ( ; i < length; i += 2 ) { matchIndexes.push( i ); } return matchIndexes; }), "odd": createPositionalPseudo(function( matchIndexes, length ) { var i = 1; for ( ; i < length; i += 2 ) { matchIndexes.push( i ); } return matchIndexes; }), "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { var i = argument < 0 ? argument + length : argument; for ( ; --i >= 0; ) { matchIndexes.push( i ); } return matchIndexes; }), "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { var i = argument < 0 ? argument + length : argument; for ( ; ++i < length; ) { matchIndexes.push( i ); } return matchIndexes; }) } }; Expr.pseudos["nth"] = Expr.pseudos["eq"]; // Add button/input type pseudos for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { Expr.pseudos[ i ] = createInputPseudo( i ); } for ( i in { submit: true, reset: true } ) { Expr.pseudos[ i ] = createButtonPseudo( i ); } // Easy API for creating new setFilters function setFilters() {} setFilters.prototype = Expr.filters = Expr.pseudos; Expr.setFilters = new setFilters(); tokenize = Sizzle.tokenize = function( selector, parseOnly ) { var matched, match, tokens, type, soFar, groups, preFilters, cached = tokenCache[ selector + " " ]; if ( cached ) { return parseOnly ? 0 : cached.slice( 0 ); } soFar = selector; groups = []; preFilters = Expr.preFilter; while ( soFar ) { // Comma and first run if ( !matched || (match = rcomma.exec( soFar )) ) { if ( match ) { // Don't consume trailing commas as valid soFar = soFar.slice( match[0].length ) || soFar; } groups.push( (tokens = []) ); } matched = false; // Combinators if ( (match = rcombinators.exec( soFar )) ) { matched = match.shift(); tokens.push({ value: matched, // Cast descendant combinators to space type: match[0].replace( rtrim, " " ) }); soFar = soFar.slice( matched.length ); } // Filters for ( type in Expr.filter ) { if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || (match = preFilters[ type ]( match ))) ) { matched = match.shift(); tokens.push({ value: matched, type: type, matches: match }); soFar = soFar.slice( matched.length ); } } if ( !matched ) { break; } } // Return the length of the invalid excess // if we're just parsing // Otherwise, throw an error or return tokens return parseOnly ? soFar.length : soFar ? Sizzle.error( selector ) : // Cache the tokens tokenCache( selector, groups ).slice( 0 ); }; function toSelector( tokens ) { var i = 0, len = tokens.length, selector = ""; for ( ; i < len; i++ ) { selector += tokens[i].value; } return selector; } function addCombinator( matcher, combinator, base ) { var dir = combinator.dir, checkNonElements = base && dir === "parentNode", doneName = done++; return combinator.first ? // Check against closest ancestor/preceding element function( elem, context, xml ) { while ( (elem = elem[ dir ]) ) { if ( elem.nodeType === 1 || checkNonElements ) { return matcher( elem, context, xml ); } } } : // Check against all ancestor/preceding elements function( elem, context, xml ) { var oldCache, outerCache, newCache = [ dirruns, doneName ]; // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching if ( xml ) { while ( (elem = elem[ dir ]) ) { if ( elem.nodeType === 1 || checkNonElements ) { if ( matcher( elem, context, xml ) ) { return true; } } } } else { while ( (elem = elem[ dir ]) ) { if ( elem.nodeType === 1 || checkNonElements ) { outerCache = elem[ expando ] || (elem[ expando ] = {}); if ( (oldCache = outerCache[ dir ]) && oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { // Assign to newCache so results back-propagate to previous elements return (newCache[ 2 ] = oldCache[ 2 ]); } else { // Reuse newcache so results back-propagate to previous elements outerCache[ dir ] = newCache; // A match means we're done; a fail means we have to keep checking if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { return true; } } } } } }; } function elementMatcher( matchers ) { return matchers.length > 1 ? function( elem, context, xml ) { var i = matchers.length; while ( i-- ) { if ( !matchers[i]( elem, context, xml ) ) { return false; } } return true; } : matchers[0]; } function multipleContexts( selector, contexts, results ) { var i = 0, len = contexts.length; for ( ; i < len; i++ ) { Sizzle( selector, contexts[i], results ); } return results; } function condense( unmatched, map, filter, context, xml ) { var elem, newUnmatched = [], i = 0, len = unmatched.length, mapped = map != null; for ( ; i < len; i++ ) { if ( (elem = unmatched[i]) ) { if ( !filter || filter( elem, context, xml ) ) { newUnmatched.push( elem ); if ( mapped ) { map.push( i ); } } } } return newUnmatched; } function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { if ( postFilter && !postFilter[ expando ] ) { postFilter = setMatcher( postFilter ); } if ( postFinder && !postFinder[ expando ] ) { postFinder = setMatcher( postFinder, postSelector ); } return markFunction(function( seed, results, context, xml ) { var temp, i, elem, preMap = [], postMap = [], preexisting = results.length, // Get initial elements from seed or context elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), // Prefilter to get matcher input, preserving a map for seed-results synchronization matcherIn = preFilter && ( seed || !selector ) ? condense( elems, preMap, preFilter, context, xml ) : elems, matcherOut = matcher ? // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, postFinder || ( seed ? preFilter : preexisting || postFilter ) ? // ...intermediate processing is necessary [] : // ...otherwise use results directly results : matcherIn; // Find primary matches if ( matcher ) { matcher( matcherIn, matcherOut, context, xml ); } // Apply postFilter if ( postFilter ) { temp = condense( matcherOut, postMap ); postFilter( temp, [], context, xml ); // Un-match failing elements by moving them back to matcherIn i = temp.length; while ( i-- ) { if ( (elem = temp[i]) ) { matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); } } } if ( seed ) { if ( postFinder || preFilter ) { if ( postFinder ) { // Get the final matcherOut by condensing this intermediate into postFinder contexts temp = []; i = matcherOut.length; while ( i-- ) { if ( (elem = matcherOut[i]) ) { // Restore matcherIn since elem is not yet a final match temp.push( (matcherIn[i] = elem) ); } } postFinder( null, (matcherOut = []), temp, xml ); } // Move matched elements from seed to results to keep them synchronized i = matcherOut.length; while ( i-- ) { if ( (elem = matcherOut[i]) && (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { seed[temp] = !(results[temp] = elem); } } } // Add elements to results, through postFinder if defined } else { matcherOut = condense( matcherOut === results ? matcherOut.splice( preexisting, matcherOut.length ) : matcherOut ); if ( postFinder ) { postFinder( null, results, matcherOut, xml ); } else { push.apply( results, matcherOut ); } } }); } function matcherFromTokens( tokens ) { var checkContext, matcher, j, len = tokens.length, leadingRelative = Expr.relative[ tokens[0].type ], implicitRelative = leadingRelative || Expr.relative[" "], i = leadingRelative ? 1 : 0, // The foundational matcher ensures that elements are reachable from top-level context(s) matchContext = addCombinator( function( elem ) { return elem === checkContext; }, implicitRelative, true ), matchAnyContext = addCombinator( function( elem ) { return indexOf.call( checkContext, elem ) > -1; }, implicitRelative, true ), matchers = [ function( elem, context, xml ) { return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( (checkContext = context).nodeType ? matchContext( elem, context, xml ) : matchAnyContext( elem, context, xml ) ); } ]; for ( ; i < len; i++ ) { if ( (matcher = Expr.relative[ tokens[i].type ]) ) { matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; } else { matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); // Return special upon seeing a positional matcher if ( matcher[ expando ] ) { // Find the next relative operator (if any) for proper handling j = ++i; for ( ; j < len; j++ ) { if ( Expr.relative[ tokens[j].type ] ) { break; } } return setMatcher( i > 1 && elementMatcher( matchers ), i > 1 && toSelector( // If the preceding token was a descendant combinator, insert an implicit any-element `*` tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) ).replace( rtrim, "$1" ), matcher, i < j && matcherFromTokens( tokens.slice( i, j ) ), j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), j < len && toSelector( tokens ) ); } matchers.push( matcher ); } } return elementMatcher( matchers ); } function matcherFromGroupMatchers( elementMatchers, setMatchers ) { var bySet = setMatchers.length > 0, byElement = elementMatchers.length > 0, superMatcher = function( seed, context, xml, results, outermost ) { var elem, j, matcher, matchedCount = 0, i = "0", unmatched = seed && [], setMatched = [], contextBackup = outermostContext, // We must always have either seed elements or outermost context elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), // Use integer dirruns iff this is the outermost matcher dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), len = elems.length; if ( outermost ) { outermostContext = context !== document && context; } // Add elements passing elementMatchers directly to results // Keep `i` a string if there are no elements so `matchedCount` will be "00" below // Support: IE<9, Safari // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id for ( ; i !== len && (elem = elems[i]) != null; i++ ) { if ( byElement && elem ) { j = 0; while ( (matcher = elementMatchers[j++]) ) { if ( matcher( elem, context, xml ) ) { results.push( elem ); break; } } if ( outermost ) { dirruns = dirrunsUnique; } } // Track unmatched elements for set filters if ( bySet ) { // They will have gone through all possible matchers if ( (elem = !matcher && elem) ) { matchedCount--; } // Lengthen the array for every element, matched or not if ( seed ) { unmatched.push( elem ); } } } // Apply set filters to unmatched elements matchedCount += i; if ( bySet && i !== matchedCount ) { j = 0; while ( (matcher = setMatchers[j++]) ) { matcher( unmatched, setMatched, context, xml ); } if ( seed ) { // Reintegrate element matches to eliminate the need for sorting if ( matchedCount > 0 ) { while ( i-- ) { if ( !(unmatched[i] || setMatched[i]) ) { setMatched[i] = pop.call( results ); } } } // Discard index placeholder values to get only actual matches setMatched = condense( setMatched ); } // Add matches to results push.apply( results, setMatched ); // Seedless set matches succeeding multiple successful matchers stipulate sorting if ( outermost && !seed && setMatched.length > 0 && ( matchedCount + setMatchers.length ) > 1 ) { Sizzle.uniqueSort( results ); } } // Override manipulation of globals by nested matchers if ( outermost ) { dirruns = dirrunsUnique; outermostContext = contextBackup; } return unmatched; }; return bySet ? markFunction( superMatcher ) : superMatcher; } compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { var i, setMatchers = [], elementMatchers = [], cached = compilerCache[ selector + " " ]; if ( !cached ) { // Generate a function of recursive functions that can be used to check each element if ( !match ) { match = tokenize( selector ); } i = match.length; while ( i-- ) { cached = matcherFromTokens( match[i] ); if ( cached[ expando ] ) { setMatchers.push( cached ); } else { elementMatchers.push( cached ); } } // Cache the compiled function cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); // Save selector and tokenization cached.selector = selector; } return cached; }; /** * A low-level selection function that works with Sizzle's compiled * selector functions * @param {String|Function} selector A selector or a pre-compiled * selector function built with Sizzle.compile * @param {Element} context * @param {Array} [results] * @param {Array} [seed] A set of elements to match against */ select = Sizzle.select = function( selector, context, results, seed ) { var i, tokens, token, type, find, compiled = typeof selector === "function" && selector, match = !seed && tokenize( (selector = compiled.selector || selector) ); results = results || []; // Try to minimize operations if there is no seed and only one group if ( match.length === 1 ) { // Take a shortcut and set the context if the root selector is an ID tokens = match[0] = match[0].slice( 0 ); if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && support.getById && context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) { context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; if ( !context ) { return results; // Precompiled matchers will still verify ancestry, so step up a level } else if ( compiled ) { context = context.parentNode; } selector = selector.slice( tokens.shift().value.length ); } // Fetch a seed set for right-to-left matching i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; while ( i-- ) { token = tokens[i]; // Abort if we hit a combinator if ( Expr.relative[ (type = token.type) ] ) { break; } if ( (find = Expr.find[ type ]) ) { // Search, expanding context for leading sibling combinators if ( (seed = find( token.matches[0].replace( runescape, funescape ), rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context )) ) { // If seed is empty or no tokens remain, we can return early tokens.splice( i, 1 ); selector = seed.length && toSelector( tokens ); if ( !selector ) { push.apply( results, seed ); return results; } break; } } } } // Compile and execute a filtering function if one is not provided // Provide `match` to avoid retokenization if we modified the selector above ( compiled || compile( selector, match ) )( seed, context, !documentIsHTML, results, rsibling.test( selector ) && testContext( context.parentNode ) || context ); return results; }; // One-time assignments // Sort stability support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; // Support: Chrome<14 // Always assume duplicates if they aren't passed to the comparison function support.detectDuplicates = !!hasDuplicate; // Initialize against the default document setDocument(); // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) // Detached nodes confoundingly follow *each other* support.sortDetached = assert(function( div1 ) { // Should return 1, but returns 4 (following) return div1.compareDocumentPosition( document.createElement("div") ) & 1; }); // Support: IE<8 // Prevent attribute/property "interpolation" // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx if ( !assert(function( div ) { div.innerHTML = ""; return div.firstChild.getAttribute("href") === "#" ; }) ) { addHandle( "type|href|height|width", function( elem, name, isXML ) { if ( !isXML ) { return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); } }); } // Support: IE<9 // Use defaultValue in place of getAttribute("value") if ( !support.attributes || !assert(function( div ) { div.innerHTML = ""; div.firstChild.setAttribute( "value", "" ); return div.firstChild.getAttribute( "value" ) === ""; }) ) { addHandle( "value", function( elem, name, isXML ) { if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { return elem.defaultValue; } }); } // Support: IE<9 // Use getAttributeNode to fetch booleans when getAttribute lies if ( !assert(function( div ) { return div.getAttribute("disabled") == null; }) ) { addHandle( booleans, function( elem, name, isXML ) { var val; if ( !isXML ) { return elem[ name ] === true ? name.toLowerCase() : (val = elem.getAttributeNode( name )) && val.specified ? val.value : null; } }); } return Sizzle; })( window ); jQuery.find = Sizzle; jQuery.expr = Sizzle.selectors; jQuery.expr[":"] = jQuery.expr.pseudos; jQuery.unique = Sizzle.uniqueSort; jQuery.text = Sizzle.getText; jQuery.isXMLDoc = Sizzle.isXML; jQuery.contains = Sizzle.contains; var rneedsContext = jQuery.expr.match.needsContext; var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); var risSimple = /^.[^:#\[\.,]*$/; // Implement the identical functionality for filter and not function winnow( elements, qualifier, not ) { if ( jQuery.isFunction( qualifier ) ) { return jQuery.grep( elements, function( elem, i ) { /* jshint -W018 */ return !!qualifier.call( elem, i, elem ) !== not; }); } if ( qualifier.nodeType ) { return jQuery.grep( elements, function( elem ) { return ( elem === qualifier ) !== not; }); } if ( typeof qualifier === "string" ) { if ( risSimple.test( qualifier ) ) { return jQuery.filter( qualifier, elements, not ); } qualifier = jQuery.filter( qualifier, elements ); } return jQuery.grep( elements, function( elem ) { return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not; }); } jQuery.filter = function( expr, elems, not ) { var elem = elems[ 0 ]; if ( not ) { expr = ":not(" + expr + ")"; } return elems.length === 1 && elem.nodeType === 1 ? jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] : jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { return elem.nodeType === 1; })); }; jQuery.fn.extend({ find: function( selector ) { var i, ret = [], self = this, len = self.length; if ( typeof selector !== "string" ) { return this.pushStack( jQuery( selector ).filter(function() { for ( i = 0; i < len; i++ ) { if ( jQuery.contains( self[ i ], this ) ) { return true; } } }) ); } for ( i = 0; i < len; i++ ) { jQuery.find( selector, self[ i ], ret ); } // Needed because $( selector, context ) becomes $( context ).find( selector ) ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret ); ret.selector = this.selector ? this.selector + " " + selector : selector; return ret; }, filter: function( selector ) { return this.pushStack( winnow(this, selector || [], false) ); }, not: function( selector ) { return this.pushStack( winnow(this, selector || [], true) ); }, is: function( selector ) { return !!winnow( this, // If this is a positional/relative selector, check membership in the returned set // so $("p:first").is("p:last") won't return true for a doc with two "p". typeof selector === "string" && rneedsContext.test( selector ) ? jQuery( selector ) : selector || [], false ).length; } }); // Initialize a jQuery object // A central reference to the root jQuery(document) var rootjQuery, // Use the correct document accordingly with window argument (sandbox) document = window.document, // A simple way to check for HTML strings // Prioritize #id over to avoid XSS via location.hash (#9521) // Strict HTML recognition (#11290: must start with <) rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, init = jQuery.fn.init = function( selector, context ) { var match, elem; // HANDLE: $(""), $(null), $(undefined), $(false) if ( !selector ) { return this; } // Handle HTML strings if ( typeof selector === "string" ) { if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { // Assume that strings that start and end with <> are HTML and skip the regex check match = [ null, selector, null ]; } else { match = rquickExpr.exec( selector ); } // Match html or make sure no context is specified for #id if ( match && (match[1] || !context) ) { // HANDLE: $(html) -> $(array) if ( match[1] ) { context = context instanceof jQuery ? context[0] : context; // scripts is true for back-compat // Intentionally let the error be thrown if parseHTML is not present jQuery.merge( this, jQuery.parseHTML( match[1], context && context.nodeType ? context.ownerDocument || context : document, true ) ); // HANDLE: $(html, props) if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { for ( match in context ) { // Properties of context are called as methods if possible if ( jQuery.isFunction( this[ match ] ) ) { this[ match ]( context[ match ] ); // ...and otherwise set as attributes } else { this.attr( match, context[ match ] ); } } } return this; // HANDLE: $(#id) } else { elem = document.getElementById( match[2] ); // Check parentNode to catch when Blackberry 4.6 returns // nodes that are no longer in the document #6963 if ( elem && elem.parentNode ) { // Handle the case where IE and Opera return items // by name instead of ID if ( elem.id !== match[2] ) { return rootjQuery.find( selector ); } // Otherwise, we inject the element directly into the jQuery object this.length = 1; this[0] = elem; } this.context = document; this.selector = selector; return this; } // HANDLE: $(expr, $(...)) } else if ( !context || context.jquery ) { return ( context || rootjQuery ).find( selector ); // HANDLE: $(expr, context) // (which is just equivalent to: $(context).find(expr) } else { return this.constructor( context ).find( selector ); } // HANDLE: $(DOMElement) } else if ( selector.nodeType ) { this.context = this[0] = selector; this.length = 1; return this; // HANDLE: $(function) // Shortcut for document ready } else if ( jQuery.isFunction( selector ) ) { return typeof rootjQuery.ready !== "undefined" ? rootjQuery.ready( selector ) : // Execute immediately if ready is not present selector( jQuery ); } if ( selector.selector !== undefined ) { this.selector = selector.selector; this.context = selector.context; } return jQuery.makeArray( selector, this ); }; // Give the init function the jQuery prototype for later instantiation init.prototype = jQuery.fn; // Initialize central reference rootjQuery = jQuery( document ); var rparentsprev = /^(?:parents|prev(?:Until|All))/, // methods guaranteed to produce a unique set when starting from a unique set guaranteedUnique = { children: true, contents: true, next: true, prev: true }; jQuery.extend({ dir: function( elem, dir, until ) { var matched = [], cur = elem[ dir ]; while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { if ( cur.nodeType === 1 ) { matched.push( cur ); } cur = cur[dir]; } return matched; }, sibling: function( n, elem ) { var r = []; for ( ; n; n = n.nextSibling ) { if ( n.nodeType === 1 && n !== elem ) { r.push( n ); } } return r; } }); jQuery.fn.extend({ has: function( target ) { var i, targets = jQuery( target, this ), len = targets.length; return this.filter(function() { for ( i = 0; i < len; i++ ) { if ( jQuery.contains( this, targets[i] ) ) { return true; } } }); }, closest: function( selectors, context ) { var cur, i = 0, l = this.length, matched = [], pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ? jQuery( selectors, context || this.context ) : 0; for ( ; i < l; i++ ) { for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) { // Always skip document fragments if ( cur.nodeType < 11 && (pos ? pos.index(cur) > -1 : // Don't pass non-elements to Sizzle cur.nodeType === 1 && jQuery.find.matchesSelector(cur, selectors)) ) { matched.push( cur ); break; } } } return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched ); }, // Determine the position of an element within // the matched set of elements index: function( elem ) { // No argument, return index in parent if ( !elem ) { return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1; } // index in selector if ( typeof elem === "string" ) { return jQuery.inArray( this[0], jQuery( elem ) ); } // Locate the position of the desired element return jQuery.inArray( // If it receives a jQuery object, the first element is used elem.jquery ? elem[0] : elem, this ); }, add: function( selector, context ) { return this.pushStack( jQuery.unique( jQuery.merge( this.get(), jQuery( selector, context ) ) ) ); }, addBack: function( selector ) { return this.add( selector == null ? this.prevObject : this.prevObject.filter(selector) ); } }); function sibling( cur, dir ) { do { cur = cur[ dir ]; } while ( cur && cur.nodeType !== 1 ); return cur; } jQuery.each({ parent: function( elem ) { var parent = elem.parentNode; return parent && parent.nodeType !== 11 ? parent : null; }, parents: function( elem ) { return jQuery.dir( elem, "parentNode" ); }, parentsUntil: function( elem, i, until ) { return jQuery.dir( elem, "parentNode", until ); }, next: function( elem ) { return sibling( elem, "nextSibling" ); }, prev: function( elem ) { return sibling( elem, "previousSibling" ); }, nextAll: function( elem ) { return jQuery.dir( elem, "nextSibling" ); }, prevAll: function( elem ) { return jQuery.dir( elem, "previousSibling" ); }, nextUntil: function( elem, i, until ) { return jQuery.dir( elem, "nextSibling", until ); }, prevUntil: function( elem, i, until ) { return jQuery.dir( elem, "previousSibling", until ); }, siblings: function( elem ) { return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); }, children: function( elem ) { return jQuery.sibling( elem.firstChild ); }, contents: function( elem ) { return jQuery.nodeName( elem, "iframe" ) ? elem.contentDocument || elem.contentWindow.document : jQuery.merge( [], elem.childNodes ); } }, function( name, fn ) { jQuery.fn[ name ] = function( until, selector ) { var ret = jQuery.map( this, fn, until ); if ( name.slice( -5 ) !== "Until" ) { selector = until; } if ( selector && typeof selector === "string" ) { ret = jQuery.filter( selector, ret ); } if ( this.length > 1 ) { // Remove duplicates if ( !guaranteedUnique[ name ] ) { ret = jQuery.unique( ret ); } // Reverse order for parents* and prev-derivatives if ( rparentsprev.test( name ) ) { ret = ret.reverse(); } } return this.pushStack( ret ); }; }); var rnotwhite = (/\S+/g); // String to Object options format cache var optionsCache = {}; // Convert String-formatted options into Object-formatted ones and store in cache function createOptions( options ) { var object = optionsCache[ options ] = {}; jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) { object[ flag ] = true; }); return object; } /* * Create a callback list using the following parameters: * * options: an optional list of space-separated options that will change how * the callback list behaves or a more traditional option object * * By default a callback list will act like an event callback list and can be * "fired" multiple times. * * Possible options: * * once: will ensure the callback list can only be fired once (like a Deferred) * * memory: will keep track of previous values and will call any callback added * after the list has been fired right away with the latest "memorized" * values (like a Deferred) * * unique: will ensure a callback can only be added once (no duplicate in the list) * * stopOnFalse: interrupt callings when a callback returns false * */ jQuery.Callbacks = function( options ) { // Convert options from String-formatted to Object-formatted if needed // (we check in cache first) options = typeof options === "string" ? ( optionsCache[ options ] || createOptions( options ) ) : jQuery.extend( {}, options ); var // Flag to know if list is currently firing firing, // Last fire value (for non-forgettable lists) memory, // Flag to know if list was already fired fired, // End of the loop when firing firingLength, // Index of currently firing callback (modified by remove if needed) firingIndex, // First callback to fire (used internally by add and fireWith) firingStart, // Actual callback list list = [], // Stack of fire calls for repeatable lists stack = !options.once && [], // Fire callbacks fire = function( data ) { memory = options.memory && data; fired = true; firingIndex = firingStart || 0; firingStart = 0; firingLength = list.length; firing = true; for ( ; list && firingIndex < firingLength; firingIndex++ ) { if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) { memory = false; // To prevent further calls using add break; } } firing = false; if ( list ) { if ( stack ) { if ( stack.length ) { fire( stack.shift() ); } } else if ( memory ) { list = []; } else { self.disable(); } } }, // Actual Callbacks object self = { // Add a callback or a collection of callbacks to the list add: function() { if ( list ) { // First, we save the current length var start = list.length; (function add( args ) { jQuery.each( args, function( _, arg ) { var type = jQuery.type( arg ); if ( type === "function" ) { if ( !options.unique || !self.has( arg ) ) { list.push( arg ); } } else if ( arg && arg.length && type !== "string" ) { // Inspect recursively add( arg ); } }); })( arguments ); // Do we need to add the callbacks to the // current firing batch? if ( firing ) { firingLength = list.length; // With memory, if we're not firing then // we should call right away } else if ( memory ) { firingStart = start; fire( memory ); } } return this; }, // Remove a callback from the list remove: function() { if ( list ) { jQuery.each( arguments, function( _, arg ) { var index; while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { list.splice( index, 1 ); // Handle firing indexes if ( firing ) { if ( index <= firingLength ) { firingLength--; } if ( index <= firingIndex ) { firingIndex--; } } } }); } return this; }, // Check if a given callback is in the list. // If no argument is given, return whether or not list has callbacks attached. has: function( fn ) { return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length ); }, // Remove all callbacks from the list empty: function() { list = []; firingLength = 0; return this; }, // Have the list do nothing anymore disable: function() { list = stack = memory = undefined; return this; }, // Is it disabled? disabled: function() { return !list; }, // Lock the list in its current state lock: function() { stack = undefined; if ( !memory ) { self.disable(); } return this; }, // Is it locked? locked: function() { return !stack; }, // Call all callbacks with the given context and arguments fireWith: function( context, args ) { if ( list && ( !fired || stack ) ) { args = args || []; args = [ context, args.slice ? args.slice() : args ]; if ( firing ) { stack.push( args ); } else { fire( args ); } } return this; }, // Call all the callbacks with the given arguments fire: function() { self.fireWith( this, arguments ); return this; }, // To know if the callbacks have already been called at least once fired: function() { return !!fired; } }; return self; }; jQuery.extend({ Deferred: function( func ) { var tuples = [ // action, add listener, listener list, final state [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ], [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ], [ "notify", "progress", jQuery.Callbacks("memory") ] ], state = "pending", promise = { state: function() { return state; }, always: function() { deferred.done( arguments ).fail( arguments ); return this; }, then: function( /* fnDone, fnFail, fnProgress */ ) { var fns = arguments; return jQuery.Deferred(function( newDefer ) { jQuery.each( tuples, function( i, tuple ) { var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ]; // deferred[ done | fail | progress ] for forwarding actions to newDefer deferred[ tuple[1] ](function() { var returned = fn && fn.apply( this, arguments ); if ( returned && jQuery.isFunction( returned.promise ) ) { returned.promise() .done( newDefer.resolve ) .fail( newDefer.reject ) .progress( newDefer.notify ); } else { newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments ); } }); }); fns = null; }).promise(); }, // Get a promise for this deferred // If obj is provided, the promise aspect is added to the object promise: function( obj ) { return obj != null ? jQuery.extend( obj, promise ) : promise; } }, deferred = {}; // Keep pipe for back-compat promise.pipe = promise.then; // Add list-specific methods jQuery.each( tuples, function( i, tuple ) { var list = tuple[ 2 ], stateString = tuple[ 3 ]; // promise[ done | fail | progress ] = list.add promise[ tuple[1] ] = list.add; // Handle state if ( stateString ) { list.add(function() { // state = [ resolved | rejected ] state = stateString; // [ reject_list | resolve_list ].disable; progress_list.lock }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock ); } // deferred[ resolve | reject | notify ] deferred[ tuple[0] ] = function() { deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments ); return this; }; deferred[ tuple[0] + "With" ] = list.fireWith; }); // Make the deferred a promise promise.promise( deferred ); // Call given func if any if ( func ) { func.call( deferred, deferred ); } // All done! return deferred; }, // Deferred helper when: function( subordinate /* , ..., subordinateN */ ) { var i = 0, resolveValues = slice.call( arguments ), length = resolveValues.length, // the count of uncompleted subordinates remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0, // the master Deferred. If resolveValues consist of only a single Deferred, just use that. deferred = remaining === 1 ? subordinate : jQuery.Deferred(), // Update function for both resolve and progress values updateFunc = function( i, contexts, values ) { return function( value ) { contexts[ i ] = this; values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; if ( values === progressValues ) { deferred.notifyWith( contexts, values ); } else if ( !(--remaining) ) { deferred.resolveWith( contexts, values ); } }; }, progressValues, progressContexts, resolveContexts; // add listeners to Deferred subordinates; treat others as resolved if ( length > 1 ) { progressValues = new Array( length ); progressContexts = new Array( length ); resolveContexts = new Array( length ); for ( ; i < length; i++ ) { if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) { resolveValues[ i ].promise() .done( updateFunc( i, resolveContexts, resolveValues ) ) .fail( deferred.reject ) .progress( updateFunc( i, progressContexts, progressValues ) ); } else { --remaining; } } } // if we're not waiting on anything, resolve the master if ( !remaining ) { deferred.resolveWith( resolveContexts, resolveValues ); } return deferred.promise(); } }); // The deferred used on DOM ready var readyList; jQuery.fn.ready = function( fn ) { // Add the callback jQuery.ready.promise().done( fn ); return this; }; jQuery.extend({ // Is the DOM ready to be used? Set to true once it occurs. isReady: false, // A counter to track how many items to wait for before // the ready event fires. See #6781 readyWait: 1, // Hold (or release) the ready event holdReady: function( hold ) { if ( hold ) { jQuery.readyWait++; } else { jQuery.ready( true ); } }, // Handle when the DOM is ready ready: function( wait ) { // Abort if there are pending holds or we're already ready if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { return; } // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). if ( !document.body ) { return setTimeout( jQuery.ready ); } // Remember that the DOM is ready jQuery.isReady = true; // If a normal DOM Ready event fired, decrement, and wait if need be if ( wait !== true && --jQuery.readyWait > 0 ) { return; } // If there are functions bound, to execute readyList.resolveWith( document, [ jQuery ] ); // Trigger any bound ready events if ( jQuery.fn.triggerHandler ) { jQuery( document ).triggerHandler( "ready" ); jQuery( document ).off( "ready" ); } } }); /** * Clean-up method for dom ready events */ function detach() { if ( document.addEventListener ) { document.removeEventListener( "DOMContentLoaded", completed, false ); window.removeEventListener( "load", completed, false ); } else { document.detachEvent( "onreadystatechange", completed ); window.detachEvent( "onload", completed ); } } /** * The ready event handler and self cleanup method */ function completed() { // readyState === "complete" is good enough for us to call the dom ready in oldIE if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) { detach(); jQuery.ready(); } } jQuery.ready.promise = function( obj ) { if ( !readyList ) { readyList = jQuery.Deferred(); // Catch cases where $(document).ready() is called after the browser event has already occurred. // we once tried to use readyState "interactive" here, but it caused issues like the one // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 if ( document.readyState === "complete" ) { // Handle it asynchronously to allow scripts the opportunity to delay ready setTimeout( jQuery.ready ); // Standards-based browsers support DOMContentLoaded } else if ( document.addEventListener ) { // Use the handy event callback document.addEventListener( "DOMContentLoaded", completed, false ); // A fallback to window.onload, that will always work window.addEventListener( "load", completed, false ); // If IE event model is used } else { // Ensure firing before onload, maybe late but safe also for iframes document.attachEvent( "onreadystatechange", completed ); // A fallback to window.onload, that will always work window.attachEvent( "onload", completed ); // If IE and not a frame // continually check to see if the document is ready var top = false; try { top = window.frameElement == null && document.documentElement; } catch(e) {} if ( top && top.doScroll ) { (function doScrollCheck() { if ( !jQuery.isReady ) { try { // Use the trick by Diego Perini // http://javascript.nwbox.com/IEContentLoaded/ top.doScroll("left"); } catch(e) { return setTimeout( doScrollCheck, 50 ); } // detach all dom ready events detach(); // and execute any waiting functions jQuery.ready(); } })(); } } } return readyList.promise( obj ); }; var strundefined = typeof undefined; // Support: IE<9 // Iteration over object's inherited properties before its own var i; for ( i in jQuery( support ) ) { break; } support.ownLast = i !== "0"; // Note: most support tests are defined in their respective modules. // false until the test is run support.inlineBlockNeedsLayout = false; // Execute ASAP in case we need to set body.style.zoom jQuery(function() { // Minified: var a,b,c,d var val, div, body, container; body = document.getElementsByTagName( "body" )[ 0 ]; if ( !body || !body.style ) { // Return for frameset docs that don't have a body return; } // Setup div = document.createElement( "div" ); container = document.createElement( "div" ); container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px"; body.appendChild( container ).appendChild( div ); if ( typeof div.style.zoom !== strundefined ) { // Support: IE<8 // Check if natively block-level elements act like inline-block // elements when setting their display to 'inline' and giving // them layout div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1"; support.inlineBlockNeedsLayout = val = div.offsetWidth === 3; if ( val ) { // Prevent IE 6 from affecting layout for positioned elements #11048 // Prevent IE from shrinking the body in IE 7 mode #12869 // Support: IE<8 body.style.zoom = 1; } } body.removeChild( container ); }); (function() { var div = document.createElement( "div" ); // Execute the test only if not already executed in another module. if (support.deleteExpando == null) { // Support: IE<9 support.deleteExpando = true; try { delete div.test; } catch( e ) { support.deleteExpando = false; } } // Null elements to avoid leaks in IE. div = null; })(); /** * Determines whether an object can have data */ jQuery.acceptData = function( elem ) { var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ], nodeType = +elem.nodeType || 1; // Do not set data on non-element DOM nodes because it will not be cleared (#8335). return nodeType !== 1 && nodeType !== 9 ? false : // Nodes accept data unless otherwise specified; rejection can be conditional !noData || noData !== true && elem.getAttribute("classid") === noData; }; var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, rmultiDash = /([A-Z])/g; function dataAttr( elem, key, data ) { // If nothing was found internally, try to fetch any // data from the HTML5 data-* attribute if ( data === undefined && elem.nodeType === 1 ) { var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); data = elem.getAttribute( name ); if ( typeof data === "string" ) { try { data = data === "true" ? true : data === "false" ? false : data === "null" ? null : // Only convert to a number if it doesn't change the string +data + "" === data ? +data : rbrace.test( data ) ? jQuery.parseJSON( data ) : data; } catch( e ) {} // Make sure we set the data so it isn't changed later jQuery.data( elem, key, data ); } else { data = undefined; } } return data; } // checks a cache object for emptiness function isEmptyDataObject( obj ) { var name; for ( name in obj ) { // if the public data object is empty, the private is still empty if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { continue; } if ( name !== "toJSON" ) { return false; } } return true; } function internalData( elem, name, data, pvt /* Internal Use Only */ ) { if ( !jQuery.acceptData( elem ) ) { return; } var ret, thisCache, internalKey = jQuery.expando, // We have to handle DOM nodes and JS objects differently because IE6-7 // can't GC object references properly across the DOM-JS boundary isNode = elem.nodeType, // Only DOM nodes need the global jQuery cache; JS object data is // attached directly to the object so GC can occur automatically cache = isNode ? jQuery.cache : elem, // Only defining an ID for JS objects if its cache already exists allows // the code to shortcut on the same path as a DOM node with no cache id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; // Avoid doing any more work than we need to when trying to get data on an // object that has no data at all if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) { return; } if ( !id ) { // Only DOM nodes need a new unique ID for each element since their data // ends up in the global cache if ( isNode ) { id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++; } else { id = internalKey; } } if ( !cache[ id ] ) { // Avoid exposing jQuery metadata on plain JS objects when the object // is serialized using JSON.stringify cache[ id ] = isNode ? {} : { toJSON: jQuery.noop }; } // An object can be passed to jQuery.data instead of a key/value pair; this gets // shallow copied over onto the existing cache if ( typeof name === "object" || typeof name === "function" ) { if ( pvt ) { cache[ id ] = jQuery.extend( cache[ id ], name ); } else { cache[ id ].data = jQuery.extend( cache[ id ].data, name ); } } thisCache = cache[ id ]; // jQuery data() is stored in a separate object inside the object's internal data // cache in order to avoid key collisions between internal data and user-defined // data. if ( !pvt ) { if ( !thisCache.data ) { thisCache.data = {}; } thisCache = thisCache.data; } if ( data !== undefined ) { thisCache[ jQuery.camelCase( name ) ] = data; } // Check for both converted-to-camel and non-converted data property names // If a data property was specified if ( typeof name === "string" ) { // First Try to find as-is property data ret = thisCache[ name ]; // Test for null|undefined property data if ( ret == null ) { // Try to find the camelCased property ret = thisCache[ jQuery.camelCase( name ) ]; } } else { ret = thisCache; } return ret; } function internalRemoveData( elem, name, pvt ) { if ( !jQuery.acceptData( elem ) ) { return; } var thisCache, i, isNode = elem.nodeType, // See jQuery.data for more information cache = isNode ? jQuery.cache : elem, id = isNode ? elem[ jQuery.expando ] : jQuery.expando; // If there is already no cache entry for this object, there is no // purpose in continuing if ( !cache[ id ] ) { return; } if ( name ) { thisCache = pvt ? cache[ id ] : cache[ id ].data; if ( thisCache ) { // Support array or space separated string names for data keys if ( !jQuery.isArray( name ) ) { // try the string as a key before any manipulation if ( name in thisCache ) { name = [ name ]; } else { // split the camel cased version by spaces unless a key with the spaces exists name = jQuery.camelCase( name ); if ( name in thisCache ) { name = [ name ]; } else { name = name.split(" "); } } } else { // If "name" is an array of keys... // When data is initially created, via ("key", "val") signature, // keys will be converted to camelCase. // Since there is no way to tell _how_ a key was added, remove // both plain key and camelCase key. #12786 // This will only penalize the array argument path. name = name.concat( jQuery.map( name, jQuery.camelCase ) ); } i = name.length; while ( i-- ) { delete thisCache[ name[i] ]; } // If there is no data left in the cache, we want to continue // and let the cache object itself get destroyed if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) { return; } } } // See jQuery.data for more information if ( !pvt ) { delete cache[ id ].data; // Don't destroy the parent cache unless the internal data object // had been the only thing left in it if ( !isEmptyDataObject( cache[ id ] ) ) { return; } } // Destroy the cache if ( isNode ) { jQuery.cleanData( [ elem ], true ); // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080) /* jshint eqeqeq: false */ } else if ( support.deleteExpando || cache != cache.window ) { /* jshint eqeqeq: true */ delete cache[ id ]; // When all else fails, null } else { cache[ id ] = null; } } jQuery.extend({ cache: {}, // The following elements (space-suffixed to avoid Object.prototype collisions) // throw uncatchable exceptions if you attempt to set expando properties noData: { "applet ": true, "embed ": true, // ...but Flash objects (which have this classid) *can* handle expandos "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" }, hasData: function( elem ) { elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; return !!elem && !isEmptyDataObject( elem ); }, data: function( elem, name, data ) { return internalData( elem, name, data ); }, removeData: function( elem, name ) { return internalRemoveData( elem, name ); }, // For internal use only. _data: function( elem, name, data ) { return internalData( elem, name, data, true ); }, _removeData: function( elem, name ) { return internalRemoveData( elem, name, true ); } }); jQuery.fn.extend({ data: function( key, value ) { var i, name, data, elem = this[0], attrs = elem && elem.attributes; // Special expections of .data basically thwart jQuery.access, // so implement the relevant behavior ourselves // Gets all values if ( key === undefined ) { if ( this.length ) { data = jQuery.data( elem ); if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { i = attrs.length; while ( i-- ) { // Support: IE11+ // The attrs elements can be null (#14894) if ( attrs[ i ] ) { name = attrs[ i ].name; if ( name.indexOf( "data-" ) === 0 ) { name = jQuery.camelCase( name.slice(5) ); dataAttr( elem, name, data[ name ] ); } } } jQuery._data( elem, "parsedAttrs", true ); } } return data; } // Sets multiple values if ( typeof key === "object" ) { return this.each(function() { jQuery.data( this, key ); }); } return arguments.length > 1 ? // Sets one value this.each(function() { jQuery.data( this, key, value ); }) : // Gets one value // Try to fetch any internally stored data first elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined; }, removeData: function( key ) { return this.each(function() { jQuery.removeData( this, key ); }); } }); jQuery.extend({ queue: function( elem, type, data ) { var queue; if ( elem ) { type = ( type || "fx" ) + "queue"; queue = jQuery._data( elem, type ); // Speed up dequeue by getting out quickly if this is just a lookup if ( data ) { if ( !queue || jQuery.isArray(data) ) { queue = jQuery._data( elem, type, jQuery.makeArray(data) ); } else { queue.push( data ); } } return queue || []; } }, dequeue: function( elem, type ) { type = type || "fx"; var queue = jQuery.queue( elem, type ), startLength = queue.length, fn = queue.shift(), hooks = jQuery._queueHooks( elem, type ), next = function() { jQuery.dequeue( elem, type ); }; // If the fx queue is dequeued, always remove the progress sentinel if ( fn === "inprogress" ) { fn = queue.shift(); startLength--; } if ( fn ) { // Add a progress sentinel to prevent the fx queue from being // automatically dequeued if ( type === "fx" ) { queue.unshift( "inprogress" ); } // clear up the last queue stop function delete hooks.stop; fn.call( elem, next, hooks ); } if ( !startLength && hooks ) { hooks.empty.fire(); } }, // not intended for public consumption - generates a queueHooks object, or returns the current one _queueHooks: function( elem, type ) { var key = type + "queueHooks"; return jQuery._data( elem, key ) || jQuery._data( elem, key, { empty: jQuery.Callbacks("once memory").add(function() { jQuery._removeData( elem, type + "queue" ); jQuery._removeData( elem, key ); }) }); } }); jQuery.fn.extend({ queue: function( type, data ) { var setter = 2; if ( typeof type !== "string" ) { data = type; type = "fx"; setter--; } if ( arguments.length < setter ) { return jQuery.queue( this[0], type ); } return data === undefined ? this : this.each(function() { var queue = jQuery.queue( this, type, data ); // ensure a hooks for this queue jQuery._queueHooks( this, type ); if ( type === "fx" && queue[0] !== "inprogress" ) { jQuery.dequeue( this, type ); } }); }, dequeue: function( type ) { return this.each(function() { jQuery.dequeue( this, type ); }); }, clearQueue: function( type ) { return this.queue( type || "fx", [] ); }, // Get a promise resolved when queues of a certain type // are emptied (fx is the type by default) promise: function( type, obj ) { var tmp, count = 1, defer = jQuery.Deferred(), elements = this, i = this.length, resolve = function() { if ( !( --count ) ) { defer.resolveWith( elements, [ elements ] ); } }; if ( typeof type !== "string" ) { obj = type; type = undefined; } type = type || "fx"; while ( i-- ) { tmp = jQuery._data( elements[ i ], type + "queueHooks" ); if ( tmp && tmp.empty ) { count++; tmp.empty.add( resolve ); } } resolve(); return defer.promise( obj ); } }); var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source; var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; var isHidden = function( elem, el ) { // isHidden might be called from jQuery#filter function; // in that case, element will be second argument elem = el || elem; return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem ); }; // Multifunctional method to get and set values of a collection // The value/s can optionally be executed if it's a function var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { var i = 0, length = elems.length, bulk = key == null; // Sets many values if ( jQuery.type( key ) === "object" ) { chainable = true; for ( i in key ) { jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); } // Sets one value } else if ( value !== undefined ) { chainable = true; if ( !jQuery.isFunction( value ) ) { raw = true; } if ( bulk ) { // Bulk operations run against the entire set if ( raw ) { fn.call( elems, value ); fn = null; // ...except when executing function values } else { bulk = fn; fn = function( elem, key, value ) { return bulk.call( jQuery( elem ), value ); }; } } if ( fn ) { for ( ; i < length; i++ ) { fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); } } } return chainable ? elems : // Gets bulk ? fn.call( elems ) : length ? fn( elems[0], key ) : emptyGet; }; var rcheckableType = (/^(?:checkbox|radio)$/i); (function() { // Minified: var a,b,c var input = document.createElement( "input" ), div = document.createElement( "div" ), fragment = document.createDocumentFragment(); // Setup div.innerHTML = "
a"; // IE strips leading whitespace when .innerHTML is used support.leadingWhitespace = div.firstChild.nodeType === 3; // Make sure that tbody elements aren't automatically inserted // IE will insert them into empty tables support.tbody = !div.getElementsByTagName( "tbody" ).length; // Make sure that link elements get serialized correctly by innerHTML // This requires a wrapper element in IE support.htmlSerialize = !!div.getElementsByTagName( "link" ).length; // Makes sure cloning an html5 element does not cause problems // Where outerHTML is undefined, this still works support.html5Clone = document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav>"; // Check if a disconnected checkbox will retain its checked // value of true after appended to the DOM (IE6/7) input.type = "checkbox"; input.checked = true; fragment.appendChild( input ); support.appendChecked = input.checked; // Make sure textarea (and checkbox) defaultValue is properly cloned // Support: IE6-IE11+ div.innerHTML = ""; support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; // #11217 - WebKit loses check when the name is after the checked attribute fragment.appendChild( div ); div.innerHTML = ""; // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 // old WebKit doesn't clone checked state correctly in fragments support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; // Support: IE<9 // Opera does not clone events (and typeof div.attachEvent === undefined). // IE9-10 clones events bound via attachEvent, but they don't trigger with .click() support.noCloneEvent = true; if ( div.attachEvent ) { div.attachEvent( "onclick", function() { support.noCloneEvent = false; }); div.cloneNode( true ).click(); } // Execute the test only if not already executed in another module. if (support.deleteExpando == null) { // Support: IE<9 support.deleteExpando = true; try { delete div.test; } catch( e ) { support.deleteExpando = false; } } })(); (function() { var i, eventName, div = document.createElement( "div" ); // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event) for ( i in { submit: true, change: true, focusin: true }) { eventName = "on" + i; if ( !(support[ i + "Bubbles" ] = eventName in window) ) { // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP) div.setAttribute( eventName, "t" ); support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false; } } // Null elements to avoid leaks in IE. div = null; })(); var rformElems = /^(?:input|select|textarea)$/i, rkeyEvent = /^key/, rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/, rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; function returnTrue() { return true; } function returnFalse() { return false; } function safeActiveElement() { try { return document.activeElement; } catch ( err ) { } } /* * Helper functions for managing events -- not part of the public interface. * Props to Dean Edwards' addEvent library for many of the ideas. */ jQuery.event = { global: {}, add: function( elem, types, handler, data, selector ) { var tmp, events, t, handleObjIn, special, eventHandle, handleObj, handlers, type, namespaces, origType, elemData = jQuery._data( elem ); // Don't attach events to noData or text/comment nodes (but allow plain objects) if ( !elemData ) { return; } // Caller can pass in an object of custom data in lieu of the handler if ( handler.handler ) { handleObjIn = handler; handler = handleObjIn.handler; selector = handleObjIn.selector; } // Make sure that the handler has a unique ID, used to find/remove it later if ( !handler.guid ) { handler.guid = jQuery.guid++; } // Init the element's event structure and main handler, if this is the first if ( !(events = elemData.events) ) { events = elemData.events = {}; } if ( !(eventHandle = elemData.handle) ) { eventHandle = elemData.handle = function( e ) { // Discard the second event of a jQuery.event.trigger() and // when an event is called after a page has unloaded return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ? jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : undefined; }; // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events eventHandle.elem = elem; } // Handle multiple events separated by a space types = ( types || "" ).match( rnotwhite ) || [ "" ]; t = types.length; while ( t-- ) { tmp = rtypenamespace.exec( types[t] ) || []; type = origType = tmp[1]; namespaces = ( tmp[2] || "" ).split( "." ).sort(); // There *must* be a type, no attaching namespace-only handlers if ( !type ) { continue; } // If event changes its type, use the special event handlers for the changed type special = jQuery.event.special[ type ] || {}; // If selector defined, determine special event api type, otherwise given type type = ( selector ? special.delegateType : special.bindType ) || type; // Update special based on newly reset type special = jQuery.event.special[ type ] || {}; // handleObj is passed to all event handlers handleObj = jQuery.extend({ type: type, origType: origType, data: data, handler: handler, guid: handler.guid, selector: selector, needsContext: selector && jQuery.expr.match.needsContext.test( selector ), namespace: namespaces.join(".") }, handleObjIn ); // Init the event handler queue if we're the first if ( !(handlers = events[ type ]) ) { handlers = events[ type ] = []; handlers.delegateCount = 0; // Only use addEventListener/attachEvent if the special events handler returns false if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { // Bind the global event handler to the element if ( elem.addEventListener ) { elem.addEventListener( type, eventHandle, false ); } else if ( elem.attachEvent ) { elem.attachEvent( "on" + type, eventHandle ); } } } if ( special.add ) { special.add.call( elem, handleObj ); if ( !handleObj.handler.guid ) { handleObj.handler.guid = handler.guid; } } // Add to the element's handler list, delegates in front if ( selector ) { handlers.splice( handlers.delegateCount++, 0, handleObj ); } else { handlers.push( handleObj ); } // Keep track of which events have ever been used, for event optimization jQuery.event.global[ type ] = true; } // Nullify elem to prevent memory leaks in IE elem = null; }, // Detach an event or set of events from an element remove: function( elem, types, handler, selector, mappedTypes ) { var j, handleObj, tmp, origCount, t, events, special, handlers, type, namespaces, origType, elemData = jQuery.hasData( elem ) && jQuery._data( elem ); if ( !elemData || !(events = elemData.events) ) { return; } // Once for each type.namespace in types; type may be omitted types = ( types || "" ).match( rnotwhite ) || [ "" ]; t = types.length; while ( t-- ) { tmp = rtypenamespace.exec( types[t] ) || []; type = origType = tmp[1]; namespaces = ( tmp[2] || "" ).split( "." ).sort(); // Unbind all events (on this namespace, if provided) for the element if ( !type ) { for ( type in events ) { jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); } continue; } special = jQuery.event.special[ type ] || {}; type = ( selector ? special.delegateType : special.bindType ) || type; handlers = events[ type ] || []; tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ); // Remove matching events origCount = j = handlers.length; while ( j-- ) { handleObj = handlers[ j ]; if ( ( mappedTypes || origType === handleObj.origType ) && ( !handler || handler.guid === handleObj.guid ) && ( !tmp || tmp.test( handleObj.namespace ) ) && ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { handlers.splice( j, 1 ); if ( handleObj.selector ) { handlers.delegateCount--; } if ( special.remove ) { special.remove.call( elem, handleObj ); } } } // Remove generic event handler if we removed something and no more handlers exist // (avoids potential for endless recursion during removal of special event handlers) if ( origCount && !handlers.length ) { if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) { jQuery.removeEvent( elem, type, elemData.handle ); } delete events[ type ]; } } // Remove the expando if it's no longer used if ( jQuery.isEmptyObject( events ) ) { delete elemData.handle; // removeData also checks for emptiness and clears the expando if empty // so use it instead of delete jQuery._removeData( elem, "events" ); } }, trigger: function( event, data, elem, onlyHandlers ) { var handle, ontype, cur, bubbleType, special, tmp, i, eventPath = [ elem || document ], type = hasOwn.call( event, "type" ) ? event.type : event, namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : []; cur = tmp = elem = elem || document; // Don't do events on text and comment nodes if ( elem.nodeType === 3 || elem.nodeType === 8 ) { return; } // focus/blur morphs to focusin/out; ensure we're not firing them right now if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { return; } if ( type.indexOf(".") >= 0 ) { // Namespaced trigger; create a regexp to match event type in handle() namespaces = type.split("."); type = namespaces.shift(); namespaces.sort(); } ontype = type.indexOf(":") < 0 && "on" + type; // Caller can pass in a jQuery.Event object, Object, or just an event type string event = event[ jQuery.expando ] ? event : new jQuery.Event( type, typeof event === "object" && event ); // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) event.isTrigger = onlyHandlers ? 2 : 3; event.namespace = namespaces.join("."); event.namespace_re = event.namespace ? new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) : null; // Clean up the event in case it is being reused event.result = undefined; if ( !event.target ) { event.target = elem; } // Clone any incoming data and prepend the event, creating the handler arg list data = data == null ? [ event ] : jQuery.makeArray( data, [ event ] ); // Allow special events to draw outside the lines special = jQuery.event.special[ type ] || {}; if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { return; } // Determine event propagation path in advance, per W3C events spec (#9951) // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { bubbleType = special.delegateType || type; if ( !rfocusMorph.test( bubbleType + type ) ) { cur = cur.parentNode; } for ( ; cur; cur = cur.parentNode ) { eventPath.push( cur ); tmp = cur; } // Only add window if we got to document (e.g., not plain obj or detached DOM) if ( tmp === (elem.ownerDocument || document) ) { eventPath.push( tmp.defaultView || tmp.parentWindow || window ); } } // Fire handlers on the event path i = 0; while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) { event.type = i > 1 ? bubbleType : special.bindType || type; // jQuery handler handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); if ( handle ) { handle.apply( cur, data ); } // Native handler handle = ontype && cur[ ontype ]; if ( handle && handle.apply && jQuery.acceptData( cur ) ) { event.result = handle.apply( cur, data ); if ( event.result === false ) { event.preventDefault(); } } } event.type = type; // If nobody prevented the default action, do it now if ( !onlyHandlers && !event.isDefaultPrevented() ) { if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) && jQuery.acceptData( elem ) ) { // Call a native DOM method on the target with the same name name as the event. // Can't use an .isFunction() check here because IE6/7 fails that test. // Don't do default actions on window, that's where global variables be (#6170) if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) { // Don't re-trigger an onFOO event when we call its FOO() method tmp = elem[ ontype ]; if ( tmp ) { elem[ ontype ] = null; } // Prevent re-triggering of the same event, since we already bubbled it above jQuery.event.triggered = type; try { elem[ type ](); } catch ( e ) { // IE<9 dies on focus/blur to hidden element (#1486,#12518) // only reproducible on winXP IE8 native, not IE9 in IE8 mode } jQuery.event.triggered = undefined; if ( tmp ) { elem[ ontype ] = tmp; } } } } return event.result; }, dispatch: function( event ) { // Make a writable jQuery.Event from the native event object event = jQuery.event.fix( event ); var i, ret, handleObj, matched, j, handlerQueue = [], args = slice.call( arguments ), handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [], special = jQuery.event.special[ event.type ] || {}; // Use the fix-ed jQuery.Event rather than the (read-only) native event args[0] = event; event.delegateTarget = this; // Call the preDispatch hook for the mapped type, and let it bail if desired if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { return; } // Determine handlers handlerQueue = jQuery.event.handlers.call( this, event, handlers ); // Run delegates first; they may want to stop propagation beneath us i = 0; while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) { event.currentTarget = matched.elem; j = 0; while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { // Triggered event must either 1) have no namespace, or // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { event.handleObj = handleObj; event.data = handleObj.data; ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) .apply( matched.elem, args ); if ( ret !== undefined ) { if ( (event.result = ret) === false ) { event.preventDefault(); event.stopPropagation(); } } } } } // Call the postDispatch hook for the mapped type if ( special.postDispatch ) { special.postDispatch.call( this, event ); } return event.result; }, handlers: function( event, handlers ) { var sel, handleObj, matches, i, handlerQueue = [], delegateCount = handlers.delegateCount, cur = event.target; // Find delegate handlers // Black-hole SVG instance trees (#13180) // Avoid non-left-click bubbling in Firefox (#3861) if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) { /* jshint eqeqeq: false */ for ( ; cur != this; cur = cur.parentNode || this ) { /* jshint eqeqeq: true */ // Don't check non-elements (#13208) // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) { matches = []; for ( i = 0; i < delegateCount; i++ ) { handleObj = handlers[ i ]; // Don't conflict with Object.prototype properties (#13203) sel = handleObj.selector + " "; if ( matches[ sel ] === undefined ) { matches[ sel ] = handleObj.needsContext ? jQuery( sel, this ).index( cur ) >= 0 : jQuery.find( sel, this, null, [ cur ] ).length; } if ( matches[ sel ] ) { matches.push( handleObj ); } } if ( matches.length ) { handlerQueue.push({ elem: cur, handlers: matches }); } } } } // Add the remaining (directly-bound) handlers if ( delegateCount < handlers.length ) { handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) }); } return handlerQueue; }, fix: function( event ) { if ( event[ jQuery.expando ] ) { return event; } // Create a writable copy of the event object and normalize some properties var i, prop, copy, type = event.type, originalEvent = event, fixHook = this.fixHooks[ type ]; if ( !fixHook ) { this.fixHooks[ type ] = fixHook = rmouseEvent.test( type ) ? this.mouseHooks : rkeyEvent.test( type ) ? this.keyHooks : {}; } copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; event = new jQuery.Event( originalEvent ); i = copy.length; while ( i-- ) { prop = copy[ i ]; event[ prop ] = originalEvent[ prop ]; } // Support: IE<9 // Fix target property (#1925) if ( !event.target ) { event.target = originalEvent.srcElement || document; } // Support: Chrome 23+, Safari? // Target should not be a text node (#504, #13143) if ( event.target.nodeType === 3 ) { event.target = event.target.parentNode; } // Support: IE<9 // For mouse/key events, metaKey==false if it's undefined (#3368, #11328) event.metaKey = !!event.metaKey; return fixHook.filter ? fixHook.filter( event, originalEvent ) : event; }, // Includes some event props shared by KeyEvent and MouseEvent props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), fixHooks: {}, keyHooks: { props: "char charCode key keyCode".split(" "), filter: function( event, original ) { // Add which for key events if ( event.which == null ) { event.which = original.charCode != null ? original.charCode : original.keyCode; } return event; } }, mouseHooks: { props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), filter: function( event, original ) { var body, eventDoc, doc, button = original.button, fromElement = original.fromElement; // Calculate pageX/Y if missing and clientX/Y available if ( event.pageX == null && original.clientX != null ) { eventDoc = event.target.ownerDocument || document; doc = eventDoc.documentElement; body = eventDoc.body; event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); } // Add relatedTarget, if necessary if ( !event.relatedTarget && fromElement ) { event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; } // Add which for click: 1 === left; 2 === middle; 3 === right // Note: button is not normalized, so don't use it if ( !event.which && button !== undefined ) { event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); } return event; } }, special: { load: { // Prevent triggered image.load events from bubbling to window.load noBubble: true }, focus: { // Fire native event if possible so blur/focus sequence is correct trigger: function() { if ( this !== safeActiveElement() && this.focus ) { try { this.focus(); return false; } catch ( e ) { // Support: IE<9 // If we error on focus to hidden element (#1486, #12518), // let .trigger() run the handlers } } }, delegateType: "focusin" }, blur: { trigger: function() { if ( this === safeActiveElement() && this.blur ) { this.blur(); return false; } }, delegateType: "focusout" }, click: { // For checkbox, fire native event so checked state will be right trigger: function() { if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) { this.click(); return false; } }, // For cross-browser consistency, don't fire native .click() on links _default: function( event ) { return jQuery.nodeName( event.target, "a" ); } }, beforeunload: { postDispatch: function( event ) { // Support: Firefox 20+ // Firefox doesn't alert if the returnValue field is not set. if ( event.result !== undefined && event.originalEvent ) { event.originalEvent.returnValue = event.result; } } } }, simulate: function( type, elem, event, bubble ) { // Piggyback on a donor event to simulate a different one. // Fake originalEvent to avoid donor's stopPropagation, but if the // simulated event prevents default then we do the same on the donor. var e = jQuery.extend( new jQuery.Event(), event, { type: type, isSimulated: true, originalEvent: {} } ); if ( bubble ) { jQuery.event.trigger( e, null, elem ); } else { jQuery.event.dispatch.call( elem, e ); } if ( e.isDefaultPrevented() ) { event.preventDefault(); } } }; jQuery.removeEvent = document.removeEventListener ? function( elem, type, handle ) { if ( elem.removeEventListener ) { elem.removeEventListener( type, handle, false ); } } : function( elem, type, handle ) { var name = "on" + type; if ( elem.detachEvent ) { // #8545, #7054, preventing memory leaks for custom events in IE6-8 // detachEvent needed property on element, by name of that event, to properly expose it to GC if ( typeof elem[ name ] === strundefined ) { elem[ name ] = null; } elem.detachEvent( name, handle ); } }; jQuery.Event = function( src, props ) { // Allow instantiation without the 'new' keyword if ( !(this instanceof jQuery.Event) ) { return new jQuery.Event( src, props ); } // Event object if ( src && src.type ) { this.originalEvent = src; this.type = src.type; // Events bubbling up the document may have been marked as prevented // by a handler lower down the tree; reflect the correct value. this.isDefaultPrevented = src.defaultPrevented || src.defaultPrevented === undefined && // Support: IE < 9, Android < 4.0 src.returnValue === false ? returnTrue : returnFalse; // Event type } else { this.type = src; } // Put explicitly provided properties onto the event object if ( props ) { jQuery.extend( this, props ); } // Create a timestamp if incoming event doesn't have one this.timeStamp = src && src.timeStamp || jQuery.now(); // Mark it as fixed this[ jQuery.expando ] = true; }; // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html jQuery.Event.prototype = { isDefaultPrevented: returnFalse, isPropagationStopped: returnFalse, isImmediatePropagationStopped: returnFalse, preventDefault: function() { var e = this.originalEvent; this.isDefaultPrevented = returnTrue; if ( !e ) { return; } // If preventDefault exists, run it on the original event if ( e.preventDefault ) { e.preventDefault(); // Support: IE // Otherwise set the returnValue property of the original event to false } else { e.returnValue = false; } }, stopPropagation: function() { var e = this.originalEvent; this.isPropagationStopped = returnTrue; if ( !e ) { return; } // If stopPropagation exists, run it on the original event if ( e.stopPropagation ) { e.stopPropagation(); } // Support: IE // Set the cancelBubble property of the original event to true e.cancelBubble = true; }, stopImmediatePropagation: function() { var e = this.originalEvent; this.isImmediatePropagationStopped = returnTrue; if ( e && e.stopImmediatePropagation ) { e.stopImmediatePropagation(); } this.stopPropagation(); } }; // Create mouseenter/leave events using mouseover/out and event-time checks jQuery.each({ mouseenter: "mouseover", mouseleave: "mouseout", pointerenter: "pointerover", pointerleave: "pointerout" }, function( orig, fix ) { jQuery.event.special[ orig ] = { delegateType: fix, bindType: fix, handle: function( event ) { var ret, target = this, related = event.relatedTarget, handleObj = event.handleObj; // For mousenter/leave call the handler if related is outside the target. // NB: No relatedTarget if the mouse left/entered the browser window if ( !related || (related !== target && !jQuery.contains( target, related )) ) { event.type = handleObj.origType; ret = handleObj.handler.apply( this, arguments ); event.type = fix; } return ret; } }; }); // IE submit delegation if ( !support.submitBubbles ) { jQuery.event.special.submit = { setup: function() { // Only need this for delegated form submit events if ( jQuery.nodeName( this, "form" ) ) { return false; } // Lazy-add a submit handler when a descendant form may potentially be submitted jQuery.event.add( this, "click._submit keypress._submit", function( e ) { // Node name check avoids a VML-related crash in IE (#9807) var elem = e.target, form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; if ( form && !jQuery._data( form, "submitBubbles" ) ) { jQuery.event.add( form, "submit._submit", function( event ) { event._submit_bubble = true; }); jQuery._data( form, "submitBubbles", true ); } }); // return undefined since we don't need an event listener }, postDispatch: function( event ) { // If form was submitted by the user, bubble the event up the tree if ( event._submit_bubble ) { delete event._submit_bubble; if ( this.parentNode && !event.isTrigger ) { jQuery.event.simulate( "submit", this.parentNode, event, true ); } } }, teardown: function() { // Only need this for delegated form submit events if ( jQuery.nodeName( this, "form" ) ) { return false; } // Remove delegated handlers; cleanData eventually reaps submit handlers attached above jQuery.event.remove( this, "._submit" ); } }; } // IE change delegation and checkbox/radio fix if ( !support.changeBubbles ) { jQuery.event.special.change = { setup: function() { if ( rformElems.test( this.nodeName ) ) { // IE doesn't fire change on a check/radio until blur; trigger it on click // after a propertychange. Eat the blur-change in special.change.handle. // This still fires onchange a second time for check/radio after blur. if ( this.type === "checkbox" || this.type === "radio" ) { jQuery.event.add( this, "propertychange._change", function( event ) { if ( event.originalEvent.propertyName === "checked" ) { this._just_changed = true; } }); jQuery.event.add( this, "click._change", function( event ) { if ( this._just_changed && !event.isTrigger ) { this._just_changed = false; } // Allow triggered, simulated change events (#11500) jQuery.event.simulate( "change", this, event, true ); }); } return false; } // Delegated event; lazy-add a change handler on descendant inputs jQuery.event.add( this, "beforeactivate._change", function( e ) { var elem = e.target; if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) { jQuery.event.add( elem, "change._change", function( event ) { if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { jQuery.event.simulate( "change", this.parentNode, event, true ); } }); jQuery._data( elem, "changeBubbles", true ); } }); }, handle: function( event ) { var elem = event.target; // Swallow native change events from checkbox/radio, we already triggered them above if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { return event.handleObj.handler.apply( this, arguments ); } }, teardown: function() { jQuery.event.remove( this, "._change" ); return !rformElems.test( this.nodeName ); } }; } // Create "bubbling" focus and blur events if ( !support.focusinBubbles ) { jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { // Attach a single capturing handler on the document while someone wants focusin/focusout var handler = function( event ) { jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); }; jQuery.event.special[ fix ] = { setup: function() { var doc = this.ownerDocument || this, attaches = jQuery._data( doc, fix ); if ( !attaches ) { doc.addEventListener( orig, handler, true ); } jQuery._data( doc, fix, ( attaches || 0 ) + 1 ); }, teardown: function() { var doc = this.ownerDocument || this, attaches = jQuery._data( doc, fix ) - 1; if ( !attaches ) { doc.removeEventListener( orig, handler, true ); jQuery._removeData( doc, fix ); } else { jQuery._data( doc, fix, attaches ); } } }; }); } jQuery.fn.extend({ on: function( types, selector, data, fn, /*INTERNAL*/ one ) { var type, origFn; // Types can be a map of types/handlers if ( typeof types === "object" ) { // ( types-Object, selector, data ) if ( typeof selector !== "string" ) { // ( types-Object, data ) data = data || selector; selector = undefined; } for ( type in types ) { this.on( type, selector, data, types[ type ], one ); } return this; } if ( data == null && fn == null ) { // ( types, fn ) fn = selector; data = selector = undefined; } else if ( fn == null ) { if ( typeof selector === "string" ) { // ( types, selector, fn ) fn = data; data = undefined; } else { // ( types, data, fn ) fn = data; data = selector; selector = undefined; } } if ( fn === false ) { fn = returnFalse; } else if ( !fn ) { return this; } if ( one === 1 ) { origFn = fn; fn = function( event ) { // Can use an empty set, since event contains the info jQuery().off( event ); return origFn.apply( this, arguments ); }; // Use same guid so caller can remove using origFn fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); } return this.each( function() { jQuery.event.add( this, types, fn, data, selector ); }); }, one: function( types, selector, data, fn ) { return this.on( types, selector, data, fn, 1 ); }, off: function( types, selector, fn ) { var handleObj, type; if ( types && types.preventDefault && types.handleObj ) { // ( event ) dispatched jQuery.Event handleObj = types.handleObj; jQuery( types.delegateTarget ).off( handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, handleObj.selector, handleObj.handler ); return this; } if ( typeof types === "object" ) { // ( types-object [, selector] ) for ( type in types ) { this.off( type, selector, types[ type ] ); } return this; } if ( selector === false || typeof selector === "function" ) { // ( types [, fn] ) fn = selector; selector = undefined; } if ( fn === false ) { fn = returnFalse; } return this.each(function() { jQuery.event.remove( this, types, fn, selector ); }); }, trigger: function( type, data ) { return this.each(function() { jQuery.event.trigger( type, data, this ); }); }, triggerHandler: function( type, data ) { var elem = this[0]; if ( elem ) { return jQuery.event.trigger( type, data, elem, true ); } } }); function createSafeFragment( document ) { var list = nodeNames.split( "|" ), safeFrag = document.createDocumentFragment(); if ( safeFrag.createElement ) { while ( list.length ) { safeFrag.createElement( list.pop() ); } } return safeFrag; } var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g, rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), rleadingWhitespace = /^\s+/, rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, rtagName = /<([\w:]+)/, rtbody = /\s*$/g, // We have to close these tags to support XHTML (#13200) wrapMap = { option: [ 1, "" ], legend: [ 1, "
", "
" ], area: [ 1, "", "" ], param: [ 1, "", "" ], thead: [ 1, "", "
" ], tr: [ 2, "", "
" ], col: [ 2, "", "
" ], td: [ 3, "", "
" ], // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags, // unless wrapped in a div with non-breaking characters in front of it. _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X
", "
" ] }, safeFragment = createSafeFragment( document ), fragmentDiv = safeFragment.appendChild( document.createElement("div") ); wrapMap.optgroup = wrapMap.option; wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; wrapMap.th = wrapMap.td; function getAll( context, tag ) { var elems, elem, i = 0, found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) : typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) : undefined; if ( !found ) { for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) { if ( !tag || jQuery.nodeName( elem, tag ) ) { found.push( elem ); } else { jQuery.merge( found, getAll( elem, tag ) ); } } } return tag === undefined || tag && jQuery.nodeName( context, tag ) ? jQuery.merge( [ context ], found ) : found; } // Used in buildFragment, fixes the defaultChecked property function fixDefaultChecked( elem ) { if ( rcheckableType.test( elem.type ) ) { elem.defaultChecked = elem.checked; } } // Support: IE<8 // Manipulating tables requires a tbody function manipulationTarget( elem, content ) { return jQuery.nodeName( elem, "table" ) && jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? elem.getElementsByTagName("tbody")[0] || elem.appendChild( elem.ownerDocument.createElement("tbody") ) : elem; } // Replace/restore the type attribute of script elements for safe DOM manipulation function disableScript( elem ) { elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type; return elem; } function restoreScript( elem ) { var match = rscriptTypeMasked.exec( elem.type ); if ( match ) { elem.type = match[1]; } else { elem.removeAttribute("type"); } return elem; } // Mark scripts as having already been evaluated function setGlobalEval( elems, refElements ) { var elem, i = 0; for ( ; (elem = elems[i]) != null; i++ ) { jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) ); } } function cloneCopyEvent( src, dest ) { if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { return; } var type, i, l, oldData = jQuery._data( src ), curData = jQuery._data( dest, oldData ), events = oldData.events; if ( events ) { delete curData.handle; curData.events = {}; for ( type in events ) { for ( i = 0, l = events[ type ].length; i < l; i++ ) { jQuery.event.add( dest, type, events[ type ][ i ] ); } } } // make the cloned public data object a copy from the original if ( curData.data ) { curData.data = jQuery.extend( {}, curData.data ); } } function fixCloneNodeIssues( src, dest ) { var nodeName, e, data; // We do not need to do anything for non-Elements if ( dest.nodeType !== 1 ) { return; } nodeName = dest.nodeName.toLowerCase(); // IE6-8 copies events bound via attachEvent when using cloneNode. if ( !support.noCloneEvent && dest[ jQuery.expando ] ) { data = jQuery._data( dest ); for ( e in data.events ) { jQuery.removeEvent( dest, e, data.handle ); } // Event data gets referenced instead of copied if the expando gets copied too dest.removeAttribute( jQuery.expando ); } // IE blanks contents when cloning scripts, and tries to evaluate newly-set text if ( nodeName === "script" && dest.text !== src.text ) { disableScript( dest ).text = src.text; restoreScript( dest ); // IE6-10 improperly clones children of object elements using classid. // IE10 throws NoModificationAllowedError if parent is null, #12132. } else if ( nodeName === "object" ) { if ( dest.parentNode ) { dest.outerHTML = src.outerHTML; } // This path appears unavoidable for IE9. When cloning an object // element in IE9, the outerHTML strategy above is not sufficient. // If the src has innerHTML and the destination does not, // copy the src.innerHTML into the dest.innerHTML. #10324 if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) { dest.innerHTML = src.innerHTML; } } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) { // IE6-8 fails to persist the checked state of a cloned checkbox // or radio button. Worse, IE6-7 fail to give the cloned element // a checked appearance if the defaultChecked value isn't also set dest.defaultChecked = dest.checked = src.checked; // IE6-7 get confused and end up setting the value of a cloned // checkbox/radio button to an empty string instead of "on" if ( dest.value !== src.value ) { dest.value = src.value; } // IE6-8 fails to return the selected option to the default selected // state when cloning options } else if ( nodeName === "option" ) { dest.defaultSelected = dest.selected = src.defaultSelected; // IE6-8 fails to set the defaultValue to the correct value when // cloning other types of input fields } else if ( nodeName === "input" || nodeName === "textarea" ) { dest.defaultValue = src.defaultValue; } } jQuery.extend({ clone: function( elem, dataAndEvents, deepDataAndEvents ) { var destElements, node, clone, i, srcElements, inPage = jQuery.contains( elem.ownerDocument, elem ); if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) { clone = elem.cloneNode( true ); // IE<=8 does not properly clone detached, unknown element nodes } else { fragmentDiv.innerHTML = elem.outerHTML; fragmentDiv.removeChild( clone = fragmentDiv.firstChild ); } if ( (!support.noCloneEvent || !support.noCloneChecked) && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2 destElements = getAll( clone ); srcElements = getAll( elem ); // Fix all IE cloning issues for ( i = 0; (node = srcElements[i]) != null; ++i ) { // Ensure that the destination node is not null; Fixes #9587 if ( destElements[i] ) { fixCloneNodeIssues( node, destElements[i] ); } } } // Copy the events from the original to the clone if ( dataAndEvents ) { if ( deepDataAndEvents ) { srcElements = srcElements || getAll( elem ); destElements = destElements || getAll( clone ); for ( i = 0; (node = srcElements[i]) != null; i++ ) { cloneCopyEvent( node, destElements[i] ); } } else { cloneCopyEvent( elem, clone ); } } // Preserve script evaluation history destElements = getAll( clone, "script" ); if ( destElements.length > 0 ) { setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); } destElements = srcElements = node = null; // Return the cloned set return clone; }, buildFragment: function( elems, context, scripts, selection ) { var j, elem, contains, tmp, tag, tbody, wrap, l = elems.length, // Ensure a safe fragment safe = createSafeFragment( context ), nodes = [], i = 0; for ( ; i < l; i++ ) { elem = elems[ i ]; if ( elem || elem === 0 ) { // Add nodes directly if ( jQuery.type( elem ) === "object" ) { jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); // Convert non-html into a text node } else if ( !rhtml.test( elem ) ) { nodes.push( context.createTextNode( elem ) ); // Convert html into DOM nodes } else { tmp = tmp || safe.appendChild( context.createElement("div") ); // Deserialize a standard representation tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase(); wrap = wrapMap[ tag ] || wrapMap._default; tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1>" ) + wrap[2]; // Descend through wrappers to the right content j = wrap[0]; while ( j-- ) { tmp = tmp.lastChild; } // Manually add leading whitespace removed by IE if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) ); } // Remove IE's autoinserted from table fragments if ( !support.tbody ) { // String was a , *may* have spurious elem = tag === "table" && !rtbody.test( elem ) ? tmp.firstChild : // String was a bare or wrap[1] === "
" && !rtbody.test( elem ) ? tmp : 0; j = elem && elem.childNodes.length; while ( j-- ) { if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) { elem.removeChild( tbody ); } } } jQuery.merge( nodes, tmp.childNodes ); // Fix #12392 for WebKit and IE > 9 tmp.textContent = ""; // Fix #12392 for oldIE while ( tmp.firstChild ) { tmp.removeChild( tmp.firstChild ); } // Remember the top-level container for proper cleanup tmp = safe.lastChild; } } } // Fix #11356: Clear elements from fragment if ( tmp ) { safe.removeChild( tmp ); } // Reset defaultChecked for any radios and checkboxes // about to be appended to the DOM in IE 6/7 (#8060) if ( !support.appendChecked ) { jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked ); } i = 0; while ( (elem = nodes[ i++ ]) ) { // #4087 - If origin and destination elements are the same, and this is // that element, do not do anything if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { continue; } contains = jQuery.contains( elem.ownerDocument, elem ); // Append to fragment tmp = getAll( safe.appendChild( elem ), "script" ); // Preserve script evaluation history if ( contains ) { setGlobalEval( tmp ); } // Capture executables if ( scripts ) { j = 0; while ( (elem = tmp[ j++ ]) ) { if ( rscriptType.test( elem.type || "" ) ) { scripts.push( elem ); } } } } tmp = null; return safe; }, cleanData: function( elems, /* internal */ acceptData ) { var elem, type, id, data, i = 0, internalKey = jQuery.expando, cache = jQuery.cache, deleteExpando = support.deleteExpando, special = jQuery.event.special; for ( ; (elem = elems[i]) != null; i++ ) { if ( acceptData || jQuery.acceptData( elem ) ) { id = elem[ internalKey ]; data = id && cache[ id ]; if ( data ) { if ( data.events ) { for ( type in data.events ) { if ( special[ type ] ) { jQuery.event.remove( elem, type ); // This is a shortcut to avoid jQuery.event.remove's overhead } else { jQuery.removeEvent( elem, type, data.handle ); } } } // Remove cache only if it was not already removed by jQuery.event.remove if ( cache[ id ] ) { delete cache[ id ]; // IE does not allow us to delete expando properties from nodes, // nor does it have a removeAttribute function on Document nodes; // we must handle all of these cases if ( deleteExpando ) { delete elem[ internalKey ]; } else if ( typeof elem.removeAttribute !== strundefined ) { elem.removeAttribute( internalKey ); } else { elem[ internalKey ] = null; } deletedIds.push( id ); } } } } } }); jQuery.fn.extend({ text: function( value ) { return access( this, function( value ) { return value === undefined ? jQuery.text( this ) : this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); }, null, value, arguments.length ); }, append: function() { return this.domManip( arguments, function( elem ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { var target = manipulationTarget( this, elem ); target.appendChild( elem ); } }); }, prepend: function() { return this.domManip( arguments, function( elem ) { if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { var target = manipulationTarget( this, elem ); target.insertBefore( elem, target.firstChild ); } }); }, before: function() { return this.domManip( arguments, function( elem ) { if ( this.parentNode ) { this.parentNode.insertBefore( elem, this ); } }); }, after: function() { return this.domManip( arguments, function( elem ) { if ( this.parentNode ) { this.parentNode.insertBefore( elem, this.nextSibling ); } }); }, remove: function( selector, keepData /* Internal Use Only */ ) { var elem, elems = selector ? jQuery.filter( selector, this ) : this, i = 0; for ( ; (elem = elems[i]) != null; i++ ) { if ( !keepData && elem.nodeType === 1 ) { jQuery.cleanData( getAll( elem ) ); } if ( elem.parentNode ) { if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) { setGlobalEval( getAll( elem, "script" ) ); } elem.parentNode.removeChild( elem ); } } return this; }, empty: function() { var elem, i = 0; for ( ; (elem = this[i]) != null; i++ ) { // Remove element nodes and prevent memory leaks if ( elem.nodeType === 1 ) { jQuery.cleanData( getAll( elem, false ) ); } // Remove any remaining nodes while ( elem.firstChild ) { elem.removeChild( elem.firstChild ); } // If this is a select, ensure that it displays empty (#12336) // Support: IE<9 if ( elem.options && jQuery.nodeName( elem, "select" ) ) { elem.options.length = 0; } } return this; }, clone: function( dataAndEvents, deepDataAndEvents ) { dataAndEvents = dataAndEvents == null ? false : dataAndEvents; deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; return this.map(function() { return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); }); }, html: function( value ) { return access( this, function( value ) { var elem = this[ 0 ] || {}, i = 0, l = this.length; if ( value === undefined ) { return elem.nodeType === 1 ? elem.innerHTML.replace( rinlinejQuery, "" ) : undefined; } // See if we can take a shortcut and just use innerHTML if ( typeof value === "string" && !rnoInnerhtml.test( value ) && ( support.htmlSerialize || !rnoshimcache.test( value ) ) && ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) { value = value.replace( rxhtmlTag, "<$1>" ); try { for (; i < l; i++ ) { // Remove element nodes and prevent memory leaks elem = this[i] || {}; if ( elem.nodeType === 1 ) { jQuery.cleanData( getAll( elem, false ) ); elem.innerHTML = value; } } elem = 0; // If using innerHTML throws an exception, use the fallback method } catch(e) {} } if ( elem ) { this.empty().append( value ); } }, null, value, arguments.length ); }, replaceWith: function() { var arg = arguments[ 0 ]; // Make the changes, replacing each context element with the new content this.domManip( arguments, function( elem ) { arg = this.parentNode; jQuery.cleanData( getAll( this ) ); if ( arg ) { arg.replaceChild( elem, this ); } }); // Force removal if there was no new content (e.g., from empty arguments) return arg && (arg.length || arg.nodeType) ? this : this.remove(); }, detach: function( selector ) { return this.remove( selector, true ); }, domManip: function( args, callback ) { // Flatten any nested arrays args = concat.apply( [], args ); var first, node, hasScripts, scripts, doc, fragment, i = 0, l = this.length, set = this, iNoClone = l - 1, value = args[0], isFunction = jQuery.isFunction( value ); // We can't cloneNode fragments that contain checked, in WebKit if ( isFunction || ( l > 1 && typeof value === "string" && !support.checkClone && rchecked.test( value ) ) ) { return this.each(function( index ) { var self = set.eq( index ); if ( isFunction ) { args[0] = value.call( this, index, self.html() ); } self.domManip( args, callback ); }); } if ( l ) { fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this ); first = fragment.firstChild; if ( fragment.childNodes.length === 1 ) { fragment = first; } if ( first ) { scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); hasScripts = scripts.length; // Use the original fragment for the last item instead of the first because it can end up // being emptied incorrectly in certain situations (#8070). for ( ; i < l; i++ ) { node = fragment; if ( i !== iNoClone ) { node = jQuery.clone( node, true, true ); // Keep references to cloned scripts for later restoration if ( hasScripts ) { jQuery.merge( scripts, getAll( node, "script" ) ); } } callback.call( this[i], node, i ); } if ( hasScripts ) { doc = scripts[ scripts.length - 1 ].ownerDocument; // Reenable scripts jQuery.map( scripts, restoreScript ); // Evaluate executable scripts on first document insertion for ( i = 0; i < hasScripts; i++ ) { node = scripts[ i ]; if ( rscriptType.test( node.type || "" ) && !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) { if ( node.src ) { // Optional AJAX dependency, but won't run scripts if not present if ( jQuery._evalUrl ) { jQuery._evalUrl( node.src ); } } else { jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) ); } } } } // Fix #11809: Avoid leaking memory fragment = first = null; } } return this; } }); jQuery.each({ appendTo: "append", prependTo: "prepend", insertBefore: "before", insertAfter: "after", replaceAll: "replaceWith" }, function( name, original ) { jQuery.fn[ name ] = function( selector ) { var elems, i = 0, ret = [], insert = jQuery( selector ), last = insert.length - 1; for ( ; i <= last; i++ ) { elems = i === last ? this : this.clone(true); jQuery( insert[i] )[ original ]( elems ); // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get() push.apply( ret, elems.get() ); } return this.pushStack( ret ); }; }); var iframe, elemdisplay = {}; /** * Retrieve the actual display of a element * @param {String} name nodeName of the element * @param {Object} doc Document object */ // Called only from within defaultDisplay function actualDisplay( name, doc ) { var style, elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), // getDefaultComputedStyle might be reliably used only on attached element display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ? // Use of this method is a temporary fix (more like optmization) until something better comes along, // since it was removed from specification and supported only in FF style.display : jQuery.css( elem[ 0 ], "display" ); // We don't have any data stored on the element, // so use "detach" method as fast way to get rid of the element elem.detach(); return display; } /** * Try to determine the default display value of an element * @param {String} nodeName */ function defaultDisplay( nodeName ) { var doc = document, display = elemdisplay[ nodeName ]; if ( !display ) { display = actualDisplay( nodeName, doc ); // If the simple way fails, read from inside an iframe if ( display === "none" || !display ) { // Use the already-created iframe if possible iframe = (iframe || jQuery( "\n \n \n\n \n\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["details_dialog"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["editable_workspace_dialog"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, self=this, functionType="function"; function program1(depth0,data) { return "scrivito_green"; } function program3(depth0,data) { var buffer = "", stack1; buffer += "\n "; stack1 = helpers['if'].call(depth0, depth0.can_create, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n "; return buffer; } function program4(depth0,data) { var buffer = "", stack1, options; buffer += "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "editable_ws_dialog.title.select_or_create", options) : helperMissing.call(depth0, "translate", "editable_ws_dialog.title.select_or_create", options))) + "\n "; return buffer; } function program6(depth0,data) { var buffer = "", stack1, options; buffer += "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "editable_ws_dialog.title.select", options) : helperMissing.call(depth0, "translate", "editable_ws_dialog.title.select", options))) + "\n "; return buffer; } function program8(depth0,data) { var buffer = "", stack1; buffer += "\n "; stack1 = helpers['if'].call(depth0, depth0.can_create, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n "; return buffer; } function program9(depth0,data) { var buffer = "", stack1, options; buffer += "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "editable_ws_dialog.title.create", options) : helperMissing.call(depth0, "translate", "editable_ws_dialog.title.create", options))) + "\n "; return buffer; } function program11(depth0,data) { var buffer = "", stack1, options; buffer += "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "editable_ws_dialog.title.forbidden", options) : helperMissing.call(depth0, "translate", "editable_ws_dialog.title.forbidden", options))) + "\n "; return buffer; } function program13(depth0,data) { var buffer = "", stack1; buffer += "\n "; stack1 = helpers['if'].call(depth0, depth0.can_create, {hash:{},inverse:self.program(16, program16, data),fn:self.program(14, program14, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n "; return buffer; } function program14(depth0,data) { var buffer = "", stack1, options; buffer += "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "editable_ws_dialog.description.select_or_create", options) : helperMissing.call(depth0, "translate", "editable_ws_dialog.description.select_or_create", options))) + "\n "; return buffer; } function program16(depth0,data) { var buffer = "", stack1, options; buffer += "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "editable_ws_dialog.description.select", options) : helperMissing.call(depth0, "translate", "editable_ws_dialog.description.select", options))) + "\n "; return buffer; } function program18(depth0,data) { var buffer = "", stack1; buffer += "\n "; stack1 = helpers['if'].call(depth0, depth0.can_create, {hash:{},inverse:self.program(21, program21, data),fn:self.program(19, program19, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n "; return buffer; } function program19(depth0,data) { var buffer = "", stack1, options; buffer += "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "editable_ws_dialog.description.create", options) : helperMissing.call(depth0, "translate", "editable_ws_dialog.description.create", options))) + "\n "; return buffer; } function program21(depth0,data) { var buffer = "", stack1, options; buffer += "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "editable_ws_dialog.description.forbidden", options) : helperMissing.call(depth0, "translate", "editable_ws_dialog.description.forbidden", options))) + "\n "; return buffer; } function program23(depth0,data) { var buffer = "", stack1, stack2, options; buffer += "\n
\n \n \n
\n "; return buffer; } function program24(depth0,data) { var buffer = "", stack1, stack2; buffer += "\n \n "; return buffer; } function program25(depth0,data) { var buffer = "", stack1; buffer += "\n " + escapeExpression(((stack1 = depth0.title),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + "\n "; return buffer; } function program27(depth0,data) { var buffer = "", stack1, options; buffer += "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar.empty_workspace_title", options) : helperMissing.call(depth0, "translate", "menu_bar.empty_workspace_title", options))) + "\n "; return buffer; } function program29(depth0,data) { var buffer = "", stack1, options; buffer += "\n
\n \n \n
\n "; return buffer; } function program30(depth0,data) { var buffer = "", stack1, options; buffer += "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "editable_ws_dialog.or_create_new", options) : helperMissing.call(depth0, "translate", "editable_ws_dialog.or_create_new", options))) + "\n "; return buffer; } function program32(depth0,data) { var buffer = "", stack1, options; buffer += "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "editable_ws_dialog.create_new", options) : helperMissing.call(depth0, "translate", "editable_ws_dialog.create_new", options))) + "\n "; return buffer; } function program34(depth0,data) { var buffer = "", stack1, options; buffer += "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "cancel", options) : helperMissing.call(depth0, "translate", "cancel", options))) + "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "confirm", options) : helperMissing.call(depth0, "translate", "confirm", options))) + "\n "; return buffer; } function program36(depth0,data) { var buffer = "", stack1, options; buffer += "\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "close", options) : helperMissing.call(depth0, "translate", "close", options))) + "\n "; return buffer; } buffer += "
\n
\n \n

\n "; stack1 = helpers['if'].call(depth0, depth0.can_select, {hash:{},inverse:self.program(8, program8, data),fn:self.program(3, program3, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n

\n
\n
\n
\n "; stack1 = helpers['if'].call(depth0, depth0.can_select, {hash:{},inverse:self.program(18, program18, data),fn:self.program(13, program13, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n
\n
\n  \n
\n "; stack1 = helpers['if'].call(depth0, depth0.workspaces, {hash:{},inverse:self.noop,fn:self.program(23, program23, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n "; stack1 = helpers['if'].call(depth0, depth0.can_create, {hash:{},inverse:self.noop,fn:self.program(29, program29, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n
\n
\n "; stack1 = helpers['if'].call(depth0, depth0.can_select_or_create, {hash:{},inverse:self.program(36, program36, data),fn:self.program(34, program34, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n
\n
\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["editable_workspace_dialog"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["element_overlay"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; return "
\n"; }); return this.ScrivitoHandlebarsTemplates["element_overlay"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["iframe_dialog"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; function program1(depth0,data) { var buffer = "", stack1; buffer += "scrivito_"; if (stack1 = helpers.color) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.color; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1); return buffer; } function program3(depth0,data) { var buffer = "", stack1; buffer += "\n "; stack1 = helpers['with'].call(depth0, depth0.cancel, {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n "; return buffer; } function program4(depth0,data) { var buffer = "", stack1; buffer += "\n \n "; stack1 = helpers['if'].call(depth0, depth0.title, {hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n \n "; return buffer; } function program5(depth0,data) { var stack1; if (stack1 = helpers.title) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.title; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } return escapeExpression(stack1); } function program7(depth0,data) { return escapeExpression((typeof depth0 === functionType ? depth0.apply(depth0) : depth0)); } function program9(depth0,data) { var buffer = "", stack1; buffer += "\n "; stack1 = helpers['with'].call(depth0, depth0.confirm, {hash:{},inverse:self.noop,fn:self.program(10, program10, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n "; return buffer; } function program10(depth0,data) { var buffer = "", stack1; buffer += "\n \n "; stack1 = helpers['if'].call(depth0, depth0.title, {hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n \n "; return buffer; } buffer += "
\n
\n
\n "; stack1 = helpers.unless.call(depth0, depth0.disable_cancel, {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n "; stack1 = helpers.unless.call(depth0, depth0.disable_confirm, {hash:{},inverse:self.noop,fn:self.program(9, program9, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n
\n
\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["iframe_dialog"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["inplace_marker"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; function program1(depth0,data) { var buffer = "", stack1; buffer += "\n "; if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "\n "; return buffer; } buffer += "\n \n "; stack1 = helpers['if'].call(depth0, depth0.description, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["inplace_marker"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; function program1(depth0,data) { var buffer = "", stack1; buffer += "scrivito_"; if (stack1 = helpers.align) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.align; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1); return buffer; } function program3(depth0,data) { return "scrivito_right"; } function program5(depth0,data) { var buffer = "", stack1, stack2; buffer += "\n "; stack2 = ((stack1 = depth0.render),typeof stack1 === functionType ? stack1.apply(depth0) : stack1); if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n "; return buffer; } buffer += "
\n
    \n "; stack1 = helpers.each.call(depth0, depth0.menu_items, {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n
  • \n
\n
\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["menu"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_bar"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; return "
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n"; }); return this.ScrivitoHandlebarsTemplates["menu_bar"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_bar_browse_content"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; return "\n"; }); return this.ScrivitoHandlebarsTemplates["menu_bar_browse_content"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_bar_conflict_indicator"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; return "\n \n\n"; }); return this.ScrivitoHandlebarsTemplates["menu_bar_conflict_indicator"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_bar_conflict_indicator/conflict"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, stack2, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; buffer += "
  • \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar_conflict_indicator.conflict_headline", options) : helperMissing.call(depth0, "translate", "menu_bar_conflict_indicator.conflict_headline", options))) + "\n
  • \n
  • \n "; options = {hash:{},data:data}; stack2 = ((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar_conflict_indicator.conflict_description", options) : helperMissing.call(depth0, "translate", "menu_bar_conflict_indicator.conflict_description", options)); if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n
  • \n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["menu_bar_conflict_indicator/conflict"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_bar_conflict_indicator/warn"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression; buffer += "
  • \n "; if (stack1 = helpers.headline) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.headline; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "\n
  • \n
  • \n "; if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "\n
  • \n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["menu_bar_conflict_indicator/warn"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_bar_device_toggle"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression; buffer += "\n \n\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["menu_bar_device_toggle"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_bar_toggle"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, stack2, functionType="function", escapeExpression=this.escapeExpression; buffer += "
    \n \n\n
    \n \n " + escapeExpression(((stack1 = ((stack1 = depth0.switch_to_view_mode_command),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + "\n
    \n\n
    \n \n " + escapeExpression(((stack1 = ((stack1 = depth0.switch_to_editing_mode_command),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + "\n
    \n\n
    \n \n \n " + escapeExpression(((stack1 = ((stack1 = depth0.switch_to_comparing_mode_command),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + " \n \n
    \n
    \n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["menu_bar_toggle"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_bar_warning"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; buffer += "\n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar_warning.warning", options) : helperMissing.call(depth0, "translate", "menu_bar_warning.warning", options))) + "\n\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["menu_bar_warning"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_item"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; function program1(depth0,data) { return "scrivito_disabled"; } function program3(depth0,data) { var stack1; if (stack1 = helpers.tooltip) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.tooltip; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } return escapeExpression(stack1); } function program5(depth0,data) { var stack1; if (stack1 = helpers.reason_for_being_disabled) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.reason_for_being_disabled; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } return escapeExpression(stack1); } function program7(depth0,data) { var buffer = "", stack1; buffer += "\n "; if (stack1 = helpers.subtitle) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.subtitle; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "\n "; return buffer; } buffer += "
  • \n \n "; if (stack1 = helpers.icon) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.icon; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } if(stack1 || stack1 === 0) { buffer += stack1; } if (stack1 = helpers.title) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.title; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "\n "; stack1 = helpers['if'].call(depth0, depth0.subtitle, {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n \n
  • \n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["menu_item"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_item/icon"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression; buffer += "\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["menu_item/icon"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_item/icon_hex"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function"; buffer += ""; if (stack1 = helpers.icon) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.icon; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["menu_item/icon_hex"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_item/icon_sci"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression; buffer += "\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["menu_item/icon_sci"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_item/separator"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; function program1(depth0,data) { var buffer = "", stack1; buffer += ""; if (stack1 = helpers.title) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.title; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + ""; return buffer; } buffer += "
  • \n "; stack1 = helpers['if'].call(depth0, depth0.title, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n
  • \n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["menu_item/separator"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["menu_item/spinner"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, options, functionType="function", escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing; buffer += "
  • \n \n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_item.spinner.loading", options) : helperMissing.call(depth0, "translate", "menu_item.spinner.loading", options))) + "\n \n
  • \n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["menu_item/spinner"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["obj_menu"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, stack2, functionType="function", escapeExpression=this.escapeExpression, self=this; function program1(depth0,data) { return "\n scrivito_new\n "; } function program3(depth0,data) { return "\n scrivito_changed\n "; } function program5(depth0,data) { return "\n scrivito_deleted\n "; } buffer += "\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["obj_menu"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["obj_sorting_dialog"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, stack2, options, functionType="function", escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing, self=this; function program1(depth0,data) { var buffer = "", stack1; buffer += "\n
  • "; if (stack1 = helpers.description_for_editor) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.description_for_editor; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "
  • \n "; return buffer; } buffer += "
    \n\n
    \n

    "; if (stack1 = helpers.icon) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.icon; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } if(stack1 || stack1 === 0) { buffer += stack1; } buffer += ""; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "obj_sorting_dialog.title", options) : helperMissing.call(depth0, "translate", "obj_sorting_dialog.title", options))) + "

    \n
    \n\n
    \n
      \n "; stack2 = helpers.each.call(depth0, depth0.child_list, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}); if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n
    \n
    \n\n \n\n
    \n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["obj_sorting_dialog"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["option_marker"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression; buffer += "\n \n\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["option_marker"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["overlay"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; return "
    \n"; }); return this.ScrivitoHandlebarsTemplates["overlay"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["prompt_dialog"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; function program1(depth0,data) { var buffer = "", stack1; buffer += "scrivito_"; if (stack1 = helpers.color) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.color; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1); return buffer; } function program3(depth0,data) { var buffer = "", stack1; buffer += "\n

    "; if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "

    \n "; return buffer; } buffer += "
    \n
    \n "; if (stack1 = helpers.icon) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.icon; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n

    "; if (stack1 = helpers.title) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.title; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "

    \n "; stack1 = helpers['if'].call(depth0, depth0.description, {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n
    \n
    \n \n
    \n \n
    \n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["prompt_dialog"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["saving_indicator"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; buffer += "\n \n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "saving_indicator_item.saving", options) : helperMissing.call(depth0, "translate", "saving_indicator_item.saving", options))) + "\n \n\n \n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "saving_indicator_item.saved", options) : helperMissing.call(depth0, "translate", "saving_indicator_item.saved", options))) + "\n \n\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["saving_indicator"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["saving_overlay"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; return "
    \n \n
    \n"; }); return this.ScrivitoHandlebarsTemplates["saving_overlay"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["title"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression; buffer += "

    "; if (stack1 = helpers.title) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.title; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "

    \n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["title"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["workspace_select"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, stack2, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, functionType="function", self=this; function program1(depth0,data) { var buffer = "", stack1; buffer += "\n "; if (stack1 = helpers.icon) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.icon; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n "; if (stack1 = helpers.title) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.title; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "\n "; stack1 = helpers['if'].call(depth0, depth0.is_outdated, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n"; return buffer; } function program2(depth0,data) { var buffer = "", stack1, options; buffer += "\n \n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "workspace_select.outdated", options) : helperMissing.call(depth0, "translate", "workspace_select.outdated", options))) + "\n \n "; return buffer; } function program4(depth0,data) { var buffer = "", stack1, stack2, options; buffer += "\n
  • \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "workspace_select.this_workspace", options) : helperMissing.call(depth0, "translate", "workspace_select.this_workspace", options))) + "\n
  • \n "; stack2 = helpers.each.call(depth0, ((stack1 = depth0.commands),stack1 == null || stack1 === false ? stack1 : stack1.for_editable), {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data}); if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n
  • \n "; return buffer; } function program5(depth0,data) { var buffer = "", stack1, stack2, options; buffer += "\n "; options = {hash:{},data:data}; stack2 = ((stack1 = helpers.render),stack1 ? stack1.call(depth0, "workspace_select/menu_item", depth0, options) : helperMissing.call(depth0, "render", "workspace_select/menu_item", depth0, options)); if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n "; return buffer; } function program7(depth0,data) { var buffer = "", stack1, stack2, options; buffer += "\n
  • \n "; options = {hash:{},data:data}; stack2 = ((stack1 = helpers.render),stack1 ? stack1.call(depth0, "workspace_select/menu_item", ((stack1 = depth0.commands),stack1 == null || stack1 === false ? stack1 : stack1.select_published), options) : helperMissing.call(depth0, "render", "workspace_select/menu_item", ((stack1 = depth0.commands),stack1 == null || stack1 === false ? stack1 : stack1.select_published), options)); if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n "; return buffer; } stack1 = helpers['with'].call(depth0, depth0.selected_workspace, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n\n
    \n
      \n "; stack2 = helpers['if'].call(depth0, ((stack1 = depth0.selected_workspace),stack1 == null || stack1 === false ? stack1 : stack1.is_editable), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data}); if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n\n
    • \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "workspace_select.other_workspaces", options) : helperMissing.call(depth0, "translate", "workspace_select.other_workspaces", options))) + "\n
    • \n\n "; options = {hash:{},data:data}; stack2 = ((stack1 = helpers.render),stack1 ? stack1.call(depth0, "workspace_select/menu_item", ((stack1 = depth0.commands),stack1 == null || stack1 === false ? stack1 : stack1.create_workspace), options) : helperMissing.call(depth0, "render", "workspace_select/menu_item", ((stack1 = depth0.commands),stack1 == null || stack1 === false ? stack1 : stack1.create_workspace), options)); if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n\n "; stack2 = helpers.unless.call(depth0, ((stack1 = depth0.selected_workspace),stack1 == null || stack1 === false ? stack1 : stack1.is_published), {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data}); if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n\n
    • \n \n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar.loading_workspaces", options) : helperMissing.call(depth0, "translate", "menu_bar.loading_workspaces", options))) + "\n \n
    • \n\n
    • \n
    \n
    \n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["workspace_select"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["workspace_select/menu_item"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; function program1(depth0,data) { return "scrivito_highlight"; } function program3(depth0,data) { return "scrivito_disabled"; } function program5(depth0,data) { var stack1; if (stack1 = helpers.tooltip) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.tooltip; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } return escapeExpression(stack1); } function program7(depth0,data) { var stack1; if (stack1 = helpers.reason_for_being_disabled) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.reason_for_being_disabled; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } return escapeExpression(stack1); } function program9(depth0,data) { var buffer = "", stack1; buffer += "\n "; if (stack1 = helpers.subtitle) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.subtitle; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "\n "; return buffer; } buffer += "
  • \n \n "; if (stack1 = helpers.icon) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.icon; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } if(stack1 || stack1 === 0) { buffer += stack1; } buffer += " "; if (stack1 = helpers.title) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.title; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "\n "; stack1 = helpers['if'].call(depth0, depth0.subtitle, {hash:{},inverse:self.noop,fn:self.program(9, program9, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n \n
  • \n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["workspace_select/menu_item"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["workspace_select/other_workspaces"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, helperMissing=helpers.helperMissing, self=this; function program1(depth0,data) { return "\n
  • \n"; } function program3(depth0,data) { var buffer = "", stack1, stack2, options; buffer += "\n "; options = {hash:{},data:data}; stack2 = ((stack1 = helpers.render),stack1 ? stack1.call(depth0, "workspace_select/menu_item", depth0, options) : helperMissing.call(depth0, "render", "workspace_select/menu_item", depth0, options)); if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n"; return buffer; } stack1 = helpers['if'].call(depth0, depth0.has_separator, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n"; stack1 = helpers.each.call(depth0, depth0.commands, {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["workspace_select/other_workspaces"]; }).call(this); (function() { this.ScrivitoHandlebarsTemplates || (this.ScrivitoHandlebarsTemplates = {}); this.ScrivitoHandlebarsTemplates["workspace_settings_dialog"] = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { this.compilerInfo = [3,'>= 1.0.0-rc.4']; helpers = helpers || Handlebars.helpers; data = data || {}; var buffer = "", stack1, stack2, options, functionType="function", escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing; buffer += "
    \n
    \n

    "; if (stack1 = helpers.title) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.title; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "

    \n
    \n\n
    \n

    "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "workspace_settings_dialog.owners", options) : helperMissing.call(depth0, "translate", "workspace_settings_dialog.owners", options))) + "

    \n \n
    \n\n \n
    \n"; return buffer; }); return this.ScrivitoHandlebarsTemplates["workspace_settings_dialog"]; }).call(this); $.i18n().load({ 'confirm': 'Bestätigen', 'cancel': 'Abbrechen', 'save': 'Speichern', 'welcome': 'Willkommen', 'welcome_x': 'Willkommen $1', 'accept': 'Übernehmen', 'close': 'Schließen', 'done': 'Fertig', 'loading': 'Lade...', 'current_page': 'Aktuelle Seite', 'ok': 'Ok', 'obj.tooltip.is_new': 'Diese Seite ist neu.', 'obj.tooltip.is_edited': 'Diese Seite wurde geändert.', 'obj.tooltip.is_deleted': 'Diese Seite wurde gelöscht.', 'workspace.title_published': 'Veröffentlichte Inhalte', 'workspace.empty_title': '', 'workspace_settings_dialog.owners': 'Besitzer', 'workspace_settings_dialog.nothing_found': 'Nichts gefunden', 'workspace_settings_dialog.searching': 'Suche...', 'workspace_settings_dialog.too_short': 'Benutzer suchen...', 'workspace_select.outdated': 'veraltet', 'workspace_select.this_workspace': 'Diese Arbeitskopie', 'workspace_select.other_workspaces': 'Andere Arbeitskopien', 'menu_item.spinner.loading': 'Laden...', 'choose_obj_class_dialog.add_child_page.title': 'Seitenvorlage auswählen', 'choose_obj_class_dialog.create_widget.title': 'Widget auswählen', 'choose_obj_class_dialog.last_used': 'Zuletzt verwendet', 'choose_obj_class_dialog.popular': 'Oft verwendet', 'choose_obj_class_dialog.all': 'Alle', 'editable_ws_dialog.title.select_or_create': 'Arbeitskopie wählen', 'editable_ws_dialog.title.select': 'Arbeitskopie auswählen', 'editable_ws_dialog.title.create': 'Arbeitskopie anlegen', 'editable_ws_dialog.title.forbidden': 'Keine Arbeitskopie verfügbar', 'editable_ws_dialog.description.select_or_create': 'Wählen Sie eine Arbeitskopie aus oder legen Sie eine neue an, um Inhalte zu ändern. Veröffentlichen Sie die Arbeitskopie nach Abschluss der Bearbeitung, oder lassen Sie sie veröffentlichen.', 'editable_ws_dialog.description.select': 'Wählen Sie eine Arbeitskopie aus, um Inhalte zu ändern. Veröffentlichen Sie die Arbeitskopie nach Abschluss der Bearbeitung, oder lassen Sie sie veröffentlichen.', 'editable_ws_dialog.description.create': 'Legen Sie eine neue Arbeitskopie an, um Inhalte zu ändern. Veröffentlichen Sie die Arbeitskopie nach Abschluss der Bearbeitung, oder lassen Sie sie veröffentlichen.', 'editable_ws_dialog.description.forbidden': 'Es gibt keine Arbeitskopie, in der Sie Inhalte ändern könnten. Auch wurde es Ihnen nicht ermöglicht, Arbeitskopien anzulegen.', 'editable_ws_dialog.choose_existing': 'Wählen Sie eine bestehende Arbeitskopie aus:', 'editable_ws_dialog.create_new': 'Legen Sie eine neue Arbeitskopie an:', 'editable_ws_dialog.or_create_new': 'Oder legen Sie eine neue an:', 'editable_ws_dialog.create_new_playholder': 'Titel der neuen Arbeitskopie', 'editable_ws_dialog.select': 'Auswählen', 'resource_dialog.title': 'Eigenschaften der Ressource "$1"', 'resource_dialog.commands.revert_obj.title': 'Änderungen an Ressource verwerfen', 'resource_dialog.commands.revert_obj.new_obj': 'Dies ist eine neue Ressource. Um die Erstellung dieser Ressource rückgängig zu machen, löschen Sie sie bitte.', 'resource_dialog.commands.revert_obj.not_modified_obj': 'Diese Ressource wurde nicht geändert. Daher gibt es nichts zu verwerfen.', 'resource_dialog.commands.revert_obj.dialog.title': 'Wirklich Änderungen an dieser Ressource verwerfen?', 'resource_dialog.commands.restore_obj.title': 'Ressource wiederherstellen', 'resource_dialog.commands.mark_resolved_obj.title': 'Parallele Änderungen an der Ressource überschreiben', 'resource_dialog.commands.mark_resolved_obj.dialog.description': 'Diese Ressource wurde in einer anderen, inzwischen veröffentlichten Arbeitskopie geändert. Bitte bestätigen Sie, dass Ihre Änderungen erhalten und die parallel durchgeführten Änderungen verworfen werden.', 'resource_dialog.commands.delete_obj.title': 'Ressource löschen', 'resource_dialog.commands.delete_obj.dialog.title': 'Wirklich diese Ressource löschen?', 'resource_dialog.commands.delete_obj.dialog.description': 'Änderungen an einer gelöschten Ressource können nicht wiederhergestellt werden.', 'menu_bar.loading_workspaces': 'Lade Arbeitskopien', 'menu_bar.create': 'Anlegen', 'menu_bar.move': 'Verschieben', 'menu_bar.copy': 'Kopieren', 'saving_indicator_item.saving': 'Wird gespeichert...', 'saving_indicator_item.saved': 'Änderungen gespeichert', 'menu_bar_warning.warning': 'JS-Konsole überprüfen', 'menu_bar_warning.open_console': 'Es gibt Warnhinweise. Bitte öffnen Sie die JavaScript-Konsole, um Details zu erfahren.', 'menu_bar_conflict_indicator.conflict_description': 'Eine andere Version dieser Seite wurde zwischenzeitlich veröffentlicht. Lösen Sie den Konflikt, um diese Arbeitskopie veröffentlichen zu können.', 'menu_bar_conflict_indicator.conflict_headline': 'Konflikt', 'menu_bar_conflict_indicator.outdated_description': 'Eine neue Version dieser Seite wurde veröffentlicht. Aktualisieren Sie diese Arbeitskopie jetzt, um einen Konflikt zu vermeiden.', 'menu_bar_conflict_indicator.outdated_headline': 'Neue Version', 'menu_bar_conflict_indicator.warn_description': 'Änderungen an dieser Seite führen beim Veröffentlichen zu einem Konflikt. Die Seite wurde bereits in folgenden Arbeitskopien geändert:', 'menu_bar_conflict_indicator.warn_headline': 'Potenzieller Konflikt', 'menu_bar_device_toggle.description': 'Vorschaugröße', 'menu_bar_device_toggle.command.title.mobile': 'Mobiltelefon im Hochformat', 'menu_bar_device_toggle.command.title.tablet': 'Tablet im Hochformat', 'menu_bar_device_toggle.command.title.laptop': 'Laptop', 'menu_bar_device_toggle.command.title.desktop': 'Desktop', 'menu_bar_device_toggle.command.disabled': 'Aktuell ausgewählte Größe', 'inplace_marker.overlapping': 'Zwei oder mehrere Menü-Handles überschneiden sich. Bitte passen Sie Ihr CSS an. Die folgenden Menü-Handles überschneiden sich:', 'widget_marker.widget_is_new': 'Widget ist neu', 'widget_marker.widget_is_edited': 'Widget wurde geändert', 'widget_marker.widget_is_edited_and_dragged_here': 'Widget wurde geändert und hierher gezogen', 'widget_marker.widget_is_edited_and_dragged_away': 'Widget wurde geändert und von hier weggezogen', 'widget_marker.widget_is_deleted': 'Widget wurde gelöscht', 'widget_marker.widget_is_dragged_here': 'Widget wurde hierher gezogen', 'widget_marker.widget_is_dragged_away': 'Widget wurde von hier weggezogen', 'child_list_menu.description': 'Elemente von $1', 'changes_dialog.title': 'Änderungen von "$1"', 'changes_dialog.empty': 'In dieser Arbeitskopie wurde nichts geändert.', 'changes_dialog.more': 'Mehr...', 'changes_dialog.modification': 'Änderung', 'changes_dialog.rights': 'Veröffentlichen erlaubt', 'changes_dialog.description_for_editor': 'Titel', 'changes_dialog.obj_class_name': 'Typ', 'changes_dialog.last_changed': 'Letzte Änderung', 'current_page_link_dialog.title': 'Diese Seite teilen', 'current_page_link_dialog.description': 'Mit dieser URL können Sie die aktuelle Seite als Teil dieser Arbeitskopie teilen. Die Empfänger müssen angemeldet sein und Zugriff auf die Arbeitskopie haben.', 'commands.current_page_link.title': 'Diese Seite teilen', 'commands.create_workspace.forbidden': 'Eine Arbeitskopie kann aufgrund fehlender Benutzerrechte nicht angelegt werden.', 'commands.create_workspace.title': 'Arbeitskopie anlegen', 'commands.create_workspace.dialog.title': 'Arbeitskopie anlegen', 'commands.create_workspace.dialog.description': 'Bitte geben Sie den Titel der neuen Arbeitskopie ein.', 'commands.create_workspace.dialog.placeholder': 'Neuer Titel', 'commands.create_workspace.dialog.accept': 'Anlegen', 'commands.rename_workspace.title': 'Umbenennen', 'commands.rename_workspace.dialog.title': '"$1" umbenennen', 'commands.rename_workspace.dialog.description': 'Bitte geben Sie den neuen Titel der Arbeitskopie ein.', 'commands.rename_workspace.dialog.accept': 'Umbenennen', 'commands.rebase_workspace.title': 'Aktualisieren', 'commands.rebase_workspace.tooltip': 'Arbeitskopie "$1" is veraltet. Bitte aktualisieren Sie sie.', 'commands.rebase_workspace.uptodate': 'Arbeitskopie "$1" muss nicht aktualisiert werden.', 'commands.rebase_workspace.has_conflicts.title': 'Geänderte Inhalte wurden zwischenzeitlich veröffentlicht', 'commands.rebase_workspace.has_conflicts.description': 'Ihre Arbeitskopie konnte nicht vollständig aktualisiert werden. Einige Inhalte wurden auch in einer anderen Arbeitskopie geändert, die inzwischen veröffentlicht wurde. Bitte entnehmen Sie die Details der Liste der Änderungen.', 'commands.rebase_workspace.open_changes_dialog': 'Änderungen anzeigen', 'commands.delete_workspace.title': 'Löschen', 'commands.delete_workspace.dialog.title': 'Wirklich "$1" löschen?', 'commands.delete_workspace.dialog.description': 'Eine gelöschte Arbeitskopie kann nicht wiederhergestellt werden.', 'commands.delete_workspace.dialog.confirm': 'Löschen', 'commands.workspace_settings.title': 'Einstellungen bearbeiten', 'commands.workspace_settings.dialog.title': 'Einstellungen von "$1"', 'commands.workspace_changes.title': 'Änderungen anzeigen', 'commands.obj_details.title_edit': 'Seiteneigenschaften bearbeiten', 'commands.obj_details.title_view': 'Seiteneigenschaften anzeigen', 'commands.obj_details.dialog.title_edit': 'Eigenschaften von "$1" bearbeiten', 'commands.obj_details.dialog.title_view': 'Eigenschaften von "$1" anzeigen', 'commands.save_obj_to_clipboard.title': 'Seite zum Kopieren oder Verschieben markieren', 'commands.save_obj_to_clipboard.has_children': 'Seiten mit Unterseiten können noch nicht verschoben oder kopiert werden.', 'commands.delete_obj.title': 'Seite löschen', 'commands.delete_obj.published_workspace': 'Die veröffentlichten Inhalte können nicht direkt geändert werden.', 'commands.delete_obj.has_children': 'Seiten mit Unterseiten können noch nicht gelöscht werden.', 'commands.delete_obj.dialog.title': 'Wirklich diese Seite löschen?', 'commands.delete_obj.dialog.description': 'Änderungen an einer gelöschten Seite können nicht wiederhergestellt werden.', 'commands.delete_obj.dialog.confirm': 'Löschen', 'commands.revert_obj.title': 'Änderungen an Seite verwerfen', 'commands.revert_obj.published_workspace': 'Die veröffentlichten Inhalte können nicht direkt geändert werden. Daher gibt es nichts zu verwerfen.', 'commands.revert_obj.new_obj': 'Dies ist eine neue Seite. Um die Erstellung dieser Seite rückgängig zu machen, löschen Sie sie bitte.', 'commands.revert_obj.not_modified_obj': 'Diese Seite wurde nicht geändert. Daher gibt es nichts zu verwerfen.', 'commands.revert_obj.is_binary': 'Verwerfen von Änderungen ist nicht verfügbar für binäre Daten.', 'commands.revert_obj.dialog.title': 'Wirklich Änderungen an dieser Seite verwerfen?', 'commands.revert_obj.dialog.description': 'Verworfene Änderungen können nicht wiederhergestellt werden.', 'commands.revert_obj.dialog.confirm': 'Verwerfen', 'commands.revert_widget.content_title': 'Änderungen am Inhalt verwerfen', 'commands.revert_widget.widget_title': 'Änderungen am Widget verwerfen', 'commands.revert_widget.is_new': 'Dies ist ein neues Widget. Um die Erstellung dieses Widgets rückgängig zu machen, löschen Sie es bitte.', 'commands.revert_widget.is_not_modified': 'Dieses Widget wurde nicht geändert. Daher gibt es nichts zu verwerfen.', 'commands.revert_widget.dialog.title': 'Wirklich Änderungen an diesem Widget verwerfen?', 'commands.revert_widget.dialog.description': 'Verworfene Änderungen können nicht wiederhergestellt werden.', 'commands.revert_widget.dialog.confirm': 'Verwerfen', 'commands.restore_widget.title': 'Widget wiederherstellen', 'commands.restore_obj.title': 'Seite wiederherstellen', 'commands.mark_resolved_obj.title': 'Parallele Änderungen an der Seite überschreiben', 'commands.mark_resolved_obj.dialog.title': 'Wirklich parallele Änderungen an der Seite überschreiben?', 'commands.mark_resolved_obj.dialog.description': 'Diese Seite wurde in einer anderen, inzwischen veröffentlichten Arbeitskopie geändert. Bitte bestätigen Sie, dass Ihre Änderungen erhalten und die parallel durchgeführten Änderungen verworfen werden.', 'commands.mark_resolved_obj.dialog.confirm': 'Änderungen überschreiben', 'commands.duplicate_obj.title': 'Seite duplizieren', 'commands.duplicate_obj.published_workspace': 'Die veröffentlichten Inhalte können nicht direkt geändert werden.', 'commands.duplicate_obj.has_children': 'Seiten mit Unterseiten können noch nicht dupliziert werden.', 'commands.add_subpage.title': 'Neue Seite anlegen', 'commands.add_subpage.tooltip': 'Seite unterhalb $1 anlegen', 'commands.copy_page_from_clipboard.title': 'Markierte Seite hierher kopieren', 'commands.copy_page_from_clipboard.paste_forbidden': 'Aufgrund ihres Typs kann die Seite hier nicht eingefügt werden. Nur Seiten der folgenden Typen können hierher verschoben oder kopiert werden: $1', 'commands.move_page_from_clipboard.title': 'Markierte Seite hierher verschieben', 'commands.move_page_from_clipboard.paste_forbidden': 'Aufgrund ihres Typs kann die Seite hier nicht eingefügt werden. Nur Seiten der folgenden Typen können hierher verschoben oder kopiert werden: $1', 'obj_sorting_dialog.title': 'Elemente sortieren', 'commands.sort_items.title': 'Elemente sortieren', 'commands.sort_items.tooltip': 'Reihenfolge der Elemente unterhalb $1 bearbeiten', 'commands.sort_items.auto_sort': 'Diese Navigation wird automatisch sortiert.', 'commands.sort_items.too_less_children': 'Die Navigation kann nicht sortiert werden, weil sie weniger als zwei Elemente enthält.', 'commands.select_workspace.x_and_1_owner': '$1 und 1 weiterer Besitzer', 'commands.select_workspace.x_and_n_owners': '$1 und $2 weitere Besitzer', 'commands.select_workspace.disabled': 'Diese Arbeitskopie kann aufgrund fehlender Benutzerrechte nicht ausgewählt werden', 'commands.choose_and_create_widget.title': 'Widget einfügen', 'commands.choose_and_create_widget.disabled': 'Sie können hier keine Widgets einfügen.', 'commands.create_widget.title': '$1 einfügen', 'commands.add_content.title': 'Inhalt einfügen', 'commands.add_content.not_allowed': 'Es ist nicht erlaubt in dieses Feld beliebige Inhalte einzufügen', 'commands.widget_details.title': 'Widget-Eigenschaften', 'commands.widget_details.no_details_view': 'Dieses Widget hat keine Eigenschaften', 'commands.widget_details.dialog.title': 'Eigenschaften von "$1"', 'commands.save_widget_to_clipboard.content_title': 'Inhalt zum Kopieren markieren', 'commands.save_widget_to_clipboard.widget_title': 'Widget zum Kopieren markieren', 'commands.copy_widget_from_clipboard.content_title': 'Kopie des markierten Inhalts einfügen', 'commands.copy_widget_from_clipboard.widget_title': 'Kopie des markierten Widgets einfügen', 'commands.copy_widget_from_clipboard.paste_forbidden': 'Aufgrund seines Typs kann das Widget hier nicht eingefügt werden. Nur Widgets der folgenden Typen können hierher verschoben oder kopiert werden: $1.', 'commands.delete_widget.content_title': 'Inhalt löschen', 'commands.delete_widget.widget_title': 'Widget löschen', 'commands.delete_widget.dialog.title': 'Wirklich dieses Widget löschen?', 'commands.delete_widget.dialog.description': 'Ein gelöschtes Widget kann nicht wiederhergestellt werden.', 'commands.delete_widget.dialog.confirm': 'Löschen', 'commands.switch_mode.view': 'Vorschau', 'commands.switch_mode.editing': 'Bearbeiten', 'commands.switch_mode.diff': 'Vergleichen', 'commands.switch_mode.added': 'Hinzugefügt', 'commands.switch_mode.deleted': 'Gelöscht', 'commands.switch_mode.disabled': 'Aktuell ausgewählter Anzeigemodus', 'commands.publish_workspace.title': 'Veröffentlichen', 'commands.publish_workspace.permission_denied': 'Die Arbeitskopie kann aufgrund fehlender Benutzerrechte nicht veröffentlicht werden.', 'commands.publish_workspace.dialog.confirm': 'Veröffentlichen', 'commands.publish_workspace.dialog.title': '"$1" veröffentlichen?', 'commands.publish_workspace.dialog.description': 'Eine Arbeitskopie zu veröffentlichen ist endgültig. Dieser Vorgang kann nicht rückgängig gemacht werden.', 'commands.publish_workspace.error_dialog.title': 'Arbeitskopie konnte nicht veröffentlicht werden', 'commands.publish_workspace.error_dialog.description': 'Bitte entnehmen Sie die Details der Liste der Änderungen.', 'commands.publish_workspace.error_dialog.confirm': 'Liste der Änderungen', 'commands.publish_workspace.alert.invalid_certificates': 'Die Arbeitskopie konnte nicht veröffentlicht werden, weil mindestens ein Benutzer gerade Inhalte darin ändert.', 'ajax.error': 'Die Kommunikation mit dem CMS ist aufgrund eines Fehlers fehlgeschlagen: $1', 'ajax.error.communication': 'Die Kommunikation mit dem CMS ist fehlgeschlagen. Bitte überprüfen Sie Ihre Netzwerkverbindung.', 'ajax.error.unknown': 'Die Kommunikation mit dem CMS ist aufgrund eines unbekannten Fehlers fehlgeschlagen.', 'ajax.error.production': 'Bei Ihrer letzten Aktion ist ein technischer Fehler aufgetreten. Bitte versuchen Sie es später noch einmal. Falls das Problem bestehen bleibt, wenden Sie sich bitte an Ihren technischen Ansprechpartner für diese Website.', 'workspace_limit_exceeded.message': 'In Ihrem Tarif sind keine weiteren Arbeitskopien verfügbar. Bitte wechseln Sie den Tarif.', 'warn_before_unloading': 'Sie haben nicht gespeicherte Änderungen! Sind Sie sicher, dass sie schließen wollen?' }, 'de'); $.i18n().load({ 'confirm': 'Confirm', 'cancel': 'Cancel', 'save': 'Save', 'welcome': 'Welcome', 'welcome_x': 'Welcome $1', 'accept': 'Accept', 'close': 'Close', 'done': 'Done', 'loading': 'Loading...', 'current_page': 'current page', 'ok': 'Ok', 'obj.tooltip.is_new': 'This page is new.', 'obj.tooltip.is_edited': 'This page has been modified.', 'obj.tooltip.is_deleted': 'This page has been deleted.', 'workspace.title_published': 'Published content', 'workspace.empty_title': '', 'workspace_settings_dialog.owners': 'Owners', 'workspace_settings_dialog.nothing_found': 'Nothing found', 'workspace_settings_dialog.searching': 'Searching...', 'workspace_settings_dialog.too_short': 'Find user...', 'workspace_select.outdated': 'outdated', 'workspace_select.this_workspace': 'This working copy', 'workspace_select.other_workspaces': 'Other working copies', 'menu_item.spinner.loading': 'Loading...', 'choose_obj_class_dialog.add_child_page.title': 'Select Page Type', 'choose_obj_class_dialog.create_widget.title': 'Select Widget', 'choose_obj_class_dialog.last_used': 'Last used', 'choose_obj_class_dialog.popular': 'Often used', 'choose_obj_class_dialog.all': 'All', 'editable_ws_dialog.title.select_or_create': 'Choose a working copy', 'editable_ws_dialog.title.select': 'Select a working copy', 'editable_ws_dialog.title.create': 'Create a working copy', 'editable_ws_dialog.title.forbidden': 'No working copy available', 'editable_ws_dialog.description.select_or_create': 'To alter content, select or create a working copy first. When you finished editing, publish the working copy or have it published.', 'editable_ws_dialog.description.select': 'To alter content, select a working copy first. When you finished editing, publish the working copy or have it published.', 'editable_ws_dialog.description.create': 'To alter content, create a working copy first. When you finished editing, publish the working copy or have it published.', 'editable_ws_dialog.description.forbidden': 'There is no working copy you could use to alter content. Also, creating working copies has not been enabled for you.', 'editable_ws_dialog.choose_existing': 'Select an existing working copy:', 'editable_ws_dialog.create_new': 'Create a new working copy:', 'editable_ws_dialog.or_create_new': 'Or, create a new one:', 'editable_ws_dialog.create_new_playholder': 'new working copy title', 'editable_ws_dialog.select': 'Select', 'resource_dialog.title': 'Properties of resource "$1"', 'resource_dialog.commands.revert_obj.title': 'Discard changes to resource', 'resource_dialog.commands.revert_obj.new_obj': 'This is a new resource. To discard the creation of this resource, please delete it.', 'resource_dialog.commands.revert_obj.not_modified_obj': 'This resource has not been modified. Therefore, nothing can be discarded.', 'resource_dialog.commands.revert_obj.dialog.title': 'Really discard changes to this resource?', 'resource_dialog.commands.restore_obj.title': 'Restore resource', 'resource_dialog.commands.mark_resolved_obj.title': 'Override concurrent changes to resource', 'resource_dialog.commands.mark_resolved_obj.dialog.description': 'This resource was altered in a different working copy that has been published. Please confirm that you want to keep your changes and discard the ones concurrently made by others.', 'resource_dialog.commands.delete_obj.title': 'Delete resource', 'resource_dialog.commands.delete_obj.dialog.title': 'Really delete this resource?', 'resource_dialog.commands.delete_obj.dialog.description': 'Changes to a deleted resource cannot be restored.', 'menu_bar.loading_workspaces': 'Loading working copies', 'menu_bar.create': 'Create', 'menu_bar.move': 'Move', 'menu_bar.copy': 'Copy', 'saving_indicator_item.saving': 'Saving...', 'saving_indicator_item.saved': 'Changes saved', 'menu_bar_warning.warning': 'Check JS console', 'menu_bar_warning.open_console': 'There are warnings. Please open the JavaScript console for details.', 'menu_bar_conflict_indicator.conflict_description': 'A different version of this page has been published in the meantime. Resolve the conflict to be able to publish this working copy.', 'menu_bar_conflict_indicator.conflict_headline': 'Conflict', 'menu_bar_conflict_indicator.outdated_description': 'A new version of this page has been published. Update this working copy now to avoid a conflict.', 'menu_bar_conflict_indicator.outdated_headline': 'New version', 'menu_bar_conflict_indicator.warn_description': 'Changes to this page will cause a conflict when publishing. The page has already been modified in these working copies:', 'menu_bar_conflict_indicator.warn_headline': 'Potential conflict', 'menu_bar_device_toggle.description': 'Preview size', 'menu_bar_device_toggle.command.title.mobile': 'Mobile phone, portrait', 'menu_bar_device_toggle.command.title.tablet': 'Tablet, portrait', 'menu_bar_device_toggle.command.title.laptop': 'Laptop', 'menu_bar_device_toggle.command.title.desktop': 'Desktop', 'menu_bar_device_toggle.command.disabled': 'Currently selected size', 'inplace_marker.overlapping': 'Two or more menu handles are overlapping. Please adjust your CSS. The following menu handles are overlapping:', 'widget_marker.widget_is_new': 'Widget is new', 'widget_marker.widget_is_edited': 'Widget has been modified', 'widget_marker.widget_is_edited_and_dragged_here': 'Widget has been modified and dragged here', 'widget_marker.widget_is_edited_and_dragged_away': 'Widget has been modified and dragged away from here', 'widget_marker.widget_is_deleted': 'Widget has been deleted', 'widget_marker.widget_is_dragged_here': 'Widget has been dragged here', 'widget_marker.widget_is_dragged_away': 'Widget has been dragged away from here', 'child_list_menu.description': 'Items of $1', 'changes_dialog.title': 'Changes to "$1"', 'changes_dialog.empty': 'Nothing was changed in this working copy.', 'changes_dialog.more': 'More...', 'changes_dialog.modification': 'Change', 'changes_dialog.rights': 'Publishing permitted', 'changes_dialog.description_for_editor': 'Title', 'changes_dialog.obj_class_name': 'Type', 'changes_dialog.last_changed': 'Last change', 'current_page_link_dialog.title': 'Share this page', 'current_page_link_dialog.description': 'Using the URL below, you can share the current page as part of this working copy. The recipients need to be logged in and have access to the working copy.', 'commands.current_page_link.title': 'Share this page', 'commands.create_workspace.forbidden': 'You can not create a workspace due to missing user permissions.', 'commands.create_workspace.title': 'Create working copy', 'commands.create_workspace.dialog.title': 'Create working copy', 'commands.create_workspace.dialog.description': 'Please enter the title of the new working copy.', 'commands.create_workspace.dialog.placeholder': 'new title', 'commands.create_workspace.dialog.accept': 'Create', 'commands.rename_workspace.title': 'Rename', 'commands.rename_workspace.dialog.title': 'Rename "$1"', 'commands.rename_workspace.dialog.description': 'Please enter the new title of the working copy.', 'commands.rename_workspace.dialog.accept': 'Rename', 'commands.rebase_workspace.title': 'Update', 'commands.rebase_workspace.tooltip': 'Working copy "$1" is outdated. Please update it.', 'commands.rebase_workspace.uptodate': 'Working copy "$1" is up to date.', 'commands.rebase_workspace.has_conflicts.title': 'Changed content has been published intermediately', 'commands.rebase_workspace.has_conflicts.description': 'Your working copy could not be fully updated. Some of its content has also been altered in a different working copy that has been published in the meantime. Please refer to the changes list for details.', 'commands.rebase_workspace.open_changes_dialog': 'Show changes', 'commands.delete_workspace.title': 'Delete', 'commands.delete_workspace.dialog.title': 'Really delete "$1"?', 'commands.delete_workspace.dialog.description': 'A deleted working copy cannot be restored.', 'commands.delete_workspace.dialog.confirm': 'Delete', 'commands.workspace_settings.title': 'Edit settings', 'commands.workspace_settings.dialog.title': 'Settings for "$1"', 'commands.workspace_changes.title': 'Show changes', 'commands.obj_details.title_edit': 'Edit page properties', 'commands.obj_details.title_view': 'View page properties', 'commands.obj_details.dialog.title_edit': 'Edit properties of "$1"', 'commands.obj_details.dialog.title_view': 'View properties of "$1"', 'commands.save_obj_to_clipboard.title': 'Mark page for copying or moving', 'commands.save_obj_to_clipboard.has_children': 'Pages with subpages cannot be copied or moved yet.', 'commands.delete_obj.title': 'Delete page', 'commands.delete_obj.published_workspace': 'Since this is the published content, nothing can be modified.', 'commands.delete_obj.has_children': 'Pages with subpages cannot be deleted yet.', 'commands.delete_obj.dialog.title': 'Really delete this page?', 'commands.delete_obj.dialog.description': 'Changes to a deleted page cannot be restored.', 'commands.delete_obj.dialog.confirm': 'Delete', 'commands.revert_obj.title': 'Discard changes to page', 'commands.revert_obj.published_workspace': 'Since this is the published content, nothing has been modified. Therefore, nothing can be discarded.', 'commands.revert_obj.new_obj': 'This is a new page. To discard the creation of this page, please delete it.', 'commands.revert_obj.is_binary': 'Discarding changes is not available for binary content.', 'commands.revert_obj.not_modified_obj': 'This page has not been modified. Therefore, nothing can be discarded.', 'commands.revert_obj.dialog.title': 'Really discard changes to this page?', 'commands.revert_obj.dialog.description': 'Discarded changes cannot be restored.', 'commands.revert_obj.dialog.confirm': 'Discard', 'commands.revert_widget.content_title': 'Discard changes to content', 'commands.revert_widget.widget_title': 'Discard changes to widget', 'commands.revert_widget.is_new': 'This is a new widget. To discard the creation of this widget, please delete it.', 'commands.revert_widget.is_not_modified': 'This widget has not been modified. Therefore, nothing can be discarded.', 'commands.revert_widget.dialog.title': 'Really discard changes to this widget?', 'commands.revert_widget.dialog.description': 'Discarded changes cannot be restored.', 'commands.revert_widget.dialog.confirm': 'Discard', 'commands.restore_widget.title': 'Restore widget', 'commands.restore_obj.title': 'Restore page', 'commands.mark_resolved_obj.title': 'Override concurrent changes to page', 'commands.mark_resolved_obj.dialog.confirm': 'Override changes', 'commands.mark_resolved_obj.dialog.title': 'Really override changes made by others in the meantime?', 'commands.mark_resolved_obj.dialog.description': 'This page was altered in a different working copy that has been published. Please confirm that you want to keep your changes and discard the ones concurrently made by others.', 'commands.duplicate_obj.title': 'Duplicate page', 'commands.duplicate_obj.published_workspace': 'Since this is the published content, nothing can be modified.', 'commands.duplicate_obj.has_children': 'Pages with subpages cannot be duplicated yet.', 'commands.add_subpage.title': 'Create new page', 'commands.add_subpage.tooltip': 'Create page underneath $1', 'commands.copy_page_from_clipboard.title': 'Copy marked page here', 'commands.copy_page_from_clipboard.paste_forbidden': 'Due to its type, the page cannot be moved or copied here. Only pages of the following types can be inserted here: $1', 'commands.move_page_from_clipboard.title': 'Move marked page here', 'commands.move_page_from_clipboard.paste_forbidden': 'Due to its type, the page cannot be moved or copied here. Only pages of the following types can be inserted here: $1', 'obj_sorting_dialog.title': 'Sort items', 'commands.sort_items.title': 'Sort items', 'commands.sort_items.tooltip': 'Edit order of items underneath $1', 'commands.sort_items.auto_sort': 'This navigation is sorted automatically.', 'commands.sort_items.too_less_children': 'This navigation cannot be sorted because it consists of less than two items.', 'commands.select_workspace.x_and_1_owner': '$1 and 1 other owner', 'commands.select_workspace.x_and_n_owners': '$1 and $2 other owners', 'commands.select_workspace.disabled': 'This working copy can not be selected due to missing user permissions.', 'commands.choose_and_create_widget.title': 'Insert widget', 'commands.choose_and_create_widget.disabled': 'You cannot insert any widgets here.', 'commands.create_widget.title': 'Insert $1', 'commands.add_content.title': 'Insert content', 'commands.add_content.not_allowed': 'It is not allowed to insert random content into this field.', 'commands.widget_details.title': 'Widget properties', 'commands.widget_details.no_details_view': 'This widget has no properties', 'commands.widget_details.dialog.title': 'Properties of "$1"', 'commands.save_widget_to_clipboard.content_title': 'Mark content for copying', 'commands.save_widget_to_clipboard.widget_title': 'Mark widget for copying', 'commands.copy_widget_from_clipboard.content_title': 'Insert copy of marked content', 'commands.copy_widget_from_clipboard.widget_title': 'Insert copy of marked widget', 'commands.copy_widget_from_clipboard.paste_forbidden': 'Due to its type, the widget cannot be moved or copied here. Only widgets of the following types can be inserted here: $1.', 'commands.delete_widget.content_title': 'Delete content', 'commands.delete_widget.widget_title': 'Delete widget', 'commands.delete_widget.dialog.title': 'Really delete this widget?', 'commands.delete_widget.dialog.description': 'A deleted widget cannot be restored.', 'commands.delete_widget.dialog.confirm': 'Delete', 'commands.switch_mode.view': 'Preview', 'commands.switch_mode.editing': 'Edit', 'commands.switch_mode.diff': 'All changes', 'commands.switch_mode.added': 'Additions', 'commands.switch_mode.deleted': 'Deletions', 'commands.switch_mode.disabled': 'Currently selected display mode', 'commands.publish_workspace.title': 'Publish', 'commands.publish_workspace.permission_denied': 'The working copy can not be published due to missing user permissions.', 'commands.publish_workspace.dialog.confirm': 'Publish', 'commands.publish_workspace.dialog.title': 'Publish "$1"?', 'commands.publish_workspace.dialog.description': 'Publishing a working copy is final. This action cannot be undone.', 'commands.publish_workspace.error_dialog.title': 'Working copy could not be published', 'commands.publish_workspace.error_dialog.description': 'Please check the changes list for details.', 'commands.publish_workspace.error_dialog.confirm': 'Open changes list', 'commands.publish_workspace.alert.invalid_certificates': 'The working copy could not be published because at least one user is currently modifying content in it.', 'ajax.error': 'Communication with the CMS failed with error: $1', 'ajax.error.communication': 'Communication with the CMS failed. Please check your network connectivity.', 'ajax.error.unknown': 'Communication with the CMS failed for unknown reasons.', 'ajax.error.production': 'During your last action, a technical error occurred. Please try again later. If the problem persists, please contact a technician familiar with this website.', 'workspace_limit_exceeded.message': 'You have reached the maximum number of working copies included in your plan. Please consider to have your plan upgraded.', 'warn_before_unloading': 'You have unsaved changes. Are you sure you want to quit?', 'test.two_arguments': '$1, $2', 'test.four_arguments': '$1, $2, $3, $4' }, 'en'); /* global alert:false */ var scrivito = {}; (function() { var inited = false; var ui_config_attr_name = 'data-scrivito-private-ui-config'; var wait_until_write_ends = function() { var deferred = $.Deferred(); if (scrivito.write_monitor.is_writing()) { scrivito.write_monitor.on('end_write', function() { wait_until_write_ends().done(function() { deferred.resolve(); }); }); } else { deferred.resolve(); } return deferred; }; var convert_internal_error = function(error) { // message is the only field of an error that is public API return {message: error.message}; }; var restore_prior_attr = function(promise, dom_element, attr_name) { var prior_attr = dom_element.attr(attr_name); promise.always(function() { if (prior_attr) { dom_element.attr(attr_name, prior_attr); } else { // jQuery#removeAttr violates CSP by assigning an empty value. dom_element.get(0).removeAttribute(attr_name); } }); }; _.extend(scrivito, { suppress_alerts: false, popular_obj_classes: [], alert: function(message) { if (!scrivito.suppress_alerts) { window.alert(message); } }, warn: function() { if (scrivito.is_development_mode) { scrivito.menu_bar_warning.show(); } if (window.console) { window.console.warn.apply(window.console, arguments); } }, log_error: function(message, exception) { if (window.console) { window.console.error(message, exception); } }, redirect_to: function(location, target_window) { wait_until_write_ends().done(function() { scrivito.change_location(location, target_window); }); return $.Deferred(); }, change_editing_context: function(params) { return scrivito.redirect_to(scrivito.editing_context.location(params).href()); }, open_obj: function(obj) { if (obj.is_binary() && ( obj.is_edited() || obj.is_new() && !scrivito.editing_context.is_deleted_mode() || obj.is_deleted() && scrivito.editing_context.is_deleted_mode())) { scrivito.resource_dialog.open(obj); } else { var url = scrivito.root_path(); var params = {}; if (obj.is_binary()) { url = '/__scrivito/resource_details/'; params.return_to = document.URL; } if (obj.is_new() && scrivito.editing_context.is_deleted_mode()) { params._scrivito_display_mode = 'added'; } if (obj.is_deleted() && !scrivito.editing_context.is_deleted_mode()) { params._scrivito_display_mode = 'deleted'; } url += obj.id(); if (!_.isEmpty(params)) { url += '?'+$.param(params); } scrivito.with_saving_overlay(scrivito.redirect_to(url)); } }, // For testing purpose only. location: function() { return window.location; }, // For testing purpose only. change_location: function(location, target_window) { (target_window || window).location = location; }, wait: function(seconds) { // this is a proxy method, so we can stub it easier. return $.Deferred(function(dfd) { setTimeout(dfd.resolve, seconds * 1000); }); }, run_new_event: function(method) { scrivito.wait(0).done(method); }, reload: function(target_window) { wait_until_write_ends().done(function() { scrivito.reload_location(target_window); }); return $.Deferred(); }, // For testing purpose only. reload_location: function(target_window) { (target_window || window).location.reload(); }, center: function(elem) { if (elem.length === 1) { elem.css({ marginLeft: -elem.innerWidth() / 2, marginTop: -elem.innerHeight() / 2, left: '50%' }); } }, ensure_fully_visible_within: function(dom_element, viewport_container, viewport_height) { var viewport_offset = viewport_container.scrollTop(); var dom_element_offset = dom_element.offset().top; var dom_element_height = dom_element.height(); var scroll_top; if (viewport_offset > dom_element_offset) { scroll_top = dom_element_offset - 50; } else if (dom_element_offset + dom_element_height > viewport_offset + viewport_height) { scroll_top = dom_element_height + dom_element_offset + 50 - viewport_height; } if (scroll_top) { viewport_container.animate({scrollTop: scroll_top}); } }, ensure_fully_visible_within_window: function(dom_element) { var cms_document = scrivito.cms_document.from(dom_element); scrivito.ensure_fully_visible_within(dom_element, cms_document.dom_element().find('body'), $(cms_document.browser_window()).height() ); }, describe_element: function(elem) { var description = elem.get(0).nodeName; if (elem.attr("id")) { description += "#"+elem.attr("id"); } var css_class = elem.attr('class'); if (css_class) { _(css_class.split(" ")).each(function(class_name) { description += "."+class_name; }); } return "["+description+"]"; }, remove_enter_and_escape_action: function() { $(document).off('keyup.scrivito_enter_escape_action'); }, random_hex: function() { var hex = Math.floor(Math.random() * Math.pow(16, 8)).toString(16); while (hex.length < 8) { hex = '0' + hex; } return hex; }, // 16 chars hex string random_id: function() { return scrivito.random_hex() + scrivito.random_hex(); }, deprecation_warning: function(subject, alternative) { var message = 'DEPRECATION WARNING: "' + subject + '" is deprecated.'; if (alternative) { message += ' Please use "' + alternative + '" instead.'; } scrivito.warn(message); }, on: function(event, callback) { if (event === 'load') { scrivito.gui.on('open', function() { callback(); }); if (scrivito.gui.is_started()) { scrivito.run_new_event(function() { callback(); }); } } else if (event === 'content') { scrivito.gui.on('content', function(dom_element) { callback(dom_element); }); if (scrivito.gui.is_started()) { scrivito.run_new_event(function() { callback(window.document); }); } } else { $.error('Unknown event "' + event + '"'); } }, create_obj: function(attributes) { return scrivito.obj.create(attributes).then(function(obj) { return {id: obj.id()}; }, convert_internal_error); }, delete_obj: function(id) { if (id) { return scrivito.obj.create_instance({id: id}).destroy() .then(null, convert_internal_error); } else { $.error("Can't delete without ID"); } }, is_current_page_restricted: function() { var current_page = scrivito.application_document().page(); if (current_page) { return current_page.has_restriction(); } }, never_resolve: function() { return $.Deferred(); }, trigger: function(event_name, dom_element) { if (event_name === 'content') { _.each($(dom_element), function(e) { scrivito.gui.new_content(e); }); } else if (event_name === 'new_content') { scrivito.deprecation_warning( 'scrivito.trigger("new_content")', 'scrivito.trigger("content")'); scrivito.trigger('content', dom_element); } else { $.error('Unknown event "' + event_name + '"'); } }, in_editable_view: function() { return scrivito.editing_context.display_mode === 'editing' && scrivito.editing_context.visible_workspace.is_editable(); }, open_resource_dialog: function(obj_id) { return scrivito.resource_dialog.open(obj_id); }, // See http://underscorejs.org/#throttle throttle: function(fn, ms) { return scrivito.bypass_throttle ? fn : _.throttle(fn, ms); }, json_parse_base64: function(base64_string) { // See http://mzl.la/1p1zI9k. var dom_string = decodeURIComponent(window.escape(atob(base64_string))); return JSON.parse(dom_string); }, json_stringify_base64: function(object) { var dom_string = JSON.stringify(object); // See http://mzl.la/1p1zI9k. return btoa(window.unescape(encodeURIComponent(dom_string))); }, t: function() { return scrivito.i18n.translate.apply(null, arguments); }, // proxy function so that other gems need no knowledge of `cms_document` register_public_api: function() { return scrivito.cms_document.register_public_api.apply(this, arguments); }, is_inited: function() { return inited; }, application_document: function() { return scrivito.application_window.document(); }, root_path: function() { return scrivito.application_window.is_frame() ? '/scrivito/' : '/'; }, details_url_for_obj_id: function(id) { return scrivito.obj.create_instance({id: id}).details_src(); }, workspace_limit_exceeded: function() { scrivito.info_dialog(scrivito.t('workspace_limit_exceeded.message')); }, register_default_obj_class_for_content_type: function(mapping) { scrivito.obj_class_defaults.register(mapping); }, default_obj_class_for_content_type: function(content_type) { return scrivito.obj_class_defaults.lookup(content_type); }, pattern_sort: function(items, patterns) { if (patterns && patterns.length) { var results = []; _.each(patterns, function(pattern, index) { if (!pattern.match(/(.*)\.\*$/)) { var hit = _.find(items, function(item) { return item.id() === pattern; }); if (hit) { results[index] = hit; items = _.without(items, hit); } } }); _.each(patterns, function(pattern, index) { if (pattern.match(/(.*)\.\*$/)) { var hits = _.select(items, function(item) { return !item.id().indexOf(pattern.replace('.*', '')); }); if (hits.length) { results[index] = hits; items = _.difference(items, hits); } } }); return _.flatten(_.compact(results.concat(items))); } else { return items; } }, page_menu: function(cms_document) { return scrivito.menu_builder.create_instance(cms_document); }, custom_dialog: function(iframe, doc, content, options) { var dialog = scrivito.iframe_dialog.open(iframe, options); dialog.when_open.done(function(dialog_body) { var panel = scrivito.full_screen_panel(doc, dialog.when_closed); panel.css('background-color', dialog_body.css('background-color')); panel.append(content); }); return {when_closed: dialog.when_closed}; }, register_browse_content: function (browse_content) { scrivito.browse_content = browse_content; }, ui_config: function() { return scrivito.dom_config.read($('body'), ui_config_attr_name); }, // For test purpose only. mock_ui_config: function(config) { if (config) { scrivito.dom_config.write($('body'), ui_config_attr_name, config); } else { $('body').removeAttr(ui_config_attr_name); } }, restore_styles_afterwards: function(promise, dom_element) { restore_prior_attr(promise, dom_element, 'class'); restore_prior_attr(promise, dom_element, 'style'); }, // FIXME content-widget enable_content_upload: false, is_development_mode: false, init: function(config) { scrivito.config = config; scrivito.editing_context.init(config.editing_context); scrivito.i18n.init(config.i18n); scrivito.resource_dialog.init(config.resource_dialog); scrivito.user.init(config.user); scrivito.user_permissions.init(config.user_permissions); scrivito.is_development_mode = config.is_development_mode; scrivito.inplace_marker.init(); scrivito.option_marker.init(); scrivito.menu_bar_saving_indicator.init(); scrivito.menu_bar_device_toggle.init(); scrivito.menu_bar_warning.init(); scrivito.menu_bar_toggle.init(); scrivito.current_page_menu.init(); scrivito.menu_bar_browse_content.init(); scrivito.menu_bar_conflict_indicator.init(); scrivito.current_page_restriction.init(); scrivito.workspace_select.init(); scrivito.menu_bar.init(); scrivito.child_list_commands.init(); scrivito.current_page_commands.init(); scrivito.widget_commands.init(); scrivito.widgetlist_field_commands.init(); scrivito.child_list_marker.init(); scrivito.widgetlist_field_menu.init(); scrivito.widget_marker.init(); scrivito.dynamic_menus.init(); scrivito.external_links.init(); scrivito.widget_reloading.init(); scrivito.widget_sorting.init(); scrivito.no_turbolinks.init(); // FIXME content-widget if (scrivito.enable_content_upload) { scrivito.content_upload.init(); } scrivito.reloading.init(); window.onbeforeunload = scrivito.warn_before_unloading; scrivito.url_update(scrivito.application_window, scrivito.cms_window.from(window)); scrivito.application_window.use_fragment_of(scrivito.cms_window.from(window)); inited = true; } }); }()); (function() { var valid_locale = ['en', 'de']; var language; _.extend(scrivito, { i18n: { init: function(config) { scrivito.i18n.set_locale(config.locale); }, locale: function() { return language; }, set_locale: function(locale) { if($.inArray(locale, valid_locale) !== -1) { language = locale; } else { language = 'en'; } moment.locale(language); }, // In addition to the key you can pass multiple parameters that will be interpolated into // the translated string. translate: function(key) { if (!scrivito.i18n.locale()) { $.error('scrivito.i18n locale not yet set!'); } $.i18n().locale = scrivito.i18n.locale(); return $.i18n.apply(0, arguments); }, // localize_date localizes an ISO6801 date string according to the current locale. localize_date: function(date_string) { return moment(date_string).format('LLLL'); }, // localize_date_relative converts an ISO6801 date string to a relative time and localizes it // according to the current locale. localize_date_relative: function(date_string) { return moment(date_string).fromNow(); }, // Test purpose only. reset_locale: function() { language = undefined; } } }); }()); (function() { var assert_valid_dom_element = function(dom_element) { if (dom_element.length < 1) { $.error('Can not call "scrivito" method on an empty element'); } if (dom_element.length > 1) { $.error('Can not call "scrivito" method on more than one tag'); } }; var build_cms_element = function(dom_element) { return scrivito.cms_element.from_dom_element(dom_element); }; var save_content = function(dom_element, content) { if (dom_element.length > 0) { if (dom_element.length === 1) { if (content === undefined) { $.error('Can not call "save" with no content'); } else { var cms_element = build_cms_element(dom_element); cms_element.set_original_content(content); return cms_element.save(content).then(function() { return; }, function(error) { return {message: error.message}; }); } } else { $.error('Can not call "scrivito" method on more than one tag'); } } }; var get_original_content = function(dom_element) { assert_valid_dom_element(dom_element); return build_cms_element(dom_element).original_content(); }; var get_menu = function(dom_element) { assert_valid_dom_element(dom_element); var cms_element = build_cms_element(dom_element); return scrivito.menu_builder.create_instance(cms_element); }; var reload = function(dom_element) { assert_valid_dom_element(dom_element); build_cms_element(dom_element); $(dom_element).trigger('reload.scrivito'); }; _.extend(scrivito, { // @api public jquery_plugin: function(method, content) { switch (method) { case 'save': return save_content($(this), content); case 'content': return get_original_content($(this)); case 'menu': return get_menu($(this)); case 'reload': reload($(this)); break; default: $.error('Unknown method "' + method + '"'); } } }); $.fn.scrivito = scrivito.jquery_plugin; }()); (function() { _.extend(scrivito, { dom_config: { read: function(dom_element, attr_name) { var selector = '[' + attr_name + ']'; var config = dom_element.find(selector).addBack(selector).attr(attr_name); if (config) { return JSON.parse(config); } }, write: function(dom_element, attr_name, config) { dom_element.attr(attr_name, JSON.stringify(config)); } } }); }()); (function() { _.extend(scrivito, { url_update: function(application_cms_window, ui_cms_window) { if (application_cms_window === ui_cms_window) { return; } application_cms_window.on('document', function(application_document) { var ui_window = ui_cms_window.browser_window(); var application_window = application_document.browser_window(); var ui_url = ui_window.location.origin + '/scrivito' + application_window.location.pathname + application_window.location.search + application_window.location.hash; ui_window.history.replaceState({}, '', ui_url); }); } }); }()); (function() { var is_started = false; var callbacks = {}; // The callback has to be function that takes no arguments var log_exception_in_callback = function(event_name, callback) { if (scrivito.gui.sandbox_callbacks) { try { callback(); } catch(exception) { var text = "'"+event_name+"' callback threw exception: "; scrivito.log_error(text, exception); } } else { callback(); } }; var run_open_callbacks = function() { if (callbacks.open) { _.each(callbacks.open, function(callback) { log_exception_in_callback('open', callback); }); } if (scrivito.editing_context.is_editing_mode() && callbacks.editing) { _.each(callbacks.editing, function(callback) { log_exception_in_callback('editing', callback); }); } }; _.extend(scrivito, { gui: { start: function() { scrivito.gui.on('document', function(document) { var body = document.dom_element().find('body'); body.attr('data-scrivito-display-mode', scrivito.editing_context.display_mode); _.each(['dragenter', 'dragover', 'drop'], function(e) { body.on(e, false); }); }); $('body').append('
    '); run_open_callbacks(); scrivito.gui.run_content_callbacks(window.document); is_started = true; }, // For test purpose only. stop: function() { is_started = false; }, new_content: function(dom_element) { scrivito.gui.run_content_callbacks(dom_element); if (dom_element) { var cms_document = scrivito.cms_document.from($(dom_element)); cms_document.notify_new_content(dom_element); } }, new_document: function(document) { _.each(callbacks.document, function(callback) { callback(document); }); document.window().notify_new_document(document); }, on: function(event_name, callback) { if (callbacks[event_name] === undefined) { callbacks[event_name] = []; } callbacks[event_name].push(callback); }, run_content_callbacks: function(dom_element) { if (callbacks.content) { _.each(callbacks.content, function(callback) { if (dom_element) { log_exception_in_callback('content', function() { callback(dom_element); }); } }); } }, // For testing purpose only. reset_callbacks: function() { callbacks = {}; }, // For testing purpose only. sandbox_callbacks: true, is_started: function() { return is_started; } } }); }()); (function() { _.extend(scrivito, { editing_context: { display_mode: null, selected_workspace: null, visible_workspace: null, init: function(config) { scrivito.editing_context.display_mode = config.display_mode; var visible_workspace = scrivito.workspace.from_data(config.visible_workspace); var selected_workspace = scrivito.workspace.from_data(config.selected_workspace); scrivito.editing_context.visible_workspace = visible_workspace; scrivito.editing_context.selected_workspace = selected_workspace; if (document.hasFocus()) { scrivito.editing_context.write_cookie(); } $.ajaxPrefilter(scrivito.editing_context.ajax_prefilter); scrivito.gui.on('document', function(cms_document) { if (!window.cms_documents) { window.cms_documents = []; } window.cms_documents.push(cms_document); cms_document.local_jquery().ajaxPrefilter(scrivito.editing_context.ajax_prefilter); }); // This can not be unit tested, since it is not possible to trigger a 'focus' // event on a 'window' object with JavaScript. $(window).focus(function() { scrivito.editing_context.write_cookie(); }); }, location: function(params) { var uri = new URI(scrivito.location()); if (params.workspace_id) { uri.setQuery('_scrivito_workspace_id', params.workspace_id); } if (params.display_mode) { uri.setQuery('_scrivito_display_mode', params.display_mode); } return uri; }, is_view_mode: function() { return scrivito.editing_context.display_mode === 'view'; }, is_editing_mode: function() { return scrivito.editing_context.display_mode === 'editing'; }, is_added_mode: function() { return scrivito.editing_context.display_mode === 'added'; }, is_deleted_mode: function() { return scrivito.editing_context.display_mode === 'deleted'; }, is_diff_mode: function() { return scrivito.editing_context.display_mode === 'diff'; }, is_comparing_mode: function() { return scrivito.editing_context.is_added_mode() || scrivito.editing_context.is_deleted_mode() || scrivito.editing_context.is_diff_mode(); }, ajax_prefilter: function(options, originalOptions, xhr) { if (!options.crossDomain) { xhr.setRequestHeader('Scrivito-Editing-Context', serialize()); } }, write_cookie: function() { $.cookie('scrivito_editing_context', serialize(), {path: '/'}); }, comparing_mode: function() { var storage_key = 'editing_context.comparing_mode'; if (scrivito.editing_context.is_comparing_mode()) { var mode = scrivito.editing_context.display_mode; scrivito.storage.set(storage_key, mode); return mode; } else { if (scrivito.storage.has_key(storage_key)) { return scrivito.storage.get(storage_key); } else { return 'diff'; } } } } }); var serialize = function() { return JSON.stringify({ display_mode: scrivito.editing_context.display_mode, workspace_id: scrivito.editing_context.selected_workspace.id() }); }; }()); (function() { _.extend(scrivito, { user_permissions: { permissions_hash: {}, init: function(permissions_hash) { scrivito.user_permissions.permissions_hash = permissions_hash; }, can: function(permission_key) { return !!scrivito.user_permissions.permissions_hash[permission_key]; } } }); }()); (function() { var handle_task = function(task) { switch (task.status) { case 'success': return $.Deferred().resolve(task.result); case 'error': return $.Deferred().reject({ message: task.message, code: task.code }); case 'open': return scrivito.wait(2).then(function() { return single_ajax('GET', 'tasks/' + task.id).then(function(data) { return handle_task(data); }); }); default: throw { message: "Invalid task (unknown status)", task: task }; } }; var single_ajax = function(type, path, options) { var base_url = window.location.protocol + '//' + window.location.host + '/__scrivito/'; if (options && options.data) { options.data = JSON.stringify(options.data); } return $.ajax(base_url + path, _.extend({ type: type, dataType: 'json', contentType: 'application/json; charset=utf-8', cache: false // Don't cache GET requests. }, options || {})).then( function(result, text_status, xhr) { return $.Deferred().resolve(result); }, function(xhr, text_status, error) { var error_message; var error_code; try { var error_json = JSON.parse(xhr.responseText); error_message = error_json.error; error_code = error_json.code; } catch (SyntaxError) {} if (!error_message) { error_message = error; } return $.Deferred().reject({ status: xhr.status, message: error_message, code: error_code }); } ); }; _.extend(scrivito, { silent_ajax: function(type, path, options) { var is_write_request = type === 'PUT' || type === 'POST' || type === 'DELETE'; if (is_write_request) { options = options || {}; options.timeout = 15000; // miliseconds scrivito.write_monitor.start_write(); } var ajax_promise = single_ajax(type, path, options).then(function(result) { if (result && result.task && _.size(result) === 1) { return handle_task(result.task); } else { return $.Deferred().resolve(result); } }); if (is_write_request) { ajax_promise.always(function() { scrivito.write_monitor.end_write(); }); } return ajax_promise; }, ajax: function(type, path, options) { return scrivito.silent_ajax(type, path, options).fail(function(error) { scrivito.display_ajax_error(error); }); }, display_ajax_error: function(error) { var ajax_error = error.message; var error_message; if (_.contains(['abort', 'parsererror', 'timeout'], ajax_error)) { error_message = scrivito.t('ajax.error.communication'); } else if (ajax_error === 'error') { error_message = scrivito.t('ajax.error.unknown'); } else if (ajax_error) { error_message = scrivito.t('ajax.error', ajax_error); } else { error_message = scrivito.t('ajax.error.unknown'); } if (scrivito.is_development_mode) { scrivito.alert_dialog(error_message); } else { scrivito.log_error(error_message); scrivito.info_dialog(scrivito.t('ajax.error.production')); } } }); }()); (function() { _.extend(scrivito, { command: { create_instance: function(params) { var that = { id: function() { return params.id; }, dom_id: function() { return params.id.replace(/\./g, '_'); }, title: function() { var title = params.title; return typeof title === 'function' ? title() : title; }, icon: function() { return params.icon || ''; }, subtitle: function() { return params.subtitle; }, tooltip: function() { return params.tooltip; }, is_present: function() { var is_present = params.present; switch (typeof is_present) { case 'undefined': return true; case 'function': return !!is_present(); default: return !!is_present; } }, is_enabled: function() { return !that.is_disabled(); }, is_disabled: function() { return !!that.reason_for_being_disabled(); }, is_action_required: function() { var is_action_required = params.action_required; return typeof is_action_required === 'function' && is_action_required(); }, reason_for_being_disabled: function() { var reason_for_being_disabled = params.disabled; if (typeof reason_for_being_disabled === 'function') { return reason_for_being_disabled(); } }, update: function() { if (that.needs_update()) { return params.update(); } }, needs_update: function() { return !!params.update; }, execute: function() { if (that.is_present() && that.is_enabled()) { params.execute(); return true; } return false; }, update_params: function(new_params) { return _.extend(params, new_params); } }; return that; } } }); }()); (function() { _.extend(scrivito, { command_separator: { create_instance: function(params) { return { id: function() { return params.id; }, title: function() { return params.title; }, update_params: function(new_params) { return _.extend(params, new_params); } }; } } }); }()); (function() { _.extend(scrivito, { menu_item: { create_instance: function(item) { if (item.execute) { return from_command(item); } else if (item.render) { return item; } else { return from_separator(item); } } } }); var from_command = function(command) { var icon = command.icon(); var icon_template = 'menu_item/icon'; if (icon.indexOf('&') === 0) { icon_template += '_hex'; } else if (!(/^scrivito_icon_/).test(icon)) { icon_template += '_sci'; } var render_menu_item = function() { return scrivito.template.render('menu_item', _.extend({}, command, {icon: function() { return scrivito.template.render(icon_template, {icon: icon}); }})); }; return { render: function() { if (command.is_present()) { var view; if (command.needs_update()) { var id = _.uniqueId(command.dom_id()); view = scrivito.template.render('menu_item/spinner', {id: id}); command.update().then(function() { $('#'+id).replaceWith(render_menu_item()); }); } else { view = render_menu_item(); } return view; } } }; }; var from_separator = function(separator) { return { render: function() { return scrivito.template.render('menu_item/separator', separator); } }; }; }()); (function() { _.extend(scrivito, { menu_builder: { create_instance: function(cms_element) { return { list: function() { return cms_element.menu(); }, add: function(id, params) { var menu = cms_element.menu(); menu.push(scrivito.command.create_instance(_.extend(params, {id: id}))); cms_element.set_menu(menu); }, update: function(id, params) { var menu = cms_element.menu(); _.find(menu, function(command, index) { if (command.id() === id) { return command.update_params(params); } }); cms_element.set_menu(menu); }, replace: function(id, params) { var menu = cms_element.menu(); _.find(menu, function(command, index) { if (command.id() === id) { return menu[index] = scrivito.command.create_instance(_.extend(params, {id: id})); } }); cms_element.set_menu(menu); }, remove: function(id) { var menu = cms_element.menu(); var command = _.find(menu, function(command) { return command.id() === id; }); cms_element.set_menu(_.without(menu, command)); } }; } } }); }()); (function() { var callbacks = {}; var current_token = 0; var counter = 0; var run_callbacks = function(event_name) { _.each(callbacks[event_name], function(callback) { callback(); }); }; _.extend(scrivito, { write_monitor: { on: function(event_name, callback) { if (callbacks[event_name] === undefined) { callbacks[event_name] = {}; } current_token += 1; callbacks[event_name][current_token] = callback; return current_token; }, off: function(token) { _.each(callbacks, function(event_callbacks) { delete event_callbacks[token]; }); }, is_writing: function() { return counter > 0; }, start_write: function() { if (!scrivito.write_monitor.is_writing()) { run_callbacks('start_write'); } counter += 1; }, end_write: function() { counter -= 1; if (!scrivito.write_monitor.is_writing()) { scrivito.run_new_event(function() { if (!scrivito.write_monitor.is_writing()) { run_callbacks('end_write'); } }); } }, track_changes: function(fn, on_change_callback) { var has_changes = false; var changes_finished = false; var start_token = scrivito.write_monitor.on('start_write', function() { has_changes = true; changes_finished = false; }); var end_token = scrivito.write_monitor.on('end_write', function() { changes_finished = true; }); return fn().done(function() { scrivito.write_monitor.off(start_token); scrivito.write_monitor.off(end_token); if (has_changes) { if (changes_finished) { on_change_callback(); } else { var saving_promise = $.Deferred(); var final_end_token = scrivito.write_monitor.on('end_write', function() { scrivito.write_monitor.off(final_end_token); saving_promise.resolve(); on_change_callback(); }); scrivito.with_saving_overlay(saving_promise); } } }); }, // For test purpose only. reset_callbacks: function() { callbacks = {}; current_token = 0; }, // For test purpose only. reset_counter: function() { counter = 0; } } }); }()); (function() { var menu_bar_items_renderer = []; _.extend(scrivito, { menu_bar: { init: function() { // Add the corresponding CSS class to all documents (including iframe in details dialog). scrivito.gui.on('document', function(document) { document.dom_element().find('body').addClass('scrivito_editing_active'); }); // Re-render the menu bar if the application window changes. scrivito.application_window.on('document', function(document) { scrivito.menu_bar.render(); }); }, register_item_renderer: function(item_renderer) { menu_bar_items_renderer.push(item_renderer); }, render: function() { var view = $(scrivito.template.render('menu_bar')); _.each(menu_bar_items_renderer, function(item_renderer) { item_renderer(view); }); var menu_bar = $('.scrivito_topbar'); if (menu_bar.length) { menu_bar.replaceWith(view); } else { $('body').append(view); } }, // For test purpose only. reset_items_renderer: function() { menu_bar_items_renderer = []; }, // For test purpose only. remove: function() { $('.scrivito_topbar').remove(); } } }); }()); (function() { _.extend(scrivito, { menu_bar_saving_indicator: { init: function() { scrivito.menu_bar.register_item_renderer(function(parent_view) { scrivito.saving_indicator.create(parent_view.find('#scrivito_menu_bar_saving_indicator')); }); } } }); }()); (function() { _.extend(scrivito, { menu_bar_device_toggle: { init: function() { var device_toggle; var current_device = function() { return scrivito.storage.get('menu_bar_device_toggle.current_device') || 'desktop'; }; var toggle_device = function(device) { scrivito.storage.set('menu_bar_device_toggle.current_device', device); $('iframe[name=scrivito_application]').attr('class', 'scrivito_iframe_'+device); device_toggle.find('> .scrivito_icon') .attr('class', 'scrivito_icon scrivito_icon_'+device); }; scrivito.menu_bar.register_item_renderer(function(menu_bar) { $('#scrivito_ui').addClass('scrivito_iframe_resize_bg'); device_toggle = $(scrivito.template.render('menu_bar_device_toggle', {device: current_device()} )).appendTo(menu_bar.find('#scrivito_menu_bar_device_toggle')); toggle_device(current_device()); var commands = _.map(['mobile', 'tablet', 'laptop', 'desktop'], function(device) { return scrivito.command.create_instance({ id: 'scrivito.sdk.switch_to_'+device+'_device', title: scrivito.t('menu_bar_device_toggle.command.title.'+device), icon: 'scrivito_icon_'+device, disabled: function() { if (device === current_device()) { return scrivito.t('menu_bar_device_toggle.command.disabled'); } }, execute: function() { var iframe = $('iframe[name=scrivito_application]'); scrivito.transition(iframe, function() { toggle_device(device); iframe.addClass('scrivito_iframe_animate_resize'); }).done(function() { iframe.removeClass('scrivito_iframe_animate_resize'); }); } }); }); commands = [ scrivito.command_separator.create_instance({ id: 'scrivito.sdk.menu_bar_device_toggle.description', title: scrivito.t('menu_bar_device_toggle.description') }) ].concat(commands); device_toggle.on('click', function() { scrivito.static_menus.toggle(device_toggle, commands); return false; }); }); } } }); }()); (function() { _.extend(scrivito, { menu_bar_warning: { init: function() { scrivito.menu_bar.register_item_renderer(function(parent_view) { scrivito.menu_bar_warning.create( parent_view.find('#scrivito_menu_bar_warning')); }); }, create: function(parent_view) { parent_view.append(scrivito.template.render('menu_bar_warning')); $(parent_view).on('click', function() { scrivito.alert_dialog(scrivito.t('menu_bar_warning.open_console')); scrivito.menu_bar_warning.hide(); }); }, show: function() { $('.scrivito_menu_bar_warning').show(); }, hide: function() { $('.scrivito_menu_bar_warning').hide(); } } }); }()); (function() { _.extend(scrivito, { menu_bar_toggle: { init: function() { scrivito.menu_bar.register_item_renderer(function(menu_bar) { var comparing_mode = scrivito.editing_context.comparing_mode(); var switch_to_view_mode_command = scrivito.switch_mode_command('view'); var switch_to_editing_mode_command = scrivito.switch_mode_command('editing'); var switch_to_comparing_mode_command = scrivito.switch_mode_command(comparing_mode); var template = scrivito.template.render('menu_bar_toggle', { mode: scrivito.editing_context.display_mode, comparing_mode: comparing_mode, switch_to_view_mode_command: switch_to_view_mode_command, switch_to_editing_mode_command: switch_to_editing_mode_command, switch_to_comparing_mode_command: switch_to_comparing_mode_command }); var menu_bar_toggle = menu_bar.find('#scrivito_menu_bar_toggle').html(template); _.each([ switch_to_view_mode_command, switch_to_editing_mode_command, switch_to_comparing_mode_command ], function(command) { menu_bar_toggle.find('.'+command.dom_id()).on('click', function() { command.execute(); return false; }); }); menu_bar_toggle.find('.scrivito_comparing_mode_toggle').on('click', function() { scrivito.static_menus.toggle($(this), [ scrivito.switch_mode_command('diff'), scrivito.switch_mode_command('added'), scrivito.switch_mode_command('deleted') ], {align: 'left'}); return false; }); }); } } }); }()); (function() { _.extend(scrivito, { obj_menu: { create: function(dom_element, obj, commands) { dom_element.append(scrivito.template.render('obj_menu', {obj: obj})); dom_element.on('click', function() { scrivito.static_menus.toggle(dom_element, _.isFunction(commands) ? commands() : commands); return false; }); } } }); }()); (function() { _.extend(scrivito, { current_page_menu: { init: function() { scrivito.menu_bar.register_item_renderer(function(menu_bar) { var current_page = scrivito.application_document().page(); if (current_page) { var dom_element = menu_bar.find('#scrivito_current_page_menu'); scrivito.obj_menu.create(dom_element, current_page, function() { return scrivito.application_document().menu(); }); } }); } } }); }()); (function() { _.extend(scrivito, { menu_bar_browse_content: { init: function() { scrivito.menu_bar.register_item_renderer(function(menu_bar) { if (scrivito.browse_content && scrivito.in_editable_view()) { var button = menu_bar.find('#scrivito_menu_bar_browse_content'); button.addClass('scrivito_button_bar scrivito_right'); button.append(scrivito.template.render('menu_bar_browse_content')); button.on('click', function() { scrivito.browse_content(); return false; }); } }); } } }); }()); (function() { var render, current_page; _.extend(scrivito, { menu_bar_conflict_indicator: { init: function() { scrivito.menu_bar.register_item_renderer(function(menu_bar) { render = function(color, commands) { var target = $(scrivito.template.render('menu_bar_conflict_indicator')) .appendTo(menu_bar.find('#scrivito_menu_bar_conflict_indicator')); target.show(); target.find('.scrivito_icon').addClass('scrivito_'+color); target.on('click', function() { scrivito.static_menus.toggle(target, commands); }); }; current_page = scrivito.application_document().page(); if (current_page) { check_conflict(function() { check_uptodate(function() { check_potential_conflicts(); }); }); } }); } } }); var check_conflict = function(next) { if (current_page.has_conflict()) { render_conflict(); } else { next(); } }; var check_uptodate = function(next) { if (scrivito.in_editable_view()) { current_page.is_outdated().done(function(is_outdated) { if (is_outdated) { render_outdated(); } else { next(); } }); } }; var check_potential_conflicts = function() { current_page.conflicting_workspaces().done(function(workspaces) { if (workspaces.length) { render_potential_conflicts(workspaces); } }); }; var render_conflict = function() { render('red', [{ id: function() { return 'scrivito.menu_bar_conflict_indicator.header'; }, render: function() { return scrivito.template.render('menu_bar_conflict_indicator/conflict'); } }]); }; var render_outdated = function() { render('red', [ { id: function() { return 'scrivito.menu_bar_conflict_indicator.header'; }, render: function() { return scrivito.template.render('menu_bar_conflict_indicator/warn', { headline_color: 'red', headline: scrivito.t('menu_bar_conflict_indicator.outdated_headline'), description: scrivito.t('menu_bar_conflict_indicator.outdated_description') }); } }, scrivito.rebase_workspace_command(scrivito.editing_context.selected_workspace) ]); }; var render_potential_conflicts = function(workspaces) { render('yellow', [{ id: function() { return 'scrivito.menu_bar_conflict_indicator.header'; }, render: function() { return scrivito.template.render('menu_bar_conflict_indicator/warn', { headline_color: 'yellow', headline: scrivito.t('menu_bar_conflict_indicator.warn_headline'), description: scrivito.t('menu_bar_conflict_indicator.warn_description') }); } }].concat(_.map(workspaces, function(ws) { return scrivito.select_workspace_command(ws); }))); }; }()); (function() { _.extend(scrivito, { current_page_restriction: { init: function() { scrivito.menu_bar.register_item_renderer(function(menu_bar) { var current_page = scrivito.application_document().page(); if (current_page && current_page.has_restriction()) { $(scrivito.template.render('current_page_restriction', { restriction_messages: current_page.restriction_messages })).appendTo(menu_bar.find('#scrivito_current_page_restriction')); } }); } } }); }()); (function() { _.extend(scrivito, { workspace_select: { init: function() { var selected_workspace = scrivito.editing_context.selected_workspace; var commands = { create_workspace: scrivito.create_workspace_command(), select_published: scrivito.select_workspace_command(scrivito.workspace.published()), for_editable: [ scrivito.workspace_changes_command(), scrivito.workspace_settings_command(selected_workspace), scrivito.rename_workspace_command(selected_workspace), scrivito.rebase_workspace_command(selected_workspace), scrivito.publish_workspace_command(selected_workspace), scrivito.delete_workspace_command(selected_workspace) ] }; scrivito.menu_bar.register_item_renderer(function(menu_bar) { var workspace_select = menu_bar.find('#scrivito_workspace_select'); workspace_select.append(scrivito.template.render('workspace_select', { selected_workspace: selected_workspace, commands: commands })); var bind_command = function(command) { workspace_select.on('click', '#'+command.dom_id(), function() { return command.execute(); }); }; bind_command(commands.create_workspace); bind_command(commands.select_published); _.each(commands.for_editable, function(command) { bind_command(command); }); workspace_select.on('click', function() { var menu_box = workspace_select.find('.scrivito_menu_box'); menu_box.fadeToggle('50'); var workspace_list = menu_box.find('.scrivito_workspace_list'); var spinner = workspace_list.find('.scrivito_spinning'); if (spinner.length && !spinner.attr('data-scrivito-private-loading')) { spinner.attr('data-scrivito-private-loading', true); scrivito.workspace.editable().then(function(workspaces) { var commands = _(workspaces).reject(function(workspace) { return workspace.id() === selected_workspace.id(); }).map(function(workspace) { return scrivito.select_workspace_command(workspace); }); workspace_list.replaceWith(scrivito.template.render( 'workspace_select/other_workspaces', { has_separator: selected_workspace.is_published() && commands.length, commands: commands } )); _.each(commands, function(command) { bind_command(command); }); }).always(function() { spinner.removeAttr('data-scrivito-private-loading'); }); } return false; }); }); } } }); }()); (function() { var dialog; _.extend(scrivito, { changes_dialog: { open: function() { var promise = $.Deferred(); dialog = $(scrivito.template.render('changes_dialog')).appendTo($('#scrivito_editing')); open_batch(scrivito.obj_changes()); var close = function() { scrivito.dialog.close_without_transition(dialog); promise.resolve(); return false; }; dialog.find('.scrivito_cancel').on('click', close); scrivito.dialog.open_and_adjust_without_transition(dialog); return scrivito.with_dialog_behaviour(dialog, promise, {escape: close}); } } }); var open_batch = function(chainable_search, objs) { render(chainable_search); chainable_search.load_batch().then(function(result, next) { objs = (objs || []).concat(_.map(result.hits, function(hit) { return scrivito.obj.create_instance(hit); })); render(chainable_search, result, objs, next); }); }; var render = function(chainable_search, result, objs, next) { var view = dialog.find('.scrivito_changes_dialog_content'); view.html(scrivito.template.render('changes_dialog/content', { title: scrivito.t('changes_dialog.title', scrivito.editing_context.selected_workspace.title()), is_loaded: !!result, total: result && result.total, objs: objs, has_more: !!next })); scrivito.update_auto_height_for(view); view.find('[data-scrivito-sort-by="'+chainable_search.query().order+'"]') .addClass('scrivito_'+(chainable_search.query().reverse_order ? 'sort_down' : 'sort_up')); view.find('[data-scrivito-sort-by]').on('click', function() { var sortable = $(this); var chainable_search = scrivito.obj_changes(); chainable_search.order(sortable.attr('data-scrivito-sort-by')); if (sortable.hasClass('scrivito_sort_down')) { chainable_search.reverse_order(); } open_batch(chainable_search); return false; }); view.find('[data-scrivito-obj-id]').on('click', function() { var obj_id = $(this).attr('data-scrivito-obj-id'); scrivito.open_obj(_.find(objs, function(obj) { return obj.id() === obj_id; })); return false; }); view.find('.scrivito_load_more').on('click', function() { open_batch(next, objs); return false; }); }; }()); (function() { _.extend(scrivito, { current_page_link_dialog: function() { var workspace_id = scrivito.editing_context.selected_workspace.id(); var current_page_link = scrivito.editing_context.location({workspace_id: workspace_id}); var view = $(scrivito.template.render('current_page_link_dialog', { current_page_link: current_page_link })); var deferred = $.Deferred(); $('#scrivito_editing').append(view); view.find('input').focus().select(); var done = function() { scrivito.dialog.close_with_transition(view); deferred.resolve(); return false; }; view.find('.scrivito_done').on('click', done); scrivito.dialog.open_and_adjust_with_transition(view); scrivito.with_dialog_behaviour(view, deferred, {enter: done, escape: done}); } }); }()); (function() { var defaults; _.extend(scrivito, { obj_class_defaults: { register: function(mapping) { _.extend(defaults, mapping); }, lookup: function(content_type) { return defaults[content_type] || defaults[content_type.split('/')[0] + '/*'] || defaults['*/*']; }, reset: function() { defaults = {}; scrivito.obj_class_defaults.register({'image/*': 'Image', '*/*': 'Download'}); } } }); scrivito.obj_class_defaults.reset(); }()); (function() { _.extend(scrivito, { obj_class_selection: { store: function(obj_class) { var new_storage = get_storage(); new_storage.unshift(obj_class); new_storage = _.uniq(new_storage); new_storage = _.take(new_storage, 200); scrivito.storage.set(scrivito.obj_class_selection.storage_key, new_storage); }, recent: function(valid_obj_classes) { var recent_valid_obj_classes = _.intersection(get_storage(), valid_obj_classes); return _.take(recent_valid_obj_classes, 5); }, // for testing only storage_key: 'obj_class_selection.used_classes' } }); var get_storage = function() { return scrivito.storage.get(scrivito.obj_class_selection.storage_key) || []; }; }()); (function() { var expando = "scrivito_cms_element"; _.extend(scrivito, { cms_element: { create_instance: function(dom_element) { var that = { dom_element: function() { return dom_element; }, equals: function(cms_element) { return cms_element.dom_element().get(0) === that.dom_element().get(0); }, menu: function() { var menu = dom_element.data('scrivito-menu'); if (!menu) { menu = []; that.set_menu(menu); } return menu; }, set_menu: function(menu) { dom_element.data('scrivito-menu', menu); }, enrich_obj_classes_with_recent_and_popular: function(obj_classes_markup) { var sorted_all = _.pluck(obj_classes_markup, 'name').sort(); var popular = _.intersection(scrivito.popular_obj_classes, sorted_all); var recent = scrivito.obj_class_selection.recent(sorted_all); return { all: format_obj_classes(sorted_all, obj_classes_markup), popular: format_obj_classes(popular, obj_classes_markup), recent: format_obj_classes(recent, obj_classes_markup) }; } }; return that; }, from_dom_element: function(dom_element) { if (!dom_element || !dom_element.jquery) { dom_element = $(dom_element); } if (dom_element.length === 0) { $.error("Expected a jquery instance with exactly one element, " + "instead got " + dom_element); } var instance = dom_element[0][expando]; if (!instance) { var cms_element = scrivito.cms_element.create_instance(dom_element); _.find(scrivito.cms_element.definitions, function(definition) { instance = definition.create_instance(cms_element); return instance; }); if (!instance) { $.error("This dom element is not a scrivito tag."); } dom_element[0][expando] = instance; } return instance; }, definitions: [], all: function(selector, root_element) { return _.map(root_element.find(selector).addBack(selector), function(dom_element) { return scrivito.cms_element.from_dom_element($(dom_element)); }); } } }); var format_obj_classes = function(obj_classes, obj_classes_markup) { return _.map(obj_classes, function(obj_class) { return { name: obj_class, markup: _.find(obj_classes_markup, function(obj_class_markup) { return obj_class_markup.name === obj_class; }).markup }; }); }; }()); (function() { _.extend(scrivito, { blob: { create: function(obj_id, binary) { var uploaded_binary = binary.is_uploaded_binary ? binary : scrivito.blob.upload_binary(binary); return get_upload_permission().then(function(permission) { scrivito.write_monitor.start_write(); return upload_to_s3(uploaded_binary, permission).then(function(blob) { return activate_upload(obj_id, blob, binary.filename, binary.content_type) .then(function() { return blob; }); }).always(function() { scrivito.write_monitor.end_write(); }); }); }, // For testing purpose only. get_form_data: function() { return new FormData(); }, upload_binary: function(params) { var blob = params.blob || params.file; if (!blob) { $.error('need blob or file'); } if (!params.content_type) { params.content_type = blob.type; } if (!params.filename) { if (params.blob) { $.error('blob needs a filename'); } params.filename = blob.name; } params.filename = params.filename.replace(/[^\w\-_\.$]/g, '-'); return $.extend(params, {is_uploaded_binary: true}); } } }); var get_upload_permission = function() { return scrivito.ajax('GET', 'blobs/upload_permission'); }; var upload_to_s3 = function(binary, permission) { var form_data = scrivito.blob.get_form_data(); _.each(permission.fields, function(value, name) { form_data.append(name, value); }); // File must be appended last, otherwise S3 will complain. form_data.append('file', binary.blob || binary.file); permission.blob.filename = binary.filename; permission.blob.content_type = binary.content_type; return $.ajax({type: 'POST', url: permission.url, data: form_data, // These are needed in order for jQuery to work properly with a FormData. contentType: false, processData: false }).then(function() { return permission.blob; }); }; var activate_upload = function(obj_id, blob, filename, content_type) { return scrivito.ajax('PUT', 'blobs/activate_upload', {data: { obj_id: obj_id, upload: blob, filename: filename, content_type: content_type }}); }; }()); (function() { _.extend(scrivito, { child_list_element: { create_instance: function(cms_element) { if (cms_element.dom_element().attr('data-scrivito-private-child-list-path')) { var that = cms_element; _.extend(that, { path: function() { return that.dom_element().attr('data-scrivito-private-child-list-path'); }, obj: function() { return scrivito.obj.create_instance({ id: that.dom_element().attr('data-scrivito-private-child-list-order-obj-id'), description_for_editor: that.dom_element() .attr('data-scrivito-private-obj-description-for-editor') }); }, fetch_page_class_selection: function() { var request_path = 'objs/page_class_selection?' + $.param({parent_path: that.path()}); return scrivito.ajax('GET', request_path).then(function(obj_classes_markup) { return that.enrich_obj_classes_with_recent_and_popular(obj_classes_markup); }); }, allowed_classes: function() { return JSON.parse( that.dom_element().attr('data-scrivito-private-child-list-allowed-classes')); }, create_child: function(obj_class) { var id = scrivito.random_id(); scrivito.obj_class_selection.store(obj_class); return scrivito.obj.create({ _id: id, _path: that.path() + '/' + id, _obj_class: obj_class }); }, add_child: function(child) { return child.save({ _path: that.path() + '/' + child.id() }); }, children: function() { return _.map(that.dom_element().find('>[data-scrivito-private-obj-id]'), function(dom_element) { return scrivito.cms_element.from_dom_element($(dom_element)); }); }, has_child_order: function() { return !!that.dom_element().attr('data-scrivito-private-child-list-order-obj-id'); }, save_order: function() { if (that.has_child_order()) { var new_child_order = _.map(that.children(), function(child) { return child.obj().id(); }); return that.obj().save({child_order: new_child_order}); } else { $.error("Can't save order, when child order is not allowed!"); } }, is_valid_child_class: function(obj_class_name) { var allowed_classes = that.allowed_classes(); if (allowed_classes) { return _.contains(allowed_classes, obj_class_name); } else { return true; } } }); return that; } }, all: function(root_element) { return scrivito.cms_element.all('[data-scrivito-private-child-list-path]', root_element); } } }); scrivito.cms_element.definitions.push(scrivito.child_list_element); }()); (function() { _.extend(scrivito, { cms_document: { // return offset of given element relative to scrivito window offset: function(dom_element) { var document = scrivito.cms_document.from(dom_element); return document.offset(dom_element); }, local_jquery: function(dom_element) { return scrivito.cms_document.from($(dom_element)).local_jquery(dom_element); }, from: function(dom_element) { var element_document; if (!dom_element.jquery) { $.error("not a jquery instance"); } if (dom_element.length === 0) { $.error("empty jquery instance given"); } if (dom_element[0].ownerDocument) { element_document = $(dom_element[0].ownerDocument); } else if (dom_element[0].nodeType === 9) { element_document = dom_element; } else { $.error("scrivito.cms_document.from must be called with " + "a dom element"); } return scrivito.cms_element.from_dom_element(element_document); }, create_instance: function(cms_element) { if (cms_element.dom_element()[0].nodeType === 9) { return create_instance(cms_element); } }, // for testing purposes only reset_public_api: function() { additional_public_api = {}; }, register_public_api: function(namespace, implementation) { additional_public_api[namespace] = implementation; } } }); var additional_public_api = {}; var page_config_attr_name = 'data-scrivito-private-page-config'; var create_instance = function(cms_element) { var that = cms_element; // PUBLIC _.extend(that, { install_public_api: function() { local_$().fn.scrivito = scrivito.jquery_plugin; // @api public browser_window.scrivito = _.extend({}, additional_public_api, { on: local_on_function, trigger: scrivito.trigger, create_obj: scrivito.create_obj, delete_obj: scrivito.delete_obj, obj_where: scrivito.obj_where, is_current_page_restricted: scrivito.is_current_page_restricted, in_editable_view: scrivito.in_editable_view, register_default_obj_class_for_content_type: scrivito.register_default_obj_class_for_content_type, default_obj_class_for_content_type: scrivito.default_obj_class_for_content_type, upload_binary: scrivito.blob.upload_binary, page_menu: function() { return scrivito.page_menu(that); }, // @api beta dialog: function(content, options) { var iframe = that.window().iframe(); return scrivito.custom_dialog(iframe, browser_document, content, options); } }); // @api public public_getter_setter(browser_window.scrivito, [ 'menu_order', 'popular_obj_classes', 'select_content' // @api beta ]); }, assert_user_logged_in: function() { if (that.user_id() !== scrivito.user.current.id()) { // editing is either no longer allowed, or user changed => closing UI scrivito.change_location(window.location, window.parent); } }, connect: function() { if (connected) { $.error("document connected twice!"); } _.each(load_callbacks, function(callback) { scrivito.run_new_event(callback); }); connected = true; scrivito.gui.new_document(that); scrivito.gui.new_content(that.dom_element()[0]); }, notify_new_content: function(content) { if (!connected) { return; } _.each(content_callbacks, function(callback) { scrivito.run_new_event(function() { callback.apply(this, [content]); }); }); }, add_app_extensions: function() { var app_extension_tags = scrivito.ui_config().app_extension_tags; browser_window.document.write(app_extension_tags); }, window: function() { return scrivito.cms_window.from(browser_window); }, // return the given dom element using the local jQuery lib or the lib itself. local_jquery: function(element) { return element ? local_$()(element) : local_$(); }, browser_window: function() { return browser_window; }, // Return offset of given element relative to scrivito window. offset: function(dom_element) { var element_offset = dom_element.offset(); var iframe_offset = $(that.window().iframe()).offset(); if (iframe_offset) { return { top: iframe_offset.top - $(browser_window.document).scrollTop() + element_offset.top, left: iframe_offset.left - $(browser_window.document).scrollLeft() + element_offset.left }; } else { return element_offset; } }, page: function() { var config = that.page_config(); if (config && !_.isEmpty(config.current_page)) { return scrivito.obj.create_instance(config.current_page); } }, user_id: function() { var config = that.page_config(); if (config) { return config.user_id; } }, page_config: function() { return scrivito.dom_config.read(that.dom_element().find('body'), page_config_attr_name); }, // For test purpose only. mock_page_config: function(config) { if (config) { scrivito.dom_config.write(that.dom_element().find('body'), page_config_attr_name, config); } else { that.dom_element().find('body').removeAttr(page_config_attr_name); } }, // For test purpose only. mock_current_page: function(attrs) { that.mock_page_config({current_page: attrs}); } }); // PRIVATE var browser_document = cms_element.dom_element()[0]; var browser_window = browser_document.defaultView; var local_$ = function() { if (browser_window.jQuery) { return browser_window.jQuery; } else { var jquery_missing = 'jQuery is missing! ' + 'In order for Scrivito to work, jQuery is needed. ' + 'Please add jQuery to your assets.'; scrivito.alert_dialog(jquery_missing); $.error(jquery_missing); } }; var connected = false; var load_callbacks = []; var content_callbacks = []; var local_on_function = function(event, callback) { if (event === "load") { if (!connected) { load_callbacks.push(callback); } else { scrivito.run_new_event(callback); } } else if (event === "content") { content_callbacks.push(callback); if (connected) { scrivito.run_new_event(function() { callback(browser_document); }); } } else { $.error("unknown event " + event); } }; return that; }; var public_getter_setter = function(item, attributes) { _.each(attributes, function(attribute) { Object.defineProperty(item, attribute, { get: function() { return scrivito[attribute]; }, set: function(new_value) { scrivito[attribute] = new_value; } }); }); }; scrivito.cms_element.definitions.push(scrivito.cms_document); }()); (function() { var has_original_content = function(field_type) { return _.contains([ 'enum', 'html', 'multienum', 'reference', 'referencelist', 'string', 'stringlist', 'binary', 'date' ], field_type); }; _.extend(scrivito, { cms_field_element: { create_instance: function(cms_element) { var that = cms_element; var to_be_saved_data; _.extend(that, { field_name: function() { return that.dom_element().attr('data-scrivito-field-name'); }, field_type: function() { return that.dom_element().attr('data-scrivito-field-type'); }, obj: function() { return scrivito.obj.create_instance({ id: that.dom_element().attr('data-scrivito-private-field-obj-id'), obj_class_name: that.dom_element().attr('data-scrivito-field-obj-class') }); }, workspace_id: function() { return that.dom_element().attr('data-scrivito-private-field-workspace-id'); }, widget: function() { var widget_id = that.dom_element().attr('data-scrivito-private-field-widget-id'); if (widget_id) { return scrivito.widget.create_instance(that.obj(), widget_id, that.dom_element().attr('data-scrivito-widget-obj-class')); } }, save: function(content) { assert_valid_workspace_id(); if (content === undefined) { if (that.content) { content = that.content(); } else { $.error("Can't save without content"); } } var request_promise = $.Deferred(); var to_be_saved = to_be_saved_data || {}; to_be_saved.value = content; to_be_saved.promises = to_be_saved.promises || []; to_be_saved.promises.push(request_promise); to_be_saved_data = to_be_saved; if (!currently_saving()) { next_save_request(); } return request_promise.then(function(model_data) { return model_data[that.field_name()]; }); }, original_content: function() { assert_valid_workspace_id(); if (has_original_content(that.field_type())) { var raw_value = scrivito.json_parse_base64( that.dom_element().attr('data-scrivito-private-field-original-content')); return prepare_original_content(raw_value, that.field_type()); } else { $.error('Fields of type ' + that.field_type() + ' do not support original content'); } }, set_original_content: function(content) { if (has_original_content(that.field_type())) { that.dom_element().attr('data-scrivito-private-field-original-content', scrivito.json_stringify_base64(content)); } } }); var assert_valid_workspace_id = function() { if (that.workspace_id() !== scrivito.editing_context.selected_workspace.id()) { $.error('Tried to edit cms data from wrong workspace!'); } }; var next_save_request = function() { currently_saving(true); var to_be_saved = to_be_saved_data; to_be_saved_data = undefined; var changes = {}; changes[that.field_name()] = to_be_saved.value; var widget = that.widget(); var save_promise = widget ? widget.save(changes) : that.obj().save(changes); save_promise.done(function(result) { _.each(to_be_saved.promises, function(succeeding_promise) { succeeding_promise.resolve(result); }); if (to_be_saved_data) { next_save_request(); } else { remove_currently_saving(); } }).fail(function(error) { var new_promises = (to_be_saved_data || {}).promises; var failing_promises = to_be_saved.promises.concat(new_promises || []); _.each(failing_promises, function(failing_promise) { failing_promise.reject(error); }); to_be_saved_data = undefined; remove_currently_saving(); }); }; var currently_saving = function(new_currently_saving) { if (new_currently_saving) { return that.dom_element().data('scrivito-currently-saving', new_currently_saving); } else { return that.dom_element().data('scrivito-currently-saving'); } }; var remove_currently_saving = function() { that.dom_element().removeData('scrivito-currently-saving'); }; var prepare_original_content = function(value, field_type) { if (value && field_type === 'date') { var DateClass = scrivito.cms_document.from(that.dom_element()).browser_window().Date; return new DateClass(value); } else { return value; } }; return that; } } }); }()); (function() { scrivito.cms_window = { from: function(element) { if (!element) { $.error("no element given!"); } var browser_window; if ($.isWindow(element)) { browser_window = element; } else if (element.jquery && element[0].tagName === "IFRAME") { var doc = $(element).contents()[0]; browser_window = doc.defaultView; } else { $.error("element is a closed browser window or " + "not a cms window element at all"); } if (browser_window.closed) { $.error("element belongs to closed browser window"); } var instance = find_instance(browser_window); if (!instance) { instance = create_instance(browser_window); store_instance(instance); } return instance; }, // for test purposes only! instances: function() { return instances; } }; var instances = []; var create_instance = function(browser_window) { // PUBLIC var that = { document: function() { return scrivito.cms_element.from_dom_element($(browser_window.document)); }, on: function(event, callback) { if (event !== "document") { $.error("invalid event name: " + event); } document_callbacks.push(callback); }, notify_new_document: function(document) { _.each(document_callbacks, function(callback) { callback(document); }); }, browser_window: function() { return browser_window; }, reload: function() { return with_saving_overlay(scrivito.reload(browser_window)); }, redirect_to: function(location) { return with_saving_overlay(scrivito.redirect_to(location, browser_window)); }, use_fragment_of: function(other_cms_window) { if (that === other_cms_window) { return; } var ui_hash = other_cms_window.browser_window().location.hash; if (ui_hash) { var src_uri = new URI(that.iframe().src); src_uri.fragment(ui_hash); that.iframe().src = src_uri.href(); } }, is_frame: function() { return browser_window.parent !== browser_window; }, iframe: function() { return _.find($(browser_window.parent.document).find('iframe'), function(iframe) { // Remove this try-catch after non-iframe mode has been disabled. try { return $(iframe).contents()[0].defaultView === browser_window; } catch (e) { // Ignore cross-origin security errors. } }); } }; // PRIVATE var document_callbacks = []; var with_saving_overlay = function(promise) { promise = scrivito.with_saving_overlay(promise); var my_frame = that.iframe(); if (my_frame) { $(my_frame).one('load', function() { promise.resolve(); }); } return promise; }; return that; }; var cleanup_instances = function() { // remove closed windows to allow the garbage collector to reap them instances = _.reject(instances, function(instance) { var win = instance.browser_window(); var closed = true; if (win) { try { closed = win.closed; } catch(e) { // some browser prevent us from accessing closed windows // by throwing an error } } return closed; }); }; var find_instance = function(browser_window) { cleanup_instances(); return _.detect(instances, function(instance) { return instance.browser_window() === browser_window; }); }; var store_instance = function(instance) { instances.push(instance); }; }()); (function() { _.extend(scrivito, { date_field_element: { create_instance: function(cms_element) { if (cms_element.dom_element().attr('data-scrivito-field-type') === 'date') { return scrivito.cms_field_element.create_instance(cms_element); } }, all: function() { return _.map($('[data-scrivito-field-type="date"]'), function(dom_element) { return scrivito.cms_element.from_dom_element($(dom_element)); }); } } }); scrivito.cms_element.definitions.push(scrivito.date_field_element); }()); (function() { _.extend(scrivito, { html_field_element: { create_instance: function(cms_element) { if (cms_element.dom_element().attr('data-scrivito-field-type') === 'html') { var that = scrivito.cms_field_element.create_instance(cms_element); _.extend(that, { content: function() { var content = that.dom_element().html(); return $.trim(content); } }); return that; } }, all: function() { return _.map($('[data-scrivito-field-type="html"]'), function(dom_element) { return scrivito.cms_element.from_dom_element($(dom_element)); }); } } }); scrivito.cms_element.definitions.push(scrivito.html_field_element); }()); (function() { var is_file = function(object) { return object && _.isFunction(object.slice) && _.isDate(object.lastModifiedDate) && _.isString(object.name); }; var format_date_number = function(number) { var string = number.toString(); return string.length === 1 ? '0' + string : string; }; var serialize_date = function(date) { return date.getUTCFullYear().toString() + '-' + format_date_number(date.getUTCMonth() + 1) + // Month numbers are starting at 0. '-' + format_date_number(date.getUTCDate()) + 'T' + format_date_number(date.getUTCHours()) + ':' + format_date_number(date.getUTCMinutes()) + ':' + format_date_number(date.getUTCSeconds()) + 'Z'; }; var convert_attrs = function(obj_id, attrs) { var collected_promises = _.map(attrs, function(value, field_name) { if (is_file(value)) { return scrivito.blob.create(obj_id, {file: value}).then(function(blob) { return [field_name, blob]; }); } else if (value && value.is_uploaded_binary) { return scrivito.blob.create(obj_id, value).then(function(blob) { return [field_name, blob]; }); } return $.Deferred().resolve([field_name, scrivito.obj.serialize_value(value)]); }); return $.when.apply(this, collected_promises).then(function() { return _.object(arguments); }); }; var convert_widget_pool = function(obj_id, widget_pool) { if (widget_pool) { var conversion_promises = _.map(widget_pool, function(attrs, widget_id) { return convert_attrs(obj_id, attrs).then(function(converted_attrs) { return [widget_id, converted_attrs]; }); }); return $.when.apply(this, conversion_promises).then(function() { return _.object(arguments); }); } else { return $.Deferred().resolve(widget_pool); } }; var prepare_attrs = function(obj_id, attrs) { return convert_widget_pool(obj_id, attrs._widget_pool).then(function(widget_pool) { return convert_attrs(obj_id, attrs).then(function(converted_attrs) { converted_attrs._widget_pool = widget_pool; return converted_attrs; }); }); }; _.extend(scrivito, { obj: { serialize_value: function(value) { if (_.isDate(value)) { return serialize_date(value); } else { return value; } }, create_instance: function(params) { var that = { id: function() { return params.id; }, obj_class_name: function() { return params.obj_class_name; }, description_for_editor: function() { return params.description_for_editor; }, modification: function() { return params.modification; }, is_new: function() { return that.modification() === 'new'; }, is_edited: function() { return that.modification() === 'edited'; }, is_deleted: function() { return that.modification() === 'deleted'; }, has_children: function() { return !!params.has_children; }, has_conflict: function() { return !!params.has_conflict; }, has_restriction : function() { return that.restriction_messages().length > 0; }, restriction_messages: function() { return params.restriction_messages || []; }, is_binary: function() { return !!params.is_binary; }, has_details_view: function() { return !!params.has_details_view; }, tooltip: function() { if (editing_state()) { return scrivito.t('obj.tooltip.' + editing_state()); } }, last_changed: function() { return params.last_changed; }, save: function(attrs) { return prepare_attrs(that.id(), attrs).then(function(prepared_attrs) { return scrivito.ajax('PUT', 'objs/'+that.id(), {data: {obj: prepared_attrs}}); }); }, destroy: function() { return scrivito.ajax('DELETE', 'objs/' + that.id()).then(function(result) { return result.redirect_to; }); }, destroy_widget: function(widget_id) { return scrivito.ajax('PUT', 'objs/' + that.id() + '/destroy_widget?widget_id=' + widget_id); }, revert: function() { return scrivito.ajax('PUT', 'objs/' + that.id() + '/revert'); }, revert_widget: function(widget_id) { return scrivito.ajax('PUT', 'objs/'+that.id()+'/revert_widget?widget_id='+widget_id); }, conflicting_workspaces: function() { return scrivito.ajax('GET', 'objs/' + that.id() + '/conflicting_workspaces').then( function(workspace_datas) { return scrivito.workspace.from_data_collection(workspace_datas); }); }, is_outdated: function() { return scrivito.ajax('GET', 'objs/' + that.id() + '/is_outdated').then( function(result) { return result.is_outdated; }); }, restore: function() { return scrivito.ajax('PUT', 'objs/' + that.id() + '/restore'); }, restore_widget: function(widget_id) { return scrivito.ajax('PUT', 'objs/'+that.id()+'/restore_widget?widget_id='+widget_id); }, details_src: function() { // TODO unify with ajax url generation return '/__scrivito/page_details/' + that.id(); }, mark_resolved: function() { return scrivito.ajax('PUT', 'objs/' + that.id() + '/mark_resolved'); }, copy_to: function(path) { var attrs = {data: {parent_path: path}}; return scrivito.ajax('POST', 'objs/'+that.id()+'/copy', attrs).then(function(data) { return scrivito.obj.create_instance(data); }); }, duplicate: function() { return scrivito.ajax('POST', 'objs/'+that.id()+'/duplicate').then(function(data) { return scrivito.obj.create_instance(data); }); }, reload: function() { return scrivito.ajax('GET', 'objs/'+that.id()).then(function(data) { params.has_conflict = data.has_conflict; params.modification = data.modification; }); }, reload_widget: function(widget_id) { return scrivito.ajax('GET', 'objs/'+that.id()+'/widget?widget_id='+widget_id); } }; var editing_state = function() { if (that.is_new()) { return 'is_new'; } if (that.is_edited()) { return 'is_edited'; } if (that.is_deleted()) { return 'is_deleted'; } }; return that; }, create: function(attrs) { return prepare_attrs(scrivito.random_id(), attrs).then(function(prepared_attrs) { return scrivito.ajax('POST', 'objs', {data: {obj: prepared_attrs}}).then(function(data) { return scrivito.obj.create_instance(data); }); }); } } }); }()); (function() { _.extend(scrivito, { obj_changes: function() { return scrivito.obj_where('_modification', 'equals', ['new', 'edited', 'deleted']). batch_size(100). order('_last_changed'). reverse_order(). format('_default'). include_deleted(); } }); }()); (function() { _.extend(scrivito, { obj_element: { create_instance: function(cms_element) { if (cms_element.dom_element().attr('data-scrivito-private-obj-id')) { var that = cms_element; _.extend(that, { obj: function() { return scrivito.obj.create_instance({ id: that.dom_element().attr('data-scrivito-private-obj-id'), description_for_editor: that.dom_element() .attr('data-scrivito-private-obj-description-for-editor') }); } }); return that; } }, // for testing purposes only all: function() { return _.map($('[data-scrivito-private-obj-id]'), function(dom_element) { return scrivito.cms_element.from_dom_element($(dom_element)); }); } } }); scrivito.cms_element.definitions.push(scrivito.obj_element); }()); (function() { _.extend(scrivito, { chainable_search: { create_instance: function(build_query) { var query = build_query || { predicates: [] }; var add_predicate = function(field, operator, value, boost, negate) { var serialized_value; if (_.isArray(value)) { serialized_value = _.map(value, scrivito.obj.serialize_value); } else { serialized_value = scrivito.obj.serialize_value(value); } var new_query = { field: field, operator: operator, value: serialized_value }; if (negate) { new_query.negate = true; } if (boost) { new_query.boost = boost; } query.predicates.push(new_query); return that; }; var execute_search = function(query, action) { return scrivito.ajax('GET', 'objs/search?' + $.param({query: JSON.stringify(query), query_action: action})); }; var that = { // @api public query: function() { return query; }, // @api public and: function(field_or_search, operator, value, boost) { if (_.isString(field_or_search)) { add_predicate(field_or_search, operator, value, boost); } else { var other_predicates = field_or_search.query().predicates; query.predicates = query.predicates.concat(other_predicates); } return that; }, // @api public and_not: function(field, operator, value) { add_predicate(field, operator, value, undefined, true); return that; }, // @api public offset: function(offset) { query.offset = offset; return that; }, // @api public order: function(order) { query.order = order; return that; }, // @api public reverse_order: function() { if (query.reverse_order) { delete query.reverse_order; } else { query.reverse_order = true; } return that; }, // @api public batch_size: function(batch_size) { query.batch_size = batch_size; return that; }, // @api public format: function(name) { query.format = name; return that; }, // @api public include_deleted: function() { query.include_deleted = true; return that; }, // @api public load_batch: function() { var offset = query.offset || 0; var next; return execute_search(query).then(function(result) { var batch_size = result.hits.length; var total_matches = result.total; if (total_matches > (batch_size + offset)) { var next_offset = offset + batch_size; var next_query = _.extend({}, query, {offset: next_offset}); next = scrivito.chainable_search.create_instance(next_query); } else { next = undefined; } return $.Deferred().resolve(result, next); }); }, // @api public size: function() { return execute_search(query, 'size').then(function(result) { return $.Deferred().resolve(result.total); }); }, // @api public clone: function() { var cloned_query = $.extend(true, {}, query); return scrivito.chainable_search.create_instance(cloned_query); } }; return that; } } }); }()); (function() { _.extend(scrivito, { // @api public obj_where: function(field, operator, value, boost) { return scrivito.chainable_search.create_instance().and(field, operator, value, boost); } }); }()); (function() { var field_types = [ 'binary', 'enum', 'link', 'linklist', 'multienum', 'reference', 'referencelist', 'stringlist' ]; _.extend(scrivito, { standard_field_element: { create_instance: function(cms_element) { if (_.include(field_types, cms_element.dom_element().attr('data-scrivito-field-type'))) { return scrivito.cms_field_element.create_instance(cms_element); } } } }); scrivito.cms_element.definitions.push(scrivito.standard_field_element); }()); (function() { _.extend(scrivito, { string_field_element: { create_instance: function(cms_element) { if (cms_element.dom_element().attr('data-scrivito-field-type') === 'string') { var that = scrivito.cms_field_element.create_instance(cms_element); _.extend(that, { content: function() { var content = that.dom_element().text(); return $.trim(content); } }); return that; } }, all: function() { return _.map($('[data-scrivito-field-type="string"]'), function(dom_element) { return scrivito.cms_element.from_dom_element($(dom_element)); }); } } }); scrivito.cms_element.definitions.push(scrivito.string_field_element); }()); (function() { _.extend(scrivito, { user: { init: function(config) { scrivito.user.current = scrivito.user.create_instance(config.current); }, create_instance: function(params) { var that = { id: function() { return params.id; }, description: function() { return params.description; } }; return that; }, suggest: function(input) { return scrivito.ajax('GET', 'users/suggest?input=' + input); } } }); }()); (function() { _.extend(scrivito, { widget: { create_instance: function(obj, id, widget_class_name, options) { options = options || {}; var that = { id: function() { return id; }, obj: function() { return obj; }, widget_class_name: function() { return widget_class_name; }, modification: function() { return options.modification; }, placement_modification: function() { return options.placement_modification; }, description_for_editor: function() { return options.description_for_editor; }, is_modified: function() { return !!that.modification(); }, is_new: function() { return that.modification() === 'new'; }, is_edited: function() { return that.modification() === 'edited'; }, is_deleted: function() { return that.modification() === 'deleted'; }, is_placement_modified: function() { return !!that.placement_modification(); }, is_content_widget: function() { return widget_class_name === 'Scrivito::ContentWidget'; }, save: function(widget_attributes) { var obj_attributes = build_obj_attributes(widget_attributes); return that.obj().save(obj_attributes).then(function(obj_data) { return obj_data._widget_pool[that.id()]; }); }, destroy: function() { return that.obj().destroy_widget(that.id()); }, details_src: function() { // TODO unify with ajax url generation return "/__scrivito/" + markup_url('widget_details'); }, revert: function() { return that.obj().revert_widget(that.id()).then(function() { options.modification = null; }); }, restore: function() { return that.obj().restore_widget(that.id()).then(function() { options.modification = null; }); }, fetch_markup: function(template_name, inner_tag) { var params = { template_name: template_name, inner_tag: inner_tag }; return scrivito.ajax('GET', markup_url('show_widget') + '?' + $.param(params), {dataType: 'html'}); }, reload: function() { return that.obj().reload_widget(that.id()).then(function(data) { options.modification = data.modification; }); } }; var build_obj_attributes = function(widget_attributes) { var obj_attributes = {_widget_pool: {}}; obj_attributes._widget_pool[that.id()] = widget_attributes; return obj_attributes; }; var markup_url = function(action_name) { var obj_id = that.obj().id(); var widget_id = that.id(); return 'render_widget/'+obj_id+'/'+action_name+'/'+widget_id; }; return that; } } }); }()); (function() { _.extend(scrivito, { widget_element: { create_instance: function(cms_element) { if (cms_element.dom_element().attr('data-scrivito-private-widget-id')) { var that = cms_element; _.extend(that, { widget: function() { var dom_element = that.dom_element(); return scrivito.widget.create_instance(that.widget_field().obj(), dom_element.attr('data-scrivito-private-widget-id'), dom_element.attr('data-scrivito-widget-obj-class'), { modification: dom_element.attr('data-scrivito-private-widget-modification'), placement_modification: dom_element.attr( 'data-scrivito-private-widget-placement-modification'), description_for_editor: dom_element.attr( 'data-scrivito-private-widget-description-for-editor') } ); }, widget_field: function() { return scrivito.cms_element.from_dom_element(that.dom_element().parent()); }, has_details_view: function() { return !!that.dom_element().attr('data-scrivito-private-widget-has-details-view'); }, fetch_markup: function() { var template_name = that.widget_field().template_name(); var inner_tag = that.widget_field().inner_tag(); return that.widget().fetch_markup(template_name, inner_tag); }, details_src: function() { return that.widget().details_src(); }, field_name: function() { return that.widget_field().field_name(); }, has_widgetlist: function() { return !!that.dom_element().find('[data-scrivito-field-type=widgetlist]').length; } }); return that; } }, all: function(root_element) { return scrivito.cms_element.all('[data-scrivito-private-widget-id]', root_element); } } }); scrivito.cms_element.definitions.push(scrivito.widget_element); }()); (function() { _.extend(scrivito, { widgetlist_field_element: { create_instance: function(cms_element) { if (cms_element.dom_element().attr('data-scrivito-field-type') === 'widgetlist') { var that = scrivito.cms_field_element.create_instance(cms_element); _.extend(that, { content: function() { return _.map(that.widget_elements(), function(widget_element) { return widget_element.widget().id(); }); }, widget_elements: function() { var widget_elements_dom = that.dom_element() .children('[data-scrivito-private-widget-id]'); var widget_elements = _.map(widget_elements_dom, function(widget_element_dom) { return scrivito.cms_element.from_dom_element($(widget_element_dom)); }); return widget_elements; }, is_empty: function() { return that.widget_elements().length === 0; }, add_widget: function(widget_spec, widget_element, position) { var index; if (widget_element) { index = widget_element.dom_element() .prevAll('[data-scrivito-private-widget-id]').length; if (position === 'bottom') { index += 1; } } else { index = that.widget_elements().length; } var content = that.content(); content.splice(index, 0, widget_spec); return that.save(content).then(function(field_data) { var new_widget_id = field_data[index]; var widget = scrivito.widget.create_instance(that.obj(), new_widget_id); return insert_widget(widget, widget_element, position); }); }, add_widget_via_create: function(widget_params, widget_element, position) { scrivito.obj_class_selection.store(widget_params._obj_class); return that.add_widget({create: widget_params}, widget_element, position); }, add_widget_via_copy: function(widget_params, widget_element, position) { return that.add_widget({copy: widget_params}, widget_element, position); }, fetch_widget_class_selection: function() { var params = {field_name: that.field_name()}; if (that.widget()) { params.widget_id = that.widget().id(); } var request_path = 'objs/' + that.obj().id() + '/widget_class_selection?' + $.param(params); return scrivito.ajax('GET', request_path).then(function(obj_classes_markup) { return that.enrich_obj_classes_with_recent_and_popular(obj_classes_markup); }); }, allowed_classes: function() { return _.map(allowed_classes_json(), function(obj_class) { return obj_class.name; }); }, allowed_classes_for_create: function() { return _.without(that.allowed_classes(), 'Scrivito::ContentWidget'); }, can_create_widget: function() { return that.allowed_classes_for_create().length !== 0; }, can_choose_widget_class: function() { return that.allowed_classes_for_create().length > 1; }, description_for_allowed_classes: function() { return _.map(allowed_classes_json(), function(allowed_class_json) { return allowed_class_json.description; }); }, description_for_allowed_class: function(class_name) { var allowed_class = _.findWhere(allowed_classes_json(), {name: class_name}); if (allowed_class) { return allowed_class.description; } }, is_valid_child_class: function(widget_class_name) { var allowed_classes = that.allowed_classes(); if (allowed_classes) { return _.contains(allowed_classes, widget_class_name); } else { return true; } }, is_content_widget_allowed: function() { return that.is_valid_child_class('Scrivito::ContentWidget'); }, template_name: function() { return that.dom_element().attr('data-scrivito-private-field-widget-template'); }, inner_tag: function() { return that.dom_element().attr('data-scrivito-private-field-widget-inner-tag'); } }); var allowed_classes_json = function() { return JSON.parse(that.dom_element() .attr('data-scrivito-private-field-widget-allowed-classes')); }; var insert_widget = function(widget, widget_element, position) { return widget.fetch_markup(that.template_name(), that.inner_tag()).then( function(widget_markup) { var dom_element = $($.trim(widget_markup)); if (widget_element) { if (position === 'bottom') { widget_element.dom_element().after(dom_element); } else { widget_element.dom_element().before(dom_element); } } else { that.dom_element().prepend(dom_element); } scrivito.gui.new_content(dom_element.get(0)); scrivito.ensure_fully_visible_within_window(dom_element); scrivito.widget_sorting.update_placeholder(that); return widget; }); }; return that; } }, all: function(root_element) { return scrivito.cms_element.all('[data-scrivito-field-type="widgetlist"]', root_element); } } }); scrivito.cms_element.definitions.push(scrivito.widgetlist_field_element); }()); (function() { _.extend(scrivito, { workspace: { from_data: function(data) { var that = { id: function() { return data.id; }, title: function() { return that.original_title() || default_title(); }, original_title: function() { return data.title; }, icon: function() { return that.is_published() ? '' : ''; }, memberships: function() { return data.memberships; }, is_published: function() { return that.id() === 'published'; }, is_outdated: function() { return !!data.outdated; }, mark_as_outdated: function() { data.outdated = true; }, is_editable: function() { return !that.is_published(); }, check: function() { return check(0).then(function(result) { return handle_check_result(result, []); }); }, check_and_publish: function() { return check_and_publish(0); }, publish: function(certificates) { return scrivito.silent_ajax('PUT', 'workspaces/' + that.id() + '/publish', {data: { certificates: certificates }}); }, rebase: function() { return scrivito.ajax('PUT', 'workspaces/' + that.id() + '/rebase').done(function() { data.outdated = false; }); }, update: function(attributes) { return scrivito.ajax('PUT', 'workspaces/' + that.id(), {data: {workspace: attributes}}); }, rename: function(new_title) { return that.update({title: new_title}); }, destroy: function() { return scrivito.ajax('DELETE', 'workspaces/' + that.id()); }, has_conflicts: function() { return scrivito.obj_where('_conflicts', 'equals', true).size().then(function(size) { var promise = $.Deferred(); return size === 0 ? promise.reject() : promise.resolve(); }); }, owners: function() { return _.map(_.where(that.memberships(), {role: 'owner'}), function(membership) { return scrivito.user.create_instance({ id: membership.user_id, description: membership.description }); }); }, is_accessible: function() { return data.id === 'published' || data.is_accessible; } }; var check_and_publish = function(number_of_retries) { return rebase_outdated().then(function() { return that.check().then(function(certificates) { if (certificates) { return that.publish(certificates).then(null, function(error) { return handle_check_and_publish_error(error, number_of_retries); }); } else { return $.Deferred().reject({type: 'check_failed'}); } }, function(error) { return handle_check_and_publish_error(error, number_of_retries); }); }); }; var rebase_outdated = function() { return that.is_outdated() ? that.rebase() : $.Deferred().resolve(); }; var check = function(offset) { return scrivito.silent_ajax('GET', 'workspaces/' + that.id() + '/check?from=' + offset); }; var handle_check_result = function(result, certificates) { if (result.result === 'fail') { return $.Deferred().resolve(false); } certificates.push(result.certificate); if (result.pass.until === 'END') { return $.Deferred().resolve(certificates); } else { var offset = parseInt(result.pass.until, 10) + 1; return check(offset).then(function(result) { return handle_check_result(result, certificates); }); } }; var handle_check_and_publish_error = function(error, number_of_retries) { if (error.code === 'precondition_not_verifiable.workspace.publish.content_state_id') { // Another workspace has been published since last check. that.mark_as_outdated(); return check_and_publish(number_of_retries); } else if (error.code === 'precondition_not_met.workspace.publish.content_state_id') { // The workspace has been changed since last check. if (number_of_retries === 2) { return $.Deferred().reject({type: 'outdated_certificates'}); } else { return check_and_publish(number_of_retries + 1); } } else { scrivito.display_ajax_error(error); return error; } }; var default_title = function() { if (that.is_published()) { return scrivito.t('workspace.title_published'); } else { return scrivito.t('workspace.empty_title'); } }; return that; }, from_data_collection: function(workspace_datas) { return _.sortBy(_.map(workspace_datas, function(workspace_data) { return scrivito.workspace.from_data(workspace_data); }, function(workspace) { return workspace.is_published() ? '' : workspace.title().toUpperCase(); })); }, all: function() { return scrivito.ajax('GET', 'workspaces').then(function(workspace_datas) { return scrivito.workspace.from_data_collection(workspace_datas); }); }, editable: function() { return scrivito.workspace.all().then(function(workspaces) { return _.select(workspaces, function(workspace) { return workspace.is_editable(); }); }); }, published: function() { return scrivito.workspace.from_data({id: 'published'}); }, create: function(title) { var params = {data: {workspace: {title: title}}}; return scrivito.silent_ajax('POST', 'workspaces', params).then(function(ws_data) { return scrivito.workspace.from_data(ws_data); }, function(error) { if (error.code === 'precondition_not_met.workspace.create.exceeds_limit') { scrivito.workspace_limit_exceeded(); } else { scrivito.display_ajax_error(error); } }); } } }); }()); (function() { scrivito.storage = { set: function(key, object) { localStorage.setItem(full_key(key), JSON.stringify(object)); }, get: function(key) { return JSON.parse(localStorage.getItem(full_key(key))); }, has_key: function(key) { return !!scrivito.storage.get(key); }, remove: function(key) { localStorage.removeItem(full_key(key)); }, clear: function() { for (var i=0; i < localStorage.length; i++) { var key = localStorage.key(i); if (key.indexOf(storage_key_prefix) === 0) { localStorage.removeItem(key); } } } }; var storage_key_prefix = '_scrivito_'; var full_key = function(key_suffix) { return storage_key_prefix + key_suffix; }; })(); (function() { _.extend(scrivito, { /* * This component has two main purposes: * * 1. It wraps a function triggering a CSS transition * in an additional javascript event, so that that * transition will be executed even if associated target * has just been added to the DOM. * * 2. It skips any transitions and immediately executes * all functions in correct order if configured to do so, * e.g. in specs. */ transition: function(target, trigger_fn) { var deferred = $.Deferred(); if (!scrivito.transition.immediate_mode) { target.on('webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd', function() { deferred.resolve(); }); setTimeout(trigger_fn, 0); } else { trigger_fn(); deferred.resolve(); } return deferred; } }); _.extend(scrivito.transition, {immediate_mode: false}); }()); (function() { var auto_height_dirty = false; var relevant_siblings_for = function(elem) { return elem.siblings().filter(":not(.hover):visible"); }; var target_height_for = function(elem, dont_store_height) { var parent = elem.parent(); var heightOfParent = parent.innerHeight(); if (!dont_store_height) { parent.data("scrivito_last_inner_height", heightOfParent); } var heightOfAllSiblings = _(relevant_siblings_for(elem)) .chain() .map($) .reduce(function(sum, sibling) { var height = sibling.outerHeight(true); if (!dont_store_height) { sibling.data("scrivito_last_outer_height", height); } return sum + height; }, 0).value() ; return Math.max(0, heightOfParent - heightOfAllSiblings); }; var set_auto_height_for = function(elem) { elem.css('height', target_height_for(elem)); elem.addClass("scrivito_height_done"); }; var sibling_height_changes = function(elem) { return _(relevant_siblings_for(elem)).map(function(sibling) { sibling = $(sibling); var last = sibling.data("scrivito_last_outer_height"); var actual = sibling.outerHeight(true); if (last !== actual) { return scrivito.describe_element(sibling) + " unexpectantly changed it's height from " + (last === undefined ? "" : last) + " to " + actual ; } }); }; var parent_height_changes = function(elem) { var parent = elem.parent(); var last = parent.data("scrivito_last_inner_height"); var actual = parent.innerHeight(); if (last !== actual) { return scrivito.describe_element(parent) + " unexpectantly changed it's height from " + (last || "") + " to " + actual ; } }; _.extend(scrivito, { update_auto_height_for: function(root_element) { var elements = root_element.find('.scrivito_auto_height:visible'); if (root_element.hasClass("scrivito_auto_height")) { elements = elements.add(root_element); } elements.not(".scrivito_height_done").each(function (i, elem) { set_auto_height_for($(elem)); }); }, invalidate_auto_height: function() { $(".scrivito_height_done").removeClass("scrivito_height_done"); auto_height_dirty = true; }, invalidate_auto_height_for: function(elem) { elem.find(".scrivito_height_done").removeClass("scrivito_height_done"); }, process_auto_height: function() { if (auto_height_dirty) { scrivito.update_auto_height_for($("body")); auto_height_dirty = false; } }, auto_height_errors: function() { return _($(".scrivito_auto_height:visible")).chain().map($).map(function(elem) { var expected = target_height_for(elem, true); var actual = parseInt(elem.css('height'), 10); if (actual !== expected) { if (!elem.hasClass("scrivito_height_done")) { return [scrivito.describe_element(elem) + " was never updated"]; } else { var errors = sibling_height_changes(elem); errors.push(parent_height_changes(elem)); return _(errors).compact(); } } }).compact().flatten().value(); } }); }()); /*global ScrivitoHandlebarsTemplates:false */ /*global Handlebars:false */ (function() { Handlebars.registerHelper('translate', scrivito.i18n.translate); Handlebars.registerHelper('localize_date', function(date_value_function) { return scrivito.i18n.localize_date(date_value_function()); }); Handlebars.registerHelper('localize_date_relative', function(date_value_function) { return scrivito.i18n.localize_date_relative(date_value_function()); }); Handlebars.registerHelper('array_to_title', function(array_fn) { var escaped_array = array_fn().map(function(text) { return Handlebars.Utils.escapeExpression(text); }); return new Handlebars.SafeString(escaped_array.join(' ')); }); Handlebars.registerHelper('render', function(template_path, object) { return new Handlebars.SafeString(scrivito.template.render(template_path, object)); }); _.extend(scrivito, { template: { load_templates_from_server: false, template_cache: {}, render: function(template_path, data) { var template; if(typeof ScrivitoHandlebarsTemplates !== 'undefined') { template = ScrivitoHandlebarsTemplates[template_path]; } if(!template) { if(scrivito.template.load_templates_from_server) { template = scrivito.template.template_cache[template_path]; if(!template) { var url = "/app/assets/javascripts/templates/" + template_path + ".hbs?" + Math.random(); var source = jQuery.ajax(url, { async: false }).responseText; template = Handlebars.compile(source); scrivito.template.template_cache[template_path] = template; } } else { throw('could not load template' + template_path); } } return template(data); } } }); }()); (function() { _.extend(scrivito, { with_dialog_overlay: function(dom_element, promise) { var token = scrivito.dialog_overlay.create(dom_element); return promise.always(function() { scrivito.dialog_overlay.destroy(token); }); }, dialog_overlay: { create: function(dom_element) { var predecessor = $('.scrivito_overlay').last(); predecessor.removeClass('scrivito_show'); var overlay = $(scrivito.template.render('overlay')); dom_element.before(overlay); scrivito.transition(overlay, function() { overlay.addClass('scrivito_show'); }); return {overlay: overlay, predecessor: predecessor}; }, destroy: function(token) { var overlay = token.overlay; var predecessor = token.predecessor; scrivito.transition(overlay, function() { overlay.removeClass('scrivito_show'); }).then(function() { overlay.remove(); if (predecessor.length) { predecessor.addClass('scrivito_show'); } }); }, // Test purpose only. remove_all: function() { $('.scrivito_overlay').remove(); } } }); }()); (function() { var view; _.extend(scrivito, { with_saving_overlay: function(promise) { scrivito.saving_overlay.show(); return promise.always(function() { scrivito.saving_overlay.hide(); }); }, saving_overlay: { show: function() { if (!view) { view = $(scrivito.template.render('saving_overlay')); $('#scrivito_editing').append(view); } scrivito.transition(view, function() { view.addClass('scrivito_show'); }); }, hide: function() { if (view) { scrivito.transition(view, function() { view.removeClass('scrivito_show'); }).then(function(e) { // Remove the view only if event is triggered by a "fade-out" transition. if (e && $(e.target).hasClass('scrivito_show')) { return; } if (view) { view.remove(); } view = null; }); } }, // Test purpose only. remove_all: function() { $('.scrivito_saving_overlay').remove(); view = null; } } }); return scrivito; }()); (function() { _.extend(scrivito, { saving_indicator: { create: function(parent_view) { var target_selector = '.scrivito_saving_indicator'; var saving_in_progress_selector = target_selector + ' .scrivito_saving_in_progress'; var saving_done_selector = target_selector + ' .scrivito_saving_done'; parent_view.append(scrivito.template.render('saving_indicator')); var start_write_token = scrivito.write_monitor.on('start_write', function() { parent_view.find(saving_in_progress_selector).show(); parent_view.find(saving_done_selector).hide(); }); var end_write_token = scrivito.write_monitor.on('end_write', function() { if (!scrivito.write_monitor.is_writing()) { parent_view.find(saving_in_progress_selector).hide(); var saving_done_element = parent_view.find(saving_done_selector); saving_done_element.show(); if (!scrivito.transition.immediate_mode) { setTimeout(function() { saving_done_element.fadeOut(1000); }, 3000); } } }); return { destroy: function() { scrivito.write_monitor.off(start_write_token); scrivito.write_monitor.off(end_write_token); parent_view.find(target_selector).remove(); }, // Test purpose only. start_write_token: start_write_token, end_write_token: end_write_token }; } } }); }()); (function() { _.extend(scrivito, { with_element_overlay: function(dom_element, promise) { var element_overlay = scrivito.element_overlay.create(dom_element); return promise.always(function() { element_overlay.remove(); }); }, element_overlay: { create: function(dom_element) { var dom_element_position = dom_element.position(); var view = $(scrivito.template.render('element_overlay')).css({ position: 'absolute', // Required for unit tests to pass without an extra CSS file. top: 0, left: dom_element_position.left, width: dom_element.width(), height: dom_element.height() }); dom_element.append(view); return view; } } }); }()); (function() { _.extend(scrivito, { alert_dialog: function(message) { return scrivito.alert_dialog.open(message); } }); _.extend(scrivito.alert_dialog, { open: function(message, options) { var view = $(scrivito.template.render('alert_dialog', _.extend({message: message, color: 'red', icon: ''}, options || {}))); view.appendTo($('#scrivito_editing')); var promise = $.Deferred(); var close = function() { scrivito.dialog.close_with_transition(view); promise.resolve(); return false; }; view.find('.scrivito_close').on('click', close); scrivito.dialog.open_and_center_with_transition(view); return scrivito.with_dialog_behaviour(view, promise, {enter: close, escape: close}); }, // For test purpose only. remove_all: function() { $('.scrivito_alert_dialog').remove(); } }); }()); (function() { _.extend(scrivito, { info_dialog: function(message) { return scrivito.alert_dialog.open(message, {color: 'yellow', icon: ''}); } }); }()); (function() { _.extend(scrivito, { confirmation_dialog: function(options) { return scrivito.confirmation_dialog.open(options); } }); _.extend(scrivito.confirmation_dialog, { open: function(options) { var view = $(scrivito.template.render('confirmation_dialog', _.extend({ icon: '', cancel_button_text: scrivito.t('cancel'), confirm_button_text: scrivito.t('confirm') }, options || {}))); $('#scrivito_editing').append(view); var deferred = $.Deferred(); var accept = function() { scrivito.dialog.close_with_transition(view); deferred.resolve(); return false; }; var cancel = function() { scrivito.dialog.close_with_transition(view); deferred.reject(); return false; }; view.find('.scrivito_confirm').on('click', accept); view.find('.scrivito_cancel').on('click', cancel); scrivito.dialog.open_and_center_with_transition(view); return scrivito.with_dialog_behaviour(view, deferred, {enter: accept, escape: cancel}); }, // Test purpose only. remove_all: function() { $('.scrivito_confirmation_dialog').remove(); } }); }()); (function() { _.extend(scrivito, { prompt_dialog: function(options) { return scrivito.prompt_dialog.open(options); } }); _.extend(scrivito.prompt_dialog, { open: function(options) { var view = $(scrivito.template.render('prompt_dialog', _.extend({ icon: '', accept_button_text: scrivito.t('accept'), cancel_button_text: scrivito.t('cancel') }, options || {}))); $('#scrivito_editing').append(view); var deferred = $.Deferred(); var accept = function() { var val = view.find('input').val(); if (val) { scrivito.dialog.close_with_transition(view); deferred.resolve(val); } return false; }; var cancel = function() { scrivito.dialog.close_with_transition(view); deferred.reject(); return false; }; view.find('.scrivito_accept').on('click', accept); view.find('.scrivito_cancel').on('click', cancel); scrivito.dialog.open_and_center_with_transition(view).then(function() { view.find('input').focus(); }); return scrivito.with_dialog_behaviour(view, deferred, {enter: accept, escape: cancel}); } }); }()); (function() { _.extend(scrivito, { dialog: { open_without_transition: function(view) { view.addClass('scrivito_show'); }, open_and_adjust_without_transition: function(view) { scrivito.dialog.open_without_transition(view); scrivito.dialog.adjust(view); }, open_with_transition: function(view) { return scrivito.transition(view, function() { scrivito.dialog.open_without_transition(view); }); }, open_and_adjust_with_transition: function(view) { return scrivito.dialog.open_with_transition(view).then(function() { scrivito.dialog.adjust(view); }); }, open_and_center_with_transition: function(view) { return scrivito.dialog.open_with_transition(view).then(function() { scrivito.center(view); }); }, close_with_transition: function(view) { scrivito.transition(view, function() { view.removeClass('scrivito_show'); }).then(function() { view.remove(); view = null; }); }, close_without_transition: function(view) { view.removeClass('scrivito_show'); view.remove(); view = null; }, adjust: function(view) { scrivito.invalidate_auto_height_for(view); scrivito.update_auto_height_for(view); } } }); $(window).on('resize', function() { _.each($('.scrivito_adjust_dialog'), function(elem) { scrivito.dialog.adjust($(elem)); }); _.each($('.scrivito_center_dialog'), function(elem) { scrivito.center($(elem)); }); }); }()); (function() { _.extend(scrivito, { reloading: { init: function() { scrivito.gui.on('document', function(cms_document) { var body = cms_document.dom_element().find('body'); $(body).on('reload.scrivito', function() { cms_document.window().reload(); }); // TODO: remove this in 1.0.0. cms_document.local_jquery(body).on('scrivito_reload', function() { scrivito.deprecation_warning('$.trigger("scrivito_reload")', '$.scrivito("reload")'); cms_document.window().reload(); }); }); } } }); }()); (function() { _.extend(scrivito, { choose_obj_class_dialog: function(obj_classes_deferred, locale_path) { return scrivito.choose_obj_class_dialog.open(obj_classes_deferred, locale_path); } }); _.extend(scrivito.choose_obj_class_dialog, { open: function(obj_classes_deferred, locale_path) { var deferred = $.Deferred(); var view = $(scrivito.template.render('choose_obj_class_dialog', { title: scrivito.t('choose_obj_class_dialog.' + locale_path + '.title'), description: scrivito.t('choose_obj_class_dialog.' + locale_path + '.description') })); obj_classes_deferred.done(function(obj_class_selection) { var selection_view = scrivito.template.render('choose_obj_class_dialog/list', {obj_class_selection: obj_class_selection}); selection_view = $($.trim(selection_view)); view.find('#scrivito_replace_with_real_obj_classes').replaceWith(selection_view); view.on('click', '.scrivito_obj_class_thumbnail', function(e) { e.preventDefault(); scrivito.dialog.close_without_transition(view); deferred.resolve($(this).attr('data-scrivito-private-obj-class-name')); }); }); $('#scrivito_editing').append(view); var cancel = function() { scrivito.dialog.close_without_transition(view); deferred.reject(); return false; }; view.find('.scrivito_cancel').on('click', cancel); scrivito.dialog.open_and_adjust_without_transition(view); return scrivito.with_dialog_behaviour(view, deferred, {escape: cancel}); } }); }()); (function() { _.extend(scrivito, { details_dialog: { open: function(src, title, obj, commands) { var deferred = $.Deferred(); var view = $(scrivito.template.render('details_dialog', {src: src, title: title, obj: obj})); if (obj) { scrivito.obj_menu.create(view.find('.scrivito_obj_menu'), obj, commands); } $('#scrivito_editing').append(view); var indicator = scrivito.saving_indicator.create(view.find('.scrivito_saving_indicator')); var target = view.find('.scrivito_details_dialog_markup').hide(); var spinner = view.find('.scrivito_modal_body .scrivito_spinning').show(); var iframe = view.find('iframe'); iframe.on('load', function() { if (iframe.contents().find('body').hasClass('scrivito_dialog') && !iframe.contents().get(0).defaultView.scrivito) { scrivito.alert_dialog('Missing required Scrivito assets in the details dialog. ' + 'Are you sure your "scrivito_dialog.html.*" sources the Scrivito assets?'); } spinner.hide(); target.show(); var size_attr = 'data-scrivito-modal-size'; var modal_size = iframe.contents().find('['+size_attr+']').attr(size_attr); if (_.contains(['small', 'medium', 'large'], modal_size)) { view.removeClass('scrivito_modal_medium'); view.addClass('scrivito_modal_' + modal_size); } scrivito.dialog.adjust(view); }); var cancel = function() { indicator.destroy(); scrivito.dialog.close_without_transition(view); deferred.resolve(); return false; }; view.find('.scrivito_cancel').on('click', cancel); scrivito.dialog.open_and_adjust_without_transition(view); return scrivito.with_dialog_behaviour(view, deferred, {escape: cancel}); } } }); }()); (function() { _.extend(scrivito, { menus: { open: function(dom_element, commands, options) { var menu = $(scrivito.template.render('menu', _.extend(options || {}, { menu_items: _.map(scrivito.pattern_sort(commands, scrivito.menu_order), function(command) { return scrivito.menu_item.create_instance(command); }) }))); menu.find('.scrivito_menu_box_overlay').on('click', function() { menu.data('scrivito-menu-close')(); return false; }); dom_element.data('scrivito-menu-dom', menu); menu.data('scrivito-menu-close', function() { dom_element.removeData('scrivito-menu-dom'); menu.fadeOut(500, function() { menu.remove(); }); }); _.each(commands, function(command) { if (command.dom_id) { menu.on('click', '.'+command.dom_id(), function() { if (command.is_enabled()) { menu.data('scrivito-menu-close')(); } command.execute(); return false; }); } }); return menu; }, toggle: function(dom_element, open) { var menu = dom_element.data('scrivito-menu-dom'); if (menu) { menu.data('scrivito-menu-close')(); } else { open(); } } } }); }()); (function() { _.extend(scrivito, { dynamic_menus: { init: function() { scrivito.gui.on('document', function(cms_document) { var browser_window = $(cms_document.browser_window()); var dom_element = cms_document.dom_element(); _.each(['resize', 'scroll', 'load'], function(event) { browser_window.on(event, function() { scrivito.dynamic_menus.update_positions(); }); }); }); }, open: function(dom_element, commands, options) { var menu = scrivito.menus.open(dom_element, commands, options); var anchor = (options || {}).anchor; if (anchor) { menu.addClass('scrivito_precise_offset'); } menu.data('scrivito-menu-update-position', function() { var offset = scrivito.cms_document.offset(dom_element); if (anchor) { offset.left += anchor.x * dom_element.width(); offset.top += anchor.y * dom_element.height(); } menu.offset(offset); }); menu.appendTo($('#scrivito_editing')); menu.data('scrivito-menu-update-position')(); // Bugfix IE: can't set offset before append. menu.find('.scrivito_menu_box').fadeIn(500); }, toggle: function(dom_element, commands, options) { scrivito.menus.toggle(dom_element, function() { scrivito.dynamic_menus.open(dom_element, commands, options); }); }, update_positions: function() { _.each($('.scrivito_editing_marker_menu'), function(menu) { var update_position = $(menu).data('scrivito-menu-update-position'); if (update_position) { update_position(); } }); } } }); }()); (function() { _.extend(scrivito, { static_menus: { open: function(dom_element, commands, options) { var menu = scrivito.menus.open(dom_element, commands, options); menu.appendTo(dom_element); menu.find('.scrivito_menu_box').fadeIn(500); }, toggle: function(dom_element, commands, options) { scrivito.menus.toggle(dom_element, function() { scrivito.static_menus.open(dom_element, commands, options); }); } } }); }()); (function() { var callbacks = []; _.extend(scrivito, { inplace_marker: { init: function() { scrivito.on('content', function(content) { scrivito.inplace_marker.refresh(scrivito.cms_document.from($(content)).dom_element()); }); }, define: function(callback) { callbacks.push(callback); }, refresh: function(root_element) { if (!scrivito.editing_context.is_view_mode()) { root_element.find('.scrivito_editing_marker').remove(); _.each(callbacks, function(callback) { callback(builder, root_element); }); scrivito.dynamic_menus.update_positions(); } }, are_overlapping: function(dom_element1, dom_element2) { var a = dom_element1.getBoundingClientRect(); var b = dom_element2.getBoundingClientRect(); return a.left <= b.right && b.left <= a.right && a.top <= b.bottom && b.top <= a.bottom; }, // For test purpose only. reset_callbacks: function() { callbacks = []; } } }); var warn_overlapping = function(dom_element) { var other_dom_elements = $($(dom_element).closest('body')).find('.scrivito_editing_marker').not(dom_element); var overlapping_dom_elements = _.filter(other_dom_elements, function(other_dom_element) { return scrivito.inplace_marker.are_overlapping(dom_element, other_dom_element); }); if (overlapping_dom_elements.length) { scrivito.warn.apply(null, [scrivito.t('inplace_marker.overlapping'), dom_element].concat(overlapping_dom_elements)); } }; var lights_on = function(highlightable_element) { highlightable_element.addClass('scrivito_active scrivito_entered'); var timer = setTimeout(function() { highlightable_element.removeClass('scrivito_entered'); }, 2000); highlightable_element.data('scrivito-entered-timer', timer); }; var lights_off = function(document) { document.find('.scrivito_active').removeClass('scrivito_active'); document.find('.scrivito_entered').removeClass('scrivito_entered').each(function () { clearTimeout($(this).data('scrivito-entered-timer')); }); }; var enable_highlighting_for = function(marker_container) { if (marker_container.data('scrivito-highlightable')) { return; } marker_container.data('scrivito-highlightable', true); var document = scrivito.cms_document.from(marker_container).dom_element(); marker_container.on('mouseenter', function(event) { var target = $(event.target).closest(':data(scrivito-highlightable)'); if (target.is(marker_container)) { lights_off(document); lights_on(marker_container); } }); marker_container.on('mouseleave', function(event) { lights_off(document); var target = $(event.relatedTarget).closest(':data(scrivito-highlightable)'); if (target.length) { lights_on(target); } }); }; var builder = { activate_for: function(cms_element, options) { var marker = $(scrivito.template.render('inplace_marker', options || {})); marker.on('click', function() { if (scrivito.is_development_mode) { warn_overlapping(marker.get(0)); } scrivito.dynamic_menus.toggle(marker, cms_element.menu()); return false; }); var marker_container = cms_element.dom_element(); marker.prependTo(marker_container); enable_highlighting_for(marker_container); } }; }()); (function() { _.extend(scrivito, { option_marker: { init: function() { scrivito.on('content', function(content) { if (scrivito.editing_context.is_editing_mode()) { _.each(scrivito.widget_element.all($(content)), function(widget_element) { if (!widget_element.has_widgetlist()) { scrivito.option_marker.create(widget_element, 'top'); scrivito.option_marker.create(widget_element, 'bottom'); } }); } }); }, create: function(widget_element, position) { var marker = $(scrivito.template.render('option_marker', {position: position})); marker.appendTo(widget_element.dom_element()); marker.on('click', function() { var widgetlist_field_element = widget_element.widget_field(); if (widgetlist_field_element.can_choose_widget_class()) { scrivito.choose_and_create_widget_command(widget_element, position).execute(); } else { scrivito.create_widget_command(widget_element, position).execute(); } return false; }); } } }); }()); (function() { _.extend(scrivito, { resource_dialog: { init: function(config) { if (config.obj) { var obj = scrivito.obj.create_instance(config.obj); scrivito.gui.on('open', function() { scrivito.resource_dialog.open(obj, config.return_to).then(function() { return scrivito.with_saving_overlay(scrivito.redirect_to(config.return_to)); }); }); } }, open: function(obj, return_to) { var title = scrivito.t('resource_dialog.title', obj.obj_class_name()); return scrivito.details_dialog.open(obj.details_src(), title, obj, [ scrivito.revert_obj_command(obj, 'resource_dialog.commands.revert_obj'), scrivito.restore_obj_command(obj, 'resource_dialog.commands.restore_obj'), scrivito.mark_resolved_obj_command(obj, 'resource_dialog.commands.mark_resolved_obj'), scrivito.delete_obj_command(obj, 'resource_dialog.commands.delete_obj', return_to || '/'+scrivito.application_document().page().id()) ]); } } }); }()); (function() { _.extend(scrivito, { external_links: { init: function() { scrivito.gui.on('document', function(cms_document) { var new_document = cms_document.dom_element(); var base = new_document.find('head > base'); if (!base.length) { base = $(''); new_document.find('head').prepend(base); } base.attr('target', '_top'); }); scrivito.on('content', function(content) { content = $(content); _.each(content.find('a').not( '[data-scrivito-display-mode="editing"] [data-scrivito-field-type="html"] a'), function(link) { var element = $(link); var target = convert_target(link, element.attr('target')); element.attr('target', target); }); _.each(content.find('form').not( '[data-scrivito-display-mode="editing"] [data-scrivito-field-type="html"] form'), function(form) { var element = $(form); var link = document.createElement('a'); link.href = form.action; var target = convert_target(link, element.attr('target')); element.attr('target', target); }); }); } } }); var convert_target = function(link, target) { if (link.protocol === window.location.protocol && link.host === window.location.host) { if (!target) { return '_self'; } } else { if ( target === '' || target === '_self' || target === '_parent' || (/^scrivito/).test(target) ) { return '_top'; } } return target; }; }()); (function() { _.extend(scrivito, { iframe_dialog: { open: function(iframe, options) { iframe = $(iframe); options = options || {}; var iframe_container; if (!iframe.parent().is('body')) { iframe_container = iframe.closest('#scrivito_editing > div'); } var view = $(scrivito.template.render('iframe_dialog', { color: options.color, confirm: options.confirm || scrivito.t('confirm'), cancel: options.cancel || scrivito.t('cancel'), disable_confirm: options.confirm === false, disable_cancel: options.cancel === false })); $('#scrivito_editing').append(view); var dialog_body = view.find('.scrivito_modal_body'); var when_closed = $.Deferred(); var confirm = function() { scrivito.dialog.close_without_transition(view); when_closed.resolve(); return false; }; var cancel = function() { scrivito.dialog.close_without_transition(view); when_closed.reject(); return false; }; view.find('.scrivito_confirm').on('click', confirm); view.find('.scrivito_cancel').on('click', cancel); scrivito.with_dialog_behaviour(view, when_closed, {enter: confirm, escape: cancel}); scrivito.dialog.open_and_adjust_without_transition(view); scrivito.restore_styles_afterwards(when_closed, iframe); iframe.css('z-index', scrivito.iframe_dialog.z_index(view) + 1); if (iframe_container) { scrivito.restore_styles_afterwards(when_closed, iframe_container); iframe_container.addClass('scrivito_dialog_mode'); } else { iframe.attr('class', ''); // Remove device toggle classes. } var adjust = function() { // Make sure to never manipulate the iFrame after the dialog has been closed. if (when_closed.state() !== 'pending') { return; } iframe.width(dialog_body.width()); iframe.height(dialog_body.height()); iframe.offset(dialog_body.offset()); }; $(window).on('resize', adjust); adjust(); return { when_open: $.Deferred().resolve(dialog_body), when_closed: when_closed.promise() }; }, // For test purpose only. z_index: function(view) { return parseInt(view.css('z-index'), 10); } } }); }()); (function() { _.extend(scrivito, { full_screen_panel: function(doc, promise) { var body = $(doc).find('body'); var panel = $('
    '); body.append(panel); promise.always(function() { panel.detach(); }); scrivito.restore_styles_afterwards(promise, body); body.css('overflow', 'hidden'); return panel; } }); }()); (function() { _.extend(scrivito, { add_content_command: function(cms_element) { var widgetlist_field_element, widget_element; if (cms_element.widget_field) { widget_element = cms_element; } else { widgetlist_field_element = cms_element; } return scrivito.command.create_instance({ id: 'scrivito.sdk.add_content', title: scrivito.t('commands.add_content.title'), icon: '', present: function() { return scrivito.select_content && scrivito.editing_context.is_editing_mode() && (widget_element || widgetlist_field_element.is_empty()); }, disabled: function() { if (!(widgetlist_field_element || widget_element.widget_field()) .is_content_widget_allowed()) { return scrivito.t('commands.add_content.not_allowed'); } }, execute: function() { if (!widgetlist_field_element) { widgetlist_field_element = widget_element.widget_field(); } scrivito.select_content().then(function(contents) { var content = contents[0]; if (content) { var widget_params = { _obj_class: 'Scrivito::ContentWidget', content: content }; scrivito.with_saving_overlay( widgetlist_field_element.add_widget_via_create(widget_params, widget_element) ); } }); } }); } }); }()); (function() { _.extend(scrivito, { add_subpage_command: function(child_list_element) { return scrivito.command.create_instance({ id: 'scrivito.sdk.add_subpage', title: scrivito.t('commands.add_subpage.title'), icon: '', tooltip: scrivito.t('commands.add_subpage.tooltip', child_list_element.obj().description_for_editor()), execute: function() { var class_selection = child_list_element.fetch_page_class_selection(); var choose_obj_class = scrivito.choose_obj_class_dialog(class_selection, 'add_child_page'); return choose_obj_class.then(function(obj_class) { var add_subpage = child_list_element.create_child(obj_class); return scrivito.with_saving_overlay(add_subpage).then(function(obj) { return scrivito.application_window.redirect_to('/' + obj.id()); }); }); } }); } }); }()); (function() { _.extend(scrivito, { choose_and_create_widget_command: function(cms_element, position) { var widgetlist_field_element, widget_element; if (cms_element.widget_field) { widget_element = cms_element; widgetlist_field_element = widget_element.widget_field(); } else { widgetlist_field_element = cms_element; } return scrivito.command.create_instance({ id: 'scrivito.sdk.choose_and_create_widget', title: scrivito.t('commands.choose_and_create_widget.title'), icon: '', present: function() { return scrivito.editing_context.is_editing_mode() && (widget_element || widgetlist_field_element.is_empty()) && (widgetlist_field_element.can_choose_widget_class() || !widgetlist_field_element.can_create_widget()); }, disabled: function() { if (!widgetlist_field_element.can_create_widget()) { return scrivito.t('commands.choose_and_create_widget.disabled'); } }, execute: function() { var choose_obj_class = scrivito.choose_obj_class_dialog( widgetlist_field_element.fetch_widget_class_selection(), 'create_widget'); return choose_obj_class.then(function(obj_class) { var widget_params = {_obj_class: obj_class}; return scrivito.with_saving_overlay( widgetlist_field_element.add_widget_via_create(widget_params, widget_element, position)); }); } }); } }); }()); (function() { _.extend(scrivito, { copy_page_from_clipboard_command: function(child_list_element) { return scrivito.command.create_instance({ id: 'scrivito.sdk.copy_page_from_clipboard', title: scrivito.t('commands.copy_page_from_clipboard.title'), icon: '', present: function() { return scrivito.obj_clipboard.is_present(); }, disabled: function() { var obj_class_name = scrivito.obj_clipboard.obj().obj_class_name(); if (!child_list_element.is_valid_child_class(obj_class_name)) { return scrivito.t('commands.copy_page_from_clipboard.paste_forbidden', child_list_element.allowed_classes().join(', ')); } }, execute: function() { var copy_page = scrivito.obj_clipboard.obj().copy_to(child_list_element.path()); return scrivito.with_saving_overlay(copy_page).then(function(obj) { return scrivito.application_window.redirect_to('/' + obj.id()); }); } }); } }); }()); (function() { _.extend(scrivito, { copy_widget_from_clipboard_command: function(cms_element) { var widgetlist_field_element, widget_element; if (cms_element.widget_field) { widget_element = cms_element; } else { widgetlist_field_element = cms_element; } return scrivito.command.create_instance({ id: 'scrivito.sdk.copy_widget_from_clipboard', title: function() { return scrivito.t('commands.copy_widget_from_clipboard.' + (scrivito.widget_clipboard.widget().is_content_widget() ? 'content' : 'widget') + '_title'); }, icon: '', present: function() { return scrivito.editing_context.is_editing_mode() && scrivito.widget_clipboard.is_present() && (widget_element || widgetlist_field_element.is_empty()); }, disabled: function() { if (!widgetlist_field_element) { widgetlist_field_element = widget_element.widget_field(); } var widget_class_name = scrivito.widget_clipboard.widget().widget_class_name(); if (!widgetlist_field_element.is_valid_child_class(widget_class_name)) { return scrivito.t('commands.copy_widget_from_clipboard.paste_forbidden', widgetlist_field_element.description_for_allowed_classes().join(', ')); } }, execute: function() { if (!widgetlist_field_element) { widgetlist_field_element = widget_element.widget_field(); } var widget = scrivito.widget_clipboard.widget(); var workspace_id = scrivito.widget_clipboard.workspace_id(); var widget_params = { workspace_id: workspace_id, obj_id: widget.obj().id(), widget_id: widget.id() }; return scrivito.with_saving_overlay( widgetlist_field_element.add_widget_via_copy(widget_params, widget_element) ); } }); } }); }()); (function() { _.extend(scrivito, { create_widget_command: function(cms_element, position) { var widgetlist_field_element, widget_element, description, obj_class; if (cms_element.widget_field) { widget_element = cms_element; widgetlist_field_element = widget_element.widget_field(); } else { widgetlist_field_element = cms_element; } obj_class = widgetlist_field_element.allowed_classes_for_create()[0]; description = widgetlist_field_element.description_for_allowed_class(obj_class); return scrivito.command.create_instance({ id: 'scrivito.sdk.create_widget', title: scrivito.t('commands.create_widget.title', description), icon: '', present: function() { return scrivito.editing_context.is_editing_mode() && (widget_element || widgetlist_field_element.is_empty()) && widgetlist_field_element.can_create_widget() && !widgetlist_field_element.can_choose_widget_class(); }, execute: function() { var params = {_obj_class: obj_class}; return scrivito.with_saving_overlay( widgetlist_field_element.add_widget_via_create(params, widget_element, position)); } }); } }); }()); (function() { _.extend(scrivito, { create_workspace_command: function() { return scrivito.command.create_instance({ id: 'scrivito.sdk.create_workspace', title: scrivito.t('commands.create_workspace.title'), icon: '', disabled: function() { if (!scrivito.user_permissions.can('create_workspace')) { return scrivito.t('commands.create_workspace.forbidden'); } }, execute: function() { scrivito.prompt_dialog({ title: scrivito.t('commands.create_workspace.dialog.title'), description: scrivito.t('commands.create_workspace.dialog.description'), placeholder: scrivito.t('commands.create_workspace.dialog.placeholder'), icon: '', color: 'green', accept_button_text: scrivito.t('commands.create_workspace.dialog.accept'), accept_button_color: 'green' }).then(function(title) { scrivito.with_saving_overlay(scrivito.workspace.create(title)).then(function(workspace) { var params = {workspace_id: workspace.id()}; if (!scrivito.editing_context.selected_workspace.is_editable()) { params.display_mode = 'editing'; } return scrivito.change_editing_context(params); }); }); } }); } }); }()); (function() { _.extend(scrivito, { current_page_link_command: function() { return scrivito.command.create_instance({ id: 'scrivito.sdk.current_page_link', icon: 'scrivito_icon_link', title: scrivito.t('commands.current_page_link.title'), execute: function() { scrivito.current_page_link_dialog(); } }); } }); }()); (function() { _.extend(scrivito, { delete_obj_command: function(obj, translations_namespace, redirect_target) { if (!translations_namespace) { translations_namespace = 'commands.delete_obj'; } return scrivito.command.create_instance({ id: 'scrivito.sdk.delete_obj', title: scrivito.t(translations_namespace + '.title'), icon: '', present: function() { return obj && !scrivito.editing_context.is_deleted_mode(); }, disabled: function() { if (!scrivito.editing_context.selected_workspace.is_editable()) { return scrivito.t('commands.delete_obj.published_workspace'); } if (obj.has_children()) { return scrivito.t('commands.delete_obj.has_children'); } }, execute: function() { scrivito.confirmation_dialog({ title: scrivito.t(translations_namespace + '.dialog.title'), description: scrivito.t(translations_namespace + '.dialog.description'), icon: '', color: 'red', confirm_button_text: scrivito.t('commands.delete_obj.dialog.confirm'), confirm_button_color: 'red' }).then(function() { return scrivito.with_saving_overlay(obj.destroy().then(function(redirect_to) { if (scrivito.obj_clipboard.is_present() && scrivito.obj_clipboard.obj().id() === obj.id()) { scrivito.obj_clipboard.clear(); } var redirect_url = URI({ path: scrivito.root_path() + (redirect_target || redirect_to) }); redirect_url.normalizePath(); return scrivito.redirect_to(redirect_url.path()); })); }); } }); } }); }()); (function() { _.extend(scrivito, { delete_widget_command: function(widget_element) { return scrivito.command.create_instance({ id: 'scrivito.sdk.delete_widget', title: scrivito.t('commands.delete_widget.' + (widget_element.widget().is_content_widget() ? 'content' : 'widget') + '_title'), icon: '', present: function() { return scrivito.editing_context.is_editing_mode(); }, execute: function() { return scrivito.confirmation_dialog({ title: scrivito.t('commands.delete_widget.dialog.title'), description: scrivito.t('commands.delete_widget.dialog.description'), icon: '', color: 'red', confirm_button_text: scrivito.t('commands.delete_widget.dialog.confirm'), confirm_button_color: 'red' }).then(function() { var widgetlist_field_element = widget_element.widget_field(); var widget = widget_element.widget(); widget_element.dom_element().remove(); scrivito.widget_sorting.update_placeholder(widgetlist_field_element); return widget.destroy().then(function() { if (scrivito.widget_clipboard.is_present() && scrivito.widget_clipboard.widget().id() === widget.id()) { scrivito.widget_clipboard.clear(); } }); }); } }); } }); }()); (function() { _.extend(scrivito, { delete_workspace_command: function(workspace) { return scrivito.command.create_instance({ id: 'scrivito.sdk.delete_workspace', title: scrivito.t('commands.delete_workspace.title'), icon: '', execute: function() { scrivito.confirmation_dialog({ title: scrivito.t('commands.delete_workspace.dialog.title', workspace.title()), description: scrivito.t('commands.delete_workspace.dialog.description'), icon: '', color: 'red', confirm_button_text: scrivito.t('commands.delete_workspace.dialog.confirm'), confirm_button_color: 'red' }).done(function() { scrivito.with_saving_overlay(workspace.destroy().then(function() { return scrivito.change_editing_context({workspace_id: 'published'}); })); }); } }); } }); }()); (function() { _.extend(scrivito, { duplicate_obj_command: function(obj) { return scrivito.command.create_instance({ id: 'scrivito.sdk.duplicate_obj', title: scrivito.t('commands.duplicate_obj.title'), icon: '', present: function() { return obj && !scrivito.editing_context.is_deleted_mode(); }, disabled: function() { if (!scrivito.editing_context.selected_workspace.is_editable()) { return scrivito.t('commands.duplicate_obj.published_workspace'); } if (obj.has_children()) { return scrivito.t('commands.duplicate_obj.has_children'); } }, execute: function() { return scrivito.with_saving_overlay(obj.duplicate()).then(function(obj) { return scrivito.application_window.redirect_to('/' + obj.id()); }); } }); } }); }()); (function() { _.extend(scrivito, { mark_resolved_obj_command: function(obj, translations_namespace) { if (!translations_namespace) { translations_namespace = 'commands.mark_resolved_obj'; } return scrivito.command.create_instance({ id: 'scrivito.sdk.mark_resolved_obj', title: scrivito.t(translations_namespace + '.title'), icon: '', present: function() { return obj && obj.has_conflict(); }, execute: function() { return scrivito.confirmation_dialog({ title: scrivito.t('commands.mark_resolved_obj.dialog.title'), description: scrivito.t(translations_namespace + '.dialog.description'), icon: '', color: 'red', confirm_button_text: scrivito.t('commands.mark_resolved_obj.dialog.confirm'), confirm_button_color: 'red' }).then(function() { return scrivito.with_saving_overlay(obj.mark_resolved()).then(function() { scrivito.application_window.reload(); }); }); } }); } }); }()); (function() { _.extend(scrivito, { move_page_from_clipboard_command: function(child_list_element) { return scrivito.command.create_instance({ id: 'scrivito.sdk.move_page_from_clipboard', title: scrivito.t('commands.move_page_from_clipboard.title'), icon: '', present: function() { return scrivito.obj_clipboard.is_present(); }, disabled: function() { var obj_class_name = scrivito.obj_clipboard.obj().obj_class_name(); if (!child_list_element.is_valid_child_class(obj_class_name)) { return scrivito.t('commands.move_page_from_clipboard.paste_forbidden', child_list_element.allowed_classes().join(', ')); } }, execute: function() { var move_page = child_list_element.add_child(scrivito.obj_clipboard.obj()); return scrivito.with_saving_overlay(move_page).then(function() { scrivito.obj_clipboard.clear(); scrivito.application_window.reload(); }); } }); } }); }()); (function() { _.extend(scrivito, { obj_details_command: function(obj) { return scrivito.command.create_instance({ id: 'scrivito.sdk.obj_details', title: function() { if (scrivito.editing_context.is_editing_mode()) { return scrivito.t('commands.obj_details.title_edit'); } else { return scrivito.t('commands.obj_details.title_view'); } }, icon: '', present: function() { return obj.has_details_view(); }, execute: function() { var title_locale; if (scrivito.editing_context.is_editing_mode()) { title_locale = 'commands.obj_details.dialog.title_edit'; } else { title_locale = 'commands.obj_details.dialog.title_view'; } return scrivito.write_monitor.track_changes(function() { return scrivito.details_dialog.open(obj.details_src(), scrivito.t(title_locale, obj.obj_class_name())); }, function() { scrivito.application_window.redirect_to('/' + obj.id()); }); } }); } }); }()); (function() { _.extend(scrivito, { publish_workspace_command: function(workspace) { var open_confirmation_dialog = function() { return scrivito.confirmation_dialog({ title: scrivito.t('commands.publish_workspace.dialog.title', workspace.title()), description: scrivito.t('commands.publish_workspace.dialog.description'), icon: '', color: 'green', confirm_button_text: scrivito.t('commands.publish_workspace.dialog.confirm'), confirm_button_color: 'green' }); }; var open_check_failed_dialog = function() { scrivito.confirmation_dialog({ title: scrivito.t('commands.publish_workspace.error_dialog.title'), description: scrivito.t('commands.publish_workspace.error_dialog.description'), icon: '', confirm_button_text: scrivito.t('commands.publish_workspace.error_dialog.confirm') }).then(function() { scrivito.changes_dialog.open(); }); }; return scrivito.command.create_instance({ id: 'scrivito.sdk.publish_workspace', title: scrivito.t('commands.publish_workspace.title'), icon: '', tooltip: scrivito.t('commands.publish_workspace.title', workspace.title()), disabled: function() { if (!scrivito.user_permissions.can('publish_workspace')) { return scrivito.t('commands.publish_workspace.permission_denied'); } }, execute: function() { if (scrivito.user_permissions.can('publish_workspace')) { open_confirmation_dialog().done(function() { scrivito.with_saving_overlay(workspace.check_and_publish().done(function() { return scrivito.change_editing_context({workspace_id: 'published'}); }).fail(function(error) { if (error.type === 'check_failed') { open_check_failed_dialog(); } else if (error.type === 'outdated_certificates') { scrivito.alert_dialog( scrivito.t('commands.publish_workspace.alert.invalid_certificates')); } })); }); } } }); } }); }()); (function() { _.extend(scrivito, { rebase_workspace_command: function(workspace) { return scrivito.command.create_instance({ id: 'scrivito.sdk.rebase_workspace', title: scrivito.t('commands.rebase_workspace.title'), icon: '', tooltip: scrivito.t('commands.rebase_workspace.tooltip', workspace.title()), disabled: function() { if (!workspace.is_outdated()) { return scrivito.t('commands.rebase_workspace.uptodate', workspace.title()); } }, action_required: function() { return workspace.is_outdated(); }, execute: function() { var rebase_promise = workspace.rebase(); scrivito.with_saving_overlay(rebase_promise); rebase_promise.then(function() { return workspace.has_conflicts().then(function() { return scrivito.confirmation_dialog({ title: scrivito.t('commands.rebase_workspace.has_conflicts.title'), description: scrivito.t('commands.rebase_workspace.has_conflicts.description'), confirm_button_text: scrivito.t('commands.rebase_workspace.open_changes_dialog'), cancel_button_text: scrivito.t('close') }).then(function() { return scrivito.changes_dialog.open(); }); }).always(function() { scrivito.with_saving_overlay($.Deferred()); scrivito.application_window.reload(); }); }); } }); } }); }()); (function() { _.extend(scrivito, { rename_workspace_command: function(workspace) { return scrivito.command.create_instance({ id: 'scrivito.sdk.rename_workspace', title: scrivito.t('commands.rename_workspace.title'), icon: '', execute: function() { scrivito.prompt_dialog({ title: scrivito.t('commands.rename_workspace.dialog.title', workspace.title()), description: scrivito.t('commands.rename_workspace.dialog.description'), value: workspace.original_title(), icon: '', color: 'green', accept_button_text: scrivito.t('commands.rename_workspace.dialog.accept'), accept_button_color: 'green' }).done(function(new_title) { scrivito.with_saving_overlay(workspace.rename(new_title).then(function() { return scrivito.reload(); })); }); } }); } }); }()); (function() { _.extend(scrivito, { restore_obj_command: function(obj, translations_namespace) { if (!translations_namespace) { translations_namespace = 'commands.restore_obj'; } return scrivito.command.create_instance({ id: 'scrivito.sdk.restore_obj', title: scrivito.t(translations_namespace + '.title'), icon: '', present: function() { return obj && obj.is_deleted(); }, execute: function() { scrivito.with_saving_overlay(obj.restore().then(function() { return scrivito.reload(); })); } }); } }); }()); (function() { _.extend(scrivito, { restore_widget_command: function(widget_element) { var widget = widget_element.widget(); return scrivito.command.create_instance({ id: 'scrivito.sdk.restore_widget', title: scrivito.t('commands.restore_widget.title'), icon: '', present: function() { return widget.is_deleted(); }, execute: function() { scrivito.with_saving_overlay(widget.restore()).then(function() { scrivito.application_window.reload(); }); } }); } }); }()); (function() { _.extend(scrivito, { revert_obj_command: function(obj, translations_namespace) { if (!translations_namespace) { translations_namespace = 'commands.revert_obj'; } return scrivito.command.create_instance({ id: 'scrivito.sdk.revert_obj', title: scrivito.t(translations_namespace + '.title'), icon: '', present: function() { return scrivito.editing_context.selected_workspace.is_editable() && obj && !obj.is_deleted(); }, disabled: function() { if (!obj.modification()) { return scrivito.t(translations_namespace + '.not_modified_obj'); } if (obj.is_new()) { return scrivito.t(translations_namespace + '.new_obj'); } }, update: function() { return obj.reload(); }, execute: function() { return scrivito.confirmation_dialog({ title: scrivito.t(translations_namespace + '.dialog.title'), description: scrivito.t('commands.revert_obj.dialog.description'), icon: '', color: 'red', confirm_button_text: scrivito.t('commands.revert_obj.dialog.confirm'), confirm_button_color: 'red' }).then(function() { return scrivito.with_saving_overlay(obj.revert()).then(function() { scrivito.application_window.reload(); }); }); } }); } }); }()); (function() { _.extend(scrivito, { revert_widget_command: function(widget_element) { var widget = widget_element.widget(); return scrivito.command.create_instance({ id: 'scrivito.sdk.revert_widget', title: scrivito.t('commands.revert_widget.' + (widget.is_content_widget() ? 'content' : 'widget') + '_title'), icon: '', present: function() { return scrivito.editing_context.selected_workspace.is_editable() && !widget.is_deleted(); }, disabled: function() { if (widget.is_new()) { return scrivito.t('commands.revert_widget.is_new'); } if (!widget.is_modified()) { return scrivito.t('commands.revert_widget.is_not_modified'); } }, update: function() { return widget.reload(); }, execute: function() { return scrivito.confirmation_dialog({ title: scrivito.t('commands.revert_widget.dialog.title'), description: scrivito.t('commands.revert_widget.dialog.description'), icon: '', color: 'red', confirm_button_text: scrivito.t('commands.revert_obj.dialog.confirm'), confirm_button_color: 'red' }).then(function() { var dom_element = widget_element.dom_element(); scrivito.with_element_overlay(dom_element, widget.revert().then(function() { dom_element.scrivito('reload'); })); }); } }); } }); }()); (function() { _.extend(scrivito, { save_obj_to_clipboard_command: function(obj) { return scrivito.command.create_instance({ id: 'scrivito.sdk.save_obj_to_clipboard', title: scrivito.t('commands.save_obj_to_clipboard.title'), icon: '', present: function() { return !scrivito.editing_context.is_deleted_mode(); }, disabled: function() { if (obj.has_children()) { return scrivito.t('commands.save_obj_to_clipboard.has_children'); } }, execute: function() { scrivito.obj_clipboard.save_obj(obj); } }); } }); }()); (function() { _.extend(scrivito, { save_widget_to_clipboard_command: function(widget_element) { return scrivito.command.create_instance({ id: 'scrivito.sdk.save_widget_to_clipboard', title: scrivito.t('commands.save_widget_to_clipboard.' + (widget_element.widget().is_content_widget() ? 'content' : 'widget') + '_title'), icon: '', present: function() { return scrivito.editing_context.is_editing_mode(); }, execute: function() { scrivito.widget_clipboard.save_widget(widget_element.widget()); } }); } }); }()); (function() { _.extend(scrivito, { select_workspace_command: function(workspace) { return scrivito.command.create_instance({ id: 'scrivito.sdk.select_workspace_'+workspace.id(), title: workspace.title(), icon: workspace.icon(), subtitle: subtitle(workspace), disabled: function() { if (!workspace.is_accessible()) { return scrivito.t('commands.select_workspace.disabled'); } }, execute: function() { scrivito.with_saving_overlay( scrivito.change_editing_context({workspace_id: workspace.id()})); } }); } }); var subtitle = function(workspace) { var owners = workspace.owners(); var owner = owners[0]; switch (owners.length) { case 0: return undefined; case 1: return owner.description(); case 2: return scrivito.t('commands.select_workspace.x_and_1_owner', owner.description()); default: return scrivito.t('commands.select_workspace.x_and_n_owners', owner.description(), owners.length - 1); } }; }()); (function() { _.extend(scrivito, { sort_items_command: function(child_list_element) { return scrivito.command.create_instance({ id: 'scrivito.sdk.sort_items', title: scrivito.t('commands.sort_items.title'), icon: '', tooltip: scrivito.t('commands.sort_items.tooltip', child_list_element.obj().description_for_editor()), disabled: function() { if (!child_list_element.has_child_order()) { return scrivito.t('commands.sort_items.auto_sort'); } if (child_list_element.children().length < 2) { return scrivito.t('commands.sort_items.too_less_children'); } }, execute: function() { var children = child_list_element.children(); return scrivito.obj_sorting_dialog.open(children).then(function(sorted_children) { var dom_element = child_list_element.dom_element(); _.each(sorted_children, function(sorted_child) { dom_element.append(sorted_child.dom_element()); }); return child_list_element.save_order(); }); } }); } }); }()); (function() { _.extend(scrivito, { switch_mode_command: function(mode) { var icon; switch (mode) { case 'diff': icon = ''; break; case 'added': icon = ''; break; case 'deleted': icon = ''; break; } return scrivito.command.create_instance({ id: 'scrivito.sdk.switch_to_' + mode + '_mode', title: scrivito.t('commands.switch_mode.' + mode), icon: icon, disabled: function() { if (scrivito.editing_context.display_mode === mode) { return scrivito.t('commands.switch_mode.disabled'); } }, execute: function() { if (mode !== 'view' && !scrivito.editing_context.selected_workspace.is_editable()) { scrivito.with_saving_overlay(scrivito.workspace.editable()).then(function(workspaces) { scrivito.editable_workspace_dialog(workspaces).then(function(workspace_id) { redirect_to(mode, workspace_id); }); }); } else { redirect_to(mode); } } }); } }); var redirect_to = function(dispaly_mode, workspace_id) { var promise = scrivito.change_editing_context( {workspace_id: workspace_id, display_mode: dispaly_mode}); scrivito.with_saving_overlay(promise); }; }()); (function() { _.extend(scrivito, { widget_details_command: function(widget_element) { var widget = function() { return widget_element.widget(); }; return scrivito.command.create_instance({ id: 'scrivito.sdk.widget_details', title: scrivito.t('commands.widget_details.title'), icon: '', present: function() { return widget_element.widget_field().template_name() === 'show' && !widget().is_content_widget() && (scrivito.editing_context.is_editing_mode() || widget().is_modified() || widget().is_placement_modified()); }, disabled: function() { if (!widget_element.has_details_view()) { return scrivito.t('commands.widget_details.no_details_view'); } }, execute: function() { return scrivito.write_monitor.track_changes(function() { return scrivito.details_dialog.open(widget_element.details_src(), scrivito.t('commands.widget_details.dialog.title', widget().widget_class_name())); }, function() { widget_element.dom_element().scrivito('reload'); }); } }); } }); }()); (function() { _.extend(scrivito, { workspace_changes_command: function() { return scrivito.command.create_instance({ id: 'scrivito.sdk.workspace_changes', title: scrivito.t('commands.workspace_changes.title'), icon: '', execute: function() { scrivito.changes_dialog.open(); } }); } }); }()); (function() { _.extend(scrivito, { workspace_settings_command: function(workspace) { return scrivito.command.create_instance({ id: 'scrivito.sdk.workspace_settings', title: scrivito.t('commands.workspace_settings.title'), icon: '', execute: function() { var title = scrivito.t('commands.workspace_settings.dialog.title', workspace.title()); scrivito.workspace_settings_dialog.open(title, workspace.memberships()).then( function(memberships) { scrivito.with_saving_overlay( workspace.update({memberships: memberships}).then(function() { return scrivito.reload(); }) ); } ); } }); } }); }()); (function() { _.extend(scrivito, { child_list_commands: { init: function() { if (scrivito.editing_context.is_editing_mode()) { scrivito.on('content', function(content) { _.each(scrivito.child_list_element.all($(content)), function(child_list_element) { child_list_element.set_menu([ scrivito.add_subpage_command(child_list_element), scrivito.copy_page_from_clipboard_command(child_list_element), scrivito.move_page_from_clipboard_command(child_list_element), scrivito.sort_items_command(child_list_element) ].concat(child_list_element.menu())); }); }); } } } }); }()); (function() { var create_command_separator = function(index) { return scrivito.command_separator .create_instance({id: 'scrivito.sdk.current_page_commands.separator'+index}); }; _.extend(scrivito, { current_page_commands: { init: function() { scrivito.gui.on('document', function(cms_document) { var current_page = cms_document.page(); if (current_page) { cms_document.set_menu([ scrivito.obj_details_command(current_page), scrivito.current_page_link_command(), create_command_separator(1), scrivito.save_obj_to_clipboard_command(current_page), scrivito.duplicate_obj_command(current_page), create_command_separator(2), scrivito.mark_resolved_obj_command(current_page), scrivito.restore_obj_command(current_page), scrivito.revert_obj_command(current_page), scrivito.delete_obj_command(current_page) ].concat(cms_document.menu())); } }); } } }); }()); (function() { var create_command_separator = function(index) { return scrivito.command_separator .create_instance({id: 'scrivito.sdk.widget_commands.separator'+index}); }; _.extend(scrivito, { widget_commands: { init: function() { if (!scrivito.editing_context.is_view_mode()) { scrivito.on('content', function(content) { _.each(scrivito.widget_element.all($(content)), function(widget_element) { widget_element.set_menu([ scrivito.create_widget_command(widget_element), scrivito.choose_and_create_widget_command(widget_element), // // FIXME content-widget // // scrivito.add_content_command(widget_element), scrivito.widget_details_command(widget_element), create_command_separator(1), scrivito.save_widget_to_clipboard_command(widget_element), scrivito.copy_widget_from_clipboard_command(widget_element), create_command_separator(2), scrivito.restore_widget_command(widget_element), scrivito.revert_widget_command(widget_element), scrivito.delete_widget_command(widget_element) ].concat(widget_element.menu())); }); }); } } } }); }()); (function() { _.extend(scrivito, { widgetlist_field_commands: { init: function() { if (scrivito.editing_context.is_editing_mode()) { scrivito.on('content', function(content) { _.each(scrivito.widgetlist_field_element.all($(content)), function(widgetlist_field_element) { widgetlist_field_element.set_menu([ scrivito.create_widget_command(widgetlist_field_element), scrivito.choose_and_create_widget_command(widgetlist_field_element), // // FIXME content-widget // // scrivito.add_content_command(widgetlist_field_element), scrivito.copy_widget_from_clipboard_command(widgetlist_field_element) ].concat(widgetlist_field_element.menu())); }); }); } } } }); }()); (function() { _.extend(scrivito, { child_list_marker: { init: function() { scrivito.inplace_marker.define(function(inplace_marker, root_element) { if (scrivito.editing_context.is_editing_mode()) { _.each(scrivito.child_list_element.all(root_element), function(child_list_element) { var description = scrivito.t('child_list_menu.description', child_list_element.obj().description_for_editor()); inplace_marker.activate_for(child_list_element, {description: description}); }); } }); } } }); }()); (function() { _.extend(scrivito, { widgetlist_field_menu: { init: function() { scrivito.on('content', function(content) { if (scrivito.editing_context.is_editing_mode()) { var widgetlist_field_elements = scrivito.widgetlist_field_element.all($(content)); _.each(widgetlist_field_elements, function(widgetlist_field_element) { activate_menu_for(widgetlist_field_element); }); } }); } } }); var activate_menu_for = function(widgetlist_field_element) { var container = widgetlist_field_element.dom_element(); container.on('click.scrivito', function(e) { if (!widgetlist_field_element.is_empty()) { return; } var container_offset = container.offset(); var relative_offset = { left: e.pageX - container_offset.left, top: e.pageY - container_offset.top }; var anchor = { x: relative_offset.left / container.width(), y: relative_offset.top / container.height() }; scrivito.dynamic_menus.toggle(container, widgetlist_field_element.menu(), {anchor: anchor}); return false; }); }; }()); (function() { _.extend(scrivito, { widget_marker: { init: function() { scrivito.inplace_marker.define(function(inplace_marker, root_element) { if (scrivito.editing_context.selected_workspace.is_editable()) { var widgetlist_field_elements = scrivito.widgetlist_field_element.all(root_element); _.each(widgetlist_field_elements, function(widgetlist_field_element) { _.each(widgetlist_field_element.widget_elements(), function(widget_element) { var show_as_modified = widget_element.widget().is_modified() || widget_element.widget().is_placement_modified(); if (scrivito.editing_context.is_editing_mode() || scrivito.editing_context.is_comparing_mode() && show_as_modified) { if (widget_element.has_widgetlist()) { widget_element.dom_element().attr('data-scrivito-private-structure-widget', true); } inplace_marker.activate_for(widget_element, inplace_marker_options(widget_element)); } }); }); } }); } } }); var inplace_marker_options = function(widget_element) { var options = {}; if (widget_element.has_widgetlist()) { options.icon = 'scrivito_icon_structure_widget'; } if (scrivito.editing_context.is_comparing_mode()) { var tooltip_translation_key; var modification = widget_element.widget().modification(); var placement_modification = widget_element.widget().placement_modification(); switch (modification) { case 'new': tooltip_translation_key = 'widget_is_new'; options.icon = 'scrivito_icon_inv_plus'; break; case 'deleted': tooltip_translation_key = 'widget_is_deleted'; options.icon = 'scrivito_icon_trash'; break; case 'edited': options.icon = 'scrivito_icon_edited'; switch (placement_modification) { case 'new': tooltip_translation_key = 'widget_is_edited_and_dragged_here'; options.css_classes = 'scrivito_widget_moved_icon'; break; case 'deleted': tooltip_translation_key = 'widget_is_edited_and_dragged_away'; options.css_classes = 'scrivito_widget_moved_icon'; break; default: tooltip_translation_key = 'widget_is_edited'; } break; default: options.icon = 'scrivito_icon_moved'; switch (placement_modification) { case 'new': tooltip_translation_key = 'widget_is_dragged_here'; break; case 'deleted': tooltip_translation_key = 'widget_is_dragged_away'; break; } } if (tooltip_translation_key) { options.tooltip = scrivito.t('widget_marker.' + tooltip_translation_key); } } options.description = widget_element.widget().description_for_editor(); return options; }; }()); (function() { _.extend(scrivito, { widget_reloading: { init: function() { scrivito.on('content', function(dom_element) { if (scrivito.in_editable_view()) { var jquery_object = $(dom_element); if (jquery_object.attr('data-scrivito-private-widget-id')) { activate_for(jquery_object); } _.each(jquery_object.find('[data-scrivito-private-widget-id]'), function(dom_element) { activate_for($(dom_element)); }); } }); }, reload_widget: function(widget_element){ scrivito.with_element_overlay(widget_element.dom_element(), widget_element.fetch_markup().then(function(show_markup) { var new_jquery_object = $(show_markup); widget_element.dom_element().replaceWith(new_jquery_object); scrivito.gui.new_content(new_jquery_object); }) ); } } }); var activate_for = function(jquery_object) { var activate = function() { var widget_element = scrivito.cms_element.from_dom_element(jquery_object); scrivito.widget_reloading.reload_widget(widget_element); return false; }; $(jquery_object).on('reload.scrivito', function() { activate(); return false; }); // TODO: remove this in 1.0.0. scrivito.cms_document.local_jquery(jquery_object).on('scrivito_reload', function() { scrivito.deprecation_warning('$.trigger("scrivito_reload")', '$.scrivito("reload")'); activate(); return false; }); }; }()); (function() { _.extend(scrivito, { widget_sorting: { init: function() { scrivito.on('content', function(root_element) { if (scrivito.in_editable_view()) { create($(root_element)); } }); }, start: function(event, ui) { var cms_document = scrivito.cms_document.from(ui.item); cms_document.dom_element().find('body').addClass('scrivito_widget_dragging_active'); var widget_element = scrivito.cms_element.from_dom_element(ui.item); var widget_class_name = widget_element.widget().widget_class_name(); _.each(widgetlist_field_elements, function(widgetlist_field_element) { var dom_element = widgetlist_field_element.dom_element(); if (dom_element.data('ui-sortable')) { if (widgetlist_field_element.is_valid_child_class(widget_class_name) && dom_element.is(':visible')) { dom_element.addClass('scrivito_widget_drop_allowed'); } else { dom_element.sortable('disable'); } } }); $(event.target).sortable('refresh'); }, stop: function(event, ui) { var root_element = scrivito.cms_document.from(ui.item).dom_element(); root_element.find('body').removeClass('scrivito_widget_dragging_active'); // Drag the _last_ widget out of a widget field and then drop it back. if (!ui.sender) { var widgetlist_field_element = scrivito.cms_element.from_dom_element(ui.item).widget_field(); scrivito.widget_sorting.update_placeholder(widgetlist_field_element); } _.each(widget_field_dom_elements, function(dom_element) { dom_element.removeClass('scrivito_widget_drop_allowed'); if (dom_element.data('ui-sortable')) { dom_element.sortable('enable'); } }); }, update: function(event, ui) { if (event.target === ui.item.parent()[0]) { var widget_element = scrivito.cms_element.from_dom_element(ui.item); var target_field_element = widget_element.widget_field(); scrivito.widget_sorting.update_placeholder(target_field_element); if (ui.sender) { var source_field_element = scrivito.cms_element.from_dom_element(ui.sender); scrivito.widget_sorting.update_placeholder(source_field_element); var changes = {}; add_changes(changes, source_field_element); add_changes(changes, target_field_element); source_field_element.obj().save(changes); if (!widget_element.dom_element().is(target_field_element.inner_tag())) { scrivito.widget_reloading.reload_widget(widget_element); } } else { target_field_element.save(); } } }, // We can not listen to "out", because of the a bug in jQuery-Sortable. // The bug in http://bugs.jqueryui.com/ticket/5671 is still present. over: function(event, ui) { if (ui.sender) { var widgetlist_field_element = scrivito.cms_element.from_dom_element(ui.sender); // If "over" is triggered, then exactly one item has been removed from the sender field. var number_of_widget_elements = widgetlist_field_element.widget_elements().length - 1; scrivito.widget_sorting.update_placeholder(widgetlist_field_element, number_of_widget_elements); } }, update_placeholder: function(widgetlist_field_element, number_of_widget_elements) { var dom_element = widgetlist_field_element.dom_element(); if (number_of_widget_elements === undefined) { number_of_widget_elements = widgetlist_field_element.widget_elements().length; } if (number_of_widget_elements === 0) { dom_element.addClass('scrivito_empty_widget_field'); } else { dom_element.removeClass('scrivito_empty_widget_field'); } } } }); var widgetlist_field_elements = []; var widget_field_dom_elements = []; var create = function(root_element) { var cms_document = scrivito.cms_document.from(root_element); if (scrivito.editing_context.visible_workspace.is_editable()) { _.each(scrivito.widgetlist_field_element.all(root_element), function(widgetlist_field_element) { var dom_element = widgetlist_field_element.dom_element(); if (!dom_element.data('ui-sortable')) { dom_element.sortable({ items: '> [data-scrivito-private-widget-id]', handle: '> .scrivito_editing_marker', placeholder: 'scrivito_widget_drop_placeholder', connectWith: '*[data-scrivito-field-type="widgetlist"]', start: scrivito.widget_sorting.start, stop: scrivito.widget_sorting.stop, update: scrivito.widget_sorting.update, over: scrivito.widget_sorting.over, cursor: 'move', forcePlaceholderSize: true, // Force placeholders to be always visible. tolerance: 'pointer' // jQuery fails to correctly determine the intersection. }); scrivito.widget_sorting.update_placeholder(widgetlist_field_element); widgetlist_field_elements.push(widgetlist_field_element); widget_field_dom_elements.push(dom_element); } }); } }; var add_changes = function(changes, widgetlist_field_element) { var widget = widgetlist_field_element.widget(); if (widget) { add_widget_changes(changes, widgetlist_field_element, widget.id()); } else { add_field_changes(changes, widgetlist_field_element); } }; var add_field_changes = function(changes, widgetlist_field_element) { changes[widgetlist_field_element.field_name()] = widgetlist_field_element.content(); }; var add_widget_changes = function(changes, widgetlist_field_element, widget_id) { if (!changes._widget_pool) { changes._widget_pool = {}; } if (!changes._widget_pool[widget_id]) { changes._widget_pool[widget_id] = {}; } add_field_changes(changes._widget_pool[widget_id], widgetlist_field_element); }; }()); (function() { _.extend(scrivito, { no_turbolinks: { init: function() { scrivito.gui.on('document', function(cms_document) { if (cms_document.browser_window().Turbolinks) { scrivito.alert_dialog( 'You have Turbolinks enabled. ' + 'Scrivito does not yet support Turbolinks. ' + 'Please remove it from your assets.' ); } }); } } }); }()); (function() { _.extend(scrivito, { content_upload: { init: function() { scrivito.on('content', function(content) { if (scrivito.in_editable_view()) { _.each(scrivito.widgetlist_field_element.all($(content)), function(widgetlist_field_element) { scrivito.content_upload.create(widgetlist_field_element); }); _.each(scrivito.widget_element.all($(content)), function(widget_element) { scrivito.content_upload.create(widget_element.widget_field(), widget_element); }); } }); }, create: function(widgetlist_field_element, widget_element) { var dropzone = (widget_element || widgetlist_field_element).dom_element(); var is_active = function() { return widget_element || widgetlist_field_element.is_empty(); }; dropzone.on('dragenter', function() { if (is_active()) { dropzone.addClass('scrivito_content_upload'); } return false; }); dropzone.on('dragleave', function() { if (is_active()) { dropzone.removeClass('scrivito_content_upload'); } return false; }); dropzone.on('drop', function(event) { if (is_active()) { dropzone.removeClass('scrivito_content_upload'); var data_transfer = event.originalEvent.dataTransfer; if (data_transfer) { var files = data_transfer.files; if (files.length === 1) { scrivito.content_upload.upload(files[0], widgetlist_field_element, widget_element); } } } return false; }); }, upload: function(file, widgetlist_field_element, widget_element) { var obj_class = scrivito.default_obj_class_for_content_type(file.type); var create_obj = scrivito.create_obj({blob: file, _obj_class: obj_class}); scrivito.with_saving_overlay(create_obj.then(function(obj) { return widgetlist_field_element.create_content_widget(obj.id, widget_element); })); } } }); }()); (function() { _.extend(scrivito, { hotkeys: { add_actions_while: function(promise, key_map) { var key_actions = { 13: key_map.enter, // enter key 27: key_map.escape // escape key }; $(document).on('keyup.scrivito_hotkeys_add_actions_while', function(e) { if (key_actions[e.keyCode]) { e.preventDefault(); key_actions[e.keyCode](e); } }); return promise.always(function() { $(document).off('keyup.scrivito_hotkeys_add_actions_while'); }); } } }); }()); (function() { _.extend(scrivito, { with_dialog_behaviour: function(dom_element, promise, key_map) { return scrivito.with_dialog_overlay(dom_element, scrivito.hotkeys.add_actions_while(promise, key_map)); } }); }()); (function() { _.extend(scrivito, { editable_workspace_dialog: function(workspaces) { var can_select = workspaces.length; var can_create = scrivito.user_permissions.can('create_workspace'); var view = $(scrivito.template.render('editable_workspace_dialog', { workspaces: workspaces, can_select: can_select, can_create: can_create, can_select_or_create: can_select || can_create })); $('#scrivito_editing').append(view); var create_new_ws = false; view.on('focus click', '.scrivito_input_list_of_ws', function(e) { create_new_ws = false; view.find(".scrivito_confirm").html(scrivito.t('editable_ws_dialog.select')); view.find(".scrivito_disabled").removeClass("scrivito_disabled"); view.find(".scrivito_input_new_ws_name label, .scrivito_input_new_ws_name input").addClass("scrivito_disabled"); }); view.on('focus click drop', '.scrivito_input_new_ws_name', function(e) { create_new_ws = true; view.find(".scrivito_confirm").html(scrivito.t('menu_bar.create')); view.find(".scrivito_disabled").removeClass("scrivito_disabled"); view.find(".scrivito_input_list_of_ws label, .scrivito_input_list_of_ws select").addClass("scrivito_disabled"); }); var deferred = $.Deferred(); var confirm_action = function() { if (create_new_ws) { create_workspace(); } else { select_workspace(); } return false; }; var create_workspace = function() { var title = $('#scrivito_new_ws_name').val(); scrivito.dialog.close_with_transition(view); scrivito.with_saving_overlay(scrivito.workspace.create(title)).then(function(workspace) { deferred.resolve(workspace.id()); }, function() { deferred.reject(); }); }; var select_workspace = function() { var ws_id = $('select#scrivito_list_of_ws').val(); scrivito.dialog.close_with_transition(view); deferred.resolve(ws_id); }; var cancel_action = function() { scrivito.dialog.close_with_transition(view); deferred.reject(); return false; }; view.find('.scrivito_confirm').on('click', confirm_action); view.find('.scrivito_cancel').on('click', cancel_action); scrivito.dialog.open_and_center_with_transition(view); if (can_select) { view.find('.scrivito_input_list_of_ws').click(); view.find('#scrivito_list_of_ws').focus(); } else if (can_create) { view.find('.scrivito_input_new_ws_name').click(); view.find('#scrivito_new_ws_name').focus(); } return scrivito.with_dialog_behaviour(view, deferred, { enter: confirm_action, escape: cancel_action }); } }); }()); (function() { _.extend(scrivito, { obj_sorting_dialog: { open: function(children) { var child_list = _.map(children, function(child) { return child.obj(); }); var view = $(scrivito.template.render('obj_sorting_dialog', { icon: '', child_list: child_list })); $('#scrivito_editing').append(view); $('#scrivito_obj_sorting_sortable').sortable({ placeholder: 'scrivito_obj_sorting_placeholder' }); var deferred = $.Deferred(); var confirm_action = function(e) { var new_id_order = _.map($('#scrivito_obj_sorting_sortable li'), function(child) { return $(child).attr('data-scrivito-private-obj-id'); }); var sorted_children = _.sortBy(children, function(child) { return _.indexOf(new_id_order, child.obj().id()); }); deferred.resolve(sorted_children); scrivito.dialog.close_without_transition(view); return false; }; var cancel_action = function(e) { deferred.reject(); scrivito.dialog.close_without_transition(view); return false; }; view.find('.scrivito_confirm').on('click', confirm_action); view.find('.scrivito_cancel').on('click', cancel_action); scrivito.dialog.open_and_adjust_without_transition(view); return scrivito.with_dialog_behaviour(view, deferred, { enter: confirm_action, escape: cancel_action }); } } }); }()); (function() { _.extend(scrivito, { workspace_settings_dialog: { open: function(title, memberships) { var promise = $.Deferred(); var view = $(scrivito.template.render('workspace_settings_dialog', { title: title, owners: _.pluck(_.where(memberships, {role: 'owner'}), 'user_id').join() })); view.appendTo($('#scrivito_editing')); var select_owners = view.find('.scrivito_select_owners'); var confirm = function() { var new_memberships = {}; _.each(select_owners.select2('val'), function(user_id) { new_memberships[user_id] = {role: 'owner'}; }); promise.resolve(new_memberships); scrivito.dialog.close_without_transition(view); return false; }; var cancel = function() { promise.reject(); scrivito.dialog.close_without_transition(view); return false; }; select_owners.select2({ multiple: true, minimumInputLength: 1, query: scrivito.throttle(function(query) { scrivito.user.suggest(query.term).then(function(users) { query.callback({results: _.map(users, function(user) { return {id: user.id, text: user.description}; })}); }); }, 500), initSelection: function(element, callback) { var value = $(element).val(); if (value) { callback(_.map(value.split(','), function(user_id) { return { id: user_id, text: _.findWhere(memberships, {user_id: user_id}).description, locked: user_id === scrivito.user.current.id() }; })); } }, formatNoMatches: scrivito.t('workspace_settings_dialog.nothing_found'), formatSearching: scrivito.t('workspace_settings_dialog.searching'), formatInputTooShort: scrivito.t('workspace_settings_dialog.too_short') }); view.find('.scrivito_confirm').on('click', confirm); view.find('.scrivito_cancel').on('click', cancel); scrivito.dialog.open_and_adjust_without_transition(view); view.on('keyup', function(e) { if ((e.keyCode === 13 || e.keyCode === 27) && $(e.target).attr('class').indexOf('select2') > -1) { return false; } }); return scrivito.with_dialog_behaviour(view, promise, {enter: confirm, escape: cancel}); } } }); }()); (function() { _.extend(scrivito, { warn_before_unloading: function() { if (scrivito.write_monitor.is_writing()) { return scrivito.t('warn_before_unloading'); } } }); }()); (function(){ scrivito.obj_clipboard = { save_obj: function(obj) { store_obj(obj); }, is_present: function() { return !!scrivito.storage.has_key(storage_key); }, obj: function() { var data = stored_data(); return scrivito.obj.create_instance({id: data.id, obj_class_name: data.obj_class_name}); }, clear: function() { scrivito.storage.remove(storage_key); } }; var storage_key = 'obj_clipboard'; var store_obj = function(obj) { var data = {id: obj.id(), obj_class_name: obj.obj_class_name()}; scrivito.storage.set(storage_key, data); }; var stored_data = function() { var data = scrivito.storage.get(storage_key); return data || {}; }; })(); (function(){ scrivito.widget_clipboard = { save_widget: function(widget) { store_widget(widget); }, is_present: function() { return !!scrivito.storage.has_key(storage_key); }, widget: function() { var data = stored_data(); var obj = scrivito.obj.create_instance({ id: data.obj_id, obj_class_name: data.obj_class_name }); return scrivito.widget.create_instance(obj, data.id, data.widget_class_name); }, workspace_id: function() { return stored_data().workspace_id; }, clear: function() { scrivito.storage.remove(storage_key); } }; var storage_key = 'widget_clipboard'; var store_widget = function(widget) { var data = { id: widget.id(), widget_class_name: widget.widget_class_name(), obj_id: widget.obj().id(), obj_class_name: widget.obj().obj_class_name(), workspace_id: scrivito.editing_context.selected_workspace.id() }; scrivito.storage.set(storage_key, data); }; var stored_data = function() { var data = scrivito.storage.get(storage_key); return data || {}; }; })(); // // // // // (function() { $(function() { var iframe = $('iframe[name=scrivito_application]'); scrivito.application_window = scrivito.cms_window.from(iframe); // Fallback behavior in case that application window renders a page with no SDK, e.g. an error // or a static page. iframe.on('load', function() { var application_document = scrivito.application_document(); var browser_window = scrivito.application_window.browser_window(); var has_config = !!application_document.page_config(); var has_sdk = !!browser_window.scrivito; // The application window is completely missing the SDK and the config. if (!has_config && !has_sdk) { // Install jQuery in order to allow correct application document bootstrapping. if (!browser_window.jQuery) { browser_window.jQuery = jQuery; } if (!browser_window.$) { browser_window.$ = $; } // Bootstrap the application document. application_document.install_public_api(); application_document.connect(); } }); scrivito.init(scrivito.ui_config()); scrivito.gui.start(); }); }());