/*! * jQuery UI Core 1.10.2 * http://jqueryui.com * * Copyright 2013 jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license * * http://api.jqueryui.com/category/ui-core/ */ (function( $, undefined ) { var uuid = 0, runiqueId = /^ui-id-\d+$/; // $.ui might exist from components with no dependencies, e.g., $.ui.position $.ui = $.ui || {}; $.extend( $.ui, { version: "1.10.2", keyCode: { BACKSPACE: 8, COMMA: 188, DELETE: 46, DOWN: 40, END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, LEFT: 37, NUMPAD_ADD: 107, NUMPAD_DECIMAL: 110, NUMPAD_DIVIDE: 111, NUMPAD_ENTER: 108, NUMPAD_MULTIPLY: 106, NUMPAD_SUBTRACT: 109, PAGE_DOWN: 34, PAGE_UP: 33, PERIOD: 190, RIGHT: 39, SPACE: 32, TAB: 9, UP: 38 } }); // plugins $.fn.extend({ focus: (function( orig ) { return function( delay, fn ) { return typeof delay === "number" ? this.each(function() { var elem = this; setTimeout(function() { $( elem ).focus(); if ( fn ) { fn.call( elem ); } }, delay ); }) : orig.apply( this, arguments ); }; })( $.fn.focus ), scrollParent: function() { var scrollParent; if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) { scrollParent = this.parents().filter(function() { return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x")); }).eq(0); } else { scrollParent = this.parents().filter(function() { return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x")); }).eq(0); } return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent; }, zIndex: function( zIndex ) { if ( zIndex !== undefined ) { return this.css( "zIndex", zIndex ); } if ( this.length ) { var elem = $( this[ 0 ] ), position, value; while ( elem.length && elem[ 0 ] !== document ) { // Ignore z-index if position is set to a value where z-index is ignored by the browser // This makes behavior of this function consistent across browsers // WebKit always returns auto if the element is positioned position = elem.css( "position" ); if ( position === "absolute" || position === "relative" || position === "fixed" ) { // IE returns 0 when zIndex is not specified // other browsers return a string // we ignore the case of nested elements with an explicit value of 0 //
value = parseInt( elem.css( "zIndex" ), 10 ); if ( !isNaN( value ) && value !== 0 ) { return value; } } elem = elem.parent(); } } return 0; }, uniqueId: function() { return this.each(function() { if ( !this.id ) { this.id = "ui-id-" + (++uuid); } }); }, removeUniqueId: function() { return this.each(function() { if ( runiqueId.test( this.id ) ) { $( this ).removeAttr( "id" ); } }); } }); // selectors function focusable( element, isTabIndexNotNaN ) { var map, mapName, img, nodeName = element.nodeName.toLowerCase(); if ( "area" === nodeName ) { map = element.parentNode; mapName = map.name; if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) { return false; } img = $( "img[usemap=#" + mapName + "]" )[0]; return !!img && visible( img ); } return ( /input|select|textarea|button|object/.test( nodeName ) ? !element.disabled : "a" === nodeName ? element.href || isTabIndexNotNaN : isTabIndexNotNaN) && // the element and all of its ancestors must be visible visible( element ); } function visible( element ) { return $.expr.filters.visible( element ) && !$( element ).parents().addBack().filter(function() { return $.css( this, "visibility" ) === "hidden"; }).length; } $.extend( $.expr[ ":" ], { data: $.expr.createPseudo ? $.expr.createPseudo(function( dataName ) { return function( elem ) { return !!$.data( elem, dataName ); }; }) : // support: jQuery <1.8 function( elem, i, match ) { return !!$.data( elem, match[ 3 ] ); }, focusable: function( element ) { return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) ); }, tabbable: function( element ) { var tabIndex = $.attr( element, "tabindex" ), isTabIndexNaN = isNaN( tabIndex ); return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN ); } }); // support: jQuery <1.8 if ( !$( "" ).outerWidth( 1 ).jquery ) { $.each( [ "Width", "Height" ], function( i, name ) { var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], type = name.toLowerCase(), orig = { innerWidth: $.fn.innerWidth, innerHeight: $.fn.innerHeight, outerWidth: $.fn.outerWidth, outerHeight: $.fn.outerHeight }; function reduce( elem, size, border, margin ) { $.each( side, function() { size -= parseFloat( $.css( elem, "padding" + this ) ) || 0; if ( border ) { size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0; } if ( margin ) { size -= parseFloat( $.css( elem, "margin" + this ) ) || 0; } }); return size; } $.fn[ "inner" + name ] = function( size ) { if ( size === undefined ) { return orig[ "inner" + name ].call( this ); } return this.each(function() { $( this ).css( type, reduce( this, size ) + "px" ); }); }; $.fn[ "outer" + name] = function( size, margin ) { if ( typeof size !== "number" ) { return orig[ "outer" + name ].call( this, size ); } return this.each(function() { $( this).css( type, reduce( this, size, true, margin ) + "px" ); }); }; }); } // support: jQuery <1.8 if ( !$.fn.addBack ) { $.fn.addBack = function( selector ) { return this.add( selector == null ? this.prevObject : this.prevObject.filter( selector ) ); }; } // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413) if ( $( "" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) { $.fn.removeData = (function( removeData ) { return function( key ) { if ( arguments.length ) { return removeData.call( this, $.camelCase( key ) ); } else { return removeData.call( this ); } }; })( $.fn.removeData ); } // deprecated $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); $.support.selectstart = "onselectstart" in document.createElement( "div" ); $.fn.extend({ disableSelection: function() { return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) + ".ui-disableSelection", function( event ) { event.preventDefault(); }); }, enableSelection: function() { return this.unbind( ".ui-disableSelection" ); } }); $.extend( $.ui, { // $.ui.plugin is deprecated. Use the proxy pattern instead. plugin: { add: function( module, option, set ) { var i, proto = $.ui[ module ].prototype; for ( i in set ) { proto.plugins[ i ] = proto.plugins[ i ] || []; proto.plugins[ i ].push( [ option, set[ i ] ] ); } }, call: function( instance, name, args ) { var i, set = instance.plugins[ name ]; if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) { return; } for ( i = 0; i < set.length; i++ ) { if ( instance.options[ set[ i ][ 0 ] ] ) { set[ i ][ 1 ].apply( instance.element, args ); } } } }, // only used by resizable hasScroll: function( el, a ) { //If overflow is hidden, the element might have extra content, but the user wants to hide it if ( $( el ).css( "overflow" ) === "hidden") { return false; } var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop", has = false; if ( el[ scroll ] > 0 ) { return true; } // TODO: determine which cases actually cause this to happen // if the element doesn't have the scroll set, see if it's possible to // set the scroll el[ scroll ] = 1; has = ( el[ scroll ] > 0 ); el[ scroll ] = 0; return has; } }); })( jQuery ); /*! * jQuery UI Widget 1.10.2 * http://jqueryui.com * * Copyright 2013 jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license * * http://api.jqueryui.com/jQuery.widget/ */ (function( $, undefined ) { var uuid = 0, slice = Array.prototype.slice, _cleanData = $.cleanData; $.cleanData = function( elems ) { for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { try { $( elem ).triggerHandler( "remove" ); // http://bugs.jquery.com/ticket/8235 } catch( e ) {} } _cleanData( elems ); }; $.widget = function( name, base, prototype ) { var fullName, existingConstructor, constructor, basePrototype, // proxiedPrototype allows the provided prototype to remain unmodified // so that it can be used as a mixin for multiple widgets (#8876) proxiedPrototype = {}, namespace = name.split( "." )[ 0 ]; name = name.split( "." )[ 1 ]; fullName = namespace + "-" + name; if ( !prototype ) { prototype = base; base = $.Widget; } // create selector for plugin $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { return !!$.data( elem, fullName ); }; $[ namespace ] = $[ namespace ] || {}; existingConstructor = $[ namespace ][ name ]; constructor = $[ namespace ][ name ] = function( options, element ) { // allow instantiation without "new" keyword if ( !this._createWidget ) { return new constructor( options, element ); } // allow instantiation without initializing for simple inheritance // must use "new" keyword (the code above always passes args) if ( arguments.length ) { this._createWidget( options, element ); } }; // extend with the existing constructor to carry over any static properties $.extend( constructor, existingConstructor, { version: prototype.version, // copy the object used to create the prototype in case we need to // redefine the widget later _proto: $.extend( {}, prototype ), // track widgets that inherit from this widget in case this widget is // redefined after a widget inherits from it _childConstructors: [] }); basePrototype = new base(); // we need to make the options hash a property directly on the new instance // otherwise we'll modify the options hash on the prototype that we're // inheriting from basePrototype.options = $.widget.extend( {}, basePrototype.options ); $.each( prototype, function( prop, value ) { if ( !$.isFunction( value ) ) { proxiedPrototype[ prop ] = value; return; } proxiedPrototype[ prop ] = (function() { var _super = function() { return base.prototype[ prop ].apply( this, arguments ); }, _superApply = function( args ) { return base.prototype[ prop ].apply( this, args ); }; return function() { var __super = this._super, __superApply = this._superApply, returnValue; this._super = _super; this._superApply = _superApply; returnValue = value.apply( this, arguments ); this._super = __super; this._superApply = __superApply; return returnValue; }; })(); }); constructor.prototype = $.widget.extend( basePrototype, { // TODO: remove support for widgetEventPrefix // always use the name + a colon as the prefix, e.g., draggable:start // don't prefix for widgets that aren't DOM-based widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name }, proxiedPrototype, { constructor: constructor, namespace: namespace, widgetName: name, widgetFullName: fullName }); // If this widget is being redefined then we need to find all widgets that // are inheriting from it and redefine all of them so that they inherit from // the new version of this widget. We're essentially trying to replace one // level in the prototype chain. if ( existingConstructor ) { $.each( existingConstructor._childConstructors, function( i, child ) { var childPrototype = child.prototype; // redefine the child widget using the same prototype that was // originally used, but inherit from the new version of the base $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto ); }); // remove the list of existing child constructors from the old constructor // so the old child constructors can be garbage collected delete existingConstructor._childConstructors; } else { base._childConstructors.push( constructor ); } $.widget.bridge( name, constructor ); }; $.widget.extend = function( target ) { var input = slice.call( arguments, 1 ), inputIndex = 0, inputLength = input.length, key, value; for ( ; inputIndex < inputLength; inputIndex++ ) { for ( key in input[ inputIndex ] ) { value = input[ inputIndex ][ key ]; if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { // Clone objects if ( $.isPlainObject( value ) ) { target[ key ] = $.isPlainObject( target[ key ] ) ? $.widget.extend( {}, target[ key ], value ) : // Don't extend strings, arrays, etc. with objects $.widget.extend( {}, value ); // Copy everything else by reference } else { target[ key ] = value; } } } } return target; }; $.widget.bridge = function( name, object ) { var fullName = object.prototype.widgetFullName || name; $.fn[ name ] = function( options ) { var isMethodCall = typeof options === "string", args = slice.call( arguments, 1 ), returnValue = this; // allow multiple hashes to be passed on init options = !isMethodCall && args.length ? $.widget.extend.apply( null, [ options ].concat(args) ) : options; if ( isMethodCall ) { this.each(function() { var methodValue, instance = $.data( this, fullName ); if ( !instance ) { return $.error( "cannot call methods on " + name + " prior to initialization; " + "attempted to call method '" + options + "'" ); } if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) { return $.error( "no such method '" + options + "' for " + name + " widget instance" ); } methodValue = instance[ options ].apply( instance, args ); if ( methodValue !== instance && methodValue !== undefined ) { returnValue = methodValue && methodValue.jquery ? returnValue.pushStack( methodValue.get() ) : methodValue; return false; } }); } else { this.each(function() { var instance = $.data( this, fullName ); if ( instance ) { instance.option( options || {} )._init(); } else { $.data( this, fullName, new object( options, this ) ); } }); } return returnValue; }; }; $.Widget = function( /* options, element */ ) {}; $.Widget._childConstructors = []; $.Widget.prototype = { widgetName: "widget", widgetEventPrefix: "", defaultElement: "
", options: { disabled: false, // callbacks create: null }, _createWidget: function( options, element ) { element = $( element || this.defaultElement || this )[ 0 ]; this.element = $( element ); this.uuid = uuid++; this.eventNamespace = "." + this.widgetName + this.uuid; this.options = $.widget.extend( {}, this.options, this._getCreateOptions(), options ); this.bindings = $(); this.hoverable = $(); this.focusable = $(); if ( element !== this ) { $.data( element, this.widgetFullName, this ); this._on( true, this.element, { remove: function( event ) { if ( event.target === element ) { this.destroy(); } } }); this.document = $( element.style ? // element within the document element.ownerDocument : // element is window or document element.document || element ); this.window = $( this.document[0].defaultView || this.document[0].parentWindow ); } this._create(); this._trigger( "create", null, this._getCreateEventData() ); this._init(); }, _getCreateOptions: $.noop, _getCreateEventData: $.noop, _create: $.noop, _init: $.noop, destroy: function() { this._destroy(); // we can probably remove the unbind calls in 2.0 // all event bindings should go through this._on() this.element .unbind( this.eventNamespace ) // 1.9 BC for #7810 // TODO remove dual storage .removeData( this.widgetName ) .removeData( this.widgetFullName ) // support: jquery <1.6.3 // http://bugs.jquery.com/ticket/9413 .removeData( $.camelCase( this.widgetFullName ) ); this.widget() .unbind( this.eventNamespace ) .removeAttr( "aria-disabled" ) .removeClass( this.widgetFullName + "-disabled " + "ui-state-disabled" ); // clean up events and states this.bindings.unbind( this.eventNamespace ); this.hoverable.removeClass( "ui-state-hover" ); this.focusable.removeClass( "ui-state-focus" ); }, _destroy: $.noop, widget: function() { return this.element; }, option: function( key, value ) { var options = key, parts, curOption, i; if ( arguments.length === 0 ) { // don't return a reference to the internal hash return $.widget.extend( {}, this.options ); } if ( typeof key === "string" ) { // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } options = {}; parts = key.split( "." ); key = parts.shift(); if ( parts.length ) { curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); for ( i = 0; i < parts.length - 1; i++ ) { curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; curOption = curOption[ parts[ i ] ]; } key = parts.pop(); if ( value === undefined ) { return curOption[ key ] === undefined ? null : curOption[ key ]; } curOption[ key ] = value; } else { if ( value === undefined ) { return this.options[ key ] === undefined ? null : this.options[ key ]; } options[ key ] = value; } } this._setOptions( options ); return this; }, _setOptions: function( options ) { var key; for ( key in options ) { this._setOption( key, options[ key ] ); } return this; }, _setOption: function( key, value ) { this.options[ key ] = value; if ( key === "disabled" ) { this.widget() .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value ) .attr( "aria-disabled", value ); this.hoverable.removeClass( "ui-state-hover" ); this.focusable.removeClass( "ui-state-focus" ); } return this; }, enable: function() { return this._setOption( "disabled", false ); }, disable: function() { return this._setOption( "disabled", true ); }, _on: function( suppressDisabledCheck, element, handlers ) { var delegateElement, instance = this; // no suppressDisabledCheck flag, shuffle arguments if ( typeof suppressDisabledCheck !== "boolean" ) { handlers = element; element = suppressDisabledCheck; suppressDisabledCheck = false; } // no element argument, shuffle and use this.element if ( !handlers ) { handlers = element; element = this.element; delegateElement = this.widget(); } else { // accept selectors, DOM elements element = delegateElement = $( element ); this.bindings = this.bindings.add( element ); } $.each( handlers, function( event, handler ) { function handlerProxy() { // allow widgets to customize the disabled handling // - disabled as an array instead of boolean // - disabled class as method for disabling individual parts if ( !suppressDisabledCheck && ( instance.options.disabled === true || $( this ).hasClass( "ui-state-disabled" ) ) ) { return; } return ( typeof handler === "string" ? instance[ handler ] : handler ) .apply( instance, arguments ); } // copy the guid so direct unbinding works if ( typeof handler !== "string" ) { handlerProxy.guid = handler.guid = handler.guid || handlerProxy.guid || $.guid++; } var match = event.match( /^(\w+)\s*(.*)$/ ), eventName = match[1] + instance.eventNamespace, selector = match[2]; if ( selector ) { delegateElement.delegate( selector, eventName, handlerProxy ); } else { element.bind( eventName, handlerProxy ); } }); }, _off: function( element, eventName ) { eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace; element.unbind( eventName ).undelegate( eventName ); }, _delay: function( handler, delay ) { function handlerProxy() { return ( typeof handler === "string" ? instance[ handler ] : handler ) .apply( instance, arguments ); } var instance = this; return setTimeout( handlerProxy, delay || 0 ); }, _hoverable: function( element ) { this.hoverable = this.hoverable.add( element ); this._on( element, { mouseenter: function( event ) { $( event.currentTarget ).addClass( "ui-state-hover" ); }, mouseleave: function( event ) { $( event.currentTarget ).removeClass( "ui-state-hover" ); } }); }, _focusable: function( element ) { this.focusable = this.focusable.add( element ); this._on( element, { focusin: function( event ) { $( event.currentTarget ).addClass( "ui-state-focus" ); }, focusout: function( event ) { $( event.currentTarget ).removeClass( "ui-state-focus" ); } }); }, _trigger: function( type, event, data ) { var prop, orig, callback = this.options[ type ]; data = data || {}; event = $.Event( event ); event.type = ( type === this.widgetEventPrefix ? type : this.widgetEventPrefix + type ).toLowerCase(); // the original event may come from any element // so we need to reset the target on the new event event.target = this.element[ 0 ]; // copy original event properties over to the new event orig = event.originalEvent; if ( orig ) { for ( prop in orig ) { if ( !( prop in event ) ) { event[ prop ] = orig[ prop ]; } } } this.element.trigger( event, data ); return !( $.isFunction( callback ) && callback.apply( this.element[0], [ event ].concat( data ) ) === false || event.isDefaultPrevented() ); } }; $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { if ( typeof options === "string" ) { options = { effect: options }; } var hasOptions, effectName = !options ? method : options === true || typeof options === "number" ? defaultEffect : options.effect || defaultEffect; options = options || {}; if ( typeof options === "number" ) { options = { duration: options }; } hasOptions = !$.isEmptyObject( options ); options.complete = callback; if ( options.delay ) { element.delay( options.delay ); } if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { element[ method ]( options ); } else if ( effectName !== method && element[ effectName ] ) { element[ effectName ]( options.duration, options.easing, callback ); } else { element.queue(function( next ) { $( this )[ method ](); if ( callback ) { callback.call( element[ 0 ] ); } next(); }); } }; }); })( jQuery ); /*! * jQuery UI Mouse 1.10.2 * http://jqueryui.com * * Copyright 2013 jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license * * http://api.jqueryui.com/mouse/ * * Depends: * jquery.ui.widget.js */ (function( $, undefined ) { var mouseHandled = false; $( document ).mouseup( function() { mouseHandled = false; }); $.widget("ui.mouse", { version: "1.10.2", options: { cancel: "input,textarea,button,select,option", distance: 1, delay: 0 }, _mouseInit: function() { var that = this; this.element .bind("mousedown."+this.widgetName, function(event) { return that._mouseDown(event); }) .bind("click."+this.widgetName, function(event) { if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) { $.removeData(event.target, that.widgetName + ".preventClickEvent"); event.stopImmediatePropagation(); return false; } }); this.started = false; }, // TODO: make sure destroying one instance of mouse doesn't mess with // other instances of mouse _mouseDestroy: function() { this.element.unbind("."+this.widgetName); if ( this._mouseMoveDelegate ) { $(document) .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate) .unbind("mouseup."+this.widgetName, this._mouseUpDelegate); } }, _mouseDown: function(event) { // don't let more than one widget handle mouseStart if( mouseHandled ) { return; } // we may have missed mouseup (out of window) (this._mouseStarted && this._mouseUp(event)); this._mouseDownEvent = event; var that = this, btnIsLeft = (event.which === 1), // event.target.nodeName works around a bug in IE 8 with // disabled inputs (#7620) elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false); if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { return true; } this.mouseDelayMet = !this.options.delay; if (!this.mouseDelayMet) { this._mouseDelayTimer = setTimeout(function() { that.mouseDelayMet = true; }, this.options.delay); } if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { this._mouseStarted = (this._mouseStart(event) !== false); if (!this._mouseStarted) { event.preventDefault(); return true; } } // Click event may never have fired (Gecko & Opera) if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) { $.removeData(event.target, this.widgetName + ".preventClickEvent"); } // these delegates are required to keep context this._mouseMoveDelegate = function(event) { return that._mouseMove(event); }; this._mouseUpDelegate = function(event) { return that._mouseUp(event); }; $(document) .bind("mousemove."+this.widgetName, this._mouseMoveDelegate) .bind("mouseup."+this.widgetName, this._mouseUpDelegate); event.preventDefault(); mouseHandled = true; return true; }, _mouseMove: function(event) { // IE mouseup check - mouseup happened when mouse was out of window if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) { return this._mouseUp(event); } if (this._mouseStarted) { this._mouseDrag(event); return event.preventDefault(); } if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) { this._mouseStarted = (this._mouseStart(this._mouseDownEvent, event) !== false); (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event)); } return !this._mouseStarted; }, _mouseUp: function(event) { $(document) .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate) .unbind("mouseup."+this.widgetName, this._mouseUpDelegate); if (this._mouseStarted) { this._mouseStarted = false; if (event.target === this._mouseDownEvent.target) { $.data(event.target, this.widgetName + ".preventClickEvent", true); } this._mouseStop(event); } return false; }, _mouseDistanceMet: function(event) { return (Math.max( Math.abs(this._mouseDownEvent.pageX - event.pageX), Math.abs(this._mouseDownEvent.pageY - event.pageY) ) >= this.options.distance ); }, _mouseDelayMet: function(/* event */) { return this.mouseDelayMet; }, // These are placeholder methods, to be overriden by extending plugin _mouseStart: function(/* event */) {}, _mouseDrag: function(/* event */) {}, _mouseStop: function(/* event */) {}, _mouseCapture: function(/* event */) { return true; } }); })(jQuery); /*! * jQuery UI Sortable 1.10.2 * http://jqueryui.com * * Copyright 2013 jQuery Foundation and other contributors * Released under the MIT license. * http://jquery.org/license * * http://api.jqueryui.com/sortable/ * * Depends: * jquery.ui.core.js * jquery.ui.mouse.js * jquery.ui.widget.js */ (function( $, undefined ) { /*jshint loopfunc: true */ function isOverAxis( x, reference, size ) { return ( x > reference ) && ( x < ( reference + size ) ); } function isFloating(item) { return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display")); } $.widget("ui.sortable", $.ui.mouse, { version: "1.10.2", widgetEventPrefix: "sort", ready: false, options: { appendTo: "parent", axis: false, connectWith: false, containment: false, cursor: "auto", cursorAt: false, dropOnEmpty: true, forcePlaceholderSize: false, forceHelperSize: false, grid: false, handle: false, helper: "original", items: "> *", opacity: false, placeholder: false, revert: false, scroll: true, scrollSensitivity: 20, scrollSpeed: 20, scope: "default", tolerance: "intersect", zIndex: 1000, // callbacks activate: null, beforeStop: null, change: null, deactivate: null, out: null, over: null, receive: null, remove: null, sort: null, start: null, stop: null, update: null }, _create: function() { var o = this.options; this.containerCache = {}; this.element.addClass("ui-sortable"); //Get the items this.refresh(); //Let's determine if the items are being displayed horizontally this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false; //Let's determine the parent's offset this.offset = this.element.offset(); //Initialize mouse events for interaction this._mouseInit(); //We're ready to go this.ready = true; }, _destroy: function() { this.element .removeClass("ui-sortable ui-sortable-disabled"); this._mouseDestroy(); for ( var i = this.items.length - 1; i >= 0; i-- ) { this.items[i].item.removeData(this.widgetName + "-item"); } return this; }, _setOption: function(key, value){ if ( key === "disabled" ) { this.options[ key ] = value; this.widget().toggleClass( "ui-sortable-disabled", !!value ); } else { // Don't call widget base _setOption for disable as it adds ui-state-disabled class $.Widget.prototype._setOption.apply(this, arguments); } }, _mouseCapture: function(event, overrideHandle) { var currentItem = null, validHandle = false, that = this; if (this.reverting) { return false; } if(this.options.disabled || this.options.type === "static") { return false; } //We have to refresh the items data once first this._refreshItems(event); //Find out if the clicked node (or one of its parents) is a actual item in this.items $(event.target).parents().each(function() { if($.data(this, that.widgetName + "-item") === that) { currentItem = $(this); return false; } }); if($.data(event.target, that.widgetName + "-item") === that) { currentItem = $(event.target); } if(!currentItem) { return false; } if(this.options.handle && !overrideHandle) { $(this.options.handle, currentItem).find("*").addBack().each(function() { if(this === event.target) { validHandle = true; } }); if(!validHandle) { return false; } } this.currentItem = currentItem; this._removeCurrentsFromItems(); return true; }, _mouseStart: function(event, overrideHandle, noActivation) { var i, body, o = this.options; this.currentContainer = this; //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture this.refreshPositions(); //Create and append the visible helper this.helper = this._createHelper(event); //Cache the helper size this._cacheHelperProportions(); /* * - Position generation - * This block generates everything position related - it's the core of draggables. */ //Cache the margins of the original element this._cacheMargins(); //Get the next scrolling parent this.scrollParent = this.helper.scrollParent(); //The element's absolute position on the page minus margins this.offset = this.currentItem.offset(); this.offset = { top: this.offset.top - this.margins.top, left: this.offset.left - this.margins.left }; $.extend(this.offset, { click: { //Where the click happened, relative to the element left: event.pageX - this.offset.left, top: event.pageY - this.offset.top }, parent: this._getParentOffset(), relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper }); // Only after we got the offset, we can change the helper's position to absolute // TODO: Still need to figure out a way to make relative sorting possible this.helper.css("position", "absolute"); this.cssPosition = this.helper.css("position"); //Generate the original position this.originalPosition = this._generatePosition(event); this.originalPageX = event.pageX; this.originalPageY = event.pageY; //Adjust the mouse offset relative to the helper if "cursorAt" is supplied (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); //Cache the former DOM position this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] }; //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way if(this.helper[0] !== this.currentItem[0]) { this.currentItem.hide(); } //Create the placeholder this._createPlaceholder(); //Set a containment if given in the options if(o.containment) { this._setContainment(); } if( o.cursor && o.cursor !== "auto" ) { // cursor option body = this.document.find( "body" ); // support: IE this.storedCursor = body.css( "cursor" ); body.css( "cursor", o.cursor ); this.storedStylesheet = $( "" ).appendTo( body ); } if(o.opacity) { // opacity option if (this.helper.css("opacity")) { this._storedOpacity = this.helper.css("opacity"); } this.helper.css("opacity", o.opacity); } if(o.zIndex) { // zIndex option if (this.helper.css("zIndex")) { this._storedZIndex = this.helper.css("zIndex"); } this.helper.css("zIndex", o.zIndex); } //Prepare scrolling if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") { this.overflowOffset = this.scrollParent.offset(); } //Call callbacks this._trigger("start", event, this._uiHash()); //Recache the helper size if(!this._preserveHelperProportions) { this._cacheHelperProportions(); } //Post "activate" events to possible containers if( !noActivation ) { for ( i = this.containers.length - 1; i >= 0; i-- ) { this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) ); } } //Prepare possible droppables if($.ui.ddmanager) { $.ui.ddmanager.current = this; } if ($.ui.ddmanager && !o.dropBehaviour) { $.ui.ddmanager.prepareOffsets(this, event); } this.dragging = true; this.helper.addClass("ui-sortable-helper"); this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position return true; }, _mouseDrag: function(event) { var i, item, itemElement, intersection, o = this.options, scrolled = false; //Compute the helpers position this.position = this._generatePosition(event); this.positionAbs = this._convertPositionTo("absolute"); if (!this.lastPositionAbs) { this.lastPositionAbs = this.positionAbs; } //Do scrolling if(this.options.scroll) { if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") { if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) { this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed; } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) { this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed; } if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) { this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed; } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) { this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed; } } else { if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) { scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) { scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); } if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) { scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) { scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); } } if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) { $.ui.ddmanager.prepareOffsets(this, event); } } //Regenerate the absolute position used for position checks this.positionAbs = this._convertPositionTo("absolute"); //Set the helper position if(!this.options.axis || this.options.axis !== "y") { this.helper[0].style.left = this.position.left+"px"; } if(!this.options.axis || this.options.axis !== "x") { this.helper[0].style.top = this.position.top+"px"; } //Rearrange for (i = this.items.length - 1; i >= 0; i--) { //Cache variables and intersection, continue if no intersection item = this.items[i]; itemElement = item.item[0]; intersection = this._intersectsWithPointer(item); if (!intersection) { continue; } // Only put the placeholder inside the current Container, skip all // items form other containers. This works because when moving // an item from one container to another the // currentContainer is switched before the placeholder is moved. // // Without this moving items in "sub-sortables" can cause the placeholder to jitter // beetween the outer and inner container. if (item.instance !== this.currentContainer) { continue; } // cannot intersect with itself // no useless actions that have been done before // no action if the item moved is the parent of the item checked if (itemElement !== this.currentItem[0] && this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement && !$.contains(this.placeholder[0], itemElement) && (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true) ) { this.direction = intersection === 1 ? "down" : "up"; if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) { this._rearrange(event, item); } else { break; } this._trigger("change", event, this._uiHash()); break; } } //Post events to containers this._contactContainers(event); //Interconnect with droppables if($.ui.ddmanager) { $.ui.ddmanager.drag(this, event); } //Call callbacks this._trigger("sort", event, this._uiHash()); this.lastPositionAbs = this.positionAbs; return false; }, _mouseStop: function(event, noPropagation) { if(!event) { return; } //If we are using droppables, inform the manager about the drop if ($.ui.ddmanager && !this.options.dropBehaviour) { $.ui.ddmanager.drop(this, event); } if(this.options.revert) { var that = this, cur = this.placeholder.offset(), axis = this.options.axis, animation = {}; if ( !axis || axis === "x" ) { animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft); } if ( !axis || axis === "y" ) { animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop); } this.reverting = true; $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() { that._clear(event); }); } else { this._clear(event, noPropagation); } return false; }, cancel: function() { if(this.dragging) { this._mouseUp({ target: null }); if(this.options.helper === "original") { this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); } else { this.currentItem.show(); } //Post deactivating events to containers for (var i = this.containers.length - 1; i >= 0; i--){ this.containers[i]._trigger("deactivate", null, this._uiHash(this)); if(this.containers[i].containerCache.over) { this.containers[i]._trigger("out", null, this._uiHash(this)); this.containers[i].containerCache.over = 0; } } } if (this.placeholder) { //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! if(this.placeholder[0].parentNode) { this.placeholder[0].parentNode.removeChild(this.placeholder[0]); } if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) { this.helper.remove(); } $.extend(this, { helper: null, dragging: false, reverting: false, _noFinalSort: null }); if(this.domPosition.prev) { $(this.domPosition.prev).after(this.currentItem); } else { $(this.domPosition.parent).prepend(this.currentItem); } } return this; }, serialize: function(o) { var items = this._getItemsAsjQuery(o && o.connected), str = []; o = o || {}; $(items).each(function() { var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/)); if (res) { str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2])); } }); if(!str.length && o.key) { str.push(o.key + "="); } return str.join("&"); }, toArray: function(o) { var items = this._getItemsAsjQuery(o && o.connected), ret = []; o = o || {}; items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); }); return ret; }, /* Be careful with the following core functions */ _intersectsWith: function(item) { var x1 = this.positionAbs.left, x2 = x1 + this.helperProportions.width, y1 = this.positionAbs.top, y2 = y1 + this.helperProportions.height, l = item.left, r = l + item.width, t = item.top, b = t + item.height, dyClick = this.offset.click.top, dxClick = this.offset.click.left, isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r; if ( this.options.tolerance === "pointer" || this.options.forcePointerForContainers || (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"]) ) { return isOverElement; } else { return (l < x1 + (this.helperProportions.width / 2) && // Right Half x2 - (this.helperProportions.width / 2) < r && // Left Half t < y1 + (this.helperProportions.height / 2) && // Bottom Half y2 - (this.helperProportions.height / 2) < b ); // Top Half } }, _intersectsWithPointer: function(item) { var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height), isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width), isOverElement = isOverElementHeight && isOverElementWidth, verticalDirection = this._getDragVerticalDirection(), horizontalDirection = this._getDragHorizontalDirection(); if (!isOverElement) { return false; } return this.floating ? ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 ) : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) ); }, _intersectsWithSides: function(item) { var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height), isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width), verticalDirection = this._getDragVerticalDirection(), horizontalDirection = this._getDragHorizontalDirection(); if (this.floating && horizontalDirection) { return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf)); } else { return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf)); } }, _getDragVerticalDirection: function() { var delta = this.positionAbs.top - this.lastPositionAbs.top; return delta !== 0 && (delta > 0 ? "down" : "up"); }, _getDragHorizontalDirection: function() { var delta = this.positionAbs.left - this.lastPositionAbs.left; return delta !== 0 && (delta > 0 ? "right" : "left"); }, refresh: function(event) { this._refreshItems(event); this.refreshPositions(); return this; }, _connectWith: function() { var options = this.options; return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith; }, _getItemsAsjQuery: function(connected) { var i, j, cur, inst, items = [], queries = [], connectWith = this._connectWith(); if(connectWith && connected) { for (i = connectWith.length - 1; i >= 0; i--){ cur = $(connectWith[i]); for ( j = cur.length - 1; j >= 0; j--){ inst = $.data(cur[j], this.widgetFullName); if(inst && inst !== this && !inst.options.disabled) { queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]); } } } } queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]); for (i = queries.length - 1; i >= 0; i--){ queries[i][0].each(function() { items.push(this); }); } return $(items); }, _removeCurrentsFromItems: function() { var list = this.currentItem.find(":data(" + this.widgetName + "-item)"); this.items = $.grep(this.items, function (item) { for (var j=0; j < list.length; j++) { if(list[j] === item.item[0]) { return false; } } return true; }); }, _refreshItems: function(event) { this.items = []; this.containers = [this]; var i, j, cur, inst, targetData, _queries, item, queriesLength, items = this.items, queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]], connectWith = this._connectWith(); if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down for (i = connectWith.length - 1; i >= 0; i--){ cur = $(connectWith[i]); for (j = cur.length - 1; j >= 0; j--){ inst = $.data(cur[j], this.widgetFullName); if(inst && inst !== this && !inst.options.disabled) { queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]); this.containers.push(inst); } } } } for (i = queries.length - 1; i >= 0; i--) { targetData = queries[i][1]; _queries = queries[i][0]; for (j=0, queriesLength = _queries.length; j < queriesLength; j++) { item = $(_queries[j]); item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager) items.push({ item: item, instance: targetData, width: 0, height: 0, left: 0, top: 0 }); } } }, refreshPositions: function(fast) { //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change if(this.offsetParent && this.helper) { this.offset.parent = this._getParentOffset(); } var i, item, t, p; for (i = this.items.length - 1; i >= 0; i--){ item = this.items[i]; //We ignore calculating positions of all connected containers when we're not over them if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) { continue; } t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item; if (!fast) { item.width = t.outerWidth(); item.height = t.outerHeight(); } p = t.offset(); item.left = p.left; item.top = p.top; } if(this.options.custom && this.options.custom.refreshContainers) { this.options.custom.refreshContainers.call(this); } else { for (i = this.containers.length - 1; i >= 0; i--){ p = this.containers[i].element.offset(); this.containers[i].containerCache.left = p.left; this.containers[i].containerCache.top = p.top; this.containers[i].containerCache.width = this.containers[i].element.outerWidth(); this.containers[i].containerCache.height = this.containers[i].element.outerHeight(); } } return this; }, _createPlaceholder: function(that) { that = that || this; var className, o = that.options; if(!o.placeholder || o.placeholder.constructor === String) { className = o.placeholder; o.placeholder = { element: function() { var nodeName = that.currentItem[0].nodeName.toLowerCase(), element = $( that.document[0].createElement( nodeName ) ) .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder") .removeClass("ui-sortable-helper"); if ( nodeName === "tr" ) { // Use a high colspan to force the td to expand the full // width of the table (browsers are smart enough to // handle this properly) element.append( " " ); } else if ( nodeName === "img" ) { element.attr( "src", that.currentItem.attr( "src" ) ); } if ( !className ) { element.css( "visibility", "hidden" ); } return element; }, update: function(container, p) { // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified if(className && !o.forcePlaceholderSize) { return; } //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); } if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); } } }; } //Create the placeholder that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem)); //Append it after the actual current item that.currentItem.after(that.placeholder); //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317) o.placeholder.update(that, that.placeholder); }, _contactContainers: function(event) { var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating, innermostContainer = null, innermostIndex = null; // get innermost container that intersects with item for (i = this.containers.length - 1; i >= 0; i--) { // never consider a container that's located within the item itself if($.contains(this.currentItem[0], this.containers[i].element[0])) { continue; } if(this._intersectsWith(this.containers[i].containerCache)) { // if we've already found a container and it's more "inner" than this, then continue if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) { continue; } innermostContainer = this.containers[i]; innermostIndex = i; } else { // container doesn't intersect. trigger "out" event if necessary if(this.containers[i].containerCache.over) { this.containers[i]._trigger("out", event, this._uiHash(this)); this.containers[i].containerCache.over = 0; } } } // if no intersecting containers found, return if(!innermostContainer) { return; } // move the item into the container if it's not there already if(this.containers.length === 1) { if (!this.containers[innermostIndex].containerCache.over) { this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); this.containers[innermostIndex].containerCache.over = 1; } } else { //When entering a new container, we will find the item with the least distance and append our item near it dist = 10000; itemWithLeastDistance = null; floating = innermostContainer.floating || isFloating(this.currentItem); posProperty = floating ? "left" : "top"; sizeProperty = floating ? "width" : "height"; base = this.positionAbs[posProperty] + this.offset.click[posProperty]; for (j = this.items.length - 1; j >= 0; j--) { if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) { continue; } if(this.items[j].item[0] === this.currentItem[0]) { continue; } if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) { continue; } cur = this.items[j].item.offset()[posProperty]; nearBottom = false; if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){ nearBottom = true; cur += this.items[j][sizeProperty]; } if(Math.abs(cur - base) < dist) { dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j]; this.direction = nearBottom ? "up": "down"; } } //Check if dropOnEmpty is enabled if(!itemWithLeastDistance && !this.options.dropOnEmpty) { return; } if(this.currentContainer === this.containers[innermostIndex]) { return; } itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true); this._trigger("change", event, this._uiHash()); this.containers[innermostIndex]._trigger("change", event, this._uiHash(this)); this.currentContainer = this.containers[innermostIndex]; //Update the placeholder this.options.placeholder.update(this.currentContainer, this.placeholder); this.containers[innermostIndex]._trigger("over", event, this._uiHash(this)); this.containers[innermostIndex].containerCache.over = 1; } }, _createHelper: function(event) { var o = this.options, helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem); //Add the helper to the DOM if that didn't happen already if(!helper.parents("body").length) { $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]); } if(helper[0] === this.currentItem[0]) { this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") }; } if(!helper[0].style.width || o.forceHelperSize) { helper.width(this.currentItem.width()); } if(!helper[0].style.height || o.forceHelperSize) { helper.height(this.currentItem.height()); } return helper; }, _adjustOffsetFromHelper: function(obj) { if (typeof obj === "string") { obj = obj.split(" "); } if ($.isArray(obj)) { obj = {left: +obj[0], top: +obj[1] || 0}; } if ("left" in obj) { this.offset.click.left = obj.left + this.margins.left; } if ("right" in obj) { this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; } if ("top" in obj) { this.offset.click.top = obj.top + this.margins.top; } if ("bottom" in obj) { this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top; } }, _getParentOffset: function() { //Get the offsetParent and cache its position this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); // This is a special case where we need to modify a offset calculated on start, since the following happened: // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) { po.left += this.scrollParent.scrollLeft(); po.top += this.scrollParent.scrollTop(); } // This needs to be actually done for all browsers, since pageX/pageY includes this information // with an ugly IE fix if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) { po = { top: 0, left: 0 }; } return { top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0), left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0) }; }, _getRelativeOffset: function() { if(this.cssPosition === "relative") { var p = this.currentItem.position(); return { top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(), left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft() }; } else { return { top: 0, left: 0 }; } }, _cacheMargins: function() { this.margins = { left: (parseInt(this.currentItem.css("marginLeft"),10) || 0), top: (parseInt(this.currentItem.css("marginTop"),10) || 0) }; }, _cacheHelperProportions: function() { this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() }; }, _setContainment: function() { var ce, co, over, o = this.options; if(o.containment === "parent") { o.containment = this.helper[0].parentNode; } if(o.containment === "document" || o.containment === "window") { this.containment = [ 0 - this.offset.relative.left - this.offset.parent.left, 0 - this.offset.relative.top - this.offset.parent.top, $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left, ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top ]; } if(!(/^(document|window|parent)$/).test(o.containment)) { ce = $(o.containment)[0]; co = $(o.containment).offset(); over = ($(ce).css("overflow") !== "hidden"); this.containment = [ co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left, co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top, co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left, co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top ]; } }, _convertPositionTo: function(d, pos) { if(!pos) { pos = this.position; } var mod = d === "absolute" ? 1 : -1, scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); return { top: ( pos.top + // The absolute mouse position this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border) ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) ), left: ( pos.left + // The absolute mouse position this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border) ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) ) }; }, _generatePosition: function(event) { var top, left, o = this.options, pageX = event.pageX, pageY = event.pageY, scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName); // This is another very weird special case that only happens for relative elements: // 1. If the css position is relative // 2. and the scroll parent is the document or similar to the offset parent // we have to refresh the relative offset during the scroll so there are no jumps if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) { this.offset.relative = this._getRelativeOffset(); } /* * - Position constraining - * Constrain the position to a mix of grid, containment. */ if(this.originalPosition) { //If we are not dragging yet, we won't check for options if(this.containment) { if(event.pageX - this.offset.click.left < this.containment[0]) { pageX = this.containment[0] + this.offset.click.left; } if(event.pageY - this.offset.click.top < this.containment[1]) { pageY = this.containment[1] + this.offset.click.top; } if(event.pageX - this.offset.click.left > this.containment[2]) { pageX = this.containment[2] + this.offset.click.left; } if(event.pageY - this.offset.click.top > this.containment[3]) { pageY = this.containment[3] + this.offset.click.top; } } if(o.grid) { top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; } } return { top: ( pageY - // The absolute mouse position this.offset.click.top - // Click offset (relative to the element) this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent this.offset.parent.top + // The offsetParent's offset without borders (offset + border) ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) ), left: ( pageX - // The absolute mouse position this.offset.click.left - // Click offset (relative to the element) this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent this.offset.parent.left + // The offsetParent's offset without borders (offset + border) ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) ) }; }, _rearrange: function(event, i, a, hardRefresh) { a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling)); //Various things done here to improve the performance: // 1. we create a setTimeout, that calls refreshPositions // 2. on the instance, we have a counter variable, that get's higher after every append // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same // 4. this lets only the last addition to the timeout stack through this.counter = this.counter ? ++this.counter : 1; var counter = this.counter; this._delay(function() { if(counter === this.counter) { this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove } }); }, _clear: function(event, noPropagation) { this.reverting = false; // We delay all events that have to be triggered to after the point where the placeholder has been removed and // everything else normalized again var i, delayedTriggers = []; // We first have to update the dom position of the actual currentItem // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088) if(!this._noFinalSort && this.currentItem.parent().length) { this.placeholder.before(this.currentItem); } this._noFinalSort = null; if(this.helper[0] === this.currentItem[0]) { for(i in this._storedCSS) { if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") { this._storedCSS[i] = ""; } } this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); } else { this.currentItem.show(); } if(this.fromOutside && !noPropagation) { delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); }); } if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) { delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed } // Check if the items Container has Changed and trigger appropriate // events. if (this !== this.currentContainer) { if(!noPropagation) { delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); }); delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer)); delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer)); } } //Post events to containers for (i = this.containers.length - 1; i >= 0; i--){ if(!noPropagation) { delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i])); } if(this.containers[i].containerCache.over) { delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i])); this.containers[i].containerCache.over = 0; } } //Do what was originally in plugins if ( this.storedCursor ) { this.document.find( "body" ).css( "cursor", this.storedCursor ); this.storedStylesheet.remove(); } if(this._storedOpacity) { this.helper.css("opacity", this._storedOpacity); } if(this._storedZIndex) { this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex); } this.dragging = false; if(this.cancelHelperRemoval) { if(!noPropagation) { this._trigger("beforeStop", event, this._uiHash()); for (i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); } //Trigger all delayed events this._trigger("stop", event, this._uiHash()); } this.fromOutside = false; return false; } if(!noPropagation) { this._trigger("beforeStop", event, this._uiHash()); } //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! this.placeholder[0].parentNode.removeChild(this.placeholder[0]); if(this.helper[0] !== this.currentItem[0]) { this.helper.remove(); } this.helper = null; if(!noPropagation) { for (i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); } //Trigger all delayed events this._trigger("stop", event, this._uiHash()); } this.fromOutside = false; return true; }, _trigger: function() { if ($.Widget.prototype._trigger.apply(this, arguments) === false) { this.cancel(); } }, _uiHash: function(_inst) { var inst = _inst || this; return { helper: inst.helper, placeholder: inst.placeholder || $([]), position: inst.position, originalPosition: inst.originalPosition, offset: inst.positionAbs, item: inst.currentItem, sender: _inst ? _inst.element : null }; } }); })(jQuery); /* Copyright (C) 2011 by Yehuda Katz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ // lib/handlebars/browser-prefix.js var Handlebars = {}; (function(Handlebars, undefined) { ; // lib/handlebars/base.js Handlebars.VERSION = "1.0.0-rc.4"; Handlebars.COMPILER_REVISION = 3; Handlebars.REVISION_CHANGES = { 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it 2: '== 1.0.0-rc.3', 3: '>= 1.0.0-rc.4' }; Handlebars.helpers = {}; Handlebars.partials = {}; var toString = Object.prototype.toString, functionType = '[object Function]', objectType = '[object Object]'; Handlebars.registerHelper = function(name, fn, inverse) { if (toString.call(name) === objectType) { if (inverse || fn) { throw new Handlebars.Exception('Arg not supported with multiple helpers'); } Handlebars.Utils.extend(this.helpers, name); } else { if (inverse) { fn.not = inverse; } this.helpers[name] = fn; } }; Handlebars.registerPartial = function(name, str) { if (toString.call(name) === objectType) { Handlebars.Utils.extend(this.partials, name); } else { this.partials[name] = str; } }; Handlebars.registerHelper('helperMissing', function(arg) { if(arguments.length === 2) { return undefined; } else { throw new Error("Could not find property '" + arg + "'"); } }); Handlebars.registerHelper('blockHelperMissing', function(context, options) { var inverse = options.inverse || function() {}, fn = options.fn; var type = toString.call(context); if(type === functionType) { context = context.call(this); } if(context === true) { return fn(this); } else if(context === false || context == null) { return inverse(this); } else if(type === "[object Array]") { if(context.length > 0) { return Handlebars.helpers.each(context, options); } else { return inverse(this); } } else { return fn(context); } }); Handlebars.K = function() {}; Handlebars.createFrame = Object.create || function(object) { Handlebars.K.prototype = object; var obj = new Handlebars.K(); Handlebars.K.prototype = null; return obj; }; Handlebars.logger = { DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3, methodMap: {0: 'debug', 1: 'info', 2: 'warn', 3: 'error'}, // can be overridden in the host environment log: function(level, obj) { if (Handlebars.logger.level <= level) { var method = Handlebars.logger.methodMap[level]; if (typeof console !== 'undefined' && console[method]) { console[method].call(console, obj); } } } }; Handlebars.log = function(level, obj) { Handlebars.logger.log(level, obj); }; Handlebars.registerHelper('each', function(context, options) { var fn = options.fn, inverse = options.inverse; var i = 0, ret = "", data; if (options.data) { data = Handlebars.createFrame(options.data); } if(context && typeof context === 'object') { if(context instanceof Array){ for(var j = context.length; i": ">", '"': """, "'": "'", "`": "`" }; var badChars = /[&<>"'`]/g; var possible = /[&<>"'`]/; var escapeChar = function(chr) { return escape[chr] || "&"; }; Handlebars.Utils = { extend: function(obj, value) { for(var key in value) { if(value.hasOwnProperty(key)) { obj[key] = value[key]; } } }, escapeExpression: function(string) { // don't escape SafeStrings, since they're already safe if (string instanceof Handlebars.SafeString) { return string.toString(); } else if (string == null || string === false) { return ""; } // Force a string conversion as this will be done by the append regardless and // the regex test will do this transparently behind the scenes, causing issues if // an object's to string has escaped characters in it. string = string.toString(); if(!possible.test(string)) { return string; } return string.replace(badChars, escapeChar); }, isEmpty: function(value) { if (!value && value !== 0) { return true; } else if(toString.call(value) === "[object Array]" && value.length === 0) { return true; } else { return false; } } }; ; // lib/handlebars/runtime.js Handlebars.VM = { template: function(templateSpec) { // Just add water var container = { escapeExpression: Handlebars.Utils.escapeExpression, invokePartial: Handlebars.VM.invokePartial, programs: [], program: function(i, fn, data) { var programWrapper = this.programs[i]; if(data) { programWrapper = Handlebars.VM.program(i, fn, data); } else if (!programWrapper) { programWrapper = this.programs[i] = Handlebars.VM.program(i, fn); } return programWrapper; }, programWithDepth: Handlebars.VM.programWithDepth, noop: Handlebars.VM.noop, compilerInfo: null }; return function(context, options) { options = options || {}; var result = templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data); var compilerInfo = container.compilerInfo || [], compilerRevision = compilerInfo[0] || 1, currentRevision = Handlebars.COMPILER_REVISION; if (compilerRevision !== currentRevision) { if (compilerRevision < currentRevision) { var runtimeVersions = Handlebars.REVISION_CHANGES[currentRevision], compilerVersions = Handlebars.REVISION_CHANGES[compilerRevision]; throw "Template was precompiled with an older version of Handlebars than the current runtime. "+ "Please update your precompiler to a newer version ("+runtimeVersions+") or downgrade your runtime to an older version ("+compilerVersions+")."; } else { // Use the embedded version info since the runtime doesn't know about this revision yet throw "Template was precompiled with a newer version of Handlebars than the current runtime. "+ "Please update your runtime to a newer version ("+compilerInfo[1]+")."; } } return result; }; }, programWithDepth: function(i, fn, data /*, $depth */) { var args = Array.prototype.slice.call(arguments, 3); var program = function(context, options) { options = options || {}; return fn.apply(this, [context, options.data || data].concat(args)); }; program.program = i; program.depth = args.length; return program; }, program: function(i, fn, data) { var program = function(context, options) { options = options || {}; return fn(context, options.data || data); }; program.program = i; program.depth = 0; return program; }, noop: function() { return ""; }, invokePartial: function(partial, name, context, helpers, partials, data) { var options = { helpers: helpers, partials: partials, data: data }; if(partial === undefined) { throw new Handlebars.Exception("The partial " + name + " could not be found"); } else if(partial instanceof Function) { return partial(context, options); } else if (!Handlebars.compile) { throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode"); } else { partials[name] = Handlebars.compile(partial, {data: data !== undefined}); return partials[name](context, options); } } }; Handlebars.template = Handlebars.VM.template; ; // lib/handlebars/browser-suffix.js })(Handlebars); ; /*! * jQuery Cookie Plugin v1.3.1 * https://github.com/carhartl/jquery-cookie * * Copyright 2013 Klaus Hartl * Released under the MIT license */ (function (factory) { if (typeof define === 'function' && define.amd && define.amd.jQuery) { // AMD. Register as anonymous module. define(['jquery'], factory); } else { // Browser globals. factory(jQuery); } }(function ($) { var pluses = /\+/g; function raw(s) { return s; } function decoded(s) { return decodeURIComponent(s.replace(pluses, ' ')); } function converted(s) { if (s.indexOf('"') === 0) { // This is a quoted cookie as according to RFC2068, unescape s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); } try { return config.json ? JSON.parse(s) : s; } catch(er) {} } var config = $.cookie = function (key, value, options) { // write if (value !== undefined) { options = $.extend({}, config.defaults, options); if (typeof options.expires === 'number') { var days = options.expires, t = options.expires = new Date(); t.setDate(t.getDate() + days); } value = config.json ? JSON.stringify(value) : String(value); return (document.cookie = [ encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : '' ].join('')); } // read var decode = config.raw ? raw : decoded; var cookies = document.cookie.split('; '); var result = key ? undefined : {}; for (var i = 0, l = cookies.length; i < l; i++) { var parts = cookies[i].split('='); var name = decode(parts.shift()); var cookie = decode(parts.join('=')); if (key && key === name) { result = converted(cookie); break; } if (!key) { result[name] = converted(cookie); } } return result; }; config.defaults = {}; $.removeCookie = function (key, options) { if ($.cookie(key) !== undefined) { $.cookie(key, '', $.extend(options, { expires: -1 })); return true; } return false; }; })); /** * jQuery Internationalization library * * Copyright (C) 2012 Santhosh Thottingal * * jquery.i18n is dual licensed GPLv2 or later and MIT. You don't have to do * anything special to choose one license or the other and you don't have to * notify anyone which license you are using. You are free to use * UniversalLanguageSelector in commercial projects as long as the copyright * header is left intact. See files GPL-LICENSE and MIT-LICENSE for details. * * @licence GNU General Public Licence 2.0 or later * @licence MIT License */ ( function ( $ ) { 'use strict'; var nav, slice = Array.prototype.slice; /** * @constructor * @param {Object} options */ var I18N = function ( options ) { // Load defaults this.options = $.extend( {}, I18N.defaults, options ); this.parser = this.options.parser; this.locale = this.options.locale; this.messageStore = this.options.messageStore; this.languages = {}; this.init(); }; I18N.prototype = { /** * Initialize by loading locales and setting up * String.prototype.toLocaleString and String.locale. */ init: function () { var i18n; i18n = this; i18n.messageStore.init( i18n.locale ); // Set locale of String environment String.locale = i18n.locale; // Override String.localeString method String.prototype.toLocaleString = function () { var localeParts, messageLocation, localePartIndex, value, locale, fallbackIndex; value = this.valueOf(); locale = i18n.locale; fallbackIndex = 0; while ( locale ) { // Iterate through locales starting at most-specific until // localization is found. As in fi-Latn-FI, fi-Latn and fi. localeParts = locale.toLowerCase().split( '-' ); localePartIndex = localeParts.length; do { var _locale = localeParts.slice( 0, localePartIndex ).join( '-' ); if ( i18n.options.messageLocationResolver ) { messageLocation = i18n.options.messageLocationResolver( _locale, value ); if ( messageLocation && ( !i18n.messageStore.isLoaded( _locale ,messageLocation ) ) ) { i18n.messageStore.load( messageLocation, _locale ); } } var message = i18n.messageStore.get( _locale, value ); if ( message ) { return message; } localePartIndex--; } while ( localePartIndex ); if ( locale === 'en' ) { break; } locale = ( $.i18n.fallbacks[i18n.locale] && $.i18n.fallbacks[i18n.locale][fallbackIndex] ) || i18n.options.fallbackLocale; i18n.log( 'Trying fallback locale for ' + i18n.locale + ': ' + locale ); fallbackIndex++; } // key not found return ''; }; }, /* * Destroy the i18n instance. */ destroy: function () { $.removeData( document, 'i18n' ); }, /** * General message loading API This can take a URL string for * the json formatted messages. * load('path/to/all_localizations.json'); * * This can also load a localization file for a locale * load('path/to/de-messages.json', 'de' ); * * A data object containing message key- message translation mappings * can also be passed Eg: * * load( { 'hello' : 'Hello' }, optionalLocale ); * If the data argument is * null/undefined/false, * all cached messages for the i18n instance will get reset. * * @param {String|Object|null} data * @param {String} locale Language tag */ load: function ( data, locale ) { this.messageStore.load( data, locale ); }, log: function ( /* arguments */ ) { if ( window.console && $.i18n.debug ) { window.console.log.apply( window.console, arguments ); } }, /** * Does parameter and magic word substitution. * * @param {string} key Message key * @param {Array} parameters Message parameters * @return {string} */ parse: function ( key, parameters ) { var message = key.toLocaleString(); // FIXME: This changes the state of the I18N object, // should probably not change the 'this.parser' but just // pass it to the parser. this.parser.language = $.i18n.languages[$.i18n().locale] || $.i18n.languages['default']; if( message === '' ) { message = key; } return this.parser.parse( message, parameters ); } }; /** * Process a message from the $.I18N instance * for the current document, stored in jQuery.data(document). * * @param {string} key Key of the message. * @param {string} param1 [param...] Variadic list of parameters for {key}. * @return {string|$.I18N} Parsed message, or if no key was given * the instance of $.I18N is returned. */ $.i18n = function ( key, param1 ) { var parameters, i18n = $.data( document, 'i18n' ), options = typeof key === 'object' && key; // If the locale option for this call is different then the setup so far, // update it automatically. This doesn't just change the context for this // call but for all future call as well. // If there is no i18n setup yet, don't do this. It will be taken care of // by the `new I18N` construction below. // NOTE: It should only change language for this one call. // Then cache instances of I18N somewhere. if ( options && options.locale && i18n && i18n.locale !== options.locale ) { String.locale = i18n.locale = options.locale; } if ( !i18n ) { i18n = new I18N( options ); $.data( document, 'i18n', i18n ); } if ( typeof key === 'string' ) { if ( param1 !== undefined ) { parameters = slice.call( arguments, 1 ); } else { parameters = []; } return i18n.parse( key, parameters ); } else { // FIXME: remove this feature/bug. return i18n; } }; $.fn.i18n = function () { var i18n = $.data( document, 'i18n' ); String.locale = i18n.locale; if ( !i18n ) { i18n = new I18N( ); $.data( document, 'i18n', i18n ); } return this.each( function () { var $this = $( this ); if ( $this.data( 'i18n' ) ) { var messageKey = $this.data( 'i18n' ), message = messageKey.toLocaleString(); if ( message !== '' ) { $this.text( message ); } } else { $this.find( '[data-i18n]' ).i18n(); } } ); }; String.locale = String.locale || $( 'html' ).attr( 'lang' ); if ( !String.locale ) { if ( typeof window.navigator !== undefined ) { nav = window.navigator; String.locale = nav.language || nav.userLanguage || ''; } else { String.locale = ''; } } $.i18n.languages = {}; $.i18n.messageStore = $.i18n.messageStore || {}; $.i18n.parser = { // The default parser only handles variable substitution parse: function ( message, parameters ) { return message.replace( /\$(\d+)/g, function ( str, match ) { var index = parseInt( match, 10 ) - 1; return parameters[index] !== undefined ? parameters[index] : '$' + match; } ); }, emitter: {} }; $.i18n.debug = false; /* Static members */ I18N.defaults = { locale: String.locale, fallbackLocale: 'en', parser: $.i18n.parser, messageStore: $.i18n.messageStore, /* messageLocationResolver - should be a function taking language code as argument and * returning absolute or relative path to the localization file */ messageLocationResolver: null }; // Expose constructor $.I18N = I18N; }( jQuery ) ); /** * jQuery Internationalization library Message loading , parsing, retrieving utilities * * Copyright (C) 2012 Santhosh Thottingal * * jquery.i18n is dual licensed GPLv2 or later and MIT. You don't have to do anything special to * choose one license or the other and you don't have to notify anyone which license you are using. * You are free to use UniversalLanguageSelector in commercial projects as long as the copyright * header is left intact. See files GPL-LICENSE and MIT-LICENSE for details. * * @licence GNU General Public Licence 2.0 or later * @licence MIT License */ ( function ( $, window, undefined ) { 'use strict'; var MessageStore = function () { this.messages = {}; this.sources = {}; this.locale = String.locale; }; MessageStore.prototype = { /** * See https://github.com/wikimedia/jquery.i18n/wiki/Specification#wiki-Message_File_Loading * * @param locale */ init: function ( locale ) { var messageStore = this; messageStore.locale = locale; messageStore.log( 'initializing for ' + locale ); $( 'link' ).each( function ( index, element ) { var $link = $( element ), rel = ( $link.attr( 'rel' ) || '' ).toLowerCase().split( /\s+/ ); if ( $.inArray( 'localizations', rel ) !== -1 ) { // multiple localizations messageStore.load( $link.attr( 'href' ) ); } else if ( $.inArray( 'localization', rel ) !== -1 ) { // single localization messageStore.queue( ( $link.attr( 'hreflang' ) || '' ).toLowerCase(), $link.attr( 'href' ) ); } } ); }, /** * General message loading API This can take a URL string for * the json formatted messages. * load('path/to/all_localizations.json'); * * This can also load a localization file for a locale * load('path/to/de-messages.json', 'de' ); * * A data object containing message key- message translation mappings * can also be passed Eg: * * load( { 'hello' : 'Hello' }, optionalLocale ); * If the data argument is * null/undefined/false, * all cached messages for the i18n instance will get reset. * * @param {String|Object|null} data * @param {String} locale Language tag */ load: function ( data, locale ) { var key = null, messageStore = this, hasOwn = Object.prototype.hasOwnProperty; if ( !data ) { // reset all localizations messageStore.log( 'Resetting for locale ' + locale ); messageStore.messages = {}; return; } if ( typeof data === 'string' ) { // This is a URL to the messages file. messageStore.log( 'Loading messages from: ' + data ); messageStore.jsonMessageLoader( data ).done( function ( localization, textStatus ) { messageStore.load( localization, locale ); messageStore.queue( locale, data ); messageStore.markLoaded( locale, data ); } ); } else { // Data is either a group of messages for {locale}, // or a group of languages with groups of messages inside. for ( key in data ) { if ( hasOwn.call( data, key ) ) { if ( locale ) { // Lazy-init the object if ( !messageStore.messages[locale] ) { messageStore.messages[locale] = {}; } // Update message object keys, // don't overwrite the entire object. messageStore.messages[locale][key] = data[key]; messageStore.log( '[' + locale + '][' + key + '] : ' + data[key] ); // No {locale} given, assume data is a group of languages, // call this function again for each langauge. } else { messageStore.load( data[key], key ); } } } } }, log: function ( /* arguments */ ) { if ( window.console && $.i18n.debug ) { window.console.log.apply( window.console, arguments ); } }, /** * Mark a message Location for a locale loaded * * @param locale * @param messageLocation */ markLoaded: function ( locale, messageLocation ) { var i, queue = this.sources[locale]; if ( !queue ) { this.queue( locale, messageLocation ); queue = this.sources[locale]; } this.sources[locale] = this.sources[locale] || []; for ( i = 0; i < queue.length; i++ ) { if ( queue[i].source.url === messageLocation ) { queue[i].source.loaded = true; return; } } }, /** * Register the message location for a locale, will be loaded when required * * @param locale * @param messageLocation */ queue: function ( locale, messageLocation ) { var i, queue = this.sources[locale]; this.sources[locale] = this.sources[locale] || []; if ( queue ) { for ( i = 0; i < queue.length; i++ ) { if ( queue[i].source.url === messageLocation ) { return; } } } this.log( 'Source for: ' + locale + ' is ' + messageLocation + ' registered' ); this.sources[locale].push( { source: { url: messageLocation, loaded: false } } ); }, /** * Load the messages from the source queue for the locale * * @param {String} locale */ loadFromQueue: function ( locale ) { var i, queue = this.sources[locale]; if ( queue ) { for ( i = 0; i < queue.length; i++ ) { if ( !queue[i].source.loaded ) { this.load( queue[i].source.url, locale ); this.sources[locale][i].source.loaded = true; } } } }, isLoaded: function ( locale, messageLocation ) { var i, sources = this.sources[locale], result = false; if ( sources ) { for ( i = 0; i < sources.length; i++ ) { if ( sources[i].source.url === messageLocation ) { result = true; } } } return result; }, jsonMessageLoader: function ( url ) { var messageStore = this; return $.ajax( { url: url, dataType: 'json', async: false // This is unfortunate. } ).fail( function ( jqxhr, settings, exception ) { messageStore.log( 'Error in loading messages from ' + url + ' Exception: ' + exception ); } ); }, /** * * @param locale * @param messageKey * @returns {Boolean} */ get: function ( locale, messageKey ) { // load locale if not loaded if ( !this.messages[locale] ) { this.loadFromQueue( locale ); } return this.messages[locale] && this.messages[locale][messageKey]; } }; $.extend( $.i18n.messageStore, new MessageStore() ); }( jQuery, window ) ); /** * jQuery Internationalization library * * Copyright (C) 2012 Santhosh Thottingal * * jquery.i18n is dual licensed GPLv2 or later and MIT. You don't have to do anything special to * choose one license or the other and you don't have to notify anyone which license you are using. * You are free to use UniversalLanguageSelector in commercial projects as long as the copyright * header is left intact. See files GPL-LICENSE and MIT-LICENSE for details. * * @licence GNU General Public Licence 2.0 or later * @licence MIT License */ ( function ( $, undefined ) { 'use strict'; $.i18n = $.i18n || {}; $.i18n.fallbacks = { 'ab': ['ru'], 'ace': ['id'], 'aln': ['sq'], // Not so standard - als is supposed to be Tosk Albanian, // but in Wikipedia it's used for a Germanic language. 'als': ['gsw', 'de'], 'an': ['es'], 'anp': ['hi'], 'arn': ['es'], 'arz': ['ar'], 'av': ['ru'], 'ay': ['es'], 'ba': ['ru'], 'bar': ['de'], 'bat-smg': ['sgs', 'lt'], 'bcc': ['fa'], 'be-x-old': ['be-tarask'], 'bh': ['bho'], 'bjn': ['id'], 'bm': ['fr'], 'bpy': ['bn'], 'bqi': ['fa'], 'bug': ['id'], 'cbk-zam': ['es'], 'ce': ['ru'], 'crh': ['crh-latn'], 'crh-cyrl': ['ru'], 'csb': ['pl'], 'cv': ['ru'], 'de-at': ['de'], 'de-ch': ['de'], 'de-formal': ['de'], 'dsb': ['de'], 'dtp': ['ms'], 'egl': ['it'], 'eml': ['it'], 'ff': ['fr'], 'fit': ['fi'], 'fiu-vro': ['vro', 'et'], 'frc': ['fr'], 'frp': ['fr'], 'frr': ['de'], 'fur': ['it'], 'gag': ['tr'], 'gan': ['gan-hant', 'zh-hant', 'zh-hans'], 'gan-hans': ['zh-hans'], 'gan-hant': ['zh-hant', 'zh-hans'], 'gl': ['pt'], 'glk': ['fa'], 'gn': ['es'], 'gsw': ['de'], 'hif': ['hif-latn'], 'hsb': ['de'], 'ht': ['fr'], 'ii': ['zh-cn', 'zh-hans'], 'inh': ['ru'], 'iu': ['ike-cans'], 'jut': ['da'], 'jv': ['id'], 'kaa': ['kk-latn', 'kk-cyrl'], 'kbd': ['kbd-cyrl'], 'khw': ['ur'], 'kiu': ['tr'], 'kk': ['kk-cyrl'], 'kk-arab': ['kk-cyrl'], 'kk-latn': ['kk-cyrl'], 'kk-cn': ['kk-arab', 'kk-cyrl'], 'kk-kz': ['kk-cyrl'], 'kk-tr': ['kk-latn', 'kk-cyrl'], 'kl': ['da'], 'ko-kp': ['ko'], 'koi': ['ru'], 'krc': ['ru'], 'ks': ['ks-arab'], 'ksh': ['de'], 'ku': ['ku-latn'], 'ku-arab': ['ckb'], 'kv': ['ru'], 'lad': ['es'], 'lb': ['de'], 'lbe': ['ru'], 'lez': ['ru'], 'li': ['nl'], 'lij': ['it'], 'liv': ['et'], 'lmo': ['it'], 'ln': ['fr'], 'ltg': ['lv'], 'lzz': ['tr'], 'mai': ['hi'], 'map-bms': ['jv', 'id'], 'mg': ['fr'], 'mhr': ['ru'], 'min': ['id'], 'mo': ['ro'], 'mrj': ['ru'], 'mwl': ['pt'], 'myv': ['ru'], 'mzn': ['fa'], 'nah': ['es'], 'nap': ['it'], 'nds': ['de'], 'nds-nl': ['nl'], 'nl-informal': ['nl'], 'no': ['nb'], 'os': ['ru'], 'pcd': ['fr'], 'pdc': ['de'], 'pdt': ['de'], 'pfl': ['de'], 'pms': ['it'], 'pt': ['pt-br'], 'pt-br': ['pt'], 'qu': ['es'], 'qug': ['qu', 'es'], 'rgn': ['it'], 'rmy': ['ro'], 'roa-rup': ['rup'], 'rue': ['uk', 'ru'], 'ruq': ['ruq-latn', 'ro'], 'ruq-cyrl': ['mk'], 'ruq-latn': ['ro'], 'sa': ['hi'], 'sah': ['ru'], 'scn': ['it'], 'sg': ['fr'], 'sgs': ['lt'], 'sli': ['de'], 'sr': ['sr-ec'], 'srn': ['nl'], 'stq': ['de'], 'su': ['id'], 'szl': ['pl'], 'tcy': ['kn'], 'tg': ['tg-cyrl'], 'tt': ['tt-cyrl', 'ru'], 'tt-cyrl': ['ru'], 'ty': ['fr'], 'udm': ['ru'], 'ug': ['ug-arab'], 'uk': ['ru'], 'vec': ['it'], 'vep': ['et'], 'vls': ['nl'], 'vmf': ['de'], 'vot': ['fi'], 'vro': ['et'], 'wa': ['fr'], 'wo': ['fr'], 'wuu': ['zh-hans'], 'xal': ['ru'], 'xmf': ['ka'], 'yi': ['he'], 'za': ['zh-hans'], 'zea': ['nl'], 'zh': ['zh-hans'], 'zh-classical': ['lzh'], 'zh-cn': ['zh-hans'], 'zh-hant': ['zh-hans'], 'zh-hk': ['zh-hant', 'zh-hans'], 'zh-min-nan': ['nan'], 'zh-mo': ['zh-hk', 'zh-hant', 'zh-hans'], 'zh-my': ['zh-sg', 'zh-hans'], 'zh-sg': ['zh-hans'], 'zh-tw': ['zh-hant', 'zh-hans'], 'zh-yue': ['yue'] }; }( jQuery ) ); /** * jQuery Internationalization library * * Copyright (C) 2012 Santhosh Thottingal * * jquery.i18n is dual licensed GPLv2 or later and MIT. You don't have to do * anything special to choose one license or the other and you don't have to * notify anyone which license you are using. You are free to use * UniversalLanguageSelector in commercial projects as long as the copyright * header is left intact. See files GPL-LICENSE and MIT-LICENSE for details. * * @licence GNU General Public Licence 2.0 or later * @licence MIT License */ ( function ( $ ) { 'use strict'; var MessageParser = function ( options ) { this.options = $.extend( {}, $.i18n.parser.defaults, options ); this.language = $.i18n.languages[String.locale] || $.i18n.languages['default']; this.emitter = $.i18n.parser.emitter; }; MessageParser.prototype = { constructor: MessageParser, simpleParse: function ( message, parameters ) { return message.replace( /\$(\d+)/g, function ( str, match ) { var index = parseInt( match, 10 ) - 1; return parameters[index] !== undefined ? parameters[index] : '$' + match; } ); }, parse: function ( message, replacements ) { if ( message.indexOf( '{{' ) < 0 ) { return this.simpleParse( message, replacements ); } this.emitter.language = $.i18n.languages[$.i18n().locale] || $.i18n.languages['default']; return this.emitter.emit( this.ast( message ), replacements ); }, ast: function ( message ) { var pos = 0; // Try parsers until one works, if none work return null function choice ( parserSyntax ) { return function () { var i, result; for ( i = 0; i < parserSyntax.length; i++ ) { result = parserSyntax[i](); if ( result !== null ) { return result; } } return null; }; } // Try several parserSyntax-es in a row. // All must succeed; otherwise, return null. // This is the only eager one. function sequence ( parserSyntax ) { var i, res, originalPos = pos, result = []; for ( i = 0; i < parserSyntax.length; i++ ) { res = parserSyntax[i](); if ( res === null ) { pos = originalPos; return null; } result.push( res ); } return result; } // Run the same parser over and over until it fails. // Must succeed a minimum of n times; otherwise, return null. function nOrMore ( n, p ) { return function () { var originalPos = pos, result = [], parsed = p(); while ( parsed !== null ) { result.push( parsed ); parsed = p(); } if ( result.length < n ) { pos = originalPos; return null; } return result; }; } // Helpers -- just make parserSyntax out of simpler JS builtin types function makeStringParser ( s ) { var len = s.length; return function () { var result = null; if ( message.substr( pos, len ) === s ) { result = s; pos += len; } return result; }; } function makeRegexParser ( regex ) { return function () { var matches = message.substr( pos ).match( regex ); if ( matches === null ) { return null; } pos += matches[0].length; return matches[0]; }; } var pipe = makeStringParser( '|' ); var colon = makeStringParser( ':' ); var backslash = makeStringParser( '\\' ); var anyCharacter = makeRegexParser( /^./ ); var dollar = makeStringParser( '$' ); var digits = makeRegexParser( /^\d+/ ); var regularLiteral = makeRegexParser( /^[^{}\[\]$\\]/ ); var regularLiteralWithoutBar = makeRegexParser( /^[^{}\[\]$\\|]/ ); var regularLiteralWithoutSpace = makeRegexParser( /^[^{}\[\]$\s]/ ); // There is a general pattern: // parse a thing; // if it worked, apply transform, // otherwise return null. // But using this as a combinator seems to cause problems // when combined with nOrMore(). // May be some scoping issue. function transform ( p, fn ) { return function () { var result = p(); return result === null ? null : fn( result ); }; } // Used to define "literals" within template parameters. The pipe // character is the parameter delimeter, so by default // it is not a literal in the parameter function literalWithoutBar () { var result = nOrMore( 1, escapedOrLiteralWithoutBar )(); return result === null ? null : result.join( '' ); } function literal () { var result = nOrMore( 1, escapedOrRegularLiteral )(); return result === null ? null : result.join( '' ); } function escapedLiteral () { var result = sequence( [ backslash, anyCharacter ] ); return result === null ? null : result[1]; } choice( [ escapedLiteral, regularLiteralWithoutSpace ] ); var escapedOrLiteralWithoutBar = choice( [ escapedLiteral, regularLiteralWithoutBar ] ); var escapedOrRegularLiteral = choice( [ escapedLiteral, regularLiteral ] ); function replacement () { var result = sequence( [ dollar, digits ] ); if ( result === null ) { return null; } return [ 'REPLACE', parseInt( result[1], 10 ) - 1 ]; } var templateName = transform( // see $wgLegalTitleChars // not allowing : due to the need to catch "PLURAL:$1" makeRegexParser( /^[ !"$&'()*,.\/0-9;=?@A-Z\^_`a-z~\x80-\xFF+\-]+/ ), function ( result ) { return result.toString(); } ); function templateParam () { var result = sequence( [ pipe, nOrMore( 0, paramExpression ) ] ); if ( result === null ) { return null; } var expr = result[1]; // use a "CONCAT" operator if there are multiple nodes, // otherwise return the first node, raw. return expr.length > 1 ? [ 'CONCAT' ].concat( expr ) : expr[0]; } function templateWithReplacement () { var result = sequence( [ templateName, colon, replacement ] ); return result === null ? null : [ result[0], result[2] ]; } function templateWithOutReplacement () { var result = sequence( [ templateName, colon, paramExpression ] ); return result === null ? null : [ result[0], result[2] ]; } var templateContents = choice( [ function () { var res = sequence( [ // templates can have placeholders for dynamic // replacement eg: {{PLURAL:$1|one car|$1 cars}} // or no placeholders eg: // {{GRAMMAR:genitive|{{SITENAME}}} choice( [ templateWithReplacement, templateWithOutReplacement ] ), nOrMore( 0, templateParam ) ] ); return res === null ? null : res[0].concat( res[1] ); }, function () { var res = sequence( [ templateName, nOrMore( 0, templateParam ) ] ); if ( res === null ) { return null; } return [ res[0] ].concat( res[1] ); } ] ); var openTemplate = makeStringParser( '{{' ); var closeTemplate = makeStringParser( '}}' ); function template () { var result = sequence( [ openTemplate, templateContents, closeTemplate ] ); return result === null ? null : result[1]; } var expression = choice( [ template, replacement, literal ] ); var paramExpression = choice( [ template, replacement, literalWithoutBar ] ); function start () { var result = nOrMore( 0, expression )(); if ( result === null ) { return null; } return [ 'CONCAT' ].concat( result ); } var result = start(); /* * For success, the pos must have gotten to the end of the input * and returned a non-null. * n.b. This is part of language infrastructure, so we do not throw an internationalizable message. */ if ( result === null || pos !== message.length ) { throw new Error( 'Parse error at position ' + pos.toString() + ' in input: ' + message ); } return result; } }; $.extend( $.i18n.parser, new MessageParser() ); }( jQuery ) ); /** * jQuery Internationalization library * * Copyright (C) 2012 Santhosh Thottingal * * jquery.i18n is dual licensed GPLv2 or later and MIT. You don't have to do * anything special to choose one license or the other and you don't have to * notify anyone which license you are using. You are free to use * UniversalLanguageSelector in commercial projects as long as the copyright * header is left intact. See files GPL-LICENSE and MIT-LICENSE for details. * * @licence GNU General Public Licence 2.0 or later * @licence MIT License */ ( function ( $ ) { 'use strict'; var MessageParserEmitter = function () { this.language = $.i18n.languages[String.locale] || $.i18n.languages['default']; }; MessageParserEmitter.prototype = { constructor: MessageParserEmitter, /** * (We put this method definition here, and not in prototype, to make * sure it's not overwritten by any magic.) Walk entire node structure, * applying replacements and template functions when appropriate * * @param {Mixed} node abstract syntax tree (top node or subnode) * @param {Array} replacements for $1, $2, ... $n * @return {Mixed} single-string node or array of nodes suitable for * jQuery appending. */ emit: function ( node, replacements ) { var ret, subnodes, operation, messageParserEmitter = this; switch ( typeof node ) { case 'string': case 'number': ret = node; break; case 'object': // node is an array of nodes subnodes = $.map( node.slice( 1 ), function ( n ) { return messageParserEmitter.emit( n, replacements ); } ); operation = node[0].toLowerCase(); if ( typeof messageParserEmitter[operation] === 'function' ) { ret = messageParserEmitter[operation]( subnodes, replacements ); } else { throw new Error( 'unknown operation "' + operation + '"' ); } break; case 'undefined': // Parsing the empty string (as an entire expression, or as a // paramExpression in a template) results in undefined // Perhaps a more clever parser can detect this, and return the // empty string? Or is that useful information? // The logical thing is probably to return the empty string here // when we encounter undefined. ret = ''; break; default: throw new Error( 'unexpected type in AST: ' + typeof node ); } return ret; }, /** * Parsing has been applied depth-first we can assume that all nodes * here are single nodes Must return a single node to parents -- a * jQuery with synthetic span However, unwrap any other synthetic spans * in our children and pass them upwards * * @param {Array} nodes Mixed, some single nodes, some arrays of nodes. * @return String */ concat: function ( nodes ) { var result = ''; $.each( nodes, function ( i, node ) { // strings, integers, anything else result += node; } ); return result; }, /** * Return escaped replacement of correct index, or string if * unavailable. Note that we expect the parsed parameter to be * zero-based. i.e. $1 should have become [ 0 ]. if the specified * parameter is not found return the same string (e.g. "$99" -> * parameter 98 -> not found -> return "$99" ) TODO throw error if * nodes.length > 1 ? * * @param {Array} nodes One element, integer, n >= 0 * @param {Array} replacements for $1, $2, ... $n * @return {string} replacement */ replace: function ( nodes, replacements ) { var index = parseInt( nodes[0], 10 ); if ( index < replacements.length ) { // replacement is not a string, don't touch! return replacements[index]; } else { // index not found, fallback to displaying variable return '$' + ( index + 1 ); } }, /** * Transform parsed structure into pluralization n.b. The first node may * be a non-integer (for instance, a string representing an Arabic * number). So convert it back with the current language's * convertNumber. * * @param {Array} nodes List [ {String|Number}, {String}, {String} ... ] * @return {String} selected pluralized form according to current * language. */ plural: function ( nodes ) { var count = parseFloat( this.language.convertNumber( nodes[0], 10 ) ), forms = nodes.slice( 1 ); return forms.length ? this.language.convertPlural( count, forms ) : ''; }, /** * Transform parsed structure into gender Usage * {{gender:gender|masculine|feminine|neutral}}. * * @param {Array} nodes List [ {String}, {String}, {String} , {String} ] * @return {String} selected gender form according to current language */ gender: function ( nodes ) { var gender = nodes[0], forms = nodes.slice( 1 ); return this.language.gender( gender, forms ); }, /** * Transform parsed structure into grammar conversion. Invoked by * putting {{grammar:form|word}} in a message * * @param {Array} nodes List [{Grammar case eg: genitive}, {String word}] * @return {String} selected grammatical form according to current * language. */ grammar: function ( nodes ) { var form = nodes[0], word = nodes[1]; return word && form && this.language.convertGrammar( word, form ); } }; $.extend( $.i18n.parser.emitter, new MessageParserEmitter() ); }( jQuery ) ); /*global pluralRuleParser */ ( function ( $ ) { 'use strict'; var language = { // CLDR plural rules generated using // http://i18ndata.appspot.com/cldr/tags/unconfirmed/supplemental/plurals?action=browse&depth=-1 // and compressed pluralRules: { gv: { one: 'n mod 10 in 1..2 or n mod 20 is 0' }, gu: { one: 'n is 1' }, rof: { one: 'n is 1' }, ga: { few: 'n in 3..6', many: 'n in 7..10', two: 'n is 2', one: 'n is 1' }, gl: { one: 'n is 1' }, lg: { one: 'n is 1' }, lb: { one: 'n is 1' }, xog: { one: 'n is 1' }, ln: { one: 'n in 0..1' }, lo: '', brx: { one: 'n is 1' }, tr: '', ts: { one: 'n is 1' }, tn: { one: 'n is 1' }, to: '', lt: { few: 'n mod 10 in 2..9 and n mod 100 not in 11..19', one: 'n mod 10 is 1 and n mod 100 not in 11..19' }, tk: { one: 'n is 1' }, th: '', ksb: { one: 'n is 1' }, te: { one: 'n is 1' }, ksh: { zero: 'n is 0', one: 'n is 1' }, fil: { one: 'n in 0..1' }, haw: { one: 'n is 1' }, kcg: { one: 'n is 1' }, ssy: { one: 'n is 1' }, yo: '', de: { one: 'n is 1' }, ko: '', da: { one: 'n is 1' }, dz: '', dv: { one: 'n is 1' }, guw: { one: 'n in 0..1' }, shi: { few: 'n in 2..10', one: 'n within 0..1' }, el: { one: 'n is 1' }, eo: { one: 'n is 1' }, en: { one: 'n is 1' }, ses: '', teo: { one: 'n is 1' }, ee: { one: 'n is 1' }, kde: '', fr: { one: 'n within 0..2 and n is not 2' }, eu: { one: 'n is 1' }, et: { one: 'n is 1' }, es: { one: 'n is 1' }, seh: { one: 'n is 1' }, ru: { few: 'n mod 10 in 2..4 and n mod 100 not in 12..14', many: 'n mod 10 is 0 or n mod 10 in 5..9 or n mod 100 in 11..14', one: 'n mod 10 is 1 and n mod 100 is not 11' }, kl: { one: 'n is 1' }, sms: { two: 'n is 2', one: 'n is 1' }, smn: { two: 'n is 2', one: 'n is 1' }, smj: { two: 'n is 2', one: 'n is 1' }, smi: { two: 'n is 2', one: 'n is 1' }, fy: { one: 'n is 1' }, rm: { one: 'n is 1' }, ro: { few: 'n is 0 OR n is not 1 AND n mod 100 in 1..19', one: 'n is 1' }, bn: { one: 'n is 1' }, sma: { two: 'n is 2', one: 'n is 1' }, be: { few: 'n mod 10 in 2..4 and n mod 100 not in 12..14', many: 'n mod 10 is 0 or n mod 10 in 5..9 or n mod 100 in 11..14', one: 'n mod 10 is 1 and n mod 100 is not 11' }, bg: { one: 'n is 1' }, ms: '', wa: { one: 'n in 0..1' }, ps: { one: 'n is 1' }, wo: '', bm: '', jv: '', bo: '', bh: { one: 'n in 0..1' }, kea: '', asa: { one: 'n is 1' }, cgg: { one: 'n is 1' }, br: { few: 'n mod 10 in 3..4,9 and n mod 100 not in 10..19,70..79,90..99', many: 'n mod 1000000 is 0 and n is not 0', two: 'n mod 10 is 2 and n mod 100 not in 12,72,92', one: 'n mod 10 is 1 and n mod 100 not in 11,71,91' }, bs: { few: 'n mod 10 in 2..4 and n mod 100 not in 12..14', many: 'n mod 10 is 0 or n mod 10 in 5..9 or n mod 100 in 11..14', one: 'n mod 10 is 1 and n mod 100 is not 11' }, ja: '', om: { one: 'n is 1' }, fa: '', vun: { one: 'n is 1' }, or: { one: 'n is 1' }, xh: { one: 'n is 1' }, nso: { one: 'n in 0..1' }, ca: { one: 'n is 1' }, cy: { few: 'n is 3', zero: 'n is 0', many: 'n is 6', two: 'n is 2', one: 'n is 1' }, cs: { few: 'n in 2..4', one: 'n is 1' }, zh: '', lv: { zero: 'n is 0', one: 'n mod 10 is 1 and n mod 100 is not 11' }, pt: { one: 'n is 1' }, wae: { one: 'n is 1' }, tl: { one: 'n in 0..1' }, chr: { one: 'n is 1' }, pa: { one: 'n is 1' }, ak: { one: 'n in 0..1' }, pl: { few: 'n mod 10 in 2..4 and n mod 100 not in 12..14', many: 'n is not 1 and n mod 10 in 0..1 or n mod 10 in 5..9 or n mod 100 in 12..14', one: 'n is 1' }, hr: { few: 'n mod 10 in 2..4 and n mod 100 not in 12..14', many: 'n mod 10 is 0 or n mod 10 in 5..9 or n mod 100 in 11..14', one: 'n mod 10 is 1 and n mod 100 is not 11' }, am: { one: 'n in 0..1' }, ti: { one: 'n in 0..1' }, hu: '', hi: { one: 'n in 0..1' }, jmc: { one: 'n is 1' }, ha: { one: 'n is 1' }, he: { one: 'n is 1' }, mg: { one: 'n in 0..1' }, fur: { one: 'n is 1' }, bem: { one: 'n is 1' }, ml: { one: 'n is 1' }, mo: { few: 'n is 0 OR n is not 1 AND n mod 100 in 1..19', one: 'n is 1' }, mn: { one: 'n is 1' }, mk: { one: 'n mod 10 is 1 and n is not 11' }, ur: { one: 'n is 1' }, bez: { one: 'n is 1' }, mt: { few: 'n is 0 or n mod 100 in 2..10', many: 'n mod 100 in 11..19', one: 'n is 1' }, uk: { few: 'n mod 10 in 2..4 and n mod 100 not in 12..14', many: 'n mod 10 is 0 or n mod 10 in 5..9 or n mod 100 in 11..14', one: 'n mod 10 is 1 and n mod 100 is not 11' }, mr: { one: 'n is 1' }, ta: { one: 'n is 1' }, my: '', sah: '', ve: { one: 'n is 1' }, af: { one: 'n is 1' }, vi: '', is: { one: 'n is 1' }, iu: { two: 'n is 2', one: 'n is 1' }, it: { one: 'n is 1' }, kn: '', ii: '', ar: { few: 'n mod 100 in 3..10', zero: 'n is 0', many: 'n mod 100 in 11..99', two: 'n is 2', one: 'n is 1' }, zu: { one: 'n is 1' }, saq: { one: 'n is 1' }, az: '', tzm: { one: 'n in 0..1 or n in 11..99' }, id: '', ig: '', pap: { one: 'n is 1' }, nl: { one: 'n is 1' }, nn: { one: 'n is 1' }, no: { one: 'n is 1' }, nah: { one: 'n is 1' }, nd: { one: 'n is 1' }, ne: { one: 'n is 1' }, ny: { one: 'n is 1' }, naq: { two: 'n is 2', one: 'n is 1' }, nyn: { one: 'n is 1' }, kw: { two: 'n is 2', one: 'n is 1' }, nr: { one: 'n is 1' }, tig: { one: 'n is 1' }, kab: { one: 'n within 0..2 and n is not 2' }, mas: { one: 'n is 1' }, rwk: { one: 'n is 1' }, kaj: { one: 'n is 1' }, lag: { zero: 'n is 0', one: 'n within 0..2 and n is not 0 and n is not 2' }, syr: { one: 'n is 1' }, kk: { one: 'n is 1' }, ff: { one: 'n within 0..2 and n is not 2' }, fi: { one: 'n is 1' }, fo: { one: 'n is 1' }, ka: '', gsw: { one: 'n is 1' }, ckb: { one: 'n is 1' }, ss: { one: 'n is 1' }, sr: { few: 'n mod 10 in 2..4 and n mod 100 not in 12..14', many: 'n mod 10 is 0 or n mod 10 in 5..9 or n mod 100 in 11..14', one: 'n mod 10 is 1 and n mod 100 is not 11' }, sq: { one: 'n is 1' }, sw: { one: 'n is 1' }, sv: { one: 'n is 1' }, km: '', st: { one: 'n is 1' }, sk: { few: 'n in 2..4', one: 'n is 1' }, sh: { few: 'n mod 10 in 2..4 and n mod 100 not in 12..14', many: 'n mod 10 is 0 or n mod 10 in 5..9 or n mod 100 in 11..14', one: 'n mod 10 is 1 and n mod 100 is not 11' }, so: { one: 'n is 1' }, sn: { one: 'n is 1' }, ku: { one: 'n is 1' }, sl: { few: 'n mod 100 in 3..4', two: 'n mod 100 is 2', one: 'n mod 100 is 1' }, sg: '', nb: { one: 'n is 1' }, se: { two: 'n is 2', one: 'n is 1' } }, /** * Plural form transformations, needed for some languages. * * @param count * integer Non-localized quantifier * @param forms * array List of plural forms * @return string Correct form for quantifier in this language */ convertPlural: function ( count, forms ) { var pluralRules, pluralFormIndex = 0; if ( !forms || forms.length === 0 ) { return ''; } pluralRules = this.pluralRules[$.i18n().locale]; if ( !pluralRules ) { // default fallback. return ( count === 1 ) ? forms[0] : forms[1]; } pluralFormIndex = this.getPluralForm( count, pluralRules ); pluralFormIndex = Math.min( pluralFormIndex, forms.length - 1 ); return forms[pluralFormIndex]; }, /** * For the number, get the plural for index * * @param number * @param pluralRules * @return plural form index */ getPluralForm: function ( number, pluralRules ) { var i, pluralForms = [ 'zero', 'one', 'two', 'few', 'many', 'other' ], pluralFormIndex = 0; for ( i = 0; i < pluralForms.length; i++ ) { if ( pluralRules[pluralForms[i]] ) { if ( pluralRuleParser( pluralRules[pluralForms[i]], number ) ) { return pluralFormIndex; } pluralFormIndex++; } } return pluralFormIndex; }, /** * Converts a number using digitTransformTable. * * @param {number} num Value to be converted * @param {boolean} integer Convert the return value to an integer */ 'convertNumber': function ( num, integer ) { var tmp, item, i, transformTable, numberString, convertedNumber; // Set the target Transform table: transformTable = this.digitTransformTable( $.i18n().locale ); numberString = '' + num; convertedNumber = ''; if ( !transformTable ) { return num; } // Check if the restore to Latin number flag is set: if ( integer ) { if ( parseFloat( num, 10 ) === num ) { return num; } tmp = []; for ( item in transformTable ) { tmp[transformTable[item]] = item; } transformTable = tmp; } for ( i = 0; i < numberString.length; i++ ) { if ( transformTable[numberString[i]] ) { convertedNumber += transformTable[numberString[i]]; } else { convertedNumber += numberString[i]; } } return integer ? parseFloat( convertedNumber, 10 ) : convertedNumber; }, /** * Grammatical transformations, needed for inflected languages. * Invoked by putting {{grammar:form|word}} in a message. * Override this method for languages that need special grammar rules * applied dynamically. * * @param word {String} * @param form {String} * @return {String} */ convertGrammar: function ( word, form ) { return word; }, /** * Provides an alternative text depending on specified gender. Usage * {{gender:[gender|user object]|masculine|feminine|neutral}}. If second * or third parameter are not specified, masculine is used. * * These details may be overriden per language. * * @param gender * string male, female, or anything else for neutral. * @param forms * array List of gender forms * * @return string */ 'gender': function ( gender, forms ) { if ( !forms || forms.length === 0 ) { return ''; } while ( forms.length < 2 ) { forms.push( forms[forms.length - 1] ); } if ( gender === 'male' ) { return forms[0]; } if ( gender === 'female' ) { return forms[1]; } return ( forms.length === 3 ) ? forms[2] : forms[0]; }, /** * Get the digit transform table for the given language * See http://cldr.unicode.org/translation/numbering-systems * @param language * @returns {Array|boolean} List of digits in the passed language or false * representation, or boolean false if there is no information. */ digitTransformTable: function ( language ) { var tables = { ar: '٠١٢٣٤٥٦٧٨٩', fa: '۰۱۲۳۴۵۶۷۸۹', ml: '൦൧൨൩൪൫൬൭൮൯', kn: '೦೧೨೩೪೫೬೭೮೯', lo: '໐໑໒໓໔໕໖໗໘໙', or: '୦୧୨୩୪୫୬୭୮୯', kh: '០១២៣៤៥៦៧៨៩', pa: '੦੧੨੩੪੫੬੭੮੯', gu: '૦૧૨૩૪૫૬૭૮૯', hi: '०१२३४५६७८९', my: '၀၁၂၃၄၅၆၇၈၉', ta: '௦௧௨௩௪௫௬௭௮௯', te: '౦౧౨౩౪౫౬౭౮౯', th: '๐๑๒๓๔๕๖๗๘๙', //FIXME use iso 639 codes bo: '༠༡༢༣༤༥༦༧༨༩' //FIXME use iso 639 codes }; if ( !tables[language] ) { return false; } return tables[language].split( '' ); } }; $.extend( $.i18n.languages, { 'default': language } ); }( jQuery ) ); /** * Bosnian (bosanski) language functions */ ( function ( $ ) { 'use strict'; $.i18n.languages.bs = $.extend( {}, $.i18n.languages['default'], { convertGrammar: function ( word, form ) { switch ( form ) { case 'instrumental': // instrumental word = 's ' + word; break; case 'lokativ': // locative word = 'o ' + word; break; } return word; } } ); }( jQuery ) ); /** * Lower Sorbian (Dolnoserbski) language functions */ ( function ( $ ) { 'use strict'; $.i18n.languages.dsb = $.extend( {}, $.i18n.languages['default'], { convertGrammar: function ( word, form ) { switch ( form ) { case 'instrumental': // instrumental word = 'z ' + word; break; case 'lokatiw': // lokatiw word = 'wo ' + word; break; } return word; } } ); }( jQuery ) ); /** * Finnish (Suomi) language functions * * @author Santhosh Thottingal */ ( function ( $ ) { 'use strict'; $.i18n.languages.fi = $.extend( {}, $.i18n.languages['default'], { convertGrammar: function ( word, form ) { // vowel harmony flag var aou = word.match( /[aou][^äöy]*$/i ), origWord = word; if ( word.match( /wiki$/i ) ) { aou = false; } // append i after final consonant if ( word.match( /[bcdfghjklmnpqrstvwxz]$/i ) ) { word += 'i'; } switch ( form ) { case 'genitive': word += 'n'; break; case 'elative': word += ( aou ? 'sta' : 'stä' ); break; case 'partitive': word += ( aou ? 'a' : 'ä' ); break; case 'illative': // Double the last letter and add 'n' word += word.substr( word.length - 1 ) + 'n'; break; case 'inessive': word += ( aou ? 'ssa' : 'ssä' ); break; default: word = origWord; break; } return word; } } ); }( jQuery ) ); /** * Irish (Gaeilge) language functions */ ( function ( $ ) { 'use strict'; $.i18n.languages.ga = $.extend( {}, $.i18n.languages['default'], { convertGrammar: function ( word, form ) { if ( form === 'ainmlae' ) { switch ( word ) { case 'an Domhnach': word = 'Dé Domhnaigh'; break; case 'an Luan': word = 'Dé Luain'; break; case 'an Mháirt': word = 'Dé Mháirt'; break; case 'an Chéadaoin': word = 'Dé Chéadaoin'; break; case 'an Déardaoin': word = 'Déardaoin'; break; case 'an Aoine': word = 'Dé hAoine'; break; case 'an Satharn': word = 'Dé Sathairn'; break; } } return word; } } ); }( jQuery ) ); /** * Hebrew (עברית) language functions */ ( function ( $ ) { 'use strict'; $.i18n.languages.he = $.extend( {}, $.i18n.languages['default'], { convertGrammar: function ( word, form ) { switch ( form ) { case 'prefixed': case 'תחילית': // the same word in Hebrew // Duplicate prefixed "Waw", but only if it's not already double if ( word.substr( 0, 1 ) === 'ו' && word.substr( 0, 2 ) !== 'וו' ) { word = 'ו' + word; } // Remove the "He" if prefixed if ( word.substr( 0, 1 ) === 'ה' ) { word = word.substr( 1, word.length ); } // Add a hyphen (maqaf) before numbers and non-Hebrew letters if ( word.substr( 0, 1 ) < 'א' || word.substr( 0, 1 ) > 'ת' ) { word = '־' + word; } } return word; } } ); }( jQuery ) ); /** * Upper Sorbian (Hornjoserbsce) language functions */ ( function ( $ ) { 'use strict'; $.i18n.languages.hsb = $.extend( {}, $.i18n.languages['default'], { convertGrammar: function ( word, form ) { switch ( form ) { case 'instrumental': // instrumental word = 'z ' + word; break; case 'lokatiw': // lokatiw word = 'wo ' + word; break; } return word; } } ); }( jQuery ) ); /** * Hungarian language functions * * @author Santhosh Thottingal */ ( function ( $ ) { 'use strict'; $.i18n.languages.hu = $.extend( {}, $.i18n.languages['default'], { convertGrammar: function ( word, form ) { switch ( form ) { case 'rol': word += 'ról'; break; case 'ba': word += 'ba'; break; case 'k': word += 'k'; break; } return word; } } ); }( jQuery ) ); /** * Armenian (Հայերեն) language functions */ ( function ( $ ) { 'use strict'; $.i18n.languages.hy = $.extend( {}, $.i18n.languages['default'], { convertGrammar: function ( word, form ) { if ( form === 'genitive' ) { // սեռական հոլով if ( word.substr( -1 ) === 'ա' ) { word = word.substr( 0, word.length - 1 ) + 'այի'; } else if ( word.substr( -1 ) === 'ո' ) { word = word.substr( 0, word.length - 1 ) + 'ոյի'; } else if ( word.substr( -4 ) === 'գիրք' ) { word = word.substr( 0, word.length - 4 ) + 'գրքի'; } else { word = word + 'ի'; } } return word; } } ); }( jQuery ) ); /** * Latin (lingua Latina) language functions * * @author Santhosh Thottingal */ ( function ( $ ) { 'use strict'; $.i18n.languages.la = $.extend( {}, $.i18n.languages['default'], { convertGrammar: function ( word, form ) { switch ( form ) { case 'genitive': // only a few declensions, and even for those mostly the singular only word = word.replace( /u[ms]$/i, 'i' ); // 2nd declension singular word = word.replace( /ommunia$/i, 'ommunium' ); // 3rd declension neuter plural (partly) word = word.replace( /a$/i, 'ae' ); // 1st declension singular word = word.replace( /libri$/i, 'librorum' ); // 2nd declension plural (partly) word = word.replace( /nuntii$/i, 'nuntiorum' ); // 2nd declension plural (partly) word = word.replace( /tio$/i, 'tionis' ); // 3rd declension singular (partly) word = word.replace( /ns$/i, 'ntis' ); word = word.replace( /as$/i, 'atis' ); word = word.replace( /es$/i, 'ei' ); // 5th declension singular break; case 'accusative': // only a few declensions, and even for those mostly the singular only word = word.replace( /u[ms]$/i, 'um' ); // 2nd declension singular word = word.replace( /ommunia$/i, 'am' ); // 3rd declension neuter plural (partly) word = word.replace( /a$/i, 'ommunia' ); // 1st declension singular word = word.replace( /libri$/i, 'libros' ); // 2nd declension plural (partly) word = word.replace( /nuntii$/i, 'nuntios' );// 2nd declension plural (partly) word = word.replace( /tio$/i, 'tionem' ); // 3rd declension singular (partly) word = word.replace( /ns$/i, 'ntem' ); word = word.replace( /as$/i, 'atem' ); word = word.replace( /es$/i, 'em' ); // 5th declension singular break; case 'ablative': // only a few declensions, and even for those mostly the singular only word = word.replace( /u[ms]$/i, 'o' ); // 2nd declension singular word = word.replace( /ommunia$/i, 'ommunibus' ); // 3rd declension neuter plural (partly) word = word.replace( /a$/i, 'a' ); // 1st declension singular word = word.replace( /libri$/i, 'libris' ); // 2nd declension plural (partly) word = word.replace( /nuntii$/i, 'nuntiis' ); // 2nd declension plural (partly) word = word.replace( /tio$/i, 'tione' ); // 3rd declension singular (partly) word = word.replace( /ns$/i, 'nte' ); word = word.replace( /as$/i, 'ate' ); word = word.replace( /es$/i, 'e' ); // 5th declension singular break; } return word; } } ); }( jQuery ) ); /** * Ossetian (Ирон) language functions * * @author Santhosh Thottingal */ ( function ( $ ) { 'use strict'; $.i18n.languages.os = $.extend( {}, $.i18n.languages['default'], { convertGrammar: function ( word, form ) { // Ending for allative case var endAllative = 'мæ'; // Variable for 'j' beetwen vowels var jot = ''; // Variable for "-" for not Ossetic words var hyphen = ''; // Variable for ending var ending = ''; // Checking if the $word is in plural form if ( word.match( /тæ$/i ) ) { word = word.substring( 0, word.length - 1 ); endAllative = 'æм'; } // Works if word is in singular form. // Checking if word ends on one of the vowels: е, ё, и, о, ы, э, ю, // я. else if ( word.match( /[аæеёиоыэюя]$/i ) ) { jot = 'й'; } // Checking if word ends on 'у'. 'У' can be either consonant 'W' or // vowel 'U' in cyrillic Ossetic. // Examples: {{grammar:genitive|аунеу}} = аунеуы, // {{grammar:genitive|лæппу}} = лæппуйы. else if ( word.match( /у$/i ) ) { if ( !word.substring( word.length - 2, word.length - 1 ) .match( /[аæеёиоыэюя]$/i ) ) { jot = 'й'; } } else if ( !word.match( /[бвгджзйклмнопрстфхцчшщьъ]$/i ) ) { hyphen = '-'; } switch ( form ) { case 'genitive': ending = hyphen + jot + 'ы'; break; case 'dative': ending = hyphen + jot + 'æн'; break; case 'allative': ending = hyphen + endAllative; break; case 'ablative': if ( jot === 'й' ) { ending = hyphen + jot + 'æ'; } else { ending = hyphen + jot + 'æй'; } break; case 'superessive': ending = hyphen + jot + 'ыл'; break; case 'equative': ending = hyphen + jot + 'ау'; break; case 'comitative': ending = hyphen + 'имæ'; break; } return word + ending; } } ); }( jQuery ) ); /** * Russian (Русский) language functions */ ( function ( $ ) { 'use strict'; $.i18n.languages.ru = $.extend( {}, $.i18n.languages['default'], { convertGrammar: function ( word, form ) { if ( form === 'genitive' ) { // родительный падеж if ( ( word.substr( word.length - 4 ) === 'вики' ) || ( word.substr( word.length - 4 ) === 'Вики' ) ) { // ... } else if ( word.substr( word.length - 1 ) === 'ь' ) { word = word.substr( 0, word.length - 1 ) + 'я'; } else if ( word.substr( word.length - 2 ) === 'ия' ) { word = word.substr( 0, word.length - 2 ) + 'ии'; } else if ( word.substr( word.length - 2 ) === 'ка' ) { word = word.substr( 0, word.length - 2 ) + 'ки'; } else if ( word.substr( word.length - 2 ) === 'ти' ) { word = word.substr( 0, word.length - 2 ) + 'тей'; } else if ( word.substr( word.length - 2 ) === 'ды' ) { word = word.substr( 0, word.length - 2 ) + 'дов'; } else if ( word.substr( word.length - 3 ) === 'ник' ) { word = word.substr( 0, word.length - 3 ) + 'ника'; } } return word; } } ); }( jQuery ) ); /** * Slovenian (Slovenščina) language functions */ ( function ( $ ) { 'use strict'; $.i18n.languages.sl = $.extend( {}, $.i18n.languages['default'], { convertGrammar: function ( word, form ) { switch ( form ) { // locative case 'mestnik': word = 'o ' + word; break; // instrumental case 'orodnik': word = 'z ' + word; break; } return word; } } ); }( jQuery ) ); /** * Ukrainian (Українська) language functions */ ( function ( $ ) { 'use strict'; $.i18n.languages.uk = $.extend( {}, $.i18n.languages['default'], { convertGrammar: function ( word, form ) { switch ( form ) { case 'genitive': // родовий відмінок if ( ( word.substr( word.length - 4 ) === 'вікі' ) || ( word.substr( word.length - 4 ) === 'Вікі' ) ) { // ... } else if ( word.substr( word.length - 1 ) === 'ь' ) { word = word.substr( 0, word.length - 1 ) + 'я'; } else if ( word.substr( word.length - 2 ) === 'ія' ) { word = word.substr( 0, word.length - 2 ) + 'ії'; } else if ( word.substr( word.length - 2 ) === 'ка' ) { word = word.substr( 0, word.length - 2 ) + 'ки'; } else if ( word.substr( word.length - 2 ) === 'ти' ) { word = word.substr( 0, word.length - 2 ) + 'тей'; } else if ( word.substr( word.length - 2 ) === 'ды' ) { word = word.substr( 0, word.length - 2 ) + 'дов'; } else if ( word.substr( word.length - 3 ) === 'ник' ) { word = word.substr( 0, word.length - 3 ) + 'ника'; } break; case 'accusative': // знахідний відмінок if ( ( word.substr( word.length - 4 ) === 'вікі' ) || ( word.substr( word.length - 4 ) === 'Вікі' ) ) { // ... } else if ( word.substr( word.length - 2 ) === 'ія' ) { word = word.substr( 0, word.length - 2 ) + 'ію'; } break; } return word; } } ); }( jQuery ) ); /** * cldrpluralparser.js * A parser engine for CLDR plural rules. * * Copyright 2012 GPLV3+, Santhosh Thottingal * * @version 0.1.0-alpha * @source https://github.com/santhoshtr/CLDRPluralRuleParser * @author Santhosh Thottingal * @author Timo Tijhof * @author Amir Aharoni */ /** * Evaluates a plural rule in CLDR syntax for a number * @param rule * @param number * @return true|false|null */ function pluralRuleParser(rule, number) { /* Syntax: see http://unicode.org/reports/tr35/#Language_Plural_Rules ----------------------------------------------------------------- condition = and_condition ('or' and_condition)* and_condition = relation ('and' relation)* relation = is_relation | in_relation | within_relation | 'n' is_relation = expr 'is' ('not')? value in_relation = expr ('not')? 'in' range_list within_relation = expr ('not')? 'within' range_list expr = 'n' ('mod' value)? range_list = (range | value) (',' range_list)* value = digit+ digit = 0|1|2|3|4|5|6|7|8|9 range = value'..'value */ // Indicates current position in the rule as we parse through it. // Shared among all parsing functions below. var pos = 0; var whitespace = makeRegexParser(/^\s+/); var digits = makeRegexParser(/^\d+/); var _n_ = makeStringParser('n'); var _is_ = makeStringParser('is'); var _mod_ = makeStringParser('mod'); var _not_ = makeStringParser('not'); var _in_ = makeStringParser('in'); var _within_ = makeStringParser('within'); var _range_ = makeStringParser('..'); var _comma_ = makeStringParser(','); var _or_ = makeStringParser('or'); var _and_ = makeStringParser('and'); function debug() { /* console.log.apply(console, arguments);*/ } debug('pluralRuleParser', rule, number); // Try parsers until one works, if none work return null function choice(parserSyntax) { return function () { for (var i = 0; i < parserSyntax.length; i++) { var result = parserSyntax[i](); if (result !== null) { return result; } } return null; }; } // Try several parserSyntax-es in a row. // All must succeed; otherwise, return null. // This is the only eager one. function sequence(parserSyntax) { var originalPos = pos; var result = []; for (var i = 0; i < parserSyntax.length; i++) { var res = parserSyntax[i](); if (res === null) { pos = originalPos; return null; } result.push(res); } return result; } // Run the same parser over and over until it fails. // Must succeed a minimum of n times; otherwise, return null. function nOrMore(n, p) { return function () { var originalPos = pos; var result = []; var parsed = p(); while (parsed !== null) { result.push(parsed); parsed = p(); } if (result.length < n) { pos = originalPos; return null; } return result; }; } // Helpers -- just make parserSyntax out of simpler JS builtin types function makeStringParser(s) { var len = s.length; return function () { var result = null; if (rule.substr(pos, len) === s) { result = s; pos += len; } return result; }; } function makeRegexParser(regex) { return function () { var matches = rule.substr(pos).match(regex); if (matches === null) { return null; } pos += matches[0].length; return matches[0]; }; } function n() { var result = _n_(); if (result === null) { debug(" -- failed n"); return result; } result = parseInt(number, 10); debug(" -- passed n ", result); return result; } var expression = choice([mod, n]); function mod() { var result = sequence([n, whitespace, _mod_, whitespace, digits]); if (result === null) { debug(" -- failed mod"); return null; } debug(" -- passed mod"); return parseInt(result[0], 10) % parseInt(result[4], 10); } function not() { var result = sequence([whitespace, _not_]); if (result === null) { debug(" -- failed not"); return null; } else { return result[1]; } } function is() { var result = sequence([expression, whitespace, _is_, nOrMore(0, not), whitespace, digits]); if (result !== null) { debug(" -- passed is"); if (result[3][0] === 'not') { return result[0] !== parseInt(result[5], 10); } else { return result[0] === parseInt(result[5], 10); } } debug(" -- failed is"); return null; } function rangeList() { // range_list = (range | value) (',' range_list)* var result = sequence([choice([range, digits]), nOrMore(0, rangeTail)]); var resultList = []; if (result !== null) { resultList = resultList.concat(result[0], result[1][0]); return resultList; } debug(" -- failed rangeList"); return null; } function rangeTail() { // ',' range_list var result = sequence([_comma_, rangeList]); if (result !== null) { return result[1]; } debug(" -- failed rangeTail"); return null; } function range() { var result = sequence([digits, _range_, digits]); if (result !== null) { debug(" -- passed range"); var array = []; var left = parseInt(result[0], 10); var right = parseInt(result[2], 10); for ( i = left; i <= right; i++) { array.push(i); } return array; } debug(" -- failed range"); return null; } function _in() { // in_relation = expr ('not')? 'in' range_list var result = sequence([expression, nOrMore(0, not), whitespace, _in_, whitespace, rangeList]); if (result !== null) { debug(" -- passed _in"); var range_list = result[5]; for (var i = 0; i < range_list.length; i++) { if (parseInt(range_list[i], 10) === result[0]) { return (result[1][0] !== 'not'); } } return (result[1][0] === 'not'); } debug(" -- failed _in "); return null; } function within() { var result = sequence([expression, whitespace, _within_, whitespace, rangeList]); if (result !== null) { debug(" -- passed within "); var range_list = result[4]; return (parseInt( range_list[0],10 )<= result[0] && result[0] <= parseInt( range_list[1], 10)); } debug(" -- failed within "); return null; } var relation = choice([is, _in, within]); function and() { var result = sequence([relation, whitespace, _and_, whitespace, condition]); if (result) { debug(" -- passed and"); return result[0] && result[4]; } debug(" -- failed and"); return null; } function or() { var result = sequence([relation, whitespace, _or_, whitespace, condition]); if (result) { debug(" -- passed or"); return result[0] || result[4]; } debug(" -- failed or"); return null; } var condition = choice([and, or, relation]); function isInt(n) { return parseFloat(n) % 1 === 0; } function start() { if (!isInt(number)) { return false; } var result = condition(); return result; } var result = start(); /* * For success, the pos must have gotten to the end of the rule * and returned a non-null. * n.b. This is part of language infrastructure, so we do not throw an internationalizable message. */ if (result === null || pos !== rule.length) { // throw new Error("Parse error at position " + pos.toString() + " in input: " + rule + " result is " + result); } return result; } /* For module loaders, e.g. NodeJS, NPM */ if (typeof module !== 'undefined' && module.exports) { module.exports = pluralRuleParser; } ; // Underscore.js 1.5.2 // http://underscorejs.org // (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors // Underscore may be freely distributed under the MIT license. (function() { // Baseline setup // -------------- // Establish the root object, `window` in the browser, or `exports` on the server. var root = this; // Save the previous value of the `_` variable. var previousUnderscore = root._; // Establish the object that gets returned to break out of a loop iteration. var breaker = {}; // Save bytes in the minified (but not gzipped) version: var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; // Create quick reference variables for speed access to core prototypes. var push = ArrayProto.push, slice = ArrayProto.slice, concat = ArrayProto.concat, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty; // All **ECMAScript 5** native function implementations that we hope to use // are declared here. var nativeForEach = ArrayProto.forEach, nativeMap = ArrayProto.map, nativeReduce = ArrayProto.reduce, nativeReduceRight = ArrayProto.reduceRight, nativeFilter = ArrayProto.filter, nativeEvery = ArrayProto.every, nativeSome = ArrayProto.some, nativeIndexOf = ArrayProto.indexOf, nativeLastIndexOf = ArrayProto.lastIndexOf, nativeIsArray = Array.isArray, nativeKeys = Object.keys, nativeBind = FuncProto.bind; // Create a safe reference to the Underscore object for use below. var _ = function(obj) { if (obj instanceof _) return obj; if (!(this instanceof _)) return new _(obj); this._wrapped = obj; }; // Export the Underscore object for **Node.js**, with // backwards-compatibility for the old `require()` API. If we're in // the browser, add `_` as a global object via a string identifier, // for Closure Compiler "advanced" mode. if (typeof exports !== 'undefined') { if (typeof module !== 'undefined' && module.exports) { exports = module.exports = _; } exports._ = _; } else { root._ = _; } // Current version. _.VERSION = '1.5.2'; // Collection Functions // -------------------- // The cornerstone, an `each` implementation, aka `forEach`. // Handles objects with the built-in `forEach`, arrays, and raw objects. // Delegates to **ECMAScript 5**'s native `forEach` if available. var each = _.each = _.forEach = function(obj, iterator, context) { if (obj == null) return; if (nativeForEach && obj.forEach === nativeForEach) { obj.forEach(iterator, context); } else if (obj.length === +obj.length) { for (var i = 0, length = obj.length; i < length; i++) { if (iterator.call(context, obj[i], i, obj) === breaker) return; } } else { var keys = _.keys(obj); for (var i = 0, length = keys.length; i < length; i++) { if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return; } } }; // Return the results of applying the iterator to each element. // Delegates to **ECMAScript 5**'s native `map` if available. _.map = _.collect = function(obj, iterator, context) { var results = []; if (obj == null) return results; if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); each(obj, function(value, index, list) { results.push(iterator.call(context, value, index, list)); }); return results; }; var reduceError = 'Reduce of empty array with no initial value'; // **Reduce** builds up a single result from a list of values, aka `inject`, // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { var initial = arguments.length > 2; if (obj == null) obj = []; if (nativeReduce && obj.reduce === nativeReduce) { if (context) iterator = _.bind(iterator, context); return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); } each(obj, function(value, index, list) { if (!initial) { memo = value; initial = true; } else { memo = iterator.call(context, memo, value, index, list); } }); if (!initial) throw new TypeError(reduceError); return memo; }; // The right-associative version of reduce, also known as `foldr`. // Delegates to **ECMAScript 5**'s native `reduceRight` if available. _.reduceRight = _.foldr = function(obj, iterator, memo, context) { var initial = arguments.length > 2; if (obj == null) obj = []; if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { if (context) iterator = _.bind(iterator, context); return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); } var length = obj.length; if (length !== +length) { var keys = _.keys(obj); length = keys.length; } each(obj, function(value, index, list) { index = keys ? keys[--length] : --length; if (!initial) { memo = obj[index]; initial = true; } else { memo = iterator.call(context, memo, obj[index], index, list); } }); if (!initial) throw new TypeError(reduceError); return memo; }; // Return the first value which passes a truth test. Aliased as `detect`. _.find = _.detect = function(obj, iterator, context) { var result; any(obj, function(value, index, list) { if (iterator.call(context, value, index, list)) { result = value; return true; } }); return result; }; // Return all the elements that pass a truth test. // Delegates to **ECMAScript 5**'s native `filter` if available. // Aliased as `select`. _.filter = _.select = function(obj, iterator, context) { var results = []; if (obj == null) return results; if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context); each(obj, function(value, index, list) { if (iterator.call(context, value, index, list)) results.push(value); }); return results; }; // Return all the elements for which a truth test fails. _.reject = function(obj, iterator, context) { return _.filter(obj, function(value, index, list) { return !iterator.call(context, value, index, list); }, context); }; // Determine whether all of the elements match a truth test. // Delegates to **ECMAScript 5**'s native `every` if available. // Aliased as `all`. _.every = _.all = function(obj, iterator, context) { iterator || (iterator = _.identity); var result = true; if (obj == null) return result; if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context); each(obj, function(value, index, list) { if (!(result = result && iterator.call(context, value, index, list))) return breaker; }); return !!result; }; // Determine if at least one element in the object matches a truth test. // Delegates to **ECMAScript 5**'s native `some` if available. // Aliased as `any`. var any = _.some = _.any = function(obj, iterator, context) { iterator || (iterator = _.identity); var result = false; if (obj == null) return result; if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context); each(obj, function(value, index, list) { if (result || (result = iterator.call(context, value, index, list))) return breaker; }); return !!result; }; // Determine if the array or object contains a given value (using `===`). // Aliased as `include`. _.contains = _.include = function(obj, target) { if (obj == null) return false; if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; return any(obj, function(value) { return value === target; }); }; // Invoke a method (with arguments) on every item in a collection. _.invoke = function(obj, method) { var args = slice.call(arguments, 2); var isFunc = _.isFunction(method); return _.map(obj, function(value) { return (isFunc ? method : value[method]).apply(value, args); }); }; // Convenience version of a common use case of `map`: fetching a property. _.pluck = function(obj, key) { return _.map(obj, function(value){ return value[key]; }); }; // Convenience version of a common use case of `filter`: selecting only objects // containing specific `key:value` pairs. _.where = function(obj, attrs, first) { if (_.isEmpty(attrs)) return first ? void 0 : []; return _[first ? 'find' : 'filter'](obj, function(value) { for (var key in attrs) { if (attrs[key] !== value[key]) return false; } return true; }); }; // Convenience version of a common use case of `find`: getting the first object // containing specific `key:value` pairs. _.findWhere = function(obj, attrs) { return _.where(obj, attrs, true); }; // Return the maximum element or (element-based computation). // Can't optimize arrays of integers longer than 65,535 elements. // See [WebKit Bug 80797](https://bugs.webkit.org/show_bug.cgi?id=80797) _.max = function(obj, iterator, context) { if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { return Math.max.apply(Math, obj); } if (!iterator && _.isEmpty(obj)) return -Infinity; var result = {computed : -Infinity, value: -Infinity}; each(obj, function(value, index, list) { var computed = iterator ? iterator.call(context, value, index, list) : value; computed > result.computed && (result = {value : value, computed : computed}); }); return result.value; }; // Return the minimum element (or element-based computation). _.min = function(obj, iterator, context) { if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { return Math.min.apply(Math, obj); } if (!iterator && _.isEmpty(obj)) return Infinity; var result = {computed : Infinity, value: Infinity}; each(obj, function(value, index, list) { var computed = iterator ? iterator.call(context, value, index, list) : value; computed < result.computed && (result = {value : value, computed : computed}); }); return result.value; }; // Shuffle an array, using the modern version of the // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). _.shuffle = function(obj) { var rand; var index = 0; var shuffled = []; each(obj, function(value) { rand = _.random(index++); shuffled[index - 1] = shuffled[rand]; shuffled[rand] = value; }); return shuffled; }; // Sample **n** random values from an array. // If **n** is not specified, returns a single random element from the array. // The internal `guard` argument allows it to work with `map`. _.sample = function(obj, n, guard) { if (arguments.length < 2 || guard) { return obj[_.random(obj.length - 1)]; } return _.shuffle(obj).slice(0, Math.max(0, n)); }; // An internal function to generate lookup iterators. var lookupIterator = function(value) { return _.isFunction(value) ? value : function(obj){ return obj[value]; }; }; // Sort the object's values by a criterion produced by an iterator. _.sortBy = function(obj, value, context) { var iterator = lookupIterator(value); return _.pluck(_.map(obj, function(value, index, list) { return { value: value, index: index, criteria: iterator.call(context, value, index, list) }; }).sort(function(left, right) { var a = left.criteria; var b = right.criteria; if (a !== b) { if (a > b || a === void 0) return 1; if (a < b || b === void 0) return -1; } return left.index - right.index; }), 'value'); }; // An internal function used for aggregate "group by" operations. var group = function(behavior) { return function(obj, value, context) { var result = {}; var iterator = value == null ? _.identity : lookupIterator(value); each(obj, function(value, index) { var key = iterator.call(context, value, index, obj); behavior(result, key, value); }); return result; }; }; // Groups the object's values by a criterion. Pass either a string attribute // to group by, or a function that returns the criterion. _.groupBy = group(function(result, key, value) { (_.has(result, key) ? result[key] : (result[key] = [])).push(value); }); // Indexes the object's values by a criterion, similar to `groupBy`, but for // when you know that your index values will be unique. _.indexBy = group(function(result, key, value) { result[key] = value; }); // Counts instances of an object that group by a certain criterion. Pass // either a string attribute to count by, or a function that returns the // criterion. _.countBy = group(function(result, key) { _.has(result, key) ? result[key]++ : result[key] = 1; }); // Use a comparator function to figure out the smallest index at which // an object should be inserted so as to maintain order. Uses binary search. _.sortedIndex = function(array, obj, iterator, context) { iterator = iterator == null ? _.identity : lookupIterator(iterator); var value = iterator.call(context, obj); var low = 0, high = array.length; while (low < high) { var mid = (low + high) >>> 1; iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; } return low; }; // Safely create a real, live array from anything iterable. _.toArray = function(obj) { if (!obj) return []; if (_.isArray(obj)) return slice.call(obj); if (obj.length === +obj.length) return _.map(obj, _.identity); return _.values(obj); }; // Return the number of elements in an object. _.size = function(obj) { if (obj == null) return 0; return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; }; // Array Functions // --------------- // Get the first element of an array. Passing **n** will return the first N // values in the array. Aliased as `head` and `take`. The **guard** check // allows it to work with `_.map`. _.first = _.head = _.take = function(array, n, guard) { if (array == null) return void 0; return (n == null) || guard ? array[0] : slice.call(array, 0, n); }; // Returns everything but the last entry of the array. Especially useful on // the arguments object. Passing **n** will return all the values in // the array, excluding the last N. The **guard** check allows it to work with // `_.map`. _.initial = function(array, n, guard) { return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); }; // Get the last element of an array. Passing **n** will return the last N // values in the array. The **guard** check allows it to work with `_.map`. _.last = function(array, n, guard) { if (array == null) return void 0; if ((n == null) || guard) { return array[array.length - 1]; } else { return slice.call(array, Math.max(array.length - n, 0)); } }; // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. // Especially useful on the arguments object. Passing an **n** will return // the rest N values in the array. The **guard** // check allows it to work with `_.map`. _.rest = _.tail = _.drop = function(array, n, guard) { return slice.call(array, (n == null) || guard ? 1 : n); }; // Trim out all falsy values from an array. _.compact = function(array) { return _.filter(array, _.identity); }; // Internal implementation of a recursive `flatten` function. var flatten = function(input, shallow, output) { if (shallow && _.every(input, _.isArray)) { return concat.apply(output, input); } each(input, function(value) { if (_.isArray(value) || _.isArguments(value)) { shallow ? push.apply(output, value) : flatten(value, shallow, output); } else { output.push(value); } }); return output; }; // Flatten out an array, either recursively (by default), or just one level. _.flatten = function(array, shallow) { return flatten(array, shallow, []); }; // Return a version of the array that does not contain the specified value(s). _.without = function(array) { return _.difference(array, slice.call(arguments, 1)); }; // Produce a duplicate-free version of the array. If the array has already // been sorted, you have the option of using a faster algorithm. // Aliased as `unique`. _.uniq = _.unique = function(array, isSorted, iterator, context) { if (_.isFunction(isSorted)) { context = iterator; iterator = isSorted; isSorted = false; } var initial = iterator ? _.map(array, iterator, context) : array; var results = []; var seen = []; each(initial, function(value, index) { if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { seen.push(value); results.push(array[index]); } }); return results; }; // Produce an array that contains the union: each distinct element from all of // the passed-in arrays. _.union = function() { return _.uniq(_.flatten(arguments, true)); }; // Produce an array that contains every item shared between all the // passed-in arrays. _.intersection = function(array) { var rest = slice.call(arguments, 1); return _.filter(_.uniq(array), function(item) { return _.every(rest, function(other) { return _.indexOf(other, item) >= 0; }); }); }; // Take the difference between one array and a number of other arrays. // Only the elements present in just the first array will remain. _.difference = function(array) { var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); return _.filter(array, function(value){ return !_.contains(rest, value); }); }; // Zip together multiple lists into a single array -- elements that share // an index go together. _.zip = function() { var length = _.max(_.pluck(arguments, "length").concat(0)); var results = new Array(length); for (var i = 0; i < length; i++) { results[i] = _.pluck(arguments, '' + i); } return results; }; // Converts lists into objects. Pass either a single array of `[key, value]` // pairs, or two parallel arrays of the same length -- one of keys, and one of // the corresponding values. _.object = function(list, values) { if (list == null) return {}; var result = {}; for (var i = 0, length = list.length; i < length; i++) { if (values) { result[list[i]] = values[i]; } else { result[list[i][0]] = list[i][1]; } } return result; }; // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), // we need this function. Return the position of the first occurrence of an // item in an array, or -1 if the item is not included in the array. // Delegates to **ECMAScript 5**'s native `indexOf` if available. // If the array is large and already in sort order, pass `true` // for **isSorted** to use binary search. _.indexOf = function(array, item, isSorted) { if (array == null) return -1; var i = 0, length = array.length; if (isSorted) { if (typeof isSorted == 'number') { i = (isSorted < 0 ? Math.max(0, length + isSorted) : isSorted); } else { i = _.sortedIndex(array, item); return array[i] === item ? i : -1; } } if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); for (; i < length; i++) if (array[i] === item) return i; return -1; }; // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. _.lastIndexOf = function(array, item, from) { if (array == null) return -1; var hasIndex = from != null; if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); } var i = (hasIndex ? from : array.length); while (i--) if (array[i] === item) return i; return -1; }; // Generate an integer Array containing an arithmetic progression. A port of // the native Python `range()` function. See // [the Python documentation](http://docs.python.org/library/functions.html#range). _.range = function(start, stop, step) { if (arguments.length <= 1) { stop = start || 0; start = 0; } step = arguments[2] || 1; var length = Math.max(Math.ceil((stop - start) / step), 0); var idx = 0; var range = new Array(length); while(idx < length) { range[idx++] = start; start += step; } return range; }; // Function (ahem) Functions // ------------------ // Reusable constructor function for prototype setting. var ctor = function(){}; // Create a function bound to a given object (assigning `this`, and arguments, // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if // available. _.bind = function(func, context) { var args, bound; if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); if (!_.isFunction(func)) throw new TypeError; args = slice.call(arguments, 2); return bound = function() { if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); ctor.prototype = func.prototype; var self = new ctor; ctor.prototype = null; var result = func.apply(self, args.concat(slice.call(arguments))); if (Object(result) === result) return result; return self; }; }; // Partially apply a function by creating a version that has had some of its // arguments pre-filled, without changing its dynamic `this` context. _.partial = function(func) { var args = slice.call(arguments, 1); return function() { return func.apply(this, args.concat(slice.call(arguments))); }; }; // Bind all of an object's methods to that object. Useful for ensuring that // all callbacks defined on an object belong to it. _.bindAll = function(obj) { var funcs = slice.call(arguments, 1); if (funcs.length === 0) throw new Error("bindAll must be passed function names"); each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); return obj; }; // Memoize an expensive function by storing its results. _.memoize = function(func, hasher) { var memo = {}; hasher || (hasher = _.identity); return function() { var key = hasher.apply(this, arguments); return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); }; }; // Delays a function for the given number of milliseconds, and then calls // it with the arguments supplied. _.delay = function(func, wait) { var args = slice.call(arguments, 2); return setTimeout(function(){ return func.apply(null, args); }, wait); }; // Defers a function, scheduling it to run after the current call stack has // cleared. _.defer = function(func) { return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); }; // Returns a function, that, when invoked, will only be triggered at most once // during a given window of time. Normally, the throttled function will run // as much as it can, without ever going more than once per `wait` duration; // but if you'd like to disable the execution on the leading edge, pass // `{leading: false}`. To disable execution on the trailing edge, ditto. _.throttle = function(func, wait, options) { var context, args, result; var timeout = null; var previous = 0; options || (options = {}); var later = function() { previous = options.leading === false ? 0 : new Date; timeout = null; result = func.apply(context, args); }; return function() { var now = new Date; if (!previous && options.leading === false) previous = now; var remaining = wait - (now - previous); context = this; args = arguments; if (remaining <= 0) { clearTimeout(timeout); timeout = null; previous = now; result = func.apply(context, args); } else if (!timeout && options.trailing !== false) { timeout = setTimeout(later, remaining); } return result; }; }; // Returns a function, that, as long as it continues to be invoked, will not // be triggered. The function will be called after it stops being called for // N milliseconds. If `immediate` is passed, trigger the function on the // leading edge, instead of the trailing. _.debounce = function(func, wait, immediate) { var timeout, args, context, timestamp, result; return function() { context = this; args = arguments; timestamp = new Date(); var later = function() { var last = (new Date()) - timestamp; if (last < wait) { timeout = setTimeout(later, wait - last); } else { timeout = null; if (!immediate) result = func.apply(context, args); } }; var callNow = immediate && !timeout; if (!timeout) { timeout = setTimeout(later, wait); } if (callNow) result = func.apply(context, args); return result; }; }; // Returns a function that will be executed at most one time, no matter how // often you call it. Useful for lazy initialization. _.once = function(func) { var ran = false, memo; return function() { if (ran) return memo; ran = true; memo = func.apply(this, arguments); func = null; return memo; }; }; // Returns the first function passed as an argument to the second, // allowing you to adjust arguments, run code before and after, and // conditionally execute the original function. _.wrap = function(func, wrapper) { return function() { var args = [func]; push.apply(args, arguments); return wrapper.apply(this, args); }; }; // Returns a function that is the composition of a list of functions, each // consuming the return value of the function that follows. _.compose = function() { var funcs = arguments; return function() { var args = arguments; for (var i = funcs.length - 1; i >= 0; i--) { args = [funcs[i].apply(this, args)]; } return args[0]; }; }; // Returns a function that will only be executed after being called N times. _.after = function(times, func) { return function() { if (--times < 1) { return func.apply(this, arguments); } }; }; // Object Functions // ---------------- // Retrieve the names of an object's properties. // Delegates to **ECMAScript 5**'s native `Object.keys` _.keys = nativeKeys || function(obj) { if (obj !== Object(obj)) throw new TypeError('Invalid object'); var keys = []; for (var key in obj) if (_.has(obj, key)) keys.push(key); return keys; }; // Retrieve the values of an object's properties. _.values = function(obj) { var keys = _.keys(obj); var length = keys.length; var values = new Array(length); for (var i = 0; i < length; i++) { values[i] = obj[keys[i]]; } return values; }; // Convert an object into a list of `[key, value]` pairs. _.pairs = function(obj) { var keys = _.keys(obj); var length = keys.length; var pairs = new Array(length); for (var i = 0; i < length; i++) { pairs[i] = [keys[i], obj[keys[i]]]; } return pairs; }; // Invert the keys and values of an object. The values must be serializable. _.invert = function(obj) { var result = {}; var keys = _.keys(obj); for (var i = 0, length = keys.length; i < length; i++) { result[obj[keys[i]]] = keys[i]; } return result; }; // Return a sorted list of the function names available on the object. // Aliased as `methods` _.functions = _.methods = function(obj) { var names = []; for (var key in obj) { if (_.isFunction(obj[key])) names.push(key); } return names.sort(); }; // Extend a given object with all the properties in passed-in object(s). _.extend = function(obj) { each(slice.call(arguments, 1), function(source) { if (source) { for (var prop in source) { obj[prop] = source[prop]; } } }); return obj; }; // Return a copy of the object only containing the whitelisted properties. _.pick = function(obj) { var copy = {}; var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); each(keys, function(key) { if (key in obj) copy[key] = obj[key]; }); return copy; }; // Return a copy of the object without the blacklisted properties. _.omit = function(obj) { var copy = {}; var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); for (var key in obj) { if (!_.contains(keys, key)) copy[key] = obj[key]; } return copy; }; // Fill in a given object with default properties. _.defaults = function(obj) { each(slice.call(arguments, 1), function(source) { if (source) { for (var prop in source) { if (obj[prop] === void 0) obj[prop] = source[prop]; } } }); return obj; }; // Create a (shallow-cloned) duplicate of an object. _.clone = function(obj) { if (!_.isObject(obj)) return obj; return _.isArray(obj) ? obj.slice() : _.extend({}, obj); }; // Invokes interceptor with the obj, and then returns obj. // The primary purpose of this method is to "tap into" a method chain, in // order to perform operations on intermediate results within the chain. _.tap = function(obj, interceptor) { interceptor(obj); return obj; }; // Internal recursive comparison function for `isEqual`. var eq = function(a, b, aStack, bStack) { // Identical objects are equal. `0 === -0`, but they aren't identical. // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). if (a === b) return a !== 0 || 1 / a == 1 / b; // A strict comparison is necessary because `null == undefined`. if (a == null || b == null) return a === b; // Unwrap any wrapped objects. if (a instanceof _) a = a._wrapped; if (b instanceof _) b = b._wrapped; // Compare `[[Class]]` names. var className = toString.call(a); if (className != toString.call(b)) return false; switch (className) { // Strings, numbers, dates, and booleans are compared by value. case '[object String]': // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is // equivalent to `new String("5")`. return a == String(b); case '[object Number]': // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for // other numeric values. return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); case '[object Date]': case '[object Boolean]': // Coerce dates and booleans to numeric primitive values. Dates are compared by their // millisecond representations. Note that invalid dates with millisecond representations // of `NaN` are not equivalent. return +a == +b; // RegExps are compared by their source patterns and flags. case '[object RegExp]': return a.source == b.source && a.global == b.global && a.multiline == b.multiline && a.ignoreCase == b.ignoreCase; } if (typeof a != 'object' || typeof b != 'object') return false; // Assume equality for cyclic structures. The algorithm for detecting cyclic // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. var length = aStack.length; while (length--) { // Linear search. Performance is inversely proportional to the number of // unique nested structures. if (aStack[length] == a) return bStack[length] == b; } // Objects with different constructors are not equivalent, but `Object`s // from different frames are. var aCtor = a.constructor, bCtor = b.constructor; if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && _.isFunction(bCtor) && (bCtor instanceof bCtor))) { return false; } // Add the first object to the stack of traversed objects. aStack.push(a); bStack.push(b); var size = 0, result = true; // Recursively compare objects and arrays. if (className == '[object Array]') { // Compare array lengths to determine if a deep comparison is necessary. size = a.length; result = size == b.length; if (result) { // Deep compare the contents, ignoring non-numeric properties. while (size--) { if (!(result = eq(a[size], b[size], aStack, bStack))) break; } } } else { // Deep compare objects. for (var key in a) { if (_.has(a, key)) { // Count the expected number of properties. size++; // Deep compare each member. if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; } } // Ensure that both objects contain the same number of properties. if (result) { for (key in b) { if (_.has(b, key) && !(size--)) break; } result = !size; } } // Remove the first object from the stack of traversed objects. aStack.pop(); bStack.pop(); return result; }; // Perform a deep comparison to check if two objects are equal. _.isEqual = function(a, b) { return eq(a, b, [], []); }; // Is a given array, string, or object empty? // An "empty" object has no enumerable own-properties. _.isEmpty = function(obj) { if (obj == null) return true; if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; for (var key in obj) if (_.has(obj, key)) return false; return true; }; // Is a given value a DOM element? _.isElement = function(obj) { return !!(obj && obj.nodeType === 1); }; // Is a given value an array? // Delegates to ECMA5's native Array.isArray _.isArray = nativeIsArray || function(obj) { return toString.call(obj) == '[object Array]'; }; // Is a given variable an object? _.isObject = function(obj) { return obj === Object(obj); }; // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { _['is' + name] = function(obj) { return toString.call(obj) == '[object ' + name + ']'; }; }); // Define a fallback version of the method in browsers (ahem, IE), where // there isn't any inspectable "Arguments" type. if (!_.isArguments(arguments)) { _.isArguments = function(obj) { return !!(obj && _.has(obj, 'callee')); }; } // Optimize `isFunction` if appropriate. if (typeof (/./) !== 'function') { _.isFunction = function(obj) { return typeof obj === 'function'; }; } // Is a given object a finite number? _.isFinite = function(obj) { return isFinite(obj) && !isNaN(parseFloat(obj)); }; // Is the given value `NaN`? (NaN is the only number which does not equal itself). _.isNaN = function(obj) { return _.isNumber(obj) && obj != +obj; }; // Is a given value a boolean? _.isBoolean = function(obj) { return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; }; // Is a given value equal to null? _.isNull = function(obj) { return obj === null; }; // Is a given variable undefined? _.isUndefined = function(obj) { return obj === void 0; }; // Shortcut function for checking if an object has a given property directly // on itself (in other words, not on a prototype). _.has = function(obj, key) { return hasOwnProperty.call(obj, key); }; // Utility Functions // ----------------- // Run Underscore.js in *noConflict* mode, returning the `_` variable to its // previous owner. Returns a reference to the Underscore object. _.noConflict = function() { root._ = previousUnderscore; return this; }; // Keep the identity function around for default iterators. _.identity = function(value) { return value; }; // Run a function **n** times. _.times = function(n, iterator, context) { var accum = Array(Math.max(0, n)); for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); return accum; }; // Return a random integer between min and max (inclusive). _.random = function(min, max) { if (max == null) { max = min; min = 0; } return min + Math.floor(Math.random() * (max - min + 1)); }; // List of HTML entities for escaping. var entityMap = { escape: { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' } }; entityMap.unescape = _.invert(entityMap.escape); // Regexes containing the keys and values listed immediately above. var entityRegexes = { escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') }; // Functions for escaping and unescaping strings to/from HTML interpolation. _.each(['escape', 'unescape'], function(method) { _[method] = function(string) { if (string == null) return ''; return ('' + string).replace(entityRegexes[method], function(match) { return entityMap[method][match]; }); }; }); // If the value of the named `property` is a function then invoke it with the // `object` as context; otherwise, return it. _.result = function(object, property) { if (object == null) return void 0; var value = object[property]; return _.isFunction(value) ? value.call(object) : value; }; // Add your own custom functions to the Underscore object. _.mixin = function(obj) { each(_.functions(obj), function(name) { var func = _[name] = obj[name]; _.prototype[name] = function() { var args = [this._wrapped]; push.apply(args, arguments); return result.call(this, func.apply(_, args)); }; }); }; // Generate a unique integer id (unique within the entire client session). // Useful for temporary DOM ids. var idCounter = 0; _.uniqueId = function(prefix) { var id = ++idCounter + ''; return prefix ? prefix + id : id; }; // By default, Underscore uses ERB-style template delimiters, change the // following template settings to use alternative delimiters. _.templateSettings = { evaluate : /<%([\s\S]+?)%>/g, interpolate : /<%=([\s\S]+?)%>/g, escape : /<%-([\s\S]+?)%>/g }; // When customizing `templateSettings`, if you don't want to define an // interpolation, evaluation or escaping regex, we need one that is // guaranteed not to match. var noMatch = /(.)^/; // Certain characters need to be escaped so that they can be put into a // string literal. var escapes = { "'": "'", '\\': '\\', '\r': 'r', '\n': 'n', '\t': 't', '\u2028': 'u2028', '\u2029': 'u2029' }; var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; // JavaScript micro-templating, similar to John Resig's implementation. // Underscore templating handles arbitrary delimiters, preserves whitespace, // and correctly escapes quotes within interpolated code. _.template = function(text, data, settings) { var render; settings = _.defaults({}, settings, _.templateSettings); // Combine delimiters into one regular expression via alternation. var matcher = new RegExp([ (settings.escape || noMatch).source, (settings.interpolate || noMatch).source, (settings.evaluate || noMatch).source ].join('|') + '|$', 'g'); // Compile the template source, escaping string literals appropriately. var index = 0; var source = "__p+='"; text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { source += text.slice(index, offset) .replace(escaper, function(match) { return '\\' + escapes[match]; }); if (escape) { source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; } if (interpolate) { source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; } if (evaluate) { source += "';\n" + evaluate + "\n__p+='"; } index = offset + match.length; return match; }); source += "';\n"; // If a variable is not specified, place data values in local scope. if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; source = "var __t,__p='',__j=Array.prototype.join," + "print=function(){__p+=__j.call(arguments,'');};\n" + source + "return __p;\n"; try { render = new Function(settings.variable || 'obj', '_', source); } catch (e) { e.source = source; throw e; } if (data) return render(data, _); var template = function(data) { return render.call(this, data, _); }; // Provide the compiled function source as a convenience for precompilation. template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; return template; }; // Add a "chain" function, which will delegate to the wrapper. _.chain = function(obj) { return _(obj).chain(); }; // OOP // --------------- // If Underscore is called as a function, it returns a wrapped object that // can be used OO-style. This wrapper holds altered versions of all the // underscore functions. Wrapped objects may be chained. // Helper function to continue chaining intermediate results. var result = function(obj) { return this._chain ? _(obj).chain() : obj; }; // Add all of the Underscore functions to the wrapper object. _.mixin(_); // Add all mutator Array functions to the wrapper. each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { var method = ArrayProto[name]; _.prototype[name] = function() { var obj = this._wrapped; method.apply(obj, arguments); if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; return result.call(this, obj); }; }); // Add all accessor Array functions to the wrapper. each(['concat', 'join', 'slice'], function(name) { var method = ArrayProto[name]; _.prototype[name] = function() { return result.call(this, method.apply(this._wrapped, arguments)); }; }); _.extend(_.prototype, { // Start chaining a wrapped Underscore object. chain: function() { this._chain = true; return this; }, // Extracts the result from a wrapped and chained object. value: function() { return this._wrapped; } }); }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["changes_list_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, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; buffer += "
\n\n
\n

\n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "changes_list.title", options) : helperMissing.call(depth0, "translate", "changes_list.title", options))) + "\n \n ( / )\n \n

\n
\n
\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n
"; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "changes_list.row.change", options) : helperMissing.call(depth0, "translate", "changes_list.row.change", options))) + ""; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "changes_list.row.title", options) : helperMissing.call(depth0, "translate", "changes_list.row.title", options))) + ""; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "changes_list.row.type", options) : helperMissing.call(depth0, "translate", "changes_list.row.type", options))) + ""; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "changes_list.row.last_changed", options) : helperMissing.call(depth0, "translate", "changes_list.row.last_changed", options))) + "
\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "changes_list.empty_result", options) : helperMissing.call(depth0, "translate", "changes_list.empty_result", options))) + "\n
\n \n
\n\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "changes_list.more", options) : helperMissing.call(depth0, "translate", "changes_list.more", options))) + "\n\n
\n
\n\n
\n"; return buffer; }); return this.InfoparkHandlebarsTemplates["changes_list_dialog"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["changes_list_row"] = 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 "\n \n"; } function program3(depth0,data) { var buffer = "", stack1; buffer += "\n \n"; return buffer; } function program5(depth0,data) { var buffer = "", stack1; buffer += "\n \n "; return buffer; } stack1 = helpers['if'].call(depth0, depth0.deleted, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n\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 "; if (stack1 = helpers.obj_class) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.obj_class; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "\n\n \n "; stack1 = helpers.unless.call(depth0, depth0.deleted, {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n \n\n"; return buffer; }); return this.InfoparkHandlebarsTemplates["changes_list_row"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["choose_obj_class_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, options, functionType="function", escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing; buffer += "
\n\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
\n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "loading", options) : helperMissing.call(depth0, "translate", "loading", options))) + "\n
\n
\n\n \n\n
\n"; return buffer; }); return this.InfoparkHandlebarsTemplates["choose_obj_class_dialog"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["choose_obj_class_list"] = 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 "; stack1 = helpers['with'].call(depth0, depth0, {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; buffer += "\n
\n "; if (stack1 = helpers.markup) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.markup; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n
\n "; return buffer; } stack1 = helpers.each.call(depth0, depth0.obj_classes, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n"; return buffer; }); return this.InfoparkHandlebarsTemplates["choose_obj_class_list"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["confirmation_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 += "\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(1, program1, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n
\n \n
\n"; return buffer; }); return this.InfoparkHandlebarsTemplates["confirmation_dialog"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["edit_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, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; 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, "edit_dialog.title", depth0.title, options) : helperMissing.call(depth0, "translate", "edit_dialog.title", depth0.title, options))) + "

\n
\n
\n\n
\n \n
\n
\n\n \n\n
\n"; return buffer; }); return this.InfoparkHandlebarsTemplates["edit_dialog"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["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, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression; buffer += "
\n
\n \n

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

\n
\n
\n
\n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "editable_ws_dialog.description", options) : helperMissing.call(depth0, "translate", "editable_ws_dialog.description", options))) + "\n
\n
\n  \n
\n
\n \n
\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
\n
\n \n
\n"; return buffer; }); return this.InfoparkHandlebarsTemplates["editable_workspace_dialog"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["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.InfoparkHandlebarsTemplates["element_overlay"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["inplace_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 += "\n
  • \n " + escapeExpression(((stack1 = depth0.icon),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + "" + escapeExpression(((stack1 = depth0.text),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + "\n
  • \n "; return buffer; } buffer += "
    \n \n
    \n"; return buffer; }); return this.InfoparkHandlebarsTemplates["inplace_menu"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["inplace_menu_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.InfoparkHandlebarsTemplates["inplace_menu_icon"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["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 CMS\n
    \n\n
    \n
    \n
    \n
    \n
    \n
    \n
    \n"; }); return this.InfoparkHandlebarsTemplates["menu_bar"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["menu_bar_close"] = 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.InfoparkHandlebarsTemplates["menu_bar_close"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["menu_bar_dropdown"] = 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, helperMissing=helpers.helperMissing; function program1(depth0,data) { return "ip_changed"; } function program3(depth0,data) { var buffer = "", stack1; buffer += "\n "; stack1 = helpers['if'].call(depth0, depth0.is_present, {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, options; 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 += ""; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.concat_translate),stack1 ? stack1.call(depth0, "menu_bar_dropdown.", depth0.name, options) : helperMissing.call(depth0, "concat_translate", "menu_bar_dropdown.", depth0.name, options))) + "\n
  • \n "; return buffer; } function program5(depth0,data) { return "disabled"; } buffer += "\n\n\n"; return buffer; }); return this.InfoparkHandlebarsTemplates["menu_bar_dropdown"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["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, options, functionType="function", escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing; buffer += "
    \n \n\n
    \n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar_toggle.view", options) : helperMissing.call(depth0, "translate", "menu_bar_toggle.view", options))) + "\n
    \n\n
    \n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar_toggle.editing", options) : helperMissing.call(depth0, "translate", "menu_bar_toggle.editing", options))) + "\n
    \n
    \n"; return buffer; }); return this.InfoparkHandlebarsTemplates["menu_bar_toggle"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["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.InfoparkHandlebarsTemplates["overlay"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["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 += "\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(1, program1, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n
    \n
    \n \n
    \n \n
    \n"; return buffer; }); return this.InfoparkHandlebarsTemplates["prompt_dialog"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["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.InfoparkHandlebarsTemplates["saving_indicator"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["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.InfoparkHandlebarsTemplates["saving_overlay"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["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.InfoparkHandlebarsTemplates["title"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["workspace_form_select_list"] = 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, helperMissing=helpers.helperMissing, self=this; function program1(depth0,data) { var buffer = "", stack1, stack2; buffer += "\n\n"; return buffer; } function program2(depth0,data) { var buffer = "", stack1; buffer += "\n " + escapeExpression(((stack1 = depth0.title),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + "\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, "menu_bar.empty_workspace_title", options) : helperMissing.call(depth0, "translate", "menu_bar.empty_workspace_title", options))) + "\n "; return buffer; } buffer += "\n"; return buffer; }); return this.InfoparkHandlebarsTemplates["workspace_form_select_list"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["workspace_select_list"] = 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, self=this, functionType="function", escapeExpression=this.escapeExpression; function program1(depth0,data) { var buffer = "", stack1, stack2; buffer += "\n "; stack1 = helpers.unless.call(depth0, depth0.is_editable, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n\n
  • \n \n \n "; stack2 = helpers['if'].call(depth0, depth0.is_editable, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data}); if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n \n " + escapeExpression(((stack1 = depth0.select_title),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + "\n "; stack2 = helpers['if'].call(depth0, depth0.is_current_workspace, {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data}); if(stack2 || stack2 === 0) { buffer += stack2; } buffer += "\n \n
  • \n"; return buffer; } function program2(depth0,data) { return "\n
  • \n "; } function program4(depth0,data) { return "\n \n "; } function program6(depth0,data) { return "\n \n "; } function program8(depth0,data) { return "\n \n "; } stack1 = helpers.each.call(depth0, depth0.workspaces, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n"; return buffer; }); return this.InfoparkHandlebarsTemplates["workspace_select_list"]; }).call(this); (function() { this.InfoparkHandlebarsTemplates || (this.InfoparkHandlebarsTemplates = {}); this.InfoparkHandlebarsTemplates["workspace_select_menu_bar_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, stack2, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, functionType="function", self=this; function program1(depth0,data) { var buffer = "", stack1, options; buffer += "\n
  • \n \n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "changes_list.menu_item", options) : helperMissing.call(depth0, "translate", "changes_list.menu_item", options))) + "\n \n
  • \n
  • \n
  • \n \n \n \n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar.publish_working_copy", depth0.current_short_title, options) : helperMissing.call(depth0, "translate", "menu_bar.publish_working_copy", depth0.current_short_title, options))) + "\n \n
  • \n
  • \n \n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar.rename_working_copy", depth0.current_short_title, options) : helperMissing.call(depth0, "translate", "menu_bar.rename_working_copy", depth0.current_short_title, options))) + "\n \n
  • \n
  • \n \n \n \n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar.rebase_working_copy", depth0.current_short_title, options) : helperMissing.call(depth0, "translate", "menu_bar.rebase_working_copy", depth0.current_short_title, options))) + "\n \n
  • \n
  • \n \n \n "; options = {hash:{},data:data}; buffer += escapeExpression(((stack1 = helpers.translate),stack1 ? stack1.call(depth0, "menu_bar.delete_working_copy", depth0.current_short_title, options) : helperMissing.call(depth0, "translate", "menu_bar.delete_working_copy", depth0.current_short_title, options))) + "\n \n
  • \n "; return buffer; } buffer += "\n"; if (stack1 = helpers.current_long_title) { stack1 = stack1.call(depth0, {hash:{},data:data}); } else { stack1 = depth0.current_long_title; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } buffer += escapeExpression(stack1) + "\n\n\n"; return buffer; }); return this.InfoparkHandlebarsTemplates["workspace_select_menu_bar_item"]; }).call(this); $.i18n().load({ 'confirm': 'Bestätigen', 'cancel': 'Abbrechen', 'save': 'Speichern', 'welcome': 'Willkommen', 'welcome_x': 'Willkommen $1', 'accept': 'Übernehmen', 'close': 'Schließen', 'loading': 'Lade...', 'current_page': 'Aktuelle Seite', 'choose_obj_class_dialog.add_child_page.title': 'Seitenvorlage auswählen', 'choose_obj_class_dialog.add_widget.title': 'Widget auswählen', 'editable_ws_dialog.title': 'Arbeitskopie auswählen oder anlegen', 'editable_ws_dialog.description': 'Veröffentlichte Inhalte können nicht direkt bearbeitet werden. Verwenden Sie eine Arbeitskopie, um Inhalte zu ändern.', 'editable_ws_dialog.choose_existing': 'Wählen Sie eine bestehende Arbeitskopie aus:', 'editable_ws_dialog.create_new': 'Oder legen Sie eine neue an:', 'editable_ws_dialog.create_new_playholder': 'Titel der neuen Arbeitskopie', 'editable_ws_dialog.select': 'Auswählen', 'edit_dialog.title': '$1 bearbeiten', 'menu_bar.working_copy': 'Arbeitskopie', 'menu_bar.empty_workspace_title': '', 'menu_bar.published_workspace_title': 'Veröffentlichte Inhalte', 'menu_bar.loading_workspaces': 'Lade Arbeitskopien', 'menu_bar.select_working_copy': '"$1" auswählen', 'menu_bar.publish_working_copy': '"$1" veröffentlichen', 'menu_bar.publish_ws_confirmation': '"$1" veröffentlichen?', 'menu_bar.publish_ws_confirmation_desc': 'Eine Arbeitskopie zu veröffentlichen ist endgültig. Dieser Vorgang kann nicht rückgängig gemacht werden.', 'menu_bar.rebase_working_copy': '"$1" aktualisieren', 'menu_bar.rename_working_copy': '"$1" umbenennen', 'menu_bar.rename_working_copy_desc': 'Bitte geben Sie den neuen Titel der Arbeitskopie ein.', 'menu_bar.rename': 'Umbenennen', 'menu_bar.delete_working_copy': '"$1" löschen', 'menu_bar.delete_ws_confirmation': 'Wirklich "$1" löschen?', 'menu_bar.delete_ws_confirmation_desc': 'Eine gelöschte Arbeitskopie kann nicht wiederhergestellt werden.', 'menu_bar.delete': 'Löschen', 'menu_bar.move': 'Verschieben', 'menu_bar.copy': 'Kopieren', 'menu_bar.create': 'Anlegen', 'menu_bar.publish': 'Veröffentlichen', 'menu_bar.create_new_working_copy': 'Arbeitskopie anlegen', 'menu_bar.create_new_ws_confirmation': 'Arbeitskopie anlegen', 'menu_bar.create_new_ws_confirmation_desc': 'Bitte geben Sie den Titel der neuen Arbeitskopie ein.', 'menu_bar.create_new_ws_confirmation_placeholder': 'Neuer Titel', 'menu_bar.revert': 'Verwerfen', 'menu_bar_toggle.editing': 'Bearbeiten', 'menu_bar_toggle.view': 'Vorschau', 'menu_bar_toggle.hide': 'Ausblenden', 'menu_bar_dropdown.edit_current_page': 'Seiteneigenschaften', 'menu_bar_dropdown.delete_current_page': 'Diese Seite löschen', 'menu_bar_dropdown.delete_current_page.workspace_is_published': 'Die veröffentlichten Inhalte können nicht direkt geändert werden.', 'menu_bar_dropdown.delete_current_page.has_children': 'Seiten mit Unterseiten können noch nicht gelöscht werden.', 'menu_bar_dropdown.revert_current_page': 'Änderungen an dieser Seite verwerfen', 'menu_bar_dropdown.save_current_page_to_clipboard': 'Diese Seite im Clipboard ablegen', 'menu_bar_dropdown.duplicate_current_page': 'Diese Seite duplizieren', 'menu_bar_dropdown.open_current_page_in_admin_gui': 'Im Admin-GUI öffnen', 'menu_bar_dropdown.deactivate_editing': 'Direktbearbeitung deaktivieren', 'menu_bar_dropdown.save_current_page_to_clipboard.has_children': 'Seiten mit Unterseiten können noch nicht verschoben oder kopiert werden.', 'menu_bar_dropdown.duplicate_current_page.has_children': 'Seiten mit Unterseiten können noch nicht dupliziert werden.', 'menu_bar_dropdown.duplicate_current_page.workspace_is_published': 'Die veröffentlichten Inhalte können nicht direkt geändert werden.', 'menu_bar_dropdown.revert_current_page.workspace_is_published': 'Die veröffentlichten Inhalte können nicht direkt geändert werden. Daher gibt es nichts zu verwerfen.', 'menu_bar_dropdown.revert_current_page.workspace_is_rtc': 'Diese Seite ist Teil der "rtc"-Arbeitskopie, bei der Änderungen nicht verworfen werden können.', 'menu_bar_dropdown.revert_current_page.obj_is_new': 'Dies ist eine neue Seite. Um die Erstellung dieser Seite rückgängig zu machen, löschen Sie sie bitte.', 'menu_bar_dropdown.revert_current_page.obj_is_deleted': 'Diese Seite wurde gelöscht. Derzeit können gelöschte Seite nicht wiederhergestellt werden.', 'menu_bar_dropdown.revert_current_page.obj_is_unchanged': 'Diese Seite wurde nicht geändert. Daher gibt es nichts zu verwerfen.', 'saving_indicator_item.saving': 'Wird gespeichert...', 'saving_indicator_item.saved': 'Änderungen gespeichert', 'child_list_menus.add_subpage': 'Neue Seite anlegen', 'child_list_menus.move_here': 'Seite im Clipboard hierher verschieben', 'child_list_menus.copy_here': 'Seite im Clipboard hier einfügen', 'widget_menus.add_widget': 'Widget einfügen', 'widget_menus.edit_widget': 'Widget-Eigenschaften', 'widget_menus.delete_widget': 'Widget löschen', 'changes_list.menu_item': 'Liste der Änderungen', 'changes_list.title': 'Änderungen', 'changes_list.empty_result': 'In dieser Arbeitskopie wurde nichts geändert.', 'changes_list.more': 'Mehr...', 'changes_list.row.change': 'Änderung', 'changes_list.row.title': 'Titel', 'changes_list.row.type': 'Typ', 'changes_list.row.last_changed': 'Letzte Änderung', 'commands.delete_obj.confirm_title': 'Wirklich diese Seite löschen?', 'commands.delete_obj.confirm_description': 'Eine gelöschte Seite kann nicht wiederhergestellt werden.', 'commands.move_obj_into.confirm_title': 'Seite im Clipboard hierher verschieben?', 'commands.move_obj_into.confirm_description': 'Die im Clipboard abgelegte Seite wird hierher verschoben.', 'commands.copy_obj_into.confirm_title': 'Seite im Clipboard hierher kopieren?', 'commands.copy_obj_into.confirm_description': 'Eine Kopie der Seite im Clipboard wird hier eingefügt.', 'commands.paste.not_allowed': 'Aufgrund ihres Typs kann die Seite hier nicht eingefügt werden.\n\nNur Seiten der folgenden Typen können hierher verschoben oder kopiert werden:\n\n$2', 'commands.delete_widget.confirm_title': 'Wirklich dieses Widget löschen?', 'commands.delete_widget.confirm_description': 'Ein gelöschtes Widget kann nicht wiederhergestellt werden.', 'commands.duplicate_obj.button_text': 'Duplizieren', 'commands.duplicate_obj.confirm_title': 'Diese Seite duplizieren?', 'commands.duplicate_obj.confirm_description': 'Diese Seite wird sofort dupliziert.', 'commands.revert_obj.confirm_title': 'Wirklich Änderungen an dieser Seite verwerfen?', 'commands.revert_obj.confirm_description': 'Verworfene Änderungen können nicht wiederhergestellt werden.', 'image_upload.too_many_files': 'Nur eine Datei erlaubt.', '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', 'loading': 'Loading...', 'current_page': 'current page', 'choose_obj_class_dialog.add_child_page.title': 'Select Page Type', 'choose_obj_class_dialog.add_widget.title': 'Select Widget', 'editable_ws_dialog.title': 'Select or create a working copy', 'editable_ws_dialog.description': 'The published content cannot be edited directly. Use a working copy to change content.', 'editable_ws_dialog.choose_existing': 'Select an existing working copy:', 'editable_ws_dialog.create_new': 'Or, create a new one:', 'editable_ws_dialog.create_new_playholder': 'new working copy title', 'editable_ws_dialog.select': 'Select', 'edit_dialog.title': 'Edit $1', 'menu_bar.working_copy': 'Working copy', 'menu_bar.empty_workspace_title': '', 'menu_bar.published_workspace_title': 'Published content', 'menu_bar.loading_workspaces': 'Loading working copies', 'menu_bar.select_working_copy': 'Select "$1"', 'menu_bar.publish_working_copy': 'Publish "$1"', 'menu_bar.publish_ws_confirmation': 'Publish "$1"?', 'menu_bar.publish_ws_confirmation_desc': 'Publishing a working copy is final. This action cannot be undone.', 'menu_bar.rebase_working_copy': 'Update "$1"', 'menu_bar.rename_working_copy': 'Rename "$1"', 'menu_bar.rename_working_copy_desc': 'Please enter the new title of the working copy.', 'menu_bar.rename': 'Rename', 'menu_bar.delete_working_copy': 'Delete "$1"', 'menu_bar.delete_ws_confirmation': 'Really delete "$1"?', 'menu_bar.delete_ws_confirmation_desc': 'A deleted working copy cannot be restored.', 'menu_bar.delete': 'Delete', 'menu_bar.create': 'Create', 'menu_bar.move': 'Move', 'menu_bar.copy': 'Copy', 'menu_bar.publish': 'Publish', 'menu_bar.create_new_working_copy': 'Create working copy', 'menu_bar.create_new_ws_confirmation': 'Create a working copy', 'menu_bar.create_new_ws_confirmation_desc': 'Please enter the title of the new working copy.', 'menu_bar.create_new_ws_confirmation_placeholder': 'new title', 'menu_bar.revert': 'Discard', 'menu_bar_toggle.editing': 'Edit', 'menu_bar_toggle.view': 'Preview', 'menu_bar_toggle.hide': 'Hide', 'menu_bar_dropdown.edit_current_page': 'Page properties', 'menu_bar_dropdown.delete_current_page': 'Delete this page', 'menu_bar_dropdown.delete_current_page.workspace_is_published': 'Since this is the published content, nothing can be modified.', 'menu_bar_dropdown.delete_current_page.has_children': 'Pages with subpages cannot be deleted yet.', 'menu_bar_dropdown.revert_current_page': 'Discard changes to this page', 'menu_bar_dropdown.save_current_page_to_clipboard': 'Place this page on the clipboard', 'menu_bar_dropdown.duplicate_current_page': 'Duplicate this page', 'menu_bar_dropdown.open_current_page_in_admin_gui': 'Open in admin GUI', 'menu_bar_dropdown.deactivate_editing': 'Deactivate in-place editing', 'menu_bar_dropdown.save_current_page_to_clipboard.has_children': 'Pages with subpages cannot be copied or moved yet.', 'menu_bar_dropdown.duplicate_current_page.has_children': 'Pages with subpages cannot be duplicated yet.', 'menu_bar_dropdown.duplicate_current_page.workspace_is_published': 'Since this is the published content, nothing can be modified.', 'menu_bar_dropdown.revert_current_page.workspace_is_published': 'Since this is the published content, nothing has been modified. Therefore, nothing can be discarded.', 'menu_bar_dropdown.revert_current_page.workspace_is_rtc': 'This page is part of the "rtc" working copy, for which discarding changes is not supported.', 'menu_bar_dropdown.revert_current_page.obj_is_new': 'This is a new page. To discard the creation of this page, please delete it.', 'menu_bar_dropdown.revert_current_page.obj_is_deleted': 'This page has been deleted. Currently, deleted pages cannot be restored.', 'menu_bar_dropdown.revert_current_page.obj_is_unchanged': 'This page has not been modified. Therefore, nothing can be discarded.', 'saving_indicator_item.saving': 'Saving...', 'saving_indicator_item.saved': 'Changes saved', 'child_list_menus.add_subpage': 'Create new page', 'child_list_menus.move_here': 'Move page on clipboard here', 'child_list_menus.copy_here': 'Copy page on clipboard here', 'widget_menus.add_widget': 'Insert widget', 'widget_menus.edit_widget': 'Widget properties', 'widget_menus.delete_widget': 'Delete widget', 'changes_list.menu_item': 'Changes List', 'changes_list.title': 'Changes', 'changes_list.empty_result': 'Nothing was changed in this working copy.', 'changes_list.more': 'More...', 'changes_list.row.change': 'Change', 'changes_list.row.title': 'Title', 'changes_list.row.type': 'Type', 'changes_list.row.last_changed': 'Last change', 'commands.delete_obj.confirm_title': 'Really delete this page?', 'commands.delete_obj.confirm_description': 'A deleted page cannot be restored.', 'commands.move_obj_into.confirm_title': 'Move page on clipboard here?', 'commands.move_obj_into.confirm_description': 'The page that has been placed on the clipboard will be moved here.', 'commands.copy_obj_into.confirm_title': 'Copy page on clipboard here?', 'commands.copy_obj_into.confirm_description': 'A copy of the page on the clipboard will be inserted here.', 'commands.paste.not_allowed': 'Due to its type, the page cannot be moved or copied here.\n\nOnly pages of the following types can be inserted here:\n\n$2', 'commands.delete_widget.confirm_title': 'Really delete this widget?', 'commands.delete_widget.confirm_description': 'A deleted widget cannot be restored.', 'commands.duplicate_obj.button_text': 'Duplicate', 'commands.duplicate_obj.confirm_title': 'Duplicate the current page?', 'commands.duplicate_obj.confirm_description': 'The current page will be duplicated immediately.', 'commands.revert_obj.confirm_title': 'Really discard changes to this page?', 'commands.revert_obj.confirm_description': 'Discarded changes cannot be restored.', 'image_upload.too_many_files': 'Only one file allowed.', '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 infopark = { suppress_alerts: false, alert: function(message) { if (!infopark.suppress_alerts) { window.alert(message); } }, change_location: function(location) { // this is a proxy method, so we can stub it easier. window.location = location; }, redirect_to: function(location) { infopark.change_location(location); // it returns an never resolved or rejected deferred. return $.Deferred(); }, wait: function(seconds) { // this is a proxy method, so we can stub it easier. return $.Deferred(function(dfd) { setTimeout(dfd.resolve, seconds * 1000); }); }, // For testing purpose only. reload_location: function() { window.location.reload(); }, reload: function() { if (infopark.write_monitor.is_writing()) { infopark.write_monitor.on('end_write', function() { infopark.reload(); }); } else { infopark.reload_location(); } return $.Deferred(); }, center: function(elem) { if (elem.length === 1) { elem.css({ marginLeft: -elem.innerWidth() / 2, marginTop: -elem.innerHeight() / 2, left: '50%' }); } }, ensure_fully_visible_within: function(elem, viewport_container, viewport_height) { var viewport_offset = viewport_container.scrollTop(); var widget_offset = elem.offset().top; var widget_height = elem.height(); if (viewport_offset > widget_offset) { viewport_container.animate({scrollTop: widget_offset - 50}); } else if (widget_offset + widget_height > viewport_offset + viewport_height) { viewport_container.animate({scrollTop: widget_height + widget_offset + 50 - viewport_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+"]"; }, add_enter_and_escape_action: function(enter_action, escape_action) { var key_actions = { 13: enter_action, // enter key 27: escape_action // escape key }; $(document).on('keyup.ip_enter_escape_action', function(e) { if (key_actions[e.keyCode]) { e.preventDefault(); key_actions[e.keyCode](e); } }); }, remove_enter_and_escape_action: function() { $(document).off('keyup.ip_enter_escape_action'); }, admin_gui_base_url: null, random_hex: function() { var hex = Math.floor(Math.random() * Math.pow(16, 8)).toString(16); while (hex.length < 8) { hex = '0' + hex; } return hex; }, deprecation_warning: function(subject, alternative) { var message = 'DEPRECATION WARNING: "' + subject + '" is deprecated.'; if (alternative) { message += ' Please use "' + alternative + '" instead.'; } window.console.warn(message); }, on: function(event, callback) { if (event === 'editing') { infopark.gui.on('editing', function() { if (infopark.gui.workspace().is_editable()) { callback(); } }); } else if (event === 'new_content') { infopark.gui.on('new_content', function(dom_element) { if (dom_element) { callback(dom_element); } }); } else { $.error('Unknown event "' + event + '"'); } }, create_obj: function(attributes) { return infopark.obj.create(attributes).then(function(obj) { return {id: obj.id()}; }); }, delete_obj: function(id) { if (id) { return infopark.obj.create_instance(id).destroy(); } else { $.error("Can't delete without ID"); } }, never_resolve: function() { return $.Deferred(); }, trigger: function(event_name, dom_element) { if (event_name === 'new_content') { _.each($(dom_element), function(e) { infopark.gui.new_content(e); }); } else { $.error('Unknown event "' + event_name + '"'); } } }; (function() { var valid_locale = ['en', 'de']; var language = 'en'; $.extend(infopark, { i18n: { locale: function() { return language; }, set_locale: function(locale) { if($.inArray(locale, valid_locale) !== -1) { language = locale; } else { language = 'en'; } }, // In addition to the key you can pass multiple parameters that will be interpolated into // the translated string. translate: function(key) { $.i18n().locale = infopark.i18n.locale(); return $.i18n.apply(0, arguments); } } }); }()); (function() { var assert_valid_dom_element = function(dom_element) { if (dom_element.length > 0) { if (dom_element.length === 1) { return true; } else { $.error('Can not call "infopark" method on more than one tag'); } } }; var build_cms_field_element = function(dom_element) { var cms_field_element = infopark.cms_element.from_dom_element(dom_element); if (cms_field_element) { return cms_field_element; } else { $.error('Can not call "infopark" method on a non-cms tag'); } }; var save_content = function(dom_element, content) { if (assert_valid_dom_element(dom_element)) { if (content === undefined) { $.error('Can not call "save" with no content'); } else { var cms_field_element = build_cms_field_element(dom_element); return cms_field_element.save(content).then(function() { cms_field_element.set_original_content(content); }); } } }; var get_original_content = function(dom_element) { if (assert_valid_dom_element(dom_element)) { return build_cms_field_element(dom_element).original_content(); } else { $.error('Can not call "infopark" method on an empty element'); } }; $.fn.infopark = function(method, content) { if (method === 'save') { return save_content($(this), content); } else if (method === 'content') { return get_original_content($(this)); } else { $.error('Unknown method "' + method + '"'); } }; }()); (function() { var state; var state_storage_key = 'gui.state'; var callbacks = {}; var current_workspace; var update_state = function(options) { infopark.storage.set(state_storage_key, $.extend(state, options)); }; var load_state = function() { state = infopark.storage.get(state_storage_key) || {is_open: false, mode: 'editing'}; }; var is_editing_mode = function() { return state.mode === 'editing'; }; var run_open_callbacks = function(options) { if (callbacks.open) { _.each(callbacks.open, function(callback) { callback(options || {}); }); } if (is_editing_mode() && callbacks.editing) { _.each(callbacks.editing, function(callback) { callback(options || {}); }); } }; var run_new_content_callbacks = function(dom_element) { if (is_editing_mode() && callbacks.new_content) { _.each(callbacks.new_content, function(callback) { if (dom_element) { callback(dom_element); } }); } }; $.extend(infopark, { gui: { initialize: function() { load_state(); if (state.is_open) { run_open_callbacks({on_initialize: true}); } $('body').append('
    '); }, open: function() { if (!state.is_open) { update_state({is_open: true}); run_open_callbacks(); } }, close: function() { update_state({is_open: false}); infopark.reload(); }, set_mode: function(mode) { update_state({mode: mode}); infopark.reload(); }, mode: function() { return state.mode; }, new_content: function(dom_element) { run_new_content_callbacks(dom_element); }, is_open: function() { return state.is_open; }, on: function(event_name, callback) { if (callbacks[event_name] === undefined) { callbacks[event_name] = []; } callbacks[event_name].push(callback); }, set_workspace: function(workspace) { current_workspace = workspace; }, workspace: function() { return current_workspace; }, // for testing purposes only reset_callbacks: function() { callbacks = {}; } } }); }()); // This module is only for backwards compatibility reasons. (function() { $.extend(infopark, { editing: { activate: function() { infopark.deprecation_warning('infopark.editing.activate', 'infopark.gui.open'); infopark.gui.open(); }, deactivate: function() { infopark.deprecation_warning('infopark.editing.deactivate', 'infopark.gui.close'); infopark.gui.close(); }, is_active: function() { infopark.deprecation_warning('infopark.editing.is_active', 'infopark.gui.is_open'); return infopark.gui.is_open(); } } }); }()); (function() { var handle_task = function(task) { switch (task.status) { case 'success': return $.Deferred().resolve(task.result); case 'error': return $.Deferred().reject(task.message); case 'open': return infopark.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 + '/__ipcms/'; if (options && options.data) { options.data = JSON.stringify(options.data); } return $.ajax(base_url + path, $.extend(options || {}, { type: type, dataType: 'json', contentType: 'application/json; charset=utf-8', cache: false // Don't cache GET requests. })).then( function(result, text_status, xhr) { return $.Deferred().resolve(result); }, function(xhr, text_status, error) { var error_message; try { error_message = JSON.parse(xhr.responseText).error; } catch (SyntaxError) {} if (!error_message) { error_message = error; } return $.Deferred().reject(error_message); } ); }; $.extend(infopark, { ajax: function(type, path, options) { var is_write_request = type === 'PUT' || type === 'POST' || type === 'DELETE'; if (is_write_request) { infopark.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); } }); var promise = ajax_promise.fail(function(error_message) { infopark.alert(error_message); }); if (is_write_request) { promise = promise.always(function() { infopark.write_monitor.end_write(); }); } return promise; } }); }()); (function() { var callbacks = {}; var current_token = 0; var counter = 0; var run_callbacks = function(event_name) { _.each(callbacks[event_name], function(callback) { callback(); }); }; $.extend(infopark, { 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() { run_callbacks('start_write'); counter += 1; }, end_write: function() { counter -= 1; run_callbacks('end_write'); }, // For test purpose only. reset_callbacks: function() { callbacks = {}; current_token = 0; }, // For test purpose only. reset_counter: function() { counter = 0; } } }); }()); (function() { var fade_time = 500; var menu_bar_items_renderer = []; var add_menu_bar = function(skip_fade) { var body = $('body'); body.addClass('ip_editing_active'); var view = $(infopark.template.render('menu_bar')); _.each(menu_bar_items_renderer, function(item_renderer) { item_renderer(view); }); view.hide(); body.append(view); if (skip_fade) { view.show(); } else { view.slideDown(fade_time); } }; $.extend(infopark, { menu_bar: { register_item_renderer: function(item_renderer) { menu_bar_items_renderer.push(item_renderer); }, init: function() { infopark.gui.on('open', function(options) { add_menu_bar(options.on_initialize === true); }); }, // For test purpose only. remove: function() { var dom_item = $('.ip_topbar'); dom_item.slideUp(fade_time, function() { dom_item.remove(); }); $('body').removeClass('ip_editing_active'); }, // For test purpose only. reset_items_renderer: function() { menu_bar_items_renderer = []; } } }); }()); (function() { $.extend(infopark, { menu_bar_saving_indicator: { init: function() { infopark.menu_bar.register_item_renderer(function(parent_view) { infopark.saving_indicator.create(parent_view.find('#ip_menu_bar_saving_indicator')); }); } } }); }()); (function() { $.extend(infopark, { menu_bar_toggle: { init: function() { infopark.menu_bar.register_item_renderer(function(menu_bar) { var menu_bar_toggle = menu_bar.find('#ip_menu_bar_toggle') .html(infopark.template.render('menu_bar_toggle', {mode: infopark.gui.mode()})); define_mode(menu_bar_toggle, 'view', function() { infopark.gui.set_mode('view'); }); define_mode(menu_bar_toggle, 'editing', function() { infopark.gui.set_mode('editing'); }); }); } } }); var define_mode = function(menu_bar_toggle, mode, callback) { var new_class = 'ip_viewmode_' + mode + '_active'; var view_modes = menu_bar_toggle.find('.ip_viewmodes'); if (!view_modes.hasClass(new_class)) { menu_bar_toggle.find('.ip_viewmode_' + mode).click(function() { view_modes .removeClass('ip_viewmode_editing_active ip_viewmode_view_active ip_viewmode_hide_active') .addClass(new_class); callback(); }); } }; }()); (function() { $.extend(infopark, { menu_bar_dropdown: { init: function() { infopark.menu_bar.register_item_renderer(function(menu_bar) { var view = infopark.template.render('menu_bar_dropdown', { dropdown_items: dropdown_items, is_current_page_changed: function() { var current_page_modification = infopark.obj.current_page_modification; return current_page_modification === 'new' || current_page_modification === 'edited'; } }); var menu_bar_dropdown = menu_bar.find('#ip_menu_bar_dropdown').html(view); menu_bar_dropdown.click(function() { menu_bar_dropdown.toggleClass('active'); menu_bar_dropdown.find('.ip_menu_box').fadeToggle('50'); return false; }); _.each(dropdown_items, function(dropdown_item) { menu_bar_dropdown.find('#ip_' + dropdown_item.name).click(function() { return dropdown_item.is_enabled() ? dropdown_item.execute() : false; }); }); }); } } }); var dropdown_items = [ { name: 'edit_current_page', icon: '', is_present: function() { return infopark.obj.current_page_has_edit_view; }, is_enabled: function() { return infopark.obj.current_page_has_edit_view; }, execute: function() { infopark.commands.edit_obj(infopark.obj.current_page()); } }, { name: 'save_current_page_to_clipboard', icon: '', title: function() { if (infopark.obj.current_page_has_children) { return infopark.i18n.translate( 'menu_bar_dropdown.save_current_page_to_clipboard.has_children'); } }, is_present: true, is_enabled: function() { return !infopark.obj.current_page_has_children; }, execute: function() { infopark.commands.save_obj_to_clipboard(infopark.obj.current_page()); } }, { name: 'duplicate_current_page', icon: '', title: function() { if (!infopark.gui.workspace().is_editable()) { return infopark.i18n.translate( 'menu_bar_dropdown.duplicate_current_page.workspace_is_published'); } if (infopark.obj.current_page_has_children) { return infopark.i18n.translate('menu_bar_dropdown.duplicate_current_page.has_children'); } }, is_present: function() { return infopark.obj.current_page_id; }, is_enabled: function() { return infopark.gui.workspace().is_editable() && !infopark.obj.current_page_has_children; }, execute: function() { infopark.commands.duplicate_obj(infopark.obj.current_page()); } }, { name: 'revert_current_page', icon: '', title: function() { if (!infopark.gui.workspace().is_editable()) { return infopark.i18n.translate( 'menu_bar_dropdown.revert_current_page.workspace_is_published'); } if (infopark.gui.workspace().is_rtc()) { return infopark.i18n.translate('menu_bar_dropdown.revert_current_page.workspace_is_rtc'); } if (!infopark.obj.current_page_modification) { return infopark.i18n.translate('menu_bar_dropdown.revert_current_page.obj_is_unchanged'); } if (infopark.obj.current_page_modification === 'new') { return infopark.i18n.translate('menu_bar_dropdown.revert_current_page.obj_is_new'); } if (infopark.obj.current_page_modification === 'deleted') { return infopark.i18n.translate('menu_bar_dropdown.revert_current_page.obj_is_deleted'); } }, is_present: function() { return infopark.obj.current_page_id; }, is_enabled: function() { return infopark.gui.workspace().is_editable() && !infopark.gui.workspace().is_rtc() && infopark.obj.current_page_modification === 'edited'; }, execute: function() { infopark.commands.revert_obj(infopark.obj.current_page()); } }, { name: 'delete_current_page', icon: '', title: function() { if (!infopark.gui.workspace().is_editable()) { return infopark.i18n.translate( 'menu_bar_dropdown.delete_current_page.workspace_is_published'); } if (infopark.obj.current_page_has_children) { return infopark.i18n.translate('menu_bar_dropdown.delete_current_page.has_children'); } }, is_present: function() { return infopark.obj.current_page_id; }, is_enabled: function() { return infopark.gui.workspace().is_editable() && !infopark.obj.current_page_has_children; }, execute: function() { infopark.commands.delete_obj(infopark.obj.current_page()); } }, { name: 'open_current_page_in_admin_gui', icon: '', is_present: function() { return infopark.obj.current_page_id; }, is_enabled: function() { return infopark.obj.current_page_id; }, execute: function() { infopark.commands.open_in_admin_gui(infopark.obj.current_page_id); } } ]; }()); (function() { $.extend(infopark, { menu_bar_close: { init: function() { infopark.menu_bar.register_item_renderer(function(menu_bar) { var menu_bar_close = menu_bar.find('#ip_menu_bar_close').html( infopark.template.render('menu_bar_close')); menu_bar_close.on('click', function() { infopark.gui.close(); }); }); } } }); }()); (function() { var t = infopark.i18n.translate; var workspace_title_short = function(workspace) { if (workspace.is_editable()) { if (workspace.title()) { return workspace.title(); } else { return t('menu_bar.empty_workspace_title'); } } else { return t('menu_bar.published_workspace_title'); } }; var workspace_title_long = function(workspace) { if (workspace.is_editable()) { var title = t('menu_bar.working_copy') + ': '; return title + workspace_title_short(workspace); } else { return workspace_title_short(workspace); } }; var workspace_title_select = function(workspace) { var title = workspace_title_short(workspace); return t('menu_bar.select_working_copy', title); }; var renderer = function(view) { var select_menu_view = $(infopark.template.render('workspace_select_menu_bar_item', { current_workspace: infopark.gui.workspace(), current_short_title: workspace_title_short(infopark.gui.workspace()), current_long_title: workspace_title_long(infopark.gui.workspace()) })); view.find('#ip_select_workspace').append(select_menu_view); }; var default_click_action = function(e) { e.preventDefault(); e.stopPropagation(); $('#ip_select_workspace .ip_menu_box').fadeToggle('50'); }; $(document).on("click.ip-toggle-ws-select", "#ip_select_workspace", function(e) { default_click_action(e); var replace_with_real_ws = $('#ip_select_workspace #ip_replace_with_real_ws'); if(replace_with_real_ws.length > 0) { infopark.workspace.all().done(function(workspaces) { var workspaces_where_published_is_last = _.sortBy(workspaces, function(ws) { return !ws.is_editable(); }); var handlebars_workspaces = _.map(workspaces_where_published_is_last, function(ws) { return { is_editable: ws.is_editable, long_title: workspace_title_long(ws), select_title: workspace_title_select(ws), is_current_workspace: (ws.id() === infopark.gui.workspace().id()) }; }); var ws_list_view_html = infopark.template.render('workspace_select_list', { workspaces: handlebars_workspaces }); var ws_list_view = $($.trim(ws_list_view_html)); _.each(ws_list_view.find('span'), function(dom_element, index) { $(dom_element).on('click.ip_open_workspace', function(e) { default_click_action(e); infopark.with_saving_overlay( infopark.redirect_to("?_rc-ws=" + workspaces_where_published_is_last[index].id()) ); }); }); replace_with_real_ws.replaceWith(ws_list_view); }); } }); $(document).on("click.ip-create-ws", "#ip-create-new-ws", function(e) { default_click_action(e); infopark.prompt_dialog({ icon: '', title: t('menu_bar.create_new_ws_confirmation'), description: t('menu_bar.create_new_ws_confirmation_desc'), placeholder: t('menu_bar.create_new_ws_confirmation_placeholder'), accept_button_text: t('menu_bar.create') }).done(function(title) { infopark.with_saving_overlay( infopark.workspace.create(title).then(function(new_workspace) { return infopark.redirect_to('?_rc-ws=' + new_workspace.id()); }) ); }); }); $(document).on("click.ip-publish-ws", "#ip-publish-current-ws", function(e) { default_click_action(e); infopark.confirmation_dialog({ icon: '', confirm_button_text: t('menu_bar.publish'), title: t('menu_bar.publish_ws_confirmation', workspace_title_short( infopark.gui.workspace())), description: t('menu_bar.publish_ws_confirmation_desc') }).done(function() { infopark.with_saving_overlay( infopark.gui.workspace().publish().then(function() { return infopark.redirect_to('?_rc-ws=published'); }) ); }); }); $(document).on("click.ip-rename-ws", "#ip-rename-current-ws", function(e) { default_click_action(e); infopark.prompt_dialog({ icon: '', title: t('menu_bar.rename_working_copy', infopark.gui.workspace().title()), description: t('menu_bar.rename_working_copy_desc'), value: infopark.gui.workspace().title(), accept_button_text: t('menu_bar.rename') }).done(function(new_title) { infopark.with_saving_overlay( infopark.gui.workspace().rename(new_title).then(function() { return infopark.reload(); }) ); }); }); $(document).on("click.ip-rebase-ws", "#ip-rebase-current-ws", function(e) { default_click_action(e); infopark.with_saving_overlay( infopark.gui.workspace().rebase().then(function() { return infopark.reload(); }) ); }); $(document).on("click.ip-delete-ws", "#ip-delete-current-ws", function(e) { default_click_action(e); infopark.confirmation_dialog({ icon: '', confirm_button_color: 'ip_red', confirm_button_text: t('menu_bar.delete'), title: t('menu_bar.delete_ws_confirmation', workspace_title_short( infopark.gui.workspace())), description: t('menu_bar.delete_ws_confirmation_desc') }).done(function() { infopark.with_saving_overlay( infopark.gui.workspace().destroy().then(function(new_workspace) { return infopark.redirect_to('?_rc-ws=published'); }) ); }); }); $(document).on('click', '#ip_changes_list_toggle', function(e) { e.preventDefault(); infopark.changes_dialog.open(); }); $.extend(infopark, { workspace_select: { init: function() { infopark.menu_bar.register_item_renderer(renderer); } } }); }()); (function() { $.extend(infopark, { changes_dialog: { open: function() { loaded_objs = []; total_obj_count = 0; batch = basic_batch(); view = $(infopark.template.render('changes_list_dialog')); $('#ip-editing').append(view); var next_loader = view.find('.ip_load_more'); target = view.find('#ip_changes_table_loaded'); var spinner = view.find('#ip_changes_table_loading'); var empty_result = view.find('#ip_changes_table_empty_result'); var obj_count = view.find('#ip_obj_count'); loaded_obj_count_ref = view.find('#ip_loaded_obj_count'); total_obj_count_ref = view.find('#ip_total_obj_count'); load_markup = function() { loading_in_progress = true; spinner.show(); batch.load_batch().then(function(data, next) { loading_in_progress = false; batch = next; if (!batch) { next_loader.hide(); } else { next_loader.show(); } if (data.total > 0) { loaded_objs = loaded_objs.concat(data.hits); total_obj_count = data.total; render_objs(loaded_objs); } else { empty_result.show(); } spinner.hide(); loaded_obj_count_ref.text(loaded_objs.length); total_obj_count_ref.text(total_obj_count); obj_count.show(); view.on('click.ip_link_to_obj', '.ip_link_to_obj', function(e) { var obj_id = $(e.currentTarget).attr('data-obj-id'); infopark.change_location('/' + obj_id); return false; }); }); }; next_loader.on('click', load_markup); load_markup(); activate_sorting(); var deferred = $.Deferred(); var cancel = function(e) { e.preventDefault(); infopark.dialog.close(view); deferred.resolve(); }; view.find('.ip_cancel').on('click', cancel); infopark.transition(view, function() { view.addClass('ip_show'); }).then(function() { infopark.dialog.adjust(view); }); return infopark.with_dialog_behaviour(deferred, {escape: cancel}); } } }); var batch; var view; var loaded_obj_count_ref; var total_obj_count_ref; var loaded_objs; var total_obj_count; var target; var load_markup; var loading_in_progress; var basic_batch = function() { return infopark. obj_where('_modification', 'equals', ['new', 'edited', 'deleted']). batch_size(100). order('_last_changed'). reverse_order(). format('_changes_list'). include_deleted(); }; var render_objs = function(objs) { var markup = _.map(objs, function(obj) { return infopark.template.render('changes_list_row', obj); }); target.html(markup); }; var activate_sorting = function() { var sortables = view.find('.ip_sortable'); view.on('click.ip_sortable', '.ip_sortable', function() { if (loading_in_progress) { return; } var sortable = $(this); var sorting_by = {}; sorting_by.attribute = sortable.attr('data-ip-sort-by'); var order_was_asc = sortable.hasClass('sort_up'); if (order_was_asc) { sorting_by.order = 'desc'; } else { sorting_by.order = 'asc'; } sortables.removeClass('sort_up').removeClass('sort_down'); var local_sort = function() { var objs = _.sortBy(loaded_objs, sorting_by.attribute); if (sorting_by.order === 'desc') { objs = objs.reverse(); } render_objs(objs); }; var backend_sort = function() { batch = basic_batch(); batch.order('_' + sorting_by.attribute); if (sorting_by.order === 'asc') { batch.reverse_order(); } loaded_objs = []; render_objs(loaded_objs); load_markup(); }; if (loaded_objs.length === total_obj_count) { local_sort(); } else { backend_sort(); } if (sorting_by.order === 'asc') { sortable.addClass('sort_up'); } else { sortable.addClass('sort_down'); } }); }; }()); (function() { $.extend(infopark, { blob: { create: function(file) { return get_upload_permission().then(function(permission) { infopark.write_monitor.start_write(); return upload_to_s3(file, permission).always(function() { infopark.write_monitor.end_write(); }); }); }, // For testing purpose only. get_form_data: function() { return new FormData(); } } }); var get_upload_permission = function() { return infopark.ajax('GET', 'blobs/upload_permission'); }; var upload_to_s3 = function(file, permission) { var form_data = infopark.blob.get_form_data(); _.each(permission.fields, function(value, name) { form_data.append(name, value); }); form_data.append('file', file); // File must be appended last, otherwise S3 will complain. 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; }); }; }()); (function() { $.extend(infopark, { child_list_element: { create_instance: function(cms_element) { if (cms_element.dom_element().attr('data-ip-private-child-list-path')) { var that = cms_element; var generate_path = function(){ var name = infopark.random_hex(); return that.path() + '/' + name; }; $.extend(that, { path: function() { return that.dom_element().attr('data-ip-private-child-list-path'); }, fetch_page_class_selection: function() { return infopark.ajax('GET', 'objs/page_class_selection?' + $.param({parent_path: that.path()})); }, allowed_classes: function() { return JSON.parse( that.dom_element().attr('data-ip-private-child-list-allowed-classes')); }, create_child: function(obj_class) { var path = generate_path(); return infopark.obj.create({ _path: path, _obj_class: obj_class }); }, add_child: function(child) { var path = generate_path(); return child.save({ _path: path }); } }); return that; } }, all: function() { return _.map($('[data-ip-private-child-list-path]'), function(dom_element) { return infopark.cms_element.from_dom_element($(dom_element)); }); } } }); }()); $(function() { infopark.cms_element.definitions.push(infopark.child_list_element); }); (function() { $.extend(infopark, { 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); } }; return that; }, from_dom_element: function(dom_element) { var cms_element = infopark.cms_element.create_instance(dom_element); var instance; _.find(infopark.cms_element.definitions, function(definition) { instance = definition.create_instance(cms_element); return instance; }); return instance; }, definitions: [] } }); }()); (function() { var has_original_content = function(field_type) { return _.contains([ 'enum', 'html', 'multienum', 'reference', 'referencelist', 'string', 'text' ], field_type); }; $.extend(infopark, { cms_field_element: { create_instance: function(cms_element) { var that = cms_element; $.extend(that, { field_name: function() { return that.dom_element().attr('data-ip-field-name'); }, field_type: function() { return that.dom_element().attr('data-ip-field-type'); }, obj: function() { return infopark.obj.create_instance( that.dom_element().attr('data-ip-private-field-id'), that.dom_element().attr('data-ip-field-obj-class') ); }, widget: function() { var widget_id = that.dom_element().attr('data-ip-private-field-widget-id'); if (widget_id) { return infopark.widget.create_instance(that.obj(), widget_id, that.dom_element().attr('data-ip-private-widget-obj-class')); } }, save: function(content) { if (content === undefined) { if (that.content) { content = that.content(); } else { $.error("Can't save without content"); } } var changes = {}; changes[that.field_name()] = content; var widget = that.widget(); if (widget) { return that.widget().save(changes); } else { return that.obj().save(changes); } }, original_content: function() { if (has_original_content(that.field_type())) { return JSON.parse(that.dom_element().attr('data-ip-private-field-original-content')); } 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-ip-private-field-original-content', JSON.stringify(content)); } } }); return that; } } }); }()); (function() { $.extend(infopark, { date_field_element: { create_instance: function(cms_element) { if (cms_element.dom_element().attr('data-ip-field-type') === 'date') { return infopark.cms_field_element.create_instance(cms_element); } }, all: function() { return _.map($('[data-ip-field-type="date"]'), function(dom_element) { return infopark.cms_element.from_dom_element($(dom_element)); }); } } }); infopark.cms_element.definitions.push(infopark.date_field_element); }()); (function() { $.extend(infopark, { html_field_element: { create_instance: function(cms_element) { if (cms_element.dom_element().attr('data-ip-field-type') === 'html') { var that = infopark.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-ip-field-type="html"]'), function(dom_element) { return infopark.cms_element.from_dom_element($(dom_element)); }); } } }); infopark.cms_element.definitions.push(infopark.html_field_element); }()); (function() { var format_date = function(date) { return date.getUTCFullYear().toString() + format_date_number(date.getUTCMonth() + 1) + // Month numbers are starting at 0. format_date_number(date.getUTCDate()) + format_date_number(date.getUTCHours()) + format_date_number(date.getUTCMinutes()) + format_date_number(date.getUTCSeconds()); }; var format_date_number = function(number) { var string = number.toString(); return string.length === 1 ? '0' + string : string; }; var prepare_attributes = function(data) { var attributes = {}; _.each(data, function(value, field_name) { if (value instanceof Date) { value = format_date(value); } attributes[field_name] = value; }); if (attributes.blob) { return infopark.blob.create(attributes.blob).then(function(blob_id) { attributes.blob = blob_id; return attributes; }); } else { return $.Deferred().resolve(attributes); } }; $.extend(infopark, { obj: { create_instance: function(id, obj_class_name) { var that = { id: function() { return id; }, obj_class_name: function() { return obj_class_name; }, save: function(data) { return prepare_attributes(data).then(function(attributes) { return infopark.ajax('PUT', 'objs/' + that.id(), {data: {obj: attributes}}).then( function(result) { return; } ); }); }, destroy: function() { return infopark.ajax('DELETE', 'objs/' + that.id()); }, revert: function() { return infopark.ajax('PUT', 'objs/' + that.id() + '/revert'); }, fetch_edit_markup: function() { return infopark.ajax('GET', 'objs/' + that.id() + '/edit').then(function(data) { return data.markup; }); }, copy_to: function(path) { var post_attr = {data: {parent_path: path}}; var url = 'objs/'+that.id()+'/copy'; return infopark.ajax('POST', url, post_attr).then(function(new_data) { return infopark.obj.create_instance(new_data.id, new_data._obj_class); }); }, duplicate: function() { return infopark.ajax('POST', 'objs/'+that.id()+'/duplicate').then(function(new_data) { return infopark.obj.create_instance(new_data.id, new_data._obj_class); }); } }; return that; }, create: function(data) { return prepare_attributes(data).then(function(attributes) { return infopark.ajax('POST', 'objs', {data: {obj: attributes}}).then(function(new_data) { return infopark.obj.create_instance(new_data.id, new_data._obj_class); }); }); }, current_page_id: null, current_page_obj_class_name: null, current_page: function() { if (infopark.obj.current_page_id) { return infopark.obj.create_instance(infopark.obj.current_page_id, infopark.obj.current_page_obj_class_name); } }, current_page_has_edit_view: false, current_page_has_children: false } }); }()); (function() { $.extend(infopark, { chainable_search: { create_instance: function(build_query) { // Private var query = build_query || { predicates: [] }; var add_predicate = function(field, operator, value, boost, negate) { var new_query = { field: field, operator: operator, value: 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 infopark.ajax('GET', 'objs/search?' + $.param({query: JSON.stringify(query), query_action: action})); }; // Public var that = { query: function() { return query; }, and: function(field, operator, value, boost) { add_predicate(field, operator, value, boost); return that; }, and_not: function(field, operator, value) { add_predicate(field, operator, value, undefined, true); return that; }, offset: function(offset) { query.offset = offset; return that; }, order: function(order) { query.order = order; return that; }, reverse_order: function() { if (query.reverse_order) { delete query.reverse_order; } else { query.reverse_order = true; } return that; }, batch_size: function(batch_size) { query.batch_size = batch_size; return that; }, format: function(name) { query.format = name; return that; }, include_deleted: function() { query.include_deleted = true; return that; }, 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 = infopark.chainable_search.create_instance(next_query); } else { next = undefined; } return $.Deferred().resolve(result, next); }); }, size: function() { return execute_search(query, 'size').then(function(result) { return $.Deferred().resolve(result.total); }); } }; return that; } } }); }()); (function() { $.extend(infopark, { obj_where: function(field, operator, value, boost) { return infopark.chainable_search.create_instance().and(field, operator, value, boost); } }); }()); (function() { var field_types = [ 'binary', 'enum', 'linklist', 'multienum', 'reference', 'referencelist', 'text' ]; $.extend(infopark, { standard_field_element: { create_instance: function(cms_element) { if (_.include(field_types, cms_element.dom_element().attr('data-ip-field-type'))) { return infopark.cms_field_element.create_instance(cms_element); } } } }); infopark.cms_element.definitions.push(infopark.standard_field_element); }()); (function() { $.extend(infopark, { string_field_element: { create_instance: function(cms_element) { if (cms_element.dom_element().attr('data-ip-field-type') === 'string') { var that = infopark.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-ip-field-type="string"]'), function(dom_element) { return infopark.cms_element.from_dom_element($(dom_element)); }); } } }); infopark.cms_element.definitions.push(infopark.string_field_element); }()); (function() { $.extend(infopark, { widget: { create_instance: function(obj, id, widget_class_name) { var that = { id: function() { return id; }, obj: function() { return obj; }, widget_class_name: function() { return widget_class_name; }, save: function(widget_attributes) { return that.obj().save(build_obj_attributes(widget_attributes)); }, destroy: function() { return that.obj().save(build_obj_attributes(null)); } }; var build_obj_attributes = function(widget_attributes) { var obj_attributes = {_widget_pool: {}}; obj_attributes._widget_pool[that.id()] = widget_attributes; return obj_attributes; }; return that; } } }); }()); (function() { $.extend(infopark, { widget_element: { create_instance: function(cms_element) { if (cms_element.dom_element().attr('data-ip-private-widget-id')) { var that = cms_element; $.extend(that, { widget: function() { return infopark.widget.create_instance(that.widget_field().obj(), that.dom_element().attr('data-ip-private-widget-id'), that.dom_element().attr('data-ip-private-widget-obj-class') ); }, widget_field: function() { return infopark.cms_element.from_dom_element(that.dom_element().parent()); }, has_edit_view: function() { return that.dom_element().attr('data-ip-private-widget-has-edit-view') ? true : false; }, fetch_edit_markup: function() { var url = 'objs/' + that.widget().obj().id() + '/edit_widget?' + $.param({ widget_id: that.widget().id() }); return infopark.ajax('GET', url).then(function(data) { return data.markup; }); }, fetch_show_markup: function() { var url = 'objs/' + that.widget().obj().id() + '/show_widget?' + $.param({ widget_id: that.widget().id(), current_page_id: infopark.obj.current_page().id(), field_name: that.field_name() }); return infopark.ajax('GET', url).then(function(data) { return data.markup; }); }, field_name: function() { return that.widget_field().field_name(); } }); return that; } } } }); infopark.cms_element.definitions.push(infopark.widget_element); }()); (function() { $.extend(infopark, { widget_field_element: { create_instance: function(cms_element) { if (cms_element.dom_element().attr('data-ip-field-type') === 'widget') { var that = infopark.cms_field_element.create_instance(cms_element); $.extend(that, { content: function() { return {list: _.map(that.widget_elements(), function(widget_element) { return {widget: widget_element.widget().id()}; })}; }, widget_elements: function() { var widget_elements_dom = that.dom_element().children('[data-ip-private-widget-id]'); var widget_elements = _.map(widget_elements_dom, function(widget_element_dom) { return infopark.cms_element.from_dom_element($(widget_element_dom)); }); return widget_elements; }, create_widget: function(widget_class) { var url = 'objs/' + that.obj().id() + '/create_widget'; var data = { obj_class: widget_class, current_page_id: infopark.obj.current_page().id(), field_name: that.field_name() }; return infopark.ajax('POST', url, {data: data}); }, fetch_widget_class_selection: function() { return infopark.ajax('GET', 'objs/' + that.obj().id() + '/widget_class_selection?' + $.param({field_name: that.field_name()})); } }); return that; } }, all: function() { return _.map($('[data-ip-field-type="widget"]'), function(dom_element) { return infopark.cms_element.from_dom_element($(dom_element)); }); } } }); infopark.cms_element.definitions.push(infopark.widget_field_element); }()); (function() { $.extend(infopark, { workspace: { from_data: function(data) { var that = { id: function() { return data.id; }, title: function() { return data.title; }, is_editable: function() { return that.id() !== 'published'; }, is_rtc: function() { return that.id() === 'rtc'; }, publish: function() { if (that.is_editable()) { return infopark.ajax('PUT', 'workspaces/' + that.id() + '/publish'); } else { throw "publish not allowed for already published contents"; } }, rebase: function() { if (that.is_editable()) { return infopark.ajax('PUT', 'workspaces/' + that.id() + '/rebase'); } else { throw "rebase not allowed for already published contents"; } }, rename: function(new_title) { return infopark.ajax('PUT', 'workspaces/' + that.id(), {data: {workspace: {title: new_title}}}); }, destroy: function() { return infopark.ajax('DELETE', 'workspaces/' + that.id()); } }; return that; }, all: function() { return infopark.ajax('GET', 'workspaces').then(function(ws_data) { var workspaces = _.map(ws_data.results, function(workspace) { return infopark.workspace.from_data(workspace); }); var sorted_workspaces = _.sortBy(workspaces, function(ws) { return (ws.title() || '').toUpperCase(); }); return sorted_workspaces; }); }, all_editable: function() { return infopark.workspace.all().then(function(workspaces) { return _.select(workspaces, function(workspace) { return workspace.is_editable(); }); }); }, create: function(title) { return infopark.ajax('POST', 'workspaces', {data: {workspace: {title: title}}}). then(function(ws_data) { return infopark.workspace.from_data(ws_data); }); } } }); }()); (function() { infopark.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 !!infopark.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 = '_infopark_'; var full_key = function(key_suffix) { return storage_key_prefix + key_suffix; }; })(); (function() { $.extend(infopark, { /* * 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 (!infopark.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(infopark.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("ip-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("ip-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("ip_height_done"); }; var sibling_height_changes = function(elem) { return _(relevant_siblings_for(elem)).map(function(sibling) { sibling = $(sibling); var last = sibling.data("ip-last_outer_height"); var actual = sibling.outerHeight(true); if (last !== actual) { return infopark.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("ip-last_inner_height"); var actual = parent.innerHeight(); if (last !== actual) { return infopark.describe_element(parent) + " unexpectantly changed it's height from " + (last || "") + " to " + actual ; } }; $.extend(infopark, { update_auto_height_for: function(root_element) { var elements = root_element.find('.ip_auto_height:visible'); if (root_element.hasClass("ip_auto_height")) { elements = elements.add(root_element); } elements.not(".ip_height_done").each(function (i, elem) { set_auto_height_for($(elem)); }); }, invalidate_auto_height: function() { $(".ip_height_done").removeClass("ip_height_done"); auto_height_dirty = true; }, invalidate_auto_height_for: function(elem) { elem.find(".ip_height_done").removeClass("ip_height_done"); }, process_auto_height: function() { if (auto_height_dirty) { infopark.update_auto_height_for($("body")); auto_height_dirty = false; } }, auto_height_errors: function() { return _($(".ip_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("ip_height_done")) { return [infopark.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 InfoparkHandlebarsTemplates:false */ /*global Handlebars:false */ (function() { Handlebars.registerHelper('translate', infopark.i18n.translate); Handlebars.registerHelper('concat_translate', function(key_prefix, key) { // Temporary workaround. // The `handlebars_assets` gem as of the version `0.15` bundles the version `1.2.2` // of the Handlebars. Subexpressions are supported from the Handlebars version `1.3.0` on. return infopark.i18n.translate(key_prefix + key); }); $.extend(infopark, { template: { load_templates_from_server: false, render: function(template_path, data) { var template; if(typeof InfoparkHandlebarsTemplates !== 'undefined') { template = InfoparkHandlebarsTemplates[template_path]; } if(template === undefined) { if(infopark.template.load_templates_from_server) { var url = "/app/assets/javascripts/templates/" + template_path + ".hbs?" + Math.random(); var source = jQuery.ajax(url, { async: false }).responseText; template = Handlebars.compile(source); } else { throw('could not load template' + template_path); } } return template(data); } } }); }()); (function() { var view; $.extend(infopark, { with_overlay: function(promise) { infopark.overlay.show(); return promise.always(function() { infopark.overlay.hide(); }); }, overlay: { show: function() { if (!view) { view = $(infopark.template.render('overlay')); $('#ip-editing').append(view); } infopark.transition(view, function() { view.addClass('ip_show'); }); }, hide: function() { if (view) { infopark.transition(view, function() { view.removeClass('ip_show'); }).then(function() { view.remove(); view = null; }); } }, // Test purpose only. remove_all: function() { $('.ip_overlay').remove(); view = null; } } }); }()); (function() { var view; $.extend(infopark, { with_saving_overlay: function(promise) { infopark.saving_overlay.show(); return promise.always(function() { infopark.saving_overlay.hide(); }); }, saving_overlay: { show: function() { if (!view) { view = $(infopark.template.render('saving_overlay')); $('#ip-editing').append(view); } infopark.transition(view, function() { view.addClass('ip_show'); }); }, hide: function() { if (view) { infopark.transition(view, function() { view.removeClass('ip_show'); }).then(function(e) { // Remove the view only if event is triggered by a "fade-out" transition. if (e && $(e.target).hasClass('ip_show')) { return; } view.remove(); view = null; }); } }, // Test purpose only. remove_all: function() { $('.ip_saving_overlay').remove(); view = null; } } }); return infopark; }()); (function() { $.extend(infopark, { saving_indicator: { create: function(parent_view) { var target_selector = '.ip_saving_indicator'; var saving_in_progress_selector = target_selector + ' .ip_saving_in_progress'; var saving_done_selector = target_selector + ' .ip_saving_done'; parent_view.append(infopark.template.render('saving_indicator')); var start_write_token = infopark.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 = infopark.write_monitor.on('end_write', function() { if (!infopark.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 (!infopark.transition.immediate_mode) { setTimeout(function() { saving_done_element.fadeOut(1000); }, 3000); } } }); return { destroy: function() { infopark.write_monitor.off(start_write_token); infopark.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(infopark, { with_element_overlay: function(dom_element, promise) { var element_overlay = infopark.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 = $(infopark.template.render('element_overlay')).css({ position: 'absolute', // Required for unit tests to pass without an extra CSS file. top: dom_element_position.top, left: dom_element_position.left, width: dom_element.width(), height: dom_element.height() }); dom_element.append(view); return view; } } }); }()); (function() { $.extend(infopark, { confirmation_dialog: function(options) { return infopark.confirmation_dialog.open(options); } }); var close = function(view) { infopark.transition(view, function() { view.removeClass('ip_show'); }).then(function() { view.remove(); view = null; }); }; $.extend(infopark.confirmation_dialog, { open: function(options) { if(!options.icon) { options.icon = ''; } if(!options.cancel_button_text) { options.cancel_button_text = infopark.i18n.translate('cancel'); } if(!options.confirm_button_color) { options.confirm_button_color = 'ip_blue'; } if(!options.confirm_button_text) { options.confirm_button_text = infopark.i18n.translate('confirm'); } var view = $(infopark.template.render('confirmation_dialog', options)); $('#ip-editing').append(view); var deferred = $.Deferred(); var click_action = function(e) { e.preventDefault(); close(view); }; var confirm_action = function(e) { click_action(e); deferred.resolve(); }; var cancel_action = function(e) { click_action(e); deferred.reject(); }; view.find('.ip_confirm').on('click', confirm_action); view.find('.ip_cancel').on('click', cancel_action); infopark.transition(view, function() { view.addClass('ip_show'); }); return infopark.with_dialog_behaviour(deferred, { enter: confirm_action, escape: cancel_action }); }, // Test purpose only. remove_all: function() { $('.ip_confirmation_dialog').remove(); } }); }()); (function() { $.extend(infopark, { prompt_dialog: function(options) { return infopark.prompt_dialog.open(options); } }); var close = function(view) { infopark.transition(view, function() { view.removeClass('ip_show'); }).then(function() { view.remove(); view = null; }); }; $.extend(infopark.prompt_dialog, { open: function(options) { if (!options.icon) { options.icon = ''; } if(!options.cancel_button_text) { options.cancel_button_text = infopark.i18n.translate('cancel'); } if(!options.accept_button_text) { options.accept_button_text = infopark.i18n.translate('accept'); } var view = $(infopark.template.render('prompt_dialog', options)); $('#ip-editing').append(view); var deferred = $.Deferred(); var click_action = function(e) { e.preventDefault(); close(view); }; var accept_action = function(e) { e.preventDefault(); var val = view.find('input').val(); if (val) { click_action(e); deferred.resolve(val); } }; var cancel_action = function(e) { click_action(e); deferred.reject(); }; view.find('.ip_accept').on('click', accept_action); view.find('.ip_cancel').on('click', cancel_action); infopark.transition(view, function() { view.find('input').focus(); view.addClass('ip_show'); }); return infopark.with_dialog_behaviour(deferred, { enter: accept_action, escape: cancel_action }); } }); }()); (function() { $.extend(infopark, { dialog: { close: function(view) { infopark.transition(view, function() { view.removeClass('ip_show'); }).then(function() { view.remove(); view = null; }); }, adjust: function(view) { infopark.center(view); infopark.invalidate_auto_height_for(view); infopark.update_auto_height_for(view); } } }); $(window).on('resize', function() { _.each($('.ip_adjust_dialog'), function(elem) { infopark.dialog.adjust($(elem)); }); }); }()); (function() { $.extend(infopark, { reloading: { init: function() { $('body').on('infopark_reload', function() { infopark.with_saving_overlay(infopark.reload()); }); } } }); }()); (function() { $.extend(infopark, { choose_obj_class_dialog: function(obj_classes_deferred, locale_path) { return infopark.choose_obj_class_dialog.open(obj_classes_deferred, locale_path); } }); $.extend(infopark.choose_obj_class_dialog, { open: function(obj_classes_deferred, locale_path) { var deferred = $.Deferred(); var view = $(infopark.template.render('choose_obj_class_dialog', { title: infopark.i18n.translate('choose_obj_class_dialog.' + locale_path + '.title'), description: infopark.i18n.translate('choose_obj_class_dialog.' + locale_path + '.description') })); obj_classes_deferred.done(function(obj_class_selection) { var selection_view = infopark.template.render('choose_obj_class_list', {obj_classes: obj_class_selection}); selection_view = $($.trim(selection_view)); view.find('#ip_replace_with_real_obj_classes').replaceWith(selection_view); view.on('click', '.ip_obj_class_thumbnail', function(e) { e.preventDefault(); infopark.dialog.close(view); deferred.resolve($(this).attr('data-ip-private-obj-class-name')); }); }); $('#ip-editing').append(view); var cancel_action = function(e) { e.preventDefault(); infopark.dialog.close(view); deferred.reject(); }; view.find('.ip_cancel').on('click', cancel_action); infopark.transition(view, function() { view.addClass('ip_show'); }); infopark.dialog.adjust(view); return infopark.with_dialog_behaviour(deferred, {escape: cancel_action}); } }); }()); (function() { $.extend(infopark, { edit_dialog: { open: function(title, fetch_markup, icon) { var deferred = $.Deferred(); var view = $(infopark.template.render('edit_dialog', {icon: icon || '', title: title})); $('#ip-editing').append(view); var saving_indicator = infopark.saving_indicator.create( view.find('.ip_edit_dialog_saving_indicator')); var load_markup = function() { var target = view.find('.ip_edit_dialog_markup'); var spinner = view.find('.ip_modal_body .ip_spinning'); target.hide(); spinner.show(); fetch_markup().then(function(markup) { target.html(markup); spinner.hide(); target.show(); infopark.gui.new_content(target.get(0)); }, function() { close(); }); }; view.on('infopark_reload', function() { load_markup(); return false; }); load_markup(); var close = function() { infopark.dialog.close(view); deferred.resolve(); }; var cancel = function(e) { e.preventDefault(); saving_indicator.destroy(); close(); }; view.find('.ip_cancel').on('click', cancel); infopark.transition(view, function() { view.addClass('ip_show'); }).then(function() { infopark.dialog.adjust(view); }); return infopark.with_dialog_behaviour(deferred, {escape: cancel}); } } }); }()); (function() { var menu_define_callbacks = []; var dom_elements_with_menu = []; var fade_time = 500; $.extend(infopark, { inplace_menus: { define: function(menu_define_callback) { menu_define_callbacks.push(menu_define_callback); }, refresh_positions: function() { _.each($('.ip_editing_marker_menu'), function(menu_dom) { var menu = $(menu_dom); var marker = $('#' + menu.data('infopark-editing-menu-icon-id')); menu.offset(marker.offset()); }); }, reset_menu_define_callbacks: function() { menu_define_callbacks = []; }, init: function() { infopark.gui.on('editing', function() { infopark.inplace_menus.refresh(); }); infopark.gui.on('new_content', function() { infopark.inplace_menus.refresh(); }); }, close_all_menus: function() { remove_menus(); }, refresh: function() { remove_markers_and_menus(); collect_menu_items(); render_menu_items(); infopark.inplace_menus.refresh_positions(); } } }); var collect_menu_items = function() { var menu = { add_item: function(dom_element, menu_item) { var element = $(dom_element); var dom_menu = (element.data('infopark-editing-menu') || []); dom_menu.push(menu_item); element.data('infopark-editing-menu', dom_menu); dom_elements_with_menu.push(element); } }; _.each($(menu_define_callbacks), function(menu_define_callback) { menu_define_callback(menu); }); }; var render_menu_items = function() { _.each($(dom_elements_with_menu), function(dom_element, menu_index) { if(dom_element.children('.ip_editing_marker').length === 0) { var menu_id = 'ip_editing_marker_menu_' + menu_index; var menu_icon_id = 'ip_editing_marker_menu_icon_' + menu_index; var dom_menu = dom_element.data('infopark-editing-menu'); var menu_icon = $(infopark.template.render('inplace_menu_icon', { menu_icon_id: menu_icon_id })); menu_icon.data('infopark-editing-menu-id', menu_id); menu_icon.on('click.ip-menu-open', function(e) { e.preventDefault(); var menu = $('#' + menu_id); var remove_menu = function() { menu.fadeOut(fade_time, function() { menu.remove(); }); }; if(menu.length === 0) { var items = _.map(dom_menu, function(menu_item) { return { icon: menu_item.icon, text: menu_item.title, css_class: menu_item.disabled ? 'ip_menu_item disabled' : 'ip_menu_item' }; }); menu = $(infopark.template.render('inplace_menu', { menu_id: menu_id, items: items })); _.each(menu.find('li'), function(menu_item, index) { $(menu_item).on('click.ip-menu-item-action', function(e){ e.preventDefault(); dom_menu[index].execute(); remove_menu(); }); }); menu.data('infopark-editing-menu-icon-id', menu_icon_id); $('body').append(menu); // Bugfix IE: offset can not be set before append. menu.offset(menu_icon.offset()); menu.find('.ip_menu_box').fadeIn(fade_time); } else { remove_menu(); } }); dom_element.prepend(menu_icon); } }); }; var remove_markers_and_menus = function() { $('.ip_editing_marker').remove(); remove_menus(); }; var remove_menus = function() { $('.ip_editing_marker_menu').fadeOut(fade_time, function() { $('.ip_editing_marker_menu').remove(); }); _.each($(dom_elements_with_menu), function(dom_element) { dom_element.removeData('infopark-editing-menu'); }); dom_elements_with_menu = []; }; }()); $(window).on('resize', function () { infopark.inplace_menus.refresh_positions(); }); $(window).on('load', function () { infopark.inplace_menus.refresh_positions(); }); (function() { $.extend(infopark, { commands: { new_child_page: function(child_list_element) { return infopark.choose_obj_class_dialog(child_list_element.fetch_page_class_selection(), 'add_child_page').then( function(obj_class) { return infopark.with_saving_overlay( child_list_element.create_child(obj_class).then(function(new_obj) { return infopark.redirect_to('/'+new_obj.id()); }) ); } ); }, edit_obj: function(obj) { var has_changes = false; var token = infopark.write_monitor.on('start_write', function() { has_changes = true; }); var title = infopark.i18n.translate('current_page'); var fetch_markup = function() { return obj.fetch_edit_markup(); }; return infopark.edit_dialog.open(title, fetch_markup, '').then(function() { infopark.write_monitor.off(token); if (has_changes) { return infopark.with_saving_overlay(infopark.reload()); } }); }, delete_obj: function(obj) { return infopark.confirmation_dialog({ icon: '', confirm_button_color: 'ip_red', confirm_button_text: infopark.i18n.translate('menu_bar.delete'), title: infopark.i18n.translate('commands.delete_obj.confirm_title'), description: infopark.i18n.translate('commands.delete_obj.confirm_description') }).then(function() { return infopark.with_saving_overlay(obj.destroy().then(function() { return infopark.redirect_to('/'); })); }); }, revert_obj: function(obj) { return infopark.confirmation_dialog({ icon: '', confirm_button_color: 'ip_red', confirm_button_text: infopark.i18n.translate('menu_bar.revert'), title: infopark.i18n.translate('commands.revert_obj.confirm_title'), description: infopark.i18n.translate('commands.revert_obj.confirm_description') }).then(function() { return infopark.with_saving_overlay(obj.revert().then(function() { infopark.reload(); })); }); }, save_obj_to_clipboard: function(obj) { infopark.clipboard.save_obj(obj); infopark.inplace_menus.refresh(); }, move_obj_into: function(child_list_element) { if (!infopark.clipboard.can_paste_into(child_list_element)) { paste_obj_not_allowed(child_list_element); } else { return infopark.confirmation_dialog({ icon: '', confirm_button_color: 'ip_green', confirm_button_text: infopark.i18n.translate('menu_bar.move'), title: infopark.i18n.translate('commands.move_obj_into.confirm_title'), description: infopark.i18n.translate('commands.move_obj_into.confirm_description') }).then(function() { var obj = infopark.clipboard.obj(); return infopark.with_saving_overlay(child_list_element.add_child(obj).then(function() { infopark.clipboard.clear(); return infopark.reload(); })); }); } }, duplicate_obj: function(obj) { return infopark.confirmation_dialog({ icon: '', confirm_button_color: 'ip_green', confirm_button_text: infopark.i18n.translate('commands.duplicate_obj.button_text'), title: infopark.i18n.translate('commands.duplicate_obj.confirm_title'), description: infopark.i18n.translate('commands.duplicate_obj.confirm_description') }).then(function(){ return infopark.with_saving_overlay(obj.duplicate().then(function(new_obj) { return infopark.redirect_to('/' + new_obj.id()); })); }); }, copy_obj_into: function(child_list_element) { if (!infopark.clipboard.can_paste_into(child_list_element)) { paste_obj_not_allowed(child_list_element); } else { return infopark.confirmation_dialog({ icon: '', confirm_button_color: 'ip_green', confirm_button_text: infopark.i18n.translate('menu_bar.copy'), title: infopark.i18n.translate('commands.copy_obj_into.confirm_title'), description: infopark.i18n.translate('commands.copy_obj_into.confirm_description') }).then(function() { var obj = infopark.clipboard.obj(); var promise = obj.copy_to(child_list_element.path()); return infopark.with_saving_overlay(promise.then(function() { infopark.clipboard.clear(); return infopark.reload(); })); }); } }, add_widget: function(widget_field_element, widget_element) { return infopark.choose_obj_class_dialog( widget_field_element.fetch_widget_class_selection(), 'add_widget').then( function(obj_class) { var dom_element; infopark.with_saving_overlay( widget_field_element.create_widget(obj_class).then(function(data) { dom_element = $(data.markup); if (widget_element) { widget_element.dom_element().after(dom_element); } else { widget_field_element.dom_element().append(dom_element); } infopark.gui.new_content(dom_element.get(0)); }) ).then(function() { return widget_field_element.save().then(function() { infopark.ensure_fully_visible_within(dom_element, $('body'), $(window).height()); }); }); } ); }, edit_widget: function(widget_element) { var widget = widget_element.widget(); var dom_element = widget_element.dom_element(); var has_changes = false; var token = infopark.write_monitor.on('start_write', function() { has_changes = true; }); var title = widget.widget_class_name(); var fetch_markup = function() { return widget_element.fetch_edit_markup(); }; return infopark.edit_dialog.open(title, fetch_markup).then(function() { infopark.write_monitor.off(token); if (has_changes) { dom_element.trigger('infopark_reload'); } }); }, delete_widget: function(widget_field_element, widget_element) { return infopark.confirmation_dialog({ icon: '', confirm_button_color: 'ip_red', confirm_button_text: infopark.i18n.translate('menu_bar.delete'), title: infopark.i18n.translate('commands.delete_widget.confirm_title'), description: infopark.i18n.translate('commands.delete_widget.confirm_description') }).then(function() { var widget = widget_element.widget(); widget_element.dom_element().remove(); if(widget_field_element.widget_elements().length === 0){ infopark.inplace_menus.refresh(); } return widget_field_element.save().then(function() { return widget.destroy(); }); }); }, open_in_admin_gui: function(obj_id) { window.open( infopark.admin_gui_base_url + '#' + obj_id + ';dc;' + infopark.gui.workspace().id(), 'admin-gui', // New window has a name, so it can be identified in integration tests. 'status=1,toolbar=1,location=1,menubar=1,scrollbars=1,resizable=1' ); } } }); var paste_obj_not_allowed = function(child_list_element) { var obj_class_name = infopark.clipboard.obj().obj_class_name(); var allowed_classes = _.map(child_list_element.allowed_classes(), function(item) { return ' ' + item; }); var message = infopark.i18n.translate( 'commands.paste.not_allowed', obj_class_name, allowed_classes.join('\n')); infopark.alert(message); }; }()); (function() { $.extend(infopark, { widget_menus: { init: function() { infopark.inplace_menus.define(function(menu) { if (infopark.gui.workspace().is_editable()) { _.each(infopark.widget_field_element.all(), function(widget_field_element) { var widget_elements = widget_field_element.widget_elements(); if (widget_elements.length === 0) { menu.add_item(widget_field_element.dom_element(), { title: infopark.i18n.translate('widget_menus.add_widget'), icon: '\uF022', execute: function() { infopark.commands.add_widget(widget_field_element); } }); } _.each(widget_elements, function(widget_element) { var widget_dom_element = widget_element.dom_element(); menu.add_item(widget_dom_element, { title: infopark.i18n.translate('widget_menus.add_widget'), icon: '\uF022', execute: function() { infopark.commands.add_widget(widget_field_element, widget_element); } }); if (widget_element.has_edit_view()) { menu.add_item(widget_dom_element, { title: infopark.i18n.translate('widget_menus.edit_widget'), icon: '\uF030', execute: function() { infopark.commands.edit_widget(widget_element); } }); } menu.add_item(widget_dom_element, { title: infopark.i18n.translate('widget_menus.delete_widget'), icon: '\uF018', execute: function() { infopark.commands.delete_widget(widget_field_element, widget_element); } }); }); }); } }); } } }); }()); (function() { $.extend(infopark, { widget_reloading: { init: function() { activate_for_all_beneath($('body')); infopark.on('new_content', function(dom_element) { var jquery_object = $(dom_element); if (jquery_object.attr('data-ip-private-widget-id')) { activate_for(jquery_object); } activate_for_all_beneath(jquery_object); }); } } }); var activate_for_all_beneath = function(jquery_object) { _.each(jquery_object.find('[data-ip-private-widget-id]'), function(dom_element) { activate_for($(dom_element)); }); }; var activate_for = function(jquery_object) { jquery_object.on('infopark_reload', function() { var widget_element = infopark.cms_element.from_dom_element(jquery_object); infopark.with_element_overlay(jquery_object, widget_element.fetch_show_markup().then(function(show_markup) { var new_jquery_object = $(show_markup); jquery_object.replaceWith(new_jquery_object); infopark.gui.new_content(new_jquery_object.get(0)); }) ); return false; }); }; }()); (function() { $.extend(infopark, { widget_sorting: { init: function() { infopark.gui.on('editing', create); infopark.gui.on('new_content', create); }, // Called when actual dragging started. activate: function(event, ui) { var marker = ui.item.find('.ip_editing_marker'); $('.ip_editing_marker').not(marker).hide(); infopark.inplace_menus.close_all_menus(); }, // Called when dragging stopped. deactivate: function(event, ui) { $('.ip_editing_marker').show(); infopark.inplace_menus.refresh_positions(); }, // Called when dragging stopped and there has been a position change. update: function(event, ui) { var widget_field_element = infopark.cms_element.from_dom_element(ui.item).widget_field(); widget_field_element.save(); } } }); var create = function() { if (infopark.gui.workspace().is_editable()) { _.each(infopark.widget_field_element.all(), function(widget_field_element) { var dom_element = widget_field_element.dom_element(); if (!dom_element.data('ui-sortable')) { dom_element.sortable({ items: '> [data-ip-private-widget-id]', handle: '> .ip_editing_marker', activate: infopark.widget_sorting.activate, deactivate: infopark.widget_sorting.deactivate, update: infopark.widget_sorting.update }); } }); } }; }()); (function() { $.extend(infopark, { child_list_menus: { init: function() { infopark.inplace_menus.define(function(menu) { if (infopark.gui.workspace().is_editable()) { _.each(infopark.child_list_element.all(), function(child_list_element) { menu.add_item(child_list_element.dom_element(), { title: infopark.i18n.translate('child_list_menus.add_subpage'), icon: '\uF022', execute: function() { infopark.commands.new_child_page(child_list_element); } }); if (!infopark.clipboard.is_empty()) { menu.add_item(child_list_element.dom_element(), { title: infopark.i18n.translate('child_list_menus.move_here'), icon: '\uF016', execute: function() { infopark.commands.move_obj_into(child_list_element); }, disabled: !infopark.clipboard.can_paste_into(child_list_element) }); menu.add_item(child_list_element.dom_element(), { title: infopark.i18n.translate('child_list_menus.copy_here'), icon: '\uF015', execute: function() { infopark.commands.copy_obj_into(child_list_element); }, disabled: !infopark.clipboard.can_paste_into(child_list_element) }); } }); } }); } } }); }()); (function() { $.extend(infopark, { 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.ip_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.ip_hotkeys_add_actions_while'); }); } } }); }()); (function() { $.extend(infopark, { with_dialog_behaviour: function(promise, key_map) { return infopark.with_overlay( infopark.hotkeys.add_actions_while(promise, key_map) ); } }); }()); (function() { $.extend(infopark, { image_upload: { init: function() { infopark.on('editing', function() { activate_for_field_type('linklist'); activate_for_field_type('reference'); }); // Disable DnD for all elements by default to prevent the user // from accidentally opening an image in browser. $('body').on('dragover', function(e) { return false; }); $('body').on('drop', function(e) { return false; }); }, upload_image: function(event, dom_element, field_type) { var data_transfer = event.originalEvent.dataTransfer; if (!data_transfer) { return; } var files = data_transfer.files; if (files.length === 0) { return; } else if (files.length > 1) { infopark.alert(infopark.i18n.translate('image_upload.too_many_files')); dom_element.removeClass('ip_editing_dragover'); return; } var file = files[0]; var create_image = function(file) { var obj_name = file.name.replace(/[^a-z0-9_.$\-]/ig, '-'); var path = '_resources/' + infopark.random_hex() + '/' + obj_name; return infopark.create_obj({blob: file, _path: path, _obj_class: 'Image'}); }; infopark.with_saving_overlay(create_image(file).then(function(data) { var field_value; if (field_type === 'reference') { field_value = data.id; } else if (field_type === 'linklist') { field_value = [{obj_id: data.id}]; } else { $.error('Field type must be "reference" or "linklist".'); } return dom_element.infopark('save', field_value).then(function() { dom_element.trigger('infopark_reload'); }); })); } } }); var activate_for_field_type = function(field_type) { var field_type_selector = 'img[data-ip-field-type=' + field_type + ']'; $('body').on('dragover.image_upload', field_type_selector, function(e) { $(e.target).addClass('ip_editing_dragover'); return false; }); $('body').on('dragleave.image_upload', field_type_selector, function(e) { $(e.target).removeClass('ip_editing_dragover'); return false; }); $('body').on('drop.image_upload', field_type_selector, function(e) { infopark.image_upload.upload_image(e, $(e.target), field_type); return false; }); }; }()); (function() { $.extend(infopark, { editable_workspace_dialog: function() { return infopark.editable_workspace_dialog.open(); } }); $.extend(infopark.editable_workspace_dialog, { open: function() { var view = $(infopark.template.render('editable_workspace_dialog')); $('#ip-editing').append(view); infopark.workspace.all_editable().done(function(workspaces) { var ws_form_select = $(infopark.template.render('workspace_form_select_list', { workspaces: workspaces })); $('.ip_editable_workspace_dialog #ip_replace_with_real_ws').replaceWith(ws_form_select); $('#ip_list_of_ws').focus(); }); var create_new_ws = false; view.on('focus click', '.ip_input_list_of_ws', function(e) { create_new_ws = false; view.find(".ip_confirm").html(infopark.i18n.translate('editable_ws_dialog.select')); view.find(".ip_disabled").removeClass("ip_disabled"); view.find(".ip_input_new_ws_name label, .ip_input_new_ws_name input").addClass("ip_disabled"); }); view.on('focus click drop', '.ip_input_new_ws_name', function(e) { create_new_ws = true; view.find(".ip_confirm").html(infopark.i18n.translate('menu_bar.create')); view.find(".ip_disabled").removeClass("ip_disabled"); view.find(".ip_input_list_of_ws label, .ip_input_list_of_ws select").addClass("ip_disabled"); }); var deferred = $.Deferred(); var confirm_action = function(e) { e.preventDefault(); if (create_new_ws) { var title = $('#ip_new_ws_name').val(); infopark.dialog.close(view); infopark.with_saving_overlay( infopark.workspace.create(title).then(function(new_workspace) { return infopark.redirect_to('?_rc-ws=' + new_workspace.id()); }) ); deferred.resolve(); } else { var ws_id = $('select#ip_list_of_ws').val(); infopark.redirect_to("?_rc-ws=" + ws_id); } }; var cancel_action = function(e) { e.preventDefault(); infopark.dialog.close(view); deferred.reject(); }; view.find('.ip_confirm').on('click', confirm_action); view.find('.ip_cancel').on('click', cancel_action); infopark.transition(view, function() { view.addClass('ip_show'); }); return infopark.with_dialog_behaviour(deferred, { enter: confirm_action, escape: cancel_action }); }, init: function() { infopark.gui.on('open', function(options) { if((options.on_initialize !== true) && !infopark.gui.workspace().is_editable()) { infopark.editable_workspace_dialog.open(); } }); } }); }()); (function() { $.extend(infopark, { warn_before_unloading: function() { if (infopark.write_monitor.is_writing()) { return infopark.i18n.translate('warn_before_unloading'); } } }); }()); (function(){ infopark.clipboard = { save_obj: function(obj) { store_obj(obj); }, is_empty: function() { return !infopark.storage.has_key(storage_key); }, obj: function() { var data = stored_data(); return infopark.obj.create_instance(data.id, data.obj_class_name); }, clear: function() { infopark.storage.remove(storage_key); }, can_paste_into: function(child_list_element) { var allowed_classes = child_list_element.allowed_classes(); if (allowed_classes) { var obj_class_name = stored_data().obj_class_name; return _.contains(allowed_classes, obj_class_name); } else { return true; } } }; var storage_key = 'clipboard'; var store_obj = function(obj) { var data = {id: obj.id(), obj_class_name: obj.obj_class_name()}; infopark.storage.set(storage_key, data); }; var stored_data = function() { var data = infopark.storage.get(storage_key); return data || {}; }; })(); infopark.inplace_menus.init(); infopark.menu_bar_saving_indicator.init(); infopark.menu_bar_toggle.init(); infopark.menu_bar_dropdown.init(); infopark.menu_bar_close.init(); infopark.workspace_select.init(); infopark.menu_bar.init(); infopark.widget_menus.init(); infopark.widget_reloading.init(); infopark.widget_sorting.init(); infopark.image_upload.init(); infopark.child_list_menus.init(); infopark.editable_workspace_dialog.init(); infopark.reloading.init(); window.onbeforeunload = infopark.warn_before_unloading;