/*! * 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/base.js /*jshint eqnull:true*/ this.Handlebars = {}; (function(Handlebars) { Handlebars.VERSION = "1.0.0-rc.3"; Handlebars.COMPILER_REVISION = 2; 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' }; Handlebars.helpers = {}; Handlebars.partials = {}; Handlebars.registerHelper = function(name, fn, inverse) { if(inverse) { fn.not = inverse; } this.helpers[name] = fn; }; Handlebars.registerPartial = function(name, str) { this.partials[name] = str; }; Handlebars.registerHelper('helperMissing', function(arg) { if(arguments.length === 2) { return undefined; } else { throw new Error("Could not find property '" + arg + "'"); } }); var toString = Object.prototype.toString, functionType = "[object Function]"; Handlebars.registerHelper('blockHelperMissing', function(context, options) { var inverse = options.inverse || function() {}, fn = options.fn; var ret = ""; 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 = { 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 ""; } if(!possible.test(string)) { return string; } return string.replace(badChars, escapeChar); }, isEmpty: function(value) { if (!value && value !== 0) { return true; } else if(Object.prototype.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) { return Handlebars.VM.program(fn, data); } else if(programWrapper) { return programWrapper; } else { programWrapper = this.programs[i] = Handlebars.VM.program(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(fn, data, $depth) { var args = Array.prototype.slice.call(arguments, 2); return function(context, options) { options = options || {}; return fn.apply(this, [context, options.data || data].concat(args)); }; }, program: function(fn, data) { return function(context, options) { options = options || {}; return fn(context, options.data || data); }; }, 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; ; /*! * 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; } ; var RELANG = {}; RELANG['de'] = { html: 'HTML', video: 'Video', image: 'Bilder', table: 'Tabelle', link: 'Link', link_insert: 'Link einfügen ...', unlink: 'Link entfernen', formatting: 'Formatvorlagen', paragraph: 'Absatz', quote: 'Zitat', code: 'Code', header1: 'Überschrift 1', header2: 'Überschrift 2', header3: 'Überschrift 3', header4: 'Überschrift 4', bold: 'Fett', italic: 'Kursiv', fontcolor: 'Schriftfarbe', backcolor: 'Texthervorhebungsfarbe', unorderedlist: 'Aufzählungszeichen', orderedlist: 'Nummerierung', outdent: 'Einzug verkleinern', indent: 'Einzug vergrößern', redo: 'Wiederholen', undo: 'Rückgängig', cut: 'Ausschneiden', cancel: 'Abbrechen', insert: 'Einfügen', save: 'Speichern', _delete: 'Löschen', insert_table: 'Tabelle einfügen', insert_row_above: 'Zeile oberhalb einfügen', insert_row_below: 'Zeile unterhalb einfügen', insert_column_left: 'Spalte links einfügen', insert_column_right: 'Spalte rechts einfügen', delete_column: 'Spalte löschen', delete_row: 'Zeile löschen', delete_table: 'Tabelle löschen', rows: 'Zeilen', columns: 'Spalten', add_head: 'Titel einfügen', delete_head: 'Titel entfernen', title: 'Title', image_view: 'Bilder', image_position: 'Textumbruch', none: 'Keine', left: 'Links', right: 'Rechts', image_web_link: 'Bilder Link', text: 'Text', mailto: 'Email', web: 'URL', video_html_code: 'Video-Einbettungscode', file: 'Datei', upload: 'Hochladen', download: 'Download', choose: 'Auswählen', or_choose: 'Oder, wählen Sie eine Datei aus', drop_file_here: 'Ziehen Sie eine Datei hier hin', align_left: 'Linksbündig', align_center: 'Mitte', align_right: 'Rechtsbündig', align_justify: 'Blocksatz', horizontalrule: 'Horizontale Linie', fullscreen: 'Vollbild', deleted: 'Durchgestrichen', anchor: 'Anker', link_new_tab: 'Link in neuem Tab öffnen', underline: 'Unterstrichen', alignment: 'Ausrichtung' }; /* Redactor v8.2.5 Updated: April 2, 2013 http://redactorjs.com/ Copyright (c) 2009-2013, Imperavi Inc. License: http://redactorjs.com/license/ Usage: $('#content').redactor(); */ var rwindow, rdocument; if (typeof RELANG === 'undefined') { var RELANG = {}; } var RLANG = { html: 'HTML', video: 'Insert Video', image: 'Insert Image', table: 'Table', link: 'Link', link_insert: 'Insert link', unlink: 'Unlink', formatting: 'Formatting', paragraph: 'Paragraph', quote: 'Quote', code: 'Code', header1: 'Header 1', header2: 'Header 2', header3: 'Header 3', header4: 'Header 4', bold: 'Bold', italic: 'Italic', fontcolor: 'Font Color', backcolor: 'Back Color', unorderedlist: 'Unordered List', orderedlist: 'Ordered List', outdent: 'Outdent', indent: 'Indent', cancel: 'Cancel', insert: 'Insert', save: 'Save', _delete: 'Delete', insert_table: 'Insert Table', insert_row_above: 'Add Row Above', insert_row_below: 'Add Row Below', insert_column_left: 'Add Column Left', insert_column_right: 'Add Column Right', delete_column: 'Delete Column', delete_row: 'Delete Row', delete_table: 'Delete Table', rows: 'Rows', columns: 'Columns', add_head: 'Add Head', delete_head: 'Delete Head', title: 'Title', image_position: 'Position', none: 'None', left: 'Left', right: 'Right', image_web_link: 'Image Web Link', text: 'Text', mailto: 'Email', web: 'URL', video_html_code: 'Video Embed Code', file: 'Insert File', upload: 'Upload', download: 'Download', choose: 'Choose', or_choose: 'Or choose', drop_file_here: 'Drop file here', align_left: 'Align text to the left', align_center: 'Center text', align_right: 'Align text to the right', align_justify: 'Justify text', horizontalrule: 'Insert Horizontal Rule', deleted: 'Deleted', anchor: 'Anchor', link_new_tab: 'Open link in new tab', underline: 'Underline', alignment: 'Alignment' }; (function($){ // Plugin jQuery.fn.redactor = function(option) { return this.each(function() { var $obj = $(this); var data = $obj.data('redactor'); if (!data) { $obj.data('redactor', (data = new Redactor(this, option))); } }); }; // Initialization var Redactor = function(element, options) { // Element this.$el = $(element); // Lang if (typeof options !== 'undefined' && typeof options.lang !== 'undefined' && options.lang !== 'en' && typeof RELANG[options.lang] !== 'undefined') { RLANG = RELANG[options.lang]; } // Options this.opts = $.extend({ iframe: false, css: false, // url lang: 'en', direction: 'ltr', // ltr or rtl callback: false, // function keyupCallback: false, // function keydownCallback: false, // function execCommandCallback: false, // function plugins: false, cleanup: true, focus: false, tabindex: false, autoresize: true, minHeight: false, fixed: false, fixedTop: 0, // pixels fixedBox: false, source: true, shortcuts: true, mobile: true, air: false, // true or toolbar wym: false, convertLinks: true, convertDivs: true, protocol: 'http://', // for links http or https or ftp or false autosave: false, // false or url autosaveCallback: false, // function interval: 60, // seconds imageGetJson: false, // url (ex. /folder/images.json ) or false imageUpload: false, // url imageUploadCallback: false, // function imageUploadErrorCallback: false, // function fileUpload: false, // url fileUploadCallback: false, // function fileUploadErrorCallback: false, // function uploadCrossDomain: false, uploadFields: false, observeImages: true, overlay: true, // modal overlay allowedTags: ["form", "input", "button", "select", "option", "datalist", "output", "textarea", "fieldset", "legend", "section", "header", "hgroup", "aside", "footer", "article", "details", "nav", "progress", "time", "canvas", "code", "span", "div", "label", "a", "br", "p", "b", "i", "del", "strike", "u", "img", "video", "source", "track", "audio", "iframe", "object", "embed", "param", "blockquote", "mark", "cite", "small", "ul", "ol", "li", "hr", "dl", "dt", "dd", "sup", "sub", "big", "pre", "code", "figure", "figcaption", "strong", "em", "table", "tr", "td", "th", "tbody", "thead", "tfoot", "h1", "h2", "h3", "h4", "h5", "h6"], toolbarExternal: false, // ID selector buttonsCustom: {}, buttonsAdd: [], buttons: ['html', '|', 'formatting', '|', 'bold', 'italic', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'image', 'video', 'file', 'table', 'link', '|', 'fontcolor', 'backcolor', '|', 'alignment', '|', 'horizontalrule'], // 'underline', 'alignleft', 'aligncenter', 'alignright', 'justify' airButtons: ['formatting', '|', 'bold', 'italic', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'fontcolor', 'backcolor'], formattingTags: ['p', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4'], activeButtons: ['deleted', 'italic', 'bold', 'underline', 'unorderedlist', 'orderedlist'], // 'alignleft', 'aligncenter', 'alignright', 'justify' activeButtonsStates: { b: 'bold', strong: 'bold', i: 'italic', em: 'italic', del: 'deleted', strike: 'deleted', ul: 'unorderedlist', ol: 'orderedlist', u: 'underline' }, colors: [ '#ffffff', '#000000', '#eeece1', '#1f497d', '#4f81bd', '#c0504d', '#9bbb59', '#8064a2', '#4bacc6', '#f79646', '#ffff00', '#f2f2f2', '#7f7f7f', '#ddd9c3', '#c6d9f0', '#dbe5f1', '#f2dcdb', '#ebf1dd', '#e5e0ec', '#dbeef3', '#fdeada', '#fff2ca', '#d8d8d8', '#595959', '#c4bd97', '#8db3e2', '#b8cce4', '#e5b9b7', '#d7e3bc', '#ccc1d9', '#b7dde8', '#fbd5b5', '#ffe694', '#bfbfbf', '#3f3f3f', '#938953', '#548dd4', '#95b3d7', '#d99694', '#c3d69b', '#b2a2c7', '#b7dde8', '#fac08f', '#f2c314', '#a5a5a5', '#262626', '#494429', '#17365d', '#366092', '#953734', '#76923c', '#5f497a', '#92cddc', '#e36c09', '#c09100', '#7f7f7f', '#0c0c0c', '#1d1b10', '#0f243e', '#244061', '#632423', '#4f6128', '#3f3151', '#31859b', '#974806', '#7f6000'], // private emptyHtml: '


', buffer: false, visual: true, // modal windows container modal_file: String() + '
' + '
' + '' + '' + '
' + '' + '
' + '

' + '
', modal_image_edit: String() + '
' + '' + '' + '' + '' + '' + '' + '
' + '
', modal_image: String() + '
' + '' + '
' + '
' + '' + '
' + '' + '
' + '' + '
' + '', modal_link: String() + '
' + '
' + '
' + 'URL' + 'Email' + '' + RLANG.anchor + '' + '
' + '' + '
' + '' + '' + '' + '
' + '' + '' + '
' + '
' + '', modal_table: String() + '
' + '' + '' + '' + '' + '
' + '', modal_video: String() + '
' + '
' + '' + '' + '
' + '
'+ '', toolbar: { html: { title: RLANG.html, func: 'toggle' }, formatting: { title: RLANG.formatting, func: 'show', dropdown: { p: { title: RLANG.paragraph, exec: 'formatblock' }, blockquote: { title: RLANG.quote, exec: 'formatblock', className: 'redactor_format_blockquote' }, pre: { title: RLANG.code, exec: 'formatblock', className: 'redactor_format_pre' }, h1: { title: RLANG.header1, exec: 'formatblock', className: 'redactor_format_h1' }, h2: { title: RLANG.header2, exec: 'formatblock', className: 'redactor_format_h2' }, h3: { title: RLANG.header3, exec: 'formatblock', className: 'redactor_format_h3' }, h4: { title: RLANG.header4, exec: 'formatblock', className: 'redactor_format_h4' } } }, bold: { title: RLANG.bold, exec: 'bold' }, italic: { title: RLANG.italic, exec: 'italic' }, deleted: { title: RLANG.deleted, exec: 'strikethrough' }, underline: { title: RLANG.underline, exec: 'underline' }, unorderedlist: { title: '• ' + RLANG.unorderedlist, exec: 'insertunorderedlist' }, orderedlist: { title: '1. ' + RLANG.orderedlist, exec: 'insertorderedlist' }, outdent: { title: '< ' + RLANG.outdent, exec: 'outdent' }, indent: { title: '> ' + RLANG.indent, exec: 'indent' }, image: { title: RLANG.image, func: 'showImage' }, video: { title: RLANG.video, func: 'showVideo' }, file: { title: RLANG.file, func: 'showFile' }, table: { title: RLANG.table, func: 'show', dropdown: { insert_table: { title: RLANG.insert_table, func: 'showTable' }, separator_drop1: { name: 'separator' }, insert_row_above: { title: RLANG.insert_row_above, func: 'insertRowAbove' }, insert_row_below: { title: RLANG.insert_row_below, func: 'insertRowBelow' }, insert_column_left: { title: RLANG.insert_column_left, func: 'insertColumnLeft' }, insert_column_right: { title: RLANG.insert_column_right, func: 'insertColumnRight' }, separator_drop2: { name: 'separator' }, add_head: { title: RLANG.add_head, func: 'addHead' }, delete_head: { title: RLANG.delete_head, func: 'deleteHead' }, separator_drop3: { name: 'separator' }, delete_column: { title: RLANG.delete_column, func: 'deleteColumn' }, delete_row: { title: RLANG.delete_row, func: 'deleteRow' }, delete_table: { title: RLANG.delete_table, func: 'deleteTable' } } }, link: { title: RLANG.link, func: 'show', dropdown: { link: { title: RLANG.link_insert, func: 'showLink' }, unlink: { title: RLANG.unlink, exec: 'unlink' } } }, fontcolor: { title: RLANG.fontcolor, func: 'show' }, backcolor: { title: RLANG.backcolor, func: 'show' }, alignment: { title: RLANG.alignment, func: 'show', dropdown: { alignleft: { title: RLANG.align_left, exec: 'JustifyLeft' }, aligncenter: { title: RLANG.align_center, exec: 'JustifyCenter' }, alignright: { title: RLANG.align_right, exec: 'JustifyRight' }, justify: { title: RLANG.align_justify, exec: 'JustifyFull' } } }, alignleft: { exec: 'JustifyLeft', title: RLANG.align_left }, aligncenter: { exec: 'JustifyCenter', title: RLANG.align_center }, alignright: { exec: 'JustifyRight', title: RLANG.align_right }, justify: { exec: 'JustifyFull', title: RLANG.align_justify }, horizontalrule: { exec: 'inserthorizontalrule', title: RLANG.horizontalrule } } }, options, this.$el.data()); this.dropdowns = []; // Init this.init(); }; // Functionality Redactor.prototype = { // Initialization init: function() { // get dimensions this.height = this.$el.css('height'); this.width = this.$el.css('width'); rdocument = this.document = document; rwindow = this.window = window; // mobile if (this.opts.mobile === false && this.isMobile()) { this.build(true); return false; } // iframe if (this.opts.iframe) { this.opts.autoresize = false; } // extend buttons if (this.opts.air) { this.opts.buttons = this.opts.airButtons; } else if (this.opts.toolbar !== false) { if (this.opts.source === false) { var index = this.opts.buttons.indexOf('html'); var next = this.opts.buttons[index+1]; this.opts.buttons.splice(index, 1); if (typeof next !== 'undefined' && next === '|') { this.opts.buttons.splice(index, 1); } } $.extend(this.opts.toolbar, this.opts.buttonsCustom); $.each(this.opts.buttonsAdd, $.proxy(function(i,s) { this.opts.buttons.push(s); }, this)); } // formatting tags if (this.opts.toolbar !== false) { $.each(this.opts.toolbar.formatting.dropdown, $.proxy(function(i,s) { if ($.inArray(i, this.opts.formattingTags) == '-1') { delete this.opts.toolbar.formatting.dropdown[i]; } }, this)); } function afterBuild() { // air enable this.enableAir(); // toolbar this.buildToolbar(); // PLUGINS if (typeof this.opts.plugins === 'object') { $.each(this.opts.plugins, $.proxy(function(i,s) { if (typeof RedactorPlugins[s] !== 'undefined') { $.extend(this, RedactorPlugins[s]); if (typeof RedactorPlugins[s].init !== 'undefined') { this.init(); } } }, this)); } // buttons response if (this.opts.activeButtons !== false && this.opts.toolbar !== false) { var observeFormatting = $.proxy(function() { this.observeFormatting(); }, this); this.$editor.click(observeFormatting).keyup(observeFormatting); } // paste var oldsafari = false; if (this.browser('webkit') && navigator.userAgent.indexOf('Chrome') === -1) { var arr = this.browser('version').split('.'); if (arr[0] < 536) oldsafari = true; } if (this.isMobile(true) === false && oldsafari === false && this.browser('opera') === false) { this.$editor.bind('paste', $.proxy(function(e) { if (this.opts.cleanup === false) { return true; } this.pasteRunning = true; this.setBuffer(); if (this.opts.autoresize === true) { this.saveScroll = this.document.body.scrollTop; } else { this.saveScroll = this.$editor.scrollTop(); } var frag = this.extractContent(); setTimeout($.proxy(function() { var pastedFrag = this.extractContent(); this.$editor.append(frag); this.restoreSelection(); var html = this.getFragmentHtml(pastedFrag); this.pasteCleanUp(html); this.pasteRunning = false; }, this), 1); }, this)); } // key handlers this.keyup(); this.keydown(); // autosave if (this.opts.autosave !== false) { this.autoSave(); } // observers setTimeout($.proxy(function() { this.observeImages(); this.observeTables(); }, this), 1); // FF fix if (this.browser('mozilla')) { this.$editor.click($.proxy(function() { this.saveSelection(); }, this)); try { this.document.execCommand('enableObjectResizing', false, false); this.document.execCommand('enableInlineTableEditing', false, false); } catch (e) {} } // focus if (this.opts.focus) { setTimeout($.proxy(function(){ this.$editor.focus(); }, this), 1); } // fixed if (this.opts.fixed) { this.observeScroll(); $(document).scroll($.proxy(this.observeScroll, this)); } // callback if (typeof this.opts.callback === 'function') { this.opts.callback(this); } if (this.opts.toolbar !== false) { this.$toolbar.find('a').attr('tabindex', '-1'); } } // construct editor this.build(false, afterBuild); }, shortcuts: function(e, cmd) { e.preventDefault(); this.execCommand(cmd, false); }, keyup: function() { this.$editor.keyup($.proxy(function(e) { var key = e.keyCode || e.which; if (this.browser('mozilla') && !this.pasteRunning) { this.saveSelection(); } // callback as you type if (typeof this.opts.keyupCallback === 'function') { this.opts.keyupCallback(this, e); } // if empty if (key === 8 || key === 46) { this.observeImages(); return this.formatEmpty(e); } // new line p if (key === 13 && !e.shiftKey && !e.ctrlKey && !e.metaKey) { if (this.browser('webkit')) { this.formatNewLine(e); } // convert links if (this.opts.convertLinks) { this.$editor.linkify(); } } this.syncCode(); }, this)); }, keydown: function() { this.$editor.keydown($.proxy(function(e) { var key = e.keyCode || e.which; var parent = this.getParentNode(); var current = this.getCurrentNode(); var pre = false; var ctrl = e.ctrlKey || e.metaKey; if ((parent || current) && ($(parent).get(0).tagName === 'PRE' || $(current).get(0).tagName === 'PRE')) { pre = true; } // callback keydown if (typeof this.opts.keydownCallback === 'function') { this.opts.keydownCallback(this, e); } if (ctrl && this.opts.shortcuts) { if (key === 90) { if (this.opts.buffer !== false) { e.preventDefault(); this.getBuffer(); } else if (e.shiftKey) { this.shortcuts(e, 'redo'); // Ctrl + Shift + z } else { this.shortcuts(e, 'undo'); // Ctrl + z } } else if (key === 77) { this.shortcuts(e, 'removeFormat'); // Ctrl + m } else if (key === 66) { this.shortcuts(e, 'bold'); // Ctrl + b } else if (key === 73) { this.shortcuts(e, 'italic'); // Ctrl + i } else if (key === 74) { this.shortcuts(e, 'insertunorderedlist'); // Ctrl + j } else if (key === 75) { this.shortcuts(e, 'insertorderedlist'); // Ctrl + k } else if (key === 76) { this.shortcuts(e, 'superscript'); // Ctrl + l } else if (key === 72) { this.shortcuts(e, 'subscript'); // Ctrl + h } } // clear undo buffer if (!ctrl && key !== 90) { this.opts.buffer = false; } // enter if (pre === true && key === 13) { e.preventDefault(); var html = $(current).parent().text(); this.insertNodeAtCaret(this.document.createTextNode('\r\n')); if (html.search(/\s$/) == -1) { this.insertNodeAtCaret(this.document.createTextNode('\r\n')); } this.syncCode(); return false; } // tab if (this.opts.shortcuts && !e.shiftKey && key === 9) { if (pre === false) { this.shortcuts(e, 'indent'); // Tab } else { e.preventDefault(); this.insertNodeAtCaret(this.document.createTextNode('\t')); this.syncCode(); return false; } } else if (this.opts.shortcuts && e.shiftKey && key === 9 ) { this.shortcuts(e, 'outdent'); // Shift + tab } // safari shift key + enter if (this.browser('webkit') && navigator.userAgent.indexOf('Chrome') === -1) { return this.safariShiftKeyEnter(e, key); } }, this)); }, build: function(mobile, whendone) { if (mobile !== true) { // container this.$box = $('
'); // air box if (this.opts.air) { this.air = $(''); } this.$content = null; function initFrame() { this.$editor = this.$content.contents().find("body").attr('contenteditable', true).attr('dir', this.opts.direction); rdocument = this.document = this.$editor[0].ownerDocument; rwindow = this.window = this.document.defaultView || window; if (this.opts.css !== false) { this.$content.contents().find('head').append(''); } this.$editor.html(html); if (whendone) { whendone.call(this); whendone = null; } } // editor this.textareamode = true; if (this.$el.get(0).tagName === 'TEXTAREA') { if(this.opts.iframe) { var me = this; this.$content = $('').load(function() { initFrame.call(me); }); } else { this.$content = this.$editor = $('
'); } var classlist = this.$el.get(0).className.split(/\s+/); $.each(classlist, $.proxy(function(i,s) { this.$content.addClass('redactor_' + s); }, this)); } else { this.textareamode = false; this.$content = this.$editor = this.$el; this.$el = $('').css('height', this.height); } if (this.$editor) { this.$editor.addClass('redactor_editor').attr('contenteditable', true).attr('dir', this.opts.direction); } if (this.opts.tabindex !== false) { this.$content.attr('tabindex', this.opts.tabindex); } if (this.opts.minHeight !== false) { this.$content.css('min-height', this.opts.minHeight + 'px'); } if (this.opts.wym === true) { this.$content.addClass('redactor_editor_wym'); } if (this.opts.autoresize === false) { this.$content.css('height', this.height); } // hide textarea this.$el.hide(); // append box and frame var html = ''; if (this.textareamode) { // get html html = this.$el.val(); html = this.savePreCode(html); this.$box.insertAfter(this.$el).append(this.$content).append(this.$el); } else { // get html html = this.$editor.html(); html = this.savePreCode(html); this.$box.insertAfter(this.$content).append(this.$el).append(this.$editor); } // conver newlines to p html = this.paragraphy(html); // enable if (this.$editor) { this.$editor.html(html); } if (this.textareamode === false) { this.syncCode(); } } else { if (this.$el.get(0).tagName !== 'TEXTAREA') { var html = this.$el.val(); var textarea = $('').css('height', this.height).val(html); this.$el.hide(); this.$el.after(textarea); } } if (whendone && this.$editor) { whendone.call(this); } }, enableAir: function() { if (this.opts.air === false) { return false; } this.air.hide(); this.$editor.bind('textselect', $.proxy(function(e) { this.showAir(e); }, this)); this.$editor.bind('textunselect', $.proxy(function() { this.air.hide(); }, this)); }, showAir: function(e) { $('.redactor_air').hide(); var width = this.air.innerWidth(); var left = e.clientX; if ($(this.document).width() < (left + width)) { left = left - width; } var top = e.clientY + $(document).scrollTop() + 14; if (this.opts.iframe === true) { top = top + this.$box.position().top; left = left + this.$box.position().left; } this.air.css({ left: left + 'px', top: top + 'px' }).show(); }, syncCode: function() { this.$el.val(this.$editor.html()); }, // API functions setCode: function(html) { html = this.stripTags(html); this.$editor.html(html).focus(); this.syncCode(); }, getCode: function() { var html = ''; if (this.opts.visual) { html = this.$editor.html() } else { html = this.$el.val(); } return this.stripTags(html); }, insertHtml: function(html) { this.$editor.focus(); this.pasteHtmlAtCaret(html); this.observeImages(); this.syncCode(); }, pasteHtmlAtCaret: function (html) { var sel, range; if (this.document.getSelection) { sel = this.window.getSelection(); if (sel.getRangeAt && sel.rangeCount) { range = sel.getRangeAt(0); range.deleteContents(); var el = this.document.createElement("div"); el.innerHTML = html; var frag = this.document.createDocumentFragment(), node, lastNode; while (node = el.firstChild) { lastNode = frag.appendChild(node); } range.insertNode(frag); if (lastNode) { range = range.cloneRange(); range.setStartAfter(lastNode); range.collapse(true); sel.removeAllRanges(); sel.addRange(range); } } } else if (this.document.selection && this.document.selection.type != "Control") { this.document.selection.createRange().pasteHTML(html); } }, destroy: function() { var html = this.getCode(); if (this.textareamode) { this.$box.after(this.$el); this.$box.remove(); this.$el.height(this.height).val(html).show(); } else { this.$box.after(this.$editor); this.$box.remove(); this.$editor.removeClass('redactor_editor').removeClass('redactor_editor_wym').attr('contenteditable', false).html(html).show(); } if (this.opts.toolbarExternal) { $(this.opts.toolbarExternal).empty(); } $('.redactor_air').remove(); for (var i = 0; i < this.dropdowns.length; i++) { this.dropdowns[i].remove(); delete(this.dropdowns[i]); } if (this.opts.autosave !== false) { clearInterval(this.autosaveInterval); } }, // end API functions // OBSERVERS observeFormatting: function() { var parent = this.getCurrentNode(); this.inactiveAllButtons(); $.each(this.opts.activeButtonsStates, $.proxy(function(i,s) { if ($(parent).closest(i,this.$editor.get()[0]).length != 0) { this.setBtnActive(s); } }, this)); var tag = $(parent).closest(['p', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'td']); if (typeof tag[0] !== 'undefined' && typeof tag[0].elem !== 'undefined' && $(tag[0].elem).size() != 0) { var align = $(tag[0].elem).css('text-align'); switch (align) { case 'right': this.setBtnActive('alignright'); break; case 'center': this.setBtnActive('aligncenter'); break; case 'justify': this.setBtnActive('justify'); break; default: this.setBtnActive('alignleft'); break; } } }, observeImages: function() { if (this.opts.observeImages === false) { return false; } this.$editor.find('img').each($.proxy(function(i,s) { if (this.browser('msie')) { $(s).attr('unselectable', 'on'); } this.resizeImage(s); }, this)); }, observeTables: function() { this.$editor.find('table').click($.proxy(this.tableObserver, this)); }, observeScroll: function() { var scrolltop = $(this.document).scrollTop(); var boxtop = this.$box.offset().top; var left = 0; if (scrolltop > boxtop) { var width = '100%'; if (this.opts.fixedBox) { left = this.$box.offset().left; width = this.$box.innerWidth(); } this.fixed = true; this.$toolbar.css({ position: 'fixed', width: width, zIndex: 1005, top: this.opts.fixedTop + 'px', left: left }); } else { this.fixed = false; this.$toolbar.css({ position: 'relative', width: 'auto', zIndex: 1, top: 0, left: left }); } }, // BUFFER setBuffer: function() { this.saveSelection(); this.opts.buffer = this.$editor.html(); }, getBuffer: function() { if (this.opts.buffer === false) { return false; } this.$editor.html(this.opts.buffer); if (!this.browser('msie')) { this.restoreSelection(); } this.opts.buffer = false; }, // EXECCOMMAND execCommand: function(cmd, param) { if (this.opts.visual == false) { this.$el.focus(); return false; } try { var parent; if (cmd === 'inserthtml') { if (this.browser('msie')) { this.$editor.focus(); this.document.selection.createRange().pasteHTML(param); } else { this.pasteHtmlAtCaret(param); //this.execRun(cmd, param); } this.observeImages(); } else if (cmd === 'unlink') { parent = this.getParentNode(); if ($(parent).get(0).tagName === 'A') { $(parent).replaceWith($(parent).text()); } else { this.execRun(cmd, param); } } else if (cmd === 'JustifyLeft' || cmd === 'JustifyCenter' || cmd === 'JustifyRight' || cmd === 'JustifyFull') { parent = this.getCurrentNode(); var tag = $(parent).get(0).tagName; if (this.opts.iframe === false && $(parent).parents('.redactor_editor').size() == 0) { return false; } var tagsArray = ['P', 'DIV', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'BLOCKQUOTE', 'TD']; if ($.inArray(tag, tagsArray) != -1) { var align = false; if (cmd === 'JustifyCenter') { align = 'center'; } else if (cmd === 'JustifyRight') { align = 'right'; } else if (cmd === 'JustifyFull') { align = 'justify'; } if (align === false) { $(parent).css('text-align', ''); } else { $(parent).css('text-align', align); } } else { this.execRun(cmd, param); } } else if (cmd === 'formatblock' && param === 'blockquote') { parent = this.getCurrentNode(); if ($(parent).get(0).tagName === 'BLOCKQUOTE') { if (this.browser('msie')) { var node = $('

' + $(parent).html() + '

'); $(parent).replaceWith(node); } else { this.execRun(cmd, 'p'); } } else if ($(parent).get(0).tagName === 'P') { var parent2 = $(parent).parent(); if ($(parent2).get(0).tagName === 'BLOCKQUOTE') { var node = $('

' + $(parent).html() + '

'); $(parent2).replaceWith(node); this.setSelection(node[0], 0, node[0], 0); } else { if (this.browser('msie')) { var node = $('
' + $(parent).html() + '
'); $(parent).replaceWith(node); } else { this.execRun(cmd, param); } } } else { this.execRun(cmd, param); } } else if (cmd === 'formatblock' && (param === 'pre' || param === 'p')) { parent = this.getParentNode(); if ($(parent).get(0).tagName === 'PRE') { $(parent).replaceWith('

' + this.encodeEntities($(parent).text()) + '

'); } else { this.execRun(cmd, param); } } else { if (cmd === 'inserthorizontalrule' && this.browser('msie')) { this.$editor.focus(); } if (cmd === 'formatblock' && this.browser('mozilla')) { this.$editor.focus(); } this.execRun(cmd, param); } if (cmd === 'inserthorizontalrule') { this.$editor.find('hr').removeAttr('id'); } this.syncCode(); if (this.oldIE()) { this.$editor.focus(); } if (typeof this.opts.execCommandCallback === 'function') { this.opts.execCommandCallback(this, cmd); } if (this.opts.air) { this.air.hide(); } } catch (e) { } }, execRun: function(cmd, param) { if (cmd === 'formatblock' && this.browser('msie')) { param = '<' + param + '>'; } this.document.execCommand(cmd, false, param); }, // FORMAT NEW LINE formatNewLine: function(e) { var parent = this.getParentNode(); if (parent.nodeName === 'DIV' && parent.className === 'redactor_editor') { var element = $(this.getCurrentNode()); if (element.get(0).tagName === 'DIV' && (element.html() === '' || element.html() === '
')) { var newElement = $('

').append(element.clone().get(0).childNodes); element.replaceWith(newElement); newElement.html('
'); this.setSelection(newElement[0], 0, newElement[0], 0); } } }, // SAFARI SHIFT KEY + ENTER safariShiftKeyEnter: function(e, key) { if (e.shiftKey && key === 13) { e.preventDefault(); this.insertNodeAtCaret($('
').get(0)); this.syncCode(); return false; } else { return true; } }, // FORMAT EMPTY formatEmpty: function(e) { var html = $.trim(this.$editor.html()); html = html.replace(//i, ''); var thtml = html.replace(/

\s?<\/p>/gi, ''); if (html === '' || thtml === '') { e.preventDefault(); var node = $(this.opts.emptyHtml).get(0); this.$editor.html(node); this.setSelection(node, 0, node, 0); this.syncCode(); return false; } else { this.syncCode(); } }, // PARAGRAPHY paragraphy: function (str) { str = $.trim(str); if (str === '' || str === '

') { return this.opts.emptyHtml; } // convert div to p if (this.opts.convertDivs) { str = str.replace(/([\w\W]*?)<\/div>/gi, '

$2

'); } // inner functions var X = function(x, a, b) { return x.replace(new RegExp(a, 'g'), b); }; var R = function(a, b) { return X(str, a, b); }; // block elements var blocks = '(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|object|input|param|p|h[1-6])'; //str = '

' + str; str += '\n'; R('
\\s*
', '\n\n'); R('(<' + blocks + '[^>]*>)', '\n$1'); R('()', '$1\n\n'); R('\r\n|\r', '\n'); // newlines R('\n\n+', '\n\n'); // remove duplicates R('\n?((.|\n)+?)$', '

$1

\n'); // including one at the end R('

\\s*?

', ''); // remove empty p R('

(]*>\\s*)', '$1

'); R('

([^<]+)\\s*?(]*>)', '

$1

$2'); R('

\\s*(]*>)\\s*

', '$1'); R('

(', '$1'); R('

\\s*(]*>)', '$1'); R('(]*>)\\s*

', '$1'); R('(]*>)\\s*
', '$1'); R('
(\\s*]*>)', '$1'); // pre if (str.indexOf(')((.|\n)*?)', function(m0, m1, m2, m3) { return X(m1, '\\\\([\'\"\\\\])', '$1') + X(X(X(m3, '

', '\n'), '

|
', ''), '\\\\([\'\"\\\\])', '$1') + ''; }); } return R('\n

$', '

'); }, // REMOVE TAGS stripTags: function(html) { var allowed = this.opts.allowedTags; var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi; return html.replace(tags, function ($0, $1) { return $.inArray($1.toLowerCase(), allowed) > '-1' ? $0 : ''; }); }, savePreCode: function(html) { var pre = html.match(/([\w\W]*?)<\/pre>/gi); if (pre !== null) { $.each(pre, $.proxy(function(i,s) { var arr = s.match(/([\w\W]*?)<\/pre>/i); arr[2] = this.encodeEntities(arr[2]); html = html.replace(s, '' + arr[2] + ''); }, this)); } return html; }, encodeEntities: function(str) { str = String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); return String(str).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); }, cleanupPre: function(s) { s = s.replace(/
/gi, '\n'); s = s.replace(/<\/p>/gi, '\n'); s = s.replace(/<\/div>/gi, '\n'); var tmp = this.document.createElement("div"); tmp.innerHTML = s; return tmp.textContent||tmp.innerText; }, // PASTE CLEANUP pasteCleanUp: function(html) { var parent = this.getParentNode(); // clean up pre if ($(parent).get(0).tagName === 'PRE') { html = this.cleanupPre(html); this.pasteCleanUpInsert(html); return true; } // remove comments and php tags html = html.replace(/|<\?(?:php)?[\s\S]*?\?>/gi, ''); // remove nbsp html = html.replace(/( ){2,}/gi, ' '); // remove google docs marker html = html.replace(/([\w\W]*?)<\/b>/gi, "$2"); // strip tags html = this.stripTags(html); // prevert html = html.replace(/<\/td>/gi, '[td]'); html = html.replace(/ <\/td>/gi, '[td]'); html = html.replace(/
<\/td>/gi, '[td]'); html = html.replace(/([\w\W]*?)<\/a>/gi, '[a href="$2"]$4[/a]'); html = html.replace(/([\w\W]*?)<\/iframe>/gi, '[iframe$1]$2[/iframe]'); html = html.replace(/([\w\W]*?)<\/video>/gi, '[video$1]$2[/video]'); html = html.replace(/([\w\W]*?)<\/audio>/gi, '[audio$1]$2[/audio]'); html = html.replace(/([\w\W]*?)<\/embed>/gi, '[embed$1]$2[/embed]'); html = html.replace(/([\w\W]*?)<\/object>/gi, '[object$1]$2[/object]'); html = html.replace(//gi, '[param$1]'); html = html.replace(//gi, '[img$1$3]'); // remove attributes html = html.replace(/<(\w+)([\w\W]*?)>/gi, '<$1>'); // remove empty html = html.replace(/<[^\/>][^>]*>(\s*|\t*|\n*| |
)<\/[^>]+>/gi, ''); html = html.replace(/<[^\/>][^>]*>(\s*|\t*|\n*| |
)<\/[^>]+>/gi, ''); // revert html = html.replace(/\[td\]/gi, ' '); html = html.replace(/\[a href="(.*?)"\]([\w\W]*?)\[\/a\]/gi, '$2'); html = html.replace(/\[iframe(.*?)\]([\w\W]*?)\[\/iframe\]/gi, '$2'); html = html.replace(/\[video(.*?)\]([\w\W]*?)\[\/video\]/gi, '$2'); html = html.replace(/\[audio(.*?)\]([\w\W]*?)\[\/audio\]/gi, '$2'); html = html.replace(/\[embed(.*?)\]([\w\W]*?)\[\/embed\]/gi, '$2'); html = html.replace(/\[object(.*?)\]([\w\W]*?)\[\/object\]/gi, '$2'); html = html.replace(/\[param(.*?)\]/gi, ''); html = html.replace(/\[img(.*?)\]/gi, ''); // convert div to p if (this.opts.convertDivs) { html = html.replace(/([\w\W]*?)<\/div>/gi, '

$2

'); } // remove span html = html.replace(/([\w\W]*?)<\/span>/gi, '$1'); html = html.replace(/\n{3,}/gi, '\n'); // remove dirty p html = html.replace(/

/gi, '

'); html = html.replace(/<\/p><\/p>/gi, '

'); // FF fix if (this.browser('mozilla')) { html = html.replace(/
$/gi, ''); } this.pasteCleanUpInsert(html); }, pasteCleanUpInsert: function(html) { this.execCommand('inserthtml', html); if (this.opts.autoresize === true) { $(this.document.body).scrollTop(this.saveScroll); } else { this.$editor.scrollTop(this.saveScroll); } }, // TEXTAREA CODE FORMATTING formattingRemove: function(html) { // save pre var prebuffer = []; var pre = html.match(/([\w\W]*?)<\/pre>/gi); if (pre !== null) { $.each(pre, function(i,s) { html = html.replace(s, 'prebuffer_' + i); prebuffer.push(s); }); } html = html.replace(/\s{2,}/g, ' '); html = html.replace(/\n/g, ' '); html = html.replace(/[\t]*/g, ''); html = html.replace(/\n\s*\n/g, "\n"); html = html.replace(/^[\s\n]*/g, ''); html = html.replace(/[\s\n]*$/g, ''); html = html.replace(/>\s+<'); if (prebuffer) { $.each(prebuffer, function(i,s) { html = html.replace('prebuffer_' + i, s); }); prebuffer = []; } return html; }, formattingIndenting: function(html) { html = html.replace(/
  • /g, "\t"); return html; }, formattingEmptyTags: function(html) { var etags = ["
    ","
    \\s*
    ","\\s*","
      ","
        ","
      1. ","
        ","","\\s*", " ", "\\s*", " ", "

        \\s*

        ", "

         

        ", "

        \\s*
        \\s*

        ", "
        \\s*
        ", "
        \\s*
        \\s*
        "]; for (var i = 0; i < etags.length; ++i) { var bbb = etags[i]; html = html.replace(new RegExp(bbb,'gi'), ""); } return html; }, formattingAddBefore: function(html) { var lb = '\r\n'; var btags = ["", '', "","', '
        ', '', '', '', '', '', '', '
        ', '
        ', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']; for (var i = 0; i < atags.length; ++i) { var aaa = atags[i]; html = html.replace(new RegExp(aaa,'gi'),aaa+lb); } return html; }, formatting: function(html) { html = this.formattingRemove(html); // empty tags html = this.formattingEmptyTags(html); // add formatting before html = this.formattingAddBefore(html); // add formatting after html = this.formattingAddAfter(html); // indenting html = this.formattingIndenting(html); return html; }, // TOGGLE toggle: function() { var html; if (this.opts.visual) { var height = this.$editor.innerHeight(); this.$editor.hide(); this.$content.hide(); html = this.$editor.html(); //html = $.trim(this.formatting(html)); this.$el.height(height).val(html).show().focus(); this.setBtnActive('html'); this.opts.visual = false; } else { this.$el.hide(); var html = this.$el.val(); //html = this.savePreCode(html); // clean up //html = this.stripTags(html); // set code this.$editor.html(html).show(); this.$content.show(); if (this.$editor.html() === '') { this.setCode(this.opts.emptyHtml); } this.$editor.focus(); this.setBtnInactive('html'); this.opts.visual = true; this.observeImages(); this.observeTables(); } }, // AUTOSAVE autoSave: function() { this.autosaveInterval = setInterval($.proxy(function() { $.ajax({ url: this.opts.autosave, type: 'post', data: this.$el.attr('name') + '=' + escape(encodeURIComponent(this.getCode())), success: $.proxy(function(data) { // callback if (typeof this.opts.autosaveCallback === 'function') { this.opts.autosaveCallback(data, this); } }, this) }); }, this), this.opts.interval*1000); }, // TOOLBAR buildToolbar: function() { if (this.opts.toolbar === false) { return false; } this.$toolbar = $('